]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
Merge tag 'for-linus-20180616' of git://git.kernel.dk/linux-block
authorLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Jun 2018 20:37:55 +0000 (05:37 +0900)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 16 Jun 2018 20:37:55 +0000 (05:37 +0900)
Pull block fixes from Jens Axboe:
 "A collection of fixes that should go into -rc1. This contains:

   - bsg_open vs bsg_unregister race fix (Anatoliy)

   - NVMe pull request from Christoph, with fixes for regressions in
     this window, FC connect/reconnect path code unification, and a
     trace point addition.

   - timeout fix (Christoph)

   - remove a few unused functions (Christoph)

   - blk-mq tag_set reinit fix (Roman)"

* tag 'for-linus-20180616' of git://git.kernel.dk/linux-block:
  bsg: fix race of bsg_open and bsg_unregister
  block: remov blk_queue_invalidate_tags
  nvme-fabrics: fix and refine state checks in __nvmf_check_ready
  nvme-fabrics: handle the admin-only case properly in nvmf_check_ready
  nvme-fabrics: refactor queue ready check
  blk-mq: remove blk_mq_tagset_iter
  nvme: remove nvme_reinit_tagset
  nvme-fc: fix nulling of queue data on reconnect
  nvme-fc: remove reinit_request routine
  blk-mq: don't time out requests again that are in the timeout handler
  nvme-fc: change controllers first connect to use reconnect path
  nvme: don't rely on the changed namespace list log
  nvmet: free smart-log buffer after use
  nvme-rdma: fix error flow during mapping request data
  nvme: add bio remapping tracepoint
  nvme: fix NULL pointer dereference in nvme_init_subsystem
  blk-mq: reinit q->tag_set_list entry only after grace period

3427 files changed:
Documentation/ABI/obsolete/sysfs-gpio
Documentation/ABI/testing/sysfs-bus-rpmsg
Documentation/ABI/testing/sysfs-devices-system-cpu
Documentation/ABI/testing/sysfs-fs-f2fs
Documentation/ABI/testing/sysfs-platform-ideapad-laptop
Documentation/acpi/method-customizing.txt
Documentation/admin-guide/LSM/apparmor.rst
Documentation/admin-guide/kernel-parameters.txt
Documentation/arm/OMAP/README
Documentation/crypto/crypto_engine.rst
Documentation/device-mapper/writecache.txt [new file with mode: 0644]
Documentation/devicetree/bindings/arm/amlogic.txt
Documentation/devicetree/bindings/arm/bcm/brcm,bcm2835.txt
Documentation/devicetree/bindings/arm/samsung/samsung-boards.txt
Documentation/devicetree/bindings/arm/shmobile.txt
Documentation/devicetree/bindings/arm/tegra/nvidia,tegra30-mc.txt [deleted file]
Documentation/devicetree/bindings/bus/ti-sysc.txt
Documentation/devicetree/bindings/clock/amlogic,gxbb-clkc.txt
Documentation/devicetree/bindings/clock/st/st,clkgen.txt
Documentation/devicetree/bindings/clock/ti/gate.txt
Documentation/devicetree/bindings/clock/ti/interface.txt
Documentation/devicetree/bindings/cpufreq/cpufreq-mediatek.txt
Documentation/devicetree/bindings/devfreq/rk3399_dmc.txt
Documentation/devicetree/bindings/display/bridge/tda998x.txt
Documentation/devicetree/bindings/firmware/qcom,scm.txt
Documentation/devicetree/bindings/gpu/arm,mali-midgard.txt
Documentation/devicetree/bindings/gpu/arm,mali-utgard.txt
Documentation/devicetree/bindings/i2c/i2c-davinci.txt
Documentation/devicetree/bindings/i2c/i2c-rcar.txt
Documentation/devicetree/bindings/i2c/i2c-s3c2410.txt
Documentation/devicetree/bindings/input/mtk-pmic-keys.txt [new file with mode: 0644]
Documentation/devicetree/bindings/input/rmi4/rmi_2d_sensor.txt
Documentation/devicetree/bindings/input/rotary-encoder.txt
Documentation/devicetree/bindings/leds/backlight/pwm-backlight.txt
Documentation/devicetree/bindings/leds/backlight/zii,rave-sp-backlight.txt [new file with mode: 0644]
Documentation/devicetree/bindings/media/stih407-c8sectpfe.txt
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra20-mc.txt
Documentation/devicetree/bindings/memory-controllers/nvidia,tegra30-mc.txt
Documentation/devicetree/bindings/mfd/arizona.txt
Documentation/devicetree/bindings/mfd/as3722.txt
Documentation/devicetree/bindings/mfd/da9063.txt
Documentation/devicetree/bindings/mfd/motorola-cpcap.txt
Documentation/devicetree/bindings/mfd/mt6397.txt
Documentation/devicetree/bindings/mfd/qcom,spmi-pmic.txt
Documentation/devicetree/bindings/mfd/stm32-timers.txt
Documentation/devicetree/bindings/mfd/sun6i-prcm.txt
Documentation/devicetree/bindings/mmc/exynos-dw-mshc.txt
Documentation/devicetree/bindings/mmc/microchip,sdhci-pic32.txt
Documentation/devicetree/bindings/mmc/sdhci-st.txt
Documentation/devicetree/bindings/net/dsa/ksz.txt
Documentation/devicetree/bindings/net/dsa/mt7530.txt
Documentation/devicetree/bindings/nvmem/allwinner,sunxi-sid.txt
Documentation/devicetree/bindings/nvmem/zii,rave-sp-eeprom.txt
Documentation/devicetree/bindings/pci/hisilicon-pcie.txt
Documentation/devicetree/bindings/pci/kirin-pcie.txt
Documentation/devicetree/bindings/pci/pci-keystone.txt
Documentation/devicetree/bindings/pinctrl/pinctrl-max77620.txt
Documentation/devicetree/bindings/pinctrl/pinctrl-mcp23s08.txt
Documentation/devicetree/bindings/pinctrl/pinctrl-rk805.txt
Documentation/devicetree/bindings/power/fsl,imx-gpc.txt
Documentation/devicetree/bindings/power/pd-samsung.txt
Documentation/devicetree/bindings/power/power_domain.txt
Documentation/devicetree/bindings/power/renesas,rcar-sysc.txt
Documentation/devicetree/bindings/power/supply/ab8500/btemp.txt
Documentation/devicetree/bindings/power/supply/ab8500/chargalg.txt
Documentation/devicetree/bindings/power/supply/ab8500/charger.txt
Documentation/devicetree/bindings/power/wakeup-source.txt
Documentation/devicetree/bindings/remoteproc/qcom,q6v5.txt
Documentation/devicetree/bindings/reserved-memory/qcom,cmd-db.txt [new file with mode: 0644]
Documentation/devicetree/bindings/reset/renesas,rst.txt
Documentation/devicetree/bindings/rng/brcm,bcm2835.txt
Documentation/devicetree/bindings/serial/microchip,pic32-uart.txt
Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt [new file with mode: 0644]
Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.txt
Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt
Documentation/devicetree/bindings/soc/rockchip/power_domain.txt
Documentation/devicetree/bindings/sound/st,stm32-i2s.txt
Documentation/devicetree/bindings/sound/st,stm32-sai.txt
Documentation/devicetree/bindings/spi/spi-st-ssc.txt
Documentation/devicetree/bindings/thermal/exynos-thermal.txt
Documentation/devicetree/bindings/thermal/imx-thermal.txt
Documentation/devicetree/bindings/thermal/mediatek-thermal.txt
Documentation/devicetree/bindings/thermal/qcom-tsens.txt
Documentation/devicetree/bindings/thermal/rcar-gen3-thermal.txt
Documentation/devicetree/bindings/thermal/rcar-thermal.txt
Documentation/devicetree/bindings/thermal/uniphier-thermal.txt
Documentation/devicetree/bindings/timer/renesas,cmt.txt
Documentation/devicetree/bindings/usb/rockchip,dwc3.txt
Documentation/devicetree/bindings/vendor-prefixes.txt
Documentation/devicetree/bindings/watchdog/ingenic,jz4740-wdt.txt
Documentation/devicetree/bindings/watchdog/renesas-wdt.txt
Documentation/driver-api/gpio/consumer.rst
Documentation/features/debug/stackprotector/arch-support.txt
Documentation/filesystems/ceph.txt
Documentation/filesystems/f2fs.txt
Documentation/hwmon/ina2xx
Documentation/i2c/busses/i2c-mlxcpld
Documentation/i2c/busses/i2c-ocores
Documentation/i2c/muxes/i2c-mux-gpio
Documentation/kbuild/kconfig-language.txt
Documentation/kprobes.txt
Documentation/laptops/thinkpad-acpi.txt
Documentation/maintainer/pull-requests.rst
Documentation/networking/can.rst
Documentation/riscv/pmu.txt [new file with mode: 0644]
Documentation/security/self-protection.rst
Documentation/sphinx/rstFlatTable.py
Documentation/trace/coresight.txt
Documentation/trace/events.rst
Documentation/trace/ftrace-uses.rst
Documentation/trace/histogram.txt
Documentation/trace/intel_th.rst
Documentation/trace/tracepoint-analysis.rst
Documentation/translations/ja_JP/howto.rst
Documentation/translations/ko_KR/howto.rst
Documentation/translations/zh_CN/SubmittingDrivers
Documentation/translations/zh_CN/gpio.txt
Documentation/translations/zh_CN/io_ordering.txt
Documentation/translations/zh_CN/magic-number.txt
Documentation/translations/zh_CN/video4linux/omap3isp.txt
Documentation/translations/zh_CN/video4linux/v4l2-framework.txt
Documentation/vfio-mediated-device.txt
Documentation/virtual/kvm/api.txt
Documentation/virtual/kvm/devices/arm-vgic-v3.txt
Documentation/virtual/kvm/mmu.txt
Documentation/virtual/kvm/nested-vmx.txt
MAINTAINERS
Makefile
arch/Kconfig
arch/arm/Kconfig
arch/arm/Kconfig.debug
arch/arm/Makefile
arch/arm/boot/compressed/Makefile
arch/arm/boot/dts/Makefile
arch/arm/boot/dts/am335x-baltos-ir3220.dts
arch/arm/boot/dts/am335x-baltos-ir5221.dts
arch/arm/boot/dts/am335x-baltos.dtsi
arch/arm/boot/dts/am335x-bone-common.dtsi
arch/arm/boot/dts/am335x-boneblue.dts
arch/arm/boot/dts/am335x-evm.dts
arch/arm/boot/dts/am335x-evmsk.dts
arch/arm/boot/dts/am335x-osd335x-common.dtsi [new file with mode: 0644]
arch/arm/boot/dts/am335x-pocketbeagle.dts [new file with mode: 0644]
arch/arm/boot/dts/am3517-evm.dts
arch/arm/boot/dts/am3517-som.dtsi [new file with mode: 0644]
arch/arm/boot/dts/am437x-cm-t43.dts
arch/arm/boot/dts/am437x-gp-evm.dts
arch/arm/boot/dts/am437x-sk-evm.dts
arch/arm/boot/dts/am43x-epos-evm.dts
arch/arm/boot/dts/am571x-idk.dts
arch/arm/boot/dts/am572x-idk.dts
arch/arm/boot/dts/am574x-idk.dts
arch/arm/boot/dts/am57xx-beagle-x15-common.dtsi
arch/arm/boot/dts/am57xx-beagle-x15.dts
arch/arm/boot/dts/am57xx-idk-common.dtsi
arch/arm/boot/dts/armada-370-db.dts
arch/arm/boot/dts/armada-370-dlink-dns327l.dts
arch/arm/boot/dts/armada-370-mirabox.dts
arch/arm/boot/dts/armada-370-netgear-rn102.dts
arch/arm/boot/dts/armada-370-netgear-rn104.dts
arch/arm/boot/dts/armada-370-rd.dts
arch/arm/boot/dts/armada-370-seagate-nas-xbay.dtsi
arch/arm/boot/dts/armada-370-xp.dtsi
arch/arm/boot/dts/armada-375-db.dts
arch/arm/boot/dts/armada-375.dtsi
arch/arm/boot/dts/armada-385-db-ap.dts
arch/arm/boot/dts/armada-385-linksys-caiman.dts
arch/arm/boot/dts/armada-385-linksys-cobra.dts
arch/arm/boot/dts/armada-385-linksys-rango.dts
arch/arm/boot/dts/armada-385-linksys-shelby.dts
arch/arm/boot/dts/armada-385-linksys.dtsi
arch/arm/boot/dts/armada-388-db.dts
arch/arm/boot/dts/armada-38x.dtsi
arch/arm/boot/dts/armada-390-db.dts
arch/arm/boot/dts/armada-395-gp.dts
arch/arm/boot/dts/armada-398-db.dts
arch/arm/boot/dts/armada-39x.dtsi
arch/arm/boot/dts/armada-xp-98dx3236.dtsi
arch/arm/boot/dts/armada-xp-db-dxbc2.dts
arch/arm/boot/dts/armada-xp-db-xc3-24g4xg.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-netgear-rn2120.dts
arch/arm/boot/dts/aspeed-ast2500-evb.dts
arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts [new file with mode: 0644]
arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts [new file with mode: 0644]
arch/arm/boot/dts/aspeed-bmc-opp-romulus.dts
arch/arm/boot/dts/aspeed-bmc-opp-witherspoon.dts
arch/arm/boot/dts/aspeed-bmc-opp-zaius.dts
arch/arm/boot/dts/aspeed-bmc-portwell-neptune.dts [new file with mode: 0644]
arch/arm/boot/dts/aspeed-g4.dtsi
arch/arm/boot/dts/aspeed-g5.dtsi
arch/arm/boot/dts/at91-sama5d2_xplained.dts
arch/arm/boot/dts/at91-sama5d4ek.dts
arch/arm/boot/dts/bcm2835-rpi-a-plus.dts
arch/arm/boot/dts/bcm2835-rpi-a.dts
arch/arm/boot/dts/bcm2835-rpi-b-plus.dts
arch/arm/boot/dts/bcm2835-rpi-b-rev2.dts
arch/arm/boot/dts/bcm2835-rpi-b.dts
arch/arm/boot/dts/bcm2835-rpi.dtsi
arch/arm/boot/dts/bcm2836-rpi-2-b.dts
arch/arm/boot/dts/bcm2837-rpi-3-b-plus.dts [new file with mode: 0644]
arch/arm/boot/dts/bcm2837-rpi-3-b.dts
arch/arm/boot/dts/bcm283x-rpi-lan7515.dtsi [new file with mode: 0644]
arch/arm/boot/dts/bcm283x.dtsi
arch/arm/boot/dts/bcm4708-asus-rt-ac56u.dts
arch/arm/boot/dts/bcm4708-asus-rt-ac68u.dts
arch/arm/boot/dts/bcm4708-buffalo-wzr-1750dhp.dts
arch/arm/boot/dts/bcm4708-linksys-ea6300-v1.dts
arch/arm/boot/dts/bcm4708-luxul-xap-1510.dts
arch/arm/boot/dts/bcm4708-luxul-xwc-1000.dts
arch/arm/boot/dts/bcm4708-netgear-r6300-v2.dts
arch/arm/boot/dts/bcm4708-smartrg-sr400ac.dts
arch/arm/boot/dts/bcm47081-asus-rt-n18u.dts
arch/arm/boot/dts/bcm47081-buffalo-wzr-600dhp2.dts
arch/arm/boot/dts/bcm47081-buffalo-wzr-900dhp.dts
arch/arm/boot/dts/bcm47081-luxul-xap-1410.dts
arch/arm/boot/dts/bcm47081-luxul-xwr-1200.dts
arch/arm/boot/dts/bcm47081-tplink-archer-c5-v2.dts
arch/arm/boot/dts/bcm4709-asus-rt-ac87u.dts
arch/arm/boot/dts/bcm4709-buffalo-wxr-1900dhp.dts
arch/arm/boot/dts/bcm4709-linksys-ea9200.dts
arch/arm/boot/dts/bcm4709-netgear-r7000.dts
arch/arm/boot/dts/bcm4709-tplink-archer-c9-v1.dts
arch/arm/boot/dts/bcm47094-dlink-dir-885l.dts
arch/arm/boot/dts/bcm47094-linksys-panamera.dts
arch/arm/boot/dts/bcm47094-luxul-abr-4500.dts
arch/arm/boot/dts/bcm47094-luxul-xap-1610.dts [new file with mode: 0644]
arch/arm/boot/dts/bcm47094-luxul-xbr-4500.dts
arch/arm/boot/dts/bcm47094-luxul-xwr-3100.dts
arch/arm/boot/dts/bcm47094-luxul-xwr-3150-v1.dts [new file with mode: 0644]
arch/arm/boot/dts/bcm47094-netgear-r8500.dts
arch/arm/boot/dts/bcm5301x-nand-cs0-bch1.dtsi
arch/arm/boot/dts/bcm5301x-nand-cs0-bch4.dtsi
arch/arm/boot/dts/bcm5301x-nand-cs0-bch8.dtsi
arch/arm/boot/dts/bcm5301x-nand-cs0.dtsi
arch/arm/boot/dts/berlin2-sony-nsz-gs7.dts
arch/arm/boot/dts/berlin2.dtsi
arch/arm/boot/dts/berlin2cd-google-chromecast.dts
arch/arm/boot/dts/berlin2cd-valve-steamlink.dts [new file with mode: 0644]
arch/arm/boot/dts/berlin2cd.dtsi
arch/arm/boot/dts/berlin2q-marvell-dmp.dts
arch/arm/boot/dts/berlin2q.dtsi
arch/arm/boot/dts/da850-evm.dts
arch/arm/boot/dts/da850-lego-ev3.dts
arch/arm/boot/dts/da850.dtsi
arch/arm/boot/dts/dm8148-t410.dts
arch/arm/boot/dts/dra7-evm-common.dtsi
arch/arm/boot/dts/dra7-evm.dts
arch/arm/boot/dts/dra7-mmc-iodelay.dtsi [new file with mode: 0644]
arch/arm/boot/dts/dra7.dtsi
arch/arm/boot/dts/dra71-evm.dts
arch/arm/boot/dts/dra72-evm-common.dtsi
arch/arm/boot/dts/dra72x-mmc-iodelay.dtsi
arch/arm/boot/dts/dra76-evm.dts
arch/arm/boot/dts/emev2-kzm9d.dts
arch/arm/boot/dts/emev2.dtsi
arch/arm/boot/dts/exynos-syscon-restart.dtsi
arch/arm/boot/dts/exynos3250-rinato.dts
arch/arm/boot/dts/exynos3250.dtsi
arch/arm/boot/dts/exynos4.dtsi
arch/arm/boot/dts/exynos4210-origen.dts
arch/arm/boot/dts/exynos4210-trats.dts
arch/arm/boot/dts/exynos4412-galaxy-s3.dtsi
arch/arm/boot/dts/exynos4412-midas.dtsi
arch/arm/boot/dts/exynos4412-n710x.dts
arch/arm/boot/dts/exynos4412-odroid-common.dtsi
arch/arm/boot/dts/exynos4412-odroidu3.dts
arch/arm/boot/dts/exynos4412-odroidx.dts
arch/arm/boot/dts/exynos4412-origen.dts
arch/arm/boot/dts/exynos4412.dtsi
arch/arm/boot/dts/exynos5.dtsi
arch/arm/boot/dts/exynos5250.dtsi
arch/arm/boot/dts/exynos5410.dtsi
arch/arm/boot/dts/exynos5420-peach-pit.dts
arch/arm/boot/dts/exynos5420.dtsi
arch/arm/boot/dts/exynos5422-odroid-core.dtsi
arch/arm/boot/dts/exynos5440-sd5v1.dts [deleted file]
arch/arm/boot/dts/exynos5440-ssdk5440.dts [deleted file]
arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi [deleted file]
arch/arm/boot/dts/exynos5440-trip-points.dtsi [deleted file]
arch/arm/boot/dts/exynos5440.dtsi [deleted file]
arch/arm/boot/dts/exynos5800-peach-pi.dts
arch/arm/boot/dts/gemini-dlink-dir-685.dts
arch/arm/boot/dts/gemini-dlink-dns-313.dts
arch/arm/boot/dts/gemini-nas4220b.dts
arch/arm/boot/dts/gemini-rut1xx.dts
arch/arm/boot/dts/gemini-sq201.dts
arch/arm/boot/dts/gemini-wbd111.dts
arch/arm/boot/dts/gemini-wbd222.dts
arch/arm/boot/dts/gemini.dtsi
arch/arm/boot/dts/imx1-ads.dts
arch/arm/boot/dts/imx1.dtsi
arch/arm/boot/dts/imx23-evk.dts
arch/arm/boot/dts/imx23.dtsi
arch/arm/boot/dts/imx25-pdk.dts
arch/arm/boot/dts/imx25.dtsi
arch/arm/boot/dts/imx27-apf27.dts
arch/arm/boot/dts/imx27-pdk.dts
arch/arm/boot/dts/imx27.dtsi
arch/arm/boot/dts/imx28-cfa10049.dts
arch/arm/boot/dts/imx28-duckbill-2-enocean.dts
arch/arm/boot/dts/imx28-evk.dts
arch/arm/boot/dts/imx28-tx28.dts
arch/arm/boot/dts/imx28.dtsi
arch/arm/boot/dts/imx31.dtsi
arch/arm/boot/dts/imx35-pdk.dts
arch/arm/boot/dts/imx35.dtsi
arch/arm/boot/dts/imx50-evk.dts
arch/arm/boot/dts/imx50.dtsi
arch/arm/boot/dts/imx51-babbage.dts
arch/arm/boot/dts/imx51-zii-rdu1.dts
arch/arm/boot/dts/imx51.dtsi
arch/arm/boot/dts/imx53-ard.dts
arch/arm/boot/dts/imx53-m53.dtsi
arch/arm/boot/dts/imx53-ppd.dts
arch/arm/boot/dts/imx53-qsb-common.dtsi
arch/arm/boot/dts/imx53-qsb.dts
arch/arm/boot/dts/imx53-qsrb.dts
arch/arm/boot/dts/imx53-smd.dts
arch/arm/boot/dts/imx53-tx53-x03x.dts
arch/arm/boot/dts/imx53-tx53.dtsi
arch/arm/boot/dts/imx53-voipac-dmm-668.dtsi
arch/arm/boot/dts/imx53.dtsi
arch/arm/boot/dts/imx6dl-aristainetos2_4.dts
arch/arm/boot/dts/imx6dl-colibri-eval-v3.dts
arch/arm/boot/dts/imx6dl-mamoj.dts [new file with mode: 0644]
arch/arm/boot/dts/imx6dl-sabreauto.dts
arch/arm/boot/dts/imx6dl-sabresd.dts
arch/arm/boot/dts/imx6dl-udoo.dts
arch/arm/boot/dts/imx6dl-wandboard-revb1.dts
arch/arm/boot/dts/imx6dl-wandboard-revd1.dts
arch/arm/boot/dts/imx6dl-wandboard.dts
arch/arm/boot/dts/imx6dl.dtsi
arch/arm/boot/dts/imx6q-b850v3.dts
arch/arm/boot/dts/imx6q-ba16.dtsi
arch/arm/boot/dts/imx6q-bx50v3.dtsi
arch/arm/boot/dts/imx6q-dhcom-pdk2.dts [new file with mode: 0644]
arch/arm/boot/dts/imx6q-dhcom-som.dtsi [new file with mode: 0644]
arch/arm/boot/dts/imx6q-gk802.dts
arch/arm/boot/dts/imx6q-icore-mipi.dts [new file with mode: 0644]
arch/arm/boot/dts/imx6q-icore-ofcap12.dts
arch/arm/boot/dts/imx6q-kp-tpc.dts [new file with mode: 0644]
arch/arm/boot/dts/imx6q-kp.dtsi [new file with mode: 0644]
arch/arm/boot/dts/imx6q-novena.dts
arch/arm/boot/dts/imx6q-pistachio.dts
arch/arm/boot/dts/imx6q-sabreauto.dts
arch/arm/boot/dts/imx6q-sabresd.dts
arch/arm/boot/dts/imx6q-udoo.dts
arch/arm/boot/dts/imx6q-utilite-pro.dts
arch/arm/boot/dts/imx6q-var-dt6customboard.dts
arch/arm/boot/dts/imx6q-wandboard-revb1.dts
arch/arm/boot/dts/imx6q-wandboard-revd1.dts
arch/arm/boot/dts/imx6q-wandboard.dts
arch/arm/boot/dts/imx6q.dtsi
arch/arm/boot/dts/imx6qdl-apalis.dtsi
arch/arm/boot/dts/imx6qdl-colibri.dtsi
arch/arm/boot/dts/imx6qdl-gw5904.dtsi
arch/arm/boot/dts/imx6qdl-hummingboard.dtsi
arch/arm/boot/dts/imx6qdl-hummingboard2.dtsi
arch/arm/boot/dts/imx6qdl-icore.dtsi
arch/arm/boot/dts/imx6qdl-phytec-pfla02.dtsi
arch/arm/boot/dts/imx6qdl-sabreauto.dtsi
arch/arm/boot/dts/imx6qdl-sabrelite.dtsi
arch/arm/boot/dts/imx6qdl-sabresd.dtsi
arch/arm/boot/dts/imx6qdl-tx6-lcd.dtsi
arch/arm/boot/dts/imx6qdl-tx6-mb7.dtsi
arch/arm/boot/dts/imx6qdl-tx6.dtsi
arch/arm/boot/dts/imx6qdl-udoo.dtsi
arch/arm/boot/dts/imx6qdl-wandboard-revb1.dtsi
arch/arm/boot/dts/imx6qdl-wandboard-revc1.dtsi
arch/arm/boot/dts/imx6qdl-wandboard-revd1.dtsi
arch/arm/boot/dts/imx6qdl-wandboard.dtsi
arch/arm/boot/dts/imx6qdl-zii-rdu2.dtsi
arch/arm/boot/dts/imx6qdl.dtsi
arch/arm/boot/dts/imx6qp-sabreauto.dts
arch/arm/boot/dts/imx6qp-sabresd.dts
arch/arm/boot/dts/imx6qp-wandboard-revd1.dts
arch/arm/boot/dts/imx6qp-zii-rdu2.dts
arch/arm/boot/dts/imx6qp.dtsi
arch/arm/boot/dts/imx6sl-evk.dts
arch/arm/boot/dts/imx6sl.dtsi
arch/arm/boot/dts/imx6sx-nitrogen6sx.dts
arch/arm/boot/dts/imx6sx-sabreauto.dts
arch/arm/boot/dts/imx6sx.dtsi
arch/arm/boot/dts/imx6ul-14x14-evk.dts
arch/arm/boot/dts/imx6ul-isiot.dtsi
arch/arm/boot/dts/imx6ul-tx6ul-mainboard.dts
arch/arm/boot/dts/imx6ul-tx6ul.dtsi
arch/arm/boot/dts/imx6ul.dtsi
arch/arm/boot/dts/imx6ull-pinfunc.h
arch/arm/boot/dts/imx6ull.dtsi
arch/arm/boot/dts/imx7d-cl-som-imx7.dts
arch/arm/boot/dts/imx7d-nitrogen7.dts
arch/arm/boot/dts/imx7d-pinfunc.h
arch/arm/boot/dts/imx7d-sdb-sht11.dts
arch/arm/boot/dts/imx7d-sdb.dts
arch/arm/boot/dts/imx7d.dtsi
arch/arm/boot/dts/imx7s-warp.dts
arch/arm/boot/dts/imx7s.dtsi
arch/arm/boot/dts/keystone-k2g-evm.dts
arch/arm/boot/dts/logicpd-som-lv.dtsi
arch/arm/boot/dts/logicpd-torpedo-som.dtsi
arch/arm/boot/dts/meson8.dtsi
arch/arm/boot/dts/meson8b-odroidc1.dts
arch/arm/boot/dts/meson8b.dtsi
arch/arm/boot/dts/meson8m2-mxiii-plus.dts [new file with mode: 0644]
arch/arm/boot/dts/meson8m2.dtsi [new file with mode: 0644]
arch/arm/boot/dts/mt2701-evb.dts
arch/arm/boot/dts/mt2701.dtsi
arch/arm/boot/dts/mt6323.dtsi
arch/arm/boot/dts/mt6580-evbp1.dts
arch/arm/boot/dts/mt6580.dtsi
arch/arm/boot/dts/mt6589-aquaris5.dts
arch/arm/boot/dts/mt6589.dtsi
arch/arm/boot/dts/mt6592-evb.dts
arch/arm/boot/dts/mt6592.dtsi
arch/arm/boot/dts/mt7623.dtsi
arch/arm/boot/dts/mt7623a-rfb-emmc.dts [new file with mode: 0644]
arch/arm/boot/dts/mt7623a-rfb-nand.dts [new file with mode: 0644]
arch/arm/boot/dts/mt7623a.dtsi [new file with mode: 0644]
arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dts
arch/arm/boot/dts/mt7623n-rfb-emmc.dts [new file with mode: 0644]
arch/arm/boot/dts/mt7623n-rfb-nand.dts
arch/arm/boot/dts/mt7623n-rfb.dtsi
arch/arm/boot/dts/mt8127-moose.dts
arch/arm/boot/dts/mt8127.dtsi
arch/arm/boot/dts/mt8135-evbp1.dts
arch/arm/boot/dts/mt8135.dtsi
arch/arm/boot/dts/omap2420-n810.dts
arch/arm/boot/dts/omap3-beagle-xm.dts
arch/arm/boot/dts/omap3-cm-t3x.dtsi
arch/arm/boot/dts/omap3-devkit8000-common.dtsi
arch/arm/boot/dts/omap3-devkit8000-lcd-common.dtsi
arch/arm/boot/dts/omap3-gta04.dtsi
arch/arm/boot/dts/omap3-pandora-common.dtsi
arch/arm/boot/dts/omap3-sb-t35.dtsi
arch/arm/boot/dts/pxa3xx.dtsi
arch/arm/boot/dts/qcom-apq8064.dtsi
arch/arm/boot/dts/qcom-ipq4019-ap.dk01.1.dtsi
arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts [new file with mode: 0644]
arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c3.dts [new file with mode: 0644]
arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1.dtsi [new file with mode: 0644]
arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c1.dts [new file with mode: 0644]
arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c2.dts [new file with mode: 0644]
arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1.dtsi [new file with mode: 0644]
arch/arm/boot/dts/qcom-ipq4019.dtsi
arch/arm/boot/dts/qcom-msm8660.dtsi
arch/arm/boot/dts/qcom-msm8974-sony-xperia-amami.dts [new file with mode: 0644]
arch/arm/boot/dts/qcom-pm8941.dtsi
arch/arm/boot/dts/r7s72100.dtsi
arch/arm/boot/dts/r8a73a4-ape6evm.dts
arch/arm/boot/dts/r8a73a4.dtsi
arch/arm/boot/dts/r8a7740.dtsi
arch/arm/boot/dts/r8a7743-iwg20m.dtsi
arch/arm/boot/dts/r8a7743.dtsi
arch/arm/boot/dts/r8a7745-iwg22m.dtsi
arch/arm/boot/dts/r8a7745.dtsi
arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts [new file with mode: 0644]
arch/arm/boot/dts/r8a77470.dtsi [new file with mode: 0644]
arch/arm/boot/dts/r8a7790-lager.dts
arch/arm/boot/dts/r8a7790.dtsi
arch/arm/boot/dts/r8a7791-koelsch.dts
arch/arm/boot/dts/r8a7791-porter.dts
arch/arm/boot/dts/r8a7791.dtsi
arch/arm/boot/dts/r8a7792-blanche.dts
arch/arm/boot/dts/r8a7792-wheat.dts
arch/arm/boot/dts/r8a7792.dtsi
arch/arm/boot/dts/r8a7793-gose.dts
arch/arm/boot/dts/r8a7793.dtsi
arch/arm/boot/dts/r8a7794-alt.dts
arch/arm/boot/dts/r8a7794-silk.dts
arch/arm/boot/dts/r8a7794.dtsi
arch/arm/boot/dts/rk3036.dtsi
arch/arm/boot/dts/rk322x.dtsi
arch/arm/boot/dts/rk3288-phycore-som.dtsi
arch/arm/boot/dts/rk3288-tinker.dts
arch/arm/boot/dts/rk3288-veyron-chromebook.dtsi
arch/arm/boot/dts/rk3288-veyron-minnie.dts
arch/arm/boot/dts/rk3288.dtsi
arch/arm/boot/dts/s3c2416-smdk2416.dts
arch/arm/boot/dts/s3c2416.dtsi
arch/arm/boot/dts/s3c24xx.dtsi
arch/arm/boot/dts/s3c6410-mini6410.dts
arch/arm/boot/dts/s3c6410-smdk6410.dts
arch/arm/boot/dts/s3c64xx.dtsi
arch/arm/boot/dts/sh73a0.dtsi
arch/arm/boot/dts/ste-ccu8540-pinctrl.dtsi [deleted file]
arch/arm/boot/dts/ste-ccu8540.dts [deleted file]
arch/arm/boot/dts/ste-ccu9540.dts [deleted file]
arch/arm/boot/dts/ste-snowball.dts
arch/arm/boot/dts/stih407-family.dtsi
arch/arm/boot/dts/stih407-pinctrl.dtsi
arch/arm/boot/dts/stih407.dtsi
arch/arm/boot/dts/stih410.dtsi
arch/arm/boot/dts/stihxxx-b2120.dtsi
arch/arm/boot/dts/stm32f469-disco.dts
arch/arm/boot/dts/stm32f469.dtsi [new file with mode: 0644]
arch/arm/boot/dts/stm32f746-disco.dts
arch/arm/boot/dts/stm32f746.dtsi
arch/arm/boot/dts/stm32f769-disco.dts
arch/arm/boot/dts/stm32h743-pinctrl.dtsi
arch/arm/boot/dts/stm32h743.dtsi
arch/arm/boot/dts/stm32h743i-eval.dts
arch/arm/boot/dts/stm32mp157-pinctrl.dtsi
arch/arm/boot/dts/stm32mp157c-ed1.dts
arch/arm/boot/dts/stm32mp157c-ev1.dts
arch/arm/boot/dts/stm32mp157c.dtsi
arch/arm/boot/dts/sun7i-a20-olimex-som-evb-emmc.dts [new file with mode: 0644]
arch/arm/boot/dts/sun7i-a20-olimex-som204-evb.dts
arch/arm/boot/dts/sun8i-a23-a33.dtsi
arch/arm/boot/dts/sun8i-a33.dtsi
arch/arm/boot/dts/sun8i-a83t.dtsi
arch/arm/boot/dts/sun8i-h2-plus-libretech-all-h3-cc.dts [new file with mode: 0644]
arch/arm/boot/dts/sun8i-h2-plus-orangepi-zero.dts
arch/arm/boot/dts/sun8i-h3-libretech-all-h3-cc.dts
arch/arm/boot/dts/sun8i-h3-orangepi-one.dts
arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts
arch/arm/boot/dts/sun8i-h3.dtsi
arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic.dts [new file with mode: 0644]
arch/arm/boot/dts/sun8i-r16-nintendo-super-nes-classic.dts [new file with mode: 0644]
arch/arm/boot/dts/sun8i-r40-bananapi-m2-ultra.dts
arch/arm/boot/dts/sun8i-r40.dtsi
arch/arm/boot/dts/sun8i-v40-bananapi-m2-berry.dts
arch/arm/boot/dts/sunxi-h3-h5.dtsi
arch/arm/boot/dts/sunxi-libretech-all-h3-cc.dtsi [new file with mode: 0644]
arch/arm/boot/dts/tegra114.dtsi
arch/arm/boot/dts/tegra124-apalis-v1.2.dtsi
arch/arm/boot/dts/tegra124-apalis.dtsi
arch/arm/boot/dts/tegra30.dtsi
arch/arm/boot/dts/uniphier-pro4.dtsi
arch/arm/boot/dts/uniphier-pxs2.dtsi
arch/arm/boot/dts/vexpress-v2m-rs1.dtsi
arch/arm/boot/dts/vexpress-v2m.dtsi
arch/arm/boot/dts/vexpress-v2p-ca15-tc1.dts
arch/arm/boot/dts/vexpress-v2p-ca15_a7.dts
arch/arm/boot/dts/vexpress-v2p-ca5s.dts
arch/arm/boot/dts/vexpress-v2p-ca9.dts
arch/arm/boot/dts/vf-colibri-eval-v3.dtsi
arch/arm/boot/dts/vf610-zii-dev-rev-b.dts
arch/arm/boot/dts/vf610-zii-dev-rev-c.dts
arch/arm/boot/dts/vf610-zii-dev.dtsi
arch/arm/boot/dts/vfxxx.dtsi
arch/arm/common/Makefile
arch/arm/common/secure_cntvoff.S [new file with mode: 0644]
arch/arm/configs/bcm2835_defconfig
arch/arm/configs/davinci_all_defconfig
arch/arm/configs/exynos_defconfig
arch/arm/configs/imx_v6_v7_defconfig
arch/arm/configs/multi_v7_defconfig
arch/arm/configs/shmobile_defconfig
arch/arm/include/asm/cacheflush.h
arch/arm/include/asm/cputype.h
arch/arm/include/asm/kvm_host.h
arch/arm/include/asm/secure_cntvoff.h [new file with mode: 0644]
arch/arm/include/debug/brcmstb.S
arch/arm/include/uapi/asm/kvm.h
arch/arm/kernel/asm-offsets.c
arch/arm/kernel/entry-armv.S
arch/arm/kernel/process.c
arch/arm/kernel/sys_oabi-compat.c
arch/arm/kvm/hyp/Makefile
arch/arm/mach-berlin/Kconfig
arch/arm/mach-berlin/berlin.c
arch/arm/mach-berlin/headsmp.S
arch/arm/mach-berlin/platsmp.c
arch/arm/mach-davinci/aemif.c
arch/arm/mach-davinci/board-da830-evm.c
arch/arm/mach-davinci/board-da850-evm.c
arch/arm/mach-davinci/board-dm355-evm.c
arch/arm/mach-davinci/board-dm355-leopard.c
arch/arm/mach-davinci/board-dm365-evm.c
arch/arm/mach-davinci/board-dm644x-evm.c
arch/arm/mach-davinci/board-dm646x-evm.c
arch/arm/mach-davinci/board-mityomapl138.c
arch/arm/mach-davinci/board-neuros-osd2.c
arch/arm/mach-davinci/board-sffsdr.c
arch/arm/mach-davinci/davinci.h
arch/arm/mach-davinci/dm644x.c
arch/arm/mach-exynos/Kconfig
arch/arm/mach-exynos/common.h
arch/arm/mach-exynos/exynos.c
arch/arm/mach-exynos/include/mach/map.h
arch/arm/mach-exynos/platsmp.c
arch/arm/mach-exynos/pm.c
arch/arm/mach-exynos/suspend.c
arch/arm/mach-footbridge/dc21285.c
arch/arm/mach-imx/Kconfig
arch/arm/mach-imx/mach-mx31_3ds.c
arch/arm/mach-imx/mach-mx31lilly.c
arch/arm/mach-imx/mach-mx31lite.c
arch/arm/mach-imx/mach-mx31moboard.c
arch/arm/mach-imx/mach-pca100.c
arch/arm/mach-imx/mach-pcm037.c
arch/arm/mach-imx/mach-pcm037_eet.c
arch/arm/mach-imx/mach-pcm043.c
arch/arm/mach-imx/mach-vpr200.c
arch/arm/mach-ixp4xx/common-pci.c
arch/arm/mach-ks8695/board-acs5k.c
arch/arm/mach-meson/Kconfig
arch/arm/mach-meson/meson.c
arch/arm/mach-omap1/board-ams-delta.c
arch/arm/mach-omap1/board-htcherald.c
arch/arm/mach-omap1/board-osk.c
arch/arm/mach-omap1/common.h
arch/arm/mach-omap1/i2c.c
arch/arm/mach-omap1/mcbsp.c
arch/arm/mach-omap2/Makefile
arch/arm/mach-omap2/board-generic.c
arch/arm/mach-omap2/clockdomain.c
arch/arm/mach-omap2/clockdomain.h
arch/arm/mach-omap2/cm33xx.c
arch/arm/mach-omap2/cminst44xx.c
arch/arm/mach-omap2/common.h
arch/arm/mach-omap2/control.c
arch/arm/mach-omap2/control.h
arch/arm/mach-omap2/display.c
arch/arm/mach-omap2/hsmmc.c
arch/arm/mach-omap2/i2c.c
arch/arm/mach-omap2/io.c
arch/arm/mach-omap2/omap-pm-noop.c [deleted file]
arch/arm/mach-omap2/omap-pm.h [deleted file]
arch/arm/mach-omap2/omap_device.c
arch/arm/mach-omap2/omap_hwmod.c
arch/arm/mach-omap2/omap_hwmod.h
arch/arm/mach-omap2/omap_hwmod_2420_data.c
arch/arm/mach-omap2/omap_hwmod_2430_data.c
arch/arm/mach-omap2/omap_hwmod_33xx_43xx_ipblock_data.c
arch/arm/mach-omap2/omap_hwmod_33xx_data.c
arch/arm/mach-omap2/omap_hwmod_3xxx_data.c
arch/arm/mach-omap2/omap_hwmod_43xx_data.c
arch/arm/mach-omap2/omap_hwmod_44xx_data.c
arch/arm/mach-omap2/omap_hwmod_54xx_data.c
arch/arm/mach-omap2/omap_hwmod_7xx_data.c
arch/arm/mach-omap2/omap_hwmod_81xx_data.c
arch/arm/mach-omap2/pdata-quirks.c
arch/arm/mach-omap2/pm-debug.c
arch/arm/mach-omap2/pm.c
arch/arm/mach-omap2/pm33xx-core.c
arch/arm/mach-omap2/pm44xx.c
arch/arm/mach-omap2/powerdomain.c
arch/arm/mach-omap2/powerdomain.h
arch/arm/mach-omap2/prm33xx.c
arch/arm/mach-omap2/prm44xx.c
arch/arm/mach-omap2/prm_common.c
arch/arm/mach-omap2/timer.c
arch/arm/mach-pxa/palmz72.c
arch/arm/mach-pxa/pxa3xx.c
arch/arm/mach-pxa/stargate2.c
arch/arm/mach-pxa/viper.c
arch/arm/mach-s3c24xx/h1940-bluetooth.c
arch/arm/mach-s3c24xx/mach-mini2440.c
arch/arm/mach-sa1100/simpad.c
arch/arm/mach-shmobile/Kconfig
arch/arm/mach-shmobile/common.h
arch/arm/mach-shmobile/headsmp-apmu.S
arch/arm/mach-shmobile/setup-rcar-gen2.c
arch/arm/mach-sunxi/Kconfig
arch/arm/mach-sunxi/Makefile
arch/arm/mach-sunxi/headsmp.S [new file with mode: 0644]
arch/arm/mach-sunxi/mc_smp.c
arch/arm/mach-sunxi/sunxi.c
arch/arm/mach-tegra/tegra.c
arch/arm/mach-ux500/Kconfig
arch/arm/mach-ux500/cpu-db8500.c
arch/arm/mach-ux500/db8500-regs.h
arch/arm/mach-vexpress/spc.c
arch/arm/mm/cache-b15-rac.c
arch/arm/mm/dma-mapping.c
arch/arm/mm/pgd.c
arch/arm/plat-omap/Kconfig
arch/arm/plat-samsung/adc.c
arch/arm/plat-samsung/include/plat/map-s5p.h
arch/arm/probes/kprobes/test-core.c
arch/arm/vdso/Makefile
arch/arm64/Kconfig
arch/arm64/Kconfig.platforms
arch/arm64/Makefile
arch/arm64/boot/dts/Makefile
arch/arm64/boot/dts/allwinner/Makefile
arch/arm64/boot/dts/allwinner/axp803.dtsi
arch/arm64/boot/dts/allwinner/sun50i-a64-bananapi-m64.dts
arch/arm64/boot/dts/allwinner/sun50i-h5-libretech-all-h3-cc.dts [new file with mode: 0644]
arch/arm64/boot/dts/allwinner/sun50i-h5.dtsi
arch/arm64/boot/dts/allwinner/sun50i-h6-pine-h64.dts
arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi
arch/arm64/boot/dts/amlogic/meson-axg-s400.dts
arch/arm64/boot/dts/amlogic/meson-axg.dtsi
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
arch/arm64/boot/dts/arm/juno-base.dtsi
arch/arm64/boot/dts/arm/juno-motherboard.dtsi
arch/arm64/boot/dts/arm/juno-r1.dts
arch/arm64/boot/dts/arm/juno-r2.dts
arch/arm64/boot/dts/arm/juno.dts
arch/arm64/boot/dts/arm/rtsm_ve-aemv8a.dts
arch/arm64/boot/dts/arm/rtsm_ve-motherboard.dtsi
arch/arm64/boot/dts/arm/vexpress-v2f-1xv7-ca53x2.dts
arch/arm64/boot/dts/broadcom/Makefile
arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b-plus.dts [new file with mode: 0644]
arch/arm64/boot/dts/exynos/exynos5433.dtsi
arch/arm64/boot/dts/exynos/exynos7.dtsi
arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi
arch/arm64/boot/dts/freescale/fsl-ls208xa-rdb.dtsi
arch/arm64/boot/dts/hisilicon/hi3660.dtsi
arch/arm64/boot/dts/hisilicon/hi3798cv200-poplar.dts
arch/arm64/boot/dts/hisilicon/hi3798cv200.dtsi
arch/arm64/boot/dts/hisilicon/hip06-d03.dts
arch/arm64/boot/dts/hisilicon/hip06.dtsi
arch/arm64/boot/dts/hisilicon/hip07-d05.dts
arch/arm64/boot/dts/hisilicon/hip07.dtsi
arch/arm64/boot/dts/hisilicon/poplar-pinctrl.dtsi [new file with mode: 0644]
arch/arm64/boot/dts/marvell/Makefile
arch/arm64/boot/dts/marvell/armada-3720-espressobin.dts
arch/arm64/boot/dts/marvell/armada-37xx.dtsi
arch/arm64/boot/dts/marvell/armada-7040-db.dts
arch/arm64/boot/dts/marvell/armada-8040-db.dts
arch/arm64/boot/dts/marvell/armada-8040-mcbin.dts
arch/arm64/boot/dts/marvell/armada-cp110.dtsi
arch/arm64/boot/dts/marvell/berlin4ct-dmp.dts [deleted file]
arch/arm64/boot/dts/marvell/berlin4ct-stb.dts [deleted file]
arch/arm64/boot/dts/mediatek/mt2712-pinfunc.h [new file with mode: 0644]
arch/arm64/boot/dts/mediatek/mt2712e.dtsi
arch/arm64/boot/dts/mediatek/mt7622-rfb1.dts
arch/arm64/boot/dts/mediatek/mt7622.dtsi
arch/arm64/boot/dts/qcom/Makefile
arch/arm64/boot/dts/qcom/apq8096-db820c-pmic-pins.dtsi
arch/arm64/boot/dts/qcom/apq8096-db820c.dtsi
arch/arm64/boot/dts/qcom/ipq8074-hk01.dts
arch/arm64/boot/dts/qcom/ipq8074.dtsi
arch/arm64/boot/dts/qcom/msm8916.dtsi
arch/arm64/boot/dts/qcom/msm8992-bullhead-rev-101.dts
arch/arm64/boot/dts/qcom/msm8992-pins.dtsi
arch/arm64/boot/dts/qcom/msm8992.dtsi
arch/arm64/boot/dts/qcom/msm8994-smd-rpm.dtsi [new file with mode: 0644]
arch/arm64/boot/dts/qcom/msm8996.dtsi
arch/arm64/boot/dts/qcom/sdm845-mtp.dts [new file with mode: 0644]
arch/arm64/boot/dts/qcom/sdm845.dtsi [new file with mode: 0644]
arch/arm64/boot/dts/renesas/Makefile
arch/arm64/boot/dts/renesas/r8a7795-es1-salvator-x.dts
arch/arm64/boot/dts/renesas/r8a7795-es1.dtsi
arch/arm64/boot/dts/renesas/r8a7795-salvator-x.dts
arch/arm64/boot/dts/renesas/r8a7795-salvator-xs.dts
arch/arm64/boot/dts/renesas/r8a7795.dtsi
arch/arm64/boot/dts/renesas/r8a7796-salvator-x.dts
arch/arm64/boot/dts/renesas/r8a7796-salvator-xs.dts
arch/arm64/boot/dts/renesas/r8a7796.dtsi
arch/arm64/boot/dts/renesas/r8a77965-salvator-x.dts
arch/arm64/boot/dts/renesas/r8a77965-salvator-xs.dts
arch/arm64/boot/dts/renesas/r8a77965.dtsi
arch/arm64/boot/dts/renesas/r8a77970-eagle.dts
arch/arm64/boot/dts/renesas/r8a77970-v3msk.dts
arch/arm64/boot/dts/renesas/r8a77970.dtsi
arch/arm64/boot/dts/renesas/r8a77980-condor.dts
arch/arm64/boot/dts/renesas/r8a77980-v3hsk.dts [new file with mode: 0644]
arch/arm64/boot/dts/renesas/r8a77980.dtsi
arch/arm64/boot/dts/renesas/r8a77990-ebisu.dts [new file with mode: 0644]
arch/arm64/boot/dts/renesas/r8a77990.dtsi [new file with mode: 0644]
arch/arm64/boot/dts/renesas/r8a77995-draak.dts
arch/arm64/boot/dts/renesas/r8a77995.dtsi
arch/arm64/boot/dts/renesas/salvator-common.dtsi
arch/arm64/boot/dts/renesas/ulcb.dtsi
arch/arm64/boot/dts/rockchip/rk3328.dtsi
arch/arm64/boot/dts/rockchip/rk3368.dtsi
arch/arm64/boot/dts/rockchip/rk3399-firefly.dts
arch/arm64/boot/dts/rockchip/rk3399-gru-kevin.dts
arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi
arch/arm64/boot/dts/rockchip/rk3399-puma-haikou.dts
arch/arm64/boot/dts/rockchip/rk3399-puma.dtsi
arch/arm64/boot/dts/rockchip/rk3399-sapphire-excavator.dts
arch/arm64/boot/dts/rockchip/rk3399-sapphire.dtsi
arch/arm64/boot/dts/rockchip/rk3399.dtsi
arch/arm64/boot/dts/socionext/uniphier-ld11.dtsi
arch/arm64/boot/dts/socionext/uniphier-ld20.dtsi
arch/arm64/boot/dts/socionext/uniphier-pxs3.dtsi
arch/arm64/boot/dts/sprd/sc2731.dtsi
arch/arm64/boot/dts/sprd/sc9860.dtsi
arch/arm64/boot/dts/sprd/whale2.dtsi
arch/arm64/boot/dts/synaptics/Makefile [new file with mode: 0644]
arch/arm64/boot/dts/synaptics/berlin4ct-dmp.dts [new file with mode: 0644]
arch/arm64/boot/dts/synaptics/berlin4ct-stb.dts [new file with mode: 0644]
arch/arm64/boot/dts/synaptics/berlin4ct.dtsi [moved from arch/arm64/boot/dts/marvell/berlin4ct.dtsi with 78% similarity]
arch/arm64/configs/defconfig
arch/arm64/include/asm/cacheflush.h
arch/arm64/include/asm/cpufeature.h
arch/arm64/include/asm/fpsimd.h
arch/arm64/include/asm/kvm_asm.h
arch/arm64/include/asm/kvm_host.h
arch/arm64/include/asm/processor.h
arch/arm64/include/asm/thread_info.h
arch/arm64/include/uapi/asm/kvm.h
arch/arm64/kernel/armv8_deprecated.c
arch/arm64/kernel/fpsimd.c
arch/arm64/kernel/process.c
arch/arm64/kernel/ptrace.c
arch/arm64/kvm/Kconfig
arch/arm64/kvm/Makefile
arch/arm64/kvm/debug.c
arch/arm64/kvm/fpsimd.c [new file with mode: 0644]
arch/arm64/kvm/hyp/debug-sr.c
arch/arm64/kvm/hyp/entry.S
arch/arm64/kvm/hyp/hyp-entry.S
arch/arm64/kvm/hyp/switch.c
arch/arm64/kvm/hyp/sysreg-sr.c
arch/arm64/kvm/sys_regs.c
arch/arm64/mm/context.c
arch/arm64/mm/init.c
arch/hexagon/include/asm/pgtable.h
arch/hexagon/kernel/setup.c
arch/hexagon/mm/init.c
arch/ia64/Kconfig
arch/ia64/kernel/mca_drv.c
arch/ia64/kernel/topology.c
arch/ia64/mm/tlb.c
arch/ia64/sn/kernel/io_common.c
arch/ia64/sn/kernel/irq.c
arch/ia64/sn/pci/pcibr/pcibr_provider.c
arch/microblaze/include/asm/cacheflush.h
arch/mips/Kconfig
arch/mips/alchemy/board-gpr.c
arch/mips/alchemy/common/clock.c
arch/mips/alchemy/common/dbdma.c
arch/mips/alchemy/common/platform.c
arch/mips/alchemy/devboards/platform.c
arch/mips/bcm47xx/board.c
arch/mips/bcm47xx/buttons.c
arch/mips/bcm47xx/leds.c
arch/mips/bmips/dma.c
arch/mips/boot/compressed/Makefile
arch/mips/boot/dts/brcm/Makefile
arch/mips/boot/dts/cavium-octeon/Makefile
arch/mips/boot/dts/ingenic/Makefile
arch/mips/boot/dts/ingenic/jz4740.dtsi
arch/mips/boot/dts/ingenic/jz4780.dtsi
arch/mips/boot/dts/lantiq/Makefile
arch/mips/boot/dts/mscc/Makefile
arch/mips/boot/dts/mscc/ocelot.dtsi
arch/mips/boot/dts/mscc/ocelot_pcb123.dts
arch/mips/boot/dts/mti/Makefile
arch/mips/boot/dts/netlogic/Makefile
arch/mips/boot/dts/pic32/Makefile
arch/mips/boot/dts/ralink/Makefile
arch/mips/configs/qi_lb60_defconfig
arch/mips/dec/time.c
arch/mips/include/asm/cpu-features.h
arch/mips/include/asm/cpu.h
arch/mips/include/asm/mach-bcm47xx/bcm47xx_board.h
arch/mips/include/asm/mach-jz4740/platform.h
arch/mips/include/asm/mc146818-time.h
arch/mips/include/asm/mipsregs.h
arch/mips/include/asm/time.h
arch/mips/jz4740/platform.c
arch/mips/jz4740/reset.c
arch/mips/kernel/asm-offsets.c
arch/mips/kernel/cpu-probe.c
arch/mips/kernel/octeon_switch.S
arch/mips/kernel/perf_event_mipsxx.c
arch/mips/kernel/process.c
arch/mips/kernel/ptrace.c
arch/mips/kernel/ptrace32.c
arch/mips/kernel/r2300_switch.S
arch/mips/kernel/r4k_switch.S
arch/mips/kernel/setup.c
arch/mips/kernel/time.c
arch/mips/kernel/vpe.c
arch/mips/kvm/mips.c
arch/mips/lasat/ds1603.c
arch/mips/lasat/sysctl.c
arch/mips/lib/Makefile
arch/mips/lib/ashldi3.c [deleted file]
arch/mips/lib/ashrdi3.c [deleted file]
arch/mips/lib/cmpdi2.c [deleted file]
arch/mips/lib/lshrdi3.c [deleted file]
arch/mips/lib/memset.S
arch/mips/lib/ucmpdi2.c [deleted file]
arch/mips/loongson64/common/time.c
arch/mips/mm/sc-debugfs.c
arch/mips/mti-malta/malta-time.c
arch/mips/oprofile/op_model_mipsxx.c
arch/mips/sibyte/swarm/rtc_m41t81.c
arch/mips/sibyte/swarm/rtc_xicor1241.c
arch/mips/sibyte/swarm/setup.c
arch/mips/sni/time.c
arch/mips/txx9/rbtx4939/setup.c
arch/parisc/Kconfig
arch/powerpc/Kconfig
arch/powerpc/Makefile
arch/powerpc/include/asm/asm-prototypes.h
arch/powerpc/include/asm/kvm_book3s.h
arch/powerpc/include/asm/kvm_book3s_64.h
arch/powerpc/include/asm/kvm_booke.h
arch/powerpc/include/asm/kvm_host.h
arch/powerpc/include/asm/kvm_ppc.h
arch/powerpc/include/asm/module.h
arch/powerpc/include/asm/reg.h
arch/powerpc/include/uapi/asm/kvm.h
arch/powerpc/kernel/asm-offsets.c
arch/powerpc/kernel/module_64.c
arch/powerpc/kernel/rtasd.c
arch/powerpc/kernel/trace/ftrace.c
arch/powerpc/kernel/vdso.c
arch/powerpc/kvm/Makefile
arch/powerpc/kvm/book3s.c
arch/powerpc/kvm/book3s.h
arch/powerpc/kvm/book3s_32_mmu.c
arch/powerpc/kvm/book3s_64_mmu.c
arch/powerpc/kvm/book3s_64_mmu_hv.c
arch/powerpc/kvm/book3s_64_mmu_radix.c
arch/powerpc/kvm/book3s_64_vio.c
arch/powerpc/kvm/book3s_64_vio_hv.c
arch/powerpc/kvm/book3s_emulate.c
arch/powerpc/kvm/book3s_hv.c
arch/powerpc/kvm/book3s_hv_builtin.c
arch/powerpc/kvm/book3s_hv_interrupts.S
arch/powerpc/kvm/book3s_hv_rm_mmu.c
arch/powerpc/kvm/book3s_hv_rm_xics.c
arch/powerpc/kvm/book3s_hv_rmhandlers.S
arch/powerpc/kvm/book3s_hv_tm.c
arch/powerpc/kvm/book3s_hv_tm_builtin.c
arch/powerpc/kvm/book3s_pr.c
arch/powerpc/kvm/book3s_segment.S
arch/powerpc/kvm/book3s_xive_template.c
arch/powerpc/kvm/booke.c
arch/powerpc/kvm/booke_emulate.c
arch/powerpc/kvm/e500_emulate.c
arch/powerpc/kvm/e500_mmu.c
arch/powerpc/kvm/e500_mmu_host.c
arch/powerpc/kvm/emulate_loadstore.c
arch/powerpc/kvm/powerpc.c
arch/powerpc/kvm/tm.S [new file with mode: 0644]
arch/powerpc/lib/rheap.c
arch/powerpc/mm/mem.c
arch/powerpc/mm/mmu_context_iommu.c
arch/powerpc/mm/numa.c
arch/powerpc/net/bpf_jit_comp.c
arch/powerpc/net/bpf_jit_comp64.c
arch/powerpc/oprofile/cell/spu_profiler.c
arch/powerpc/platforms/4xx/hsta_msi.c
arch/powerpc/platforms/4xx/msi.c
arch/powerpc/platforms/4xx/pci.c
arch/powerpc/platforms/powernv/opal-sysparam.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/sysdev/xive/native.c
arch/powerpc/tools/gcc-check-mprofile-kernel.sh
arch/riscv/Kconfig
arch/riscv/Makefile
arch/riscv/configs/defconfig
arch/riscv/include/asm/Kbuild
arch/riscv/include/asm/cacheflush.h
arch/riscv/include/asm/perf_event.h [new file with mode: 0644]
arch/riscv/include/asm/tlbflush.h
arch/riscv/include/asm/uaccess.h
arch/riscv/kernel/Makefile
arch/riscv/kernel/mcount.S
arch/riscv/kernel/module.c
arch/riscv/kernel/perf_event.c [new file with mode: 0644]
arch/riscv/kernel/riscv_ksyms.c
arch/riscv/kernel/traps.c
arch/riscv/lib/uaccess.S
arch/s390/appldata/appldata_base.c
arch/s390/hypfs/hypfs_diag.c
arch/s390/hypfs/hypfs_diag0c.c
arch/s390/include/asm/ctl_reg.h
arch/s390/include/asm/kvm_host.h
arch/s390/include/asm/mmu.h
arch/s390/include/asm/mmu_context.h
arch/s390/include/asm/pgtable.h
arch/s390/kernel/debug.c
arch/s390/kernel/module.c
arch/s390/kernel/perf_cpum_cf_events.c
arch/s390/kernel/sthyi.c
arch/s390/kernel/vdso.c
arch/s390/kvm/gaccess.c
arch/s390/kvm/guestdbg.c
arch/s390/kvm/interrupt.c
arch/s390/kvm/kvm-s390.c
arch/s390/kvm/kvm-s390.h
arch/s390/kvm/priv.c
arch/s390/kvm/vsie.c
arch/s390/mm/extmem.c
arch/s390/mm/gmap.c
arch/s390/mm/pgtable.c
arch/sh/Kconfig
arch/sh/boards/board-sh7785lcr.c
arch/sh/drivers/dma/dmabrg.c
arch/sh/drivers/pci/pcie-sh7786.c
arch/sh/include/asm/vmlinux.lds.h
arch/sh/kernel/process.c
arch/sh/kernel/process_32.c
arch/sparc/Kconfig
arch/sparc/kernel/nmi.c
arch/sparc/kernel/sys_sparc_64.c
arch/sparc/mm/init_64.c
arch/sparc/net/bpf_jit_comp_32.c
arch/um/Kconfig.um
arch/um/drivers/ubd_kern.c
arch/um/drivers/vector_kern.c
arch/um/include/asm/common.lds.S
arch/um/include/shared/init.h
arch/um/os-Linux/main.c
arch/unicore32/include/asm/cacheflush.h
arch/unicore32/kernel/pm.c
arch/x86/Kconfig
arch/x86/entry/entry_32.S
arch/x86/entry/entry_64.S
arch/x86/entry/vsyscall/vsyscall_64.c
arch/x86/events/amd/iommu.c
arch/x86/events/core.c
arch/x86/events/intel/uncore.c
arch/x86/hyperv/mmu.c
arch/x86/include/asm/hyperv-tlfs.h
arch/x86/include/asm/kvm_emulate.h
arch/x86/include/asm/kvm_host.h
arch/x86/include/asm/mshyperv.h
arch/x86/include/asm/processor.h
arch/x86/include/asm/segment.h
arch/x86/include/asm/stackprotector.h
arch/x86/include/asm/vmx.h
arch/x86/kernel/asm-offsets.c
arch/x86/kernel/asm-offsets_32.c
arch/x86/kernel/asm-offsets_64.c
arch/x86/kernel/cpu/common.c
arch/x86/kernel/cpu/mcheck/mce.c
arch/x86/kernel/cpu/mcheck/mce_amd.c
arch/x86/kernel/cpu/mtrr/if.c
arch/x86/kernel/head_32.S
arch/x86/kernel/hpet.c
arch/x86/kernel/ksysfs.c
arch/x86/kvm/cpuid.c
arch/x86/kvm/emulate.c
arch/x86/kvm/hyperv.c
arch/x86/kvm/lapic.c
arch/x86/kvm/lapic.h
arch/x86/kvm/mmu.c
arch/x86/kvm/page_track.c
arch/x86/kvm/svm.c
arch/x86/kvm/trace.h
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c
arch/x86/kvm/x86.h
arch/x86/mm/init.c
arch/x86/mm/init_32.c
arch/x86/mm/init_64.c
arch/x86/net/bpf_jit_comp.c
arch/x86/net/bpf_jit_comp32.c
arch/x86/pci/xen.c
arch/x86/platform/uv/tlb_uv.c
arch/x86/platform/uv/uv_time.c
arch/xtensa/Kconfig
arch/xtensa/include/asm/cacheflush.h
arch/xtensa/kernel/asm-offsets.c
arch/xtensa/kernel/entry.S
arch/xtensa/kernel/process.c
block/Kconfig
block/bio.c
block/blk-mq.c
block/blk-tag.c
block/blk-zoned.c
block/partitions/check.c
block/partitions/ldm.c
certs/Kconfig
crypto/algif_aead.c
crypto/algif_skcipher.c
crypto/asymmetric_keys/asymmetric_type.c
crypto/asymmetric_keys/signature.c
crypto/testmgr.c
drivers/acpi/acpi_lpss.c
drivers/acpi/acpi_platform.c
drivers/acpi/acpi_video.c
drivers/acpi/acpica/dbnames.c
drivers/acpi/acpica/dbobject.c
drivers/acpi/acpica/dsdebug.c
drivers/acpi/acpica/exconfig.c
drivers/acpi/acpica/nsdump.c
drivers/acpi/acpica/psloop.c
drivers/acpi/acpica/psobject.c
drivers/acpi/acpica/pswalk.c
drivers/acpi/acpica/uterror.c
drivers/acpi/acpica/utosi.c
drivers/acpi/apei/erst.c
drivers/acpi/apei/hest.c
drivers/acpi/fan.c
drivers/acpi/nfit/core.c
drivers/acpi/processor_perflib.c
drivers/acpi/processor_throttling.c
drivers/acpi/sysfs.c
drivers/android/binder_alloc.c
drivers/ata/libata-core.c
drivers/ata/libata-pmp.c
drivers/ata/sata_mv.c
drivers/atm/fore200e.c
drivers/atm/iphase.c
drivers/atm/solos-pci.c
drivers/auxdisplay/cfag12864b.c
drivers/base/dd.c
drivers/base/firmware_loader/fallback.c
drivers/base/power/common.c
drivers/base/power/domain.c
drivers/base/power/runtime.c
drivers/base/power/sysfs.c
drivers/block/DAC960.c
drivers/block/drbd/drbd_main.c
drivers/block/loop.c
drivers/block/null_blk.c
drivers/block/ps3vram.c
drivers/block/rbd.c
drivers/block/rsxx/core.c
drivers/block/rsxx/dma.c
drivers/block/xen-blkback/xenbus.c
drivers/block/xen-blkfront.c
drivers/block/z2ram.c
drivers/block/zram/zram_drv.c
drivers/bus/Kconfig
drivers/bus/arm-cci.c
drivers/bus/fsl-mc/fsl-mc-allocator.c
drivers/bus/hisi_lpc.c
drivers/bus/ti-sysc.c
drivers/cdrom/cdrom.c
drivers/char/Kconfig
drivers/char/agp/amd-k7-agp.c
drivers/char/agp/ati-agp.c
drivers/char/agp/compat_ioctl.c
drivers/char/agp/isoch.c
drivers/char/agp/sgi-agp.c
drivers/char/agp/sworks-agp.c
drivers/char/agp/uninorth-agp.c
drivers/char/ipmi/ipmi_ssif.c
drivers/char/raw.c
drivers/char/tpm/tpm2-cmd.c
drivers/char/virtio_console.c
drivers/clk/bcm/clk-bcm2835.c
drivers/clk/clk.c
drivers/clk/ingenic/cgu.h
drivers/clk/renesas/clk-r8a7740.c
drivers/clk/renesas/clk-r8a7779.c
drivers/clk/renesas/clk-rcar-gen2.c
drivers/clk/renesas/clk-rz.c
drivers/clk/st/clkgen-fsyn.c
drivers/clk/st/clkgen-pll.c
drivers/clk/sunxi/clk-usb.c
drivers/clk/tegra/clk.c
drivers/clk/ti/adpll.c
drivers/clk/ti/apll.c
drivers/clk/ti/divider.c
drivers/clk/ti/dpll.c
drivers/clocksource/sh_cmt.c
drivers/clocksource/sh_mtu2.c
drivers/clocksource/sh_tmu.c
drivers/cpufreq/Kconfig.arm
drivers/cpufreq/acpi-cpufreq.c
drivers/cpufreq/arm_big_little.c
drivers/cpufreq/bmips-cpufreq.c
drivers/cpufreq/brcmstb-avs-cpufreq.c
drivers/cpufreq/cppc_cpufreq.c
drivers/cpufreq/cpufreq_governor.c
drivers/cpufreq/ia64-acpi-cpufreq.c
drivers/cpufreq/imx6q-cpufreq.c
drivers/cpufreq/intel_pstate.c
drivers/cpufreq/longhaul.c
drivers/cpufreq/pxa3xx-cpufreq.c
drivers/cpufreq/s3c24xx-cpufreq.c
drivers/cpufreq/scmi-cpufreq.c
drivers/cpufreq/sfi-cpufreq.c
drivers/cpufreq/spear-cpufreq.c
drivers/cpufreq/ti-cpufreq.c
drivers/crypto/amcc/crypto4xx_core.c
drivers/crypto/cavium/nitrox/nitrox_isr.c
drivers/crypto/chelsio/chtls/chtls_io.c
drivers/crypto/inside-secure/safexcel_hash.c
drivers/crypto/marvell/cesa.c
drivers/crypto/marvell/hash.c
drivers/crypto/n2_core.c
drivers/crypto/qat/qat_common/adf_isr.c
drivers/crypto/qat/qat_common/qat_uclo.c
drivers/crypto/stm32/stm32-hash.c
drivers/crypto/talitos.c
drivers/crypto/virtio/virtio_crypto_algs.c
drivers/devfreq/devfreq.c
drivers/devfreq/event/exynos-ppmu.c
drivers/dma/bestcomm/bestcomm.c
drivers/dma/dmaengine.c
drivers/dma/ioat/init.c
drivers/dma/ipu/ipu_idmac.c
drivers/dma/k3dma.c
drivers/dma/mic_x100_dma.c
drivers/dma/mv_xor.c
drivers/dma/mv_xor_v2.c
drivers/dma/pl330.c
drivers/dma/s3c24xx-dma.c
drivers/dma/sh/shdma-base.c
drivers/dma/xilinx/zynqmp_dma.c
drivers/dma/zx_dma.c
drivers/edac/amd64_edac.c
drivers/edac/i7core_edac.c
drivers/extcon/extcon.c
drivers/firewire/core-iso.c
drivers/firewire/net.c
drivers/firmware/arm_scmi/base.c
drivers/firmware/arm_scmi/bus.c
drivers/firmware/arm_scmi/clock.c
drivers/firmware/arm_scmi/common.h
drivers/firmware/arm_scmi/driver.c
drivers/firmware/arm_scmi/perf.c
drivers/firmware/arm_scmi/power.c
drivers/firmware/arm_scmi/sensors.c
drivers/firmware/arm_scpi.c
drivers/firmware/broadcom/bcm47xx_nvram.c
drivers/firmware/dell_rbu.c
drivers/firmware/efi/arm-init.c
drivers/firmware/efi/capsule.c
drivers/firmware/efi/efi-pstore.c
drivers/firmware/efi/runtime-map.c
drivers/firmware/qcom_scm.c
drivers/firmware/ti_sci.c
drivers/firmware/ti_sci.h
drivers/fmc/fmc-sdb.c
drivers/gpio/gpio-adnp.c
drivers/gpio/gpio-aspeed.c
drivers/gpio/gpio-bcm-kona.c
drivers/gpio/gpio-davinci.c
drivers/gpio/gpio-htc-egpio.c
drivers/gpio/gpio-ml-ioh.c
drivers/gpio/gpio-thunderx.c
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c
drivers/gpu/drm/amd/amdgpu/amdgpu_atpx_handler.c
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
drivers/gpu/drm/amd/amdgpu/amdgpu_object.h
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
drivers/gpu/drm/amd/amdgpu/atom.c
drivers/gpu/drm/amd/amdgpu/ci_dpm.c
drivers/gpu/drm/amd/amdgpu/df_v3_6.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/amdgpu/kv_dpm.c
drivers/gpu/drm/amd/amdgpu/psp_v3_1.c
drivers/gpu/drm/amd/amdgpu/si_dpm.c
drivers/gpu/drm/amd/amdgpu/soc15.c
drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_services.c
drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c
drivers/gpu/drm/amd/display/dc/basics/logger.c
drivers/gpu/drm/amd/display/dc/basics/vector.c
drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_compressor.c
drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp_dscl.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c
drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
drivers/gpu/drm/amd/display/include/fixed31_32.h
drivers/gpu/drm/amd/display/modules/color/color_gamma.c
drivers/gpu/drm/amd/display/modules/freesync/freesync.c
drivers/gpu/drm/amd/display/modules/stats/stats.c
drivers/gpu/drm/amd/include/asic_reg/df/df_3_6_sh_mask.h
drivers/gpu/drm/amd/include/atomfirmware.h
drivers/gpu/drm/amd/powerplay/amd_powerplay.c
drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c
drivers/gpu/drm/amd/powerplay/hwmgr/ppatomfwctrl.c
drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
drivers/gpu/drm/amd/powerplay/hwmgr/processpptables.c
drivers/gpu/drm/amd/powerplay/hwmgr/smu10_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_hwmgr.c
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_powertune.c
drivers/gpu/drm/amd/powerplay/hwmgr/vega10_processpptables.c
drivers/gpu/drm/drm_edid.c
drivers/gpu/drm/drm_hashtab.c
drivers/gpu/drm/drm_memory.c
drivers/gpu/drm/exynos/exynos_drm_dsi.c
drivers/gpu/drm/exynos/exynos_drm_fimc.c
drivers/gpu/drm/exynos/exynos_drm_gsc.c
drivers/gpu/drm/exynos/exynos_hdmi.c
drivers/gpu/drm/gma500/mid_bios.c
drivers/gpu/drm/i915/gvt/cmd_parser.c
drivers/gpu/drm/i915/gvt/display.h
drivers/gpu/drm/i915/gvt/gtt.c
drivers/gpu/drm/i915/gvt/handlers.c
drivers/gpu/drm/i915/gvt/kvmgt.c
drivers/gpu/drm/i915/gvt/mmio.c
drivers/gpu/drm/i915/gvt/vgpu.c
drivers/gpu/drm/i915/i915_gem.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_drv.h
drivers/gpu/drm/i915/intel_dsi.c
drivers/gpu/drm/i915/intel_dvo.c
drivers/gpu/drm/i915/intel_engine_cs.c
drivers/gpu/drm/i915/intel_hdcp.c
drivers/gpu/drm/i915/intel_lvds.c
drivers/gpu/drm/i915/intel_panel.c
drivers/gpu/drm/i915/intel_pm.c
drivers/gpu/drm/i915/selftests/intel_uncore.c
drivers/gpu/drm/msm/disp/mdp4/mdp4_plane.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.h
drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_pipe.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_plane.c
drivers/gpu/drm/msm/disp/mdp5/mdp5_smp.c
drivers/gpu/drm/msm/dsi/dsi_host.c
drivers/gpu/drm/msm/hdmi/hdmi.c
drivers/gpu/drm/msm/hdmi/hdmi_phy.c
drivers/gpu/drm/msm/msm_atomic.c
drivers/gpu/drm/msm/msm_drv.c
drivers/gpu/drm/msm/msm_drv.h
drivers/gpu/drm/msm/msm_kms.h
drivers/gpu/drm/nouveau/nv84_fence.c
drivers/gpu/drm/nouveau/nvif/fifo.c
drivers/gpu/drm/nouveau/nvif/mmu.c
drivers/gpu/drm/nouveau/nvif/object.c
drivers/gpu/drm/nouveau/nvif/vmm.c
drivers/gpu/drm/nouveau/nvkm/core/event.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c
drivers/gpu/drm/omapdrm/omap_gem.c
drivers/gpu/drm/qxl/qxl_fb.c
drivers/gpu/drm/qxl/qxl_kms.c
drivers/gpu/drm/radeon/atom.c
drivers/gpu/drm/radeon/btc_dpm.c
drivers/gpu/drm/radeon/ci_dpm.c
drivers/gpu/drm/radeon/kv_dpm.c
drivers/gpu/drm/radeon/ni_dpm.c
drivers/gpu/drm/radeon/r600_dpm.c
drivers/gpu/drm/radeon/radeon_atombios.c
drivers/gpu/drm/radeon/radeon_combios.c
drivers/gpu/drm/radeon/radeon_gart.c
drivers/gpu/drm/radeon/radeon_test.c
drivers/gpu/drm/radeon/rs780_dpm.c
drivers/gpu/drm/radeon/rv6xx_dpm.c
drivers/gpu/drm/radeon/rv770_dpm.c
drivers/gpu/drm/radeon/si_dpm.c
drivers/gpu/drm/radeon/sumo_dpm.c
drivers/gpu/drm/radeon/trinity_dpm.c
drivers/gpu/drm/savage/savage_bci.c
drivers/gpu/drm/scheduler/gpu_scheduler.c
drivers/gpu/drm/selftests/test-drm_mm.c
drivers/gpu/drm/shmobile/Kconfig
drivers/gpu/drm/shmobile/shmob_drm_crtc.c
drivers/gpu/drm/shmobile/shmob_drm_crtc.h
drivers/gpu/drm/shmobile/shmob_drm_drv.h
drivers/gpu/drm/shmobile/shmob_drm_kms.c
drivers/gpu/drm/shmobile/shmob_drm_kms.h
drivers/gpu/drm/shmobile/shmob_drm_plane.c
drivers/gpu/drm/tinydrm/repaper.c
drivers/gpu/drm/ttm/ttm_page_alloc.c
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
drivers/gpu/drm/v3d/Kconfig
drivers/gpu/drm/vc4/vc4_plane.c
drivers/gpu/drm/via/via_dmablit.c
drivers/gpu/vga/Kconfig
drivers/gpu/vga/vgaarb.c
drivers/hid/hid-core.c
drivers/hid/hid-debug.c
drivers/hid/hid-picolcd_fb.c
drivers/hid/hid-sensor-hub.c
drivers/hid/hidraw.c
drivers/hid/intel-ish-hid/ishtp-hid-client.c
drivers/hid/usbhid/Kconfig
drivers/hid/wacom_sys.c
drivers/hv/hv.c
drivers/hv/ring_buffer.c
drivers/hwmon/acpi_power_meter.c
drivers/hwmon/aspeed-pwm-tacho.c
drivers/hwmon/coretemp.c
drivers/hwmon/gpio-fan.c
drivers/hwmon/i5k_amb.c
drivers/hwmon/ibmpex.c
drivers/hwmon/ibmpowernv.c
drivers/hwmon/iio_hwmon.c
drivers/hwmon/nct6683.c
drivers/hwmon/nct6775.c
drivers/hwmon/pmbus/pmbus_core.c
drivers/hwmon/pmbus/ucd9000.c
drivers/hwmon/pwm-fan.c
drivers/hwspinlock/Kconfig
drivers/hwspinlock/hwspinlock_core.c
drivers/hwspinlock/hwspinlock_internal.h
drivers/hwspinlock/omap_hwspinlock.c
drivers/hwspinlock/qcom_hwspinlock.c
drivers/hwspinlock/sirf_hwspinlock.c
drivers/hwspinlock/sprd_hwspinlock.c
drivers/hwspinlock/u8500_hsem.c
drivers/hwtracing/coresight/coresight-etb10.c
drivers/hwtracing/coresight/of_coresight.c
drivers/i2c/algos/i2c-algo-bit.c
drivers/i2c/algos/i2c-algo-pca.c
drivers/i2c/algos/i2c-algo-pcf.c
drivers/i2c/busses/Kconfig
drivers/i2c/busses/Makefile
drivers/i2c/busses/i2c-amd756-s4882.c
drivers/i2c/busses/i2c-aspeed.c
drivers/i2c/busses/i2c-at91.c
drivers/i2c/busses/i2c-axxia.c
drivers/i2c/busses/i2c-designware-common.c
drivers/i2c/busses/i2c-designware-core.h
drivers/i2c/busses/i2c-designware-master.c
drivers/i2c/busses/i2c-designware-slave.c
drivers/i2c/busses/i2c-diolan-u2c.c
drivers/i2c/busses/i2c-efm32.c
drivers/i2c/busses/i2c-eg20t.c
drivers/i2c/busses/i2c-emev2.c
drivers/i2c/busses/i2c-exynos5.c
drivers/i2c/busses/i2c-gpio.c
drivers/i2c/busses/i2c-hix5hd2.c
drivers/i2c/busses/i2c-i801.c
drivers/i2c/busses/i2c-ibm_iic.c
drivers/i2c/busses/i2c-imx-lpi2c.c
drivers/i2c/busses/i2c-imx.c
drivers/i2c/busses/i2c-kempld.c
drivers/i2c/busses/i2c-mlxcpld.c
drivers/i2c/busses/i2c-mt65xx.c
drivers/i2c/busses/i2c-mxs.c
drivers/i2c/busses/i2c-nforce2-s4985.c
drivers/i2c/busses/i2c-nforce2.c
drivers/i2c/busses/i2c-nomadik.c
drivers/i2c/busses/i2c-ocores.c
drivers/i2c/busses/i2c-omap.c
drivers/i2c/busses/i2c-opal.c
drivers/i2c/busses/i2c-pasemi.c
drivers/i2c/busses/i2c-pca-platform.c
drivers/i2c/busses/i2c-pnx.c
drivers/i2c/busses/i2c-qup.c
drivers/i2c/busses/i2c-rcar.c
drivers/i2c/busses/i2c-riic.c
drivers/i2c/busses/i2c-rk3x.c
drivers/i2c/busses/i2c-robotfuzz-osif.c
drivers/i2c/busses/i2c-s3c2410.c
drivers/i2c/busses/i2c-sh_mobile.c
drivers/i2c/busses/i2c-stm32.c [new file with mode: 0644]
drivers/i2c/busses/i2c-stm32.h
drivers/i2c/busses/i2c-stm32f7.c
drivers/i2c/busses/i2c-stu300.c
drivers/i2c/busses/i2c-synquacer.c
drivers/i2c/busses/i2c-tegra.c
drivers/i2c/busses/i2c-xiic.c
drivers/i2c/busses/i2c-xlp9xx.c
drivers/i2c/i2c-core-base.c
drivers/i2c/i2c-core-of.c
drivers/i2c/i2c-core-smbus.c
drivers/i2c/i2c-dev.c
drivers/i2c/i2c-mux.c
drivers/i2c/i2c-stub.c
drivers/i2c/muxes/i2c-demux-pinctrl.c
drivers/i2c/muxes/i2c-mux-gpio.c
drivers/i2c/muxes/i2c-mux-ltc4306.c
drivers/i2c/muxes/i2c-mux-pca954x.c
drivers/i2c/muxes/i2c-mux-reg.c
drivers/ide/hpt366.c
drivers/ide/ide-probe.c
drivers/ide/it821x.c
drivers/iio/adc/at91_adc.c
drivers/iio/adc/max1027.c
drivers/iio/adc/max1363.c
drivers/iio/adc/twl6030-gpadc.c
drivers/iio/dac/ad5592r-base.c
drivers/iio/imu/adis_buffer.c
drivers/iio/inkern.c
drivers/iio/multiplexer/iio-mux.c
drivers/infiniband/core/cache.c
drivers/infiniband/core/cma.c
drivers/infiniband/core/device.c
drivers/infiniband/core/fmr_pool.c
drivers/infiniband/core/iwpm_util.c
drivers/infiniband/core/umem_odp.c
drivers/infiniband/core/uverbs_cmd.c
drivers/infiniband/hw/cxgb3/cxio_hal.c
drivers/infiniband/hw/cxgb4/device.c
drivers/infiniband/hw/cxgb4/id_table.c
drivers/infiniband/hw/cxgb4/qp.c
drivers/infiniband/hw/hfi1/sdma.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/hns/hns_roce_mr.c
drivers/infiniband/hw/mlx4/mad.c
drivers/infiniband/hw/mlx4/main.c
drivers/infiniband/hw/mlx4/qp.c
drivers/infiniband/hw/mlx5/srq.c
drivers/infiniband/hw/mthca/mthca_allocator.c
drivers/infiniband/hw/mthca/mthca_cmd.c
drivers/infiniband/hw/mthca/mthca_eq.c
drivers/infiniband/hw/mthca/mthca_memfree.c
drivers/infiniband/hw/mthca/mthca_mr.c
drivers/infiniband/hw/mthca/mthca_profile.c
drivers/infiniband/hw/mthca/mthca_qp.c
drivers/infiniband/hw/mthca/mthca_srq.c
drivers/infiniband/hw/nes/nes_mgt.c
drivers/infiniband/hw/nes/nes_nic.c
drivers/infiniband/hw/nes/nes_verbs.c
drivers/infiniband/hw/ocrdma/ocrdma_hw.c
drivers/infiniband/hw/ocrdma/ocrdma_main.c
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
drivers/infiniband/hw/qedr/main.c
drivers/infiniband/hw/qedr/verbs.c
drivers/infiniband/hw/qib/qib_iba6120.c
drivers/infiniband/hw/qib/qib_iba7220.c
drivers/infiniband/hw/qib/qib_iba7322.c
drivers/infiniband/hw/qib/qib_init.c
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c
drivers/infiniband/hw/usnic/usnic_vnic.c
drivers/infiniband/sw/rdmavt/qp.c
drivers/infiniband/ulp/ipoib/ipoib_cm.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/iser/iser_initiator.c
drivers/infiniband/ulp/isert/ib_isert.c
drivers/infiniband/ulp/srp/ib_srp.c
drivers/infiniband/ulp/srpt/ib_srpt.c
drivers/input/Kconfig
drivers/input/joystick/Kconfig
drivers/input/joystick/iforce/Kconfig
drivers/input/joystick/joydump.c
drivers/input/joystick/walkera0701.c
drivers/input/keyboard/Kconfig
drivers/input/keyboard/Makefile
drivers/input/keyboard/clps711x-keypad.c
drivers/input/keyboard/matrix_keypad.c
drivers/input/keyboard/mtk-pmic-keys.c [new file with mode: 0644]
drivers/input/keyboard/omap4-keypad.c
drivers/input/keyboard/samsung-keypad.c
drivers/input/matrix-keymap.c
drivers/input/misc/Kconfig
drivers/input/misc/rotary_encoder.c
drivers/input/mouse/Kconfig
drivers/input/mouse/alps.c
drivers/input/rmi4/rmi_driver.c
drivers/input/rmi4/rmi_f11.c
drivers/input/rmi4/rmi_f12.c
drivers/input/rmi4/rmi_f54.c
drivers/input/rmi4/rmi_spi.c
drivers/input/serio/Kconfig
drivers/input/touchscreen/wm97xx-core.c
drivers/iommu/Kconfig
drivers/iommu/amd_iommu.c
drivers/iommu/arm-smmu.c
drivers/iommu/dmar.c
drivers/iommu/intel-iommu.c
drivers/iommu/omap-iommu.c
drivers/iommu/rockchip-iommu.c
drivers/iommu/tegra-gart.c
drivers/ipack/carriers/tpci200.c
drivers/irqchip/irq-alpine-msi.c
drivers/irqchip/irq-gic-v2m.c
drivers/irqchip/irq-gic-v3-its.c
drivers/irqchip/irq-gic-v3.c
drivers/irqchip/irq-imgpdc.c
drivers/irqchip/irq-mvebu-gicp.c
drivers/irqchip/irq-partition-percpu.c
drivers/irqchip/irq-s3c24xx.c
drivers/isdn/capi/capi.c
drivers/isdn/capi/capidrv.c
drivers/isdn/gigaset/capi.c
drivers/isdn/gigaset/common.c
drivers/isdn/gigaset/i4l.c
drivers/isdn/hardware/avm/b1.c
drivers/isdn/hisax/fsm.c
drivers/isdn/hisax/hfc_2bds0.c
drivers/isdn/hisax/hfc_2bs0.c
drivers/isdn/hisax/netjet.c
drivers/isdn/i4l/isdn_bsdcomp.c
drivers/isdn/i4l/isdn_common.c
drivers/isdn/mISDN/fsm.c
drivers/leds/leds-adp5520.c
drivers/leds/leds-apu.c
drivers/leds/leds-cr0014114.c
drivers/leds/leds-da9052.c
drivers/leds/leds-lp5521.c
drivers/leds/leds-lp5523.c
drivers/leds/leds-lp5562.c
drivers/leds/leds-lp55xx-common.c
drivers/leds/leds-lp8501.c
drivers/leds/leds-lt3593.c
drivers/leds/leds-mc13783.c
drivers/leds/leds-mlxcpld.c
drivers/leds/leds-netxbig.c
drivers/leds/leds-ns2.c
drivers/leds/leds-pca955x.c
drivers/leds/leds-pca963x.c
drivers/leds/leds-tca6507.c
drivers/lightnvm/pblk-gc.c
drivers/lightnvm/pblk-init.c
drivers/lightnvm/pblk-rb.c
drivers/lightnvm/pblk-recovery.c
drivers/mailbox/hi6220-mailbox.c
drivers/mailbox/mailbox-sti.c
drivers/mailbox/omap-mailbox.c
drivers/mailbox/pcc.c
drivers/mailbox/ti-msgmgr.c
drivers/md/Kconfig
drivers/md/Makefile
drivers/md/bcache/Kconfig
drivers/md/bcache/btree.c
drivers/md/bcache/extents.c
drivers/md/bcache/super.c
drivers/md/bcache/sysfs.c
drivers/md/dm-bio-prison-v1.c
drivers/md/dm-bio-prison-v2.c
drivers/md/dm-cache-policy-smq.c
drivers/md/dm-cache-target.c
drivers/md/dm-core.h
drivers/md/dm-crypt.c
drivers/md/dm-integrity.c
drivers/md/dm-ioctl.c
drivers/md/dm-kcopyd.c
drivers/md/dm-region-hash.c
drivers/md/dm-snap.c
drivers/md/dm-stats.c
drivers/md/dm-switch.c
drivers/md/dm-table.c
drivers/md/dm-thin.c
drivers/md/dm-verity-target.c
drivers/md/dm-writecache.c [new file with mode: 0644]
drivers/md/dm-zoned-target.c
drivers/md/md-bitmap.c
drivers/md/md-cluster.c
drivers/md/md-multipath.c
drivers/md/raid0.c
drivers/md/raid1.c
drivers/md/raid10.c
drivers/md/raid5.c
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c
drivers/media/dvb-core/dmxdev.c
drivers/media/dvb-core/dvb_demux.c
drivers/media/dvb-core/dvb_ringbuffer.c
drivers/media/dvb-frontends/Kconfig
drivers/media/dvb-frontends/dib3000.h
drivers/media/dvb-frontends/dib3000mb.c
drivers/media/dvb-frontends/dib7000p.c
drivers/media/dvb-frontends/dib8000.c
drivers/media/dvb-frontends/dib9000.c
drivers/media/dvb-frontends/eds1547.h
drivers/media/dvb-frontends/nxt200x.c
drivers/media/dvb-frontends/or51211.c
drivers/media/dvb-frontends/sp8870.c
drivers/media/dvb-frontends/sp887x.c
drivers/media/dvb-frontends/tda1004x.c
drivers/media/dvb-frontends/tda10071.c
drivers/media/dvb-frontends/z0194a.h
drivers/media/i2c/max2175.c
drivers/media/i2c/s5k5baf.c
drivers/media/pci/bt8xx/Kconfig
drivers/media/pci/bt8xx/bttv-risc.c
drivers/media/pci/cx18/cx18-dvb.c
drivers/media/pci/cx18/cx18-streams.c
drivers/media/pci/cx23885/cx23885-alsa.c
drivers/media/pci/cx23885/cx23885-cards.c
drivers/media/pci/cx25821/cx25821-alsa.c
drivers/media/pci/cx88/cx88-alsa.c
drivers/media/pci/ivtv/ivtvfb.c
drivers/media/pci/meye/Kconfig
drivers/media/pci/meye/meye.c
drivers/media/pci/pt1/pt1.c
drivers/media/pci/saa7134/saa7134-alsa.c
drivers/media/pci/ttpci/Kconfig
drivers/media/pci/ttpci/av7110_ipack.c
drivers/media/platform/am437x/am437x-vpfe.c
drivers/media/platform/davinci/vpif_capture.c
drivers/media/platform/marvell-ccic/mmp-driver.c
drivers/media/platform/pxa_camera.c
drivers/media/platform/qcom/camss-8x16/camss-csid.c
drivers/media/platform/qcom/camss-8x16/camss-csiphy.c
drivers/media/platform/qcom/camss-8x16/camss-ispif.c
drivers/media/platform/qcom/camss-8x16/camss-vfe.c
drivers/media/platform/qcom/camss-8x16/camss.c
drivers/media/platform/soc_camera/sh_mobile_ceu_camera.c
drivers/media/platform/soc_camera/soc_camera.c
drivers/media/platform/via-camera.c
drivers/media/platform/vivid/vivid-core.c
drivers/media/platform/vsp1/vsp1_entity.c
drivers/media/platform/xilinx/xilinx-vipp.c
drivers/media/radio/Kconfig
drivers/media/radio/si470x/Kconfig
drivers/media/radio/wl128x/Kconfig
drivers/media/rc/ir-rx51.c
drivers/media/usb/au0828/au0828-video.c
drivers/media/usb/cpia2/cpia2_usb.c
drivers/media/usb/cx231xx/cx231xx-audio.c
drivers/media/usb/cx231xx/cx231xx-core.c
drivers/media/usb/cx231xx/cx231xx-vbi.c
drivers/media/usb/dvb-usb-v2/Kconfig
drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
drivers/media/usb/dvb-usb-v2/gl861.c
drivers/media/usb/dvb-usb-v2/lmedm04.c
drivers/media/usb/dvb-usb-v2/lmedm04.h
drivers/media/usb/dvb-usb-v2/mxl111sf.c
drivers/media/usb/dvb-usb-v2/mxl111sf.h
drivers/media/usb/dvb-usb/Kconfig
drivers/media/usb/dvb-usb/a800.c
drivers/media/usb/dvb-usb/af9005-fe.c
drivers/media/usb/dvb-usb/af9005-remote.c
drivers/media/usb/dvb-usb/af9005.c
drivers/media/usb/dvb-usb/af9005.h
drivers/media/usb/dvb-usb/az6027.c
drivers/media/usb/dvb-usb/cxusb.c
drivers/media/usb/dvb-usb/dibusb-common.c
drivers/media/usb/dvb-usb/dibusb-mb.c
drivers/media/usb/dvb-usb/dibusb-mc-common.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-firmware.c
drivers/media/usb/dvb-usb/dvb-usb-init.c
drivers/media/usb/dvb-usb/dw2102.c
drivers/media/usb/dvb-usb/friio-fe.c
drivers/media/usb/dvb-usb/friio.c
drivers/media/usb/dvb-usb/friio.h
drivers/media/usb/dvb-usb/gp8psk.c
drivers/media/usb/dvb-usb/gp8psk.h
drivers/media/usb/dvb-usb/m920x.c
drivers/media/usb/dvb-usb/nova-t-usb2.c
drivers/media/usb/dvb-usb/opera1.c
drivers/media/usb/dvb-usb/ttusb2.c
drivers/media/usb/dvb-usb/ttusb2.h
drivers/media/usb/dvb-usb/umt-010.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/go7007/go7007-fw.c
drivers/media/usb/go7007/go7007-usb.c
drivers/media/usb/gspca/m5602/Kconfig
drivers/media/usb/gspca/t613.c
drivers/media/usb/pvrusb2/pvrusb2-hdw.c
drivers/media/usb/pvrusb2/pvrusb2-std.c
drivers/media/usb/stk1160/stk1160-core.c
drivers/media/usb/stk1160/stk1160-video.c
drivers/media/usb/stkwebcam/stk-webcam.c
drivers/media/usb/tm6000/tm6000-video.c
drivers/media/usb/ttusb-dec/Kconfig
drivers/media/usb/usbtv/usbtv-video.c
drivers/media/usb/usbvision/usbvision-video.c
drivers/media/usb/uvc/uvc_video.c
drivers/media/usb/zr364xx/Kconfig
drivers/media/v4l2-core/v4l2-event.c
drivers/media/v4l2-core/v4l2-flash-led-class.c
drivers/media/v4l2-core/videobuf-dma-sg.c
drivers/memory/Kconfig
drivers/memory/Makefile
drivers/memory/brcmstb_dpfe.c
drivers/memory/of_memory.c
drivers/memory/omap-gpmc.c
drivers/memory/tegra/Makefile
drivers/memory/tegra/mc.c
drivers/memory/tegra/mc.h
drivers/memory/tegra/tegra114.c
drivers/memory/tegra/tegra124.c
drivers/memory/tegra/tegra20.c [new file with mode: 0644]
drivers/memory/tegra/tegra210.c
drivers/memory/tegra/tegra30.c
drivers/memory/tegra20-mc.c [deleted file]
drivers/memory/ti-aemif.c
drivers/memstick/core/ms_block.c
drivers/message/fusion/mptlan.c
drivers/mfd/Makefile
drivers/mfd/ab8500-debugfs.c
drivers/mfd/abx500-core.c
drivers/mfd/arizona-core.c
drivers/mfd/asic3.c
drivers/mfd/atmel-smc.c
drivers/mfd/axp20x.c
drivers/mfd/cros_ec.c
drivers/mfd/cros_ec_acpi_gpe.c [deleted file]
drivers/mfd/cros_ec_dev.c
drivers/mfd/cros_ec_i2c.c
drivers/mfd/da9062-core.c
drivers/mfd/htc-i2cpld.c
drivers/mfd/intel-lpss-pci.c
drivers/mfd/intel-lpss.c
drivers/mfd/janz-cmodio.c
drivers/mfd/jz4740-adc.c
drivers/mfd/max8997.c
drivers/mfd/mfd-core.c
drivers/mfd/motorola-cpcap.c
drivers/mfd/mt6397-core.c
drivers/mfd/omap-usb-host.c
drivers/mfd/omap-usb-tll.c
drivers/mfd/pcf50633-core.c
drivers/mfd/qcom-spmi-pmic.c
drivers/mfd/rave-sp.c
drivers/mfd/rc5t583.c
drivers/mfd/si476x-i2c.c
drivers/mfd/sm501.c
drivers/mfd/smsc-ece1099.c
drivers/mfd/sprd-sc27xx-spi.c
drivers/mfd/stm32-timers.c
drivers/mfd/syscon.c
drivers/mfd/ti_am335x_tscadc.c
drivers/mfd/timberdale.c
drivers/mfd/tps65090.c
drivers/mfd/tps6586x.c
drivers/mfd/tps65910.c
drivers/mfd/tps65911-comparator.c
drivers/mfd/tps68470.c
drivers/mfd/tps80031.c
drivers/mfd/twl-core.c
drivers/mfd/twl6030-irq.c
drivers/mfd/viperboard.c
drivers/mfd/wm8994-core.c
drivers/mfd/wm97xx-core.c
drivers/misc/altera-stapl/altera.c
drivers/misc/cxl/guest.c
drivers/misc/cxl/of.c
drivers/misc/eeprom/at24.c
drivers/misc/eeprom/idt_89hpesx.c
drivers/misc/genwqe/card_ddcb.c
drivers/misc/sgi-xp/xpc_main.c
drivers/misc/sgi-xp/xpc_partition.c
drivers/misc/sgi-xp/xpnet.c
drivers/misc/sram.c
drivers/misc/vmw_vmci/vmci_queue_pair.c
drivers/mmc/host/sdhci-omap.c
drivers/mtd/ar7part.c
drivers/mtd/bcm47xxpart.c
drivers/mtd/chips/cfi_cmdset_0001.c
drivers/mtd/chips/cfi_cmdset_0002.c
drivers/mtd/chips/cfi_cmdset_0020.c
drivers/mtd/devices/docg3.c
drivers/mtd/ftl.c
drivers/mtd/inftlmount.c
drivers/mtd/lpddr/lpddr_cmds.c
drivers/mtd/maps/physmap_of_core.c
drivers/mtd/maps/vmu-flash.c
drivers/mtd/mtdconcat.c
drivers/mtd/mtdoops.c
drivers/mtd/mtdswap.c
drivers/mtd/nand/onenand/onenand_base.c
drivers/mtd/nand/raw/davinci_nand.c
drivers/mtd/nand/raw/nand_bch.c
drivers/mtd/nand/raw/nandsim.c
drivers/mtd/nand/raw/qcom_nandc.c
drivers/mtd/nand/raw/s3c2410.c
drivers/mtd/nftlmount.c
drivers/mtd/ofpart.c
drivers/mtd/parsers/parser_trx.c
drivers/mtd/parsers/sharpslpart.c
drivers/mtd/rfd_ftl.c
drivers/mtd/sm_ftl.c
drivers/mtd/ssfdc.c
drivers/mtd/tests/pagetest.c
drivers/mtd/tests/stresstest.c
drivers/mtd/ubi/eba.c
drivers/mtd/ubi/wl.c
drivers/net/bonding/bond_main.c
drivers/net/can/grcan.c
drivers/net/can/slcan.c
drivers/net/dsa/b53/b53_common.c
drivers/net/ethernet/amazon/ena/ena_ethtool.c
drivers/net/ethernet/amd/lance.c
drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c
drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c
drivers/net/ethernet/atheros/atlx/atl2.c
drivers/net/ethernet/broadcom/bcm63xx_enet.c
drivers/net/ethernet/broadcom/bnx2.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c
drivers/net/ethernet/broadcom/cnic.c
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/brocade/bna/bnad.c
drivers/net/ethernet/calxeda/xgmac.c
drivers/net/ethernet/cavium/liquidio/octeon_droq.c
drivers/net/ethernet/cavium/liquidio/request_manager.c
drivers/net/ethernet/cavium/thunder/nic.h
drivers/net/ethernet/cavium/thunder/nicvf_main.c
drivers/net/ethernet/cavium/thunder/nicvf_queues.c
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
drivers/net/ethernet/chelsio/cxgb4/sge.c
drivers/net/ethernet/cortina/gemini.c
drivers/net/ethernet/ethoc.c
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c
drivers/net/ethernet/freescale/ucc_geth.c
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c
drivers/net/ethernet/hisilicon/hns/hns_enet.c
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c
drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c
drivers/net/ethernet/ibm/ibmveth.c
drivers/net/ethernet/intel/Kconfig
drivers/net/ethernet/intel/e1000/e1000_ethtool.c
drivers/net/ethernet/intel/e1000e/ethtool.c
drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
drivers/net/ethernet/intel/igb/igb_ethtool.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c
drivers/net/ethernet/intel/ixgb/ixgb_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe.h
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_type.h
drivers/net/ethernet/intel/ixgbevf/ethtool.c
drivers/net/ethernet/jme.c
drivers/net/ethernet/mellanox/mlx4/alloc.c
drivers/net/ethernet/mellanox/mlx4/cmd.c
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/eq.c
drivers/net/ethernet/mellanox/mlx4/icm.c
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
drivers/net/ethernet/mellanox/mlx5/core/en_main.c
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c
drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
drivers/net/ethernet/micrel/ksz884x.c
drivers/net/ethernet/moxa/moxart_ether.c
drivers/net/ethernet/neterion/vxge/vxge-config.c
drivers/net/ethernet/neterion/vxge/vxge-main.c
drivers/net/ethernet/netronome/nfp/abm/main.c
drivers/net/ethernet/netronome/nfp/flower/main.c
drivers/net/ethernet/netronome/nfp/flower/metadata.c
drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c
drivers/net/ethernet/netronome/nfp/nfp_net.h
drivers/net/ethernet/netronome/nfp/nfp_net_common.c
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_resource.c
drivers/net/ethernet/ni/nixge.c
drivers/net/ethernet/nvidia/forcedeth.c
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
drivers/net/ethernet/pasemi/pasemi_mac.c
drivers/net/ethernet/qlogic/qed/qed_debug.c
drivers/net/ethernet/qlogic/qed/qed_dev.c
drivers/net/ethernet/qlogic/qed/qed_init_ops.c
drivers/net/ethernet/qlogic/qed/qed_l2.c
drivers/net/ethernet/qlogic/qed/qed_mcp.c
drivers/net/ethernet/qlogic/qede/qede_filter.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
drivers/net/ethernet/qlogic/qlge/qlge_main.c
drivers/net/ethernet/qualcomm/emac/emac-sgmii.c
drivers/net/ethernet/sfc/ef10.c
drivers/net/ethernet/sfc/falcon/farch.c
drivers/net/ethernet/sfc/farch.c
drivers/net/ethernet/socionext/netsec.c
drivers/net/ethernet/stmicro/stmmac/dwmac-meson8b.c
drivers/net/ethernet/stmicro/stmmac/hwif.c
drivers/net/ethernet/stmicro/stmmac/stmmac.h
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
drivers/net/ethernet/ti/cpsw.c
drivers/net/ethernet/ti/netcp_ethss.c
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
drivers/net/ethernet/xilinx/xilinx_emaclite.c
drivers/net/gtp.c
drivers/net/hippi/rrunner.c
drivers/net/hyperv/Kconfig
drivers/net/hyperv/hyperv_net.h
drivers/net/hyperv/netvsc_drv.c
drivers/net/phy/dp83640.c
drivers/net/phy/mdio-gpio.c
drivers/net/phy/phy_led_triggers.c
drivers/net/ppp/bsd_comp.c
drivers/net/ppp/pptp.c
drivers/net/slip/slip.c
drivers/net/team/team.c
drivers/net/usb/asix_common.c
drivers/net/usb/ax88179_178a.c
drivers/net/usb/smsc95xx.c
drivers/net/usb/usbnet.c
drivers/net/virtio_net.c
drivers/net/wan/fsl_ucc_hdlc.c
drivers/net/wireless/ath/ath10k/htt_rx.c
drivers/net/wireless/ath/ath10k/wmi-tlv.c
drivers/net/wireless/ath/ath5k/debug.c
drivers/net/wireless/ath/ath5k/phy.c
drivers/net/wireless/ath/ath6kl/cfg80211.c
drivers/net/wireless/ath/ath9k/ar9003_paprd.c
drivers/net/wireless/ath/ath9k/hw.c
drivers/net/wireless/ath/carl9170/main.c
drivers/net/wireless/broadcom/b43/phy_n.c
drivers/net/wireless/broadcom/b43legacy/main.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c
drivers/net/wireless/cisco/airo.c
drivers/net/wireless/intel/ipw2x00/ipw2100.c
drivers/net/wireless/intel/ipw2x00/ipw2200.c
drivers/net/wireless/intel/iwlegacy/common.c
drivers/net/wireless/intel/iwlwifi/mvm/scan.c
drivers/net/wireless/intersil/hostap/hostap_info.c
drivers/net/wireless/intersil/hostap/hostap_ioctl.c
drivers/net/wireless/intersil/p54/eeprom.c
drivers/net/wireless/intersil/prism54/oid_mgt.c
drivers/net/wireless/mac80211_hwsim.c
drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c
drivers/net/wireless/marvell/mwifiex/cfg80211.c
drivers/net/wireless/marvell/mwifiex/sdio.c
drivers/net/wireless/mediatek/mt76/mac80211.c
drivers/net/wireless/quantenna/qtnfmac/commands.c
drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
drivers/net/wireless/realtek/rtlwifi/efuse.c
drivers/net/wireless/realtek/rtlwifi/usb.c
drivers/net/wireless/st/cw1200/queue.c
drivers/net/wireless/st/cw1200/scan.c
drivers/net/wireless/zydas/zd1211rw/zd_mac.c
drivers/net/xen-netback/xenbus.c
drivers/net/xen-netfront.c
drivers/nfc/fdp/i2c.c
drivers/ntb/hw/amd/ntb_hw_amd.c
drivers/ntb/hw/idt/ntb_hw_idt.c
drivers/ntb/hw/intel/Makefile
drivers/ntb/hw/intel/ntb_hw_gen1.c [moved from drivers/ntb/hw/intel/ntb_hw_intel.c with 74% similarity]
drivers/ntb/hw/intel/ntb_hw_gen1.h [new file with mode: 0644]
drivers/ntb/hw/intel/ntb_hw_gen3.c [new file with mode: 0644]
drivers/ntb/hw/intel/ntb_hw_gen3.h [new file with mode: 0644]
drivers/ntb/hw/intel/ntb_hw_intel.h
drivers/ntb/ntb_transport.c
drivers/nvmem/rockchip-efuse.c
drivers/nvmem/sunxi_sid.c
drivers/of/platform.c
drivers/of/unittest.c
drivers/opp/ti-opp-supply.c
drivers/oprofile/event_buffer.c
drivers/parport/Kconfig
drivers/pci/Kconfig
drivers/pci/Makefile
drivers/pci/cadence/Kconfig [deleted file]
drivers/pci/cadence/Makefile [deleted file]
drivers/pci/controller/Kconfig [moved from drivers/pci/host/Kconfig with 90% similarity]
drivers/pci/controller/Makefile [moved from drivers/pci/host/Makefile with 89% similarity]
drivers/pci/controller/dwc/Kconfig [moved from drivers/pci/dwc/Kconfig with 100% similarity]
drivers/pci/controller/dwc/Makefile [moved from drivers/pci/dwc/Makefile with 100% similarity]
drivers/pci/controller/dwc/pci-dra7xx.c [moved from drivers/pci/dwc/pci-dra7xx.c with 99% similarity]
drivers/pci/controller/dwc/pci-exynos.c [moved from drivers/pci/dwc/pci-exynos.c with 100% similarity]
drivers/pci/controller/dwc/pci-imx6.c [moved from drivers/pci/dwc/pci-imx6.c with 100% similarity]
drivers/pci/controller/dwc/pci-keystone-dw.c [moved from drivers/pci/dwc/pci-keystone-dw.c with 100% similarity]
drivers/pci/controller/dwc/pci-keystone.c [moved from drivers/pci/dwc/pci-keystone.c with 100% similarity]
drivers/pci/controller/dwc/pci-keystone.h [moved from drivers/pci/dwc/pci-keystone.h with 100% similarity]
drivers/pci/controller/dwc/pci-layerscape.c [moved from drivers/pci/dwc/pci-layerscape.c with 100% similarity]
drivers/pci/controller/dwc/pcie-armada8k.c [moved from drivers/pci/dwc/pcie-armada8k.c with 100% similarity]
drivers/pci/controller/dwc/pcie-artpec6.c [moved from drivers/pci/dwc/pcie-artpec6.c with 100% similarity]
drivers/pci/controller/dwc/pcie-designware-ep.c [moved from drivers/pci/dwc/pcie-designware-ep.c with 98% similarity]
drivers/pci/controller/dwc/pcie-designware-host.c [moved from drivers/pci/dwc/pcie-designware-host.c with 99% similarity]
drivers/pci/controller/dwc/pcie-designware-plat.c [moved from drivers/pci/dwc/pcie-designware-plat.c with 100% similarity]
drivers/pci/controller/dwc/pcie-designware.c [moved from drivers/pci/dwc/pcie-designware.c with 100% similarity]
drivers/pci/controller/dwc/pcie-designware.h [moved from drivers/pci/dwc/pcie-designware.h with 100% similarity]
drivers/pci/controller/dwc/pcie-hisi.c [moved from drivers/pci/dwc/pcie-hisi.c with 99% similarity]
drivers/pci/controller/dwc/pcie-histb.c [moved from drivers/pci/dwc/pcie-histb.c with 100% similarity]
drivers/pci/controller/dwc/pcie-kirin.c [moved from drivers/pci/dwc/pcie-kirin.c with 100% similarity]
drivers/pci/controller/dwc/pcie-qcom.c [moved from drivers/pci/dwc/pcie-qcom.c with 100% similarity]
drivers/pci/controller/dwc/pcie-spear13xx.c [moved from drivers/pci/dwc/pcie-spear13xx.c with 100% similarity]
drivers/pci/controller/pci-aardvark.c [moved from drivers/pci/host/pci-aardvark.c with 100% similarity]
drivers/pci/controller/pci-ftpci100.c [moved from drivers/pci/host/pci-ftpci100.c with 100% similarity]
drivers/pci/controller/pci-host-common.c [moved from drivers/pci/host/pci-host-common.c with 100% similarity]
drivers/pci/controller/pci-host-generic.c [moved from drivers/pci/host/pci-host-generic.c with 100% similarity]
drivers/pci/controller/pci-hyperv.c [moved from drivers/pci/host/pci-hyperv.c with 100% similarity]
drivers/pci/controller/pci-mvebu.c [moved from drivers/pci/host/pci-mvebu.c with 100% similarity]
drivers/pci/controller/pci-rcar-gen2.c [moved from drivers/pci/host/pci-rcar-gen2.c with 100% similarity]
drivers/pci/controller/pci-tegra.c [moved from drivers/pci/host/pci-tegra.c with 100% similarity]
drivers/pci/controller/pci-thunder-ecam.c [moved from drivers/pci/host/pci-thunder-ecam.c with 100% similarity]
drivers/pci/controller/pci-thunder-pem.c [moved from drivers/pci/host/pci-thunder-pem.c with 100% similarity]
drivers/pci/controller/pci-v3-semi.c [moved from drivers/pci/host/pci-v3-semi.c with 100% similarity]
drivers/pci/controller/pci-versatile.c [moved from drivers/pci/host/pci-versatile.c with 100% similarity]
drivers/pci/controller/pci-xgene-msi.c [moved from drivers/pci/host/pci-xgene-msi.c with 100% similarity]
drivers/pci/controller/pci-xgene.c [moved from drivers/pci/host/pci-xgene.c with 100% similarity]
drivers/pci/controller/pcie-altera-msi.c [moved from drivers/pci/host/pcie-altera-msi.c with 100% similarity]
drivers/pci/controller/pcie-altera.c [moved from drivers/pci/host/pcie-altera.c with 100% similarity]
drivers/pci/controller/pcie-cadence-ep.c [moved from drivers/pci/cadence/pcie-cadence-ep.c with 99% similarity]
drivers/pci/controller/pcie-cadence-host.c [moved from drivers/pci/cadence/pcie-cadence-host.c with 100% similarity]
drivers/pci/controller/pcie-cadence.c [moved from drivers/pci/cadence/pcie-cadence.c with 100% similarity]
drivers/pci/controller/pcie-cadence.h [moved from drivers/pci/cadence/pcie-cadence.h with 100% similarity]
drivers/pci/controller/pcie-iproc-bcma.c [moved from drivers/pci/host/pcie-iproc-bcma.c with 100% similarity]
drivers/pci/controller/pcie-iproc-msi.c [moved from drivers/pci/host/pcie-iproc-msi.c with 100% similarity]
drivers/pci/controller/pcie-iproc-platform.c [moved from drivers/pci/host/pcie-iproc-platform.c with 100% similarity]
drivers/pci/controller/pcie-iproc.c [moved from drivers/pci/host/pcie-iproc.c with 100% similarity]
drivers/pci/controller/pcie-iproc.h [moved from drivers/pci/host/pcie-iproc.h with 100% similarity]
drivers/pci/controller/pcie-mediatek.c [moved from drivers/pci/host/pcie-mediatek.c with 100% similarity]
drivers/pci/controller/pcie-mobiveil.c [moved from drivers/pci/host/pcie-mobiveil.c with 100% similarity]
drivers/pci/controller/pcie-rcar.c [moved from drivers/pci/host/pcie-rcar.c with 100% similarity]
drivers/pci/controller/pcie-rockchip-ep.c [moved from drivers/pci/host/pcie-rockchip-ep.c with 99% similarity]
drivers/pci/controller/pcie-rockchip-host.c [moved from drivers/pci/host/pcie-rockchip-host.c with 100% similarity]
drivers/pci/controller/pcie-rockchip.c [moved from drivers/pci/host/pcie-rockchip.c with 100% similarity]
drivers/pci/controller/pcie-rockchip.h [moved from drivers/pci/host/pcie-rockchip.h with 100% similarity]
drivers/pci/controller/pcie-tango.c [moved from drivers/pci/host/pcie-tango.c with 100% similarity]
drivers/pci/controller/pcie-xilinx-nwl.c [moved from drivers/pci/host/pcie-xilinx-nwl.c with 100% similarity]
drivers/pci/controller/pcie-xilinx.c [moved from drivers/pci/host/pcie-xilinx.c with 100% similarity]
drivers/pci/controller/vmd.c [moved from drivers/pci/host/vmd.c with 100% similarity]
drivers/pci/msi.c
drivers/pci/pci-sysfs.c
drivers/pci/pcie/Kconfig
drivers/pci/pcie/Makefile
drivers/pci/pcie/aer.c [new file with mode: 0644]
drivers/pci/pcie/aer/Kconfig [deleted file]
drivers/pci/pcie/aer/Kconfig.debug [deleted file]
drivers/pci/pcie/aer/Makefile [deleted file]
drivers/pci/pcie/aer/aerdrv.c [deleted file]
drivers/pci/pcie/aer/aerdrv.h [deleted file]
drivers/pci/pcie/aer/aerdrv_acpi.c [deleted file]
drivers/pci/pcie/aer/aerdrv_core.c [deleted file]
drivers/pci/pcie/aer/aerdrv_errprint.c [deleted file]
drivers/pci/pcie/aer/ecrc.c [deleted file]
drivers/pci/pcie/aer_inject.c [moved from drivers/pci/pcie/aer/aer_inject.c with 99% similarity]
drivers/pci/pcie/dpc.c
drivers/pci/pcie/portdrv.h
drivers/pcmcia/cistpl.c
drivers/pcmcia/pd6729.c
drivers/pinctrl/bcm/pinctrl-bcm2835.c
drivers/pinctrl/berlin/berlin.c
drivers/pinctrl/freescale/pinctrl-imx.c
drivers/pinctrl/freescale/pinctrl-imx1-core.c
drivers/pinctrl/freescale/pinctrl-mxs.c
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c
drivers/pinctrl/mvebu/pinctrl-armada-xp.c
drivers/pinctrl/mvebu/pinctrl-mvebu.c
drivers/pinctrl/pinctrl-at91-pio4.c
drivers/pinctrl/pinctrl-at91.c
drivers/pinctrl/pinctrl-axp209.c
drivers/pinctrl/pinctrl-digicolor.c
drivers/pinctrl/pinctrl-ingenic.c
drivers/pinctrl/pinctrl-lantiq.c
drivers/pinctrl/pinctrl-lpc18xx.c
drivers/pinctrl/pinctrl-ocelot.c
drivers/pinctrl/pinctrl-rockchip.c
drivers/pinctrl/pinctrl-single.c
drivers/pinctrl/pinctrl-st.c
drivers/pinctrl/pinctrl-xway.c
drivers/pinctrl/samsung/pinctrl-exynos.c
drivers/pinctrl/samsung/pinctrl-samsung.c
drivers/pinctrl/sh-pfc/core.c
drivers/pinctrl/sh-pfc/gpio.c
drivers/pinctrl/sh-pfc/pinctrl.c
drivers/pinctrl/sirf/pinctrl-sirf.c
drivers/pinctrl/spear/pinctrl-plgpio.c
drivers/pinctrl/spear/pinctrl-spear.c
drivers/pinctrl/sprd/pinctrl-sprd.c
drivers/pinctrl/sunxi/pinctrl-sunxi.c
drivers/pinctrl/tegra/pinctrl-tegra.c
drivers/pinctrl/ti/pinctrl-ti-iodelay.c
drivers/pinctrl/vt8500/pinctrl-wmt.c
drivers/pinctrl/zte/pinctrl-zx.c
drivers/platform/chrome/cros_ec_debugfs.c
drivers/platform/mellanox/mlxreg-hotplug.c
drivers/platform/x86/Kconfig
drivers/platform/x86/acer-wmi.c
drivers/platform/x86/alienware-wmi.c
drivers/platform/x86/apple-gmux.c
drivers/platform/x86/asus-laptop.c
drivers/platform/x86/asus-wireless.c
drivers/platform/x86/asus-wmi.c
drivers/platform/x86/dell-laptop.c
drivers/platform/x86/dell-smbios-base.c
drivers/platform/x86/dell-wmi.c
drivers/platform/x86/fujitsu-laptop.c
drivers/platform/x86/ideapad-laptop.c
drivers/platform/x86/intel_ips.c
drivers/platform/x86/intel_scu_ipc.c
drivers/platform/x86/mlx-platform.c
drivers/platform/x86/panasonic-laptop.c
drivers/platform/x86/samsung-laptop.c
drivers/platform/x86/silead_dmi.c
drivers/platform/x86/thinkpad_acpi.c
drivers/power/supply/charger-manager.c
drivers/power/supply/power_supply_core.c
drivers/power/supply/wm97xx_battery.c
drivers/power/supply/z2_battery.c
drivers/powercap/powercap_sys.c
drivers/pwm/Kconfig
drivers/pwm/pwm-atmel-tcb.c
drivers/pwm/pwm-lp3943.c
drivers/pwm/pwm-lpss-platform.c
drivers/pwm/pwm-lpss.c
drivers/pwm/pwm-lpss.h
drivers/pwm/pwm-meson.c
drivers/pwm/pwm-rcar.c
drivers/pwm/pwm-stm32.c
drivers/rapidio/devices/rio_mport_cdev.c
drivers/rapidio/rio-scan.c
drivers/regulator/act8865-regulator.c
drivers/regulator/as3711-regulator.c
drivers/regulator/bcm590xx-regulator.c
drivers/regulator/da9063-regulator.c
drivers/regulator/gpio-regulator.c
drivers/regulator/max1586.c
drivers/regulator/max8660.c
drivers/regulator/max8997-regulator.c
drivers/regulator/max8998.c
drivers/regulator/mc13xxx-regulator-core.c
drivers/regulator/pbias-regulator.c
drivers/regulator/rc5t583-regulator.c
drivers/regulator/s2mps11.c
drivers/regulator/s5m8767.c
drivers/regulator/ti-abb-regulator.c
drivers/regulator/tps65090-regulator.c
drivers/regulator/tps65217-regulator.c
drivers/regulator/tps65218-regulator.c
drivers/regulator/tps65910-regulator.c
drivers/regulator/tps80031-regulator.c
drivers/remoteproc/Kconfig
drivers/remoteproc/da8xx_remoteproc.c
drivers/remoteproc/qcom_q6v5_pil.c
drivers/reset/reset-ti-syscon.c
drivers/reset/reset-uniphier.c
drivers/rpmsg/Kconfig
drivers/rpmsg/qcom_glink_native.c
drivers/rpmsg/qcom_glink_native.h
drivers/rpmsg/qcom_glink_rpm.c
drivers/rpmsg/qcom_glink_smem.c
drivers/rpmsg/qcom_smd.c
drivers/rpmsg/rpmsg_char.c
drivers/rpmsg/rpmsg_core.c
drivers/rpmsg/rpmsg_internal.h
drivers/rpmsg/virtio_rpmsg_bus.c
drivers/rtc/rtc-mt6397.c
drivers/s390/block/dasd_eer.c
drivers/s390/block/dcssblk.c
drivers/s390/char/keyboard.c
drivers/s390/char/sclp_sd.c
drivers/s390/char/tty3270.c
drivers/s390/char/vmur.c
drivers/s390/char/zcore.c
drivers/s390/cio/qdio_setup.c
drivers/s390/cio/qdio_thinint.c
drivers/s390/crypto/pkey_api.c
drivers/s390/net/ctcm_main.c
drivers/s390/net/qeth_core_main.c
drivers/sbus/char/oradax.c
drivers/scsi/BusLogic.c
drivers/scsi/aacraid/aachba.c
drivers/scsi/aacraid/commctrl.c
drivers/scsi/aacraid/linit.c
drivers/scsi/aha1542.c
drivers/scsi/aic7xxx/aic79xx_core.c
drivers/scsi/aic7xxx/aic7xxx_core.c
drivers/scsi/aic94xx/aic94xx_hwi.c
drivers/scsi/aic94xx/aic94xx_init.c
drivers/scsi/arm/queue.c
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/bfa/bfad_attr.c
drivers/scsi/bfa/bfad_bsg.c
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
drivers/scsi/bnx2fc/bnx2fc_io.c
drivers/scsi/csiostor/csio_wr.c
drivers/scsi/esas2r/esas2r_init.c
drivers/scsi/fcoe/fcoe_ctlr.c
drivers/scsi/fnic/fnic_debugfs.c
drivers/scsi/fnic/fnic_trace.c
drivers/scsi/hpsa.c
drivers/scsi/ipr.c
drivers/scsi/isci/init.c
drivers/scsi/libiscsi.c
drivers/scsi/libsas/sas_expander.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_mem.c
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/lpfc/lpfc_vport.c
drivers/scsi/mac53c94.c
drivers/scsi/megaraid.c
drivers/scsi/megaraid/megaraid_mm.c
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/megaraid/megaraid_sas_fusion.c
drivers/scsi/mpt3sas/mpt3sas_base.c
drivers/scsi/osst.c
drivers/scsi/pm8001/pm8001_ctl.c
drivers/scsi/pmcraid.c
drivers/scsi/qedi/qedi_main.c
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/qla2xxx/qla_mbx.c
drivers/scsi/qla2xxx/qla_nx.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla2xxx/qla_target.c
drivers/scsi/qla2xxx/tcm_qla2xxx.c
drivers/scsi/qla4xxx/ql4_nx.c
drivers/scsi/scsi_debug.c
drivers/scsi/sd_zbc.c
drivers/scsi/ses.c
drivers/scsi/sg.c
drivers/scsi/smartpqi/smartpqi_init.c
drivers/scsi/st.c
drivers/scsi/ufs/ufshcd-pltfrm.c
drivers/scsi/ufs/ufshcd.c
drivers/scsi/virtio_scsi.c
drivers/sh/clk/cpg.c
drivers/sh/intc/core.c
drivers/sh/maple/maple.c
drivers/slimbus/qcom-ctrl.c
drivers/soc/Makefile
drivers/soc/bcm/raspberrypi-power.c
drivers/soc/fsl/qbman/qman.c
drivers/soc/imx/gpc.c
drivers/soc/imx/gpcv2.c
drivers/soc/mediatek/mtk-infracfg.c
drivers/soc/mediatek/mtk-pmic-wrap.c
drivers/soc/mediatek/mtk-scpsys.c
drivers/soc/qcom/Kconfig
drivers/soc/qcom/Makefile
drivers/soc/qcom/cmd-db.c [new file with mode: 0644]
drivers/soc/qcom/mdt_loader.c
drivers/soc/qcom/qcom-geni-se.c [new file with mode: 0644]
drivers/soc/qcom/qmi_interface.c
drivers/soc/qcom/smd-rpm.c
drivers/soc/qcom/smem.c
drivers/soc/renesas/Kconfig
drivers/soc/renesas/Makefile
drivers/soc/renesas/r8a77470-sysc.c [new file with mode: 0644]
drivers/soc/renesas/r8a77990-sysc.c [new file with mode: 0644]
drivers/soc/renesas/r8a77995-sysc.c
drivers/soc/renesas/rcar-rst.c
drivers/soc/renesas/rcar-sysc.c
drivers/soc/renesas/rcar-sysc.h
drivers/soc/renesas/renesas-soc.c
drivers/soc/rockchip/pm_domains.c
drivers/soc/samsung/pm_domains.c
drivers/soc/ti/knav_qmss.h
drivers/soc/ti/knav_qmss_acc.c
drivers/soc/ti/knav_qmss_queue.c
drivers/soundwire/stream.c
drivers/spi/spi-davinci.c
drivers/spi/spi-ep93xx.c
drivers/spi/spi-gpio.c
drivers/spi/spi-imx.c
drivers/spi/spi-oc-tiny.c
drivers/spi/spi-pl022.c
drivers/spi/spi.c
drivers/staging/android/ion/ion_heap.c
drivers/staging/fbtft/fbtft-core.c
drivers/staging/fbtft/fbtft.h
drivers/staging/fsl-mc/bus/dpio/dpio-driver.txt
drivers/staging/greybus/audio_topology.c
drivers/staging/greybus/camera.c
drivers/staging/media/bcm2048/TODO
drivers/staging/media/imx/imx-media-dev.c
drivers/staging/media/zoran/Kconfig
drivers/staging/media/zoran/zoran_driver.c
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
drivers/staging/rtl8188eu/core/rtw_mlme.c
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
drivers/staging/rtl8192u/r8192U_core.c
drivers/staging/rtl8723bs/core/rtw_mlme.c
drivers/staging/rtlwifi/efuse.c
drivers/staging/rts5208/ms.c
drivers/staging/rts5208/rtsx_chip.c
drivers/staging/unisys/visorhba/visorhba_main.c
drivers/target/target_core_transport.c
drivers/target/target_core_user.c
drivers/thermal/imx_thermal.c
drivers/thermal/int340x_thermal/acpi_thermal_rel.c
drivers/thermal/int340x_thermal/int340x_thermal_zone.c
drivers/thermal/int340x_thermal/processor_thermal_device.c
drivers/thermal/mtk_thermal.c
drivers/thermal/of-thermal.c
drivers/thermal/qcom-spmi-temp-alarm.c
drivers/thermal/qcom/tsens.c
drivers/thermal/rcar_gen3_thermal.c
drivers/thermal/rcar_thermal.c
drivers/thermal/samsung/exynos_tmu.c
drivers/thermal/samsung/exynos_tmu.h [deleted file]
drivers/thermal/tegra/soctherm.c
drivers/thermal/thermal-generic-adc.c
drivers/thermal/thermal_core.c
drivers/thermal/thermal_core.h
drivers/thermal/thermal_helpers.c
drivers/thermal/thermal_hwmon.c
drivers/thermal/thermal_hwmon.h
drivers/thermal/thermal_sysfs.c
drivers/thermal/ti-soc-thermal/omap5-thermal-data.c
drivers/thermal/uniphier_thermal.c
drivers/thermal/x86_pkg_temp_thermal.c
drivers/tty/ehv_bytechan.c
drivers/tty/goldfish.c
drivers/tty/hvc/hvc_iucv.c
drivers/tty/hvc/hvcs.c
drivers/tty/isicom.c
drivers/tty/serial/atmel_serial.c
drivers/tty/serial/pch_uart.c
drivers/tty/serial/rp2.c
drivers/tty/serial/serial_core.c
drivers/tty/serial/sunsab.c
drivers/tty/tty_io.c
drivers/tty/vt/consolemap.c
drivers/tty/vt/keyboard.c
drivers/tty/vt/selection.c
drivers/uio/uio_pruss.c
drivers/usb/core/devio.c
drivers/usb/core/hub.c
drivers/usb/core/message.c
drivers/usb/dwc2/hcd.c
drivers/usb/gadget/function/f_fs.c
drivers/usb/gadget/udc/atmel_usba_udc.c
drivers/usb/gadget/udc/bdc/bdc_ep.c
drivers/usb/gadget/udc/fsl_udc_core.c
drivers/usb/gadget/udc/renesas_usb3.c
drivers/usb/host/ehci-sched.c
drivers/usb/host/fhci-tds.c
drivers/usb/host/imx21-hcd.c
drivers/usb/host/ohci-dbg.c
drivers/usb/host/xhci-mem.c
drivers/usb/misc/ldusb.c
drivers/usb/misc/sisusbvga/sisusb_con.c
drivers/usb/mon/mon_bin.c
drivers/usb/renesas_usbhs/mod_gadget.c
drivers/usb/renesas_usbhs/pipe.c
drivers/usb/serial/iuu_phoenix.c
drivers/usb/storage/alauda.c
drivers/usb/storage/ene_ub6250.c
drivers/usb/storage/sddr09.c
drivers/usb/storage/sddr55.c
drivers/usb/wusbcore/wa-rpipe.c
drivers/uwb/est.c
drivers/uwb/i1480/dfu/usb.c
drivers/vfio/mdev/mdev_core.c
drivers/vfio/mdev/mdev_private.h
drivers/vfio/mdev/mdev_sysfs.c
drivers/vfio/platform/vfio_platform_common.c
drivers/vfio/vfio.c
drivers/vfio/vfio_iommu_type1.c
drivers/vhost/net.c
drivers/vhost/scsi.c
drivers/vhost/test.c
drivers/vhost/vhost.c
drivers/vhost/vringh.c
drivers/video/backlight/Kconfig
drivers/video/backlight/Makefile
drivers/video/backlight/adp8860_bl.c
drivers/video/backlight/adp8870_bl.c
drivers/video/backlight/as3711_bl.c
drivers/video/backlight/generic_bl.c
drivers/video/backlight/lp855x_bl.c
drivers/video/backlight/max8925_bl.c
drivers/video/backlight/otm3225a.c [new file with mode: 0644]
drivers/video/backlight/pandora_bl.c
drivers/video/backlight/pwm_bl.c
drivers/video/backlight/rave-sp-backlight.c [new file with mode: 0644]
drivers/video/backlight/tps65217_bl.c
drivers/video/console/sticore.c
drivers/video/fbdev/Kconfig
drivers/video/fbdev/Makefile
drivers/video/fbdev/aty/aty128fb.c
drivers/video/fbdev/aty/radeon_pm.c
drivers/video/fbdev/au1100fb.c
drivers/video/fbdev/au1200fb.c
drivers/video/fbdev/auo_k1900fb.c [deleted file]
drivers/video/fbdev/auo_k1901fb.c [deleted file]
drivers/video/fbdev/auo_k190x.c [deleted file]
drivers/video/fbdev/auo_k190x.h [deleted file]
drivers/video/fbdev/broadsheetfb.c
drivers/video/fbdev/core/bitblit.c
drivers/video/fbdev/core/fb_defio.c
drivers/video/fbdev/core/fbcon.c
drivers/video/fbdev/core/fbcon_ccw.c
drivers/video/fbdev/core/fbcon_cw.c
drivers/video/fbdev/core/fbcon_rotate.c
drivers/video/fbdev/core/fbcon_ud.c
drivers/video/fbdev/core/fbmem.c
drivers/video/fbdev/core/fbmon.c
drivers/video/fbdev/imxfb.c
drivers/video/fbdev/mb862xx/mb862xxfb_accel.c
drivers/video/fbdev/mmp/fb/mmpfb.c
drivers/video/fbdev/mmp/hw/mmp_ctrl.c
drivers/video/fbdev/mxsfb.c
drivers/video/fbdev/nvidia/nvidia.c
drivers/video/fbdev/omap/lcd_ams_delta.c
drivers/video/fbdev/omap/lcd_h3.c
drivers/video/fbdev/omap/lcd_htcherald.c
drivers/video/fbdev/omap/lcd_inn1510.c
drivers/video/fbdev/omap/lcd_inn1610.c
drivers/video/fbdev/omap/lcd_osk.c
drivers/video/fbdev/omap/lcd_palmte.c
drivers/video/fbdev/omap/lcd_palmtt.c
drivers/video/fbdev/omap/lcd_palmz71.c
drivers/video/fbdev/omap/omapfb_main.c
drivers/video/fbdev/omap2/omapfb/Kconfig
drivers/video/fbdev/omap2/omapfb/displays/panel-dsi-cm.c
drivers/video/fbdev/omap2/omapfb/dss/manager.c
drivers/video/fbdev/omap2/omapfb/dss/overlay.c
drivers/video/fbdev/omap2/omapfb/vrfb.c
drivers/video/fbdev/pvr2fb.c
drivers/video/fbdev/pxafb.c
drivers/video/fbdev/riva/fbdev.c
drivers/video/fbdev/savage/savagefb_driver.c
drivers/video/fbdev/sh_mobile_lcdcfb.c
drivers/video/fbdev/sh_mobile_lcdcfb.h
drivers/video/fbdev/sh_mobile_meram.c [deleted file]
drivers/video/fbdev/skeletonfb.c
drivers/video/fbdev/sm501fb.c
drivers/video/fbdev/uvesafb.c
drivers/video/fbdev/via/global.h
drivers/video/fbdev/via/hw.c
drivers/video/fbdev/via/via-core.c
drivers/video/fbdev/via/via_clock.c
drivers/video/fbdev/via/viafbdev.c
drivers/video/fbdev/w100fb.c
drivers/video/fbdev/xen-fbfront.c
drivers/video/of_display_timing.c
drivers/virt/fsl_hypervisor.c
drivers/virt/vboxguest/vboxguest_core.c
drivers/virtio/virtio_pci_common.c
drivers/virtio/virtio_pci_modern.c
drivers/virtio/virtio_ring.c
drivers/watchdog/cadence_wdt.c
drivers/watchdog/da9062_wdt.c
drivers/watchdog/da9063_wdt.c
drivers/watchdog/hpwdt.c
drivers/watchdog/jz4740_wdt.c
drivers/watchdog/mena21_wdt.c
drivers/watchdog/of_xilinx_wdt.c
drivers/watchdog/renesas_wdt.c
drivers/watchdog/sp805_wdt.c
drivers/watchdog/wdat_wdt.c
drivers/xen/arm-device.c
drivers/xen/evtchn.c
drivers/xen/grant-table.c
drivers/xen/xen-pciback/pciback_ops.c
fs/9p/fid.c
fs/Kconfig
fs/Kconfig.binfmt
fs/Makefile
fs/adfs/inode.c
fs/adfs/super.c
fs/afs/Makefile
fs/afs/addr_list.c
fs/afs/callback.c
fs/afs/cell.c
fs/afs/cmservice.c
fs/afs/dynroot.c
fs/afs/fsclient.c
fs/afs/internal.h
fs/afs/main.c
fs/afs/netdevices.c
fs/afs/proc.c
fs/afs/rxrpc.c
fs/afs/server.c
fs/afs/super.c
fs/aio.c
fs/attr.c
fs/autofs/Kconfig
fs/autofs/init.c
fs/autofs4/Kconfig [deleted file]
fs/autofs4/Makefile [deleted file]
fs/bad_inode.c
fs/befs/ChangeLog
fs/binfmt_elf.c
fs/binfmt_elf_fdpic.c
fs/binfmt_misc.c
fs/block_dev.c
fs/btrfs/check-integrity.c
fs/btrfs/ctree.h
fs/btrfs/extent_io.c
fs/btrfs/file.c
fs/btrfs/inode.c
fs/btrfs/ioctl.c
fs/btrfs/root-tree.c
fs/btrfs/scrub.c
fs/btrfs/transaction.c
fs/ceph/addr.c
fs/ceph/cache.c
fs/ceph/caps.c
fs/ceph/dir.c
fs/ceph/file.c
fs/ceph/inode.c
fs/ceph/mds_client.c
fs/ceph/snap.c
fs/ceph/super.c
fs/ceph/xattr.c
fs/cifs/asn1.c
fs/cifs/cache.c
fs/cifs/cifsacl.c
fs/cifs/cifssmb.c
fs/cifs/file.c
fs/cifs/fscache.c
fs/cifs/inode.c
fs/cifs/misc.c
fs/cifs/smb2pdu.c
fs/cifs/transport.c
fs/coda/coda_linux.c
fs/configfs/inode.c
fs/cramfs/inode.c
fs/crypto/bio.c
fs/crypto/crypto.c
fs/crypto/fscrypt_private.h
fs/debugfs/inode.c
fs/dlm/lockspace.c
fs/eventfd.c
fs/eventpoll.c
fs/exofs/inode.c
fs/exofs/ore.c
fs/exofs/ore_raid.c
fs/exofs/super.c
fs/ext2/super.c
fs/ext4/ext4.h
fs/ext4/extents.c
fs/ext4/ialloc.c
fs/ext4/namei.c
fs/ext4/readpage.c
fs/ext4/resize.c
fs/ext4/super.c
fs/f2fs/checkpoint.c
fs/f2fs/data.c
fs/f2fs/debug.c
fs/f2fs/dir.c
fs/f2fs/extent_cache.c
fs/f2fs/f2fs.h
fs/f2fs/file.c
fs/f2fs/gc.c
fs/f2fs/gc.h
fs/f2fs/inline.c
fs/f2fs/inode.c
fs/f2fs/namei.c
fs/f2fs/node.c
fs/f2fs/recovery.c
fs/f2fs/segment.c
fs/f2fs/segment.h
fs/f2fs/shrinker.c
fs/f2fs/super.c
fs/f2fs/sysfs.c
fs/f2fs/xattr.c
fs/fat/inode.c
fs/fat/namei_msdos.c
fs/fat/namei_vfat.c
fs/fuse/dev.c
fs/fuse/inode.c
fs/gfs2/dir.c
fs/gfs2/glock.c
fs/gfs2/glops.c
fs/gfs2/quota.c
fs/gfs2/rgrp.c
fs/gfs2/super.c
fs/hfs/inode.c
fs/hfsplus/inode.c
fs/hostfs/hostfs_kern.c
fs/hpfs/dnode.c
fs/hpfs/map.c
fs/inode.c
fs/iomap.c
fs/jbd2/revoke.c
fs/jffs2/acl.c
fs/jffs2/acl.h
fs/jffs2/dir.c
fs/jffs2/file.c
fs/jffs2/fs.c
fs/jffs2/wbuf.c
fs/jfs/jfs_dmap.c
fs/jfs/jfs_dtree.c
fs/jfs/jfs_unicode.c
fs/kernfs/dir.c
fs/kernfs/inode.c
fs/locks.c
fs/mbcache.c
fs/namei.c
fs/nfs/callback_proc.c
fs/nfs/client.c
fs/nfs/delegation.c
fs/nfs/dir.c
fs/nfs/export.c
fs/nfs/flexfilelayout/flexfilelayout.c
fs/nfs/flexfilelayout/flexfilelayoutdev.c
fs/nfs/fscache-index.c
fs/nfs/fscache.c
fs/nfs/inode.c
fs/nfs/nfs2xdr.c
fs/nfs/nfs3proc.c
fs/nfs/nfs3xdr.c
fs/nfs/nfs42proc.c
fs/nfs/nfs4_fs.h
fs/nfs/nfs4idmap.c
fs/nfs/nfs4proc.c
fs/nfs/nfs4state.c
fs/nfs/nfs4xdr.c
fs/nfs/pnfs.c
fs/nfs/pnfs.h
fs/nfs/proc.c
fs/nfs/unlink.c
fs/nfs/write.c
fs/nfsd/blocklayout.c
fs/nfsd/cache.h
fs/nfsd/export.c
fs/nfsd/nfs3xdr.c
fs/nfsd/nfs4recover.c
fs/nfsd/nfs4state.c
fs/nfsd/nfs4xdr.c
fs/nfsd/nfscache.c
fs/nfsd/nfsxdr.c
fs/notify/dnotify/dnotify.c
fs/notify/fanotify/fanotify.c
fs/notify/fdinfo.c
fs/notify/fsnotify.c
fs/notify/fsnotify.h
fs/notify/group.c
fs/notify/inotify/inotify.h
fs/notify/inotify/inotify_fsnotify.c
fs/notify/inotify/inotify_user.c
fs/notify/mark.c
fs/ntfs/compress.c
fs/ntfs/inode.c
fs/ocfs2/cluster/tcp.c
fs/ocfs2/dlm/dlmdomain.c
fs/ocfs2/dlmglue.c
fs/ocfs2/file.c
fs/ocfs2/journal.c
fs/ocfs2/sysfile.c
fs/orangefs/devorangefs-req.c
fs/orangefs/inode.c
fs/orangefs/orangefs-kernel.h
fs/orangefs/orangefs-sysfs.c
fs/overlayfs/inode.c
fs/overlayfs/namei.c
fs/overlayfs/overlayfs.h
fs/proc/base.c
fs/proc/generic.c
fs/proc/inode.c
fs/proc/internal.h
fs/proc/proc_net.c
fs/proc/proc_sysctl.c
fs/proc/root.c
fs/proc/task_mmu.c
fs/proc/uptime.c
fs/pstore/platform.c
fs/pstore/ram.c
fs/read_write.c
fs/reiserfs/bitmap.c
fs/reiserfs/inode.c
fs/reiserfs/journal.c
fs/reiserfs/namei.c
fs/reiserfs/resize.c
fs/reiserfs/xattr.c
fs/select.c
fs/signalfd.c
fs/splice.c
fs/ubifs/dir.c
fs/ubifs/file.c
fs/ubifs/journal.c
fs/ubifs/lpt.c
fs/ubifs/super.c
fs/ubifs/tnc.c
fs/ubifs/tnc_commit.c
fs/ubifs/ubifs.h
fs/udf/ialloc.c
fs/udf/inode.c
fs/udf/super.c
fs/udf/udfdecl.h
fs/udf/udftime.c
fs/ufs/super.c
fs/xfs/Makefile
fs/xfs/kmem.c
fs/xfs/kmem.h
fs/xfs/libxfs/xfs_ag_resv.c
fs/xfs/libxfs/xfs_ag_resv.h
fs/xfs/libxfs/xfs_alloc.c
fs/xfs/libxfs/xfs_alloc.h
fs/xfs/libxfs/xfs_alloc_btree.c
fs/xfs/libxfs/xfs_alloc_btree.h
fs/xfs/libxfs/xfs_attr.c
fs/xfs/libxfs/xfs_attr_leaf.c
fs/xfs/libxfs/xfs_attr_leaf.h
fs/xfs/libxfs/xfs_attr_remote.c
fs/xfs/libxfs/xfs_attr_remote.h
fs/xfs/libxfs/xfs_attr_sf.h
fs/xfs/libxfs/xfs_bit.c
fs/xfs/libxfs/xfs_bit.h
fs/xfs/libxfs/xfs_bmap.c
fs/xfs/libxfs/xfs_bmap.h
fs/xfs/libxfs/xfs_bmap_btree.c
fs/xfs/libxfs/xfs_bmap_btree.h
fs/xfs/libxfs/xfs_btree.c
fs/xfs/libxfs/xfs_btree.h
fs/xfs/libxfs/xfs_da_btree.c
fs/xfs/libxfs/xfs_da_btree.h
fs/xfs/libxfs/xfs_da_format.c
fs/xfs/libxfs/xfs_da_format.h
fs/xfs/libxfs/xfs_defer.c
fs/xfs/libxfs/xfs_defer.h
fs/xfs/libxfs/xfs_dir2.c
fs/xfs/libxfs/xfs_dir2.h
fs/xfs/libxfs/xfs_dir2_block.c
fs/xfs/libxfs/xfs_dir2_data.c
fs/xfs/libxfs/xfs_dir2_leaf.c
fs/xfs/libxfs/xfs_dir2_node.c
fs/xfs/libxfs/xfs_dir2_priv.h
fs/xfs/libxfs/xfs_dir2_sf.c
fs/xfs/libxfs/xfs_dquot_buf.c
fs/xfs/libxfs/xfs_errortag.h
fs/xfs/libxfs/xfs_format.h
fs/xfs/libxfs/xfs_fs.h
fs/xfs/libxfs/xfs_ialloc.c
fs/xfs/libxfs/xfs_ialloc.h
fs/xfs/libxfs/xfs_ialloc_btree.c
fs/xfs/libxfs/xfs_ialloc_btree.h
fs/xfs/libxfs/xfs_iext_tree.c
fs/xfs/libxfs/xfs_inode_buf.c
fs/xfs/libxfs/xfs_inode_buf.h
fs/xfs/libxfs/xfs_inode_fork.c
fs/xfs/libxfs/xfs_inode_fork.h
fs/xfs/libxfs/xfs_log_format.h
fs/xfs/libxfs/xfs_log_recover.h
fs/xfs/libxfs/xfs_log_rlimit.c
fs/xfs/libxfs/xfs_quota_defs.h
fs/xfs/libxfs/xfs_refcount.c
fs/xfs/libxfs/xfs_refcount.h
fs/xfs/libxfs/xfs_refcount_btree.c
fs/xfs/libxfs/xfs_refcount_btree.h
fs/xfs/libxfs/xfs_rmap.c
fs/xfs/libxfs/xfs_rmap.h
fs/xfs/libxfs/xfs_rmap_btree.c
fs/xfs/libxfs/xfs_rmap_btree.h
fs/xfs/libxfs/xfs_rtbitmap.c
fs/xfs/libxfs/xfs_sb.c
fs/xfs/libxfs/xfs_sb.h
fs/xfs/libxfs/xfs_shared.h
fs/xfs/libxfs/xfs_symlink_remote.c
fs/xfs/libxfs/xfs_trans_resv.c
fs/xfs/libxfs/xfs_trans_resv.h
fs/xfs/libxfs/xfs_trans_space.h
fs/xfs/libxfs/xfs_types.c [new file with mode: 0644]
fs/xfs/libxfs/xfs_types.h
fs/xfs/mrlock.h
fs/xfs/scrub/agheader.c
fs/xfs/scrub/agheader_repair.c
fs/xfs/scrub/alloc.c
fs/xfs/scrub/attr.c
fs/xfs/scrub/bmap.c
fs/xfs/scrub/btree.c
fs/xfs/scrub/btree.h
fs/xfs/scrub/common.c
fs/xfs/scrub/common.h
fs/xfs/scrub/dabtree.c
fs/xfs/scrub/dabtree.h
fs/xfs/scrub/dir.c
fs/xfs/scrub/ialloc.c
fs/xfs/scrub/inode.c
fs/xfs/scrub/parent.c
fs/xfs/scrub/quota.c
fs/xfs/scrub/refcount.c
fs/xfs/scrub/repair.c
fs/xfs/scrub/repair.h
fs/xfs/scrub/rmap.c
fs/xfs/scrub/rtbitmap.c
fs/xfs/scrub/scrub.c
fs/xfs/scrub/scrub.h
fs/xfs/scrub/symlink.c
fs/xfs/scrub/trace.c
fs/xfs/scrub/trace.h
fs/xfs/scrub/xfs_scrub.h
fs/xfs/xfs.h
fs/xfs/xfs_acl.c
fs/xfs/xfs_acl.h
fs/xfs/xfs_aops.c
fs/xfs/xfs_aops.h
fs/xfs/xfs_attr.h
fs/xfs/xfs_attr_inactive.c
fs/xfs/xfs_attr_list.c
fs/xfs/xfs_bmap_item.c
fs/xfs/xfs_bmap_item.h
fs/xfs/xfs_bmap_util.c
fs/xfs/xfs_bmap_util.h
fs/xfs/xfs_buf.c
fs/xfs/xfs_buf.h
fs/xfs/xfs_buf_item.c
fs/xfs/xfs_buf_item.h
fs/xfs/xfs_dir2_readdir.c
fs/xfs/xfs_discard.c
fs/xfs/xfs_dquot.c
fs/xfs/xfs_dquot.h
fs/xfs/xfs_dquot_item.c
fs/xfs/xfs_dquot_item.h
fs/xfs/xfs_error.c
fs/xfs/xfs_error.h
fs/xfs/xfs_export.c
fs/xfs/xfs_export.h
fs/xfs/xfs_extent_busy.c
fs/xfs/xfs_extent_busy.h
fs/xfs/xfs_extfree_item.c
fs/xfs/xfs_extfree_item.h
fs/xfs/xfs_file.c
fs/xfs/xfs_filestream.c
fs/xfs/xfs_filestream.h
fs/xfs/xfs_fsmap.c
fs/xfs/xfs_fsmap.h
fs/xfs/xfs_fsops.c
fs/xfs/xfs_fsops.h
fs/xfs/xfs_globals.c
fs/xfs/xfs_icache.c
fs/xfs/xfs_icache.h
fs/xfs/xfs_icreate_item.c
fs/xfs/xfs_icreate_item.h
fs/xfs/xfs_inode.c
fs/xfs/xfs_inode.h
fs/xfs/xfs_inode_item.c
fs/xfs/xfs_inode_item.h
fs/xfs/xfs_ioctl.c
fs/xfs/xfs_ioctl.h
fs/xfs/xfs_ioctl32.c
fs/xfs/xfs_ioctl32.h
fs/xfs/xfs_iomap.c
fs/xfs/xfs_iomap.h
fs/xfs/xfs_iops.c
fs/xfs/xfs_iops.h
fs/xfs/xfs_itable.c
fs/xfs/xfs_itable.h
fs/xfs/xfs_linux.h
fs/xfs/xfs_log.c
fs/xfs/xfs_log.h
fs/xfs/xfs_log_cil.c
fs/xfs/xfs_log_priv.h
fs/xfs/xfs_log_recover.c
fs/xfs/xfs_message.c
fs/xfs/xfs_mount.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_mru_cache.c
fs/xfs/xfs_mru_cache.h
fs/xfs/xfs_ondisk.h
fs/xfs/xfs_qm.c
fs/xfs/xfs_qm.h
fs/xfs/xfs_qm_bhv.c
fs/xfs/xfs_qm_syscalls.c
fs/xfs/xfs_quota.h
fs/xfs/xfs_quotaops.c
fs/xfs/xfs_refcount_item.c
fs/xfs/xfs_refcount_item.h
fs/xfs/xfs_reflink.c
fs/xfs/xfs_reflink.h
fs/xfs/xfs_rmap_item.c
fs/xfs/xfs_rmap_item.h
fs/xfs/xfs_rtalloc.c
fs/xfs/xfs_rtalloc.h
fs/xfs/xfs_stats.c
fs/xfs/xfs_stats.h
fs/xfs/xfs_super.c
fs/xfs/xfs_super.h
fs/xfs/xfs_symlink.c
fs/xfs/xfs_symlink.h
fs/xfs/xfs_sysctl.c
fs/xfs/xfs_sysctl.h
fs/xfs/xfs_sysfs.c
fs/xfs/xfs_sysfs.h
fs/xfs/xfs_trace.c
fs/xfs/xfs_trace.h
fs/xfs/xfs_trans.c
fs/xfs/xfs_trans.h
fs/xfs/xfs_trans_ail.c
fs/xfs/xfs_trans_bmap.c
fs/xfs/xfs_trans_buf.c
fs/xfs/xfs_trans_dquot.c
fs/xfs/xfs_trans_extfree.c
fs/xfs/xfs_trans_inode.c
fs/xfs/xfs_trans_priv.h
fs/xfs/xfs_trans_refcount.c
fs/xfs/xfs_trans_rmap.c
fs/xfs/xfs_xattr.c
include/acpi/acoutput.h
include/acpi/acpixf.h
include/acpi/actbl2.h
include/acpi/actypes.h
include/dt-bindings/memory/tegra114-mc.h
include/dt-bindings/memory/tegra124-mc.h
include/dt-bindings/memory/tegra20-mc.h [new file with mode: 0644]
include/dt-bindings/memory/tegra210-mc.h
include/dt-bindings/memory/tegra30-mc.h
include/dt-bindings/power/px30-power.h [new file with mode: 0644]
include/dt-bindings/power/r8a77470-sysc.h [new file with mode: 0644]
include/dt-bindings/power/r8a77990-sysc.h [new file with mode: 0644]
include/dt-bindings/power/rk3036-power.h [new file with mode: 0644]
include/dt-bindings/power/rk3128-power.h [new file with mode: 0644]
include/dt-bindings/power/rk3228-power.h [new file with mode: 0644]
include/keys/asymmetric-subtype.h
include/keys/asymmetric-type.h
include/kvm/arm_vgic.h
include/linux/assoc_array.h
include/linux/assoc_array_priv.h
include/linux/backlight.h
include/linux/ceph/ceph_fs.h
include/linux/ceph/osd_client.h
include/linux/ceph/osdmap.h
include/linux/circ_buf.h
include/linux/fs.h
include/linux/fscrypt_notsupp.h
include/linux/fscrypt_supp.h
include/linux/fsnotify_backend.h
include/linux/ftrace.h
include/linux/hwspinlock.h
include/linux/i2c-pnx.h [deleted file]
include/linux/i2c.h
include/linux/kcov.h
include/linux/kvm_host.h
include/linux/linkage.h
include/linux/memcontrol.h
include/linux/mfd/arizona/pdata.h
include/linux/mfd/as3711.h
include/linux/mfd/axp20x.h
include/linux/mfd/cros_ec.h
include/linux/mfd/rave-sp.h
include/linux/mfd/stm32-timers.h
include/linux/mfd/syscon/exynos4-pmu.h [deleted file]
include/linux/mfd/syscon/exynos5-pmu.h [deleted file]
include/linux/mfd/tps65218.h
include/linux/mfd/tps68470.h
include/linux/mm.h
include/linux/namei.h
include/linux/netfilter.h
include/linux/netfilter/ipset/ip_set_timeout.h
include/linux/nfs_fs_sb.h
include/linux/nfs_xdr.h
include/linux/platform_data/i2c-gpio.h [moved from include/linux/i2c-gpio.h with 100% similarity]
include/linux/platform_data/i2c-mux-gpio.h [moved from include/linux/i2c-mux-gpio.h with 100% similarity]
include/linux/platform_data/i2c-ocores.h [moved from include/linux/i2c-ocores.h with 100% similarity]
include/linux/platform_data/i2c-omap.h [moved from include/linux/i2c-omap.h with 100% similarity]
include/linux/platform_data/i2c-pca-platform.h [moved from include/linux/i2c-pca-platform.h with 100% similarity]
include/linux/platform_data/i2c-xiic.h [moved from include/linux/i2c-xiic.h with 100% similarity]
include/linux/platform_data/media/ir-rx51.h [deleted file]
include/linux/platform_data/mlxreg.h
include/linux/platform_data/mtd-davinci.h
include/linux/platform_data/sc18is602.h
include/linux/platform_data/shmob_drm.h
include/linux/platform_data/spi-imx.h
include/linux/platform_data/ti-aemif.h
include/linux/platform_data/ti-sysc.h
include/linux/pm_domain.h
include/linux/pm_runtime.h
include/linux/proc_fs.h
include/linux/pstore.h
include/linux/pwm_backlight.h
include/linux/qcom-geni-se.h [new file with mode: 0644]
include/linux/rculist.h
include/linux/rculist_nulls.h
include/linux/rpmsg.h
include/linux/rpmsg/qcom_glink.h
include/linux/sched.h
include/linux/scmi_protocol.h
include/linux/slab.h
include/linux/soc/qcom/smem.h
include/linux/soc/ti/ti_sci_protocol.h
include/linux/stackprotector.h
include/linux/stat.h
include/linux/ste_modem_shm.h [deleted file]
include/linux/string_helpers.h
include/linux/sunrpc/rpc_rdma.h
include/linux/sunrpc/svc_rdma.h
include/linux/sunrpc/xprt.h
include/linux/sunrpc/xprtrdma.h
include/linux/thermal.h
include/linux/thread_info.h
include/linux/tracepoint.h
include/linux/virtio_ring.h
include/net/ip_vs.h
include/net/netfilter/nf_conntrack_count.h
include/net/netfilter/nft_dup.h [deleted file]
include/net/sctp/structs.h
include/net/tls.h
include/rdma/ib_verbs.h
include/soc/qcom/cmd-db.h [new file with mode: 0644]
include/soc/tegra/cpuidle.h
include/soc/tegra/mc.h
include/trace/events/rpcrdma.h
include/uapi/linux/aio_abi.h
include/uapi/linux/kvm.h
include/uapi/linux/netfilter/nf_conntrack_common.h
include/uapi/linux/netfilter/nf_tables.h
include/uapi/linux/nl80211.h
include/uapi/linux/prctl.h
include/uapi/linux/rpmsg.h
include/uapi/linux/usb/audio.h
include/uapi/linux/virtio_config.h
include/video/auo_k190xfb.h [deleted file]
include/video/sh_mobile_lcdc.h
include/video/sh_mobile_meram.h [deleted file]
include/xen/interface/io/kbdif.h
init/Kconfig
ipc/sem.c
ipc/shm.c
kernel/audit_fsnotify.c
kernel/audit_tree.c
kernel/audit_watch.c
kernel/bpf/btf.c
kernel/bpf/inode.c
kernel/bpf/lpm_trie.c
kernel/bpf/verifier.c
kernel/cgroup/cgroup-v1.c
kernel/cgroup/cpuset.c
kernel/configs/android-recommended.config
kernel/configs/tiny.config
kernel/debug/kdb/kdb_main.c
kernel/events/ring_buffer.c
kernel/events/uprobes.c
kernel/fail_function.c
kernel/fork.c
kernel/gcov/Kconfig
kernel/gcov/Makefile
kernel/kcov.c
kernel/kexec_core.c
kernel/kexec_file.c
kernel/locking/locktorture.c
kernel/module.c
kernel/panic.c
kernel/power/main.c
kernel/power/swap.c
kernel/rcu/rcutorture.c
kernel/relay.c
kernel/sched/core.c
kernel/sched/fair.c
kernel/sched/rt.c
kernel/sched/topology.c
kernel/sysctl.c
kernel/trace/Kconfig
kernel/trace/ftrace.c
kernel/trace/trace.c
kernel/trace/trace_events_filter.c
kernel/trace/tracing_map.c
kernel/user_namespace.c
kernel/workqueue.c
lib/Kconfig
lib/Kconfig.debug
lib/Makefile
lib/argv_split.c
lib/interval_tree_test.c
lib/kfifo.c
lib/lru_cache.c
lib/mpi/mpiutil.c
lib/rbtree_test.c
lib/reed_solomon/reed_solomon.c
lib/sbitmap.c
lib/scatterlist.c
lib/test_firmware.c
lib/test_kmod.c
lib/test_overflow.c
lib/test_printf.c
lib/test_rhashtable.c
lib/ucmpdi2.c
mm/cleancache.c
mm/cma_debug.c
mm/compaction.c
mm/dmapool.c
mm/failslab.c
mm/frontswap.c
mm/gup_benchmark.c
mm/huge_memory.c
mm/hugetlb.c
mm/ksm.c
mm/memblock.c
mm/memcontrol.c
mm/mremap.c
mm/oom_kill.c
mm/page_alloc.c
mm/page_idle.c
mm/page_owner.c
mm/percpu-stats.c
mm/shmem.c
mm/slab.c
mm/slab_common.c
mm/slub.c
mm/swap_slots.c
mm/swap_state.c
mm/swapfile.c
mm/vmalloc.c
mm/zsmalloc.c
mm/zswap.c
net/9p/protocol.c
net/9p/trans_virtio.c
net/atm/mpc.c
net/bluetooth/hci_core.c
net/bluetooth/l2cap_core.c
net/bridge/br_multicast.c
net/bridge/netfilter/ebtables.c
net/bridge/netfilter/nft_reject_bridge.c
net/can/bcm.c
net/ceph/messenger.c
net/ceph/osd_client.c
net/ceph/osdmap.c
net/ceph/pagevec.c
net/core/dev.c
net/core/ethtool.c
net/core/neighbour.c
net/core/pktgen.c
net/core/sock.c
net/dcb/dcbnl.c
net/dccp/ccids/ccid2.c
net/dsa/tag_trailer.c
net/ieee802154/nl-phy.c
net/ipv4/fib_frontend.c
net/ipv4/netfilter/ip_tables.c
net/ipv4/route.c
net/ipv4/tcp_ipv4.c
net/ipv4/tcp_offload.c
net/ipv6/addrconf.c
net/ipv6/icmp.c
net/ipv6/ila/ila_xlat.c
net/ipv6/ip6_fib.c
net/ipv6/netfilter/ip6_tables.c
net/ipv6/route.c
net/ipv6/tcp_ipv6.c
net/l2tp/l2tp_netlink.c
net/l2tp/l2tp_ppp.c
net/mac80211/chan.c
net/mac80211/main.c
net/mac80211/rc80211_minstrel.c
net/mac80211/rc80211_minstrel_ht.c
net/mac80211/scan.c
net/mac80211/util.c
net/netfilter/ipset/ip_set_hash_gen.h
net/netfilter/ipvs/ip_vs_conn.c
net/netfilter/ipvs/ip_vs_ctl.c
net/netfilter/ipvs/ip_vs_xmit.c
net/netfilter/nf_conncount.c
net/netfilter/nf_conntrack_netlink.c
net/netfilter/nf_conntrack_proto.c
net/netfilter/nf_nat_core.c
net/netfilter/nf_tables_api.c
net/netfilter/nf_tables_core.c
net/netfilter/nfnetlink.c
net/netfilter/nfnetlink_cthelper.c
net/netfilter/nft_chain_filter.c
net/netfilter/nft_connlimit.c
net/netfilter/nft_dynset.c
net/netfilter/nft_set_rbtree.c
net/netfilter/nft_socket.c
net/netfilter/x_tables.c
net/netfilter/xt_CT.c
net/netfilter/xt_connmark.c
net/netfilter/xt_set.c
net/netlink/genetlink.c
net/netrom/af_netrom.c
net/openvswitch/datapath.c
net/openvswitch/vport.c
net/packet/af_packet.c
net/rds/ib.c
net/rds/ib_cm.c
net/rds/info.c
net/rds/loop.c
net/rds/rds.h
net/rds/recv.c
net/rose/af_rose.c
net/rxrpc/rxkad.c
net/sched/sch_fq_codel.c
net/sched/sch_hhf.c
net/sctp/auth.c
net/sctp/output.c
net/sctp/protocol.c
net/smc/af_smc.c
net/smc/smc_wr.c
net/sunrpc/auth_gss/auth_gss.c
net/sunrpc/auth_gss/gss_rpc_upcall.c
net/sunrpc/cache.c
net/sunrpc/clnt.c
net/sunrpc/xprt.c
net/sunrpc/xprtrdma/backchannel.c
net/sunrpc/xprtrdma/fmr_ops.c
net/sunrpc/xprtrdma/frwr_ops.c
net/sunrpc/xprtrdma/module.c
net/sunrpc/xprtrdma/rpc_rdma.c
net/sunrpc/xprtrdma/svc_rdma.c
net/sunrpc/xprtrdma/svc_rdma_backchannel.c
net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
net/sunrpc/xprtrdma/svc_rdma_rw.c
net/sunrpc/xprtrdma/svc_rdma_sendto.c
net/sunrpc/xprtrdma/svc_rdma_transport.c
net/sunrpc/xprtrdma/transport.c
net/sunrpc/xprtrdma/verbs.c
net/sunrpc/xprtrdma/xprt_rdma.h
net/sunrpc/xprtsock.c
net/tipc/netlink_compat.c
net/tls/tls_main.c
net/tls/tls_sw.c
net/wireless/core.c
net/wireless/nl80211.c
net/wireless/util.c
net/xdp/xdp_umem.c
samples/Kconfig
samples/vfio-mdev/Makefile
samples/vfio-mdev/mbochs.c [new file with mode: 0644]
samples/vfio-mdev/mdpy-defs.h [new file with mode: 0644]
samples/vfio-mdev/mdpy-fb.c [new file with mode: 0644]
samples/vfio-mdev/mdpy.c [new file with mode: 0644]
scripts/Kconfig.include
scripts/Makefile.gcc-plugins
scripts/Makefile.kcov
scripts/clang-version.sh
scripts/documentation-file-ref-check
scripts/gcc-plugins/Makefile
scripts/gcc-x86_32-has-stack-protector.sh
scripts/gcc-x86_64-has-stack-protector.sh
scripts/kconfig/streamline_config.pl
security/apparmor/audit.c
security/apparmor/domain.c
security/apparmor/include/audit.h
security/apparmor/include/label.h
security/apparmor/include/path.h
security/apparmor/include/secid.h
security/apparmor/label.c
security/apparmor/lib.c
security/apparmor/lsm.c
security/apparmor/match.c
security/apparmor/mount.c
security/apparmor/policy.c
security/apparmor/policy_unpack.c
security/apparmor/resource.c
security/apparmor/secid.c
security/device_cgroup.c
security/keys/trusted.c
security/selinux/hooks.c
security/selinux/ss/services.c
sound/core/Kconfig
sound/core/pcm_compat.c
sound/core/pcm_native.c
sound/core/seq/seq_memory.c
sound/core/seq/seq_midi_emul.c
sound/drivers/Kconfig
sound/firewire/fireface/ff-protocol-ff400.c
sound/firewire/packets-buffer.c
sound/oss/dmasound/dmasound_core.c
sound/pci/Kconfig
sound/pci/cs46xx/cs46xx_lib.c
sound/pci/cs46xx/dsp_spos.c
sound/pci/ctxfi/ctatc.c
sound/pci/ctxfi/ctdaio.c
sound/pci/ctxfi/ctmixer.c
sound/pci/ctxfi/ctsrc.c
sound/pci/emu10k1/emu10k1_main.c
sound/pci/emu10k1/emufx.c
sound/pci/emu10k1/emupcm.c
sound/pci/emu10k1/p16v.c
sound/pci/fm801.c
sound/pci/hda/hda_codec.c
sound/pci/hda/hda_proc.c
sound/pci/hda/patch_ca0132.c
sound/pci/hda/patch_conexant.c
sound/pci/hda/patch_realtek.c
sound/pci/lx6464es/lx6464es.c
sound/pci/maestro3.c
sound/pci/sonicvibes.c
sound/pci/trident/trident_main.c
sound/pci/via82xx.c
sound/pci/via82xx_modem.c
sound/pci/ymfpci/ymfpci_main.c
sound/soc/au1x/dbdma2.c
sound/soc/codecs/hdmi-codec.c
sound/soc/codecs/rt5645.c
sound/soc/codecs/wm8904.c
sound/soc/codecs/wm8958-dsp2.c
sound/soc/codecs/wm8994.c
sound/soc/codecs/wm_adsp.c
sound/soc/davinci/davinci-mcasp.c
sound/soc/generic/audio-graph-card.c
sound/soc/generic/audio-graph-scu-card.c
sound/soc/generic/simple-card.c
sound/soc/generic/simple-scu-card.c
sound/soc/img/img-i2s-in.c
sound/soc/img/img-i2s-out.c
sound/soc/intel/common/sst-ipc.c
sound/soc/intel/skylake/skl-topology.c
sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
sound/soc/omap/ams-delta.c
sound/soc/pxa/mmp-sspa.c
sound/soc/rockchip/rk3399_gru_sound.c
sound/soc/sh/rcar/cmd.c
sound/soc/sh/rcar/core.c
sound/soc/sh/rcar/ctu.c
sound/soc/sh/rcar/dvc.c
sound/soc/sh/rcar/mix.c
sound/soc/sh/rcar/src.c
sound/soc/sh/rcar/ssi.c
sound/soc/sh/rcar/ssiu.c
sound/soc/soc-core.c
sound/soc/soc-dapm.c
sound/soc/soc-topology.c
sound/soc/uniphier/aio-cpu.c
sound/usb/6fire/pcm.c
sound/usb/caiaq/audio.c
sound/usb/card.h
sound/usb/format.c
sound/usb/line6/capture.c
sound/usb/line6/pcm.c
sound/usb/line6/playback.c
sound/usb/mixer.c
sound/usb/pcm.c
sound/usb/quirks-table.h
sound/usb/quirks.c
sound/usb/usx2y/usbusx2y.c
sound/usb/usx2y/usbusx2yaudio.c
tools/include/uapi/linux/kvm.h
tools/include/uapi/linux/prctl.h
tools/lib/api/fs/fs.c
tools/perf/util/bpf-prologue.c
tools/power/cpupower/bench/parse.c
tools/power/cpupower/utils/idle_monitor/cpuidle_sysfs.c
tools/power/cpupower/utils/idle_monitor/cpupower-monitor.c
tools/power/cpupower/utils/idle_monitor/cpupower-monitor.h
tools/power/pm-graph/config/custom-timeline-functions.cfg
tools/testing/selftests/bpf/Makefile
tools/testing/selftests/cgroup/cgroup_util.c
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_string.tc
tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_syntax.tc
tools/testing/selftests/tc-testing/tc-tests/actions/ife.json
virt/kvm/Kconfig
virt/kvm/arm/arm.c
virt/kvm/arm/vgic/vgic-debug.c
virt/kvm/arm/vgic/vgic-init.c
virt/kvm/arm/vgic/vgic-kvm-device.c
virt/kvm/arm/vgic/vgic-mmio-v3.c
virt/kvm/arm/vgic/vgic-v3.c
virt/kvm/arm/vgic/vgic-v4.c
virt/kvm/arm/vgic/vgic.h
virt/kvm/kvm_main.c

index 32513dc2eec9bdbf36ebc5117ece8f3577621e94..40d41ea1a3f52f515ac228c1cffa848deb6ede74 100644 (file)
@@ -11,7 +11,7 @@ Description:
   Kernel code may export it for complete or partial access.
 
   GPIOs are identified as they are inside the kernel, using integers in
-  the range 0..INT_MAX.  See Documentation/gpio/gpio.txt for more information.
+  the range 0..INT_MAX.  See Documentation/gpio for more information.
 
     /sys/class/gpio
        /export ... asks the kernel to export a GPIO to userspace
index 189e419a5a2d96543a2765eb1509c6d322941829..990fcc42093539b77ac3d4918d0c700a1be410c2 100644 (file)
@@ -73,3 +73,23 @@ Description:
                This sysfs entry tells us whether the channel is a local
                server channel that is announced (values are either
                true or false).
+
+What:          /sys/bus/rpmsg/devices/.../driver_override
+Date:          April 2018
+KernelVersion: 4.18
+Contact:       Bjorn Andersson <bjorn.andersson@linaro.org>
+Description:
+               Every rpmsg device is a communication channel with a remote
+               processor. Channels are identified by a textual name (see
+               /sys/bus/rpmsg/devices/.../name above) and have a local
+               ("source") rpmsg address, and remote ("destination") rpmsg
+               address.
+
+               The listening entity (or client) which communicates with a
+               remote processor is referred as rpmsg driver. The rpmsg device
+               and rpmsg driver are matched based on rpmsg device name and
+               rpmsg driver ID table.
+
+               This sysfs entry allows the rpmsg driver for a rpmsg device
+               to be specified which will override standard OF, ID table
+               and name matching.
index bd4975e132d3438984d2f838daa814b1397fae5f..9c5e7732d2499995b402ff2b4a725d621d1834f8 100644 (file)
@@ -238,9 +238,6 @@ Description:        Discover and change clock speed of CPUs
 
                See files in Documentation/cpu-freq/ for more information.
 
-               In particular, read Documentation/cpu-freq/user-guide.txt
-               to learn how to control the knobs.
-
 
 What:          /sys/devices/system/cpu/cpu#/cpufreq/freqdomain_cpus
 Date:          June 2013
index 540553c933b6197e51cd81367ffbc16fbd24273d..9b0123388f182dfe5829205a73bdf5a63bd32e10 100644 (file)
@@ -101,6 +101,7 @@ Date:               February 2015
 Contact:       "Jaegeuk Kim" <jaegeuk@kernel.org>
 Description:
                 Controls the trimming rate in batch mode.
+                <deprecated>
 
 What:          /sys/fs/f2fs/<disk>/cp_interval
 Date:          October 2015
@@ -140,7 +141,7 @@ Contact:    "Shuoran Liu" <liushuoran@huawei.com>
 Description:
                 Shows total written kbytes issued to disk.
 
-What:          /sys/fs/f2fs/<disk>/feature
+What:          /sys/fs/f2fs/<disk>/features
 Date:          July 2017
 Contact:       "Jaegeuk Kim" <jaegeuk@kernel.org>
 Description:
index 597a2f3d1efceb7383c85dda040f4b1def8adddf..1b31be3f996a40df66299e4715ee4eb984ec12e1 100644 (file)
@@ -25,3 +25,16 @@ Description:
                Control touchpad mode.
                        * 1 -> Switched On
                        * 0 -> Switched Off
+
+What:          /sys/bus/pci/devices/<bdf>/<device>/VPC2004:00/fn_lock
+Date:          May 2018
+KernelVersion: 4.18
+Contact:       "Oleg Keri <ezhi99@gmail.com>"
+Description:
+               Control fn-lock mode.
+                       * 1 -> Switched On
+                       * 0 -> Switched Off
+
+               For example:
+               # echo "0" >    \
+               /sys/bus/pci/devices/0000:00:1f.0/PNP0C09:00/VPC2004:00/fn_lock
index a3f598e141f2eca4e844f868e9586dab657ec59d..7235da975f23b4e916353710b6480ec65716175f 100644 (file)
@@ -16,7 +16,8 @@ control method rather than override the entire DSDT, because kernel
 rebuild/reboot is not needed and test result can be got in minutes.
 
 Note: Only ACPI METHOD can be overridden, any other object types like
-      "Device", "OperationRegion", are not recognized.
+      "Device", "OperationRegion", are not recognized. Methods
+      declared inside scope operators are also not supported.
 Note: The same ACPI control method can be overridden for many times,
       and it's always the latest one that used by Linux/kernel.
 Note: To get the ACPI debug object output (Store (AAAA, Debug)),
@@ -32,8 +33,6 @@ Note: To get the ACPI debug object output (Store (AAAA, Debug)),
 
       DefinitionBlock ("", "SSDT", 1, "", "", 0x20080715)
       {
-       External (ACON)
-
        Method (\_SB_.AC._PSR, 0, NotSerialized)
        {
                Store ("In AC _PSR", Debug)
@@ -42,9 +41,10 @@ Note: To get the ACPI debug object output (Store (AAAA, Debug)),
       }
       Note that the full pathname of the method in ACPI namespace
       should be used.
-      And remember to use "External" to declare external objects.
    e) assemble the file to generate the AML code of the method.
-      e.g. "iasl psr.asl" (psr.aml is generated as a result)
+      e.g. "iasl -vw 6084 psr.asl" (psr.aml is generated as a result)
+      If parameter "-vw 6084" is not supported by your iASL compiler,
+      please try a newer version.
    f) mount debugfs by "mount -t debugfs none /sys/kernel/debug"
    g) override the old method via the debugfs by running
       "cat /tmp/psr.aml > /sys/kernel/debug/acpi/custom_method"
index 3e9734bd0e0586bb737e65c45bd2e6d6fbf0e383..6cf81bbd7ce8b86bfcc740abe4e0bde49e239700 100644 (file)
@@ -44,8 +44,8 @@ Links
 
 Mailing List - apparmor@lists.ubuntu.com
 
-Wiki - http://apparmor.wiki.kernel.org/
+Wiki - http://wiki.apparmor.net
 
-User space tools - https://launchpad.net/apparmor
+User space tools - https://gitlab.com/apparmor
 
-Kernel module - git://git.kernel.org/pub/scm/linux/kernel/git/jj/apparmor-dev.git
+Kernel module - git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor
index 638342d0a0957741608c7f810c01aa9e810aea0f..efc7aa7a067099f6bacdb860cde13f2d876030a8 100644 (file)
                                (may crash computer or cause data corruption)
 
        ALSA            [HW,ALSA]
-                       See Documentation/sound/alsa/alsa-parameters.txt
+                       See Documentation/sound/alsa-configuration.rst
 
        alignment=      [KNL,ARM]
                        Allow the default userspace alignment fault handler
                        This will also cause panics on machine check exceptions.
                        Useful together with panic=30 to trigger a reboot.
 
-       OSS             [HW,OSS]
-                       See Documentation/sound/oss/oss-parameters.txt
-
        page_owner=     [KNL] Boot-time page_owner enabling option.
                        Storage of the information about who allocated
                        each page is disabled in default. With this switch,
                        [FTRACE] Set and start specified trace events in order
                        to facilitate early boot debugging. The event-list is a
                        comma separated list of trace events to enable. See
-                       also Documentation/trace/events.txt
+                       also Documentation/trace/events.rst
 
        trace_options=[option-list]
                        [FTRACE] Enable or disable tracer options at boot.
 
                              trace_options=stacktrace
 
-                       See also Documentation/trace/ftrace.txt "trace options"
+                       See also Documentation/trace/ftrace.rst "trace options"
                        section.
 
        tp_printk[FTRACE]
index 75645c45d14a17a56a83a6bfde987783794852ee..90c6c57d61e8d459f6e9990af37d839e41ae9a0e 100644 (file)
@@ -5,3 +5,7 @@ KERNEL          NEW DEPENDENCIES
 v4.3+          Update is needed for custom .config files to make sure
                CONFIG_REGULATOR_PBIAS is enabled for MMC1 to work
                properly.
+
+v4.18+         Update is needed for custom .config files to make sure
+               CONFIG_MMC_SDHCI_OMAP is enabled for all MMC instances
+               to work in DRA7 and K2G based boards.
index 8272ac92a14fcd5a55f6607c1586ba04a7629c17..1d56221dfe355ad82ef5e391e2851d612206316c 100644 (file)
@@ -8,11 +8,13 @@ The crypto engine API (CE), is a crypto queue manager.
 
 Requirement
 -----------
-You have to put at start of your tfm_ctx the struct crypto_engine_ctx
-struct your_tfm_ctx {
+You have to put at start of your tfm_ctx the struct crypto_engine_ctx::
+
+  struct your_tfm_ctx {
         struct crypto_engine_ctx enginectx;
         ...
-};
+  };
+
 Why: Since CE manage only crypto_async_request, it cannot know the underlying
 request_type and so have access only on the TFM.
 So using container_of for accessing __ctx is impossible.
diff --git a/Documentation/device-mapper/writecache.txt b/Documentation/device-mapper/writecache.txt
new file mode 100644 (file)
index 0000000..4424fa2
--- /dev/null
@@ -0,0 +1,68 @@
+The writecache target caches writes on persistent memory or on SSD. It
+doesn't cache reads because reads are supposed to be cached in page cache
+in normal RAM.
+
+When the device is constructed, the first sector should be zeroed or the
+first sector should contain valid superblock from previous invocation.
+
+Constructor parameters:
+1. type of the cache device - "p" or "s"
+       p - persistent memory
+       s - SSD
+2. the underlying device that will be cached
+3. the cache device
+4. block size (4096 is recommended; the maximum block size is the page
+   size)
+5. the number of optional parameters (the parameters with an argument
+   count as two)
+       high_watermark n        (default: 50)
+               start writeback when the number of used blocks reach this
+               watermark
+       low_watermark x         (default: 45)
+               stop writeback when the number of used blocks drops below
+               this watermark
+       writeback_jobs n        (default: unlimited)
+               limit the number of blocks that are in flight during
+               writeback. Setting this value reduces writeback
+               throughput, but it may improve latency of read requests
+       autocommit_blocks n     (default: 64 for pmem, 65536 for ssd)
+               when the application writes this amount of blocks without
+               issuing the FLUSH request, the blocks are automatically
+               commited
+       autocommit_time ms      (default: 1000)
+               autocommit time in milliseconds. The data is automatically
+               commited if this time passes and no FLUSH request is
+               received
+       fua                     (by default on)
+               applicable only to persistent memory - use the FUA flag
+               when writing data from persistent memory back to the
+               underlying device
+       nofua
+               applicable only to persistent memory - don't use the FUA
+               flag when writing back data and send the FLUSH request
+               afterwards
+               - some underlying devices perform better with fua, some
+                 with nofua. The user should test it
+
+Status:
+1. error indicator - 0 if there was no error, otherwise error number
+2. the number of blocks
+3. the number of free blocks
+4. the number of blocks under writeback
+
+Messages:
+       flush
+               flush the cache device. The message returns successfully
+               if the cache device was flushed without an error
+       flush_on_suspend
+               flush the cache device on next suspend. Use this message
+               when you are going to remove the cache device. The proper
+               sequence for removing the cache device is:
+               1. send the "flush_on_suspend" message
+               2. load an inactive table with a linear target that maps
+                  to the underlying device
+               3. suspend the device
+               4. ask for status and verify that there are no errors
+               5. resume the device, so that it will use the linear
+                  target
+               6. the cache device is now inactive and it can be deleted
index f747f47922c55dfabdf56a2ba3db6bbf1d704816..69880560c0f0219aa0a875396d0587b4274c97fc 100644 (file)
@@ -25,6 +25,10 @@ Boards with the Amlogic Meson8b SoC shall have the following properties:
   Required root node property:
     compatible: "amlogic,meson8b";
 
+Boards with the Amlogic Meson8m2 SoC shall have the following properties:
+  Required root node property:
+    compatible: "amlogic,meson8m2";
+
 Boards with the Amlogic Meson GXBaby SoC shall have the following properties:
   Required root node property:
     compatible: "amlogic,meson-gxbb";
@@ -54,6 +58,8 @@ Board compatible values (alphabetically, grouped by SoC):
   - "hardkernel,odroid-c1" (Meson8b)
   - "tronfy,mxq" (Meson8b)
 
+  - "tronsmart,mxiii-plus" (Meson8m2)
+
   - "amlogic,p200" (Meson gxbb)
   - "amlogic,p201" (Meson gxbb)
   - "friendlyarm,nanopi-k2" (Meson gxbb)
index 3e3efa046ac57ab49cee7d706cfff3b2d93c6247..1e3e29a545e263470fff686f036361ddaf48abfa 100644 (file)
@@ -34,6 +34,10 @@ Raspberry Pi 3 Model B
 Required root node properties:
 compatible = "raspberrypi,3-model-b", "brcm,bcm2837";
 
+Raspberry Pi 3 Model B+
+Required root node properties:
+compatible = "raspberrypi,3-model-b-plus", "brcm,bcm2837";
+
 Raspberry Pi Compute Module
 Required root node properties:
 compatible = "raspberrypi,compute-module", "brcm,bcm2835";
index 14510b215480b6f13bd3bf765ca5425fd9438f6f..bdadc3da9556d47e52372f0a68846779dccc1d95 100644 (file)
@@ -21,8 +21,6 @@ Required root node properties:
        - "samsung,smdk5420"    - for Exynos5420-based Samsung SMDK5420 eval board.
        - "samsung,tm2"         - for Exynos5433-based Samsung TM2 board.
        - "samsung,tm2e"        - for Exynos5433-based Samsung TM2E board.
-       - "samsung,sd5v1"       - for Exynos5440-based Samsung board.
-       - "samsung,ssdk5440"    - for Exynos5440-based Samsung board.
 
 * Other companies Exynos SoC based
   * FriendlyARM
index d3d1df97834f231c98da1e9027337c692bd4158f..d8cf740132c6d869eaaeaed6fb430b294c3ab9e3 100644 (file)
@@ -21,6 +21,8 @@ SoCs:
     compatible = "renesas,r8a7744"
   - RZ/G1E (R8A77450)
     compatible = "renesas,r8a7745"
+  - RZ/G1C (R8A77470)
+    compatible = "renesas,r8a77470"
   - R-Car M1A (R8A77781)
     compatible = "renesas,r8a7778"
   - R-Car H1 (R8A77790)
@@ -45,6 +47,8 @@ SoCs:
     compatible = "renesas,r8a77970"
   - R-Car V3H (R8A77980)
     compatible = "renesas,r8a77980"
+  - R-Car E3 (R8A77990)
+    compatible = "renesas,r8a77990"
   - R-Car D3 (R8A77995)
     compatible = "renesas,r8a77995"
 
@@ -67,6 +71,8 @@ Boards:
     compatible = "renesas,draak", "renesas,r8a77995"
   - Eagle (RTP0RC77970SEB0010S)
     compatible = "renesas,eagle", "renesas,r8a77970"
+  - Ebisu (RTP0RC77990SEB0010S)
+    compatible = "renesas,ebisu", "renesas,r8a77990"
   - Genmai (RTK772100BC00000BR)
     compatible = "renesas,genmai", "renesas,r7s72100"
   - GR-Peach (X28A-M01-E/F)
@@ -78,6 +84,8 @@ Boards:
     compatible = "renesas,h3ulcb", "renesas,r8a7795"
   - Henninger
     compatible = "renesas,henninger", "renesas,r8a7791"
+  - iWave Systems RZ/G1C Single Board Computer (iW-RainboW-G23S)
+    compatible = "iwave,g23s", "renesas,r8a77470"
   - iWave Systems RZ/G1E SODIMM SOM Development Platform (iW-RainboW-G22D)
     compatible = "iwave,g22d", "iwave,g22m", "renesas,r8a7745"
   - iWave Systems RZ/G1E SODIMM System On Module (iW-RainboW-G22M-SM)
@@ -108,7 +116,7 @@ Boards:
     compatible = "renesas,salvator-x", "renesas,r8a7795"
   - Salvator-X (RTP0RC7796SIPB0011S)
     compatible = "renesas,salvator-x", "renesas,r8a7796"
-  - Salvator-X (RTP0RC7796SIPB0011S (M3N))
+  - Salvator-X (RTP0RC7796SIPB0011S (M3-N))
     compatible = "renesas,salvator-x", "renesas,r8a77965"
   - Salvator-XS (Salvator-X 2nd version, RTP0RC7795SIPB0012S)
     compatible = "renesas,salvator-xs", "renesas,r8a7795"
@@ -124,6 +132,8 @@ Boards:
     compatible = "renesas,sk-rzg1m", "renesas,r8a7743"
   - Stout (ADAS Starterkit, Y-R-CAR-ADAS-SKH2-BOARD)
     compatible = "renesas,stout", "renesas,r8a7790"
+  - V3HSK (Y-ASK-RCAR-V3H-WS10)
+    compatible = "renesas,v3hsk", "renesas,r8a77980"
   - V3MSK (Y-ASK-RCAR-V3M-WS10)
     compatible = "renesas,v3msk", "renesas,r8a77970"
   - Wheat (RTP0RC7792ASKB0000JE)
diff --git a/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra30-mc.txt b/Documentation/devicetree/bindings/arm/tegra/nvidia,tegra30-mc.txt
deleted file mode 100644 (file)
index bdf1a61..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-NVIDIA Tegra30 MC(Memory Controller)
-
-Required properties:
-- compatible : "nvidia,tegra30-mc"
-- reg : Should contain 4 register ranges(address and length); see the
-  example below. Note that the MC registers are interleaved with the
-  SMMU registers, and hence must be represented as multiple ranges.
-- interrupts : Should contain MC General interrupt.
-
-Example:
-       memory-controller {
-               compatible = "nvidia,tegra30-mc";
-               reg = <0x7000f000 0x010
-                      0x7000f03c 0x1b4
-                      0x7000f200 0x028
-                      0x7000f284 0x17c>;
-               interrupts = <0 77 0x04>;
-       };
index 2957a9ae291f4384ea145b61b2fb42876598a04c..d8ed5b780ed9d31dec1ee7b59aa6758abde4b41d 100644 (file)
@@ -79,7 +79,11 @@ Optional properties:
                mode as for example omap4 L4_CFG_CLKCTRL
 
 - clock-names  should contain at least "fck", and optionally also "ick"
-               depending on the SoC and the interconnect target module
+               depending on the SoC and the interconnect target module,
+               some interconnect target modules also need additional
+               optional clocks that can be specified as listed in TRM
+               for the related CLKCTRL register bits 8 to 15 such as
+               "dbclk" or "clk32k" depending on their role
 
 - ti,hwmods    optional TI interconnect module name to use legacy
                hwmod platform data
index e2b377ed6f915440997b3715eed53a94775ab70d..e950599566a99876b9be5e7536828e469fef4f80 100644 (file)
@@ -10,9 +10,6 @@ Required Properties:
                "amlogic,gxl-clkc" for GXL and GXM SoC,
                "amlogic,axg-clkc" for AXG SoC.
 
-- reg: physical base address of the clock controller and length of memory
-       mapped region.
-
 - #clock-cells: should be 1.
 
 Each clock is assigned an identifier and client nodes can use this identifier
@@ -20,13 +17,22 @@ to specify the clock which they consume. All available clocks are defined as
 preprocessor macros in the dt-bindings/clock/gxbb-clkc.h header and can be
 used in device tree sources.
 
+Parent node should have the following properties :
+- compatible: "syscon", "simple-mfd, and "amlogic,meson-gx-hhi-sysctrl" or
+              "amlogic,meson-axg-hhi-sysctrl"
+- reg: base address and size of the HHI system control register space.
+
 Example: Clock controller node:
 
-       clkc: clock-controller@c883c000 {
+sysctrl: system-controller@0 {
+       compatible = "amlogic,meson-gx-hhi-sysctrl", "syscon", "simple-mfd";
+       reg = <0 0 0 0x400>;
+
+       clkc: clock-controller {
                #clock-cells = <1>;
                compatible = "amlogic,gxbb-clkc";
-               reg = <0x0 0xc883c000 0x0 0x3db>;
        };
+};
 
 Example: UART controller node that consumes the clock generated by the clock
   controller:
index 7364953d0d0bd8c22699366a50981bef3adb5386..45ac19bfa0a9ff4d73cb6cffcd16560dd0fe6b0c 100644 (file)
@@ -31,10 +31,10 @@ This binding uses the common clock binding[1].
 Each subnode should use the binding described in [2]..[7]
 
 [1] Documentation/devicetree/bindings/clock/clock-bindings.txt
-[3] Documentation/devicetree/bindings/clock/st,clkgen-mux.txt
-[4] Documentation/devicetree/bindings/clock/st,clkgen-pll.txt
-[7] Documentation/devicetree/bindings/clock/st,quadfs.txt
-[8] Documentation/devicetree/bindings/clock/st,flexgen.txt
+[3] Documentation/devicetree/bindings/clock/st/st,clkgen-mux.txt
+[4] Documentation/devicetree/bindings/clock/st/st,clkgen-pll.txt
+[7] Documentation/devicetree/bindings/clock/st/st,quadfs.txt
+[8] Documentation/devicetree/bindings/clock/st/st,flexgen.txt
 
 
 Required properties:
index 03f8fdee62a7e3e2c559789eb501f9f12d6542a5..56d603c1f71685678a6cf9d8a52da537cff721bd 100644 (file)
@@ -10,7 +10,7 @@ will be controlled instead and the corresponding hw-ops for
 that is used.
 
 [1] Documentation/devicetree/bindings/clock/clock-bindings.txt
-[2] Documentation/devicetree/bindings/clock/gate-clock.txt
+[2] Documentation/devicetree/bindings/clock/gpio-gate-clock.txt
 [3] Documentation/devicetree/bindings/clock/ti/clockdomain.txt
 
 Required properties:
index 3111a409fea6cebb739a01592874d2c88d56328b..3f4704040140d1dd350148da2dff43cff63f9120 100644 (file)
@@ -9,7 +9,7 @@ companion clock finding (match corresponding functional gate
 clock) and hardware autoidle enable / disable.
 
 [1] Documentation/devicetree/bindings/clock/clock-bindings.txt
-[2] Documentation/devicetree/bindings/clock/gate-clock.txt
+[2] Documentation/devicetree/bindings/clock/gpio-gate-clock.txt
 
 Required properties:
 - compatible : shall be one of:
index d36f07e0a2bb43af831d64c6b671f18a6e7a82ef..0551c78619de807b99908d76eaf76cd6831ee3a5 100644 (file)
@@ -8,7 +8,7 @@ Required properties:
        "intermediate"  - A parent of "cpu" clock which is used as "intermediate" clock
                          source (usually MAINPLL) when the original CPU PLL is under
                          transition and not stable yet.
-       Please refer to Documentation/devicetree/bindings/clk/clock-bindings.txt for
+       Please refer to Documentation/devicetree/bindings/clock/clock-bindings.txt for
        generic clock consumer properties.
 - operating-points-v2: Please refer to Documentation/devicetree/bindings/opp/opp.txt
        for detail.
index d6d2833482c9b09ba1f7c664ea4952b8f2b63464..fc2bcbe26b1e5fae443fdaa96a016a48655e8870 100644 (file)
@@ -12,7 +12,7 @@ Required properties:
 - clocks:               Phandles for clock specified in "clock-names" property
 - clock-names :                 The name of clock used by the DFI, must be
                         "pclk_ddr_mon";
-- operating-points-v2:  Refer to Documentation/devicetree/bindings/power/opp.txt
+- operating-points-v2:  Refer to Documentation/devicetree/bindings/opp/opp.txt
                         for details.
 - center-supply:        DMC supply node.
 - status:               Marks the node enabled/disabled.
index 1a4eaca40d941e60835accac50d23a6d5f43e054..f5a02f61dd36f1c68acc89f15507a144188db8c0 100644 (file)
@@ -30,7 +30,7 @@ Optional properties:
   - nxp,calib-gpios: calibration GPIO, which must correspond with the
        gpio used for the TDA998x interrupt pin.
 
-[1] Documentation/sound/alsa/soc/DAI.txt
+[1] Documentation/sound/soc/dai.rst
 [2] include/dt-bindings/display/tda998x.h
 
 Example:
index 7b40054be0d8c76a3196cdb9fd2cc093ce63b463..fcf6979c0b6d3e0ba95f22ea70e56d103ac77d1e 100644 (file)
@@ -11,9 +11,10 @@ Required properties:
  * "qcom,scm-msm8660" for MSM8660 platforms
  * "qcom,scm-msm8690" for MSM8690 platforms
  * "qcom,scm-msm8996" for MSM8996 platforms
+ * "qcom,scm-ipq4019" for IPQ4019 platforms
  * "qcom,scm" for later processors (MSM8916, APQ8084, MSM8974, etc)
 - clocks: One to three clocks may be required based on compatible.
- * No clock required for "qcom,scm-msm8996"
+ * No clock required for "qcom,scm-msm8996", "qcom,scm-ipq4019"
  * Only core clock required for "qcom,scm-apq8064", "qcom,scm-msm8660", and "qcom,scm-msm8960"
  * Core, iface, and bus clocks required for "qcom,scm"
 - clock-names: Must contain "core" for the core clock, "iface" for the interface
index 039219df05c5f69836a39bac48bac64ce33d476a..18a2cde2e5f3a96c89067ea5cafd60fe4c71a0bc 100644 (file)
@@ -34,7 +34,7 @@ Optional properties:
 - mali-supply : Phandle to regulator for the Mali device. Refer to
   Documentation/devicetree/bindings/regulator/regulator.txt for details.
 
-- operating-points-v2 : Refer to Documentation/devicetree/bindings/power/opp.txt
+- operating-points-v2 : Refer to Documentation/devicetree/bindings/opp/opp.txt
   for details.
 
 
index c1f65d1dac1db5db178f8766e61eb8a22bf88f1f..63cd91176a688b5faf24b37dfd959dbeb1c7376d 100644 (file)
@@ -44,7 +44,7 @@ Optional properties:
 
   - memory-region:
     Memory region to allocate from, as defined in
-    Documentation/devicetree/bindi/reserved-memory/reserved-memory.txt
+    Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
 
   - mali-supply:
     Phandle to regulator for the Mali device, as defined in
index 64e6e656c345c29c6b626100ffe74e47398959d1..b745f3706120f0605f43642af2750832832c75db 100644 (file)
@@ -24,7 +24,7 @@ Recommended properties :
 - clock-frequency : desired I2C bus clock frequency in Hz.
 - ti,has-pfunc: boolean; if defined, it indicates that SoC supports PFUNC
        registers. PFUNC registers allow to switch I2C pins to function as
-       GPIOs, so they can by toggled manually.
+       GPIOs, so they can be toggled manually.
 
 Example (enbw_cmc board):
        i2c@1c22000 {
index 4a7811ecd95447c8d1026b578f0bd557b65a07d7..7ce8fae55537046beb460436c025fb7bed2cddd2 100644 (file)
@@ -15,6 +15,7 @@ Required properties:
        "renesas,i2c-r8a7796" if the device is a part of a R8A7796 SoC.
        "renesas,i2c-r8a77965" if the device is a part of a R8A77965 SoC.
        "renesas,i2c-r8a77970" if the device is a part of a R8A77970 SoC.
+       "renesas,i2c-r8a77980" if the device is a part of a R8A77980 SoC.
        "renesas,i2c-r8a77995" if the device is a part of a R8A77995 SoC.
        "renesas,rcar-gen1-i2c" for a generic R-Car Gen1 compatible device.
        "renesas,rcar-gen2-i2c" for a generic R-Car Gen2 or RZ/G1 compatible
index 89b3250f049b6ead36b110df609a1ab340ac0fb8..66ae46d3bc2ff410b5be06a8f1fd288c306c6c4e 100644 (file)
@@ -8,9 +8,7 @@ Required properties:
       (b) "samsung, s3c2440-i2c", for i2c compatible with s3c2440 i2c.
       (c) "samsung, s3c2440-hdmiphy-i2c", for s3c2440-like i2c used
           inside HDMIPHY block found on several samsung SoCs
-      (d) "samsung, exynos5440-i2c", for s3c2440-like i2c used
-          on EXYNOS5440 which does not need GPIO configuration.
-      (e) "samsung, exynos5-sata-phy-i2c", for s3c2440-like i2c used as
+      (d) "samsung, exynos5-sata-phy-i2c", for s3c2440-like i2c used as
           a host to SATA PHY controller on an internal bus.
   - reg: physical base address of the controller and length of memory mapped
     region.
diff --git a/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt b/Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
new file mode 100644 (file)
index 0000000..2888d07
--- /dev/null
@@ -0,0 +1,43 @@
+MediaTek MT6397/MT6323 PMIC Keys Device Driver
+
+There are two key functions provided by MT6397/MT6323 PMIC, pwrkey
+and homekey. The key functions are defined as the subnode of the function
+node provided by MT6397/MT6323 PMIC that is being defined as one kind
+of Muti-Function Device (MFD)
+
+For MT6397/MT6323 MFD bindings see:
+Documentation/devicetree/bindings/mfd/mt6397.txt
+
+Required properties:
+- compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys"
+- linux,keycodes: See Documentation/devicetree/bindings/input/keys.txt
+
+Optional Properties:
+- wakeup-source: See Documentation/devicetree/bindings/power/wakeup-source.txt
+- mediatek,long-press-mode: Long press key shutdown setting, 1 for
+       pwrkey only, 2 for pwrkey/homekey together, others for disabled.
+- power-off-time-sec: See Documentation/devicetree/bindings/input/keys.txt
+
+Example:
+
+       pmic: mt6397 {
+               compatible = "mediatek,mt6397";
+
+               ...
+
+               mt6397keys: mt6397keys {
+                       compatible = "mediatek,mt6397-keys";
+                       mediatek,long-press-mode = <1>;
+                       power-off-time-sec = <0>;
+
+                       power {
+                               linux,keycodes = <116>;
+                               wakeup-source;
+                       };
+
+                       home {
+                               linux,keycodes = <114>;
+                       };
+               };
+
+       };
index f2c30c8b725dff3f6ba8c2b55b4f4e2e416e97a7..9afffbdf6e285bc3c57673e86b4aac3e805aa855 100644 (file)
@@ -12,7 +12,7 @@ Additional documentation for F11 can be found at:
 http://www.synaptics.com/sites/default/files/511-000136-01-Rev-E-RMI4-Interfacing-Guide.pdf
 
 Optional Touch Properties:
-Description in Documentation/devicetree/bindings/input/touch
+Description in Documentation/devicetree/bindings/input/touchscreen
 - touchscreen-inverted-x
 - touchscreen-inverted-y
 - touchscreen-swapped-x-y
index f99fe5cdeaec6b6c4d841bfa49603e84495a1b16..a644408b33b8f17d1d00be1177a259e8780a9c97 100644 (file)
@@ -28,7 +28,7 @@ Deprecated properties:
   This property is deprecated. Instead, a 'steps-per-period ' value should
   be used, such as "rotary-encoder,steps-per-period = <2>".
 
-See Documentation/input/rotary-encoder.txt for more information.
+See Documentation/input/devices/rotary-encoder.rst for more information.
 
 Example:
 
index 764db86d441ad131aceca0e15146d5c914d97919..3108109066132698eaaff2606cd4a652d708a202 100644 (file)
@@ -17,6 +17,10 @@ Optional properties:
                "pwms" property (see PWM binding[0])
   - enable-gpios: contains a single GPIO specifier for the GPIO which enables
                   and disables the backlight (see GPIO binding[1])
+  - post-pwm-on-delay-ms: Delay in ms between setting an initial (non-zero) PWM
+                          and enabling the backlight using GPIO.
+  - pwm-off-delay-ms: Delay in ms between disabling the backlight using GPIO
+                      and setting PWM value to 0.
 
 [0]: Documentation/devicetree/bindings/pwm/pwm.txt
 [1]: Documentation/devicetree/bindings/gpio/gpio.txt
@@ -32,4 +36,6 @@ Example:
 
                power-supply = <&vdd_bl_reg>;
                enable-gpios = <&gpio 58 0>;
+               post-pwm-on-delay-ms = <10>;
+               pwm-off-delay-ms = <10>;
        };
diff --git a/Documentation/devicetree/bindings/leds/backlight/zii,rave-sp-backlight.txt b/Documentation/devicetree/bindings/leds/backlight/zii,rave-sp-backlight.txt
new file mode 100644 (file)
index 0000000..ff5c921
--- /dev/null
@@ -0,0 +1,23 @@
+Zodiac Inflight Innovations RAVE Supervisory Processor Backlight Bindings
+
+RAVE SP backlight device is a "MFD cell" device corresponding to
+backlight functionality of RAVE Supervisory Processor. It is expected
+that its Device Tree node is specified as a child of the node
+corresponding to the parent RAVE SP device (as documented in
+Documentation/devicetree/bindings/mfd/zii,rave-sp.txt)
+
+Required properties:
+
+- compatible: Should be "zii,rave-sp-backlight"
+
+Example:
+
+       rave-sp {
+               compatible = "zii,rave-sp-rdu1";
+               current-speed = <38400>;
+
+               backlight {
+                       compatible = "zii,rave-sp-backlight";
+               };
+       }
+
index c7888d6f640874df3607a578e68cb124d0b8cfa8..880d4d70c9fd741ac13101721ced18f04336c373 100644 (file)
@@ -28,7 +28,7 @@ See: Documentation/devicetree/bindings/clock/clock-bindings.txt
 - pinctrl-names        : a pinctrl state named tsin%d-serial or tsin%d-parallel (where %d is tsin-num)
                   must be defined for each tsin child node.
 - pinctrl-0    : phandle referencing pin configuration for this tsin configuration
-See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
+See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
 
 
 Required properties (tsin (child) node):
index f9632bacbd04aebd4ad68c46012777eb0c263204..7d60a50a4fa1c72ec7c6347705b3ffea3898c6b3 100644 (file)
@@ -6,11 +6,21 @@ Required properties:
   example below. Note that the MC registers are interleaved with the
   GART registers, and hence must be represented as multiple ranges.
 - interrupts : Should contain MC General interrupt.
+- #reset-cells : Should be 1. This cell represents memory client module ID.
+  The assignments may be found in header file <dt-bindings/memory/tegra20-mc.h>
+  or in the TRM documentation.
 
 Example:
-       memory-controller@7000f000 {
+       mc: memory-controller@7000f000 {
                compatible = "nvidia,tegra20-mc";
                reg = <0x7000f000 0x024
                       0x7000f03c 0x3c4>;
                interrupts = <0 77 0x04>;
+               #reset-cells = <1>;
+       };
+
+       video-codec@6001a000 {
+               compatible = "nvidia,tegra20-vde";
+               ...
+               resets = <&mc TEGRA20_MC_RESET_VDE>;
        };
index 14968b048cd3a5a963cd6f7604bc2ff5c19f4c11..a878b5908a4d0652cce014bbe465137d48056ded 100644 (file)
@@ -12,6 +12,9 @@ Required properties:
 - clock-names: Must include the following entries:
   - mc: the module's clock input
 - interrupts: The interrupt outputs from the controller.
+- #reset-cells : Should be 1. This cell represents memory client module ID.
+  The assignments may be found in header file <dt-bindings/memory/tegra30-mc.h>
+  or in the TRM documentation.
 
 Required properties for Tegra30, Tegra114, Tegra124, Tegra132 and Tegra210:
 - #iommu-cells: Should be 1. The single cell of the IOMMU specifier defines
@@ -72,12 +75,14 @@ Example SoC include file:
                interrupts = <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>;
 
                #iommu-cells = <1>;
+               #reset-cells = <1>;
        };
 
        sdhci@700b0000 {
                compatible = "nvidia,tegra124-sdhci";
                ...
                iommus = <&mc TEGRA_SWGROUP_SDMMC1A>;
+               resets = <&mc TEGRA124_MC_RESET_SDMMC1>;
        };
 };
 
index bdd017686ea5a082faf99e389b48a624074471cc..a014afb07902350f083d8352bc353e364d7c031a 100644 (file)
@@ -50,7 +50,7 @@ Required properties:
 
 Optional properties:
 
-  - wlf,reset : GPIO specifier for the GPIO controlling /RESET
+  - reset-gpios : GPIO specifier for the GPIO controlling /RESET
 
   - clocks: Should reference the clocks supplied on MCLK1 and MCLK2
   - clock-names: Should contains two strings:
@@ -70,6 +70,10 @@ Optional properties:
     Documentation/devicetree/bindings/regulator/regulator.txt
     (wm5102, wm5110, wm8280, wm8997, wm8998, wm1814)
 
+Deprecated properties:
+
+  - wlf,reset : GPIO specifier for the GPIO controlling /RESET
+
 Also see child specific device properties:
   Regulator - ../regulator/arizona-regulator.txt
   Extcon    - ../extcon/extcon-arizona.txt
index 0b2a6099aa20a25cdbddc537c3318b0c20116d52..5297b22107040046a2bf6ddf1213941a3ddc15f8 100644 (file)
@@ -46,7 +46,7 @@ is required:
        Following properties are require if pin control setting is required
        at boot.
        - pinctrl-names: A pinctrl state named "default" be defined, using the
-               bindings in pinctrl/pinctrl-binding.txt.
+               bindings in pinctrl/pinctrl-bindings.txt.
        - pinctrl[0...n]: Properties to contain the phandle that refer to
                different nodes of pin control settings. These nodes represents
                the pin control setting of state 0 to state n. Each of these
index 05b21bcb85437198e669ece2725a49c092316264..443e68286957a2c11af4a6660df7cf029902c121 100644 (file)
@@ -1,4 +1,4 @@
-* Dialog DA9063 Power Management Integrated Circuit (PMIC)
+* Dialog DA9063/DA9063L Power Management Integrated Circuit (PMIC)
 
 DA9093 consists of a large and varied group of sub-devices (I2C Only):
 
@@ -6,14 +6,14 @@ Device                   Supply Names    Description
 ------                   ------------    -----------
 da9063-regulator        :               : LDOs & BUCKs
 da9063-onkey            :               : On Key
-da9063-rtc              :               : Real-Time Clock
+da9063-rtc              :               : Real-Time Clock (DA9063 only)
 da9063-watchdog         :               : Watchdog
 
 ======
 
 Required properties:
 
-- compatible : Should be "dlg,da9063"
+- compatible : Should be "dlg,da9063" or "dlg,da9063l"
 - reg : Specifies the I2C slave address (this defaults to 0x58 but it can be
   modified to match the chip's OTP settings).
 - interrupt-parent : Specifies the reference to the interrupt controller for
@@ -23,8 +23,8 @@ Required properties:
 
 Sub-nodes:
 
-- regulators : This node defines the settings for the LDOs and BUCKs. The
-  DA9063 regulators are bound using their names listed below:
+- regulators : This node defines the settings for the LDOs and BUCKs.
+  The DA9063(L) regulators are bound using their names listed below:
 
     bcore1    : BUCK CORE1
     bcore2    : BUCK CORE2
@@ -32,16 +32,16 @@ Sub-nodes:
     bmem      : BUCK MEM
     bio       : BUCK IO
     bperi     : BUCK PERI
-    ldo1      : LDO_1
-    ldo2      : LDO_2
+    ldo1      : LDO_1  (DA9063 only)
+    ldo2      : LDO_2  (DA9063 only)
     ldo3      : LDO_3
-    ldo4      : LDO_4
-    ldo5      : LDO_5
-    ldo6      : LDO_6
+    ldo4      : LDO_4  (DA9063 only)
+    ldo5      : LDO_5  (DA9063 only)
+    ldo6      : LDO_6  (DA9063 only)
     ldo7      : LDO_7
     ldo8      : LDO_8
     ldo9      : LDO_9
-    ldo10     : LDO_10
+    ldo10     : LDO_10 (DA9063 only)
     ldo11     : LDO_11
 
   The component follows the standard regulator framework and the bindings
@@ -49,8 +49,9 @@ Sub-nodes:
   Documentation/devicetree/bindings/regulator/regulator.txt
 
 - rtc : This node defines settings for the Real-Time Clock associated with
-  the DA9063. There are currently no entries in this binding, however
-  compatible = "dlg,da9063-rtc" should be added if a node is created.
+  the DA9063 only. The RTC is not present in DA9063L. There are currently
+  no entries in this binding, however compatible = "dlg,da9063-rtc" should
+  be added if a node is created.
 
 - onkey : This node defines the OnKey settings for controlling the key
   functionality of the device. The node should contain the compatible property
@@ -65,8 +66,9 @@ Sub-nodes:
     and KEY_SLEEP.
 
 - watchdog : This node defines settings for the Watchdog timer associated
-  with the DA9063. There are currently no entries in this binding, however
-  compatible = "dlg,da9063-watchdog" should be added if a node is created.
+  with the DA9063 and DA9063L. There are currently no entries in this
+  binding, however compatible = "dlg,da9063-watchdog" should be added
+  if a node is created.
 
 
 Example:
index 15bc885f9df45a1de3d975d68deb9dd8cc55f050..c639705a98ef67c38a5e79b43b78cc77de76f326 100644 (file)
@@ -12,6 +12,30 @@ Required properties:
 - spi-max-frequency    : Typically set to 3000000
 - spi-cs-high          : SPI chip select direction
 
+Optional subnodes:
+
+The sub-functions of CPCAP get their own node with their own compatible values,
+which are described in the following files:
+
+- ../power/supply/cpcap-battery.txt
+- ../power/supply/cpcap-charger.txt
+- ../regulator/cpcap-regulator.txt
+- ../phy/phy-cpcap-usb.txt
+- ../input/cpcap-pwrbutton.txt
+- ../rtc/cpcap-rtc.txt
+- ../leds/leds-cpcap.txt
+- ../iio/adc/cpcap-adc.txt
+
+The only exception is the audio codec. Instead of a compatible value its
+node must be named "audio-codec".
+
+Required properties for the audio-codec subnode:
+
+- #sound-dai-cells = <1>;
+
+The audio-codec provides two DAIs. The first one is connected to the
+Stereo HiFi DAC and the second one is connected to the Voice DAC.
+
 Example:
 
 &mcspi1 {
@@ -26,6 +50,24 @@ Example:
                #size-cells = <0>;
                spi-max-frequency = <3000000>;
                spi-cs-high;
+
+               audio-codec {
+                       #sound-dai-cells = <1>;
+
+                       /* HiFi */
+                       port@0 {
+                               endpoint {
+                                       remote-endpoint = <&cpu_dai1>;
+                               };
+                       };
+
+                       /* Voice */
+                       port@1 {
+                               endpoint {
+                                       remote-endpoint = <&cpu_dai2>;
+                               };
+                       };
+               };
        };
 };
 
index 522a3bbf1bac0482018970f966a06b58aa43faf5..0ebd08af777d4d461c13e1d414627ea209d4af81 100644 (file)
@@ -7,11 +7,12 @@ MT6397/MT6323 is a multifunction device with the following sub modules:
 - GPIO
 - Clock
 - LED
+- Keys
 
 It is interfaced to host controller using SPI interface by a proprietary hardware
 called PMIC wrapper or pwrap. MT6397/MT6323 MFD is a child device of pwrap.
 See the following for pwarp node definitions:
-Documentation/devicetree/bindings/soc/pwrap.txt
+Documentation/devicetree/bindings/soc/mediatek/pwrap.txt
 
 This document describes the binding for MFD device and its sub module.
 
@@ -40,6 +41,11 @@ Optional subnodes:
                - compatible: "mediatek,mt6323-led"
        see Documentation/devicetree/bindings/leds/leds-mt6323.txt
 
+- keys
+       Required properties:
+               - compatible: "mediatek,mt6397-keys" or "mediatek,mt6323-keys"
+       see Documentation/devicetree/bindings/input/mtk-pmic-keys.txt
+
 Example:
        pwrap: pwrap@1000f000 {
                compatible = "mediatek,mt8135-pwrap";
index 6ac06c1b9aec8908095c0b2fc22af1882334293c..143706222a51cfc8c8785199f3a9d5b1d53eec33 100644 (file)
@@ -29,6 +29,9 @@ Required properties:
                    "qcom,pm8916",
                    "qcom,pm8004",
                    "qcom,pm8909",
+                   "qcom,pm8998",
+                   "qcom,pmi8998",
+                   "qcom,pm8005",
                    or generalized "qcom,spmi-pmic".
 - reg:             Specifies the SPMI USID slave address for this device.
                    For more information see:
index 1db6e0057a638e09a5346956a70620c31276fdf6..0e900b52e8959cf2653c554f6f179bb2a44adab6 100644 (file)
@@ -19,6 +19,11 @@ Required parameters:
 Optional parameters:
 - resets:              Phandle to the parent reset controller.
                        See ../reset/st,stm32-rcc.txt
+- dmas:                        List of phandle to dma channels that can be used for
+                       this timer instance. There may be up to 7 dma channels.
+- dma-names:           List of dma names. Must match 'dmas' property. Valid
+                       names are: "ch1", "ch2", "ch3", "ch4", "up", "trig",
+                       "com".
 
 Optional subnodes:
 - pwm:                 See ../pwm/pwm-stm32.txt
@@ -44,3 +49,18 @@ Example:
                        reg = <0>;
                };
        };
+
+Example with all dmas:
+       timer@40010000 {
+               ...
+               dmas = <&dmamux1 11 0x400 0x0>,
+                      <&dmamux1 12 0x400 0x0>,
+                      <&dmamux1 13 0x400 0x0>,
+                      <&dmamux1 14 0x400 0x0>,
+                      <&dmamux1 15 0x400 0x0>,
+                      <&dmamux1 16 0x400 0x0>,
+                      <&dmamux1 17 0x400 0x0>;
+               dma-names = "ch1", "ch2", "ch3", "ch4", "up", "trig", "com";
+               ...
+               child nodes...
+       };
index dd2c06540485bd94c8ee7197d5e052f4dbef4de1..daa091c2e67ba06063e778ce0ca0c012c808a590 100644 (file)
@@ -8,8 +8,8 @@ Required properties:
  - reg: The PRCM registers range
 
 The prcm node may contain several subdevices definitions:
- - see Documentation/devicetree/clk/sunxi.txt for clock devices
- - see Documentation/devicetree/reset/allwinner,sunxi-clock-reset.txt for reset
+ - see Documentation/devicetree/bindings/clock/sunxi.txt for clock devices
+ - see Documentation/devicetree/bindings/reset/allwinner,sunxi-clock-reset.txt for reset
    controller devices
 
 
index a58c173b7ab9882091fe26e378ce655610f17455..0419a63f73a01457a88e79bb9b61ff4b606fd011 100644 (file)
@@ -62,7 +62,7 @@ Required properties for a slot (Deprecated - Recommend to use one slot per host)
   rest of the gpios (depending on the bus-width property) are the data lines in
   no particular order. The format of the gpio specifier depends on the gpio
   controller.
-(Deprecated - Refer to Documentation/devicetree/binding/pinctrl/samsung-pinctrl.txt)
+(Deprecated - Refer to Documentation/devicetree/bindings/pinctrl/samsung-pinctrl.txt)
 
 Example:
 
index 3149297b3933293c35647ef8ae215684f2d1fc5c..f064528effed31f30d1d1c6e0b49c02e215d99af 100644 (file)
@@ -12,7 +12,7 @@ Required properties:
           See: Documentation/devicetree/bindings/clock/clock-bindings.txt
 - pinctrl-names: A pinctrl state names "default" must be defined.
 - pinctrl-0: Phandle referencing pin configuration of the SDHCI controller.
-             See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
+             See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
 
 Example:
 
index 6b3d40ca395eb47c59696766f45cf22a6fc8de77..ccf82b4ee838e0c86f5bfef9b1f14b19d3323fc4 100644 (file)
@@ -20,7 +20,7 @@ Required properties:
 
 - pinctrl-names:       A pinctrl state names "default" must be defined.
 - pinctrl-0:           Phandle referencing pin configuration of the sd/emmc controller.
-                       See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
+                       See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
 
 - reg:                 This must provide the host controller base address and it can also
                        contain the FlashSS Top register for TX/RX delay used by the driver
index fd23904ac68e929adcc6657b6cde29ea4206fd7e..a700943218cac9892a58df1c51b603e5003d029f 100644 (file)
@@ -6,7 +6,7 @@ Required properties:
 - compatible: For external switch chips, compatible string must be exactly one
   of: "microchip,ksz9477"
 
-See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional
+See Documentation/devicetree/bindings/net/dsa/dsa.txt for a list of additional
 required and optional properties.
 
 Examples:
index a9bc27b93ee326fe2ac665ffc143b0e3e345c0a0..aa3527f71fdc7ee9377b95fba69adad5d2264955 100644 (file)
@@ -31,7 +31,7 @@ Required properties for the child nodes within ports container:
 - phy-mode: String, must be either "trgmii" or "rgmii" for port labeled
         "cpu".
 
-See Documentation/devicetree/bindings/dsa/dsa.txt for a list of additional
+See Documentation/devicetree/bindings/net/dsa/dsa.txt for a list of additional
 required, optional properties and how the integrated switch subnodes must
 be specified.
 
index d69543701d5d58dad79bf41772eb1426d8f4efee..e319fe5e205ac5d32af9726285afe942848f934c 100644 (file)
@@ -4,6 +4,7 @@ Required properties:
 - compatible: Should be one of the following:
   "allwinner,sun4i-a10-sid"
   "allwinner,sun7i-a20-sid"
+  "allwinner,sun8i-a83t-sid"
   "allwinner,sun8i-h3-sid"
   "allwinner,sun50i-a64-sid"
 
index d5e22fc67d66a5ba1a51d6d0c01ab098f5356e03..0df79d9e07ec22f50ef7c6641afea3ba6c311aa0 100644 (file)
@@ -18,7 +18,7 @@ Optional properties:
 Data cells:
 
 Data cells are child nodes of eerpom node, bindings for which are
-documented in Documentation/bindings/nvmem/nvmem.txt
+documented in Documentation/devicetree/bindings/nvmem/nvmem.txt
 
 Example:
 
index 7bf9df047a1ee4992ee7f8b9f8e3f742b26bc8a0..0dcb87d6554fdaa2f8c36dc37ab6ea545f80bc86 100644 (file)
@@ -3,7 +3,7 @@ HiSilicon Hip05 and Hip06 PCIe host bridge DT description
 HiSilicon PCIe host controller is based on the Synopsys DesignWare PCI core.
 It shares common functions with the PCIe DesignWare core driver and inherits
 common properties defined in
-Documentation/devicetree/bindings/pci/designware-pci.txt.
+Documentation/devicetree/bindings/pci/designware-pcie.txt.
 
 Additional properties are described here:
 
index 6e217c63123db6c1021dba04d09ec419be05fd67..6bbe43818ad5d23d1e726cbc408ef08a86ea46fb 100644 (file)
@@ -3,7 +3,7 @@ HiSilicon Kirin SoCs PCIe host DT description
 Kirin PCIe host controller is based on the Synopsys DesignWare PCI core.
 It shares common functions with the PCIe DesignWare core driver and
 inherits common properties defined in
-Documentation/devicetree/bindings/pci/designware-pci.txt.
+Documentation/devicetree/bindings/pci/designware-pcie.txt.
 
 Additional properties are described here:
 
index 7e05487544edffae025e1071406fe711cf220773..3d4a209b0fd057e173fa24c7e20bc75c234445d5 100644 (file)
@@ -3,9 +3,9 @@ TI Keystone PCIe interface
 Keystone PCI host Controller is based on the Synopsys DesignWare PCI
 hardware version 3.65.  It shares common functions with the PCIe DesignWare
 core driver and inherits common properties defined in
-Documentation/devicetree/bindings/pci/designware-pci.txt
+Documentation/devicetree/bindings/pci/designware-pcie.txt
 
-Please refer to Documentation/devicetree/bindings/pci/designware-pci.txt
+Please refer to Documentation/devicetree/bindings/pci/designware-pcie.txt
 for the details of DesignWare DT bindings.  Additional properties are
 described here as well as properties that are not applicable.
 
index ad4fce3552bbec734726f08a694294512a3f7038..511fc234558bf1743c76c2f2d03c4c40b2a22bfd 100644 (file)
@@ -11,9 +11,9 @@ Optional Pinmux properties:
 --------------------------
 Following properties are required if default setting of pins are required
 at boot.
-- pinctrl-names: A pinctrl state named per <pinctrl-binding.txt>.
+- pinctrl-names: A pinctrl state named per <pinctrl-bindings.txt>.
 - pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
-               <pinctrl-binding.txt>.
+               <pinctrl-bindings.txt>.
 
 The pin configurations are defined as child of the pinctrl states node. Each
 sub-node have following properties:
index a677145ae6d1f6f69a765f785ccaeaf25f49912b..625a22e2f2115050477e59c076203be38346ae91 100644 (file)
@@ -101,9 +101,9 @@ Optional Pinmux properties:
 --------------------------
 Following properties are required if default setting of pins are required
 at boot.
-- pinctrl-names: A pinctrl state named per <pinctrl-binding.txt>.
+- pinctrl-names: A pinctrl state named per <pinctrl-bindings.txt>.
 - pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
-               <pinctrl-binding.txt>.
+               <pinctrl-bindings.txt>.
 
 The pin configurations are defined as child of the pinctrl states node. Each
 sub-node have following properties:
index eee3dc26093437e22b2271dda50c627eafcfe39f..cbcbd31e3ce850bf9d3cd501027350991bfefaf4 100644 (file)
@@ -10,9 +10,9 @@ Optional Pinmux properties:
 --------------------------
 Following properties are required if default setting of pins are required
 at boot.
-- pinctrl-names: A pinctrl state named per <pinctrl-binding.txt>.
+- pinctrl-names: A pinctrl state named per <pinctrl-bindings.txt>.
 - pinctrl[0...n]: Properties to contain the phandle for pinctrl states per
-               <pinctrl-binding.txt>.
+               <pinctrl-bindings.txt>.
 
 The pin configurations are defined as child of the pinctrl states node. Each
 sub-node have following properties:
index b31d6bbeee1644e7a553cb69fab1da5e9a225ec6..726ec2875223d8038b2a8fa7300d7ccfd8db2884 100644 (file)
@@ -14,7 +14,7 @@ Required properties:
   datasheet
 - interrupts: Should contain one interrupt specifier for the GPC interrupt
 - clocks: Must contain an entry for each entry in clock-names.
-  See Documentation/devicetree/bindings/clocks/clock-bindings.txt for details.
+  See Documentation/devicetree/bindings/clock/clock-bindings.txt for details.
 - clock-names: Must include the following entries:
   - ipg
 
index 549f7dee9b9de0b33f851ab1bb34008ab9d1a51a..92ef355e8f6433c58c14f4bc3d05f39fbf7ea858 100644 (file)
@@ -15,23 +15,13 @@ Required Properties:
 Optional Properties:
 - label: Human readable string with domain name. Will be visible in userspace
        to let user to distinguish between multiple domains in SoC.
-- clocks: List of clock handles. The parent clocks of the input clocks to the
-       devices in this power domain are set to oscclk before power gating
-       and restored back after powering on a domain. This is required for
-       all domains which are powered on and off and not required for unused
-       domains.
-- clock-names: The following clocks can be specified:
-       - oscclk: Oscillator clock.
-       - clkN: Input clocks to the devices in this power domain. These clocks
-               will be reparented to oscclk before switching power domain off.
-               Their original parent will be brought back after turning on
-               the domain. Maximum of 4 clocks (N = 0 to 3) are supported.
-       - asbN: Clocks required by asynchronous bridges (ASB) present in
-               the power domain. These clock should be enabled during power
-               domain on/off operations.
 - power-domains: phandle pointing to the parent power domain, for more details
                 see Documentation/devicetree/bindings/power/power_domain.txt
 
+Deprecated Properties:
+- clocks
+- clock-names
+
 Node of a device using power domains must have a power-domains property
 defined with a phandle to respective power domain.
 
@@ -47,8 +37,6 @@ Example:
        mfc_pd: power-domain@10044060 {
                compatible = "samsung,exynos4210-pd";
                reg = <0x10044060 0x20>;
-               clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_USER_ACLK333>;
-               clock-names = "oscclk", "clk0";
                #power-domain-cells = <0>;
                label = "MFC";
        };
index 4733f76cbe48da4d81f3207e59d081c6988dfe6c..9b387f861aed166bda522f6e3d4ebb8856a49218 100644 (file)
@@ -111,8 +111,8 @@ Example 3:
 ==PM domain consumers==
 
 Required properties:
- - power-domains : A phandle and PM domain specifier as defined by bindings of
-                   the power controller specified by phandle.
+ - power-domains : A list of PM domain specifiers, as defined by bindings of
+               the power controller that is the PM domain provider.
 
 Example:
 
@@ -122,9 +122,18 @@ Example:
                power-domains = <&power 0>;
        };
 
-The node above defines a typical PM domain consumer device, which is located
-inside a PM domain with index 0 of a power controller represented by a node
-with the label "power".
+       leaky-device@12351000 {
+               compatible = "foo,i-leak-current";
+               reg = <0x12351000 0x1000>;
+               power-domains = <&power 0>, <&power 1> ;
+       };
+
+The first example above defines a typical PM domain consumer device, which is
+located inside a PM domain with index 0 of a power controller represented by a
+node with the label "power".
+In the second example the consumer device are partitioned across two PM domains,
+the first with index 0 and the second with index 1, of a power controller that
+is represented by a node with the label "power.
 
 Optional properties:
 - required-opps: This contains phandle to an OPP node in another device's OPP
index ab399e559257a106448f583dbd7275137d4c5bdb..180ae65be753ae43ecc39a294a3a7163bdb517d5 100644 (file)
@@ -9,6 +9,7 @@ Required properties:
   - compatible: Must contain exactly one of the following:
       - "renesas,r8a7743-sysc" (RZ/G1M)
       - "renesas,r8a7745-sysc" (RZ/G1E)
+      - "renesas,r8a77470-sysc" (RZ/G1C)
       - "renesas,r8a7779-sysc" (R-Car H1)
       - "renesas,r8a7790-sysc" (R-Car H2)
       - "renesas,r8a7791-sysc" (R-Car M2-W)
@@ -20,6 +21,7 @@ Required properties:
       - "renesas,r8a77965-sysc" (R-Car M3-N)
       - "renesas,r8a77970-sysc" (R-Car V3M)
       - "renesas,r8a77980-sysc" (R-Car V3H)
+      - "renesas,r8a77990-sysc" (R-Car E3)
       - "renesas,r8a77995-sysc" (R-Car D3)
   - reg: Address start and address range for the device.
   - #power-domain-cells: Must be 1.
index 0ba1bcc7f33aad00408c287f8d1fd95911443c41..f181e46d8e077c333fe3e6ea71d976bee0ec61a0 100644 (file)
@@ -13,4 +13,4 @@ Required Properties:
        };
 
 For information on battery specific node, Ref:
-Documentation/devicetree/bindings/power_supply/ab8500/fg.txt
+Documentation/devicetree/bindings/power/supply/ab8500/fg.txt
index ef5328371122c58a3ecb7ed359873de4c8a6203a..56636f927203e8398a6430d61b47da4b65cfed49 100644 (file)
@@ -13,4 +13,4 @@ ab8500_chargalg {
 };
 
 For information on battery specific node, Ref:
-Documentation/devicetree/bindings/power_supply/ab8500/fg.txt
+Documentation/devicetree/bindings/power/supply/ab8500/fg.txt
index 6bdbb08ea9e0f78a82f52c7aac9a5f7dee180c9b..24ada03e07b4dda824fc479a61ce35ea18834dea 100644 (file)
@@ -22,4 +22,4 @@ Required Properties:
        };
 
 For information on battery specific node, Ref:
-Documentation/devicetree/bindings/power_supply/ab8500/fg.txt
+Documentation/devicetree/bindings/power/supply/ab8500/fg.txt
index 5d254ab13ebf384034b7e8629365a7b0070c2af3..cfd74659fbed03e00a6de0e7f0150b32fbf3713b 100644 (file)
@@ -22,7 +22,7 @@ List of legacy properties and respective binding document
 3. "has-tpo"                   Documentation/devicetree/bindings/rtc/rtc-opal.txt
 4. "linux,wakeup"              Documentation/devicetree/bindings/input/gpio-matrix-keypad.txt
                                Documentation/devicetree/bindings/mfd/tc3589x.txt
-                               Documentation/devicetree/bindings/input/ads7846.txt
+                               Documentation/devicetree/bindings/input/touchscreen/ads7846.txt
 5. "linux,keypad-wakeup"       Documentation/devicetree/bindings/input/qcom,pm8xxx-keypad.txt
 6. "linux,input-wakeup"                Documentation/devicetree/bindings/input/samsung-keypad.txt
 7. "nvidia,wakeup-source"      Documentation/devicetree/bindings/input/nvidia,tegra20-kbc.txt
index 00d3d58a102fe6da2ed0b70b7ce2d61772b17822..d9018242545044e6ac0cad6f7bbead4bdbbb87f6 100644 (file)
@@ -11,6 +11,7 @@ on the Qualcomm Hexagon core.
                    "qcom,msm8916-mss-pil",
                    "qcom,msm8974-mss-pil"
                    "qcom,msm8996-mss-pil"
+                   "qcom,sdm845-mss-pil"
 
 - reg:
        Usage: required
diff --git a/Documentation/devicetree/bindings/reserved-memory/qcom,cmd-db.txt b/Documentation/devicetree/bindings/reserved-memory/qcom,cmd-db.txt
new file mode 100644 (file)
index 0000000..6839553
--- /dev/null
@@ -0,0 +1,37 @@
+Command DB
+---------
+
+Command DB is a database that provides a mapping between resource key and the
+resource address for a system resource managed by a remote processor. The data
+is stored in a shared memory region and is loaded by the remote processor.
+
+Some of the Qualcomm Technologies Inc SoC's have hardware accelerators for
+controlling shared resources. Depending on the board configuration the shared
+resource properties may change. These properties are dynamically probed by the
+remote processor and made available in the shared memory.
+
+The bindings for Command DB is specified in the reserved-memory section in
+devicetree. The devicetree representation of the command DB driver should be:
+
+Properties:
+- compatible:
+       Usage: required
+       Value type: <string>
+       Definition: Should be "qcom,cmd-db"
+
+- reg:
+       Usage: required
+       Value type: <prop encoded array>
+       Definition: The register address that points to the actual location of
+                   the Command DB in memory.
+
+Example:
+
+       reserved-memory {
+               [...]
+               reserved-memory@85fe0000 {
+                       reg = <0x0 0x85fe0000 0x0 0x20000>;
+                       compatible = "qcom,cmd-db";
+                       no-map;
+               };
+       };
index 294a0dae106a2623160b42dd1d947102095e5a37..67e83b02e10b63e33615e7f516618cfe238c84c3 100644 (file)
@@ -17,6 +17,7 @@ Required properties:
                Examples with soctypes are:
                  - "renesas,r8a7743-rst" (RZ/G1M)
                  - "renesas,r8a7745-rst" (RZ/G1E)
+                 - "renesas,r8a77470-rst" (RZ/G1C)
                  - "renesas,r8a7778-reset-wdt" (R-Car M1A)
                  - "renesas,r8a7779-reset-wdt" (R-Car H1)
                  - "renesas,r8a7790-rst" (R-Car H2)
@@ -29,6 +30,7 @@ Required properties:
                  - "renesas,r8a77965-rst" (R-Car M3-N)
                  - "renesas,r8a77970-rst" (R-Car V3M)
                  - "renesas,r8a77980-rst" (R-Car V3H)
+                 - "renesas,r8a77990-rst" (R-Car E3)
                  - "renesas,r8a77995-rst" (R-Car D3)
   - reg: Address start and address range for the device.
 
index 627b29531a32f183435f28a9f5f7a383d7a2bbde..aaac7975f61c7b6f6cb8736a8362272e40dd8464 100644 (file)
@@ -14,11 +14,16 @@ Optional properties:
 - clocks : phandle to clock-controller plus clock-specifier pair
 - clock-names : "ipsec" as a clock name
 
+Optional properties:
+
+- interrupts: specify the interrupt for the RNG block
+
 Example:
 
 rng {
-        compatible = "brcm,bcm2835-rng";
-        reg = <0x7e104000 0x10>;
+       compatible = "brcm,bcm2835-rng";
+       reg = <0x7e104000 0x10>;
+       interrupts = <2 29>;
 };
 
 rng@18033000 {
index 7a34345d0ca368e05cd036e01c58920313cb6f70..c8dd440e97470b3f3c237545d2b7ba879caae411 100644 (file)
@@ -8,7 +8,7 @@ Required properties:
           See: Documentation/devicetree/bindings/clock/clock-bindings.txt
 - pinctrl-names: A pinctrl state names "default" must be defined.
 - pinctrl-0: Phandle referencing pin configuration of the UART peripheral.
-             See: Documentation/devicetree/bindings/pinctrl/pinctrl-binding.txt
+             See: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt
 
 Optional properties:
 - cts-gpios: CTS pin for UART
diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.txt
new file mode 100644 (file)
index 0000000..d330c73
--- /dev/null
@@ -0,0 +1,119 @@
+Qualcomm Technologies, Inc. GENI Serial Engine QUP Wrapper Controller
+
+Generic Interface (GENI) based Qualcomm Universal Peripheral (QUP) wrapper
+is a programmable module for supporting a wide range of serial interfaces
+like UART, SPI, I2C, I3C, etc. A single QUP module can provide upto 8 Serial
+Interfaces, using its internal Serial Engines. The GENI Serial Engine QUP
+Wrapper controller is modeled as a node with zero or more child nodes each
+representing a serial engine.
+
+Required properties:
+- compatible:          Must be "qcom,geni-se-qup".
+- reg:                 Must contain QUP register address and length.
+- clock-names:         Must contain "m-ahb" and "s-ahb".
+- clocks:              AHB clocks needed by the device.
+
+Required properties if child node exists:
+- #address-cells:      Must be <1> for Serial Engine Address
+- #size-cells:                 Must be <1> for Serial Engine Address Size
+- ranges:              Must be present
+
+Properties for children:
+
+A GENI based QUP wrapper controller node can contain 0 or more child nodes
+representing serial devices.  These serial devices can be a QCOM UART, I2C
+controller, SPI controller, or some combination of aforementioned devices.
+Please refer below the child node definitions for the supported serial
+interface protocols.
+
+Qualcomm Technologies Inc. GENI Serial Engine based I2C Controller
+
+Required properties:
+- compatible:          Must be "qcom,geni-i2c".
+- reg:                         Must contain QUP register address and length.
+- interrupts:          Must contain I2C interrupt.
+- clock-names:                 Must contain "se".
+- clocks:              Serial engine core clock needed by the device.
+- #address-cells:      Must be <1> for I2C device address.
+- #size-cells:         Must be <0> as I2C addresses have no size component.
+
+Optional property:
+- clock-frequency:     Desired I2C bus clock frequency in Hz.
+                       When missing default to 400000Hz.
+
+Child nodes should conform to I2C bus binding as described in i2c.txt.
+
+Qualcomm Technologies Inc. GENI Serial Engine based UART Controller
+
+Required properties:
+- compatible:          Must be "qcom,geni-debug-uart".
+- reg:                         Must contain UART register location and length.
+- interrupts:          Must contain UART core interrupts.
+- clock-names:         Must contain "se".
+- clocks:              Serial engine core clock needed by the device.
+
+Qualcomm Technologies Inc. GENI Serial Engine based SPI Controller
+
+Required properties:
+- compatible:          Must contain "qcom,geni-spi".
+- reg:                 Must contain SPI register location and length.
+- interrupts:          Must contain SPI controller interrupts.
+- clock-names:         Must contain "se".
+- clocks:              Serial engine core clock needed by the device.
+- spi-max-frequency:   Specifies maximum SPI clock frequency, units - Hz.
+- #address-cells:      Must be <1> to define a chip select address on
+                       the SPI bus.
+- #size-cells:         Must be <0>.
+
+SPI slave nodes must be children of the SPI master node and conform to SPI bus
+binding as described in Documentation/devicetree/bindings/spi/spi-bus.txt.
+
+Example:
+       geniqup@8c0000 {
+               compatible = "qcom,geni-se-qup";
+               reg = <0x8c0000 0x6000>;
+               clock-names = "m-ahb", "s-ahb";
+               clocks = <&clock_gcc GCC_QUPV3_WRAP_0_M_AHB_CLK>,
+                       <&clock_gcc GCC_QUPV3_WRAP_0_S_AHB_CLK>;
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges;
+
+               i2c0: i2c@a94000 {
+                       compatible = "qcom,geni-i2c";
+                       reg = <0xa94000 0x4000>;
+                       interrupts = <GIC_SPI 358 IRQ_TYPE_LEVEL_HIGH>;
+                       clock-names = "se";
+                       clocks = <&clock_gcc GCC_QUPV3_WRAP0_S5_CLK>;
+                       pinctrl-names = "default", "sleep";
+                       pinctrl-0 = <&qup_1_i2c_5_active>;
+                       pinctrl-1 = <&qup_1_i2c_5_sleep>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+               };
+
+               uart0: serial@a88000 {
+                       compatible = "qcom,geni-debug-uart";
+                       reg = <0xa88000 0x7000>;
+                       interrupts = <GIC_SPI 355 IRQ_TYPE_LEVEL_HIGH>;
+                       clock-names = "se";
+                       clocks = <&clock_gcc GCC_QUPV3_WRAP0_S0_CLK>;
+                       pinctrl-names = "default", "sleep";
+                       pinctrl-0 = <&qup_1_uart_3_active>;
+                       pinctrl-1 = <&qup_1_uart_3_sleep>;
+               };
+
+               spi0: spi@a84000 {
+                       compatible = "qcom,geni-spi";
+                       reg = <0xa84000 0x4000>;
+                       interrupts = <GIC_SPI 354 IRQ_TYPE_LEVEL_HIGH>;
+                       clock-names = "se";
+                       clocks = <&clock_gcc GCC_QUPV3_WRAP0_S0_CLK>;
+                       pinctrl-names = "default", "sleep";
+                       pinctrl-0 = <&qup_1_spi_2_active>;
+                       pinctrl-1 = <&qup_1_spi_2_sleep>;
+                       spi-max-frequency = <19200000>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+               };
+       }
index a48049ccf6d0dd4cf332609d7a7b67326c58cf27..89e1cb9212f6899a51851ee7488bd6b73cc24db6 100644 (file)
@@ -22,6 +22,7 @@ resources.
                    "qcom,rpm-apq8084"
                    "qcom,rpm-msm8916"
                    "qcom,rpm-msm8974"
+                   "qcom,rpm-msm8998"
 
 - qcom,smd-channels:
        Usage: required
index ea1dc75ec9eaca099589114a3c13322c1d193625..234ae2256501b7511976ffe6272d34a5c327c769 100644 (file)
@@ -22,9 +22,15 @@ The edge is described by the following properties:
        Definition: should specify the IRQ used by the remote processor to
                    signal this processor about communication related updates
 
-- qcom,ipc:
+- mboxes:
        Usage: required
        Value type: <prop-encoded-array>
+       Definition: reference to the associated doorbell in APCS, as described
+                   in mailbox/mailbox.txt
+
+- qcom,ipc:
+       Usage: required, unless mboxes is specified
+       Value type: <prop-encoded-array>
        Definition: three entries specifying the outgoing ipc bit used for
                    signaling the remote processor:
                    - phandle to a syscon node representing the apcs registers
index 301d2a9bc1b8bb2ab0e213e6656b03691c2c71e8..5d49d0a2ff29df92201d62f1171eeaec5e5f9d22 100644 (file)
@@ -5,6 +5,10 @@ powered up/down by software based on different application scenes to save power.
 
 Required properties for power domain controller:
 - compatible: Should be one of the following.
+       "rockchip,px30-power-controller" - for PX30 SoCs.
+       "rockchip,rk3036-power-controller" - for RK3036 SoCs.
+       "rockchip,rk3128-power-controller" - for RK3128 SoCs.
+       "rockchip,rk3228-power-controller" - for RK3228 SoCs.
        "rockchip,rk3288-power-controller" - for RK3288 SoCs.
        "rockchip,rk3328-power-controller" - for RK3328 SoCs.
        "rockchip,rk3366-power-controller" - for RK3366 SoCs.
@@ -17,6 +21,10 @@ Required properties for power domain controller:
 
 Required properties for power domain sub nodes:
 - reg: index of the power domain, should use macros in:
+       "include/dt-bindings/power/px30-power.h" - for PX30 type power domain.
+       "include/dt-bindings/power/rk3036-power.h" - for RK3036 type power domain.
+       "include/dt-bindings/power/rk3128-power.h" - for RK3128 type power domain.
+       "include/dt-bindings/power/rk3228-power.h" - for RK3228 type power domain.
        "include/dt-bindings/power/rk3288-power.h" - for RK3288 type power domain.
        "include/dt-bindings/power/rk3328-power.h" - for RK3328 type power domain.
        "include/dt-bindings/power/rk3366-power.h" - for RK3366 type power domain.
@@ -93,6 +101,10 @@ Node of a device using power domains must have a power-domains property,
 containing a phandle to the power device node and an index specifying which
 power domain to use.
 The index should use macros in:
+       "include/dt-bindings/power/px30-power.h" - for px30 type power domain.
+       "include/dt-bindings/power/rk3036-power.h" - for rk3036 type power domain.
+       "include/dt-bindings/power/rk3128-power.h" - for rk3128 type power domain.
+       "include/dt-bindings/power/rk3128-power.h" - for rk3228 type power domain.
        "include/dt-bindings/power/rk3288-power.h" - for rk3288 type power domain.
        "include/dt-bindings/power/rk3328-power.h" - for rk3328 type power domain.
        "include/dt-bindings/power/rk3366-power.h" - for rk3366 type power domain.
index 4bda52042402600cfdab48c466e84d35d2f5bea4..58c341300552578018be27280517d36a24da35e5 100644 (file)
@@ -18,7 +18,7 @@ Required properties:
     See Documentation/devicetree/bindings/dma/stm32-dma.txt.
   - dma-names: Identifier for each DMA request line. Must be "tx" and "rx".
   - pinctrl-names: should contain only value "default"
-  - pinctrl-0: see Documentation/devicetree/bindings/pinctrl/pinctrl-stm32.txt
+  - pinctrl-0: see Documentation/devicetree/bindings/pinctrl/st,stm32-pinctrl.txt
 
 Optional properties:
   - resets: Reference to a reset controller asserting the reset controller
index f301cdf0b7e68942172253f077a93c8abb923b95..3a3fc506e43ae8ce727e03f14f0073a10008adfa 100644 (file)
@@ -37,7 +37,7 @@ SAI subnodes required properties:
        "tx": if sai sub-block is configured as playback DAI
        "rx": if sai sub-block is configured as capture DAI
   - pinctrl-names: should contain only value "default"
-  - pinctrl-0: see Documentation/devicetree/bindings/pinctrl/pinctrl-stm32.txt
+  - pinctrl-0: see Documentation/devicetree/bindings/pinctrl/st,stm32-pinctrl.txt
 
 SAI subnodes Optional properties:
   - st,sync: specify synchronization mode.
index fe54959ec95774407471885f89e9aacc2cb59b20..1bdc4709e4743c5599d790e09ff68295c05f9fa0 100644 (file)
@@ -9,7 +9,7 @@ Required properties:
 - clocks       : Must contain an entry for each name in clock-names
                    See ../clk/*
 - pinctrl-names        : Uses "default", can use "sleep" if provided
-                   See ../pinctrl/pinctrl-binding.txt
+                   See ../pinctrl/pinctrl-bindings.txt
 
 Optional properties:
 - cs-gpios     : List of GPIO chip selects
index b957acff57aa448071e0deda91a3e11eb78ca184..ad648d93d9613fd3c72d70496d47618d1ee18e0a 100644 (file)
@@ -12,7 +12,6 @@
               "samsung,exynos5420-tmu-ext-triminfo" for TMU channels 2, 3 and 4
                        Exynos5420 (Must pass triminfo base and triminfo clock)
                "samsung,exynos5433-tmu"
-              "samsung,exynos5440-tmu"
               "samsung,exynos7-tmu"
 - interrupt-parent : The phandle for the interrupt controller
 - reg : Address range of the thermal registers. For soc's which has multiple
@@ -68,18 +67,7 @@ Example 1):
                #thermal-sensor-cells = <0>;
        };
 
-Example 2):
-
-       tmuctrl_0: tmuctrl@160118 {
-               compatible = "samsung,exynos5440-tmu";
-               reg = <0x160118 0x230>, <0x160368 0x10>;
-               interrupts = <0 58 0>;
-               clocks = <&clock 21>;
-               clock-names = "tmu_apbif";
-               #thermal-sensor-cells = <0>;
-       };
-
-Example 3): (In case of Exynos5420 "with misplaced TRIMINFO register")
+Example 2): (In case of Exynos5420 "with misplaced TRIMINFO register")
        tmu_cpu2: tmu@10068000 {
                compatible = "samsung,exynos5420-tmu-ext-triminfo";
                reg = <0x10068000 0x100>, <0x1006c000 0x4>;
index 379eb763073e68d4a63b540c6ca3384a3b09f642..823e4176eef8f7399eff8e9a8ded841c54bd8d4c 100644 (file)
@@ -1,8 +1,13 @@
 * Temperature Monitor (TEMPMON) on Freescale i.MX SoCs
 
 Required properties:
-- compatible : "fsl,imx6q-tempmon" for i.MX6Q, "fsl,imx6sx-tempmon" for i.MX6SX.
-  i.MX6SX has two more IRQs than i.MX6Q, one is IRQ_LOW and the other is IRQ_PANIC,
+- compatible : must be one of following:
+  - "fsl,imx6q-tempmon" for i.MX6Q,
+  - "fsl,imx6sx-tempmon" for i.MX6SX,
+  - "fsl,imx7d-tempmon" for i.MX7S/D.
+- interrupts : the interrupt output of the controller:
+  i.MX6Q has one IRQ which will be triggered when temperature is higher than high threshold,
+  i.MX6SX and i.MX7S/D have two more IRQs than i.MX6Q, one is IRQ_LOW and the other is IRQ_PANIC,
   when temperature is below than low threshold, IRQ_LOW will be triggered, when temperature
   is higher than panic threshold, system will auto reboot by SRC module.
 - fsl,tempmon : phandle pointer to system controller that contains TEMPMON
index 0d73ea5e9c0c41da00f34d98fcb86ea5d27e200b..41d6a443ad660a1e969e765b19ec253e5f04530d 100644 (file)
@@ -12,6 +12,7 @@ Required properties:
   - "mediatek,mt8173-thermal" : For MT8173 family of SoCs
   - "mediatek,mt2701-thermal" : For MT2701 family of SoCs
   - "mediatek,mt2712-thermal" : For MT2712 family of SoCs
+  - "mediatek,mt7622-thermal" : For MT7622 SoC
 - reg: Address range of the thermal controller
 - interrupts: IRQ for the thermal controller
 - clocks, clock-names: Clocks needed for the thermal controller. required
index 292ed89d900bbc6d19d6357c799b083fe0fcf9a2..06195e8f35e287b870920ecb4f4dfed799625231 100644 (file)
@@ -8,6 +8,7 @@ Required properties:
 
 - reg: Address range of the thermal registers
 - #thermal-sensor-cells : Should be 1. See ./thermal.txt for a description.
+- #qcom,sensors: Number of sensors in tsens block
 - Refer to Documentation/devicetree/bindings/nvmem/nvmem.txt to know how to specify
 nvmem cells
 
index 39e7d4e61a63c038e003d739c5602f2cc97a55e7..cfa154bb0fa7c7ec5977de4c38c92a7ebd596e7e 100644 (file)
@@ -9,6 +9,7 @@ Required properties:
                          Examples with soctypes are:
                            - "renesas,r8a7795-thermal" (R-Car H3)
                            - "renesas,r8a7796-thermal" (R-Car M3-W)
+                           - "renesas,r8a77965-thermal" (R-Car M3-N)
 - reg                  : Address ranges of the thermal registers. Each sensor
                          needs one address range. Sorting must be done in
                          increasing order according to datasheet, i.e.
@@ -18,7 +19,7 @@ Required properties:
 
 Optional properties:
 
-- interrupts           : interrupts routed to the TSC (3 for H3 and M3-W)
+- interrupts           : interrupts routed to the TSC (3 for H3, M3-W and M3-N)
 - power-domain         : Must contain a reference to the power domain. This
                          property is mandatory if the thermal sensor instance
                          is part of a controllable power domain.
index 349e635f2d87e0a8421bcaaea1ef18e12b73dff2..67c563f1b4c42131157e8428300c5a12d39bbc2f 100644 (file)
@@ -3,7 +3,8 @@
 Required properties:
 - compatible           : "renesas,thermal-<soctype>",
                           "renesas,rcar-gen2-thermal" (with thermal-zone) or
-                          "renesas,rcar-thermal" (without thermal-zone) as fallback.
+                          "renesas,rcar-thermal" (without thermal-zone) as
+                           fallback except R-Car D3.
                          Examples with soctypes are:
                            - "renesas,thermal-r8a73a4" (R-Mobile APE6)
                            - "renesas,thermal-r8a7743" (RZ/G1M)
@@ -12,13 +13,15 @@ Required properties:
                            - "renesas,thermal-r8a7791" (R-Car M2-W)
                            - "renesas,thermal-r8a7792" (R-Car V2H)
                            - "renesas,thermal-r8a7793" (R-Car M2-N)
+                           - "renesas,thermal-r8a77995" (R-Car D3)
 - reg                  : Address range of the thermal registers.
                          The 1st reg will be recognized as common register
                          if it has "interrupts".
 
 Option properties:
 
-- interrupts           : use interrupt
+- interrupts           : If present should contain 3 interrupts for
+                          R-Car D3 or 1 interrupt otherwise.
 
 Example (non interrupt support):
 
index 686c0b42ed3f6c7debe89e2a25d129226bd262b8..ceb92a95727a8aadb79dbfe9e222ced65449d6c7 100644 (file)
@@ -8,6 +8,7 @@ Required properties:
 - compatible :
   - "socionext,uniphier-pxs2-thermal" : For UniPhier PXs2 SoC
   - "socionext,uniphier-ld20-thermal" : For UniPhier LD20 SoC
+  - "socionext,uniphier-pxs3-thermal" : For UniPhier PXs3 SoC
 - interrupts : IRQ for the temperature alarm
 - #thermal-sensor-cells : Should be 0. See ./thermal.txt for details.
 
index d740989eb56981cbce66e2cd6930481d452f1f97..b40add2d9bb485ecd3ea395669da1e43e9e31a1e 100644 (file)
@@ -22,6 +22,10 @@ Required Properties:
 
     - "renesas,r8a73a4-cmt0" for the 32-bit CMT0 device included in r8a73a4.
     - "renesas,r8a73a4-cmt1" for the 48-bit CMT1 device included in r8a73a4.
+    - "renesas,r8a7743-cmt0" for the 32-bit CMT0 device included in r8a7743.
+    - "renesas,r8a7743-cmt1" for the 48-bit CMT1 device included in r8a7743.
+    - "renesas,r8a7745-cmt0" for the 32-bit CMT0 device included in r8a7745.
+    - "renesas,r8a7745-cmt1" for the 48-bit CMT1 device included in r8a7745.
     - "renesas,r8a7790-cmt0" for the 32-bit CMT0 device included in r8a7790.
     - "renesas,r8a7790-cmt1" for the 48-bit CMT1 device included in r8a7790.
     - "renesas,r8a7791-cmt0" for the 32-bit CMT0 device included in r8a7791.
@@ -31,10 +35,12 @@ Required Properties:
     - "renesas,r8a7794-cmt0" for the 32-bit CMT0 device included in r8a7794.
     - "renesas,r8a7794-cmt1" for the 48-bit CMT1 device included in r8a7794.
 
-    - "renesas,rcar-gen2-cmt0" for 32-bit CMT0 devices included in R-Car Gen2.
-    - "renesas,rcar-gen2-cmt1" for 48-bit CMT1 devices included in R-Car Gen2.
-               These are fallbacks for r8a73a4 and all the R-Car Gen2
-               entries listed above.
+    - "renesas,rcar-gen2-cmt0" for 32-bit CMT0 devices included in R-Car Gen2
+               and RZ/G1.
+    - "renesas,rcar-gen2-cmt1" for 48-bit CMT1 devices included in R-Car Gen2
+               and RZ/G1.
+               These are fallbacks for r8a73a4, R-Car Gen2 and RZ/G1 entries
+               listed above.
 
   - reg: base address and length of the registers block for the timer module.
   - interrupts: interrupt-specifier for the timer, one per channel.
index 50a31536e975ef915defb7fd35db914f3b0d6cf6..252a05c5d976d56b039bcf04069ec9c6e9595dea 100644 (file)
@@ -16,7 +16,7 @@ A child node must exist to represent the core DWC3 IP block. The name of
 the node is not important. The content of the node is defined in dwc3.txt.
 
 Phy documentation is provided in the following places:
-Documentation/devicetree/bindings/phy/rockchip,dwc3-usb-phy.txt
+Documentation/devicetree/bindings/phy/qcom-dwc3-usb-phy.txt
 
 Example device nodes:
 
index 4b38f3373f4322501a99a67d043cf7f9da3f1acb..7cad066191eeb8e6c9711cb81fd50283362fcf4d 100644 (file)
@@ -58,6 +58,7 @@ bosch Bosch Sensortec GmbH
 boundary       Boundary Devices Inc.
 brcm   Broadcom Corporation
 buffalo        Buffalo, Inc.
+bticino Bticino International
 calxeda        Calxeda
 capella        Capella Microsystems, Inc
 cascoda        Cascoda, Ltd.
@@ -285,6 +286,7 @@ pine64      Pine64
 pixcir  PIXCIR MICROELECTRONICS Co., Ltd
 plathome       Plat'Home Co., Ltd.
 plda   PLDA
+portwell       Portwell Inc.
 poslab Poslab Technology Co., Ltd.
 powervr        PowerVR (deprecated, use img)
 probox2        PROBOX2 (by W2COMP Co., Ltd.)
index cb44918f01a8b61b9ebf7444d372cf74c4a6a075..ce1cb72d53452df3ab226f3d68daaa5ae91663b2 100644 (file)
@@ -3,10 +3,15 @@ Ingenic Watchdog Timer (WDT) Controller for JZ4740 & JZ4780
 Required properties:
 compatible: "ingenic,jz4740-watchdog" or "ingenic,jz4780-watchdog"
 reg: Register address and length for watchdog registers
+clocks: phandle to the RTC clock
+clock-names: should be "rtc"
 
 Example:
 
 watchdog: jz4740-watchdog@10002000 {
        compatible = "ingenic,jz4740-watchdog";
-       reg = <0x10002000 0x100>;
+       reg = <0x10002000 0x10>;
+
+       clocks = <&cgu JZ4740_CLK_RTC>;
+       clock-names = "rtc";
 };
index 74b2f03c151553f5ce78fd89373f07b09549b2c8..f24d802b8056f6c6a726a758561ef471cbec4933 100644 (file)
@@ -1,18 +1,27 @@
 Renesas Watchdog Timer (WDT) Controller
 
 Required properties:
-- compatible : Should be "renesas,<soctype>-wdt", and
-              "renesas,rcar-gen3-wdt" or "renesas,rza-wdt" as fallback.
+ - compatible : Must be "renesas,<soctype>-wdt", followed by a generic
+               fallback compatible string when compatible with the generic
+               version.
               Examples with soctypes are:
-                - "renesas,r7s72100-wdt" (RZ/A1)
+                - "renesas,r8a7743-wdt" (RZ/G1M)
+                - "renesas,r8a7745-wdt" (RZ/G1E)
+                - "renesas,r8a7790-wdt" (R-Car H2)
+                - "renesas,r8a7791-wdt" (R-Car M2-W)
+                - "renesas,r8a7792-wdt" (R-Car V2H)
+                - "renesas,r8a7793-wdt" (R-Car M2-N)
+                - "renesas,r8a7794-wdt" (R-Car E2)
                 - "renesas,r8a7795-wdt" (R-Car H3)
                 - "renesas,r8a7796-wdt" (R-Car M3-W)
+                - "renesas,r8a77965-wdt" (R-Car M3-N)
                 - "renesas,r8a77970-wdt" (R-Car V3M)
                 - "renesas,r8a77995-wdt" (R-Car D3)
-
-  When compatible with the generic version, nodes must list the SoC-specific
-  version corresponding to the platform first, followed by the generic
-  version.
+                - "renesas,r7s72100-wdt" (RZ/A1)
+               The generic compatible string must be:
+                - "renesas,rza-wdt" for RZ/A
+                - "renesas,rcar-gen2-wdt" for R-Car Gen2 and RZ/G
+                - "renesas,rcar-gen3-wdt" for R-Car Gen3
 
 - reg : Should contain WDT registers location and length
 - clocks : the clock feeding the watchdog timer.
index c71a50d85b50170dcfbb0323f24c29a0494d1648..aa03f389d41d6a794f16607ee076f248848da17a 100644 (file)
@@ -57,7 +57,7 @@ device that displays digits), an additional index argument can be specified::
                                          enum gpiod_flags flags)
 
 For a more detailed description of the con_id parameter in the DeviceTree case
-see Documentation/gpio/board.txt
+see Documentation/driver-api/gpio/board.rst
 
 The flags parameter is used to optionally specify a direction and initial value
 for the GPIO. Values can be:
index 74b89a9c8b3a312ba0fa110f646bcb9f6c03f0ce..954ac1c95553ef095040d3c862767aaf021cf7b5 100644 (file)
@@ -1,6 +1,6 @@
 #
 # Feature name:          stackprotector
-#         Kconfig:       HAVE_CC_STACKPROTECTOR
+#         Kconfig:       HAVE_STACKPROTECTOR
 #         description:   arch supports compiler driven stack overflow protection
 #
     -----------------------
index d7f011ddc1500cdf8e705430c90ed60deb7a2ecc..8bf62240e10d35a7dc99fac14f86afeb14313490 100644 (file)
@@ -105,15 +105,13 @@ Mount Options
        address its connection to the monitor originates from.
 
   wsize=X
-       Specify the maximum write size in bytes.  By default there is no
-       maximum.  Ceph will normally size writes based on the file stripe
-       size.
+       Specify the maximum write size in bytes.  Default: 16 MB.
 
   rsize=X
-       Specify the maximum read size in bytes.  Default: 64 MB.
+       Specify the maximum read size in bytes.  Default: 16 MB.
 
   rasize=X
-       Specify the maximum readahead.  Default: 8 MB.
+       Specify the maximum readahead size in bytes.  Default: 8 MB.
 
   mount_timeout=X
        Specify the timeout value for mount (in seconds), in the case
index 12a147c9f87f208bc018419d50b4306ba907a017..69f8de99573974749263a33d75904ad5d37971de 100644 (file)
@@ -182,13 +182,15 @@ whint_mode=%s          Control which write hints are passed down to block
                        passes down hints with its policy.
 alloc_mode=%s          Adjust block allocation policy, which supports "reuse"
                        and "default".
-fsync_mode=%s          Control the policy of fsync. Currently supports "posix"
-                       and "strict". In "posix" mode, which is default, fsync
-                       will follow POSIX semantics and does a light operation
-                       to improve the filesystem performance. In "strict" mode,
-                       fsync will be heavy and behaves in line with xfs, ext4
-                       and btrfs, where xfstest generic/342 will pass, but the
-                       performance will regress.
+fsync_mode=%s          Control the policy of fsync. Currently supports "posix",
+                       "strict", and "nobarrier". In "posix" mode, which is
+                       default, fsync will follow POSIX semantics and does a
+                       light operation to improve the filesystem performance.
+                       In "strict" mode, fsync will be heavy and behaves in line
+                       with xfs, ext4 and btrfs, where xfstest generic/342 will
+                       pass, but the performance will regress. "nobarrier" is
+                       based on "posix", but doesn't issue flush command for
+                       non-atomic files likewise "nobarrier" mount option.
 test_dummy_encryption  Enable dummy encryption, which provides a fake fscrypt
                        context. The fake fscrypt context is used by xfstests.
 
index cfd31d94c8727251179a0c2afcc4f9b2a4580156..72d16f08e431c674c62738641d7c28926d6331cb 100644 (file)
@@ -53,7 +53,7 @@ bus supply voltage.
 
 The shunt value in micro-ohms can be set via platform data or device tree at
 compile-time or via the shunt_resistor attribute in sysfs at run-time. Please
-refer to the Documentation/devicetree/bindings/i2c/ina2xx.txt for bindings
+refer to the Documentation/devicetree/bindings/hwmon/ina2xx.txt for bindings
 if the device tree is used.
 
 Additionally ina226 supports update_interval attribute as described in
index 4e46c440b38d9a07046f43323cc011fcffa10838..925904aa9b57c787c750e83cdc3975cc1862e5d8 100644 (file)
@@ -20,6 +20,10 @@ The next transaction types are supported:
  - Write Byte/Block.
 
 Registers:
+CPBLTY         0x0 - capability reg.
+                       Bits [6:5] - transaction length. b01 - 72B is supported,
+                       36B in other case.
+                       Bit 7 - SMBus block read support.
 CTRL           0x1 - control reg.
                        Resets all the registers.
 HALF_CYC       0x4 - cycle reg.
index 9e1dfe7553ad8ee39b5ff69d81f4ca4b672c554a..4e713f4cdb2f9cfc23a206918937c964b0a70113 100644 (file)
@@ -18,7 +18,7 @@ Usage
 i2c-ocores uses the platform bus, so you need to provide a struct
 platform_device with the base address and interrupt number. The
 dev.platform_data of the device should also point to a struct
-ocores_i2c_platform_data (see linux/i2c-ocores.h) describing the
+ocores_i2c_platform_data (see linux/platform_data/i2c-ocores.h) describing the
 distance between registers and the input clock speed.
 There is also a possibility to attach a list of i2c_board_info which
 the i2c-ocores driver will add to the bus upon creation.
index 7a8d7d261632e6d68a738bbb6395c6054eed44b8..893ecdfe6e43c3e297f725237f6a3fe8b93e7d61 100644 (file)
@@ -30,12 +30,12 @@ i2c-mux-gpio uses the platform bus, so you need to provide a struct
 platform_device with the platform_data pointing to a struct
 i2c_mux_gpio_platform_data with the I2C adapter number of the master
 bus, the number of bus segments to create and the GPIO pins used
-to control it. See include/linux/i2c-mux-gpio.h for details.
+to control it. See include/linux/platform_data/i2c-mux-gpio.h for details.
 
 E.G. something like this for a MUX providing 4 bus segments
 controlled through 3 GPIO pins:
 
-#include <linux/i2c-mux-gpio.h>
+#include <linux/platform_data/i2c-mux-gpio.h>
 #include <linux/platform_device.h>
 
 static const unsigned myboard_gpiomux_gpios[] = {
index 0e966e8f9ec72f20df4c9b5b8db737e1d3ca50a0..3534a84d206caf324423a9422eb985b48c97813b 100644 (file)
@@ -473,6 +473,24 @@ config option to 'y' no matter the dependencies.
 The dependencies are moved to the symbol GENERIC_IOMAP and we avoid the
 situation where select forces a symbol equals to 'y'.
 
+Adding features that need compiler support
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+There are several features that need compiler support. The recommended way
+to describe the dependency on the compiler feature is to use "depends on"
+followed by a test macro.
+
+config STACKPROTECTOR
+       bool "Stack Protector buffer overflow detection"
+       depends on $(cc-option,-fstack-protector)
+       ...
+
+If you need to expose a compiler capability to makefiles and/or C source files,
+CC_HAS_ is the recommended prefix for the config option.
+
+config CC_HAS_STACKPROTECTOR_NONE
+       def_bool $(cc-option,-fno-stack-protector)
+
 Build as module only
 ~~~~~~~~~~~~~~~~~~~~
 To restrict a component build to module-only, qualify its config symbol
index 22208bf2386d1dac06b04f4b8c064286885f9d55..cb3b0de83fc6db83d9a5739bdaa0eb199ae5250d 100644 (file)
@@ -724,8 +724,8 @@ migrate your tool to one of the following options:
 
   See following documents:
 
-  - Documentation/trace/kprobetrace.txt
-  - Documentation/trace/events.txt
+  - Documentation/trace/kprobetrace.rst
+  - Documentation/trace/events.rst
   - tools/perf/Documentation/perf-probe.txt
 
 
index 00b6dfed573cf595594714df451621eb2f991893..6cced88de6da08134d35c4a3678a3ed119736958 100644 (file)
@@ -540,8 +540,10 @@ Events that are propagated by the driver to userspace:
 0x6021         ALARM: a sensor is too hot
 0x6022         ALARM: a sensor is extremely hot
 0x6030         System thermal table changed
+0x6032         Thermal Control command set completion  (DYTC, Windows)
 0x6040         Nvidia Optimus/AC adapter related (TO BE VERIFIED)
 0x60C0         X1 Yoga 2016, Tablet mode status changed
+0x60F0         Thermal Transformation changed (GMTS, Windows)
 
 Battery nearly empty alarms are a last resort attempt to get the
 operating system to hibernate or shutdown cleanly (0x2313), or shutdown
index a19db3458b56b7aedfc09004166a46606ab7fe51..22b271de030474c1dbbcadd7cfdef88b95a5766e 100644 (file)
@@ -41,7 +41,7 @@ named ``char-misc-next``, you would be using the following command::
 
 that will create a signed tag called ``char-misc-4.15-rc1`` based on the
 last commit in the ``char-misc-next`` branch, and sign it with your gpg key
-(see :ref:`Documentation/maintainer/configure_git.rst <configuregit>`).
+(see :ref:`Documentation/maintainer/configure-git.rst <configuregit>`).
 
 Linus will only accept pull requests based on a signed tag. Other
 maintainers may differ.
index d23c51abf8c6d3806c7209fd8e620a69cb75a608..2fd0b51a8c529da1f6e0f18cfc4da4f9bbd3b40e 100644 (file)
@@ -164,7 +164,7 @@ The Linux network devices (by default) just can handle the
 transmission and reception of media dependent frames. Due to the
 arbitration on the CAN bus the transmission of a low prio CAN-ID
 may be delayed by the reception of a high prio CAN frame. To
-reflect the correct [*]_ traffic on the node the loopback of the sent
+reflect the correct [#f1]_ traffic on the node the loopback of the sent
 data has to be performed right after a successful transmission. If
 the CAN network interface is not capable of performing the loopback for
 some reason the SocketCAN core can do this task as a fallback solution.
@@ -175,7 +175,7 @@ networking behaviour for CAN applications. Due to some requests from
 the RT-SocketCAN group the loopback optionally may be disabled for each
 separate socket. See sockopts from the CAN RAW sockets in :ref:`socketcan-raw-sockets`.
 
-.. [*] you really like to have this when you're running analyser
+.. [#f1] you really like to have this when you're running analyser
        tools like 'candump' or 'cansniffer' on the (same) node.
 
 
diff --git a/Documentation/riscv/pmu.txt b/Documentation/riscv/pmu.txt
new file mode 100644 (file)
index 0000000..b29f03a
--- /dev/null
@@ -0,0 +1,249 @@
+Supporting PMUs on RISC-V platforms
+==========================================
+Alan Kao <alankao@andestech.com>, Mar 2018
+
+Introduction
+------------
+
+As of this writing, perf_event-related features mentioned in The RISC-V ISA
+Privileged Version 1.10 are as follows:
+(please check the manual for more details)
+
+* [m|s]counteren
+* mcycle[h], cycle[h]
+* minstret[h], instret[h]
+* mhpeventx, mhpcounterx[h]
+
+With such function set only, porting perf would require a lot of work, due to
+the lack of the following general architectural performance monitoring features:
+
+* Enabling/Disabling counters
+  Counters are just free-running all the time in our case.
+* Interrupt caused by counter overflow
+  No such feature in the spec.
+* Interrupt indicator
+  It is not possible to have many interrupt ports for all counters, so an
+  interrupt indicator is required for software to tell which counter has
+  just overflowed.
+* Writing to counters
+  There will be an SBI to support this since the kernel cannot modify the
+  counters [1].  Alternatively, some vendor considers to implement
+  hardware-extension for M-S-U model machines to write counters directly.
+
+This document aims to provide developers a quick guide on supporting their
+PMUs in the kernel.  The following sections briefly explain perf' mechanism
+and todos.
+
+You may check previous discussions here [1][2].  Also, it might be helpful
+to check the appendix for related kernel structures.
+
+
+1. Initialization
+-----------------
+
+*riscv_pmu* is a global pointer of type *struct riscv_pmu*, which contains
+various methods according to perf's internal convention and PMU-specific
+parameters.  One should declare such instance to represent the PMU.  By default,
+*riscv_pmu* points to a constant structure *riscv_base_pmu*, which has very
+basic support to a baseline QEMU model.
+
+Then he/she can either assign the instance's pointer to *riscv_pmu* so that
+the minimal and already-implemented logic can be leveraged, or invent his/her
+own *riscv_init_platform_pmu* implementation.
+
+In other words, existing sources of *riscv_base_pmu* merely provide a
+reference implementation.  Developers can flexibly decide how many parts they
+can leverage, and in the most extreme case, they can customize every function
+according to their needs.
+
+
+2. Event Initialization
+-----------------------
+
+When a user launches a perf command to monitor some events, it is first
+interpreted by the userspace perf tool into multiple *perf_event_open*
+system calls, and then each of them calls to the body of *event_init*
+member function that was assigned in the previous step.  In *riscv_base_pmu*'s
+case, it is *riscv_event_init*.
+
+The main purpose of this function is to translate the event provided by user
+into bitmap, so that HW-related control registers or counters can directly be
+manipulated.  The translation is based on the mappings and methods provided in
+*riscv_pmu*.
+
+Note that some features can be done in this stage as well:
+
+(1) interrupt setting, which is stated in the next section;
+(2) privilege level setting (user space only, kernel space only, both);
+(3) destructor setting.  Normally it is sufficient to apply *riscv_destroy_event*;
+(4) tweaks for non-sampling events, which will be utilized by functions such as
+*perf_adjust_period*, usually something like the follows:
+
+if (!is_sampling_event(event)) {
+        hwc->sample_period = x86_pmu.max_period;
+        hwc->last_period = hwc->sample_period;
+        local64_set(&hwc->period_left, hwc->sample_period);
+}
+
+In the case of *riscv_base_pmu*, only (3) is provided for now.
+
+
+3. Interrupt
+------------
+
+3.1. Interrupt Initialization
+
+This often occurs at the beginning of the *event_init* method. In common
+practice, this should be a code segment like
+
+int x86_reserve_hardware(void)
+{
+        int err = 0;
+
+        if (!atomic_inc_not_zero(&pmc_refcount)) {
+                mutex_lock(&pmc_reserve_mutex);
+                if (atomic_read(&pmc_refcount) == 0) {
+                        if (!reserve_pmc_hardware())
+                                err = -EBUSY;
+                        else
+                                reserve_ds_buffers();
+                }
+                if (!err)
+                        atomic_inc(&pmc_refcount);
+                mutex_unlock(&pmc_reserve_mutex);
+        }
+
+        return err;
+}
+
+And the magic is in *reserve_pmc_hardware*, which usually does atomic
+operations to make implemented IRQ accessible from some global function pointer.
+*release_pmc_hardware* serves the opposite purpose, and it is used in event
+destructors mentioned in previous section.
+
+(Note: From the implementations in all the architectures, the *reserve/release*
+pair are always IRQ settings, so the *pmc_hardware* seems somehow misleading.
+It does NOT deal with the binding between an event and a physical counter,
+which will be introduced in the next section.)
+
+3.2. IRQ Structure
+
+Basically, a IRQ runs the following pseudo code:
+
+for each hardware counter that triggered this overflow
+
+    get the event of this counter
+
+    // following two steps are defined as *read()*,
+    // check the section Reading/Writing Counters for details.
+    count the delta value since previous interrupt
+    update the event->count (# event occurs) by adding delta, and
+               event->hw.period_left by subtracting delta
+
+    if the event overflows
+        sample data
+        set the counter appropriately for the next overflow
+
+        if the event overflows again
+            too frequently, throttle this event
+        fi
+    fi
+
+end for
+
+However as of this writing, none of the RISC-V implementations have designed an
+interrupt for perf, so the details are to be completed in the future.
+
+4. Reading/Writing Counters
+---------------------------
+
+They seem symmetric but perf treats them quite differently.  For reading, there
+is a *read* interface in *struct pmu*, but it serves more than just reading.
+According to the context, the *read* function not only reads the content of the
+counter (event->count), but also updates the left period to the next interrupt
+(event->hw.period_left).
+
+But the core of perf does not need direct write to counters.  Writing counters
+is hidden behind the abstraction of 1) *pmu->start*, literally start counting so one
+has to set the counter to a good value for the next interrupt; 2) inside the IRQ
+it should set the counter to the same resonable value.
+
+Reading is not a problem in RISC-V but writing would need some effort, since
+counters are not allowed to be written by S-mode.
+
+
+5. add()/del()/start()/stop()
+-----------------------------
+
+Basic idea: add()/del() adds/deletes events to/from a PMU, and start()/stop()
+starts/stop the counter of some event in the PMU.  All of them take the same
+arguments: *struct perf_event *event* and *int flag*.
+
+Consider perf as a state machine, then you will find that these functions serve
+as the state transition process between those states.
+Three states (event->hw.state) are defined:
+
+* PERF_HES_STOPPED:    the counter is stopped
+* PERF_HES_UPTODATE:   the event->count is up-to-date
+* PERF_HES_ARCH:       arch-dependent usage ... we don't need this for now
+
+A normal flow of these state transitions are as follows:
+
+* A user launches a perf event, resulting in calling to *event_init*.
+* When being context-switched in, *add* is called by the perf core, with a flag
+  PERF_EF_START, which means that the event should be started after it is added.
+  At this stage, a general event is bound to a physical counter, if any.
+  The state changes to PERF_HES_STOPPED and PERF_HES_UPTODATE, because it is now
+  stopped, and the (software) event count does not need updating.
+** *start* is then called, and the counter is enabled.
+   With flag PERF_EF_RELOAD, it writes an appropriate value to the counter (check
+   previous section for detail).
+   Nothing is written if the flag does not contain PERF_EF_RELOAD.
+   The state now is reset to none, because it is neither stopped nor updated
+   (the counting already started)
+* When being context-switched out, *del* is called.  It then checks out all the
+  events in the PMU and calls *stop* to update their counts.
+** *stop* is called by *del*
+   and the perf core with flag PERF_EF_UPDATE, and it often shares the same
+   subroutine as *read* with the same logic.
+   The state changes to PERF_HES_STOPPED and PERF_HES_UPTODATE, again.
+
+** Life cycle of these two pairs: *add* and *del* are called repeatedly as
+  tasks switch in-and-out; *start* and *stop* is also called when the perf core
+  needs a quick stop-and-start, for instance, when the interrupt period is being
+  adjusted.
+
+Current implementation is sufficient for now and can be easily extended to
+features in the future.
+
+A. Related Structures
+---------------------
+
+* struct pmu: include/linux/perf_event.h
+* struct riscv_pmu: arch/riscv/include/asm/perf_event.h
+
+  Both structures are designed to be read-only.
+
+  *struct pmu* defines some function pointer interfaces, and most of them take
+*struct perf_event* as a main argument, dealing with perf events according to
+perf's internal state machine (check kernel/events/core.c for details).
+
+  *struct riscv_pmu* defines PMU-specific parameters.  The naming follows the
+convention of all other architectures.
+
+* struct perf_event: include/linux/perf_event.h
+* struct hw_perf_event
+
+  The generic structure that represents perf events, and the hardware-related
+details.
+
+* struct riscv_hw_events: arch/riscv/include/asm/perf_event.h
+
+  The structure that holds the status of events, has two fixed members:
+the number of events and the array of the events.
+
+References
+----------
+
+[1] https://github.com/riscv/riscv-linux/pull/124
+[2] https://groups.google.com/a/groups.riscv.org/forum/#!topic/sw-dev/f19TmCNP6yA
index 0f53826c78b9f6449cbd3ccf620fc34712ac24c9..e1ca698e000639720e9c718ec28613177cad189e 100644 (file)
@@ -156,7 +156,7 @@ The classic stack buffer overflow involves writing past the expected end
 of a variable stored on the stack, ultimately writing a controlled value
 to the stack frame's stored return address. The most widely used defense
 is the presence of a stack canary between the stack variables and the
-return address (``CONFIG_CC_STACKPROTECTOR``), which is verified just before
+return address (``CONFIG_STACKPROTECTOR``), which is verified just before
 the function returns. Other defenses include things like shadow stacks.
 
 Stack depth overflow
index 25feb0d35e7abc7f6ff7797faf02e9e79321e644..2019a55f6b182a4a5306b204b096739bfae143bb 100755 (executable)
@@ -53,8 +53,6 @@ from docutils.utils import SystemMessagePropagation
 # common globals
 # ==============================================================================
 
-# The version numbering follows numbering of the specification
-# (Documentation/books/kernel-doc-HOWTO).
 __version__  = '1.0'
 
 PY3 = sys.version_info[0] == 3
index 1d74ad0202b6525c4ce4b257d0db1ba466226b0d..efbc832146e77f8e2f1a4a107364e40ca082569f 100644 (file)
@@ -426,5 +426,5 @@ root@genericarmv8:~#
 Details on how to use the generic STM API can be found here [2].
 
 [1]. Documentation/ABI/testing/sysfs-bus-coresight-devices-stm
-[2]. Documentation/trace/stm.txt
+[2]. Documentation/trace/stm.rst
 [3]. https://github.com/Linaro/perf-opencsd
index 1afae55dc55caceceac0a5c6c0a8b6a1abb748d4..696dc69b8158bf6c15484c44b26d3eaf5e6c3a51 100644 (file)
@@ -8,7 +8,7 @@ Event Tracing
 1. Introduction
 ===============
 
-Tracepoints (see Documentation/trace/tracepoints.txt) can be used
+Tracepoints (see Documentation/trace/tracepoints.rst) can be used
 without creating custom kernel modules to register probe functions
 using the event tracing infrastructure.
 
index 00283b6dd101dbc210055b20cf360d9a959eb480..1fbc69894eed0b552dd04dd0037e810ba499331f 100644 (file)
@@ -199,7 +199,7 @@ If @buf is NULL and reset is set, all functions will be enabled for tracing.
 The @buf can also be a glob expression to enable all functions that
 match a specific pattern.
 
-See Filter Commands in :file:`Documentation/trace/ftrace.txt`.
+See Filter Commands in :file:`Documentation/trace/ftrace.rst`.
 
 To just trace the schedule function:
 
index b13771cb12c1ba7adc3b2a8b086068de351ff98a..e73bcf9cb5f31cc756521702bbc15fd142e09c71 100644 (file)
@@ -7,7 +7,7 @@
 
   Histogram triggers are special event triggers that can be used to
   aggregate trace event data into histograms.  For information on
-  trace events and event triggers, see Documentation/trace/events.txt.
+  trace events and event triggers, see Documentation/trace/events.rst.
 
 
 2. Histogram Trigger Command
index 990f132651785b54996fdd5b835da479b78a2694..19e2d633f3c71f453fd0d2c1d9905d939a6326d6 100644 (file)
@@ -38,7 +38,7 @@ description is at Documentation/ABI/testing/sysfs-bus-intel_th-devices-gth.
 
 STH registers an stm class device, through which it provides interface
 to userspace and kernelspace software trace sources. See
-Documentation/trace/stm.txt for more information on that.
+Documentation/trace/stm.rst for more information on that.
 
 MSU can be configured to collect trace data into a system memory
 buffer, which can later on be read from its device nodes via read() or
index a4d3ff2e5efb616a9bc91fd814b4bb193961217d..716326b9f152516ad5af0c36f23444f1b6470667 100644 (file)
@@ -6,7 +6,7 @@ Notes on Analysing Behaviour Using Events and Tracepoints
 1. Introduction
 ===============
 
-Tracepoints (see Documentation/trace/tracepoints.txt) can be used without
+Tracepoints (see Documentation/trace/tracepoints.rst) can be used without
 creating custom kernel modules to register probe functions using the event
 tracing infrastructure.
 
@@ -55,7 +55,7 @@ simple case of::
 3.1 System-Wide Event Enabling
 ------------------------------
 
-See Documentation/trace/events.txt for a proper description on how events
+See Documentation/trace/events.rst for a proper description on how events
 can be enabled system-wide. A short example of enabling all events related
 to page allocation would look something like::
 
@@ -112,7 +112,7 @@ at that point.
 3.4 Local Event Enabling
 ------------------------
 
-Documentation/trace/ftrace.txt describes how to enable events on a per-thread
+Documentation/trace/ftrace.rst describes how to enable events on a per-thread
 basis using set_ftrace_pid.
 
 3.5 Local Event Enablement with PCL
@@ -137,7 +137,7 @@ basis using PCL such as follows.
 4. Event Filtering
 ==================
 
-Documentation/trace/ftrace.txt covers in-depth how to filter events in
+Documentation/trace/ftrace.rst covers in-depth how to filter events in
 ftrace.  Obviously using grep and awk of trace_pipe is an option as well
 as any script reading trace_pipe.
 
index 8d7ed0cbbf5fb76cfdaa3c228a6c5f60069732c0..f3116381c26bd86399f11cce0e8ab1b39eed760b 100644 (file)
@@ -1,5 +1,5 @@
 NOTE:
-This is a version of Documentation/HOWTO translated into Japanese.
+This is a version of Documentation/process/howto.rst translated into Japanese.
 This document is maintained by Tsugikazu Shibata <tshibata@ab.jp.nec.com>
 If you find any difference between this document and the original file or
 a problem with the translation, please contact the maintainer of this file.
@@ -109,7 +109,7 @@ linux-api@vger.kernel.org に送ることを勧めます。
     ています。 カーネルに関して初めての人はここからスタートすると良い
     でしょう。
 
-  :ref:`Documentation/Process/changes.rst <changes>`
+  :ref:`Documentation/process/changes.rst <changes>`
     このファイルはカーネルをうまく生成(訳注 build )し、走らせるのに最
     小限のレベルで必要な数々のソフトウェアパッケージの一覧を示してい
     ます。
index 624654bdcd8ad3b54362be65d60f1d9f7aa121b7..a8197e072599a9bdded162198a62810cb8b9ff2c 100644 (file)
@@ -160,7 +160,7 @@ mtk.manpages@gmail.com의 메인테이너에게 보낼 것을 권장한다.
     독특한 행동에 관하여 흔히 있는 오해들과 혼란들을 해소하고 있기
     때문이다.
 
-  :ref:`Documentation/process/stable_kernel_rules.rst <stable_kernel_rules>`
+  :ref:`Documentation/process/stable-kernel-rules.rst <stable_kernel_rules>`
     이 문서는 안정적인 커널 배포가 이루어지는 규칙을 설명하고 있으며
     여러분들이 이러한 배포들 중 하나에 변경을 하길 원한다면
     무엇을 해야 하는지를 설명한다.
index 929385e4b1941b6c063d0eb96d5a389c3fa787d3..15e73562f710c9002a154b4d6864ceb8d41b8b96 100644 (file)
@@ -107,7 +107,7 @@ Linux 2.6:
                程序测试的指导,请参阅
                Documentation/power/drivers-testing.txt。有关驱动程序电
                源管理问题相对全面的概述,请参阅
-               Documentation/power/admin-guide/devices.rst。
+               Documentation/driver-api/pm/devices.rst。
 
 管理:              如果一个驱动程序的作者还在进行有效的维护,那么通常除了那
                些明显正确且不需要任何检查的补丁以外,其他所有的补丁都会
index 4f8bf30a41dc59ea52b0a77d5816cb6b1716f105..4cb1ba8b8fed50470dd641197b54f14706cb9b8c 100644 (file)
@@ -1,4 +1,4 @@
-Chinese translated version of Documentation/gpio.txt
+Chinese translated version of Documentation/gpio
 
 If you have any comment or update to the content, please contact the
 original document maintainer directly.  However, if you have a problem
@@ -10,7 +10,7 @@ Maintainer: Grant Likely <grant.likely@secretlab.ca>
                Linus Walleij <linus.walleij@linaro.org>
 Chinese maintainer: Fu Wei <tekkamanninja@gmail.com>
 ---------------------------------------------------------------------
-Documentation/gpio.txt 的中文翻译
+Documentation/gpio 的中文翻译
 
 如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
 交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
index e592daf4e0143b4a00ee213a2d167e53eff94ca6..1f8127bdd415a64a0f6eccd03eaae126231cd8c6 100644 (file)
@@ -1,4 +1,4 @@
-Chinese translated version of Documentation/io_orderings.txt
+Chinese translated version of Documentation/io_ordering.txt
 
 If you have any comment or update to the content, please contact the
 original document maintainer directly.  However, if you have a problem
index e9db693c0a2302d2fc05d005b604e347fde1b09c..7159cec04090d8f0243090b18a53f227a942e4e1 100644 (file)
@@ -1,4 +1,4 @@
-Chinese translated version of Documentation/magic-number.txt
+Chinese translated version of Documentation/process/magic-number.rst
 
 If you have any comment or update to the content, please post to LKML directly.
 However, if you have problem communicating in English you can also ask the
@@ -7,7 +7,7 @@ translation is outdated or there is problem with translation.
 
 Chinese maintainer: Jia Wei Wei <harryxiyou@gmail.com>
 ---------------------------------------------------------------------
-Documentation/magic-number.txt的中文翻译
+Documentation/process/magic-number.rst的中文翻译
 
 如果想评论或更新本文的内容,请直接发信到LKML。如果你使用英文交流有困难的话,也可
 以向中文版维护者求助。如果本翻译更新不及时或者翻译存在问题,请联系中文版维护者。
index 67ffbf352ae0c252d67d8c262d4a416de97ce6f7..e9f29375aa952d01748954b9b3fe287f215f2f58 100644 (file)
@@ -1,4 +1,4 @@
-Chinese translated version of Documentation/video4linux/omap3isp.txt
+Chinese translated version of Documentation/media/v4l-drivers/omap3isp.rst
 
 If you have any comment or update to the content, please contact the
 original document maintainer directly.  However, if you have a problem
@@ -11,7 +11,7 @@ Maintainer: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
          David Cohen <dacohen@gmail.com>
 Chinese maintainer: Fu Wei <tekkamanninja@gmail.com>
 ---------------------------------------------------------------------
-Documentation/video4linux/omap3isp.txt 的中文翻译
+Documentation/media/v4l-drivers/omap3isp.rst 的中文翻译
 
 如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
 交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
index c77c0f0608647ea9432597aa0e0a2ee70c892fa9..66c7c568bd866cf07ca9869e51a1600cb17e1f0c 100644 (file)
@@ -1,4 +1,4 @@
-Chinese translated version of Documentation/video4linux/v4l2-framework.txt
+Chinese translated version of Documentation/media/media_kapi.rst
 
 If you have any comment or update to the content, please contact the
 original document maintainer directly.  However, if you have a problem
@@ -9,7 +9,7 @@ or if there is a problem with the translation.
 Maintainer: Mauro Carvalho Chehab <mchehab@kernel.org>
 Chinese maintainer: Fu Wei <tekkamanninja@gmail.com>
 ---------------------------------------------------------------------
-Documentation/video4linux/v4l2-framework.txt 的中文翻译
+Documentation/media/media_kapi.rst 的中文翻译
 
 如果想评论或更新本文的内容,请直接联系原文档的维护者。如果你使用英文
 交流有困难的话,也可以向中文版维护者求助。如果本翻译更新不及时或者翻
@@ -777,7 +777,7 @@ v4l2 核心 API 提供了一个处理视频缓冲的标准方法(称为“videob
 线性 DMA(videobuf-dma-contig)以及大多用于 USB 设备的用 vmalloc
 分配的缓冲(videobuf-vmalloc)。
 
-请参阅 Documentation/video4linux/videobuf,以获得更多关于 videobuf
+请参阅 Documentation/media/kapi/v4l2-videobuf.rst,以获得更多关于 videobuf
 层的使用信息。
 
 v4l2_fh 结构体
index 1b395034653205b5a6c127488053daced91075d6..c3f69bcaf96e1f9caaae06fbcdc0cafde22bbf0b 100644 (file)
@@ -145,6 +145,11 @@ The functions in the mdev_parent_ops structure are as follows:
 * create: allocate basic resources in a driver for a mediated device
 * remove: free resources in a driver when a mediated device is destroyed
 
+(Note that mdev-core provides no implicit serialization of create/remove
+callbacks per mdev parent device, per mdev type, or any other categorization.
+Vendor drivers are expected to be fully asynchronous in this respect or
+provide their own internal resource protection.)
+
 The callbacks in the mdev_parent_ops structure are as follows:
 
 * open: open callback of mediated device
index 758bf403a169dac0db8ec259bc611986aea69cfd..495b7742ab58086b5c81fff88eeb884769391b49 100644 (file)
@@ -1269,12 +1269,18 @@ struct kvm_cpuid_entry2 {
        __u32 padding[3];
 };
 
-This ioctl returns x86 cpuid features which are supported by both the hardware
-and kvm.  Userspace can use the information returned by this ioctl to
-construct cpuid information (for KVM_SET_CPUID2) that is consistent with
-hardware, kernel, and userspace capabilities, and with user requirements (for
-example, the user may wish to constrain cpuid to emulate older hardware,
-or for feature consistency across a cluster).
+This ioctl returns x86 cpuid features which are supported by both the
+hardware and kvm in its default configuration.  Userspace can use the
+information returned by this ioctl to construct cpuid information (for
+KVM_SET_CPUID2) that is consistent with hardware, kernel, and
+userspace capabilities, and with user requirements (for example, the
+user may wish to constrain cpuid to emulate older hardware, or for
+feature consistency across a cluster).
+
+Note that certain capabilities, such as KVM_CAP_X86_DISABLE_EXITS, may
+expose cpuid features (e.g. MONITOR) which are not supported by kvm in
+its default configuration. If userspace enables such capabilities, it
+is responsible for modifying the results of this ioctl appropriately.
 
 Userspace invokes KVM_GET_SUPPORTED_CPUID by passing a kvm_cpuid2 structure
 with the 'nent' field indicating the number of entries in the variable-size
@@ -4603,3 +4609,12 @@ Architectures: s390
 This capability indicates that kvm will implement the interfaces to handle
 reset, migration and nested KVM for branch prediction blocking. The stfle
 facility 82 should not be provided to the guest without this capability.
+
+8.14 KVM_CAP_HYPERV_TLBFLUSH
+
+Architectures: x86
+
+This capability indicates that KVM supports paravirtualized Hyper-V TLB Flush
+hypercalls:
+HvFlushVirtualAddressSpace, HvFlushVirtualAddressSpaceEx,
+HvFlushVirtualAddressList, HvFlushVirtualAddressListEx.
index 9293b45abdb99578724c995676addd0c50967c57..2408ab720ef7bae0bcd4736bc30ee475fd00e8ce 100644 (file)
@@ -27,16 +27,42 @@ Groups:
       VCPU and all of the redistributor pages are contiguous.
       Only valid for KVM_DEV_TYPE_ARM_VGIC_V3.
       This address needs to be 64K aligned.
+
+    KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION (rw, 64-bit)
+      The attribute data pointed to by kvm_device_attr.addr is a __u64 value:
+      bits:     | 63   ....  52  |  51   ....   16 | 15 - 12  |11 - 0
+      values:   |     count      |       base      |  flags   | index
+      - index encodes the unique redistributor region index
+      - flags: reserved for future use, currently 0
+      - base field encodes bits [51:16] of the guest physical base address
+        of the first redistributor in the region.
+      - count encodes the number of redistributors in the region. Must be
+        greater than 0.
+      There are two 64K pages for each redistributor in the region and
+      redistributors are laid out contiguously within the region. Regions
+      are filled with redistributors in the index order. The sum of all
+      region count fields must be greater than or equal to the number of
+      VCPUs. Redistributor regions must be registered in the incremental
+      index order, starting from index 0.
+      The characteristics of a specific redistributor region can be read
+      by presetting the index field in the attr data.
+      Only valid for KVM_DEV_TYPE_ARM_VGIC_V3.
+
+  It is invalid to mix calls with KVM_VGIC_V3_ADDR_TYPE_REDIST and
+  KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION attributes.
+
   Errors:
     -E2BIG:  Address outside of addressable IPA range
-    -EINVAL: Incorrectly aligned address
+    -EINVAL: Incorrectly aligned address, bad redistributor region
+             count/index, mixed redistributor region attribute usage
     -EEXIST: Address already configured
+    -ENOENT: Attempt to read the characteristics of a non existing
+             redistributor region
     -ENXIO:  The group or attribute is unknown/unsupported for this device
              or hardware support is missing.
     -EFAULT: Invalid user pointer for attr->addr.
 
 
-
   KVM_DEV_ARM_VGIC_GRP_DIST_REGS
   KVM_DEV_ARM_VGIC_GRP_REDIST_REGS
   Attributes:
index f50d45b1e9679cba4a6a619c59e4d6afd7e06ccb..e507a9e0421ed22e630425074e053303f5e990bf 100644 (file)
@@ -49,8 +49,8 @@ The mmu supports first-generation mmu hardware, which allows an atomic switch
 of the current paging mode and cr3 during guest entry, as well as
 two-dimensional paging (AMD's NPT and Intel's EPT).  The emulated hardware
 it exposes is the traditional 2/3/4 level x86 mmu, with support for global
-pages, pae, pse, pse36, cr0.wp, and 1GB pages.  Work is in progress to support
-exposing NPT capable hardware on NPT capable hosts.
+pages, pae, pse, pse36, cr0.wp, and 1GB pages. Emulated hardware also
+able to expose NPT capable hardware on NPT capable hosts.
 
 Translation
 ===========
@@ -465,5 +465,5 @@ Further reading
 ===============
 
 - NPT presentation from KVM Forum 2008
-  http://www.linux-kvm.org/wiki/images/c/c8/KvmForum2008%24kdf2008_21.pdf
+  http://www.linux-kvm.org/images/c/c8/KvmForum2008%24kdf2008_21.pdf
 
index 8ed937de1163aeb50cfc4d52acdd08ee561921bd..97eb1353e9624463d846dee3f944ac69c6b1704a 100644 (file)
@@ -31,17 +31,6 @@ L0, the guest hypervisor, which we call L1, and its nested guest, which we
 call L2.
 
 
-Known limitations
------------------
-
-The current code supports running Linux guests under KVM guests.
-Only 64-bit guest hypervisors are supported.
-
-Additional patches for running Windows under guest KVM, and Linux under
-guest VMware server, and support for nested EPT, are currently running in
-the lab, and will be sent as follow-on patchsets.
-
-
 Running nested VMX
 ------------------
 
index 2c7069037a15f1e855f50ea475a529df67617cfa..9d5eeff51b5fd32979f64d288375b6489ff25712 100644 (file)
@@ -1419,6 +1419,7 @@ M:        Shawn Guo <shawnguo@kernel.org>
 M:     Sascha Hauer <s.hauer@pengutronix.de>
 R:     Pengutronix Kernel Team <kernel@pengutronix.de>
 R:     Fabio Estevam <fabio.estevam@nxp.com>
+R:     NXP Linux Team <linux-imx@nxp.com>
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/shawnguo/linux.git
@@ -1731,7 +1732,8 @@ F:        arch/arm/mach-npcm/
 F:     arch/arm/boot/dts/nuvoton-npcm*
 F:     include/dt-bindings/clock/nuvoton,npcm7xx-clks.h
 F:     drivers/*/*npcm*
-F:     Documentation/*/*npcm*
+F:     Documentation/devicetree/bindings/*/*npcm*
+F:     Documentation/devicetree/bindings/*/*/*npcm*
 
 ARM/NUVOTON W90X900 ARM ARCHITECTURE
 M:     Wan ZongShun <mcuos.com@gmail.com>
@@ -1829,7 +1831,7 @@ F:        drivers/spi/spi-qup.c
 F:     drivers/tty/serial/msm_serial.c
 F:     drivers/*/pm8???-*
 F:     drivers/mfd/ssbi.c
-F:     drivers/firmware/qcom_scm.c
+F:     drivers/firmware/qcom_scm*
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/agross/linux.git
 
 ARM/RADISYS ENP2611 MACHINE SUPPORT
@@ -2606,6 +2608,7 @@ BACKLIGHT CLASS/SUBSYSTEM
 M:     Lee Jones <lee.jones@linaro.org>
 M:     Daniel Thompson <daniel.thompson@linaro.org>
 M:     Jingoo Han <jingoohan1@gmail.com>
+L:     dri-devel@lists.freedesktop.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/lee/backlight.git
 S:     Maintained
 F:     drivers/video/backlight/
@@ -3077,7 +3080,7 @@ M:        Clemens Ladisch <clemens@ladisch.de>
 L:     alsa-devel@alsa-project.org (moderated for non-subscribers)
 T:     git git://git.alsa-project.org/alsa-kernel.git
 S:     Maintained
-F:     Documentation/sound/alsa/Bt87x.txt
+F:     Documentation/sound/cards/bt87x.rst
 F:     sound/pci/bt87x.c
 
 BT8XXGPIO DRIVER
@@ -3373,7 +3376,7 @@ M:        David Howells <dhowells@redhat.com>
 M:     David Woodhouse <dwmw2@infradead.org>
 L:     keyrings@vger.kernel.org
 S:     Maintained
-F:     Documentation/module-signing.txt
+F:     Documentation/admin-guide/module-signing.rst
 F:     certs/
 F:     scripts/sign-file.c
 F:     scripts/extract-cert.c
@@ -4511,7 +4514,7 @@ DRM DRIVER FOR ILITEK ILI9225 PANELS
 M:     David Lechner <david@lechnology.com>
 S:     Maintained
 F:     drivers/gpu/drm/tinydrm/ili9225.c
-F:     Documentation/devicetree/bindings/display/ili9225.txt
+F:     Documentation/devicetree/bindings/display/ilitek,ili9225.txt
 
 DRM DRIVER FOR INTEL I810 VIDEO CARDS
 S:     Orphan / Obsolete
@@ -4597,13 +4600,13 @@ DRM DRIVER FOR SITRONIX ST7586 PANELS
 M:     David Lechner <david@lechnology.com>
 S:     Maintained
 F:     drivers/gpu/drm/tinydrm/st7586.c
-F:     Documentation/devicetree/bindings/display/st7586.txt
+F:     Documentation/devicetree/bindings/display/sitronix,st7586.txt
 
 DRM DRIVER FOR SITRONIX ST7735R PANELS
 M:     David Lechner <david@lechnology.com>
 S:     Maintained
 F:     drivers/gpu/drm/tinydrm/st7735r.c
-F:     Documentation/devicetree/bindings/display/st7735r.txt
+F:     Documentation/devicetree/bindings/display/sitronix,st7735r.txt
 
 DRM DRIVER FOR TDFX VIDEO CARDS
 S:     Orphan / Obsolete
@@ -4636,7 +4639,6 @@ F:        drivers/gpu/drm/
 F:     drivers/gpu/vga/
 F:     Documentation/devicetree/bindings/display/
 F:     Documentation/devicetree/bindings/gpu/
-F:     Documentation/devicetree/bindings/video/
 F:     Documentation/gpu/
 F:     include/drm/
 F:     include/uapi/drm/
@@ -4681,7 +4683,7 @@ M:        Boris Brezillon <boris.brezillon@bootlin.com>
 L:     dri-devel@lists.freedesktop.org
 S:     Supported
 F:     drivers/gpu/drm/atmel-hlcdc/
-F:     Documentation/devicetree/bindings/drm/atmel/
+F:     Documentation/devicetree/bindings/display/atmel/
 T:     git git://anongit.freedesktop.org/drm/drm-misc
 
 DRM DRIVERS FOR BRIDGE CHIPS
@@ -4712,7 +4714,7 @@ S:        Supported
 F:     drivers/gpu/drm/fsl-dcu/
 F:     Documentation/devicetree/bindings/display/fsl,dcu.txt
 F:     Documentation/devicetree/bindings/display/fsl,tcon.txt
-F:     Documentation/devicetree/bindings/display/panel/nec,nl4827hc19_05b.txt
+F:     Documentation/devicetree/bindings/display/panel/nec,nl4827hc19-05b.txt
 
 DRM DRIVERS FOR FREESCALE IMX
 M:     Philipp Zabel <p.zabel@pengutronix.de>
@@ -4822,7 +4824,7 @@ M:        Eric Anholt <eric@anholt.net>
 S:     Supported
 F:     drivers/gpu/drm/v3d/
 F:     include/uapi/drm/v3d_drm.h
-F:     Documentation/devicetree/bindings/display/brcm,bcm-v3d.txt
+F:     Documentation/devicetree/bindings/gpu/brcm,bcm-v3d.txt
 T:     git git://anongit.freedesktop.org/drm/drm-misc
 
 DRM DRIVERS FOR VC4
@@ -5733,7 +5735,7 @@ M:        Madalin Bucur <madalin.bucur@nxp.com>
 L:     netdev@vger.kernel.org
 S:     Maintained
 F:     drivers/net/ethernet/freescale/fman
-F:     Documentation/devicetree/bindings/powerpc/fsl/fman.txt
+F:     Documentation/devicetree/bindings/net/fsl-fman.txt
 
 FREESCALE QORIQ PTP CLOCK DRIVER
 M:     Yangbo Lu <yangbo.lu@nxp.com>
@@ -5951,14 +5953,14 @@ GENERIC GPIO I2C DRIVER
 M:     Haavard Skinnemoen <hskinnemoen@gmail.com>
 S:     Supported
 F:     drivers/i2c/busses/i2c-gpio.c
-F:     include/linux/i2c-gpio.h
+F:     include/linux/platform_data/i2c-gpio.h
 
 GENERIC GPIO I2C MULTIPLEXER DRIVER
 M:     Peter Korsgaard <peter.korsgaard@barco.com>
 L:     linux-i2c@vger.kernel.org
 S:     Supported
 F:     drivers/i2c/muxes/i2c-mux-gpio.c
-F:     include/linux/i2c-mux-gpio.h
+F:     include/linux/platform_data/i2c-mux-gpio.h
 F:     Documentation/i2c/muxes/i2c-mux-gpio
 
 GENERIC HDLC (WAN) DRIVERS
@@ -6499,7 +6501,7 @@ L:        linux-mm@kvack.org
 S:     Maintained
 F:     mm/hmm*
 F:     include/linux/hmm*
-F:     Documentation/vm/hmm.txt
+F:     Documentation/vm/hmm.rst
 
 HOST AP DRIVER
 M:     Jouni Malinen <j@w1.fi>
@@ -6618,7 +6620,7 @@ F:        arch/x86/hyperv
 F:     drivers/hid/hid-hyperv.c
 F:     drivers/hv/
 F:     drivers/input/serio/hyperv-keyboard.c
-F:     drivers/pci/host/pci-hyperv.c
+F:     drivers/pci/controller/pci-hyperv.c
 F:     drivers/net/hyperv/
 F:     drivers/scsi/storvsc_drv.c
 F:     drivers/uio/uio_hv_generic.c
@@ -6964,7 +6966,7 @@ IIO MULTIPLEXER
 M:     Peter Rosin <peda@axentia.se>
 L:     linux-iio@vger.kernel.org
 S:     Maintained
-F:     Documentation/devicetree/bindings/iio/multiplexer/iio-mux.txt
+F:     Documentation/devicetree/bindings/iio/multiplexer/io-channel-mux.txt
 F:     drivers/iio/multiplexer/iio-mux.c
 
 IIO SUBSYSTEM AND DRIVERS
@@ -7399,7 +7401,7 @@ F:        drivers/platform/x86/intel-wmi-thunderbolt.c
 INTEL(R) TRACE HUB
 M:     Alexander Shishkin <alexander.shishkin@linux.intel.com>
 S:     Supported
-F:     Documentation/trace/intel_th.txt
+F:     Documentation/trace/intel_th.rst
 F:     drivers/hwtracing/intel_th/
 
 INTEL(R) TRUSTED EXECUTION TECHNOLOGY (TXT)
@@ -7423,7 +7425,7 @@ M:        Linus Walleij <linus.walleij@linaro.org>
 L:     linux-iio@vger.kernel.org
 S:     Maintained
 F:     drivers/iio/gyro/mpu3050*
-F:     Documentation/devicetree/bindings/iio/gyroscope/inv,mpu3050.txt
+F:     Documentation/devicetree/bindings/iio/gyroscope/invensense,mpu3050.txt
 
 IOC3 ETHERNET DRIVER
 M:     Ralf Baechle <ralf@linux-mips.org>
@@ -8698,7 +8700,7 @@ M:        Guenter Roeck <linux@roeck-us.net>
 L:     linux-hwmon@vger.kernel.org
 S:     Maintained
 F:     Documentation/hwmon/max6697
-F:     Documentation/devicetree/bindings/i2c/max6697.txt
+F:     Documentation/devicetree/bindings/hwmon/max6697.txt
 F:     drivers/hwmon/max6697.c
 F:     include/linux/platform_data/max6697.h
 
@@ -9078,7 +9080,7 @@ M:        Martin Donnelly <martin.donnelly@ge.com>
 M:     Martyn Welch <martyn.welch@collabora.co.uk>
 S:     Maintained
 F:     drivers/gpu/drm/bridge/megachips-stdpxxxx-ge-b850v3-fw.c
-F:     Documentation/devicetree/bindings/video/bridge/megachips-stdpxxxx-ge-b850v3-fw.txt
+F:     Documentation/devicetree/bindings/display/bridge/megachips-stdpxxxx-ge-b850v3-fw.txt
 
 MEGARAID SCSI/SAS DRIVERS
 M:     Kashyap Desai <kashyap.desai@broadcom.com>
@@ -9415,10 +9417,12 @@ F:      drivers/usb/image/microtek.*
 
 MIPS
 M:     Ralf Baechle <ralf@linux-mips.org>
+M:     Paul Burton <paul.burton@mips.com>
 M:     James Hogan <jhogan@kernel.org>
 L:     linux-mips@linux-mips.org
 W:     http://www.linux-mips.org/
 T:     git git://git.linux-mips.org/pub/scm/ralf/linux.git
+T:     git git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux.git
 Q:     http://patchwork.linux-mips.org/project/linux-mips/list/
 S:     Supported
 F:     Documentation/devicetree/bindings/mips/
@@ -9520,7 +9524,7 @@ M:        Subrahmanya Lingappa <l.subrahmanya@mobiveil.co.in>
 L:     linux-pci@vger.kernel.org
 S:     Supported
 F:     Documentation/devicetree/bindings/pci/mobiveil-pcie.txt
-F:     drivers/pci/host/pcie-mobiveil.c
+F:     drivers/pci/controller/pcie-mobiveil.c
 
 MODULE SUPPORT
 M:     Jessica Yu <jeyu@kernel.org>
@@ -9661,7 +9665,7 @@ F:        include/uapi/linux/mmc/
 MULTIPLEXER SUBSYSTEM
 M:     Peter Rosin <peda@axentia.se>
 S:     Maintained
-F:     Documentation/ABI/testing/mux/sysfs-class-mux*
+F:     Documentation/ABI/testing/sysfs-class-mux*
 F:     Documentation/devicetree/bindings/mux/
 F:     include/linux/dt-bindings/mux/
 F:     include/linux/mux/
@@ -9692,7 +9696,7 @@ MXSFB DRM DRIVER
 M:     Marek Vasut <marex@denx.de>
 S:     Supported
 F:     drivers/gpu/drm/mxsfb/
-F:     Documentation/devicetree/bindings/display/mxsfb-drm.txt
+F:     Documentation/devicetree/bindings/display/mxsfb.txt
 
 MYRICOM MYRI-10G 10GbE DRIVER (MYRI10GE)
 M:     Chris Lee <christopher.lee@cspi.com>
@@ -10240,7 +10244,7 @@ F:      arch/powerpc/include/asm/pnv-ocxl.h
 F:     drivers/misc/ocxl/
 F:     include/misc/ocxl*
 F:     include/uapi/misc/ocxl.h
-F:     Documentation/accelerators/ocxl.txt
+F:     Documentation/accelerators/ocxl.rst
 
 OMAP AUDIO SUPPORT
 M:     Peter Ujfalusi <peter.ujfalusi@ti.com>
@@ -10269,18 +10273,16 @@ F:    arch/arm/boot/dts/*am5*
 F:     arch/arm/boot/dts/*dra7*
 
 OMAP DISPLAY SUBSYSTEM and FRAMEBUFFER SUPPORT (DSS2)
-M:     Tomi Valkeinen <tomi.valkeinen@ti.com>
 L:     linux-omap@vger.kernel.org
 L:     linux-fbdev@vger.kernel.org
-S:     Maintained
+S:     Orphan
 F:     drivers/video/fbdev/omap2/
 F:     Documentation/arm/OMAP/DSS
 
 OMAP FRAMEBUFFER SUPPORT
-M:     Tomi Valkeinen <tomi.valkeinen@ti.com>
 L:     linux-fbdev@vger.kernel.org
 L:     linux-omap@vger.kernel.org
-S:     Maintained
+S:     Orphan
 F:     drivers/video/fbdev/omap/
 
 OMAP GENERAL PURPOSE MEMORY CONTROLLER SUPPORT
@@ -10388,7 +10390,7 @@ F:      arch/arm/mach-omap1/
 F:     arch/arm/plat-omap/
 F:     arch/arm/configs/omap1_defconfig
 F:     drivers/i2c/busses/i2c-omap.c
-F:     include/linux/i2c-omap.h
+F:     include/linux/platform_data/i2c-omap.h
 
 OMAP2+ SUPPORT
 M:     Tony Lindgren <tony@atomide.com>
@@ -10420,7 +10422,7 @@ F:      drivers/regulator/tps65218-regulator.c
 F:     drivers/regulator/tps65910-regulator.c
 F:     drivers/regulator/twl-regulator.c
 F:     drivers/regulator/twl6030-regulator.c
-F:     include/linux/i2c-omap.h
+F:     include/linux/platform_data/i2c-omap.h
 
 ONION OMEGA2+ BOARD
 M:     Harvey Hunt <harveyhuntnexus@gmail.com>
@@ -10724,7 +10726,7 @@ PARALLEL LCD/KEYPAD PANEL DRIVER
 M:     Willy Tarreau <willy@haproxy.com>
 M:     Ksenija Stanojevic <ksenija.stanojevic@gmail.com>
 S:     Odd Fixes
-F:     Documentation/misc-devices/lcd-panel-cgram.txt
+F:     Documentation/auxdisplay/lcd-panel-cgram.txt
 F:     drivers/misc/panel.c
 
 PARALLEL PORT SUBSYSTEM
@@ -10825,7 +10827,7 @@ L:      linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/aardvark-pci.txt
-F:     drivers/pci/host/pci-aardvark.c
+F:     drivers/pci/controller/pci-aardvark.c
 
 PCI DRIVER FOR ALTERA PCIE IP
 M:     Ley Foon Tan <lftan@altera.com>
@@ -10833,7 +10835,7 @@ L:      rfi@lists.rocketboards.org (moderated for non-subscribers)
 L:     linux-pci@vger.kernel.org
 S:     Supported
 F:     Documentation/devicetree/bindings/pci/altera-pcie.txt
-F:     drivers/pci/host/pcie-altera.c
+F:     drivers/pci/controller/pcie-altera.c
 
 PCI DRIVER FOR APPLIEDMICRO XGENE
 M:     Tanmay Inamdar <tinamdar@apm.com>
@@ -10841,7 +10843,7 @@ L:      linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/xgene-pci.txt
-F:     drivers/pci/host/pci-xgene.c
+F:     drivers/pci/controller/pci-xgene.c
 
 PCI DRIVER FOR ARM VERSATILE PLATFORM
 M:     Rob Herring <robh@kernel.org>
@@ -10849,7 +10851,7 @@ L:      linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/versatile.txt
-F:     drivers/pci/host/pci-versatile.c
+F:     drivers/pci/controller/pci-versatile.c
 
 PCI DRIVER FOR ARMADA 8K
 M:     Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
@@ -10857,14 +10859,14 @@ L:    linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/pci-armada8k.txt
-F:     drivers/pci/dwc/pcie-armada8k.c
+F:     drivers/pci/controller/dwc/pcie-armada8k.c
 
 PCI DRIVER FOR CADENCE PCIE IP
 M:     Alan Douglas <adouglas@cadence.com>
 L:     linux-pci@vger.kernel.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/cdns,*.txt
-F:     drivers/pci/cadence/pcie-cadence*
+F:     drivers/pci/controller/pcie-cadence*
 
 PCI DRIVER FOR FREESCALE LAYERSCAPE
 M:     Minghuan Lian <minghuan.Lian@nxp.com>
@@ -10874,7 +10876,7 @@ L:      linuxppc-dev@lists.ozlabs.org
 L:     linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org
 S:     Maintained
-F:     drivers/pci/dwc/*layerscape*
+F:     drivers/pci/controller/dwc/*layerscape*
 
 PCI DRIVER FOR GENERIC OF HOSTS
 M:     Will Deacon <will.deacon@arm.com>
@@ -10882,8 +10884,8 @@ L:      linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/host-generic-pci.txt
-F:     drivers/pci/host/pci-host-common.c
-F:     drivers/pci/host/pci-host-generic.c
+F:     drivers/pci/controller/pci-host-common.c
+F:     drivers/pci/controller/pci-host-generic.c
 
 PCI DRIVER FOR IMX6
 M:     Richard Zhu <hongxing.zhu@nxp.com>
@@ -10892,14 +10894,14 @@ L:    linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
-F:     drivers/pci/dwc/*imx6*
+F:     drivers/pci/controller/dwc/*imx6*
 
 PCI DRIVER FOR INTEL VOLUME MANAGEMENT DEVICE (VMD)
 M:     Keith Busch <keith.busch@intel.com>
 M:     Jonathan Derrick <jonathan.derrick@intel.com>
 L:     linux-pci@vger.kernel.org
 S:     Supported
-F:     drivers/pci/host/vmd.c
+F:     drivers/pci/controller/vmd.c
 
 PCI DRIVER FOR MICROSEMI SWITCHTEC
 M:     Kurt Schwemmer <kurt.schwemmer@microsemi.com>
@@ -10919,7 +10921,7 @@ M:      Jason Cooper <jason@lakedaemon.net>
 L:     linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Maintained
-F:     drivers/pci/host/*mvebu*
+F:     drivers/pci/controller/*mvebu*
 
 PCI DRIVER FOR NVIDIA TEGRA
 M:     Thierry Reding <thierry.reding@gmail.com>
@@ -10927,14 +10929,14 @@ L:    linux-tegra@vger.kernel.org
 L:     linux-pci@vger.kernel.org
 S:     Supported
 F:     Documentation/devicetree/bindings/pci/nvidia,tegra20-pcie.txt
-F:     drivers/pci/host/pci-tegra.c
+F:     drivers/pci/controller/pci-tegra.c
 
 PCI DRIVER FOR RENESAS R-CAR
 M:     Simon Horman <horms@verge.net.au>
 L:     linux-pci@vger.kernel.org
 L:     linux-renesas-soc@vger.kernel.org
 S:     Maintained
-F:     drivers/pci/host/*rcar*
+F:     drivers/pci/controller/*rcar*
 
 PCI DRIVER FOR SAMSUNG EXYNOS
 M:     Jingoo Han <jingoohan1@gmail.com>
@@ -10942,7 +10944,7 @@ L:      linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 L:     linux-samsung-soc@vger.kernel.org (moderated for non-subscribers)
 S:     Maintained
-F:     drivers/pci/dwc/pci-exynos.c
+F:     drivers/pci/controller/dwc/pci-exynos.c
 
 PCI DRIVER FOR SYNOPSYS DESIGNWARE
 M:     Jingoo Han <jingoohan1@gmail.com>
@@ -10950,7 +10952,7 @@ M:      Joao Pinto <Joao.Pinto@synopsys.com>
 L:     linux-pci@vger.kernel.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/designware-pcie.txt
-F:     drivers/pci/dwc/*designware*
+F:     drivers/pci/controller/dwc/*designware*
 
 PCI DRIVER FOR TI DRA7XX
 M:     Kishon Vijay Abraham I <kishon@ti.com>
@@ -10958,14 +10960,14 @@ L:    linux-omap@vger.kernel.org
 L:     linux-pci@vger.kernel.org
 S:     Supported
 F:     Documentation/devicetree/bindings/pci/ti-pci.txt
-F:     drivers/pci/dwc/pci-dra7xx.c
+F:     drivers/pci/controller/dwc/pci-dra7xx.c
 
 PCI DRIVER FOR TI KEYSTONE
 M:     Murali Karicheri <m-karicheri2@ti.com>
 L:     linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Maintained
-F:     drivers/pci/dwc/*keystone*
+F:     drivers/pci/controller/dwc/*keystone*
 
 PCI ENDPOINT SUBSYSTEM
 M:     Kishon Vijay Abraham I <kishon@ti.com>
@@ -10998,7 +11000,7 @@ L:      rfi@lists.rocketboards.org (moderated for non-subscribers)
 L:     linux-pci@vger.kernel.org
 S:     Supported
 F:     Documentation/devicetree/bindings/pci/altera-pcie-msi.txt
-F:     drivers/pci/host/pcie-altera-msi.c
+F:     drivers/pci/controller/pcie-altera-msi.c
 
 PCI MSI DRIVER FOR APPLIEDMICRO XGENE
 M:     Duc Dang <dhdang@apm.com>
@@ -11006,7 +11008,7 @@ L:      linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/xgene-pci-msi.txt
-F:     drivers/pci/host/pci-xgene-msi.c
+F:     drivers/pci/controller/pci-xgene-msi.c
 
 PCI SUBSYSTEM
 M:     Bjorn Helgaas <bhelgaas@google.com>
@@ -11032,9 +11034,7 @@ L:      linux-pci@vger.kernel.org
 Q:     http://patchwork.ozlabs.org/project/linux-pci/list/
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git/
 S:     Supported
-F:     drivers/pci/cadence/
-F:     drivers/pci/host/
-F:     drivers/pci/dwc/
+F:     drivers/pci/controller/
 
 PCIE DRIVER FOR AXIS ARTPEC
 M:     Jesper Nilsson <jesper.nilsson@axis.com>
@@ -11042,7 +11042,7 @@ L:      linux-arm-kernel@axis.com
 L:     linux-pci@vger.kernel.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/axis,artpec*
-F:     drivers/pci/dwc/*artpec*
+F:     drivers/pci/controller/dwc/*artpec*
 
 PCIE DRIVER FOR CAVIUM THUNDERX
 M:     David Daney <david.daney@cavium.com>
@@ -11050,22 +11050,22 @@ L:    linux-pci@vger.kernel.org
 L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
 S:     Supported
 F:     Documentation/devicetree/bindings/pci/pci-thunder-*
-F:     drivers/pci/host/pci-thunder-*
+F:     drivers/pci/controller/pci-thunder-*
 
 PCIE DRIVER FOR HISILICON
 M:     Zhou Wang <wangzhou1@hisilicon.com>
 L:     linux-pci@vger.kernel.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/hisilicon-pcie.txt
-F:     drivers/pci/dwc/pcie-hisi.c
+F:     drivers/pci/controller/dwc/pcie-hisi.c
 
 PCIE DRIVER FOR HISILICON KIRIN
 M:     Xiaowei Song <songxiaowei@hisilicon.com>
 M:     Binghui Wang <wangbinghui@hisilicon.com>
 L:     linux-pci@vger.kernel.org
 S:     Maintained
-F:     Documentation/devicetree/bindings/pci/pcie-kirin.txt
-F:     drivers/pci/dwc/pcie-kirin.c
+F:     Documentation/devicetree/bindings/pci/kirin-pcie.txt
+F:     drivers/pci/controller/dwc/pcie-kirin.c
 
 PCIE DRIVER FOR HISILICON STB
 M:     Jianguo Sun <sunjianguo1@huawei.com>
@@ -11073,7 +11073,7 @@ M:      Shawn Guo <shawn.guo@linaro.org>
 L:     linux-pci@vger.kernel.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/hisilicon-histb-pcie.txt
-F:     drivers/pci/dwc/pcie-histb.c
+F:     drivers/pci/controller/dwc/pcie-histb.c
 
 PCIE DRIVER FOR MEDIATEK
 M:     Ryder Lee <ryder.lee@mediatek.com>
@@ -11081,14 +11081,14 @@ L:    linux-pci@vger.kernel.org
 L:     linux-mediatek@lists.infradead.org
 S:     Supported
 F:     Documentation/devicetree/bindings/pci/mediatek*
-F:     drivers/pci/host/*mediatek*
+F:     drivers/pci/controller/*mediatek*
 
 PCIE DRIVER FOR QUALCOMM MSM
 M:     Stanimir Varbanov <svarbanov@mm-sol.com>
 L:     linux-pci@vger.kernel.org
 L:     linux-arm-msm@vger.kernel.org
 S:     Maintained
-F:     drivers/pci/dwc/*qcom*
+F:     drivers/pci/controller/dwc/*qcom*
 
 PCIE DRIVER FOR ROCKCHIP
 M:     Shawn Lin <shawn.lin@rock-chips.com>
@@ -11096,20 +11096,20 @@ L:    linux-pci@vger.kernel.org
 L:     linux-rockchip@lists.infradead.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/rockchip-pcie*
-F:     drivers/pci/host/pcie-rockchip*
+F:     drivers/pci/controller/pcie-rockchip*
 
 PCI DRIVER FOR V3 SEMICONDUCTOR V360EPC
 M:     Linus Walleij <linus.walleij@linaro.org>
 L:     linux-pci@vger.kernel.org
 S:     Maintained
 F:     Documentation/devicetree/bindings/pci/v3-v360epc-pci.txt
-F:     drivers/pci/host/pci-v3-semi.c
+F:     drivers/pci/controller/pci-v3-semi.c
 
 PCIE DRIVER FOR ST SPEAR13XX
 M:     Pratyush Anand <pratyush.anand@gmail.com>
 L:     linux-pci@vger.kernel.org
 S:     Maintained
-F:     drivers/pci/dwc/*spear*
+F:     drivers/pci/controller/dwc/*spear*
 
 PCMCIA SUBSYSTEM
 M:     Dominik Brodowski <linux@dominikbrodowski.net>
@@ -12177,7 +12177,7 @@ F:      drivers/mtd/nand/raw/r852.h
 
 RISC-V ARCHITECTURE
 M:     Palmer Dabbelt <palmer@sifive.com>
-M:     Albert Ou <albert@sifive.com>
+M:     Albert Ou <aou@eecs.berkeley.edu>
 L:     linux-riscv@lists.infradead.org
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux.git
 S:     Supported
@@ -12455,7 +12455,7 @@ L:      linux-crypto@vger.kernel.org
 L:     linux-samsung-soc@vger.kernel.org
 S:     Maintained
 F:     drivers/crypto/exynos-rng.c
-F:     Documentation/devicetree/bindings/crypto/samsung,exynos-rng4.txt
+F:     Documentation/devicetree/bindings/rng/samsung,exynos4-rng.txt
 
 SAMSUNG EXYNOS TRUE RANDOM NUMBER GENERATOR (TRNG) DRIVER
 M:     Łukasz Stelmach <l.stelmach@samsung.com>
@@ -12937,6 +12937,14 @@ F:     drivers/media/usb/siano/
 F:     drivers/media/usb/siano/
 F:     drivers/media/mmc/siano/
 
+SIFIVE DRIVERS
+M:     Palmer Dabbelt <palmer@sifive.com>
+L:     linux-riscv@lists.infradead.org
+T:     git git://git.kernel.org/pub/scm/linux/kernel/git/palmer/riscv-linux.git
+S:     Supported
+K:     sifive
+N:     sifive
+
 SILEAD TOUCHSCREEN DRIVER
 M:     Hans de Goede <hdegoede@redhat.com>
 L:     linux-input@vger.kernel.org
@@ -13289,7 +13297,7 @@ M:      Vinod Koul <vkoul@kernel.org>
 L:     alsa-devel@alsa-project.org (moderated for non-subscribers)
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
 S:     Supported
-F:     Documentation/sound/alsa/compress_offload.txt
+F:     Documentation/sound/designs/compress-offload.rst
 F:     include/sound/compress_driver.h
 F:     include/uapi/sound/compress_*
 F:     sound/core/compress_offload.c
@@ -13310,7 +13318,7 @@ L:      alsa-devel@alsa-project.org (moderated for non-subscribers)
 W:     http://alsa-project.org/main/index.php/ASoC
 S:     Supported
 F:     Documentation/devicetree/bindings/sound/
-F:     Documentation/sound/alsa/soc/
+F:     Documentation/sound/soc/
 F:     sound/soc/
 F:     include/sound/soc*
 
@@ -13562,6 +13570,16 @@ T:     git git://linuxtv.org/media_tree.git
 S:     Maintained
 F:     drivers/media/usb/stk1160/
 
+STM32 TIMER/LPTIMER DRIVERS
+M:     Fabrice Gasnier <fabrice.gasnier@st.com>
+S:     Maintained
+F:     drivers/*/stm32-*timer*
+F:     drivers/pwm/pwm-stm32*
+F:     include/linux/*/stm32-*tim*
+F:     Documentation/ABI/testing/*timer-stm32
+F:     Documentation/devicetree/bindings/*/stm32-*timer*
+F:     Documentation/devicetree/bindings/pwm/pwm-stm32*
+
 STMMAC ETHERNET DRIVER
 M:     Giuseppe Cavallaro <peppe.cavallaro@st.com>
 M:     Alexandre Torgue <alexandre.torgue@st.com>
@@ -13782,7 +13800,7 @@ SYSTEM TRACE MODULE CLASS
 M:     Alexander Shishkin <alexander.shishkin@linux.intel.com>
 S:     Maintained
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/ash/stm.git
-F:     Documentation/trace/stm.txt
+F:     Documentation/trace/stm.rst
 F:     drivers/hwtracing/stm/
 F:     include/linux/stm.h
 F:     include/uapi/linux/stm.h
@@ -14459,7 +14477,7 @@ M:      Steven Rostedt <rostedt@goodmis.org>
 M:     Ingo Molnar <mingo@redhat.com>
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git perf/core
 S:     Maintained
-F:     Documentation/trace/ftrace.txt
+F:     Documentation/trace/ftrace.rst
 F:     arch/*/*/*/ftrace.h
 F:     arch/*/kernel/ftrace.c
 F:     include/*/ftrace.h
@@ -14928,7 +14946,7 @@ M:      Heikki Krogerus <heikki.krogerus@linux.intel.com>
 L:     linux-usb@vger.kernel.org
 S:     Maintained
 F:     Documentation/ABI/testing/sysfs-class-typec
-F:     Documentation/usb/typec.rst
+F:     Documentation/driver-api/usb/typec.rst
 F:     drivers/usb/typec/
 F:     include/linux/usb/typec.h
 
@@ -14995,8 +15013,7 @@ F:      drivers/media/usb/zr364xx/
 USER-MODE LINUX (UML)
 M:     Jeff Dike <jdike@addtoit.com>
 M:     Richard Weinberger <richard@nod.at>
-L:     user-mode-linux-devel@lists.sourceforge.net
-L:     user-mode-linux-user@lists.sourceforge.net
+L:     linux-um@lists.infradead.org
 W:     http://user-mode-linux.sourceforge.net
 T:     git git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml.git
 S:     Maintained
@@ -15758,7 +15775,7 @@ YEALINK PHONE DRIVER
 M:     Henk Vergonet <Henk.Vergonet@gmail.com>
 L:     usbb2k-api-dev@nongnu.org
 S:     Maintained
-F:     Documentation/input/yealink.rst
+F:     Documentation/input/devices/yealink.rst
 F:     drivers/input/misc/yealink.*
 
 Z8530 DRIVER FOR AX.25
index 019a5a020606f431acb025439b311006714df0f1..8a26b5937241469ff2657b333cbf1fc8474a13b4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -442,8 +442,6 @@ export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
 export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
 export KBUILD_ARFLAGS
 
-export CC_VERSION_TEXT := $(shell $(CC) --version | head -n 1)
-
 # When compiling out-of-tree modules, put MODVERDIR in the module
 # tree rather than in the kernel tree. The kernel tree might
 # even be read-only.
@@ -514,6 +512,12 @@ ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/cc-can-link.sh $(CC)), y)
   export CC_CAN_LINK
 endif
 
+# The expansion should be delayed until arch/$(SRCARCH)/Makefile is included.
+# Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile.
+# CC_VERSION_TEXT is referenced from Kconfig (so it needs export),
+# and from include/config/auto.conf.cmd to detect the compiler upgrade.
+CC_VERSION_TEXT = $(shell $(CC) --version | head -n 1)
+
 ifeq ($(config-targets),1)
 # ===========================================================================
 # *config targets only - make sure prerequisites are updated, and descend
@@ -523,7 +527,7 @@ ifeq ($(config-targets),1)
 # KBUILD_DEFCONFIG may point out an alternative default configuration
 # used for 'make defconfig'
 include arch/$(SRCARCH)/Makefile
-export KBUILD_DEFCONFIG KBUILD_KCONFIG
+export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT
 
 config: scripts_basic outputmakefile FORCE
        $(Q)$(MAKE) $(build)=scripts/kconfig $@
@@ -585,12 +589,32 @@ virt-y            := virt/
 endif # KBUILD_EXTMOD
 
 ifeq ($(dot-config),1)
-# Read in config
 -include include/config/auto.conf
+endif
+
+# The all: target is the default when no target is given on the
+# command line.
+# This allow a user to issue only 'make' to build a kernel including modules
+# Defaults to vmlinux, but the arch makefile usually adds further targets
+all: vmlinux
+
+CFLAGS_GCOV    := -fprofile-arcs -ftest-coverage \
+       $(call cc-option,-fno-tree-loop-im) \
+       $(call cc-disable-warning,maybe-uninitialized,)
+export CFLAGS_GCOV
 
+# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
+# values of the respective KBUILD_* variables
+ARCH_CPPFLAGS :=
+ARCH_AFLAGS :=
+ARCH_CFLAGS :=
+include arch/$(SRCARCH)/Makefile
+
+ifeq ($(dot-config),1)
 ifeq ($(KBUILD_EXTMOD),)
-# Read in dependencies to all Kconfig* files, make sure to run
-# oldconfig if changes are detected.
+# Read in dependencies to all Kconfig* files, make sure to run syncconfig if
+# changes are detected. This should be included after arch/$(SRCARCH)/Makefile
+# because some architectures define CROSS_COMPILE there.
 -include include/config/auto.conf.cmd
 
 # To avoid any implicit rule to kick in, define an empty command
@@ -622,24 +646,6 @@ else
 include/config/auto.conf: ;
 endif # $(dot-config)
 
-# The all: target is the default when no target is given on the
-# command line.
-# This allow a user to issue only 'make' to build a kernel including modules
-# Defaults to vmlinux, but the arch makefile usually adds further targets
-all: vmlinux
-
-CFLAGS_GCOV    := -fprofile-arcs -ftest-coverage \
-       $(call cc-option,-fno-tree-loop-im) \
-       $(call cc-disable-warning,maybe-uninitialized,)
-export CFLAGS_GCOV CFLAGS_KCOV
-
-# The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default
-# values of the respective KBUILD_* variables
-ARCH_CPPFLAGS :=
-ARCH_AFLAGS :=
-ARCH_CFLAGS :=
-include arch/$(SRCARCH)/Makefile
-
 KBUILD_CFLAGS  += $(call cc-option,-fno-delete-null-pointer-checks,)
 KBUILD_CFLAGS  += $(call cc-disable-warning,frame-address,)
 KBUILD_CFLAGS  += $(call cc-disable-warning, format-truncation)
@@ -680,55 +686,11 @@ ifneq ($(CONFIG_FRAME_WARN),0)
 KBUILD_CFLAGS += $(call cc-option,-Wframe-larger-than=${CONFIG_FRAME_WARN})
 endif
 
-# This selects the stack protector compiler flag. Testing it is delayed
-# until after .config has been reprocessed, in the prepare-compiler-check
-# target.
-ifdef CONFIG_CC_STACKPROTECTOR_AUTO
-  stackp-flag := $(call cc-option,-fstack-protector-strong,$(call cc-option,-fstack-protector))
-  stackp-name := AUTO
-else
-ifdef CONFIG_CC_STACKPROTECTOR_REGULAR
-  stackp-flag := -fstack-protector
-  stackp-name := REGULAR
-else
-ifdef CONFIG_CC_STACKPROTECTOR_STRONG
-  stackp-flag := -fstack-protector-strong
-  stackp-name := STRONG
-else
-  # If either there is no stack protector for this architecture or
-  # CONFIG_CC_STACKPROTECTOR_NONE is selected, we're done, and $(stackp-name)
-  # is empty, skipping all remaining stack protector tests.
-  #
-  # Force off for distro compilers that enable stack protector by default.
-  KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
-endif
-endif
-endif
-# Find arch-specific stack protector compiler sanity-checking script.
-ifdef stackp-name
-ifneq ($(stackp-flag),)
-  stackp-path := $(srctree)/scripts/gcc-$(SRCARCH)_$(BITS)-has-stack-protector.sh
-  stackp-check := $(wildcard $(stackp-path))
-  # If the wildcard test matches a test script, run it to check functionality.
-  ifdef stackp-check
-    ifneq ($(shell $(CONFIG_SHELL) $(stackp-check) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
-      stackp-broken := y
-    endif
-  endif
-  ifndef stackp-broken
-    # If the stack protector is functional, enable code that depends on it.
-    KBUILD_CPPFLAGS += -DCONFIG_CC_STACKPROTECTOR
-    # Either we've already detected the flag (for AUTO) or we'll fail the
-    # build in the prepare-compiler-check rule (for specific flag).
-    KBUILD_CFLAGS += $(stackp-flag)
-  else
-    # We have to make sure stack protector is unconditionally disabled if
-    # the compiler is broken (in case we're going to continue the build in
-    # AUTO mode).
-    KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
-  endif
-endif
-endif
+stackp-flags-$(CONFIG_CC_HAS_STACKPROTECTOR_NONE) := -fno-stack-protector
+stackp-flags-$(CONFIG_STACKPROTECTOR)             := -fstack-protector
+stackp-flags-$(CONFIG_STACKPROTECTOR_STRONG)      := -fstack-protector-strong
+
+KBUILD_CFLAGS += $(stackp-flags-y)
 
 ifeq ($(cc-name),clang)
 KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,)
@@ -1112,7 +1074,7 @@ endif
 # prepare2 creates a makefile if using a separate output directory.
 # From this point forward, .config has been reprocessed, so any rules
 # that need to depend on updated CONFIG_* values can be checked here.
-prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic
+prepare2: prepare3 outputmakefile asm-generic
 
 prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h \
                    include/config/auto.conf
@@ -1138,43 +1100,6 @@ uapi-asm-generic:
 PHONY += prepare-objtool
 prepare-objtool: $(objtool_target)
 
-# Check for CONFIG flags that require compiler support. Abort the build
-# after .config has been processed, but before the kernel build starts.
-#
-# For security-sensitive CONFIG options, we don't want to fallback and/or
-# silently change which compiler flags will be used, since that leads to
-# producing kernels with different security feature characteristics
-# depending on the compiler used. (For example, "But I selected
-# CC_STACKPROTECTOR_STRONG! Why did it build with _REGULAR?!")
-PHONY += prepare-compiler-check
-prepare-compiler-check: FORCE
-# Make sure compiler supports requested stack protector flag.
-ifdef stackp-name
-  # Warn about CONFIG_CC_STACKPROTECTOR_AUTO having found no option.
-  ifeq ($(stackp-flag),)
-       @echo CONFIG_CC_STACKPROTECTOR_$(stackp-name): \
-                 Compiler does not support any known stack-protector >&2
-  else
-  # Fail if specifically requested stack protector is missing.
-  ifeq ($(call cc-option, $(stackp-flag)),)
-       @echo Cannot use CONFIG_CC_STACKPROTECTOR_$(stackp-name): \
-                 $(stackp-flag) not supported by compiler >&2 && exit 1
-  endif
-  endif
-endif
-# Make sure compiler does not have buggy stack-protector support. If a
-# specific stack-protector was requested, fail the build, otherwise warn.
-ifdef stackp-broken
-  ifeq ($(stackp-name),AUTO)
-       @echo CONFIG_CC_STACKPROTECTOR_$(stackp-name): \
-                  $(stackp-flag) available but compiler is broken: disabling >&2
-  else
-       @echo Cannot use CONFIG_CC_STACKPROTECTOR_$(stackp-name): \
-                  $(stackp-flag) available but compiler is broken >&2 && exit 1
-  endif
-endif
-       @:
-
 # Generate some files
 # ---------------------------------------------------------------------------
 
index 86ae4c4edd6fd63fc0e0da5e3e682734eb9fcaa1..1aa59063f1fd9b29ccec8339c614c42b09f176f2 100644 (file)
@@ -403,7 +403,16 @@ config SECCOMP_FILTER
          in terms of Berkeley Packet Filter programs which implement
          task-defined system call filtering polices.
 
-         See Documentation/prctl/seccomp_filter.txt for details.
+         See Documentation/userspace-api/seccomp_filter.rst for details.
+
+preferred-plugin-hostcc := $(if-success,[ $(gcc-version) -ge 40800 ],$(HOSTCXX),$(HOSTCC))
+
+config PLUGIN_HOSTCC
+       string
+       default "$(shell,$(srctree)/scripts/gcc-plugin.sh "$(preferred-plugin-hostcc)" "$(HOSTCXX)" "$(CC)")"
+       help
+         Host compiler used to build GCC plugins.  This can be $(HOSTCXX),
+         $(HOSTCC), or a null string if GCC plugin is unsupported.
 
 config HAVE_GCC_PLUGINS
        bool
@@ -414,7 +423,7 @@ config HAVE_GCC_PLUGINS
 menuconfig GCC_PLUGINS
        bool "GCC plugins"
        depends on HAVE_GCC_PLUGINS
-       depends on !COMPILE_TEST
+       depends on PLUGIN_HOSTCC != ""
        help
          GCC plugins are loadable modules that provide extra features to the
          compiler. They are useful for runtime instrumentation and static analysis.
@@ -424,7 +433,7 @@ menuconfig GCC_PLUGINS
 config GCC_PLUGIN_CYC_COMPLEXITY
        bool "Compute the cyclomatic complexity of a function" if EXPERT
        depends on GCC_PLUGINS
-       depends on !COMPILE_TEST
+       depends on !COMPILE_TEST        # too noisy
        help
          The complexity M of a function's control flow graph is defined as:
           M = E - N + 2P
@@ -484,6 +493,7 @@ config GCC_PLUGIN_STRUCTLEAK
 config GCC_PLUGIN_STRUCTLEAK_BYREF_ALL
        bool "Force initialize all struct type variables passed by reference"
        depends on GCC_PLUGIN_STRUCTLEAK
+       depends on !COMPILE_TEST
        help
          Zero initialize any struct type local variable that may be passed by
          reference without having been initialized.
@@ -491,7 +501,7 @@ config GCC_PLUGIN_STRUCTLEAK_BYREF_ALL
 config GCC_PLUGIN_STRUCTLEAK_VERBOSE
        bool "Report forcefully initialized variables"
        depends on GCC_PLUGIN_STRUCTLEAK
-       depends on !COMPILE_TEST
+       depends on !COMPILE_TEST        # too noisy
        help
          This option will cause a warning to be printed each time the
          structleak plugin finds a variable it thinks needs to be
@@ -531,7 +541,7 @@ config GCC_PLUGIN_RANDSTRUCT
 config GCC_PLUGIN_RANDSTRUCT_PERFORMANCE
        bool "Use cacheline-aware structure randomization"
        depends on GCC_PLUGIN_RANDSTRUCT
-       depends on !COMPILE_TEST
+       depends on !COMPILE_TEST        # do not reduce test coverage
        help
          If you say Y here, the RANDSTRUCT randomization will make a
          best effort at restricting randomization to cacheline-sized
@@ -539,17 +549,20 @@ config GCC_PLUGIN_RANDSTRUCT_PERFORMANCE
          in structures.  This reduces the performance hit of RANDSTRUCT
          at the cost of weakened randomization.
 
-config HAVE_CC_STACKPROTECTOR
+config HAVE_STACKPROTECTOR
        bool
        help
          An arch should select this symbol if:
-         - its compiler supports the -fstack-protector option
          - it has implemented a stack canary (e.g. __stack_chk_guard)
 
-choice
-       prompt "Stack Protector buffer overflow detection"
-       depends on HAVE_CC_STACKPROTECTOR
-       default CC_STACKPROTECTOR_AUTO
+config CC_HAS_STACKPROTECTOR_NONE
+       def_bool $(cc-option,-fno-stack-protector)
+
+config STACKPROTECTOR
+       bool "Stack Protector buffer overflow detection"
+       depends on HAVE_STACKPROTECTOR
+       depends on $(cc-option,-fstack-protector)
+       default y
        help
          This option turns on the "stack-protector" GCC feature. This
          feature puts, at the beginning of functions, a canary value on
@@ -559,14 +572,6 @@ choice
          overwrite the canary, which gets detected and the attack is then
          neutralized via a kernel panic.
 
-config CC_STACKPROTECTOR_NONE
-       bool "None"
-       help
-         Disable "stack-protector" GCC feature.
-
-config CC_STACKPROTECTOR_REGULAR
-       bool "Regular"
-       help
          Functions will have the stack-protector canary logic added if they
          have an 8-byte or larger character array on the stack.
 
@@ -577,8 +582,11 @@ config CC_STACKPROTECTOR_REGULAR
          about 3% of all kernel functions, which increases kernel code size
          by about 0.3%.
 
-config CC_STACKPROTECTOR_STRONG
-       bool "Strong"
+config STACKPROTECTOR_STRONG
+       bool "Strong Stack Protector"
+       depends on STACKPROTECTOR
+       depends on $(cc-option,-fstack-protector-strong)
+       default y
        help
          Functions will have the stack-protector canary logic added in any
          of the following conditions:
@@ -596,14 +604,6 @@ config CC_STACKPROTECTOR_STRONG
          about 20% of all kernel functions, which increases the kernel code
          size by about 2%.
 
-config CC_STACKPROTECTOR_AUTO
-       bool "Automatic"
-       help
-         If the compiler supports it, the best available stack-protector
-         option will be chosen.
-
-endchoice
-
 config HAVE_ARCH_WITHIN_STACK_FRAMES
        bool
        help
index 94d222545920dc84548c89df38f2f9cdf944d6bc..54eeb8d00bc62a9f818aa9a833cbc15e7a1d9324 100644 (file)
@@ -8,9 +8,10 @@ config ARM
        select ARCH_HAS_DEVMEM_IS_ALLOWED
        select ARCH_HAS_ELF_RANDOMIZE
        select ARCH_HAS_FORTIFY_SOURCE
+       select ARCH_HAS_KCOV
        select ARCH_HAS_PTE_SPECIAL if ARM_LPAE
-       select ARCH_HAS_SET_MEMORY
        select ARCH_HAS_PHYS_TO_DMA
+       select ARCH_HAS_SET_MEMORY
        select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
        select ARCH_HAS_STRICT_MODULE_RWX if MMU
        select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
@@ -57,7 +58,6 @@ config ARM
        select HAVE_ARCH_TRACEHOOK
        select HAVE_ARM_SMCCC if CPU_V7
        select HAVE_EBPF_JIT if !CPU_ENDIAN_BE32
-       select HAVE_CC_STACKPROTECTOR
        select HAVE_CONTEXT_TRACKING
        select HAVE_C_RECORDMCOUNT
        select HAVE_DEBUG_KMEMLEAK
@@ -92,6 +92,7 @@ config ARM
        select HAVE_RCU_TABLE_FREE if (SMP && ARM_LPAE)
        select HAVE_REGS_AND_STACK_ACCESS_API
        select HAVE_RSEQ
+       select HAVE_STACKPROTECTOR
        select HAVE_SYSCALL_TRACEPOINTS
        select HAVE_UID16
        select HAVE_VIRT_CPU_ACCOUNTING_GEN
@@ -1301,7 +1302,7 @@ config SMP
          will run faster if you say N here.
 
          See also <file:Documentation/x86/i386/IO-APIC.txt>,
-         <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO available at
+         <file:Documentation/lockup-watchdogs.txt> and the SMP-HOWTO available at
          <http://tldp.org/HOWTO/SMP-HOWTO.html>.
 
          If you don't know what to do here, say N.
@@ -1463,7 +1464,7 @@ config ARM_PSCI
 config ARCH_NR_GPIO
        int
        default 2048 if ARCH_SOCFPGA
-       default 1024 if ARCH_BRCMSTB || ARCH_SHMOBILE || ARCH_TEGRA || \
+       default 1024 if ARCH_BRCMSTB || ARCH_RENESAS || ARCH_TEGRA || \
                ARCH_ZYNQ
        default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5 || \
                SOC_DRA7XX || ARCH_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210
index 199ebc1c4538e66700c8e8e2f49d0f5fbfb4c44b..693f84392f1ba0170cb8fb870b2ee9b8aa073d88 100644 (file)
@@ -942,6 +942,13 @@ choice
                  via SCIF0 on Renesas RZ/G1M (R8A7743), R-Car H2 (R8A7790),
                  M2-W (R8A7791), V2H (R8A7792), or M2-N (R8A7793).
 
+       config DEBUG_RCAR_GEN2_SCIF1
+               bool "Kernel low-level debugging messages via SCIF1 on R8A77470"
+               depends on ARCH_R8A77470
+               help
+                 Say Y here if you want kernel low-level debugging support
+                 via SCIF1 on Renesas RZ/G1C (R8A77470).
+
        config DEBUG_RCAR_GEN2_SCIF2
                bool "Kernel low-level debugging messages via SCIF2 on R8A7794"
                depends on ARCH_R8A7794
@@ -1495,6 +1502,7 @@ config DEBUG_LL_INCLUDE
        default "debug/renesas-scif.S" if DEBUG_RCAR_GEN1_SCIF0
        default "debug/renesas-scif.S" if DEBUG_RCAR_GEN1_SCIF2
        default "debug/renesas-scif.S" if DEBUG_RCAR_GEN2_SCIF0
+       default "debug/renesas-scif.S" if DEBUG_RCAR_GEN2_SCIF1
        default "debug/renesas-scif.S" if DEBUG_RCAR_GEN2_SCIF2
        default "debug/renesas-scif.S" if DEBUG_RCAR_GEN2_SCIF4
        default "debug/renesas-scif.S" if DEBUG_RMOBILE_SCIFA0
@@ -1617,6 +1625,7 @@ config DEBUG_UART_PHYS
        default 0xe6c80000 if DEBUG_RMOBILE_SCIFA4
        default 0xe6e58000 if DEBUG_RCAR_GEN2_SCIF2
        default 0xe6e60000 if DEBUG_RCAR_GEN2_SCIF0
+       default 0xe6e68000 if DEBUG_RCAR_GEN2_SCIF1
        default 0xe6ee0000 if DEBUG_RCAR_GEN2_SCIF4
        default 0xe8008000 if DEBUG_R7S72100_SCIF2
        default 0xf0000be0 if ARCH_EBSA110
@@ -1651,8 +1660,8 @@ config DEBUG_UART_PHYS
                DEBUG_NETX_UART || \
                DEBUG_QCOM_UARTDM || DEBUG_R7S72100_SCIF2 || \
                DEBUG_RCAR_GEN1_SCIF0 || DEBUG_RCAR_GEN1_SCIF2 || \
-               DEBUG_RCAR_GEN2_SCIF0 || DEBUG_RCAR_GEN2_SCIF2 || \
-               DEBUG_RCAR_GEN2_SCIF4 || \
+               DEBUG_RCAR_GEN2_SCIF0 || DEBUG_RCAR_GEN2_SCIF1 || \
+               DEBUG_RCAR_GEN2_SCIF2 || DEBUG_RCAR_GEN2_SCIF4 || \
                DEBUG_RMOBILE_SCIFA0 || DEBUG_RMOBILE_SCIFA1 || \
                DEBUG_RMOBILE_SCIFA4 || DEBUG_S3C24XX_UART || \
                DEBUG_S3C64XX_UART || \
index 1dc4045e1af65218eea29f5392d5d8ffab128c0d..fc26c3d7b9b66a1ebc52a6761441f7a1da9fb422 100644 (file)
@@ -212,7 +212,7 @@ machine-$(CONFIG_ARCH_S3C24XX)              += s3c24xx
 machine-$(CONFIG_ARCH_S3C64XX)         += s3c64xx
 machine-$(CONFIG_ARCH_S5PV210)         += s5pv210
 machine-$(CONFIG_ARCH_SA1100)          += sa1100
-machine-$(CONFIG_ARCH_SHMOBILE)        += shmobile
+machine-$(CONFIG_ARCH_RENESAS)         += shmobile
 machine-$(CONFIG_ARCH_SIRF)            += prima2
 machine-$(CONFIG_ARCH_SOCFPGA)         += socfpga
 machine-$(CONFIG_ARCH_STI)             += sti
index a3c5fbcad4abf08bebc2e7303309eea156bd6b01..1f5a5ffe7fcf84b5da64bc74747c50384f5bfeea 100644 (file)
@@ -25,6 +25,9 @@ endif
 
 GCOV_PROFILE           := n
 
+# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
+KCOV_INSTRUMENT                := n
+
 #
 # Architecture dependencies
 #
index 7e24249578091c0456459bb32a435dc0abcd6cdf..37a3de760d40f4f27ad4cdbad5ff41973bdda75c 100644 (file)
@@ -75,6 +75,7 @@ dtb-$(CONFIG_ARCH_BCM2835) += \
        bcm2835-rpi-a-plus.dtb \
        bcm2836-rpi-2-b.dtb \
        bcm2837-rpi-3-b.dtb \
+       bcm2837-rpi-3-b-plus.dtb \
        bcm2835-rpi-zero.dtb \
        bcm2835-rpi-zero-w.dtb
 dtb-$(CONFIG_ARCH_BCM_5301X) += \
@@ -102,8 +103,10 @@ dtb-$(CONFIG_ARCH_BCM_5301X) += \
        bcm47094-dlink-dir-885l.dtb \
        bcm47094-linksys-panamera.dtb \
        bcm47094-luxul-abr-4500.dtb \
+       bcm47094-luxul-xap-1610.dtb \
        bcm47094-luxul-xbr-4500.dtb \
        bcm47094-luxul-xwr-3100.dtb \
+       bcm47094-luxul-xwr-3150-v1.dtb \
        bcm47094-netgear-r8500.dtb \
        bcm94708.dtb \
        bcm94709.dtb \
@@ -140,6 +143,7 @@ dtb-$(CONFIG_ARCH_BCM_NSP) += \
 dtb-$(CONFIG_ARCH_BERLIN) += \
        berlin2-sony-nsz-gs7.dtb \
        berlin2cd-google-chromecast.dtb \
+       berlin2cd-valve-steamlink.dtb \
        berlin2q-marvell-dmp.dtb
 dtb-$(CONFIG_ARCH_BRCMSTB) += \
        bcm7445-bcm97445svmb.dtb
@@ -190,8 +194,6 @@ dtb-$(CONFIG_ARCH_EXYNOS5) += \
        exynos5422-odroidxu3.dtb \
        exynos5422-odroidxu3-lite.dtb \
        exynos5422-odroidxu4.dtb \
-       exynos5440-sd5v1.dtb \
-       exynos5440-ssdk5440.dtb \
        exynos5800-peach-pi.dtb
 dtb-$(CONFIG_ARCH_GEMINI) += \
        gemini-dlink-dir-685.dtb \
@@ -312,14 +314,14 @@ dtb-$(CONFIG_ARCH_NPCM7XX) += \
 dtb-$(CONFIG_MACH_MESON6) += \
        meson6-atv1200.dtb
 dtb-$(CONFIG_MACH_MESON8) += \
-       meson8-minix-neo-x8.dtb
+       meson8-minix-neo-x8.dtb \
+       meson8b-mxq.dtb \
+       meson8b-odroidc1.dtb \
+       meson8m2-mxiii-plus.dtb
 dtb-$(CONFIG_ARCH_MMP) += \
        pxa168-aspenite.dtb \
        pxa910-dkb.dtb \
        mmp2-brownstone.dtb
-dtb-$(CONFIG_MACH_MESON8B) += \
-       meson8b-mxq.dtb \
-       meson8b-odroidc1.dtb
 dtb-$(CONFIG_ARCH_MPS2) += \
        mps2-an385.dtb \
        mps2-an399.dtb
@@ -399,6 +401,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
        imx6dl-hummingboard2-som-v15.dtb \
        imx6dl-icore.dtb \
        imx6dl-icore-rqs.dtb \
+       imx6dl-mamoj.dtb \
        imx6dl-nit6xlite.dtb \
        imx6dl-nitrogen6x.dtb \
        imx6dl-phytec-mira-rdk-nand.dtb \
@@ -439,6 +442,7 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
        imx6q-cubox-i-emmc-som-v15.dtb \
        imx6q-cubox-i-som-v15.dtb \
        imx6q-dfi-fs700-m60.dtb \
+       imx6q-dhcom-pdk2.dtb \
        imx6q-display5-tianma-tm070-1280x768.dtb \
        imx6q-dmo-edmqmx6.dtb \
        imx6q-dms-ba16.dtb \
@@ -463,9 +467,11 @@ dtb-$(CONFIG_SOC_IMX6Q) += \
        imx6q-hummingboard2-emmc-som-v15.dtb \
        imx6q-hummingboard2-som-v15.dtb \
        imx6q-icore.dtb \
+       imx6q-icore-mipi.dtb \
        imx6q-icore-ofcap10.dtb \
        imx6q-icore-ofcap12.dtb \
        imx6q-icore-rqs.dtb \
+       imx6q-kp-tpc.dtb \
        imx6q-marsboard.dtb \
        imx6q-mccmon6.dtb \
        imx6q-nitrogen6x.dtb \
@@ -688,6 +694,7 @@ dtb-$(CONFIG_SOC_AM33XX) += \
        am335x-pdu001.dtb \
        am335x-pepper.dtb \
        am335x-phycore-rdk.dtb \
+       am335x-pocketbeagle.dtb \
        am335x-shc.dtb \
        am335x-sbc-t335.dtb \
        am335x-sl50.dtb \
@@ -760,12 +767,17 @@ dtb-$(CONFIG_ARCH_QCOM) += \
        qcom-apq8084-ifc6540.dtb \
        qcom-apq8084-mtp.dtb \
        qcom-ipq4019-ap.dk01.1-c1.dtb \
+       qcom-ipq4019-ap.dk04.1-c1.dtb \
+       qcom-ipq4019-ap.dk04.1-c3.dtb \
+       qcom-ipq4019-ap.dk07.1-c1.dtb \
+       qcom-ipq4019-ap.dk07.1-c2.dtb \
        qcom-ipq8064-ap148.dtb \
        qcom-msm8660-surf.dtb \
        qcom-msm8960-cdp.dtb \
        qcom-msm8974-fairphone-fp2.dtb \
        qcom-msm8974-lge-nexus5-hammerhead.dtb \
        qcom-msm8974-samsung-klte.dtb \
+       qcom-msm8974-sony-xperia-amami.dtb \
        qcom-msm8974-sony-xperia-castor.dtb \
        qcom-msm8974-sony-xperia-honami.dtb \
        qcom-mdm9615-wp8548-mangoh-green.dtb
@@ -795,6 +807,7 @@ dtb-$(CONFIG_ARCH_RENESAS) += \
        r8a7745-iwg22d-sodimm.dtb \
        r8a7745-iwg22d-sodimm-dbhd-ca.dtb \
        r8a7745-sk-rzg1e.dtb \
+       r8a77470-iwg23s-sbc.dtb \
        r8a7778-bockw.dtb \
        r8a7779-marzen.dtb \
        r8a7790-lager.dtb \
@@ -959,6 +972,7 @@ dtb-$(CONFIG_MACH_SUN7I) += \
        sun7i-a20-m3.dtb \
        sun7i-a20-mk808c.dtb \
        sun7i-a20-olimex-som-evb.dtb \
+       sun7i-a20-olimex-som-evb-emmc.dtb \
        sun7i-a20-olimex-som204-evb.dtb \
        sun7i-a20-olimex-som204-evb-emmc.dtb \
        sun7i-a20-olinuxino-lime.dtb \
@@ -992,8 +1006,9 @@ dtb-$(CONFIG_MACH_SUN8I) += \
        sun8i-a83t-bananapi-m3.dtb \
        sun8i-a83t-cubietruck-plus.dtb \
        sun8i-a83t-tbs-a711.dtb \
-       sun8i-h2-plus-orangepi-r1.dtb \
        sun8i-h2-plus-bananapi-m2-zero.dtb \
+       sun8i-h2-plus-libretech-all-h3-cc.dtb \
+       sun8i-h2-plus-orangepi-r1.dtb \
        sun8i-h2-plus-orangepi-zero.dtb \
        sun8i-h3-bananapi-m2-plus.dtb \
        sun8i-h3-beelink-x2.dtb \
@@ -1010,6 +1025,8 @@ dtb-$(CONFIG_MACH_SUN8I) += \
        sun8i-h3-orangepi-plus.dtb \
        sun8i-h3-orangepi-plus2e.dtb \
        sun8i-r16-bananapi-m2m.dtb \
+       sun8i-r16-nintendo-nes-classic.dtb \
+       sun8i-r16-nintendo-super-nes-classic.dtb \
        sun8i-r16-parrot.dtb \
        sun8i-r40-bananapi-m2-ultra.dtb \
        sun8i-v3s-licheepi-zero.dtb \
@@ -1054,9 +1071,7 @@ dtb-$(CONFIG_ARCH_U8500) += \
        ste-hrefprev60-stuib.dtb \
        ste-hrefprev60-tvk.dtb \
        ste-hrefv60plus-stuib.dtb \
-       ste-hrefv60plus-tvk.dtb \
-       ste-ccu8540.dtb \
-       ste-ccu9540.dtb
+       ste-hrefv60plus-tvk.dtb
 dtb-$(CONFIG_ARCH_UNIPHIER) += \
        uniphier-ld4-ref.dtb \
        uniphier-ld6b-ref.dtb \
@@ -1150,6 +1165,9 @@ dtb-$(CONFIG_ARCH_MEDIATEK) += \
        mt6580-evbp1.dtb \
        mt6589-aquaris5.dtb \
        mt6592-evb.dtb \
+       mt7623a-rfb-emmc.dtb \
+       mt7623a-rfb-nand.dtb \
+       mt7623n-rfb-emmc.dtb \
        mt7623n-rfb-nand.dtb \
        mt7623n-bananapi-bpi-r2.dtb \
        mt8127-moose.dtb \
@@ -1158,8 +1176,11 @@ dtb-$(CONFIG_ARCH_ZX) += zx296702-ad1.dtb
 dtb-$(CONFIG_ARCH_ASPEED) += \
        aspeed-ast2500-evb.dtb \
        aspeed-bmc-arm-centriq2400-rep.dtb \
+       aspeed-bmc-intel-s2600wf.dtb \
+       aspeed-bmc-opp-lanyang.dtb \
        aspeed-bmc-opp-palmetto.dtb \
        aspeed-bmc-opp-romulus.dtb \
        aspeed-bmc-opp-witherspoon.dtb \
        aspeed-bmc-opp-zaius.dtb \
+       aspeed-bmc-portwell-neptune.dtb \
        aspeed-bmc-quanta-q71l.dtb
index 46df1b22022c75d811fe7d3af920a3fef95f6af6..1b215c425c575ffe71870acab2101715b0b62a63 100644 (file)
@@ -85,7 +85,7 @@ tca6416: gpio@20 {
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&gpio0>;
-               interrupts = <20 GPIO_ACTIVE_LOW>;
+               interrupts = <20 IRQ_TYPE_EDGE_RISING>;
                pinctrl-names = "default";
                pinctrl-0 = <&tca6416_pins>;
        };
index 5d56355ba04067acb1f772f3e79048fb21cd87f3..832ead864dc5617b8fc395704f069ea1030964fd 100644 (file)
@@ -94,7 +94,7 @@ tca6416: gpio@20 {
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&gpio0>;
-               interrupts = <20 GPIO_ACTIVE_LOW>;
+               interrupts = <20 IRQ_TYPE_EDGE_RISING>;
                pinctrl-names = "default";
                pinctrl-0 = <&tca6416_pins>;
        };
index ec6052c521ef33d085f701632e95961caf97b667..ed7a5a3daa423cf6c935a2c25d56845949e0d9fd 100644 (file)
@@ -249,7 +249,7 @@ tps: tps@2d {
                gpio-controller;
                #gpio-cells = <2>;
                interrupt-parent = <&gpio1>;
-               interrupts = <28 GPIO_ACTIVE_LOW>;
+               interrupts = <28 IRQ_TYPE_EDGE_RISING>;
                pinctrl-names = "default";
                pinctrl-0 = <&tps65910_pins>;
        };
index e67b4d65c8d09e69b5162481f323d78ca9a7cac0..f9e8667f5886db82027643130ca87b58cbea8f62 100644 (file)
@@ -161,7 +161,14 @@ AM33XX_IOPAD(0x94c, PIN_INPUT_PULLDOWN | MUX_MODE7)
 
        mmc1_pins: pinmux_mmc1_pins {
                pinctrl-single,pins = <
-                       AM33XX_IOPAD(0x960, PIN_INPUT | MUX_MODE7) /* GPIO0_6 */
+                       AM33XX_IOPAD(0x960, PIN_INPUT | MUX_MODE7)              /* spio0_cs1.gpio0_6 */
+                       AM33XX_IOPAD(0x8fc, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat0.mmc0_dat0 */
+                       AM33XX_IOPAD(0x8f8, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat1.mmc0_dat1 */
+                       AM33XX_IOPAD(0x8f4, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat2.mmc0_dat2 */
+                       AM33XX_IOPAD(0x8f0, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat3.mmc0_dat3 */
+                       AM33XX_IOPAD(0x904, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_cmd.mmc0_cmd */
+                       AM33XX_IOPAD(0x900, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_clk.mmc0_clk */
+                       AM33XX_IOPAD(0x9a0, PIN_INPUT | MUX_MODE4)              /* mcasp0_aclkr.mmc0_sdwp */
                >;
        };
 
index 58baee158e64d2fad4e11e90e03a9c9b7516020c..7bcd72691f06d942a74e23992d50b6925e268111 100644 (file)
@@ -364,7 +364,7 @@ mpu9250@68 {
                compatible = "invensense,mpu9250";
                reg = <0x68>;
                interrupt-parent = <&gpio3>;
-               interrupts = <21 GPIO_ACTIVE_LOW>;
+               interrupts = <21 IRQ_TYPE_EDGE_RISING>;
                i2c-gate {
                        #address-cells = <1>;
                        #size-cells = <0>;
index fee6b3ee17412638a9ac67d29f9773dd22100c95..1356fd6f8da3f8d4b8643ab2686dc0c6181a4f52 100644 (file)
@@ -303,7 +303,14 @@ AM33XX_IOPAD(0x94c, PIN_INPUT_PULLDOWN | MUX_MODE7)
 
        mmc1_pins: pinmux_mmc1_pins {
                pinctrl-single,pins = <
-                       AM33XX_IOPAD(0x960, PIN_INPUT | MUX_MODE7) /* spi0_cs1.gpio0_6 */
+                       AM33XX_IOPAD(0x960, PIN_INPUT | MUX_MODE7)              /* spi0_cs1.gpio0_6 */
+                       AM33XX_IOPAD(0x8fc, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat0.mmc0_dat0 */
+                       AM33XX_IOPAD(0x8f8, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat1.mmc0_dat1 */
+                       AM33XX_IOPAD(0x8f4, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat2.mmc0_dat2 */
+                       AM33XX_IOPAD(0x8f0, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat3.mmc0_dat3 */
+                       AM33XX_IOPAD(0x904, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_cmd.mmc0_cmd */
+                       AM33XX_IOPAD(0x900, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_clk.mmc0_clk */
+                       AM33XX_IOPAD(0x9a0, PIN_INPUT | MUX_MODE4)              /* mcasp0_aclkr.mmc0_sdwp */
                >;
        };
 
index fa608cd5dc14dcc6d1101c6675d54ed4c1206ee6..0c096a795e3703651ec8127042610186a121f487 100644 (file)
@@ -137,7 +137,7 @@ switch4 {
                };
        };
 
-       backlight {
+       lcd_bl: backlight {
                compatible = "pwm-backlight";
                pwms = <&ecap2 0 50000 PWM_POLARITY_INVERTED>;
                brightness-levels = <0 58 61 66 75 90 125 170 255>;
@@ -172,6 +172,7 @@ panel {
                pinctrl-names = "default", "sleep";
                pinctrl-0 = <&lcd_pins_default>;
                pinctrl-1 = <&lcd_pins_sleep>;
+               backlight = <&lcd_bl>;
                status = "okay";
                panel-info {
                        ac-bias         = <255>;
@@ -399,7 +400,14 @@ AM33XX_IOPAD(0x94c, PIN_INPUT_PULLDOWN | MUX_MODE7)
 
        mmc1_pins: pinmux_mmc1_pins {
                pinctrl-single,pins = <
-                       AM33XX_IOPAD(0x960, PIN_INPUT | MUX_MODE7) /* spi0_cs1.gpio0_6 */
+                       AM33XX_IOPAD(0x960, PIN_INPUT | MUX_MODE7)              /* spi0_cs1.gpio0_6 */
+                       AM33XX_IOPAD(0x8fc, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat0.mmc0_dat0 */
+                       AM33XX_IOPAD(0x8f8, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat1.mmc0_dat1 */
+                       AM33XX_IOPAD(0x8f4, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat2.mmc0_dat2 */
+                       AM33XX_IOPAD(0x8f0, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_dat3.mmc0_dat3 */
+                       AM33XX_IOPAD(0x904, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_cmd.mmc0_cmd */
+                       AM33XX_IOPAD(0x900, PIN_INPUT_PULLUP | MUX_MODE0)       /* mmc0_clk.mmc0_clk */
+                       AM33XX_IOPAD(0x9a0, PIN_INPUT | MUX_MODE4)              /* mcasp0_aclkr.mmc0_sdwp */
                >;
        };
 
diff --git a/arch/arm/boot/dts/am335x-osd335x-common.dtsi b/arch/arm/boot/dts/am335x-osd335x-common.dtsi
new file mode 100644 (file)
index 0000000..f8ff473
--- /dev/null
@@ -0,0 +1,124 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Author: Robert Nelson <robertcnelson@gmail.com>
+ */
+
+/ {
+       cpus {
+               cpu@0 {
+                       cpu0-supply = <&dcdc2_reg>;
+               };
+       };
+
+       memory@80000000 {
+               device_type = "memory";
+               reg = <0x80000000 0x20000000>; /* 512 MB */
+       };
+};
+
+&cpu0_opp_table {
+       /*
+       * Octavo Systems:
+       * The EFUSE_SMA register is not programmed for any of the AM335x wafers
+       * we get and we are not programming them during our production test.
+       * Therefore, from a DEVICE_ID revision point of view, the silicon looks
+       * like it is Revision 2.1.  However, from an EFUSE_SMA point of view for
+       * the HW OPP table, the silicon looks like it is Revision 1.0 (ie the
+       * EFUSE_SMA register reads as all zeros).
+       */
+       oppnitro-1000000000 {
+               opp-supported-hw = <0x06 0x0100>;
+       };
+};
+
+&am33xx_pinmux {
+       i2c0_pins: pinmux-i2c0-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x988, PIN_INPUT_PULLUP | MUX_MODE0)       /* (C17) I2C0_SDA.I2C0_SDA */
+                       AM33XX_IOPAD(0x98c, PIN_INPUT_PULLUP | MUX_MODE0)       /* (C16) I2C0_SCL.I2C0_SCL */
+               >;
+       };
+};
+
+&i2c0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c0_pins>;
+
+       status = "okay";
+       clock-frequency = <400000>;
+
+       tps: tps@24 {
+               reg = <0x24>;
+       };
+};
+
+/include/ "tps65217.dtsi"
+
+&tps {
+       interrupts = <7>; /* NMI */
+       interrupt-parent = <&intc>;
+
+       ti,pmic-shutdown-controller;
+
+       pwrbutton {
+               interrupts = <2>;
+               status = "okay";
+       };
+
+       regulators {
+               dcdc1_reg: regulator@0 {
+                       regulator-name = "vdds_dpr";
+                       regulator-always-on;
+               };
+
+               dcdc2_reg: regulator@1 {
+                       /* VDD_MPU voltage limits 0.95V - 1.26V with +/-4% tolerance */
+                       regulator-name = "vdd_mpu";
+                       regulator-min-microvolt = <925000>;
+                       regulator-max-microvolt = <1351500>;
+                       regulator-boot-on;
+                       regulator-always-on;
+               };
+
+               dcdc3_reg: regulator@2 {
+                       /* VDD_CORE voltage limits 0.95V - 1.1V with +/-4% tolerance */
+                       regulator-name = "vdd_core";
+                       regulator-min-microvolt = <925000>;
+                       regulator-max-microvolt = <1150000>;
+                       regulator-boot-on;
+                       regulator-always-on;
+               };
+
+               ldo1_reg: regulator@3 {
+                       regulator-name = "vio,vrtc,vdds";
+                       regulator-always-on;
+               };
+
+               ldo2_reg: regulator@4 {
+                       regulator-name = "vdd_3v3aux";
+                       regulator-always-on;
+               };
+
+               ldo3_reg: regulator@5 {
+                       regulator-name = "vdd_1v8";
+                       regulator-min-microvolt = <1800000>;
+                       regulator-max-microvolt = <1800000>;
+                       regulator-always-on;
+               };
+
+               ldo4_reg: regulator@6 {
+                       regulator-name = "vdd_3v3a";
+                       regulator-always-on;
+               };
+       };
+};
+
+&aes {
+       status = "okay";
+};
+
+&sham {
+       status = "okay";
+};
diff --git a/arch/arm/boot/dts/am335x-pocketbeagle.dts b/arch/arm/boot/dts/am335x-pocketbeagle.dts
new file mode 100644 (file)
index 0000000..62fe5ca
--- /dev/null
@@ -0,0 +1,237 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * Author: Robert Nelson <robertcnelson@gmail.com>
+ */
+/dts-v1/;
+
+#include "am33xx.dtsi"
+#include "am335x-osd335x-common.dtsi"
+
+/ {
+       model = "TI AM335x PocketBeagle";
+       compatible = "ti,am335x-pocketbeagle", "ti,am335x-bone", "ti,am33xx";
+
+       chosen {
+               stdout-path = &uart0;
+       };
+
+       leds {
+               pinctrl-names = "default";
+               pinctrl-0 = <&usr_leds_pins>;
+
+               compatible = "gpio-leds";
+
+               usr0 {
+                       label = "beaglebone:green:usr0";
+                       gpios = <&gpio1 21 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "heartbeat";
+                       default-state = "off";
+               };
+
+               usr1 {
+                       label = "beaglebone:green:usr1";
+                       gpios = <&gpio1 22 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "mmc0";
+                       default-state = "off";
+               };
+
+               usr2 {
+                       label = "beaglebone:green:usr2";
+                       gpios = <&gpio1 23 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "cpu0";
+                       default-state = "off";
+               };
+
+               usr3 {
+                       label = "beaglebone:green:usr3";
+                       gpios = <&gpio1 24 GPIO_ACTIVE_HIGH>;
+                       default-state = "off";
+               };
+       };
+
+       vmmcsd_fixed: fixedregulator0 {
+               compatible = "regulator-fixed";
+               regulator-name = "vmmcsd_fixed";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+       };
+};
+
+&am33xx_pinmux {
+       i2c2_pins: pinmux-i2c2-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x97c, PIN_INPUT_PULLUP | MUX_MODE3)       /* (D17) uart1_rtsn.I2C2_SCL */
+                       AM33XX_IOPAD(0x978, PIN_INPUT_PULLUP | MUX_MODE3)       /* (D18) uart1_ctsn.I2C2_SDA */
+               >;
+       };
+
+       ehrpwm0_pins: pinmux-ehrpwm0-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x990, PIN_OUTPUT_PULLDOWN | MUX_MODE1)    /* (A13) mcasp0_aclkx.ehrpwm0A */
+               >;
+       };
+
+       ehrpwm1_pins: pinmux-ehrpwm1-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x848, PIN_OUTPUT_PULLDOWN | MUX_MODE6)    /* (U14) gpmc_a2.ehrpwm1A */
+               >;
+       };
+
+       mmc0_pins: pinmux-mmc0-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x960, PIN_INPUT | MUX_MODE7)              /* (C15) spi0_cs1.gpio0[6] */
+                       AM33XX_IOPAD(0x8fc, PIN_INPUT_PULLUP | MUX_MODE0)       /* (G16) mmc0_dat0.mmc0_dat0 */
+                       AM33XX_IOPAD(0x8f8, PIN_INPUT_PULLUP | MUX_MODE0)       /* (G15) mmc0_dat1.mmc0_dat1 */
+                       AM33XX_IOPAD(0x8f4, PIN_INPUT_PULLUP | MUX_MODE0)       /* (F18) mmc0_dat2.mmc0_dat2 */
+                       AM33XX_IOPAD(0x8f0, PIN_INPUT_PULLUP | MUX_MODE0)       /* (F17) mmc0_dat3.mmc0_dat3 */
+                       AM33XX_IOPAD(0x904, PIN_INPUT_PULLUP | MUX_MODE0)       /* (G18) mmc0_cmd.mmc0_cmd */
+                       AM33XX_IOPAD(0x900, PIN_INPUT_PULLUP | MUX_MODE0)       /* (G17) mmc0_clk.mmc0_clk */
+                       AM33XX_IOPAD(0x9a0, PIN_INPUT | MUX_MODE4)              /* (B12) mcasp0_aclkr.mmc0_sdwp */
+               >;
+       };
+
+       spi0_pins: pinmux-spi0-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x950, PIN_INPUT_PULLUP | MUX_MODE0)       /* (A17) spi0_sclk.spi0_sclk */
+                       AM33XX_IOPAD(0x954, PIN_INPUT_PULLUP | MUX_MODE0)       /* (B17) spi0_d0.spi0_d0 */
+                       AM33XX_IOPAD(0x958, PIN_INPUT_PULLUP | MUX_MODE0)       /* (B16) spi0_d1.spi0_d1 */
+                       AM33XX_IOPAD(0x95c, PIN_INPUT_PULLUP | MUX_MODE0)       /* (A16) spi0_cs0.spi0_cs0 */
+               >;
+       };
+
+       spi1_pins: pinmux-spi1-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x964, PIN_INPUT_PULLUP | MUX_MODE4)       /* (C18) eCAP0_in_PWM0_out.spi1_sclk */
+                       AM33XX_IOPAD(0x968, PIN_INPUT_PULLUP | MUX_MODE4)       /* (E18) uart0_ctsn.spi1_d0 */
+                       AM33XX_IOPAD(0x96c, PIN_INPUT_PULLUP | MUX_MODE4)       /* (E17) uart0_rtsn.spi1_d1 */
+                       AM33XX_IOPAD(0x9b0, PIN_INPUT_PULLUP | MUX_MODE4)       /* (A15) xdma_event_intr0.spi1_cs1 */
+               >;
+       };
+
+       usr_leds_pins: pinmux-usr-leds-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x854, PIN_OUTPUT | MUX_MODE7)             /* (V15) gpmc_a5.gpio1[21] - USR_LED_0 */
+                       AM33XX_IOPAD(0x858, PIN_OUTPUT | MUX_MODE7)             /* (U15) gpmc_a6.gpio1[22] - USR_LED_1 */
+                       AM33XX_IOPAD(0x85c, PIN_OUTPUT | MUX_MODE7)             /* (T15) gpmc_a7.gpio1[23] - USR_LED_2 */
+                       AM33XX_IOPAD(0x860, PIN_OUTPUT | MUX_MODE7)             /* (V16) gpmc_a8.gpio1[24] - USR_LED_3 */
+               >;
+       };
+
+       uart0_pins: pinmux-uart0-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x970, PIN_INPUT_PULLUP | MUX_MODE0)       /* (E15) uart0_rxd.uart0_rxd */
+                       AM33XX_IOPAD(0x974, PIN_OUTPUT_PULLDOWN | MUX_MODE0)    /* (E16) uart0_txd.uart0_txd */
+               >;
+       };
+
+       uart4_pins: pinmux-uart4-pins {
+               pinctrl-single,pins = <
+                       AM33XX_IOPAD(0x870, PIN_INPUT_PULLUP | MUX_MODE6)       /* (T17) gpmc_wait0.uart4_rxd */
+                       AM33XX_IOPAD(0x874, PIN_OUTPUT_PULLDOWN | MUX_MODE6)    /* (U17) gpmc_wpn.uart4_txd */
+               >;
+       };
+};
+
+&epwmss0 {
+       status = "okay";
+};
+
+&ehrpwm0 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&ehrpwm0_pins>;
+};
+
+&epwmss1 {
+       status = "okay";
+};
+
+&ehrpwm1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&ehrpwm1_pins>;
+};
+
+&i2c0 {
+       eeprom: eeprom@50 {
+               compatible = "atmel,24c256";
+               reg = <0x50>;
+       };
+};
+
+&i2c2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c2_pins>;
+
+       status = "okay";
+       clock-frequency = <400000>;
+};
+
+&mmc1 {
+       status = "okay";
+       vmmc-supply = <&vmmcsd_fixed>;
+       bus-width = <4>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&mmc0_pins>;
+       cd-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
+};
+
+&rtc {
+       system-power-controller;
+};
+
+&tscadc {
+       status = "okay";
+       adc {
+               ti,adc-channels = <0 1 2 3 4 5 6 7>;
+               ti,chan-step-avg = <16 16 16 16 16 16 16 16>;
+               ti,chan-step-opendelay = <0x98 0x98 0x98 0x98 0x98 0x98 0x98 0x98>;
+               ti,chan-step-sampledelay = <0x0 0x0 0x0 0x0 0x0 0x0 0x0 0x0>;
+       };
+};
+
+&uart0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart0_pins>;
+
+       status = "okay";
+};
+
+&uart4 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart4_pins>;
+
+       status = "okay";
+};
+
+&usb {
+       status = "okay";
+};
+
+&usb_ctrl_mod {
+       status = "okay";
+};
+
+&usb0_phy {
+       status = "okay";
+};
+
+&usb0 {
+       status = "okay";
+       dr_mode = "otg";
+};
+
+&usb1_phy {
+       status = "okay";
+};
+
+&usb1 {
+       status = "okay";
+       dr_mode = "host";
+};
+
+&cppi41dma  {
+       status = "okay";
+};
index 0e4a125f78e3f28dfa13bf480c4fe4564451916b..98aadb0f81c5e04153f0ac4ad4f5fdea1bd0bf2f 100644 (file)
@@ -8,11 +8,17 @@
 /dts-v1/;
 
 #include "am3517.dtsi"
+#include "am3517-som.dtsi"
+#include <dt-bindings/input/input.h>
 
 / {
        model = "TI AM3517 EVM (AM3517/05 TMDSEVM3517)";
        compatible = "ti,am3517-evm", "ti,am3517", "ti,omap3";
 
+       aliases {
+               display0 = &lcd0;
+       };
+
        memory@80000000 {
                device_type = "memory";
                reg = <0x80000000 0x10000000>; /* 256 MB */
@@ -24,6 +30,144 @@ vmmc_fixed: vmmc {
                 regulator-min-microvolt = <3300000>;
                 regulator-max-microvolt = <3300000>;
         };
+
+       gpio-keys {
+               compatible = "gpio-keys-polled";
+               poll-interval = <100>;
+
+               user_pb {
+                       label = "User Push Button";
+                       linux,code = <BTN_0>;
+                       gpios = <&tca6416 5 GPIO_ACTIVE_LOW>;
+               };
+
+               user_sw_1 {
+                       label = "User Switch 1";
+                       linux,code = <BTN_1>;
+                       gpios = <&tca6416 8 GPIO_ACTIVE_LOW>;
+               };
+
+               user_sw_2 {
+                       label = "User Switch 2";
+                       linux,code = <BTN_2>;
+                       gpios = <&tca6416 9 GPIO_ACTIVE_LOW>;
+               };
+
+               user_sw_3 {
+                       label = "User Switch 3";
+                       linux,code = <BTN_3>;
+                       gpios = <&tca6416 10 GPIO_ACTIVE_LOW>;
+               };
+
+               user_sw_4 {
+                       label = "User Switch 4";
+                       linux,code = <BTN_4>;
+                       gpios = <&tca6416 11 GPIO_ACTIVE_LOW>;
+               };
+
+               user_sw_5 {
+                       label = "User Switch 5";
+                       linux,code = <BTN_5>;
+                       gpios = <&tca6416 12 GPIO_ACTIVE_LOW>;
+               };
+
+               user_sw_6 {
+                       label = "User Switch 6";
+                       linux,code = <BTN_6>;
+                       gpios = <&tca6416 13 GPIO_ACTIVE_LOW>;
+               };
+
+               user_sw_7 {
+                       label = "User Switch 7";
+                       linux,code = <BTN_7>;
+                       gpios = <&tca6416 14 GPIO_ACTIVE_LOW>;
+               };
+
+               user_sw_8 {
+                       label = "User Switch 8";
+                       linux,code = <BTN_8>;
+                       gpios = <&tca6416 15 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       gpio-leds {
+               compatible = "gpio-leds";
+
+               pinctrl-names = "default";
+               pinctrl-0 = <&leds_pins>;
+
+               user_led_1 {
+                       label = "am3517evm:green:user_led_1";
+                       gpios = <&tca6416 7 GPIO_ACTIVE_LOW>;
+                       default-state = "on";
+               };
+
+               user_led_2 {
+                       label = "am3517evm:green:user_led_2";
+                       gpios = <&tca6416 6 GPIO_ACTIVE_LOW>;
+                       default-state = "on";
+               };
+
+               user_led_3 {
+                       label = "am3517evm:green:user_led_3";
+                       gpios = <&gpio1 11 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "mmc0"; /* SD/MMC card activity */
+               };
+
+               user_led_4 {
+                       label = "am3517evm:green:user_led_4";
+                       gpios = <&gpio1 31 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "heartbeat";
+               };
+       };
+
+       lcd0: display@0 {
+               compatible = "panel-dpi";
+               label = "15";
+               status = "okay";
+               pinctrl-names = "default";
+               enable-gpios = <&gpio6 16 GPIO_ACTIVE_HIGH>;    /* gpio176, lcd INI */
+
+               port {
+                       lcd_in: endpoint {
+                               remote-endpoint = <&dpi_out>;
+                       };
+               };
+
+               panel-timing {
+                       clock-frequency = <9000000>;
+                       hactive = <480>;
+                       vactive = <272>;
+                       hfront-porch = <3>;
+                       hback-porch = <2>;
+                       hsync-len = <42>;
+                       vback-porch = <3>;
+                       vfront-porch = <4>;
+                       vsync-len = <11>;
+                       hsync-active = <0>;
+                       vsync-active = <0>;
+                       de-active = <1>;
+                       pixelclk-active = <1>;
+               };
+       };
+
+       bl: backlight {
+               compatible = "pwm-backlight";
+               pinctrl-names = "default";
+               pinctrl-0 = <&backlight_pins>;
+               pwms = <&pwm11 0 5000000 0>;
+               brightness-levels = <0 10 20 30 40 50 60 70 80 90 100>;
+               default-brightness-level = <7>;
+               enable-gpios = <&gpio6 22 GPIO_ACTIVE_HIGH>; /* gpio_182 */
+       };
+
+       pwm11: dmtimer-pwm@11 {
+               compatible = "ti,omap-dmtimer-pwm";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pwm_pins>;
+               ti,timers = <&timer11>;
+               #pwm-cells = <3>;
+       };
 };
 
 &davinci_emac {
@@ -34,12 +178,32 @@ &davinci_mdio {
             status = "okay";
 };
 
-&i2c1 {
-       clock-frequency = <400000>;
+&dss {
+       status = "ok";
+
+       pinctrl-names = "default";
+       pinctrl-0 = <&dss_dpi_pins>;
+
+       vdds_dsi-supply = <&vdd_io_reg>;
+       vdda_video-supply = <&vdd_io_reg>;
+
+       port {
+               dpi_out: endpoint {
+                       remote-endpoint = <&lcd_in>;
+                       data-lines = <16>;
+               };
+       };
 };
 
 &i2c2 {
        clock-frequency = <400000>;
+       /* User DIP swithes [1:8] / User LEDS [1:2] */
+       tca6416: gpio@21 {
+               compatible = "ti,tca6416";
+               reg = <0x21>;
+               gpio-controller;
+               #gpio-cells = <2>;
+       };
 };
 
 &i2c3 {
@@ -47,8 +211,13 @@ &i2c3 {
 };
 
 &mmc1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&mmc1_pins>;
        vmmc-supply = <&vmmc_fixed>;
        bus-width = <4>;
+       wp-gpios = <&gpio4 30 GPIO_ACTIVE_HIGH>; /* gpio_126 */
+       cd-gpios = <&gpio4 31 GPIO_ACTIVE_HIGH>; /* gpio_127 */
 };
 
 &mmc2 {
@@ -59,3 +228,63 @@ &mmc3 {
       status = "disabled";
 };
 
+&omap3_pmx_core {
+
+       leds_pins: pinmux_leds_pins {
+               pinctrl-single,pins = <
+                       OMAP3_WKUP_IOPAD(0x2a24, PIN_OUTPUT_PULLUP | MUX_MODE4) /* jtag_emu0.gpio_11 */
+                       OMAP3_WKUP_IOPAD(0x2a26, PIN_OUTPUT_PULLUP | MUX_MODE4) /* jtag_emu1.gpio_31 */
+               >;
+       };
+
+       mmc1_pins: pinmux_mmc1_pins {
+               pinctrl-single,pins = <
+                       OMAP3_CORE1_IOPAD(0x2144, PIN_INPUT_PULLUP | MUX_MODE0) /* sdmmc1_clk.sdmmc1_clk */
+                       OMAP3_CORE1_IOPAD(0x2146, PIN_INPUT_PULLUP | MUX_MODE0) /* sdmmc1_cmd.sdmmc1_cmd */
+                       OMAP3_CORE1_IOPAD(0x2148, PIN_INPUT_PULLUP | MUX_MODE0) /* sdmmc1_dat0.sdmmc1_dat0 */
+                       OMAP3_CORE1_IOPAD(0x214a, PIN_INPUT_PULLUP | MUX_MODE0) /* sdmmc1_dat1.sdmmc1_dat1 */
+                       OMAP3_CORE1_IOPAD(0x214c, PIN_INPUT_PULLUP | MUX_MODE0) /* sdmmc1_dat2.sdmmc1_dat2 */
+                       OMAP3_CORE1_IOPAD(0x214e, PIN_INPUT_PULLUP | MUX_MODE0) /* sdmmc1_dat3.sdmmc1_dat3 */
+                       OMAP3_CORE1_IOPAD(0x2150, PIN_INPUT_PULLUP | MUX_MODE4) /* sdmmc1_dat4.gpio_126 */
+                       OMAP3_CORE1_IOPAD(0x2152, PIN_INPUT_PULLUP | MUX_MODE4) /* sdmmc1_dat5.gpio_127 */
+               >;
+       };
+
+       pwm_pins: pinmux_pwm_pins {
+               pinctrl-single,pins = <
+                       OMAP3_CORE1_IOPAD(0x21dc, PIN_OUTPUT | MUX_MODE1)       /* mcspi2_cs0.gpt11_pwm */
+               >;
+       };
+
+       backlight_pins: pinmux_backlight_pins {
+               pinctrl-single,pins = <
+                       OMAP3_CORE1_IOPAD(0x21de, PIN_OUTPUT | MUX_MODE4)       /* mcspi2_cs1.gpio_182 */
+               >;
+       };
+
+       dss_dpi_pins: pinmux_dss_dpi_pins {
+               pinctrl-single,pins = <
+                       OMAP3_CORE1_IOPAD(0x21d2, PIN_OUTPUT | MUX_MODE4)       /* mcspi1_cs2.gpio_176 */
+                       OMAP3_CORE1_IOPAD(0x20d4, PIN_OUTPUT | MUX_MODE0)       /* dss_pclk.dss_pclk */
+                       OMAP3_CORE1_IOPAD(0x20d6, PIN_OUTPUT | MUX_MODE0)       /* dss_hsync.dss_hsync */
+                       OMAP3_CORE1_IOPAD(0x20d8, PIN_OUTPUT | MUX_MODE0)       /* dss_vsync.dss_vsync */
+                       OMAP3_CORE1_IOPAD(0x20da, PIN_OUTPUT | MUX_MODE0)       /* dss_acbias.dss_acbias */
+                       OMAP3_CORE1_IOPAD(0x20dc, PIN_OUTPUT | MUX_MODE0)       /* dss_data0.dss_data0 */
+                       OMAP3_CORE1_IOPAD(0x20de, PIN_OUTPUT | MUX_MODE0)       /* dss_data1.dss_data1 */
+                       OMAP3_CORE1_IOPAD(0x20e0, PIN_OUTPUT | MUX_MODE0)       /* dss_data2.dss_data2 */
+                       OMAP3_CORE1_IOPAD(0x20e2, PIN_OUTPUT | MUX_MODE0)       /* dss_data3.dss_data3 */
+                       OMAP3_CORE1_IOPAD(0x20e4, PIN_OUTPUT | MUX_MODE0)       /* dss_data4.dss_data4 */
+                       OMAP3_CORE1_IOPAD(0x20e6, PIN_OUTPUT | MUX_MODE0)       /* dss_data5.dss_data5 */
+                       OMAP3_CORE1_IOPAD(0x20e8, PIN_OUTPUT | MUX_MODE0)       /* dss_data6.dss_data6 */
+                       OMAP3_CORE1_IOPAD(0x20ea, PIN_OUTPUT | MUX_MODE0)       /* dss_data7.dss_data7 */
+                       OMAP3_CORE1_IOPAD(0x20ec, PIN_OUTPUT | MUX_MODE0)       /* dss_data8.dss_data8 */
+                       OMAP3_CORE1_IOPAD(0x20ee, PIN_OUTPUT | MUX_MODE0)       /* dss_data9.dss_data9 */
+                       OMAP3_CORE1_IOPAD(0x20f0, PIN_OUTPUT | MUX_MODE0)       /* dss_data10.dss_data10 */
+                       OMAP3_CORE1_IOPAD(0x20f2, PIN_OUTPUT | MUX_MODE0)       /* dss_data11.dss_data11 */
+                       OMAP3_CORE1_IOPAD(0x20f4, PIN_OUTPUT | MUX_MODE0)       /* dss_data12.dss_data12 */
+                       OMAP3_CORE1_IOPAD(0x20f6, PIN_OUTPUT | MUX_MODE0)       /* dss_data13.dss_data13 */
+                       OMAP3_CORE1_IOPAD(0x20f8, PIN_OUTPUT | MUX_MODE0)       /* dss_data14.dss_data14 */
+                       OMAP3_CORE1_IOPAD(0x20fa, PIN_OUTPUT | MUX_MODE0)       /* dss_data15.dss_data15 */
+               >;
+       };
+};
diff --git a/arch/arm/boot/dts/am3517-som.dtsi b/arch/arm/boot/dts/am3517-som.dtsi
new file mode 100644 (file)
index 0000000..a6d5ff7
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright (C) 2016 Derald D. Woods <woods.technical@gmail.com>
+ *
+ * Based on am3517-evm.dts
+ *
+ * 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.
+ */
+
+/ {
+       cpus {
+               cpu@0 {
+                       cpu0-supply = <&vdd_core_reg>;
+               };
+       };
+};
+
+&gpmc {
+       ranges = <0 0 0x30000000 0x1000000>;    /* CS0: 16MB for NAND */
+
+       nand@0,0 {
+               compatible = "ti,omap2-nand";
+               linux,mtd-name = "micron,mt29f4g16abchch";
+               reg = <0 0 4>; /* CS0, offset 0, IO size 4 */
+               nand-bus-width = <16>;
+               ti,nand-ecc-opt = "bch8";
+               gpmc,sync-clk-ps = <0>;
+               gpmc,cs-on-ns = <0>;
+               gpmc,cs-rd-off-ns = <44>;
+               gpmc,cs-wr-off-ns = <44>;
+               gpmc,adv-on-ns = <6>;
+               gpmc,adv-rd-off-ns = <34>;
+               gpmc,adv-wr-off-ns = <44>;
+               gpmc,we-off-ns = <40>;
+               gpmc,oe-off-ns = <54>;
+               gpmc,access-ns = <64>;
+               gpmc,rd-cycle-ns = <82>;
+               gpmc,wr-cycle-ns = <82>;
+               gpmc,wr-access-ns = <40>;
+               gpmc,wr-data-mux-bus-ns = <0>;
+               gpmc,device-width = <2>;
+               #address-cells = <1>;
+               #size-cells = <1>;
+       };
+};
+
+&i2c1 {
+       clock-frequency = <400000>;
+
+       s35390a: s35390a@30 {
+               compatible = "sii,s35390a";
+               reg = <0x30>;
+
+               pinctrl-names = "default";
+               pinctrl-0 = <&rtc_pins>;
+               interrupts-extended = <&gpio2 23 IRQ_TYPE_EDGE_FALLING>; /* gpio_55 */
+       };
+
+       tps: tps65023@48 {
+               compatible = "ti,tps65023";
+               reg = <0x48>;
+
+               regulators {
+                       vdd_core_reg: VDCDC1 {
+                               regulator-name = "vdd_core";
+                               compatible = "regulator-fixed";
+                               regulator-always-on;
+                               regulator-min-microvolt = <1200000>;
+                               regulator-max-microvolt = <1200000>;
+                       };
+
+                       vdd_io_reg: VDCDC2 {
+                               regulator-name = "vdd_io";
+                               compatible = "regulator-fixed";
+                               regulator-always-on;
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                       };
+
+                       vdd_1v8_reg: VDCDC3 {
+                               regulator-name = "vdd_1v8";
+                               compatible = "regulator-fixed";
+                               regulator-always-on;
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <1800000>;
+                       };
+
+                       vdd_usb18_reg: LDO1 {
+                               regulator-name = "vdd_usb18";
+                               compatible = "regulator-fixed";
+                               regulator-always-on;
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <1800000>;
+                       };
+
+                       vdd_usb33_reg: LDO2 {
+                               regulator-name = "vdd_usb33";
+                               compatible = "regulator-fixed";
+                               regulator-always-on;
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                       };
+               };
+       };
+
+       touchscreen: tsc2004@4b {
+               compatible = "ti,tsc2004";
+               reg = <0x4b>;
+
+               vio-supply = <&vdd_io_reg>;
+
+               pinctrl-names = "default";
+               pinctrl-0 = <&tsc2004_pins>;
+               interrupts-extended = <&gpio3 1 IRQ_TYPE_EDGE_RISING>; /* gpio_65 */
+
+               touchscreen-fuzz-x = <4>;
+               touchscreen-fuzz-y = <7>;
+               touchscreen-fuzz-pressure = <2>;
+               touchscreen-size-x = <480>;
+               touchscreen-size-y = <272>;
+               touchscreen-max-pressure = <2048>;
+
+               ti,x-plate-ohms = <280>;
+               ti,esd-recovery-timeout-ms = <8000>;
+       };
+};
+
+&omap3_pmx_core {
+
+       rtc_pins: pinmux_rtc_pins {
+               pinctrl-single,pins = <
+                       OMAP3_CORE1_IOPAD(0x20b6, PIN_INPUT_PULLUP | MUX_MODE4) /* gpmc_ncs4.gpio_55 */
+               >;
+       };
+
+       tsc2004_pins: pinmux_tsc2004_pins {
+               pinctrl-single,pins = <
+                       OMAP3_CORE1_IOPAD(0x20d2, PIN_INPUT | MUX_MODE4) /* gpmc_wait3.gpio_65 */
+               >;
+       };
+};
index 3b9a94c274a7b01ed29ead402a4b3538c122138d..bff5abe69bdb6836f6597a047ef6a12ac227aa6d 100644 (file)
@@ -203,7 +203,7 @@ &i2c0 {
        tps65218: tps65218@24 {
                compatible = "ti,tps65218";
                reg = <0x24>;
-               interrupts = <GIC_SPI 7 IRQ_TYPE_NONE>; /* NMIn */
+               interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; /* NMIn */
                interrupt-parent = <&gic>;
                interrupt-controller;
                #interrupt-cells = <2>;
index 8fe95cd7232ae3859be81c29011adf2e1d8fa3f1..60414b1ca4044f38d71877d61cf0da8e34d54db9 100644 (file)
@@ -543,7 +543,7 @@ &i2c0 {
        tps65218: tps65218@24 {
                reg = <0x24>;
                compatible = "ti,tps65218";
-               interrupts = <GIC_SPI 7 IRQ_TYPE_NONE>; /* NMIn */
+               interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; /* NMIn */
                interrupt-controller;
                #interrupt-cells = <2>;
 
index 4118802b7fea0097298ca745a2b82961a06e52bc..440351ad0b80686d06126df39b02d8de104a95d0 100644 (file)
@@ -15,6 +15,7 @@
 #include <dt-bindings/pwm/pwm.h>
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
+#include <dt-bindings/interrupt-controller/irq.h>
 
 / {
        model = "TI AM437x SK EVM";
@@ -158,6 +159,22 @@ lcd_in: endpoint {
                        };
                };
        };
+
+       vmmcwl_fixed: fixedregulator-mmcwl {
+               /*
+                * WL_EN is not SDIO standard compliant. It is an out of band
+                * signal and hard to be dealt with in a standard way by the
+                * SDIO core driver.
+                * So modelling the WL_EN line as a regulator was a natural
+                * choice as the MMC core already deals with MMC supplies.
+                */
+               compatible = "regulator-fixed";
+               regulator-name = "vmmcwl_fixed";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               gpio = <&gpio4 8 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
 };
 
 &am43xx_pinmux {
@@ -418,6 +435,62 @@ usb2_pins: usb2_pins {
                        AM4372_IOPAD(0xac4, PIN_OUTPUT | MUX_MODE0) /* usb0_drvvbus.usb0_drvvbus */
                >;
        };
+
+       mmc3_pins_default: pinmux_mmc3_pins_default {
+               pinctrl-single,pins = <
+                       AM4372_IOPAD(0x9f0, PIN_INPUT_PULLUP | MUX_MODE3) /* (AD21) cam1_data2.mmc2_clk */
+                       AM4372_IOPAD(0x9f4, PIN_INPUT_PULLUP | MUX_MODE3) /* (AE22) cam1_data3.mmc2_cmd */
+                       AM4372_IOPAD(0x9f8, PIN_INPUT_PULLUP | MUX_MODE3) /* (AD22) cam1_data4.mmc2_dat0 */
+                       AM4372_IOPAD(0x9fc, PIN_INPUT_PULLUP | MUX_MODE3) /* (AE23) cam1_data5.mmc2_dat1 */
+                       AM4372_IOPAD(0xa00, PIN_INPUT_PULLUP | MUX_MODE3) /* (AD23) cam1_data6.mmc2_dat2 */
+                       AM4372_IOPAD(0xa04, PIN_INPUT_PULLUP | MUX_MODE3) /* (AE24) cam1_data7.mmc2_dat3 */
+               >;
+       };
+
+       mmc3_pins_sleep: pinmux_mmc3_pins_sleep {
+               pinctrl-single,pins = <
+                       AM4372_IOPAD(0x9f0, PIN_INPUT_PULLDOWN | MUX_MODE7) /* (AD21) cam1_data2.mmc2_clk */
+                       AM4372_IOPAD(0x9f4, PIN_INPUT_PULLDOWN | MUX_MODE7) /* (AE22) cam1_data3.mmc2_cmd */
+                       AM4372_IOPAD(0x9f8, PIN_INPUT_PULLDOWN | MUX_MODE7) /* (AD22) cam1_data4.mmc2_dat0 */
+                       AM4372_IOPAD(0x9fc, PIN_INPUT_PULLDOWN | MUX_MODE7) /* (AE23) cam1_data5.mmc2_dat1 */
+                       AM4372_IOPAD(0xa00, PIN_INPUT_PULLDOWN | MUX_MODE7) /* (AD23) cam1_data6.mmc2_dat2 */
+                       AM4372_IOPAD(0xa04, PIN_INPUT_PULLDOWN | MUX_MODE7) /* (AE24) cam1_data7.mmc2_dat3 */
+               >;
+       };
+
+       wlan_pins_default: pinmux_wlan_pins_default {
+               pinctrl-single,pins = <
+                       AM4372_IOPAD(0x9d0, PIN_OUTPUT_PULLDOWN | MUX_MODE7)            /* cam1_data8.gpio4_8 WL_EN */
+                       AM4372_IOPAD(0x9e4, PIN_INPUT | WAKEUP_ENABLE | MUX_MODE7)      /* cam1_wen.gpio4_13 WL_IRQ */
+               >;
+       };
+
+       wlan_pins_sleep: pinmux_wlan_pins_sleep {
+               pinctrl-single,pins = <
+                       AM4372_IOPAD(0x9d0, PIN_OUTPUT_PULLDOWN | MUX_MODE7)            /* cam1_data8.gpio4_8 WL_EN */
+                       AM4372_IOPAD(0x9e4, PIN_INPUT | WAKEUP_ENABLE | MUX_MODE7)      /* cam1_wen.gpio4_13 WL_IRQ */
+               >;
+       };
+
+       uart1_bt_pins_default: pinmux_uart1_bt_pins_default {
+               pinctrl-single,pins = <
+                       AM4372_IOPAD(0x980, PIN_INPUT | MUX_MODE0)              /* uart1_rxd.uart1_rxd */
+                       AM4372_IOPAD(0x984, PIN_OUTPUT_PULLDOWN | MUX_MODE0)    /* uart1_txd.uart1_txd */
+                       AM4372_IOPAD(0x978, PIN_INPUT_PULLUP | MUX_MODE0)       /* uart1_ctsn.uart1_ctsn */
+                       AM4372_IOPAD(0x97c, PIN_OUTPUT_PULLDOWN | MUX_MODE0)    /* uart1_rtsn.uart1_rtsn */
+                       AM4372_IOPAD(0x9cc, PIN_OUTPUT_PULLDOWN | MUX_MODE7)    /* cam1_data9.gpio4_7 BT_EN */
+               >;
+       };
+
+       uart1_bt_pins_sleep: pinmux_uart1_bt_pins_sleep {
+               pinctrl-single,pins = <
+                       AM4372_IOPAD(0x980, PIN_OUTPUT_PULLDOWN | MUX_MODE7)    /* uart1_rxd.uart1_rxd */
+                       AM4372_IOPAD(0x984, PIN_OUTPUT_PULLDOWN | MUX_MODE7)    /* uart1_txd.uart1_txd */
+                       AM4372_IOPAD(0x978, PIN_OUTPUT_PULLDOWN | MUX_MODE7)    /* uart1_ctsn.uart1_ctsn */
+                       AM4372_IOPAD(0x97c, PIN_OUTPUT_PULLDOWN | MUX_MODE7)    /* uart1_rtsn.uart1_rtsn */
+                       AM4372_IOPAD(0x9cc, PIN_OUTPUT_PULLUP | MUX_MODE7)      /* cam1_data9.gpio4_7 BT_EN */
+               >;
+       };
 };
 
 &i2c0 {
@@ -581,6 +654,10 @@ &gpio1 {
        status = "okay";
 };
 
+&gpio4 {
+       status = "okay";
+};
+
 &gpio5 {
        status = "okay";
 };
@@ -595,6 +672,44 @@ &mmc1 {
        cd-gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
 };
 
+&uart1 {
+       status = "okay";
+       pinctrl-names = "default", "sleep";
+       pinctrl-0 = <&uart1_bt_pins_default>;
+       pinctrl-1 = <&uart1_bt_pins_sleep>;
+};
+
+&mmc3 {
+       status = "okay";
+       /*
+        * these are on the crossbar and are outlined in the
+        * xbar-event-map element
+        */
+       dmas = <&edma_xbar 30 0 1>,
+               <&edma_xbar 31 0 2>;
+       dma-names = "tx", "rx";
+       vmmc-supply = <&vmmcwl_fixed>;
+       bus-width = <4>;
+       pinctrl-names = "default", "sleep";
+       pinctrl-0 = <&mmc3_pins_default>;
+       pinctrl-1 = <&mmc3_pins_sleep>;
+       cap-power-off-card;
+       keep-power-in-suspend;
+       ti,non-removable;
+
+       #address-cells = <1>;
+       #size-cells = <0>;
+       wlcore: wlcore@2 {
+               compatible = "ti,wl1835";
+               pinctrl-names = "default", "sleep";
+               pinctrl-0 = <&wlan_pins_default>;
+               pinctrl-1 = <&wlan_pins_sleep>;
+               reg = <2>;
+               interrupt-parent = <&gpio4>;
+               interrupts = <13 IRQ_TYPE_LEVEL_HIGH>;
+       };
+};
+
 &usb2_phy1 {
        status = "okay";
 };
index a66941885c119ac936f9f7bfe47a11d2ff4a4a13..6502d33976532ceddf12c8f780dead8b703d0dfc 100644 (file)
@@ -595,7 +595,7 @@ &i2c0 {
        tps65218: tps65218@24 {
                reg = <0x24>;
                compatible = "ti,tps65218";
-               interrupts = <GIC_SPI 7 IRQ_TYPE_NONE>; /* NMIn */
+               interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>; /* NMIn */
                interrupt-controller;
                #interrupt-cells = <2>;
 
index a2555140babc4c1dddc615a26dbda15ba7390222..5bb9d68d6e90a411b117c3a9b736f281dad6fdbc 100644 (file)
@@ -10,6 +10,7 @@
 #include "dra72x.dtsi"
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/interrupt-controller/irq.h>
+#include "dra7-mmc-iodelay.dtsi"
 #include "dra72x-mmc-iodelay.dtsi"
 #include "am57xx-idk-common.dtsi"
 
@@ -102,7 +103,7 @@ &pcie1_ep {
 
 &mmc1 {
        pinctrl-names = "default", "hs", "sdr12", "sdr25", "sdr50", "ddr50", "sdr104";
-       pinctrl-0 = <&mmc1_pins_default>;
+       pinctrl-0 = <&mmc1_pins_default_no_clk_pu>;
        pinctrl-1 = <&mmc1_pins_hs>;
        pinctrl-2 = <&mmc1_pins_sdr12>;
        pinctrl-3 = <&mmc1_pins_sdr25>;
@@ -112,7 +113,7 @@ &mmc1 {
 };
 
 &mmc2 {
-       pinctrl-names = "default", "hs", "ddr_1_8v";
+       pinctrl-names = "default", "hs", "ddr_3_3v";
        pinctrl-0 = <&mmc2_pins_default>;
        pinctrl-1 = <&mmc2_pins_hs>;
        pinctrl-2 = <&mmc2_pins_ddr_rev20 &mmc2_iodelay_ddr_conf>;
index 3a02ed720957b08093fef7678596f363c1e81eb9..3ef9111d0e8baafd530c7b09f6db1c42895d61cc 100644 (file)
@@ -9,6 +9,7 @@
 /dts-v1/;
 
 #include "dra74x.dtsi"
+#include "dra7-mmc-iodelay.dtsi"
 #include "dra74x-mmc-iodelay.dtsi"
 #include "am572x-idk-common.dtsi"
 
@@ -20,7 +21,7 @@ / {
 
 &mmc1 {
        pinctrl-names = "default", "hs", "sdr12", "sdr25", "sdr50", "ddr50", "sdr104";
-       pinctrl-0 = <&mmc1_pins_default>;
+       pinctrl-0 = <&mmc1_pins_default_no_clk_pu>;
        pinctrl-1 = <&mmc1_pins_hs>;
        pinctrl-2 = <&mmc1_pins_sdr12>;
        pinctrl-3 = <&mmc1_pins_sdr25>;
@@ -30,7 +31,7 @@ &mmc1 {
 };
 
 &mmc2 {
-       pinctrl-names = "default", "hs", "ddr_1_8v";
+       pinctrl-names = "default", "hs", "ddr_3_3v";
        pinctrl-0 = <&mmc2_pins_default>;
        pinctrl-1 = <&mmc2_pins_hs>;
        pinctrl-2 = <&mmc2_pins_ddr_rev20>;
index 41e12a382d2ffe3ddf5e6656d5cb17463eca232b..378dfa780ac17a69a1c9420dd69c7c58690cb0d3 100644 (file)
@@ -7,6 +7,8 @@
 /dts-v1/;
 
 #include "dra76x.dtsi"
+#include "dra7-mmc-iodelay.dtsi"
+#include "dra76x-mmc-iodelay.dtsi"
 #include "am572x-idk-common.dtsi"
 
 / {
@@ -20,3 +22,21 @@ m25p80@0 {
                spi-max-frequency = <96000000>;
        };
 };
+
+&mmc1 {
+       pinctrl-names = "default", "hs", "sdr12", "sdr25", "sdr50", "ddr50", "sdr104";
+       pinctrl-0 = <&mmc1_pins_default_no_clk_pu>;
+       pinctrl-1 = <&mmc1_pins_hs>;
+       pinctrl-2 = <&mmc1_pins_default>;
+       pinctrl-3 = <&mmc1_pins_hs>;
+       pinctrl-4 = <&mmc1_pins_sdr50>;
+       pinctrl-5 = <&mmc1_pins_ddr50 &mmc1_iodelay_ddr_conf>;
+       pinctrl-6 = <&mmc1_pins_ddr50 &mmc1_iodelay_sdr104_conf>;
+};
+
+&mmc2 {
+       pinctrl-names = "default", "hs", "ddr_3_3v";
+       pinctrl-0 = <&mmc2_pins_default>;
+       pinctrl-1 = <&mmc2_pins_default>;
+       pinctrl-2 = <&mmc2_pins_default>;
+};
index 6204a266212a2516183d2d33b6898be81bd09f92..ad953113cefbda10f32bf03c6b11e0551dad8834 100644 (file)
@@ -444,8 +444,8 @@ &mmc2 {
        vmmc-supply = <&vdd_3v3>;
        vqmmc-supply = <&vdd_3v3>;
        bus-width = <8>;
-       ti,non-removable;
-       cap-mmc-dual-data-rate;
+       non-removable;
+       no-1-8-v;
 };
 
 &sata {
index d6689106d2a83935ea6ac98fd89f42ce06132879..70a71c641066be2b9c0f01824e9a0e173ae55457 100644 (file)
@@ -25,10 +25,11 @@ &mmc1 {
        pinctrl-1 = <&mmc1_pins_hs>;
 
        vmmc-supply = <&ldo1_reg>;
+       no-1-8-v;
 };
 
 &mmc2 {
-       pinctrl-names = "default", "hs", "ddr_1_8v";
+       pinctrl-names = "default", "hs", "ddr_3_3v";
        pinctrl-0 = <&mmc2_pins_default>;
        pinctrl-1 = <&mmc2_pins_hs>;
        pinctrl-2 = <&mmc2_pins_ddr_3_3v_rev11 &mmc2_iodelay_ddr_3_3v_rev11_conf>;
index 43cdf523a8a02c006568db351a933b668880cabf..ad87f1ae904db15c313678c5b59c68bb78fdb733 100644 (file)
@@ -115,17 +115,6 @@ DRA7XX_CORE_IOPAD(0x37d0, MUX_MODE15 | PULL_UP)    /* dcan1_tx.off */
                        DRA7XX_CORE_IOPAD(0x37d4, MUX_MODE15 | PULL_UP) /* dcan1_rx.off */
                >;
        };
-
-       mmc1_pins_default: mmc1_pins_default {
-               pinctrl-single,pins = <
-                       DRA7XX_CORE_IOPAD(0x3754, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mmc1_clk.clk */
-                       DRA7XX_CORE_IOPAD(0x3758, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_cmd.cmd */
-                       DRA7XX_CORE_IOPAD(0x375c, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat0.dat0 */
-                       DRA7XX_CORE_IOPAD(0x3760, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat1.dat1 */
-                       DRA7XX_CORE_IOPAD(0x3764, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat2.dat2 */
-                       DRA7XX_CORE_IOPAD(0x3768, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat3.dat3 */
-               >;
-       };
 };
 
 &i2c1 {
@@ -423,8 +412,9 @@ &mmc2 {
        vmmc-supply = <&v3_3d>;
        vqmmc-supply = <&v3_3d>;
        bus-width = <8>;
-       ti,non-removable;
+       non-removable;
        max-frequency = <96000000>;
+       no-1-8-v;
 };
 
 &dcan1 {
index afe46097a40366a298e51587c7b9835f8ea47460..77261a2fb94996d904b307c39dddc6722a94cb97 100644 (file)
@@ -105,33 +105,6 @@ usb@50000 {
                        usb@51000 {
                                status = "okay";
                        };
-
-                       nand@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-
-                               partitions {
-                                       compatible = "fixed-partitions";
-                                       #address-cells = <1>;
-                                       #size-cells = <1>;
-
-                                       partition@0 {
-                                               label = "U-Boot";
-                                               reg = <0 0x800000>;
-                                       };
-                                       partition@800000 {
-                                               label = "Linux";
-                                               reg = <0x800000 0x800000>;
-                                       };
-                                       partition@1000000 {
-                                               label = "Filesystem";
-                                               reg = <0x1000000 0x3f000000>;
-                                       };
-                               };
-                       };
                };
        };
 
@@ -239,3 +212,33 @@ spi-flash@0 {
        };
 };
 
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "U-Boot";
+                               reg = <0 0x800000>;
+                       };
+                       partition@800000 {
+                               label = "Linux";
+                               reg = <0x800000 0x800000>;
+                       };
+                       partition@1000000 {
+                               label = "Filesystem";
+                               reg = <0x1000000 0x3f000000>;
+                       };
+               };
+       };
+};
index 8e46f63cbaa1b16526add979271157c0de7a7628..baa459dd51e442866fad3b58e8a6f3ef336651f5 100644 (file)
@@ -44,61 +44,6 @@ sata@a0000 {
                        usb@50000 {
                                status = "okay";
                        };
-
-                       nand@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-                               nand-ecc-strength = <4>;
-                               nand-ecc-step-size = <512>;
-
-                               partition@0 {
-                                       label = "u-boot";
-                                       /* 1.0 MiB */
-                                       reg = <0x0000000 0x100000>;
-                                       read-only;
-                               };
-
-                               partition@100000 {
-                                       label = "u-boot-env";
-                                       /* 128 KiB */
-                                       reg = <0x100000 0x20000>;
-                                       read-only;
-                               };
-
-                               partition@120000 {
-                                       label = "uImage";
-                                       /* 7 MiB */
-                                       reg = <0x120000 0x700000>;
-                               };
-
-                               partition@820000 {
-                                       label = "ubifs";
-                                       /* ~ 84 MiB */
-                                       reg = <0x820000 0x54e0000>;
-                               };
-
-                               /* Hardcoded into stock bootloader */
-                               partition@5d00000 {
-                                       label = "failsafe-uImage";
-                                       /* 5 MiB */
-                                       reg = <0x5d00000 0x500000>;
-                               };
-
-                               partition@6200000 {
-                                       label = "failsafe-fs";
-                                       /* 29 MiB */
-                                       reg = <0x6200000 0x1d00000>;
-                               };
-
-                               partition@7f00000 {
-                                       label = "bbt";
-                                       /* 1 MiB for BBT */
-                                       reg = <0x7f00000 0x100000>;
-                               };
-                       };
                };
        };
 
@@ -319,3 +264,68 @@ &i2c0 {
        clock-frequency = <100000>;
        status = "okay";
 };
+
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               /* 1.0 MiB */
+                               reg = <0x0000000 0x100000>;
+                               read-only;
+                       };
+
+                       partition@100000 {
+                               label = "u-boot-env";
+                               /* 128 KiB */
+                               reg = <0x100000 0x20000>;
+                               read-only;
+                       };
+
+                       partition@120000 {
+                               label = "uImage";
+                               /* 7 MiB */
+                               reg = <0x120000 0x700000>;
+                       };
+
+                       partition@820000 {
+                               label = "ubifs";
+                               /* ~ 84 MiB */
+                               reg = <0x820000 0x54e0000>;
+                       };
+
+                       /* Hardcoded into stock bootloader */
+                       partition@5d00000 {
+                               label = "failsafe-uImage";
+                               /* 5 MiB */
+                               reg = <0x5d00000 0x500000>;
+                       };
+
+                       partition@6200000 {
+                               label = "failsafe-fs";
+                               /* 29 MiB */
+                               reg = <0x6200000 0x1d00000>;
+                       };
+
+                       partition@7f00000 {
+                               label = "bbt";
+                               /* 1 MiB for BBT */
+                               reg = <0x7f00000 0x100000>;
+                       };
+               };
+       };
+};
index 996f31b0072940394e9487d9aba399e99c55528e..7c2f5a79b50dadf8309a007064cf2bf87c02d7ee 100644 (file)
@@ -108,27 +108,6 @@ pca9505: pca9505@25 {
                                        reg = <0x25>;
                                };
                        };
-
-                       nand@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-
-                               partition@0 {
-                                       label = "U-Boot";
-                                       reg = <0 0x400000>;
-                               };
-                               partition@400000 {
-                                       label = "Linux";
-                                       reg = <0x400000 0x400000>;
-                               };
-                               partition@800000 {
-                                       label = "Filesystem";
-                                       reg = <0x800000 0x3f800000>;
-                               };
-                       };
                };
        };
 };
@@ -173,3 +152,33 @@ stat_led_pins: stat-led-pins {
        };
 };
 
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "U-Boot";
+                               reg = <0 0x400000>;
+                       };
+                       partition@400000 {
+                               label = "Linux";
+                               reg = <0x400000 0x400000>;
+                       };
+                       partition@800000 {
+                               label = "Filesystem";
+                               reg = <0x800000 0x3f800000>;
+                       };
+               };
+       };
+};
index 56634803e16b804e832f9bd5794f6d4d2380edf6..b0b640b7de40e0fb702a7ca2fa0c14a72c50cd4f 100644 (file)
@@ -81,46 +81,6 @@ g762: g762@3e {
                                        pwm_polarity = <0>;
                                };
                        };
-
-                       nand@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-
-                               /* Use Hardware BCH ECC */
-                               nand-ecc-strength = <4>;
-                               nand-ecc-step-size = <512>;
-
-                               partition@0 {
-                                       label = "u-boot";
-                                       reg = <0x0000000 0x180000>;  /* 1.5MB */
-                                       read-only;
-                               };
-
-                               partition@180000 {
-                                       label = "u-boot-env";
-                                       reg = <0x180000 0x20000>;    /* 128KB */
-                                       read-only;
-                               };
-
-                               partition@200000 {
-                                       label = "uImage";
-                                       reg = <0x0200000 0x600000>;    /* 6MB */
-                               };
-
-                               partition@800000 {
-                                       label = "minirootfs";
-                                       reg = <0x0800000 0x400000>;    /* 4MB */
-                               };
-
-                               /* Last MB is for the BBT, i.e. not writable */
-                               partition@c00000 {
-                                       label = "ubifs";
-                                       reg = <0x0c00000 0x7400000>; /* 116MB */
-                               };
-                       };
                };
        };
 
@@ -264,3 +224,53 @@ poweroff: poweroff {
                marvell,function = "gpio";
        };
 };
+
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+
+               /* Use Hardware BCH ECC */
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0000000 0x180000>;  /* 1.5MB */
+                               read-only;
+                       };
+
+                       partition@180000 {
+                               label = "u-boot-env";
+                               reg = <0x180000 0x20000>;    /* 128KB */
+                               read-only;
+                       };
+
+                       partition@200000 {
+                               label = "uImage";
+                               reg = <0x0200000 0x600000>;    /* 6MB */
+                       };
+
+                       partition@800000 {
+                               label = "minirootfs";
+                               reg = <0x0800000 0x400000>;    /* 4MB */
+                       };
+
+                       /* Last MB is for the BBT, i.e. not writable */
+                       partition@c00000 {
+                               label = "ubifs";
+                               reg = <0x0c00000 0x7400000>; /* 116MB */
+                       };
+               };
+       };
+};
index 16d0307f786a07d0fbe8601a884a586b308d3352..9fd1cb9f499219535d00280c0cd5a1e2875eda94 100644 (file)
@@ -90,46 +90,6 @@ pca9554: pca9554@23 {
                                        reg = <0x23>;
                                };
                        };
-
-                       nand@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-
-                               /* Use Hardware BCH ECC */
-                               nand-ecc-strength = <4>;
-                               nand-ecc-step-size = <512>;
-
-                               partition@0 {
-                                       label = "u-boot";
-                                       reg = <0x0000000 0x180000>;  /* 1.5MB */
-                                       read-only;
-                               };
-
-                               partition@180000 {
-                                       label = "u-boot-env";
-                                       reg = <0x180000 0x20000>;    /* 128KB */
-                                       read-only;
-                               };
-
-                               partition@200000 {
-                                       label = "uImage";
-                                       reg = <0x0200000 0x600000>;    /* 6MB */
-                               };
-
-                               partition@800000 {
-                                       label = "minirootfs";
-                                       reg = <0x0800000 0x400000>;    /* 4MB */
-                               };
-
-                               /* Last MB is for the BBT, i.e. not writable */
-                               partition@c00000 {
-                                       label = "ubifs";
-                                       reg = <0x0c00000 0x7400000>; /* 116MB */
-                               };
-                       };
                };
        };
 
@@ -276,3 +236,53 @@ reset_button_pin: reset-button-pin {
                marvell,function = "gpio";
        };
 };
+
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+
+               /* Use Hardware BCH ECC */
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0000000 0x180000>;  /* 1.5MB */
+                               read-only;
+                       };
+
+                       partition@180000 {
+                               label = "u-boot-env";
+                               reg = <0x180000 0x20000>;    /* 128KB */
+                               read-only;
+                       };
+
+                       partition@200000 {
+                               label = "uImage";
+                               reg = <0x0200000 0x600000>;    /* 6MB */
+                       };
+
+                       partition@800000 {
+                               label = "minirootfs";
+                               reg = <0x0800000 0x400000>;    /* 4MB */
+                       };
+
+                       /* Last MB is for the BBT, i.e. not writable */
+                       partition@c00000 {
+                               label = "ubifs";
+                               reg = <0x0c00000 0x7400000>; /* 116MB */
+                       };
+               };
+       };
+};
index cc2f774eb2671ed08747f68c15c41c0c0145d8f9..2bfb3108b5b268aa27483a3e18b0a657c7c5f96a 100644 (file)
@@ -112,27 +112,6 @@ sw_led {
                                        default-state = "keep";
                                };
                        };
-
-                       nand@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-
-                               partition@0 {
-                                       label = "U-Boot";
-                                       reg = <0 0x800000>;
-                               };
-                               partition@800000 {
-                                       label = "Linux";
-                                       reg = <0x800000 0x800000>;
-                               };
-                               partition@1000000 {
-                                       label = "Filesystem";
-                                       reg = <0x1000000 0x3f000000>;
-                               };
-                       };
                };
        };
 
@@ -288,3 +267,34 @@ led_pins: led-pins {
                marvell,function = "gpio";
        };
 };
+
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "U-Boot";
+                               reg = <0 0x800000>;
+                       };
+                       partition@800000 {
+                               label = "Linux";
+                               reg = <0x800000 0x800000>;
+                       };
+                       partition@1000000 {
+                               label = "Filesystem";
+                               reg = <0x1000000 0x3f000000>;
+                       };
+               };
+       };
+};
index a5206db0ebbdac3a47893b20fbfcc5a4d9d7fe33..b52634ecf1d9c07d8df1b376e6ae6be31c165e68 100644 (file)
@@ -66,33 +66,6 @@ rtc@6f {
                                        interrupts = <110>;
                                };
                        };
-
-                       nand@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-                               nand-ecc-strength = <4>;
-                               nand-ecc-step-size = <512>;
-
-                               partition@0 {
-                                       label = "u-boot";
-                                       reg = <0x0 0x300000>;
-                               };
-                               partition@300000 {
-                                       label = "device-tree";
-                                       reg = <0x300000 0x20000>;
-                               };
-                               partition@320000 {
-                                       label = "linux";
-                                       reg = <0x320000 0x2000000>;
-                               };
-                               partition@2320000 {
-                                       label = "rootfs";
-                                       reg = <0x2320000 0xdce0000>;
-                               };
-                       };
                };
 
        };
@@ -227,3 +200,40 @@ hdd1_led_gpio_pin: hdd1-led-gpio-pin {
                marvell,function = "gpio";
        };
 };
+
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0 0x300000>;
+                       };
+                       partition@300000 {
+                               label = "device-tree";
+                               reg = <0x300000 0x20000>;
+                       };
+                       partition@320000 {
+                               label = "linux";
+                               reg = <0x320000 0x2000000>;
+                       };
+                       partition@2320000 {
+                               label = "rootfs";
+                               reg = <0x2320000 0xdce0000>;
+                       };
+               };
+       };
+};
index 11fc3271dad482cd515d371390787ebbf8d9a885..c15f5e92f97fba22fcdd57474b110e0d9d9b0eb1 100644 (file)
@@ -244,11 +244,11 @@ sata: sata@a0000 {
                                status = "disabled";
                        };
 
-                       nand: nand@d0000 {
-                               compatible = "marvell,armada370-nand";
+                       nand_controller: nand-controller@d0000 {
+                               compatible = "marvell,armada370-nand-controller";
                                reg = <0xd0000 0x54>;
                                #address-cells = <1>;
-                               #size-cells = <1>;
+                               #size-cells = <0>;
                                interrupts = <113>;
                                clocks = <&coredivclk 0>;
                                status = "disabled";
index e4ecd7e7564460d5c870ecbb6fdc92202829aa6c..0e679465cbb5dde0cdf57e4a401838d3d61c8b78 100644 (file)
@@ -103,28 +103,38 @@ &sata {
        nr-ports = <2>;
 };
 
-&nand {
+&nand_controller {
+       status = "okay";
        pinctrl-0 = <&nand_pins>;
        pinctrl-names = "default";
-       status = "okay";
-       num-cs = <1>;
-       marvell,nand-keep-config;
-       marvell,nand-enable-arbiter;
-       nand-on-flash-bbt;
-       nand-ecc-strength = <4>;
-       nand-ecc-step-size = <512>;
-
-       partition@0 {
-               label = "U-Boot";
-               reg = <0 0x800000>;
-       };
-       partition@800000 {
-               label = "Linux";
-               reg = <0x800000 0x800000>;
-       };
-       partition@1000000 {
-               label = "Filesystem";
-               reg = <0x1000000 0x3f000000>;
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "U-Boot";
+                               reg = <0 0x800000>;
+                       };
+                       partition@800000 {
+                               label = "Linux";
+                               reg = <0x800000 0x800000>;
+                       };
+                       partition@1000000 {
+                               label = "Filesystem";
+                               reg = <0x1000000 0x3f000000>;
+                       };
+               };
        };
 };
 
index 53ead6f26a0e6b079f0ce34b5a84ad8f8134ddfd..2932a29ae272e2e3ad8f171549f65d6b22913b6b 100644 (file)
@@ -502,11 +502,11 @@ sata: sata@a0000 {
                                status = "disabled";
                        };
 
-                       nand: nand@d0000 {
-                               compatible = "marvell,armada370-nand";
+                       nand_controller: nand-controller@d0000 {
+                               compatible = "marvell,armada370-nand-controller";
                                reg = <0xd0000 0x54>;
                                #address-cells = <1>;
-                               #size-cells = <1>;
+                               #size-cells = <0>;
                                interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gateclk 11>;
                                status = "disabled";
index d294f24281a51c481c68c14c5ad1f82cc6ad946d..0e4613bb56eeae02d496be3784517760cf425537 100644 (file)
@@ -135,39 +135,6 @@ bm@c8000 {
                                status = "okay";
                        };
 
-                       nfc: flash@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               nand-ecc-strength = <4>;
-                               nand-ecc-step-size = <512>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-
-                               partitions {
-                                       compatible = "fixed-partitions";
-                                       #address-cells = <1>;
-                                       #size-cells = <1>;
-
-                                       partition@0 {
-                                               label = "U-Boot";
-                                               reg = <0x00000000 0x00800000>;
-                                               read-only;
-                                       };
-
-                                       partition@800000 {
-                                               label = "uImage";
-                                               reg = <0x00800000 0x00400000>;
-                                               read-only;
-                                       };
-
-                                       partition@c00000 {
-                                               label = "Root";
-                                               reg = <0x00c00000 0x3f400000>;
-                                       };
-                               };
-                       };
-
                        usb3@f0000 {
                                status = "okay";
                                usb-phy = <&usb3_phy>;
@@ -233,3 +200,39 @@ spi-flash@0 {
                spi-max-frequency = <54000000>;
        };
 };
+
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               nand-on-flash-bbt;
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "U-Boot";
+                               reg = <0x00000000 0x00800000>;
+                               read-only;
+                       };
+
+                       partition@800000 {
+                               label = "uImage";
+                               reg = <0x00800000 0x00400000>;
+                               read-only;
+                       };
+
+                       partition@c00000 {
+                               label = "Root";
+                               reg = <0x00c00000 0x3f400000>;
+                       };
+               };
+       };
+};
index 1f30993af405ede14c7bde3b5db0e31aa4999861..a03050c97084c5c809a2834d70452deb8767b58b 100644 (file)
@@ -73,67 +73,72 @@ sata {
 
 &nand {
        /* 128MiB */
-
-       partition@0 {
-               label = "u-boot";
-               reg = <0x0000000 0x200000>;  /* 2MiB */
-               read-only;
-       };
-
-       partition@100000 {
-               label = "u_env";
-               reg = <0x200000 0x40000>;    /* 256KiB */
-       };
-
-       partition@140000 {
-               label = "s_env";
-               reg = <0x240000 0x40000>;    /* 256KiB */
-       };
-
-       partition@900000 {
-               label = "devinfo";
-               reg = <0x900000 0x100000>;   /* 1MiB */
-               read-only;
-       };
-
-       /* kernel1 overlaps with rootfs1 by design */
-       partition@a00000 {
-               label = "kernel1";
-               reg = <0xa00000 0x2800000>;  /* 40MiB */
-       };
-
-       partition@1000000 {
-               label = "rootfs1";
-               reg = <0x1000000 0x2200000>;  /* 34MiB */
-       };
-
-       /* kernel2 overlaps with rootfs2 by design */
-       partition@3200000 {
-               label = "kernel2";
-               reg = <0x3200000 0x2800000>; /* 40MiB */
-       };
-
-       partition@3800000 {
-               label = "rootfs2";
-               reg = <0x3800000 0x2200000>; /* 34MiB */
-       };
-
-       /*
-        * 38MiB, last MiB is for the BBT, not writable
-        */
-       partition@5a00000 {
-               label = "syscfg";
-               reg = <0x5a00000 0x2600000>;
-       };
-
-       /*
-        * Unused area between "s_env" and "devinfo".
-        * Moved here because otherwise the renumbered
-        * partitions would break the bootloader
-        * supplied bootargs
-        */
-       partition@180000 {
-               label = "unused_area";
-               reg = <0x280000 0x680000>;   /* 6.5MiB */
+       partitions {
+               compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               partition@0 {
+                       label = "u-boot";
+                       reg = <0x0000000 0x200000>;  /* 2MiB */
+                       read-only;
+               };
+
+               partition@100000 {
+                       label = "u_env";
+                       reg = <0x200000 0x40000>;    /* 256KiB */
+               };
+
+               partition@140000 {
+                       label = "s_env";
+                       reg = <0x240000 0x40000>;    /* 256KiB */
+               };
+
+               partition@900000 {
+                       label = "devinfo";
+                       reg = <0x900000 0x100000>;   /* 1MiB */
+                       read-only;
+               };
+
+               /* kernel1 overlaps with rootfs1 by design */
+               partition@a00000 {
+                       label = "kernel1";
+                       reg = <0xa00000 0x2800000>;  /* 40MiB */
+               };
+
+               partition@1000000 {
+                       label = "rootfs1";
+                       reg = <0x1000000 0x2200000>;  /* 34MiB */
+               };
+
+               /* kernel2 overlaps with rootfs2 by design */
+               partition@3200000 {
+                       label = "kernel2";
+                       reg = <0x3200000 0x2800000>; /* 40MiB */
+               };
+
+               partition@3800000 {
+                       label = "rootfs2";
+                       reg = <0x3800000 0x2200000>; /* 34MiB */
+               };
+
+               /*
+                * 38MiB, last MiB is for the BBT, not writable
+                */
+               partition@5a00000 {
+                       label = "syscfg";
+                       reg = <0x5a00000 0x2600000>;
+               };
+
+               /*
+                * Unused area between "s_env" and "devinfo".
+                * Moved here because otherwise the renumbered
+                * partitions would break the bootloader
+                * supplied bootargs
+                */
+               partition@180000 {
+                       label = "unused_area";
+                       reg = <0x280000 0x680000>;   /* 6.5MiB */
+               };
        };
 };
index bc34802ce6bc4084d0125dbe7f93e37ff4e663f2..e3e4877a6f4957ccc9802edac5b86faa5fcfae95 100644 (file)
@@ -73,67 +73,72 @@ sata {
 
 &nand {
        /* 128MiB */
-
-       partition@0 {
-               label = "u-boot";
-               reg = <0x0000000 0x200000>;  /* 2MiB */
-               read-only;
-       };
-
-       partition@100000 {
-               label = "u_env";
-               reg = <0x200000 0x40000>;    /* 256KiB */
-       };
-
-       partition@140000 {
-               label = "s_env";
-               reg = <0x240000 0x40000>;    /* 256KiB */
-       };
-
-       partition@900000 {
-               label = "devinfo";
-               reg = <0x900000 0x100000>;   /* 1MiB */
-               read-only;
-       };
-
-       /* kernel1 overlaps with rootfs1 by design */
-       partition@a00000 {
-               label = "kernel1";
-               reg = <0xa00000 0x2800000>;  /* 40MiB */
-       };
-
-       partition@1000000 {
-               label = "rootfs1";
-               reg = <0x1000000 0x2200000>;  /* 34MiB */
-       };
-
-       /* kernel2 overlaps with rootfs2 by design */
-       partition@3200000 {
-               label = "kernel2";
-               reg = <0x3200000 0x2800000>; /* 40MiB */
-       };
-
-       partition@3800000 {
-               label = "rootfs2";
-               reg = <0x3800000 0x2200000>; /* 34MiB */
-       };
-
-       /*
-        * 38MiB, last MiB is for the BBT, not writable
-        */
-       partition@5a00000 {
-               label = "syscfg";
-               reg = <0x5a00000 0x2600000>;
-       };
-
-       /*
-        * Unused area between "s_env" and "devinfo".
-        * Moved here because otherwise the renumbered
-        * partitions would break the bootloader
-        * supplied bootargs
-        */
-       partition@180000 {
-               label = "unused_area";
-               reg = <0x280000 0x680000>;   /* 6.5MiB */
+       partitions {
+               compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               partition@0 {
+                       label = "u-boot";
+                       reg = <0x0000000 0x200000>;  /* 2MiB */
+                       read-only;
+               };
+
+               partition@100000 {
+                       label = "u_env";
+                       reg = <0x200000 0x40000>;    /* 256KiB */
+               };
+
+               partition@140000 {
+                       label = "s_env";
+                       reg = <0x240000 0x40000>;    /* 256KiB */
+               };
+
+               partition@900000 {
+                       label = "devinfo";
+                       reg = <0x900000 0x100000>;   /* 1MiB */
+                       read-only;
+               };
+
+               /* kernel1 overlaps with rootfs1 by design */
+               partition@a00000 {
+                       label = "kernel1";
+                       reg = <0xa00000 0x2800000>;  /* 40MiB */
+               };
+
+               partition@1000000 {
+                       label = "rootfs1";
+                       reg = <0x1000000 0x2200000>;  /* 34MiB */
+               };
+
+               /* kernel2 overlaps with rootfs2 by design */
+               partition@3200000 {
+                       label = "kernel2";
+                       reg = <0x3200000 0x2800000>; /* 40MiB */
+               };
+
+               partition@3800000 {
+                       label = "rootfs2";
+                       reg = <0x3800000 0x2200000>; /* 34MiB */
+               };
+
+               /*
+                * 38MiB, last MiB is for the BBT, not writable
+                */
+               partition@5a00000 {
+                       label = "syscfg";
+                       reg = <0x5a00000 0x2600000>;
+               };
+
+               /*
+                * Unused area between "s_env" and "devinfo".
+                * Moved here because otherwise the renumbered
+                * partitions would break the bootloader
+                * supplied bootargs
+                */
+               partition@180000 {
+                       label = "unused_area";
+                       reg = <0x280000 0x680000>;   /* 6.5MiB */
+               };
        };
 };
index 5b745a0ccce513d18173ad965a0fc88add4658a2..3c4af57ec2b9e03a407f416a1208a657b0da3dfc 100644 (file)
@@ -81,74 +81,79 @@ &gpio_leds_pins {
 
 &nand {
        /* AMD/Spansion S34ML02G2 256MiB, OEM Layout */
-
-       partition@0 {
-               label = "u-boot";
-               reg = <0x0000000 0x200000>;  /* 2MiB */
-               read-only;
-       };
-
-       partition@200000 {
-               label = "u_env";
-               reg = <0x200000 0x20000>;    /* 128KiB */
-       };
-
-       partition@220000 {
-               label = "s_env";
-               reg = <0x220000 0x40000>;    /* 256KiB */
-       };
-
-       partition@7e0000 {
-               label = "devinfo";
-               reg = <0x7e0000 0x40000>;   /* 256KiB */
-               read-only;
-       };
-
-       partition@820000 {
-               label = "sysdiag";
-               reg = <0x820000 0x1e0000>;   /* 1920KiB */
-               read-only;
-       };
-
-       /* kernel1 overlaps with rootfs1 by design */
-       partition@a00000 {
-               label = "kernel1";
-               reg = <0xa00000 0x5000000>;  /* 80MiB */
-       };
-
-       partition@1000000 {
-               label = "rootfs1";
-               reg = <0x1000000 0x4a00000>;  /* 74MiB */
-       };
-
-       /* kernel2 overlaps with rootfs2 by design */
-       partition@5a00000 {
-               label = "kernel2";
-               reg = <0x5a00000 0x5000000>; /* 80MiB */
-       };
-
-       partition@6000000 {
-               label = "rootfs2";
-               reg = <0x6000000 0x4a00000>; /* 74MiB */
-       };
-
-       /*
-        * 86MiB, last MiB is for the BBT, not writable
-        */
-       partition@aa00000 {
-               label = "syscfg";
-               reg = <0xaa00000 0x5600000>;
-       };
-
-       /*
-        * Unused area between "s_env" and "devinfo".
-        * Moved here because otherwise the renumbered
-        * partitions would break the bootloader
-        * supplied bootargs
-        */
-       partition@180000 {
-               label = "unused_area";
-               reg = <0x260000 0x5c0000>;   /* 5.75MiB */
+       partitions {
+               compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               partition@0 {
+                       label = "u-boot";
+                       reg = <0x0000000 0x200000>;  /* 2MiB */
+                       read-only;
+               };
+
+               partition@200000 {
+                       label = "u_env";
+                       reg = <0x200000 0x20000>;    /* 128KiB */
+               };
+
+               partition@220000 {
+                       label = "s_env";
+                       reg = <0x220000 0x40000>;    /* 256KiB */
+               };
+
+               partition@7e0000 {
+                       label = "devinfo";
+                       reg = <0x7e0000 0x40000>;   /* 256KiB */
+                       read-only;
+               };
+
+               partition@820000 {
+                       label = "sysdiag";
+                       reg = <0x820000 0x1e0000>;   /* 1920KiB */
+                       read-only;
+               };
+
+               /* kernel1 overlaps with rootfs1 by design */
+               partition@a00000 {
+                       label = "kernel1";
+                       reg = <0xa00000 0x5000000>;  /* 80MiB */
+               };
+
+               partition@1000000 {
+                       label = "rootfs1";
+                       reg = <0x1000000 0x4a00000>;  /* 74MiB */
+               };
+
+               /* kernel2 overlaps with rootfs2 by design */
+               partition@5a00000 {
+                       label = "kernel2";
+                       reg = <0x5a00000 0x5000000>; /* 80MiB */
+               };
+
+               partition@6000000 {
+                       label = "rootfs2";
+                       reg = <0x6000000 0x4a00000>; /* 74MiB */
+               };
+
+               /*
+                * 86MiB, last MiB is for the BBT, not writable
+                */
+               partition@aa00000 {
+                       label = "syscfg";
+                       reg = <0xaa00000 0x5600000>;
+               };
+
+               /*
+                * Unused area between "s_env" and "devinfo".
+                * Moved here because otherwise the renumbered
+                * partitions would break the bootloader
+                * supplied bootargs
+                */
+               partition@180000 {
+                       label = "unused_area";
+                       reg = <0x260000 0x5c0000>;   /* 5.75MiB */
+               };
        };
 };
 
index 44f5aeb5fc33e824d2fb9c81e8ad16ba7fb13b1f..3451cd3e5dff9d47cf8a83190447d81ee81b2818 100644 (file)
@@ -73,67 +73,72 @@ sata {
 
 &nand {
        /* 128MiB */
-
-       partition@0 {
-               label = "u-boot";
-               reg = <0x0000000 0x200000>;  /* 2MiB */
-               read-only;
-       };
-
-       partition@100000 {
-               label = "u_env";
-               reg = <0x200000 0x40000>;    /* 256KiB */
-       };
-
-       partition@140000 {
-               label = "s_env";
-               reg = <0x240000 0x40000>;    /* 256KiB */
-       };
-
-       partition@900000 {
-               label = "devinfo";
-               reg = <0x900000 0x100000>;   /* 1MiB */
-               read-only;
-       };
-
-       /* kernel1 overlaps with rootfs1 by design */
-       partition@a00000 {
-               label = "kernel1";
-               reg = <0xa00000 0x2800000>;  /* 40MiB */
-       };
-
-       partition@1000000 {
-               label = "rootfs1";
-               reg = <0x1000000 0x2200000>;  /* 34MiB */
-       };
-
-       /* kernel2 overlaps with rootfs2 by design */
-       partition@3200000 {
-               label = "kernel2";
-               reg = <0x3200000 0x2800000>; /* 40MiB */
-       };
-
-       partition@3800000 {
-               label = "rootfs2";
-               reg = <0x3800000 0x2200000>; /* 34MiB */
-       };
-
-       /*
-        * 38MiB, last MiB is for the BBT, not writable
-        */
-       partition@5a00000 {
-               label = "syscfg";
-               reg = <0x5a00000 0x2600000>;
-       };
-
-       /*
-        * Unused area between "s_env" and "devinfo".
-        * Moved here because otherwise the renumbered
-        * partitions would break the bootloader
-        * supplied bootargs
-        */
-       partition@180000 {
-               label = "unused_area";
-               reg = <0x280000 0x680000>;   /* 6.5MiB */
+       partitions {
+               compatible = "fixed-partitions";
+               #address-cells = <1>;
+               #size-cells = <1>;
+
+               partition@0 {
+                       label = "u-boot";
+                       reg = <0x0000000 0x200000>;  /* 2MiB */
+                       read-only;
+               };
+
+               partition@100000 {
+                       label = "u_env";
+                       reg = <0x200000 0x40000>;    /* 256KiB */
+               };
+
+               partition@140000 {
+                       label = "s_env";
+                       reg = <0x240000 0x40000>;    /* 256KiB */
+               };
+
+               partition@900000 {
+                       label = "devinfo";
+                       reg = <0x900000 0x100000>;   /* 1MiB */
+                       read-only;
+               };
+
+               /* kernel1 overlaps with rootfs1 by design */
+               partition@a00000 {
+                       label = "kernel1";
+                       reg = <0xa00000 0x2800000>;  /* 40MiB */
+               };
+
+               partition@1000000 {
+                       label = "rootfs1";
+                       reg = <0x1000000 0x2200000>;  /* 34MiB */
+               };
+
+               /* kernel2 overlaps with rootfs2 by design */
+               partition@3200000 {
+                       label = "kernel2";
+                       reg = <0x3200000 0x2800000>; /* 40MiB */
+               };
+
+               partition@3800000 {
+                       label = "rootfs2";
+                       reg = <0x3800000 0x2200000>; /* 34MiB */
+               };
+
+               /*
+                * 38MiB, last MiB is for the BBT, not writable
+                */
+               partition@5a00000 {
+                       label = "syscfg";
+                       reg = <0x5a00000 0x2600000>;
+               };
+
+               /*
+                * Unused area between "s_env" and "devinfo".
+                * Moved here because otherwise the renumbered
+                * partitions would break the bootloader
+                * supplied bootargs
+                */
+               partition@180000 {
+                       label = "unused_area";
+                       reg = <0x280000 0x680000>;   /* 6.5MiB */
+               };
        };
 };
index 4a0d7360110b128f586aa67064ab2be618f60d60..827e82be220151ce8e74abdad5eea69061484cb4 100644 (file)
@@ -138,13 +138,19 @@ expander0: pca9635@68 {
        };
 };
 
-&nand {
+&nand_controller {
        /* 128MiB or 256MiB */
        status = "okay";
-       num-cs = <1>;
-       marvell,nand-keep-config;
-       marvell,nand-enable-arbiter;
-       nand-on-flash-bbt;
+       #address-cells = <1>;
+       #size-cells = <0>;
+
+       nand: nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+       };
 };
 
 &mdio {
index 05250d426dc40e395bb3b375c1db8420d42facd5..a2bec07bf4c55190707952545e911b932954b9cd 100644 (file)
@@ -91,29 +91,6 @@ bm@c8000 {
                                status = "okay";
                        };
 
-                       flash@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-                               nand-ecc-strength = <4>;
-                               nand-ecc-step-size = <512>;
-
-                               partition@0 {
-                                       label = "U-Boot";
-                                       reg = <0 0x800000>;
-                               };
-                               partition@800000 {
-                                       label = "Linux";
-                                       reg = <0x800000 0x800000>;
-                               };
-                               partition@1000000 {
-                                       label = "Filesystem";
-                                       reg = <0x1000000 0x3f000000>;
-                               };
-                       };
-
                        sdhci@d8000 {
                                broken-cd;
                                wp-inverted;
@@ -165,3 +142,35 @@ spi-flash@0 {
        };
 };
 
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "U-Boot";
+                               reg = <0 0x800000>;
+                       };
+                       partition@800000 {
+                               label = "Linux";
+                               reg = <0x800000 0x800000>;
+                       };
+                       partition@1000000 {
+                               label = "Filesystem";
+                               reg = <0x1000000 0x3f000000>;
+                       };
+               };
+       };
+};
index 6916d7532ad2ca07117937b388b39a6adc39fed9..18edc9bc79273b794ce263ce7d9674f43732c58e 100644 (file)
@@ -551,11 +551,11 @@ thermal: thermal@e8078 {
                                status = "okay";
                        };
 
-                       nand: flash@d0000 {
-                               compatible = "marvell,armada370-nand";
+                       nand_controller: nand-controller@d0000 {
+                               compatible = "marvell,armada370-nand-controller";
                                reg = <0xd0000 0x54>;
                                #address-cells = <1>;
-                               #size-cells = <1>;
+                               #size-cells = <0>;
                                interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&coredivclk 0>;
                                status = "disabled";
index 1b2362e4c831172986cad7129bef9ad8001e7af4..0e29474ae9a298b613fc65a9c85e6eca7f46dd00 100644 (file)
@@ -49,37 +49,6 @@ usb@58000 {
                                status = "okay";
                        };
 
-                       flash@d0000 {
-                               status = "okay";
-                               pinctrl-0 = <&nand_pins>;
-                               pinctrl-names = "default";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-                               nand-ecc-strength = <8>;
-                               nand-ecc-step-size = <512>;
-
-                               partitions {
-                                       compatible = "fixed-partitions";
-                                       #address-cells = <1>;
-                                       #size-cells = <1>;
-
-                                       partition@0 {
-                                               label = "U-Boot";
-                                               reg = <0 0x800000>;
-                                       };
-                                       partition@800000 {
-                                               label = "Linux";
-                                               reg = <0x800000 0x800000>;
-                                       };
-                                       partition@1000000 {
-                                               label = "Filesystem";
-                                               reg = <0x1000000 0x3f000000>;
-                                       };
-                               };
-                       };
-
                        /* CON98 */
                        usb3@f8000 {
                                status = "okay";
@@ -136,3 +105,38 @@ partition@400000 {
                };
        };
 };
+
+&nand_controller {
+       status = "okay";
+       pinctrl-0 = <&nand_pins>;
+       pinctrl-names = "default";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+               nand-ecc-strength = <8>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "U-Boot";
+                               reg = <0 0x800000>;
+                       };
+                       partition@800000 {
+                               label = "Linux";
+                               reg = <0x800000 0x800000>;
+                       };
+                       partition@1000000 {
+                               label = "Filesystem";
+                               reg = <0x1000000 0x3f000000>;
+                       };
+               };
+       };
+};
index 2a9de192b423bb782ec4229113c898a43897e662..6dd9e9077f8421c740801c57b6d6028de8a5cafb 100644 (file)
@@ -57,41 +57,6 @@ sata@a8000 {
                                status = "okay";
                        };
 
-                       flash@d0000 {
-                               status = "okay";
-                               pinctrl-0 = <&nand_pins>;
-                               pinctrl-names = "default";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-                               nand-ecc-strength = <4>;
-                               nand-ecc-step-size = <512>;
-
-                               partitions {
-                                       compatible = "fixed-partitions";
-                                       #address-cells = <1>;
-                                       #size-cells = <1>;
-
-                                       partition@0 {
-                                               label = "U-Boot";
-                                               reg = <0x00000000 0x00600000>;
-                                               read-only;
-                                       };
-
-                                       partition@800000 {
-                                               label = "uImage";
-                                               reg = <0x00600000 0x00400000>;
-                                               read-only;
-                                       };
-
-                                       partition@1000000 {
-                                               label = "Root";
-                                               reg = <0x00a00000 0x3f600000>;
-                                       };
-                               };
-                       };
-
                        /* CON18 */
                        sdhci@d8000 {
                                clock-frequency = <200000000>;
@@ -130,3 +95,42 @@ pcie@4,0 {
                };
        };
 };
+
+&nand_controller {
+       status = "okay";
+       pinctrl-0 = <&nand_pins>;
+       pinctrl-names = "default";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "U-Boot";
+                               reg = <0x00000000 0x00600000>;
+                               read-only;
+                       };
+
+                       partition@800000 {
+                               label = "uImage";
+                               reg = <0x00600000 0x00400000>;
+                               read-only;
+                       };
+
+                       partition@1000000 {
+                               label = "Root";
+                               reg = <0x00a00000 0x3f600000>;
+                       };
+               };
+       };
+};
index 2337f24784f73f6811e6af7d4e9df169342d7402..fc28308e5bc5db5f29e2f897304594e0b3a1be9b 100644 (file)
@@ -51,31 +51,6 @@ usb@58000 {
                                status = "okay";
                        };
 
-                       flash@d0000 {
-                               status = "okay";
-                               pinctrl-0 = <&nand_pins>;
-                               pinctrl-names = "default";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-                               nand-ecc-strength = <8>;
-                               nand-ecc-step-size = <512>;
-
-                               partition@0 {
-                                       label = "U-Boot";
-                                       reg = <0 0x800000>;
-                               };
-                               partition@800000 {
-                                       label = "Linux";
-                                       reg = <0x800000 0x800000>;
-                               };
-                               partition@1000000 {
-                                       label = "Filesystem";
-                                       reg = <0x1000000 0x3f000000>;
-                               };
-                       };
-
                        usb3@f8000 {
                                status = "okay";
                        };
@@ -122,3 +97,38 @@ partition@400000 {
                };
        };
 };
+
+&nand_controller {
+       status = "okay";
+       pinctrl-0 = <&nand_pins>;
+       pinctrl-names = "default";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+               nand-ecc-strength = <8>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "U-Boot";
+                               reg = <0 0x800000>;
+                       };
+                       partition@800000 {
+                               label = "Linux";
+                               reg = <0x800000 0x800000>;
+                       };
+                       partition@1000000 {
+                               label = "Filesystem";
+                               reg = <0x1000000 0x3f000000>;
+                       };
+               };
+       };
+};
index c1737c0a832536c8c3296c654cda3dcd3a800bf9..f0c949831efb7e59617b0781314d0a581b370a91 100644 (file)
@@ -367,11 +367,11 @@ rtc@a3800 {
                                interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
                        };
 
-                       flash@d0000 {
-                               compatible = "marvell,armada370-nand";
+                       nand_controller: nand-controller@d0000 {
+                               compatible = "marvell,armada370-nand-controller";
                                reg = <0xd0000 0x54>;
                                #address-cells = <1>;
-                               #size-cells = <1>;
+                               #size-cells = <0>;
                                interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&coredivclk 0>;
                                status = "disabled";
index a5da44fb35ed02e3f136fda11c26632b4021dfbc..8d708cc224958865a3c208b1ec29c03118c0852f 100644 (file)
@@ -306,6 +306,19 @@ &usb1 {
 &pinctrl {
        compatible = "marvell,98dx3236-pinctrl";
 
+       nand_pins: nand-pins {
+               marvell,pins = "mpp20", "mpp21", "mpp22",
+                              "mpp23", "mpp24", "mpp25",
+                              "mpp26", "mpp27", "mpp28",
+                              "mpp29", "mpp30";
+               marvell,function = "dev";
+       };
+
+       nand_rb: nand-rb {
+               marvell,pins = "mpp19";
+               marvell,function = "nand";
+       };
+
        spi0_pins: spi0-pins {
                marvell,pins = "mpp0", "mpp1",
                               "mpp2", "mpp3";
index 4c64923f1c524837d7e0dbc133c81400a141f2da..f42fc6118b7c296c582c6a2f56d904f929f40237 100644 (file)
@@ -70,9 +70,9 @@ &uart1 {
 
 &nand {
        status = "okay";
+       label = "pxa3xx_nand-0";
        num-cs = <1>;
        marvell,nand-keep-config;
-       marvell,nand-enable-arbiter;
        nand-on-flash-bbt;
        nand-ecc-strength = <4>;
        nand-ecc-step-size = <512>;
index a0ebb52683f1728a7026cbe26ea59e9458c371db..8432f517e346124cb82e0c2eed896680c022891f 100644 (file)
@@ -69,9 +69,9 @@ &i2c0 {
 
 &nand {
        status = "okay";
+       label = "pxa3xx_nand-0";
        num-cs = <1>;
        marvell,nand-keep-config;
-       marvell,nand-enable-arbiter;
        nand-on-flash-bbt;
        nand-ecc-strength = <4>;
        nand-ecc-step-size = <512>;
index 73d3f5cb9828bd33b990d76509c2b58273cede53..f3ac7483afed0997ff527e8c8cef68c3a7307367 100644 (file)
@@ -146,9 +146,9 @@ usb@52000 {
 
                        nand@d0000 {
                                status = "okay";
+                               label = "pxa3xx_nand-0";
                                num-cs = <1>;
                                marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
                                nand-on-flash-bbt;
 
                                partitions {
index c143556bbb7b069baa0911a4cdf11e428d739f32..1139e9469a83792efc102ff2c8dd375d1c5591b3 100644 (file)
@@ -162,9 +162,9 @@ bm@c0000 {
 
                        nand@d0000 {
                                status = "okay";
+                               label = "pxa3xx_nand-0";
                                num-cs = <1>;
                                marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
                                nand-on-flash-bbt;
                        };
                };
index def62e9e835b737b41f54da350d46fd03e423391..bbbb38888bb89db8ef5b1814873b7285341e7590 100644 (file)
@@ -83,9 +83,9 @@ pcf8563@51 {
 
                        nand@d0000 {
                                status = "okay";
+                               label = "pxa3xx_nand-0";
                                num-cs = <1>;
                                marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
                                nand-on-flash-bbt;
 
                                partitions {
index f8b60d937818440493b0a51611d41644890d41f2..7a2606c3b62e94119946955875ff87dbc798530d 100644 (file)
@@ -165,79 +165,6 @@ wps_amber@9 {
                        bm@c8000 {
                                status = "okay";
                        };
-
-                       nand@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-                               nand-ecc-strength = <4>;
-                               nand-ecc-step-size = <512>;
-
-                               partition@0 {
-                                       label = "u-boot";
-                                       reg = <0x0000000 0x100000>;  /* 1MB */
-                                       read-only;
-                               };
-
-                               partition@100000 {
-                                       label = "u_env";
-                                       reg = <0x100000 0x40000>;    /* 256KB */
-                               };
-
-                               partition@140000 {
-                                       label = "s_env";
-                                       reg = <0x140000 0x40000>;    /* 256KB */
-                               };
-
-                               partition@900000 {
-                                       label = "devinfo";
-                                       reg = <0x900000 0x100000>;   /* 1MB */
-                                       read-only;
-                               };
-
-                               /* kernel1 overlaps with rootfs1 by design */
-                               partition@a00000 {
-                                       label = "kernel1";
-                                       reg = <0xa00000 0x2800000>;  /* 40MB */
-                               };
-
-                               partition@d00000 {
-                                       label = "rootfs1";
-                                       reg = <0xd00000 0x2500000>;  /* 37MB */
-                               };
-
-                               /* kernel2 overlaps with rootfs2 by design */
-                               partition@3200000 {
-                                       label = "kernel2";
-                                       reg = <0x3200000 0x2800000>; /* 40MB */
-                               };
-
-                               partition@3500000 {
-                                       label = "rootfs2";
-                                       reg = <0x3500000 0x2500000>; /* 37MB */
-                               };
-
-                               /*
-                                * 38MB, last MB is for the BBT, not writable
-                                */
-                               partition@5a00000 {
-                                       label = "syscfg";
-                                       reg = <0x5a00000 0x2600000>;
-                               };
-
-                               /*
-                                * Unused area between "s_env" and "devinfo".
-                                * Moved here because otherwise the renumbered
-                                * partitions would break the bootloader
-                                * supplied bootargs
-                                */
-                               partition@180000 {
-                                       label = "unused_area";
-                                       reg = <0x180000 0x780000>;   /* 7.5MB */
-                               };
-                       };
                };
 
                bm-bppi {
@@ -434,3 +361,86 @@ fixed-link {
                };
        };
 };
+
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0000000 0x100000>;  /* 1MB */
+                               read-only;
+                       };
+
+                       partition@100000 {
+                               label = "u_env";
+                               reg = <0x100000 0x40000>;    /* 256KB */
+                       };
+
+                       partition@140000 {
+                               label = "s_env";
+                               reg = <0x140000 0x40000>;    /* 256KB */
+                       };
+
+                       partition@900000 {
+                               label = "devinfo";
+                               reg = <0x900000 0x100000>;   /* 1MB */
+                               read-only;
+                       };
+
+                       /* kernel1 overlaps with rootfs1 by design */
+                       partition@a00000 {
+                               label = "kernel1";
+                               reg = <0xa00000 0x2800000>;  /* 40MB */
+                       };
+
+                       partition@d00000 {
+                               label = "rootfs1";
+                               reg = <0xd00000 0x2500000>;  /* 37MB */
+                       };
+
+                       /* kernel2 overlaps with rootfs2 by design */
+                       partition@3200000 {
+                               label = "kernel2";
+                               reg = <0x3200000 0x2800000>; /* 40MB */
+                       };
+
+                       partition@3500000 {
+                               label = "rootfs2";
+                               reg = <0x3500000 0x2500000>; /* 37MB */
+                       };
+
+                       /*
+                        * 38MB, last MB is for the BBT, not writable
+                        */
+                       partition@5a00000 {
+                               label = "syscfg";
+                               reg = <0x5a00000 0x2600000>;
+                       };
+
+                       /*
+                        * Unused area between "s_env" and "devinfo".
+                        * Moved here because otherwise the renumbered
+                        * partitions would break the bootloader
+                        * supplied bootargs
+                        */
+                       partition@180000 {
+                               label = "unused_area";
+                               reg = <0x180000 0x780000>;   /* 7.5MB */
+                       };
+               };
+       };
+};
index c350b1cf5201fa9c643f970ea421cf1bb77601b7..8ea73587db81123f82dc5a5d170146c929b628b5 100644 (file)
@@ -117,46 +117,6 @@ sata@a0000 {
                                nr-ports = <2>;
                                status = "okay";
                        };
-
-                       nand@d0000 {
-                               status = "okay";
-                               num-cs = <1>;
-                               marvell,nand-keep-config;
-                               marvell,nand-enable-arbiter;
-                               nand-on-flash-bbt;
-
-                               /* Use Hardware BCH ECC */
-                               nand-ecc-strength = <4>;
-                               nand-ecc-step-size = <512>;
-
-                               partition@0 {
-                                       label = "u-boot";
-                                       reg = <0x0000000 0x180000>;  /* 1.5MB */
-                                       read-only;
-                               };
-
-                               partition@180000 {
-                                       label = "u-boot-env";
-                                       reg = <0x180000 0x20000>;    /* 128KB */
-                                       read-only;
-                               };
-
-                               partition@200000 {
-                                       label = "uImage";
-                                       reg = <0x0200000 0x600000>;    /* 6MB */
-                               };
-
-                               partition@800000 {
-                                       label = "minirootfs";
-                                       reg = <0x0800000 0x400000>;    /* 4MB */
-                               };
-
-                               /* Last MB is for the BBT, i.e. not writable */
-                               partition@c00000 {
-                                       label = "ubifs";
-                                       reg = <0x0c00000 0x7400000>; /* 116MB */
-                               };
-                       };
                };
        };
 
@@ -345,3 +305,53 @@ err_led_pin: err-led-pin {
                marvell,function = "gpio";
        };
 };
+
+&nand_controller {
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               label = "pxa3xx_nand-0";
+               nand-rb = <0>;
+               marvell,nand-keep-config;
+               nand-on-flash-bbt;
+
+               /* Use Hardware BCH ECC */
+               nand-ecc-strength = <4>;
+               nand-ecc-step-size = <512>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "u-boot";
+                               reg = <0x0000000 0x180000>;  /* 1.5MB */
+                               read-only;
+                       };
+
+                       partition@180000 {
+                               label = "u-boot-env";
+                               reg = <0x180000 0x20000>;    /* 128KB */
+                               read-only;
+                       };
+
+                       partition@200000 {
+                               label = "uImage";
+                               reg = <0x0200000 0x600000>;    /* 6MB */
+                       };
+
+                       partition@800000 {
+                               label = "minirootfs";
+                               reg = <0x0800000 0x400000>;    /* 4MB */
+                       };
+
+                       /* Last MB is for the BBT, i.e. not writable */
+                       partition@c00000 {
+                               label = "ubifs";
+                               reg = <0x0c00000 0x7400000>; /* 116MB */
+                       };
+               };
+       };
+};
index 91a36c1f029bd777fd0e1a510846a5bdab706556..ede11c597673677461cd69e527f864685f87b829 100644 (file)
@@ -79,3 +79,21 @@ lm75@4d {
                reg = <0x4d>;
        };
 };
+
+&ehci0 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usb2ah_default>;
+};
+
+&ehci1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usb2bh_default>;
+};
+
+&uhci {
+       status = "okay";
+
+       /* No pinctrl, this follows the above EHCI settings */
+};
diff --git a/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts b/arch/arm/boot/dts/aspeed-bmc-intel-s2600wf.dts
new file mode 100644 (file)
index 0000000..7a291de
--- /dev/null
@@ -0,0 +1,129 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2017 Intel Corporation
+/dts-v1/;
+
+#include "aspeed-g5.dtsi"
+
+/ {
+       model = "S2600WF BMC";
+       compatible = "intel,s2600wf-bmc", "aspeed,ast2500";
+
+       chosen {
+               stdout-path = &uart5;
+               bootargs = "earlyprintk";
+       };
+
+       memory {
+               reg = <0x80000000 0x20000000>;
+       };
+
+       reserved-memory {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges;
+
+               vga_memory: framebuffer@7f000000 {
+                       no-map;
+                       reg = <0x7f000000 0x01000000>;
+               };
+       };
+
+       iio-hwmon {
+               compatible = "iio-hwmon";
+               io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>,
+                       <&adc 4>, <&adc 5>, <&adc 6>, <&adc 7>,
+                       <&adc 8>, <&adc 9>, <&adc 10>, <&adc 11>,
+                       <&adc 12>, <&adc 13>, <&adc 14>, <&adc 15>;
+       };
+
+};
+
+&fmc {
+       status = "okay";
+       flash@0 {
+               status = "okay";
+               m25p,fast-read;
+               label = "bmc";
+#include "openbmc-flash-layout.dtsi"
+       };
+};
+
+&spi1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_spi1_default>;
+
+       flash@0 {
+               status = "okay";
+               m25p,fast-read;
+               label = "pnor";
+       };
+};
+
+&uart5 {
+       status = "okay";
+};
+
+&mac0 {
+       status = "okay";
+
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_rmii1_default>;
+       use-ncsi;
+};
+
+&mac1 {
+       status = "okay";
+
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_rgmii2_default &pinctrl_mdio2_default>;
+};
+
+&i2c1 {
+       status = "okay";
+};
+
+&i2c2 {
+       status = "okay";
+};
+
+&i2c3 {
+       status = "okay";
+};
+
+&i2c4 {
+       status = "okay";
+};
+
+&i2c5 {
+       status = "okay";
+};
+
+&i2c6 {
+       status = "okay";
+};
+
+&i2c7 {
+       status = "okay";
+};
+
+&i2c13 {
+       status = "okay";
+};
+
+&gfx {
+       status = "okay";
+};
+
+&pinctrl {
+       aspeed,external-nodes = <&gfx &lhc>;
+};
+
+&pwm_tacho {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_pwm0_default &pinctrl_pwm1_default
+                        &pinctrl_pwm2_default &pinctrl_pwm3_default
+                        &pinctrl_pwm4_default &pinctrl_pwm5_default
+                        &pinctrl_pwm6_default &pinctrl_pwm7_default>;
+};
diff --git a/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts b/arch/arm/boot/dts/aspeed-bmc-opp-lanyang.dts
new file mode 100644 (file)
index 0000000..d598b63
--- /dev/null
@@ -0,0 +1,325 @@
+// SPDX-License-Identifier: GPL-2.0+
+// Copyright (c) 2018 Inventec Corporation
+/dts-v1/;
+
+#include "aspeed-g5.dtsi"
+#include <dt-bindings/gpio/aspeed-gpio.h>
+
+/ {
+       model = "Lanyang BMC";
+       compatible = "inventec,lanyang-bmc", "aspeed,ast2500";
+
+       chosen {
+               stdout-path = &uart5;
+               bootargs = "console=ttyS4,115200 earlyprintk";
+       };
+
+       memory {
+               reg = <0x80000000 0x40000000>;
+       };
+
+       reserved-memory {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges;
+
+               flash_memory: region@98000000 {
+                       no-map;
+                       reg = <0x98000000 0x04000000>; /* 64M */
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               sys_boot_status {
+                       label = "System_boot_status";
+                       gpios = <&gpio ASPEED_GPIO(B, 6) GPIO_ACTIVE_LOW>;
+               };
+
+               attention {
+                       label = "Attention_locator";
+                       gpios = <&gpio ASPEED_GPIO(B, 7) GPIO_ACTIVE_HIGH>;
+               };
+
+               plt_fault {
+                       label = "Platform_fault";
+                       gpios = <&gpio ASPEED_GPIO(B, 1) GPIO_ACTIVE_HIGH>;
+               };
+
+               hdd_fault {
+                       label = "Onboard_drive_fault";
+                       gpios = <&gpio ASPEED_GPIO(B, 3) GPIO_ACTIVE_HIGH>;
+               };
+               bmc_err {
+                       lable = "BMC_fault";
+                       gpios = <&gpio ASPEED_GPIO(H, 6) GPIO_ACTIVE_HIGH>;
+               };
+
+               sys_err {
+                       lable = "Sys_fault";
+                       gpios = <&gpio ASPEED_GPIO(H, 7) GPIO_ACTIVE_HIGH>;
+               };
+       };
+
+       fsi: gpio-fsi {
+               compatible = "fsi-master-gpio", "fsi-master";
+               #address-cells = <2>;
+               #size-cells = <0>;
+
+               clock-gpios = <&gpio ASPEED_GPIO(J, 0) GPIO_ACTIVE_HIGH>;
+               data-gpios = <&gpio ASPEED_GPIO(J, 1) GPIO_ACTIVE_HIGH>;
+               trans-gpios = <&gpio ASPEED_GPIO(D, 5) GPIO_ACTIVE_HIGH>;
+               enable-gpios = <&gpio ASPEED_GPIO(D, 0) GPIO_ACTIVE_HIGH>;
+               mux-gpios = <&gpio ASPEED_GPIO(H, 2) GPIO_ACTIVE_HIGH>;
+       };
+
+       iio-hwmon {
+               compatible = "iio-hwmon";
+               io-channels = <&adc 0>, <&adc 1>, <&adc 2>, <&adc 3>,
+                       <&adc 4>, <&adc 5>, <&adc 6>, <&adc 7>,
+                       <&adc 8>, <&adc 9>, <&adc 10>, <&adc 11>,
+                       <&adc 13>, <&adc 14>, <&adc 15>;
+       };
+
+       iio-hwmon-battery {
+               compatible = "iio-hwmon";
+               io-channels = <&adc 12>;
+       };
+};
+
+&pwm_tacho {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_pwm0_default &pinctrl_pwm1_default
+               &pinctrl_pwm2_default &pinctrl_pwm3_default>;
+
+       fan@0 {
+               reg = <0x00>;
+               aspeed,fan-tach-ch = /bits/ 8 <0x00>;
+       };
+
+       fan@1 {
+               reg = <0x01>;
+               aspeed,fan-tach-ch = /bits/ 8 <0x01>;
+       };
+
+       fan@2 {
+               reg = <0x02>;
+               aspeed,fan-tach-ch = /bits/ 8 <0x02>;
+       };
+
+       fan@3 {
+               reg = <0x03>;
+               aspeed,fan-tach-ch = /bits/ 8 <0x03>;
+       };
+};
+
+&fmc {
+       status = "okay";
+       flash@0 {
+               status = "okay";
+               m25p,fast-read;
+               label = "bmc";
+#include "openbmc-flash-layout.dtsi"
+       };
+};
+
+&spi1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_spi1_default>;
+
+       flash@0 {
+               status = "okay";
+               label = "pnor";
+               m25p,fast-read;
+       };
+};
+
+&spi2 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_spi2ck_default
+                    &pinctrl_spi2cs0_default
+                    &pinctrl_spi2cs1_default
+                    &pinctrl_spi2miso_default
+                    &pinctrl_spi2mosi_default>;
+
+       flash@0 {
+               status = "okay";
+       };
+};
+
+&uart1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_txd1_default
+                    &pinctrl_rxd1_default>;
+};
+
+&lpc_ctrl {
+       status = "okay";
+       memory-region = <&flash_memory>;
+       flash = <&spi1>;
+};
+
+&lpc_snoop {
+       status = "okay";
+       snoop-ports = <0x80>;
+};
+
+&uart5 {
+       status = "okay";
+};
+
+&mac0 {
+       status = "okay";
+
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_rmii1_default>;
+       use-ncsi;
+};
+
+&mac1 {
+       status = "okay";
+
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_rgmii2_default &pinctrl_mdio2_default>;
+};
+
+&i2c0 {
+       status = "okay";
+
+       eeprom@55 {
+               compatible = "atmel,24c64";
+               reg = <0x55>;
+               pagesize = <32>;
+       };
+
+       rtc@68 {
+               compatible = "nxp,pcf8523";
+               reg = <0x68>;
+       };
+
+       tmp75@48 {
+               compatible = "ti,tmp75";
+               reg = <0x48>;
+       };
+};
+
+&i2c1 {
+       status = "okay";
+};
+
+&i2c2 {
+       status = "okay";
+};
+
+&i2c3 {
+       status = "okay";
+};
+
+&i2c4 {
+       status = "okay";
+};
+
+&i2c5 {
+       status = "okay";
+};
+
+&i2c6 {
+       status = "okay";
+};
+
+&i2c7 {
+       status = "okay";
+};
+
+&i2c8 {
+       status = "okay";
+};
+
+&i2c9 {
+       status = "okay";
+};
+
+&i2c10 {
+       status = "okay";
+};
+
+&i2c11 {
+       status = "okay";
+};
+
+&vuart {
+       status = "okay";
+};
+
+&gfx {
+       status = "okay";
+};
+
+&pinctrl {
+       aspeed,external-nodes = <&gfx &lhc>;
+};
+
+&gpio {
+       pin_gpio_b0 {
+               gpio-hog;
+               gpios = <ASPEED_GPIO(B, 0) GPIO_ACTIVE_HIGH>;
+               output-high;
+               line-name = "BMC_HDD1_PWR_EN";
+       };
+
+       pin_gpio_b5 {
+               gpio-hog;
+               gpios = <ASPEED_GPIO(B, 5) GPIO_ACTIVE_HIGH>;
+               input;
+               line-name = "BMC_USB1_OCI2";
+       };
+
+       pin_gpio_h5 {
+               gpio-hog;
+               gpios = <ASPEED_GPIO(H, 5) GPIO_ACTIVE_HIGH>;
+               output-high;
+               line-name = "BMC_CP0_PERST_ENABLE_R";
+       };
+
+       pin_gpio_z2 {
+               gpio-hog;
+               gpios = <ASPEED_GPIO(Z, 2) GPIO_ACTIVE_HIGH>;
+               output-high;
+               line-name = "RST_PCA9546_U177_N";
+       };
+
+       pin_gpio_aa6 {
+               gpio-hog;
+               gpios = <ASPEED_GPIO(AA, 6) GPIO_ACTIVE_HIGH>;
+               output-high;
+               line-name = "BMC_CP0_RESET_N";
+       };
+
+       pin_gpio_aa7 {
+               gpio-hog;
+               gpios = <ASPEED_GPIO(AA, 7) GPIO_ACTIVE_HIGH>;
+               output-high;
+               line-name = "BMC_TPM_RESET_N";
+       };
+
+       pin_gpio_ab0 {
+               gpio-hog;
+               gpios = <ASPEED_GPIO(AB, 0) GPIO_ACTIVE_LOW>;
+               output-high;
+               line-name = "BMC_USB_PWRON_N";
+       };
+};
+
+&ibt {
+       status = "okay";
+};
+
+&adc {
+       status = "okay";
+};
+
index 51bc6a2e9dd57b8dc4f496b3e316f1e7a4472746..389f5f83bef90a67a1506a785087e1851c809309 100644 (file)
@@ -68,6 +68,12 @@ checkstop {
                        gpios = <&gpio ASPEED_GPIO(J, 2) GPIO_ACTIVE_LOW>;
                        linux,code = <ASPEED_GPIO(J, 2)>;
                };
+
+               id-button {
+                       label = "id-button";
+                       gpios = <&gpio ASPEED_GPIO(Q, 7) GPIO_ACTIVE_LOW>;
+                       linux,code = <ASPEED_GPIO(Q, 7)>;
+               };
        };
 };
 
index 7056231cbee65cbb6d5ec799649e07753620c015..78a511e6e4824c14c02f4f4662c85e219ae7cb32 100644 (file)
@@ -28,6 +28,34 @@ flash_memory: region@98000000 {
                };
        };
 
+       gpio-keys {
+               compatible = "gpio-keys";
+
+               air-water {
+                       label = "air-water";
+                       gpios = <&gpio ASPEED_GPIO(B, 5) GPIO_ACTIVE_LOW>;
+                       linux,code = <ASPEED_GPIO(B, 5)>;
+               };
+
+               checkstop {
+                       label = "checkstop";
+                       gpios = <&gpio ASPEED_GPIO(J, 2) GPIO_ACTIVE_LOW>;
+                       linux,code = <ASPEED_GPIO(J, 2)>;
+               };
+
+               ps0-presence {
+                       label = "ps0-presence";
+                       gpios = <&gpio ASPEED_GPIO(P, 7) GPIO_ACTIVE_LOW>;
+                       linux,code = <ASPEED_GPIO(P, 7)>;
+               };
+
+               ps1-presence {
+                       label = "ps1-presence";
+                       gpios = <&gpio ASPEED_GPIO(N, 0) GPIO_ACTIVE_LOW>;
+                       linux,code = <ASPEED_GPIO(N, 0)>;
+               };
+       };
+
        gpio-keys-polled {
                compatible = "gpio-keys-polled";
                #address-cells = <1>;
@@ -547,6 +575,10 @@ &wdt1 {
        pinctrl-0 = <&pinctrl_wdtrst1_default>;
 };
 
+&wdt2 {
+       aspeed,alt-boot;
+};
+
 &ibt {
        status = "okay";
 };
index ebe726a0d3116911a8e86002e6781902a9710861..ccbf645ab84d13ed06ee04c61ed786fea75ab696 100644 (file)
@@ -55,6 +55,12 @@ checkstop {
                        gpios = <&gpio ASPEED_GPIO(F, 7) GPIO_ACTIVE_LOW>;
                        linux,code = <ASPEED_GPIO(F, 7)>;
                };
+
+               pcie-e2b-present{
+                       label = "pcie-e2b-present";
+                       gpios = <&gpio ASPEED_GPIO(E, 7) GPIO_ACTIVE_LOW>;
+                       linux,code = <ASPEED_GPIO(E, 7)>;
+               };
        };
 
        leds {
diff --git a/arch/arm/boot/dts/aspeed-bmc-portwell-neptune.dts b/arch/arm/boot/dts/aspeed-bmc-portwell-neptune.dts
new file mode 100644 (file)
index 0000000..43ed139
--- /dev/null
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2017 Facebook Inc.
+/dts-v1/;
+
+#include "aspeed-g5.dtsi"
+#include <dt-bindings/gpio/aspeed-gpio.h>
+
+/ {
+       model = "Portwell Neptune BMC";
+       compatible = "portwell,neptune-bmc", "aspeed,ast2500";
+       aliases {
+               serial0 = &uart1;
+               serial4 = &uart5;
+       };
+       chosen {
+               stdout-path = &uart5;
+               bootargs = "console=ttyS4,115200 earlyprintk";
+       };
+
+       memory {
+               reg = <0x80000000 0x20000000>;
+       };
+
+       leds {
+               compatible = "gpio-leds";
+               postcode0 {
+                       label="BMC_UP";
+                       gpios = <&gpio ASPEED_GPIO(H, 0) GPIO_ACTIVE_HIGH>;
+                       default-state = "on";
+               };
+               postcode1 {
+                       label="BMC_HB";
+                       gpios = <&gpio ASPEED_GPIO(H, 1) GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "heartbeat";
+               };
+               postcode2 {
+                       label="FAULT";
+                       gpios = <&gpio ASPEED_GPIO(H, 2) GPIO_ACTIVE_HIGH>;
+               };
+               // postcode3-7 are GPIOH3-H7
+       };
+};
+
+&fmc {
+       status = "okay";
+       flash@0 {
+               status = "okay";
+               m25p,fast-read;
+#include "openbmc-flash-layout.dtsi"
+       };
+};
+
+&spi1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_spi1_default>;
+       flash@0 {
+               status = "okay";
+               m25p,fast-read;
+               label = "pnor";
+       };
+};
+
+&uart1 {
+       // Host Console
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_txd1_default
+                    &pinctrl_rxd1_default>;
+};
+
+&uart5 {
+       // BMC Console
+       status = "okay";
+};
+
+&mac0 {
+       status = "okay";
+
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_rmii1_default
+                    &pinctrl_mdio1_default>;
+};
+
+&mac1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_rmii2_default>;
+       use-ncsi;
+};
+
+&i2c1 {
+       status = "okay";
+       // To PCIe slot SMBUS
+};
+
+&i2c2 {
+       status = "okay";
+       // To LAN I210
+};
+
+&i2c3 {
+       status = "okay";
+       // SMBus to COMe AB
+};
+
+&i2c4 {
+       status = "okay";
+       // I2C to COMe AB
+};
+
+&i2c5 {
+       status = "okay";
+//     USB Debug card
+       pca9555@27 {
+               compatible = "nxp,pca9555";
+               reg = <0x27>;
+       };
+};
+
+&i2c6 {
+       status = "okay";
+       tpm@20 {
+               compatible = "infineon,slb9645tt";
+               reg = <0x20>;
+       };
+       tmp421@4e {
+               compatible = "ti,tmp421";
+               reg = <0x4e>;
+       };
+       tmp421@4f {
+               compatible = "ti,tmp421";
+               reg = <0x4f>;
+       };
+};
+
+&i2c8 {
+       status = "okay";
+       eeprom@51 {
+               compatible = "atmel,24c128";
+               reg = <0x51>;
+               pagesize = <32>;
+       };
+};
+
+&pwm_tacho {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_pwm0_default &pinctrl_pwm1_default>;
+       fan@0 {
+               reg = <0x00>;
+               aspeed,fan-tach-ch = /bits/ 8 <0x00>;
+       };
+
+       fan@1 {
+               reg = <0x00>;
+               aspeed,fan-tach-ch = /bits/ 8 <0x01>;
+       };
+};
index 518d2bc7c7fca3e2ba1363c835c561c8e81c6cb4..75df1573380e923ac7f9bacdd5b8edb381a897c8 100644 (file)
@@ -108,6 +108,23 @@ mac1: ethernet@1e680000 {
                        status = "disabled";
                };
 
+               ehci0: usb@1e6a1000 {
+                       compatible = "aspeed,ast2400-ehci", "generic-ehci";
+                       reg = <0x1e6a1000 0x100>;
+                       interrupts = <5>;
+                       clocks = <&syscon ASPEED_CLK_GATE_USBPORT1CLK>;
+                       status = "disabled";
+               };
+
+               uhci: usb@1e6b0000 {
+                       compatible = "aspeed,ast2400-uhci", "generic-uhci";
+                       reg = <0x1e6b0000 0x100>;
+                       interrupts = <14>;
+                       #ports = <3>;
+                       clocks = <&syscon ASPEED_CLK_GATE_USBUHCICLK>;
+                       status = "disabled";
+               };
+
                apb {
                        compatible = "simple-bus";
                        #address-cells = <1>;
@@ -125,6 +142,14 @@ syscon: syscon@1e6e2000 {
                                pinctrl: pinctrl {
                                        compatible = "aspeed,g4-pinctrl";
                                };
+
+                       };
+
+                       rng: hwrng@1e6e2078 {
+                               compatible = "timeriomem_rng";
+                               reg = <0x1e6e2078 0x4>;
+                               period = <1>;
+                               quality = <100>;
                        };
 
                        adc: adc@1e6e9000 {
@@ -1250,6 +1275,16 @@ pinctrl_usbcki_default: usbcki_default {
                groups = "USBCKI";
        };
 
+       pinctrl_usb2h_default: usb2h_default {
+               function = "USB2H1";
+               groups = "USB2H1";
+       };
+
+       pinctrl_usb2d_default: usb2d_default {
+               function = "USB2D1";
+               groups = "USB2D1";
+       };
+
        pinctrl_vgabios_rom_default: vgabios_rom_default {
                function = "VGABIOS_ROM";
                groups = "VGABIOS_ROM";
index f9917717dd088faa33227177ceca19d822ae632f..17f2714d18a7ec09e4722d557831379e38157b89 100644 (file)
@@ -143,6 +143,31 @@ mac1: ethernet@1e680000 {
                        status = "disabled";
                };
 
+               ehci0: usb@1e6a1000 {
+                       compatible = "aspeed,ast2500-ehci", "generic-ehci";
+                       reg = <0x1e6a1000 0x100>;
+                       interrupts = <5>;
+                       clocks = <&syscon ASPEED_CLK_GATE_USBPORT1CLK>;
+                       status = "disabled";
+               };
+
+               ehci1: usb@1e6a3000 {
+                       compatible = "aspeed,ast2500-ehci", "generic-ehci";
+                       reg = <0x1e6a3000 0x100>;
+                       interrupts = <13>;
+                       clocks = <&syscon ASPEED_CLK_GATE_USBPORT2CLK>;
+                       status = "disabled";
+               };
+
+               uhci: usb@1e6b0000 {
+                       compatible = "aspeed,ast2500-uhci", "generic-uhci";
+                       reg = <0x1e6b0000 0x100>;
+                       interrupts = <14>;
+                       #ports = <2>;
+                       clocks = <&syscon ASPEED_CLK_GATE_USBUHCICLK>;
+                       status = "disabled";
+               };
+
                apb {
                        compatible = "simple-bus";
                        #address-cells = <1>;
@@ -164,6 +189,13 @@ pinctrl: pinctrl {
                                };
                        };
 
+                       rng: hwrng@1e6e2078 {
+                               compatible = "timeriomem_rng";
+                               reg = <0x1e6e2078 0x4>;
+                               period = <1>;
+                               quality = <100>;
+                       };
+
                        gfx: display@1e6e6000 {
                                compatible = "aspeed,ast2500-gfx", "syscon";
                                reg = <0x1e6e6000 0x1000>;
@@ -1380,6 +1412,21 @@ pinctrl_usbcki_default: usbcki_default {
                groups = "USBCKI";
        };
 
+       pinctrl_usb2ah_default: usb2ah_default {
+               function = "USB2AH";
+               groups = "USB2AH";
+       };
+
+       pinctrl_usb11bhid_default: usb11bhid_default {
+               function = "USB11BHID";
+               groups = "USB11BHID";
+       };
+
+       pinctrl_usb2bh_default: usb2bh_default {
+               function = "USB2BH";
+               groups = "USB2BH";
+       };
+
        pinctrl_vgabiosrom_default: vgabiosrom_default {
                function = "VGABIOSROM";
                groups = "VGABIOSROM";
index e4bbb7e0f79360b67fd6dd150a8c8969ab703904..fcc85d70f36ec6009c5c2ba0a59167f3479f278f 100644 (file)
@@ -232,7 +232,7 @@ charger {
                                                pinctrl-names = "default";
                                                pinctrl-0 = <&pinctrl_charger_chglev &pinctrl_charger_lbo &pinctrl_charger_irq>;
                                                interrupt-parent = <&pioA>;
-                                               interrupts = <PIN_PB13 GPIO_ACTIVE_LOW>;
+                                               interrupts = <PIN_PB13 IRQ_TYPE_EDGE_RISING>;
 
                                                active-semi,chglev-gpios = <&pioA PIN_PA12 GPIO_ACTIVE_HIGH>;
                                                active-semi,lbo-gpios = <&pioA PIN_PC8 GPIO_ACTIVE_LOW>;
index 7887a7160a54e5b3719b7fc618eb55844b1308b0..0702a2f2b336c1a2a7ecf7d5ed28e6b96eccd527 100644 (file)
@@ -129,8 +129,8 @@ qt1070:keyboard@1b {
                                        wakeup-source;
                                };
 
-                               atmel_mxt_ts@4c {
-                                       compatible = "atmel,atmel_mxt_ts";
+                               touchscreen@4c {
+                                       compatible = "atmel,maxtouch";
                                        reg = <0x4c>;
                                        interrupt-parent = <&pioE>;
                                        interrupts = <24 0x0>;
index aa1fc7babfea7b200333a713fd35bfb6a6bcd157..2cd9c5e4f892865f3e52ec351ae9161064f30696 100644 (file)
@@ -101,6 +101,12 @@ &hdmi {
        hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
 };
 
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
+       status = "okay";
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_gpio14>;
index 425f6b0a5ef8a95af3daa0adfc651ac891dca3b4..067d1f07a2d36c1653e47b2b3d64d77a0c81b813 100644 (file)
@@ -96,6 +96,12 @@ &hdmi {
        hpd-gpios = <&gpio 46 GPIO_ACTIVE_HIGH>;
 };
 
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
+       status = "okay";
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_gpio14>;
index effa195e789589991dc68172fa04c39d121683e2..cfbdaacbaeba815cd5d1ce2a7bea50861558774a 100644 (file)
@@ -103,6 +103,12 @@ &hdmi {
        hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
 };
 
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
+       status = "okay";
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_gpio14>;
index 772ec3b482316bafcc350e676097dcfdd2797b76..5641d162dfdb0c106eed6f7f4dc4f7c120930970 100644 (file)
@@ -96,6 +96,12 @@ &hdmi {
        hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
 };
 
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
+       status = "okay";
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_gpio14>;
index 434483d6fc14634659e1291f387daa8f18340336..31ff602e2cd3644a5524443dbc817023852c01a9 100644 (file)
@@ -91,6 +91,12 @@ &hdmi {
        hpd-gpios = <&gpio 46 GPIO_ACTIVE_HIGH>;
 };
 
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
+       status = "okay";
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_gpio14>;
index 6c3cfaa77f3ddcefa435127aa328b637cb5ec837..cb2d6d78a7fbf5d9a1ef3f70563fcb94f2ce8bef 100644 (file)
@@ -83,12 +83,6 @@ &sdhost {
        bus-width = <4>;
 };
 
-&pwm {
-       pinctrl-names = "default";
-       pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
-       status = "okay";
-};
-
 &usb {
        power-domains = <&power RPI_POWER_DOMAIN_USB>;
 };
index 5c339adabdf0152ec5c020b5880df2cc93afbac9..2fef70a099535dfceb746b64384ec5b41ff0c1ab 100644 (file)
@@ -41,6 +41,12 @@ &hdmi {
        hpd-gpios = <&gpio 46 GPIO_ACTIVE_LOW>;
 };
 
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio45>;
+       status = "okay";
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_gpio14>;
diff --git a/arch/arm/boot/dts/bcm2837-rpi-3-b-plus.dts b/arch/arm/boot/dts/bcm2837-rpi-3-b-plus.dts
new file mode 100644 (file)
index 0000000..4adb85e
--- /dev/null
@@ -0,0 +1,108 @@
+// SPDX-License-Identifier: GPL-2.0
+/dts-v1/;
+#include "bcm2837.dtsi"
+#include "bcm2835-rpi.dtsi"
+#include "bcm283x-rpi-lan7515.dtsi"
+#include "bcm283x-rpi-usb-host.dtsi"
+
+/ {
+       compatible = "raspberrypi,3-model-b-plus", "brcm,bcm2837";
+       model = "Raspberry Pi 3 Model B+";
+
+       chosen {
+               /* 8250 auxiliary UART instead of pl011 */
+               stdout-path = "serial1:115200n8";
+       };
+
+       memory {
+               reg = <0 0x40000000>;
+       };
+
+       leds {
+               act {
+                       gpios = <&gpio 29 GPIO_ACTIVE_HIGH>;
+               };
+
+               pwr {
+                       label = "PWR";
+                       gpios = <&expgpio 2 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       wifi_pwrseq: wifi-pwrseq {
+               compatible = "mmc-pwrseq-simple";
+               reset-gpios = <&expgpio 1 GPIO_ACTIVE_HIGH>;
+       };
+};
+
+&firmware {
+       expgpio: gpio {
+               compatible = "raspberrypi,firmware-gpio";
+               gpio-controller;
+               #gpio-cells = <2>;
+               gpio-line-names = "BT_ON",
+                                 "WL_ON",
+                                 "STATUS_LED",
+                                 "LAN_RUN",
+                                 "",
+                                 "CAM_GPIO0",
+                                 "CAM_GPIO1",
+                                 "";
+               status = "okay";
+       };
+};
+
+&hdmi {
+       hpd-gpios = <&gpio 28 GPIO_ACTIVE_LOW>;
+};
+
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio41>;
+       status = "okay";
+};
+
+/* SDHCI is used to control the SDIO for wireless */
+&sdhci {
+       #address-cells = <1>;
+       #size-cells = <0>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&emmc_gpio34>;
+       status = "okay";
+       bus-width = <4>;
+       non-removable;
+       mmc-pwrseq = <&wifi_pwrseq>;
+
+       brcmf: wifi@1 {
+               reg = <1>;
+               compatible = "brcm,bcm4329-fmac";
+       };
+};
+
+/* SDHOST is used to drive the SD card */
+&sdhost {
+       pinctrl-names = "default";
+       pinctrl-0 = <&sdhost_gpio48>;
+       status = "okay";
+       bus-width = <4>;
+};
+
+/* uart0 communicates with the BT module */
+&uart0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart0_ctsrts_gpio30 &uart0_gpio32 &gpclk2_gpio43>;
+       status = "okay";
+
+       bluetooth {
+               compatible = "brcm,bcm43438-bt";
+               max-speed = <2000000>;
+               shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
+       };
+};
+
+/* uart1 is mapped to the pin header */
+&uart1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart1_gpio14>;
+       status = "okay";
+};
index 0b31d995a066cbfb0a4aa86fd1e31022d2f769ef..c318bcbc6ba7e327bcf164fd543cd47c04c52d2c 100644 (file)
@@ -20,9 +20,14 @@ memory {
 
        leds {
                act {
-                       gpios = <&gpio 47 GPIO_ACTIVE_HIGH>;
+                       gpios = <&expgpio 2 GPIO_ACTIVE_HIGH>;
                };
        };
+
+       wifi_pwrseq: wifi-pwrseq {
+               compatible = "mmc-pwrseq-simple";
+               reset-gpios = <&expgpio 1 GPIO_ACTIVE_HIGH>;
+       };
 };
 
 &firmware {
@@ -42,6 +47,16 @@ expgpio: gpio {
        };
 };
 
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm0_gpio40 &pwm1_gpio41>;
+       status = "okay";
+};
+
+&hdmi {
+       hpd-gpios = <&expgpio 4 GPIO_ACTIVE_LOW>;
+};
+
 /* uart0 communicates with the BT module */
 &uart0 {
        pinctrl-names = "default";
@@ -51,6 +66,7 @@ &uart0 {
        bluetooth {
                compatible = "brcm,bcm43438-bt";
                max-speed = <2000000>;
+               shutdown-gpios = <&expgpio 0 GPIO_ACTIVE_HIGH>;
        };
 };
 
@@ -63,11 +79,19 @@ &uart1 {
 
 /* SDHCI is used to control the SDIO for wireless */
 &sdhci {
+       #address-cells = <1>;
+       #size-cells = <0>;
        pinctrl-names = "default";
        pinctrl-0 = <&emmc_gpio34>;
        status = "okay";
        bus-width = <4>;
        non-removable;
+       mmc-pwrseq = <&wifi_pwrseq>;
+
+       brcmf: wifi@1 {
+               reg = <1>;
+               compatible = "brcm,bcm4329-fmac";
+       };
 };
 
 /* SDHOST is used to drive the SD card */
diff --git a/arch/arm/boot/dts/bcm283x-rpi-lan7515.dtsi b/arch/arm/boot/dts/bcm283x-rpi-lan7515.dtsi
new file mode 100644 (file)
index 0000000..9403da0
--- /dev/null
@@ -0,0 +1,27 @@
+// SPDX-License-Identifier: GPL-2.0
+/ {
+       aliases {
+               ethernet0 = &ethernet;
+       };
+};
+
+&usb {
+       usb-port@1 {
+               compatible = "usb424,2514";
+               reg = <1>;
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               usb-port@1 {
+                       compatible = "usb424,2514";
+                       reg = <1>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       ethernet: ethernet@1 {
+                               compatible = "usb424,7800";
+                               reg = <1>;
+                       };
+               };
+       };
+};
index ac00e730f89832b4fa2aa7111f7eef980a1bc045..61315cf734efebf9f44bd72ffac55b99deda5a7b 100644 (file)
@@ -136,6 +136,7 @@ clocks: cprman@7e101000 {
                rng@7e104000 {
                        compatible = "brcm,bcm2835-rng";
                        reg = <0x7e104000 0x10>;
+                       interrupts = <2 29>;
                };
 
                mailbox: mailbox@7e00b880 {
index 4175174e589a50ec388e795cc4bdc2ea1f0f31f6..ff2e551b9058448e4fd889ee11e5f12f88914666 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Asus RT-AC56U
  *
  * Copyright (C) 2015 Rafał Miłecki <zajec5@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
  */
 
 /dts-v1/;
index 8fa033fea95905ca0e0bb241efad9bfd3a756f8b..3bcc03788f38f8f89e135712e5e7c2cc272e8005 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Asus RT-AC68U
  *
  * Copyright (C) 2015 Rafał Miłecki <zajec5@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
  */
 
 /dts-v1/;
index 8b64caabaad8401876706da9b2ebf521b3401e6c..a587384f8e401ecea027400f35acda26defedc8f 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Buffalo WZR-1750DHP
  *
  * Copyright (C) 2014 Rafał Miłecki <zajec5@gmail.com>
- *
- * Licensed under the GNU/GPL. See COPYING for details.
  */
 
 /dts-v1/;
index 126ab5867772a0b822d2e45fdd37ea6f7ca40a77..6c8f0ad823326c56250cfa06fa95e3c00d5ae633 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright (C) 2017 Rafał Miłecki <rafal@milecki.pl>
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index f591b0f256d82511c9d6d5d1ebee24cc180cc81e..ebda45fe9ea4d4905467c4ea7892926bc8dda5eb 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright 2016 Luxul Inc.
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index 50d65d8fbd9afb8dc2b7890278ae3f5c28a18a92..9dd0e22c906afb4b6740a7e99c1fbcfc34a5a691 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Luxul XWC-1000
  *
  * Copyright 2014 Luxul Inc.
- *
- * Licensed under the GNU/GPL. See COPYING for details.
  */
 
 /dts-v1/;
@@ -26,9 +25,15 @@ memory {
 
        nand: nand@18028000 {
                nandcs@0 {
-                       partition@0 {
-                               label = "ubi";
-                               reg = <0x00000000 0x08000000>;
+                       partitions {
+                               compatible = "fixed-partitions";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               partition@0 {
+                                       label = "ubi";
+                                       reg = <0x00000000 0x08000000>;
+                               };
                        };
                };
        };
index bb66cebe0bd89279647080ca9196cbc2f205211e..2642494c97a1bf99238c40ff0bd877b37c57b96b 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Netgear R6300 V2
  *
  * Copyright (C) 2014 Rafał Miłecki <zajec5@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
  */
 
 /dts-v1/;
index 83a4c60bb431233a715140e46db00548f1ce0a7d..e7b09b7b7d25700d841841e56c3de720b0ceabde 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X arm platform code.
  * DTS for SmartRG SR400ac
  *
  * Copyright (C) 2015 Rafał Miłecki <zajec5@gmail.com>
- *
- * Licensed under the GNU/GPL. See COPYING for details.
  */
 
 /dts-v1/;
index 0800a964f2fea5d55efa6f004f168f6155b6b7b6..16314fcc6e568cdfa580bd0f235297aa60817d3e 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Asus RT-N18U
  *
  * Copyright (C) 2014 Rafał Miłecki <zajec5@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
  */
 
 /dts-v1/;
index c2af33eb47de0ea1981acc54b969eece18bf1424..328aa90240ce7346079695a3b8bf8d5425d1626d 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Buffalo WZR-600DHP2
  *
  * Copyright (C) 2014 Rafał Miłecki <zajec5@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
  */
 
 /dts-v1/;
index 87ea6ba664f5c67cae8bc45b80441fee27ac3a5e..8ea46eed26e231e803f8b085523f5f53b853ebeb 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Buffalo WZR-900DHP
  *
  * Copyright (C) 2015 Rafał Miłecki <zajec5@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
  */
 
 /dts-v1/;
index 9b5759849983893a12f48bb173cb82c7ec7b0fd2..5eeac7302329605fadff558c0fc8fdc2b7ab9301 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright 2017 Luxul Inc.
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index ba1c19b1b3eb60962d951a3449d3e6560bac092a..da4d9ec62fc65e9fa72dc798453d78a1828938c5 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright 2017 Luxul Inc.
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index 3ed8de42cb4877bb78f022efd470640b43cef18f..c94c732188fbe05c51cd331c1f89bb118b8812c2 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright (C) 2017 Rafał Miłecki <rafal@milecki.pl>
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index df473cc41572932722d7a9de14b5711df5df976f..22271818f901f428d99418fc7dfd40f00e684221 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Asus RT-AC87U
  *
  * Copyright (C) 2015 Rafał Miłecki <zajec5@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
  */
 
 /dts-v1/;
index 92058c73ee59548e48766cbb0475ddb75cf75594..79a9633ec4174c78e23ca3b3ca63b670b676290e 100644 (file)
@@ -1,10 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Buffalo WXR-1900DHP
  *
  * Copyright (C) 2015 Felix Fietkau <nbd@openwrt.org>
- *
- * Licensed under the GNU/GPL. See COPYING for details.
  */
 
 /dts-v1/;
index 3d1d9c2c4efcf90da2119fcf9d1003e0767da133..db744a5e122da7ddf7a921c086e91d810ba9ab32 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright (C) 2017 Rafał Miłecki <rafal@milecki.pl>
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index f43ab47214561ea82d52553b874528c4d92e7ed5..9e267d38df4c4d2e4631de4b1297826226f74c46 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for Netgear R7000
  *
  * Copyright (C) 2015 Rafał Miłecki <zajec5@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
  */
 
 /dts-v1/;
index ec4a50e440f6bc4e831be87c2c5b848070925d26..f5bf6586ae07e9e73d6b442f36c2decf33d54073 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright (C) 2016 Rafał Miłecki <rafal@milecki.pl>
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index 7cc7d344fe5b69fd4699b946c5f62961dd2a9450..d173bcd93b918bc37d4d280b934487109c13c03b 100644 (file)
@@ -1,20 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X ARM platform code.
  * DTS for D-Link DIR-885L
  *
  * Copyright (C) 2016 Rafał Miłecki <zajec5@gmail.com>
- *
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
- * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
- * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- * PERFORMANCE OF THIS SOFTWARE.
  */
 
 /dts-v1/;
@@ -37,9 +26,15 @@ memory {
 
        nand: nand@18028000 {
                nandcs@0 {
-                       partition@0 {
-                               label = "firmware";
-                               reg = <0x00000000 0x08000000>;
+                       partitions {
+                               compatible = "fixed-partitions";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+
+                               partition@0 {
+                                       label = "firmware";
+                                       reg = <0x00000000 0x08000000>;
+                               };
                        };
                };
        };
index b6750f70dffb254012f74160bf6f3ec73bd8c5ca..f47afe36d8579f378ca09a9d3d9838505359d08d 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright (C) 2017 Rafał Miłecki <rafal@milecki.pl>
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index ecd22a2467465c0a8db19a8847e9518d22316f1a..a5cef51cfe4f31b601eedb218043c74c9505aa64 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright (C) 2017 Luxul Inc.
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
diff --git a/arch/arm/boot/dts/bcm47094-luxul-xap-1610.dts b/arch/arm/boot/dts/bcm47094-luxul-xap-1610.dts
new file mode 100644 (file)
index 0000000..7fd8547
--- /dev/null
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/*
+ * Copyright 2018 Luxul Inc.
+ */
+
+/dts-v1/;
+
+#include "bcm47094.dtsi"
+
+/ {
+       compatible = "luxul,xap-1610-v1", "brcm,bcm47094", "brcm,bcm4708";
+       model = "Luxul XAP-1610 V1";
+
+       chosen {
+               bootargs = "earlycon";
+       };
+
+       memory {
+               reg = <0x00000000 0x08000000>;
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               status  {
+                       label = "bcm53xx:green:status";
+                       gpios = <&chipcommon 0 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "timer";
+               };
+
+               2ghz {
+                       label = "bcm53xx:blue:2ghz";
+                       gpios = <&chipcommon 13 GPIO_ACTIVE_LOW>;
+               };
+
+               5ghz {
+                       label = "bcm53xx:blue:5ghz";
+                       gpios = <&chipcommon 14 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       gpio-keys {
+               compatible = "gpio-keys";
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               restart {
+                       label = "Reset";
+                       linux,code = <KEY_RESTART>;
+                       gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>;
+               };
+       };
+};
+
+&spi_nor {
+       status = "okay";
+};
index 15ffb1abc4409183677a92fcc0a1e096d43e2ee2..7496aabf8f77ca591d5ae94e85481e5a472b6e43 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright (C) 2017 Luxul Inc.
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index bc1d1e10d4acc460f76953bc36d033b6610e567d..53aaa5212610fb6efe8b42a50fa00c7ec6c24078 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright 2016 Luxul Inc.
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
diff --git a/arch/arm/boot/dts/bcm47094-luxul-xwr-3150-v1.dts b/arch/arm/boot/dts/bcm47094-luxul-xwr-3150-v1.dts
new file mode 100644 (file)
index 0000000..bdad726
--- /dev/null
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
+/*
+ * Copyright 2018 Luxul Inc.
+ */
+
+/dts-v1/;
+
+#include "bcm47094.dtsi"
+#include "bcm5301x-nand-cs0-bch8.dtsi"
+
+/ {
+       compatible = "luxul,xwr-3150-v1", "brcm,bcm47094", "brcm,bcm4708";
+       model = "Luxul XWR-3150 V1";
+
+       chosen {
+               bootargs = "earlycon";
+       };
+
+       memory {
+               reg = <0x00000000 0x08000000
+                      0x88000000 0x18000000>;
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               power   {
+                       label = "bcm53xx:green:power";
+                       gpios = <&chipcommon 0 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "default-on";
+               };
+
+               usb3    {
+                       label = "bcm53xx:green:usb3";
+                       gpios = <&chipcommon 8 GPIO_ACTIVE_LOW>;
+                       trigger-sources = <&ohci_port1>, <&ehci_port1>,
+                                         <&xhci_port1>;
+                       linux,default-trigger = "usbport";
+               };
+
+               status  {
+                       label = "bcm53xx:green:status";
+                       gpios = <&chipcommon 10 GPIO_ACTIVE_LOW>;
+                       linux,default-trigger = "timer";
+               };
+
+               2ghz {
+                       label = "bcm53xx:green:2ghz";
+                       gpios = <&chipcommon 13 GPIO_ACTIVE_LOW>;
+               };
+
+               5ghz {
+                       label = "bcm53xx:green:5ghz";
+                       gpios = <&chipcommon 14 GPIO_ACTIVE_LOW>;
+               };
+       };
+
+       gpio-keys {
+               compatible = "gpio-keys";
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               restart {
+                       label = "Reset";
+                       linux,code = <KEY_RESTART>;
+                       gpios = <&chipcommon 17 GPIO_ACTIVE_LOW>;
+               };
+       };
+};
+
+&usb3 {
+       vcc-gpio = <&chipcommon 18 GPIO_ACTIVE_HIGH>;
+};
+
+&spi_nor {
+       status = "okay";
+};
index 859929973158fed4c71c7c8819ffc55657c6f7b2..0e718edc065afb001f8c5b6b30b5cf3d8f94adbe 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright (C) 2016 Rafał Miłecki <rafal@milecki.pl>
- *
- * Licensed under the ISC license.
  */
 
 /dts-v1/;
index 24b099c00f1327747e35d2bcc139a267a2d96697..c349e8f0afc574338584781480ec07f2b8bcd446 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom Northstar NAND.
  *
  * Copyright (C) 2016 Rafał Miłecki <rafal.milecki@gmail.com>
- *
- * Licensed under the ISC license.
  */
 
 #include "bcm5301x-nand-cs0.dtsi"
index b4e875df95286d6b16f52e94f601ee608da5b253..18e25e302b132fceb1f234987c2897454f05272c 100644 (file)
@@ -1,7 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Copyright 2016 Luxul Inc.
- *
- * Licensed under the ISC license.
  */
 
 #include "bcm5301x-nand-cs0.dtsi"
index 9a9630ded306a2f96e3f581f9761ed2e4cedde53..c8e56d30bd6f536d7401eefb94acc9f4d1686e5e 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom BCM470X / BCM5301X Nand chip defaults.
  *
@@ -5,8 +6,6 @@
  * and uses 8 bit ECC.
  *
  * Copyright (C) 2015 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Licensed under the GNU/GPL. See COPYING for details.
  */
 
 #include "bcm5301x-nand-cs0.dtsi"
index 168495106b821c22e0d548b4e356eb3e1583ee1e..e5a2d62daf9267c990c9a79bc9ae466568f1bd9a 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
 /*
  * Broadcom Northstar NAND.
  *
  * Copyright (C) 2015 Hauke Mehrtens <hauke@hauke-m.de>
- *
- * Licensed under the GNU/GPL. See COPYING for details.
  */
 
 / {
index 1c475796d17f0e2bac45ad9b23720ef16ba8c350..64a297759eb9c10e93c4b69c260f1a316d7d6295 100644 (file)
@@ -1,39 +1,8 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
 /*
  * Device Tree file for Sony NSZ-GS7
  *
  * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file is licensed under the terms of the GNU General Public
- *     License version 2. This program is licensed "as is" without any
- *     warranty of any kind, whether express or implied.
- *
- * Or, alternatively,
- *
- *  b) 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.
  */
 
 /dts-v1/;
index d575823c57507b003ec938a848a28562d717a4be..db67377af2664670322da8ca2e54c2c8de341eb7 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
 /*
  * Device Tree Include file for Marvell Armada 1500 (Berlin BG2) SoC
  *
@@ -5,38 +6,6 @@
  *
  * based on GPL'ed 2.6 kernel sources
  *  (c) Marvell International Ltd.
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file is licensed under the terms of the GNU General Public
- *     License version 2. This program is licensed "as is" without any
- *     warranty of any kind, whether express or implied.
- *
- * Or, alternatively,
- *
- *  b) 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 <dt-bindings/clock/berlin2.h>
@@ -149,7 +118,7 @@ gic: interrupt-controller@ad1000 {
                local-timer@ad0600 {
                        compatible = "arm,cortex-a9-twd-timer";
                        reg = <0xad0600 0x20>;
-                       interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_HIGH)>;
+                       interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_EDGE_RISING)>;
                        clocks = <&chip_clk CLKID_TWD>;
                };
 
index ca24def0ce135e8715768395090cdff7fb538b7b..56fa951bc86f4aef987a448bb43ad43db0ef221a 100644 (file)
@@ -1,39 +1,8 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
 /*
  * Device Tree file for Google Chromecast
  *
  * Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file is licensed under the terms of the GNU General Public
- *     License version 2. This program is licensed "as is" without any
- *     warranty of any kind, whether express or implied.
- *
- * Or, alternatively,
- *
- *  b) 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.
  */
 
 /dts-v1/;
@@ -52,22 +21,35 @@ chosen {
 
        memory@0 {
                device_type = "memory";
-               reg = <0x00000000 0x20000000>; /* 512 MB */
+
+               /*
+                * We're using "linux,usable-memory" instead of "reg" here
+                * because the (signed and encrypted) bootloader that shipped
+                * with this device provides an incorrect memory range in
+                * ATAG_MEM. Linux helpfully overrides the "reg" property with
+                * data from the ATAG, so we can't specify the proper range
+                * normally. Fortunately, this alternate property is checked
+                * first by the OF driver, so we can (ab)use it instead.
+                */
+               linux,usable-memory = <0x00000000 0x20000000>; /* 512 MB */
        };
 
        leds {
-               compatible = "gpio-leds";
+               compatible = "pwm-leds";
+               pinctrl-0 = <&ledpwm_pmux>;
+               pinctrl-names = "default";
 
                white {
                        label = "white";
-                       gpios = <&portc 1 GPIO_ACTIVE_HIGH>;
-                       default-state = "keep";
+                       pwms = <&pwm 0 600000 0>;
+                       max-brightness = <255>;
+                       linux,default-trigger = "default-on";
                };
 
                red {
                        label = "red";
-                       gpios = <&portc 2 GPIO_ACTIVE_HIGH>;
-                       default-state = "keep";
+                       pwms = <&pwm 1 600000 0>;
+                       max-brightness = <255>;
                };
        };
 };
@@ -86,3 +68,10 @@ &sdhci0 {
 &usb_phy1 { status = "okay"; };
 
 &usb1 { status = "okay"; };
+
+&soc_pinctrl {
+       ledpwm_pmux: ledpwm-pmux {
+               groups = "G0";
+               function = "pwm";
+       };
+};
diff --git a/arch/arm/boot/dts/berlin2cd-valve-steamlink.dts b/arch/arm/boot/dts/berlin2cd-valve-steamlink.dts
new file mode 100644 (file)
index 0000000..79ac842
--- /dev/null
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright 2018 Alexander Monakov <amonakov@gmail.com>
+ */
+/dts-v1/;
+
+#include "berlin2cd.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+       model = "Valve Steam Link";
+       compatible = "valve,steamlink", "marvell,berlin2cd", "marvell,berlin";
+
+       memory@0 {
+               device_type = "memory";
+               reg = <0x00000000 0x20000000>; /* 512 MB */
+       };
+
+       gpio-restart {
+               compatible = "gpio-restart";
+               gpios = <&porta 6 GPIO_ACTIVE_HIGH>;
+               active-delay = <100>;
+               inactive-delay = <10>;
+               wait-delay = <100>;
+               priority = <200>;
+       };
+};
+
+&cpu {
+       cpu-supply = <&vcpu>;
+       operating-points = <
+               /* kHz    uV */
+               1000000 1325000
+       >;
+};
+
+&i2c0 {
+       status = "okay";
+
+       /* There are two regulators on the board. One is accessible via I2C,
+        * with buck1 providing SoC power (set up by bootloader to 1.325V or
+        * less depending on leakage value in OTP), and buck2 likely used for
+        * DRAM (providing 1.35V). The other regulator on the opposite side
+        * of the board is probably supplying SDIO and NAND fixed voltages. */
+       regulator@19 {
+               compatible = "marvell,88pg868";
+               reg = <0x19>;
+
+               vcpu: buck1 {
+                       regulator-boot-on;
+                       regulator-always-on;
+                       regulator-min-microvolt = <1000000>;
+                       regulator-max-microvolt = <1325000>;
+               };
+       };
+};
+
+/* Fixed interface to on-board Marvell 8897 Wi-Fi/Bluetooth/NFC chip. */
+&sdhci0 {
+       keep-power-in-suspend;
+       non-removable;
+       status = "okay";
+};
+
+&uart0 {
+       /* RX/TX are routed to TP50/TP51 on the board. */
+       status = "okay";
+};
+
+/* The SoC is connected to on-board USB hub that in turn has one downstream
+ * port wired to the on-board Steam Controller wireless receiver chip. */
+&usb_phy1 { status = "okay"; };
+
+&usb1 {
+       dr_mode = "host";
+       status = "okay";
+};
+
+&eth1 { status = "okay"; };
index 501c59d97eae4b8360563c38d82abf4120b7a9dd..e5c1f4213ff904a150d9064f3f09fd19a14282a2 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
 /*
  * Device Tree Include file for Marvell Armada 1500-mini (Berlin BG2CD) SoC
  *
@@ -5,38 +6,6 @@
  *
  * based on GPL'ed 2.6 kernel sources
  *  (c) Marvell International Ltd.
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file is licensed under the terms of the GNU General Public
- *     License version 2. This program is licensed "as is" without any
- *     warranty of any kind, whether express or implied.
- *
- * Or, alternatively,
- *
- *  b) 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 <dt-bindings/clock/berlin2.h>
@@ -57,7 +26,7 @@ cpus {
                #address-cells = <1>;
                #size-cells = <0>;
 
-               cpu@0 {
+               cpu: cpu@0 {
                        compatible = "arm,cortex-a9";
                        device_type = "cpu";
                        next-level-cache = <&l2>;
@@ -73,6 +42,12 @@ cpu@0 {
                };
        };
 
+       pmu {
+               compatible = "arm,cortex-a9-pmu";
+               interrupt-parent = <&gic>;
+               interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
+       };
+
        refclk: oscillator {
                compatible = "fixed-clock";
                #clock-cells = <0>;
@@ -87,11 +62,6 @@ soc@f7000000 {
 
                ranges = <0 0xf7000000 0x1000000>;
 
-               pmu {
-                       compatible = "arm,cortex-a9-pmu";
-                       interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
-               };
-
                sdhci0: sdhci@ab0000 {
                        compatible = "mrvl,pxav3-mmc";
                        reg = <0xab0000 0x200>;
@@ -108,6 +78,11 @@ l2: l2-cache-controller@ac0000 {
                        cache-level = <2>;
                };
 
+               snoop-control-unit@ad0000 {
+                       compatible = "arm,cortex-a9-scu";
+                       reg = <0xad0000 0x100>;
+               };
+
                gic: interrupt-controller@ad1000 {
                        compatible = "arm,cortex-a9-gic";
                        reg = <0xad1000 0x1000>, <0xad0100 0x0100>;
@@ -115,10 +90,24 @@ gic: interrupt-controller@ad1000 {
                        #interrupt-cells = <3>;
                };
 
+               global-timer@ad0200 {
+                       compatible = "arm,cortex-a9-global-timer";
+                       reg = <0xad0200 0x20>;
+                       interrupts = <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_EDGE_RISING)>;
+                       clocks = <&chip_clk CLKID_TWD>;
+               };
+
                local-timer@ad0600 {
                        compatible = "arm,cortex-a9-twd-timer";
                        reg = <0xad0600 0x20>;
-                       interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
+                       interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_EDGE_RISING)>;
+                       clocks = <&chip_clk CLKID_TWD>;
+               };
+
+               local-wdt@ad0620 {
+                       compatible = "arm,cortex-a9-twd-wdt";
+                       reg = <0xad0620 0x20>;
+                       interrupts = <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_EDGE_RISING)>;
                        clocks = <&chip_clk CLKID_TWD>;
                };
 
@@ -254,6 +243,60 @@ portd: gpio-port@3 {
                                };
                        };
 
+                       i2c0: i2c@1400 {
+                               compatible = "snps,designware-i2c";
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               reg = <0x1400 0x100>;
+                               interrupts = <16>;
+                               clocks = <&chip_clk CLKID_CFG>;
+                               status = "disabled";
+                       };
+
+                       i2c1: i2c@1800 {
+                               compatible = "snps,designware-i2c";
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               reg = <0x1800 0x100>;
+                               interrupts = <17>;
+                               clocks = <&chip_clk CLKID_CFG>;
+                               status = "disabled";
+                       };
+
+                       spi0: spi@1c00 {
+                               compatible = "snps,dw-apb-ssi";
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               reg = <0x1c00 0x100>;
+                               interrupts = <4>;
+                               clocks = <&chip_clk CLKID_CFG>;
+                               status = "disabled";
+                       };
+
+                       wdt4: watchdog@2000 {
+                               compatible = "snps,dw-wdt";
+                               reg = <0x2000 0x100>;
+                               clocks = <&chip_clk CLKID_CFG>;
+                               interrupts = <5>;
+                               status = "disabled";
+                       };
+
+                       wdt5: watchdog@2400 {
+                               compatible = "snps,dw-wdt";
+                               reg = <0x2400 0x100>;
+                               clocks = <&chip_clk CLKID_CFG>;
+                               interrupts = <6>;
+                               status = "disabled";
+                       };
+
+                       wdt6: watchdog@2800 {
+                               compatible = "snps,dw-wdt";
+                               reg = <0x2800 0x100>;
+                               clocks = <&chip_clk CLKID_CFG>;
+                               interrupts = <7>;
+                               status = "disabled";
+                       };
+
                        timer0: timer@2c00 {
                                compatible = "snps,dw-apb-timer";
                                reg = <0x2c00 0x14>;
@@ -435,6 +478,36 @@ portf: gpio-port@5 {
                                };
                        };
 
+                       spi1: spi@6000 {
+                               compatible = "snps,dw-apb-ssi";
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               reg = <0x6000 0x100>;
+                               clocks = <&refclk>;
+                               interrupts = <5>;
+                               status = "disabled";
+                       };
+
+                       i2c2: i2c@7000 {
+                               compatible = "snps,designware-i2c";
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               reg = <0x7000 0x100>;
+                               interrupts = <6>;
+                               clocks = <&refclk>;
+                               status = "disabled";
+                       };
+
+                       i2c3: i2c@8000 {
+                               compatible = "snps,designware-i2c";
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               reg = <0x8000 0x100>;
+                               interrupts = <7>;
+                               clocks = <&refclk>;
+                               status = "disabled";
+                       };
+
                        sm_gpio0: gpio@c000 {
                                compatible = "snps,dw-apb-gpio";
                                reg = <0xc000 0x400>;
@@ -472,6 +545,16 @@ uart1: serial@a000 {
                                status = "disabled";
                        };
 
+                       uart2: serial@b000 {
+                               compatible = "snps,dw-apb-uart";
+                               reg = <0xb000 0x100>;
+                               reg-shift = <2>;
+                               reg-io-width = <1>;
+                               interrupts = <10>;
+                               clocks = <&refclk>;
+                               status = "disabled";
+                       };
+
                        sysctrl: system-controller@d000 {
                                compatible = "simple-mfd", "syscon";
                                reg = <0xd000 0x100>;
@@ -479,6 +562,12 @@ sysctrl: system-controller@d000 {
                                sys_pinctrl: pin-controller {
                                        compatible = "marvell,berlin2cd-system-pinctrl";
                                };
+
+                               adc: adc {
+                                       compatible = "marvell,berlin2-adc";
+                                       interrupts = <12>, <14>;
+                                       interrupt-names = "adc", "tsen";
+                               };
                        };
 
                        sic: interrupt-controller@e000 {
index 57aa5f8a7c774d106ba12c819836d5b4ce195791..c162f98cb8e86d9b734b004e1238a9116b5581f3 100644 (file)
@@ -1,37 +1,6 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
 /*
  * Copyright (C) 2014 Antoine Ténart <antoine.tenart@free-electrons.com>
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file is licensed under the terms of the GNU General Public
- *     License version 2. This program is licensed "as is" without any
- *     warranty of any kind, whether express or implied.
- *
- * Or, alternatively,
- *
- *  b) 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.
  */
 
 /dts-v1/;
index bf3a6c9a1d347b6244a7910f0b2159c61348c308..516a7ce257915d637f47ea26883ec69e90b406d2 100644 (file)
@@ -1,37 +1,6 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
 /*
  * Copyright (C) 2014 Antoine Ténart <antoine.tenart@free-electrons.com>
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file is licensed under the terms of the GNU General Public
- *     License version 2. This program is licensed "as is" without any
- *     warranty of any kind, whether express or implied.
- *
- * Or, alternatively,
- *
- *  b) 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 <dt-bindings/clock/berlin2q.h>
@@ -53,7 +22,7 @@ cpus {
                #size-cells = <0>;
                enable-method = "marvell,berlin-smp";
 
-               cpu@0 {
+               cpu0: cpu@0 {
                        compatible = "arm,cortex-a9";
                        device_type = "cpu";
                        next-level-cache = <&l2>;
@@ -71,21 +40,21 @@ cpu@0 {
                        >;
                };
 
-               cpu@1 {
+               cpu1: cpu@1 {
                        compatible = "arm,cortex-a9";
                        device_type = "cpu";
                        next-level-cache = <&l2>;
                        reg = <1>;
                };
 
-               cpu@2 {
+               cpu2: cpu@2 {
                        compatible = "arm,cortex-a9";
                        device_type = "cpu";
                        next-level-cache = <&l2>;
                        reg = <2>;
                };
 
-               cpu@3 {
+               cpu3: cpu@3 {
                        compatible = "arm,cortex-a9";
                        device_type = "cpu";
                        next-level-cache = <&l2>;
@@ -93,6 +62,19 @@ cpu@3 {
                };
        };
 
+       pmu {
+               compatible = "arm,cortex-a9-pmu";
+               interrupt-parent = <&gic>;
+               interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>,
+                                    <&cpu1>,
+                                    <&cpu2>,
+                                    <&cpu3>;
+       };
+
        refclk: oscillator {
                compatible = "fixed-clock";
                #clock-cells = <0>;
@@ -107,14 +89,6 @@ soc@f7000000 {
                ranges = <0 0xf7000000 0x1000000>;
                interrupt-parent = <&gic>;
 
-               pmu {
-                       compatible = "arm,cortex-a9-pmu";
-                       interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
-               };
-
                sdhci0: sdhci@ab0000 {
                        compatible = "mrvl,pxav3-mmc";
                        reg = <0xab0000 0x200>;
@@ -145,6 +119,7 @@ sdhci2: sdhci@ab1000 {
                l2: l2-cache-controller@ac0000 {
                        compatible = "arm,pl310-cache";
                        reg = <0xac0000 0x1000>;
+                       cache-unified;
                        cache-level = <2>;
                        arm,data-latency = <2 2 2>;
                        arm,tag-latency = <2 2 2>;
@@ -159,7 +134,7 @@ local-timer@ad0600 {
                        compatible = "arm,cortex-a9-twd-timer";
                        reg = <0xad0600 0x20>;
                        clocks = <&chip_clk CLKID_TWD>;
-                       interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
+                       interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_EDGE_RISING)>;
                };
 
                gic: interrupt-controller@ad1000 {
index 3962fa4b07f5ba0f18d6c22da88b3c6e514148d4..0e82bb988fde6c97f6d77ffb9f2afe28e4978af7 100644 (file)
@@ -27,143 +27,6 @@ aliases {
                spi0 = &spi1;
        };
 
-       soc@1c00000 {
-               pmx_core: pinmux@14120 {
-                       status = "okay";
-
-                       mcasp0_pins: pinmux_mcasp0_pins {
-                               pinctrl-single,bits = <
-                                       /*
-                                        * AHCLKX, ACLKX, AFSX, AHCLKR, ACLKR,
-                                        * AFSR, AMUTE
-                                        */
-                                       0x00 0x11111111 0xffffffff
-                                       /* AXR11, AXR12 */
-                                       0x04 0x00011000 0x000ff000
-                               >;
-                       };
-                       nand_pins: nand_pins {
-                               pinctrl-single,bits = <
-                                       /* EMA_WAIT[0], EMA_OE, EMA_WE, EMA_CS[4], EMA_CS[3] */
-                                       0x1c 0x10110110  0xf0ff0ff0
-                                       /*
-                                        * EMA_D[0], EMA_D[1], EMA_D[2],
-                                        * EMA_D[3], EMA_D[4], EMA_D[5],
-                                        * EMA_D[6], EMA_D[7]
-                                        */
-                                       0x24 0x11111111  0xffffffff
-                                       /* EMA_A[1], EMA_A[2] */
-                                       0x30 0x01100000  0x0ff00000
-                               >;
-                       };
-               };
-               serial0: serial@42000 {
-                       status = "okay";
-               };
-               serial1: serial@10c000 {
-                       status = "okay";
-               };
-               serial2: serial@10d000 {
-                       status = "okay";
-               };
-               rtc0: rtc@23000 {
-                       status = "okay";
-               };
-               i2c0: i2c@22000 {
-                       status = "okay";
-                       clock-frequency = <100000>;
-                       pinctrl-names = "default";
-                       pinctrl-0 = <&i2c0_pins>;
-
-                       tps: tps@48 {
-                               reg = <0x48>;
-                       };
-                       tlv320aic3106: tlv320aic3106@18 {
-                               #sound-dai-cells = <0>;
-                               compatible = "ti,tlv320aic3106";
-                               reg = <0x18>;
-                               status = "okay";
-
-                               /* Regulators */
-                               IOVDD-supply = <&vdcdc2_reg>;
-                               /* Derived from VBAT: Baseboard 3.3V / 1.8V */
-                               AVDD-supply = <&vbat>;
-                               DRVDD-supply = <&vbat>;
-                               DVDD-supply = <&vbat>;
-                       };
-                       tca6416: gpio@20 {
-                               compatible = "ti,tca6416";
-                               reg = <0x20>;
-                               gpio-controller;
-                               #gpio-cells = <2>;
-                       };
-               };
-               wdt: wdt@21000 {
-                       status = "okay";
-               };
-               mmc0: mmc@40000 {
-                       max-frequency = <50000000>;
-                       bus-width = <4>;
-                       status = "okay";
-                       pinctrl-names = "default";
-                       pinctrl-0 = <&mmc0_pins>;
-               };
-               spi1: spi@30e000 {
-                       status = "okay";
-                       pinctrl-names = "default";
-                       pinctrl-0 = <&spi1_pins &spi1_cs0_pin>;
-                       flash: m25p80@0 {
-                               #address-cells = <1>;
-                               #size-cells = <1>;
-                               compatible = "m25p64";
-                               spi-max-frequency = <30000000>;
-                               m25p,fast-read;
-                               reg = <0>;
-                               partition@0 {
-                                       label = "U-Boot-SPL";
-                                       reg = <0x00000000 0x00010000>;
-                                       read-only;
-                               };
-                               partition@1 {
-                                       label = "U-Boot";
-                                       reg = <0x00010000 0x00080000>;
-                                       read-only;
-                               };
-                               partition@2 {
-                                       label = "U-Boot-Env";
-                                       reg = <0x00090000 0x00010000>;
-                                       read-only;
-                               };
-                               partition@3 {
-                                       label = "Kernel";
-                                       reg = <0x000a0000 0x00280000>;
-                               };
-                               partition@4 {
-                                       label = "Filesystem";
-                                       reg = <0x00320000 0x00400000>;
-                               };
-                               partition@5 {
-                                       label = "MAC-Address";
-                                       reg = <0x007f0000 0x00010000>;
-                                       read-only;
-                               };
-                       };
-               };
-               mdio: mdio@224000 {
-                       status = "okay";
-                       pinctrl-names = "default";
-                       pinctrl-0 = <&mdio_pins>;
-                       bus_freq = <2200000>;
-               };
-               eth0: ethernet@220000 {
-                       status = "okay";
-                       pinctrl-names = "default";
-                       pinctrl-0 = <&mii_pins>;
-               };
-               gpio: gpio@226000 {
-                       status = "okay";
-               };
-       };
        vbat: fixedregulator0 {
                compatible = "regulator-fixed";
                regulator-name = "vbat";
@@ -200,6 +63,155 @@ link0_codec: simple-audio-card,codec {
        };
 };
 
+&pmx_core {
+       status = "okay";
+
+       mcasp0_pins: pinmux_mcasp0_pins {
+               pinctrl-single,bits = <
+                       /*
+                        * AHCLKX, ACLKX, AFSX, AHCLKR, ACLKR,
+                        * AFSR, AMUTE
+                        */
+                       0x00 0x11111111 0xffffffff
+                       /* AXR11, AXR12 */
+                       0x04 0x00011000 0x000ff000
+               >;
+       };
+       nand_pins: nand_pins {
+               pinctrl-single,bits = <
+                       /* EMA_WAIT[0], EMA_OE, EMA_WE, EMA_CS[4], EMA_CS[3] */
+                       0x1c 0x10110110  0xf0ff0ff0
+                       /*
+                        * EMA_D[0], EMA_D[1], EMA_D[2],
+                        * EMA_D[3], EMA_D[4], EMA_D[5],
+                        * EMA_D[6], EMA_D[7]
+                        */
+                       0x24 0x11111111  0xffffffff
+                       /* EMA_A[1], EMA_A[2] */
+                       0x30 0x01100000  0x0ff00000
+               >;
+       };
+};
+
+&serial0 {
+       status = "okay";
+};
+
+&serial1 {
+       status = "okay";
+};
+
+&serial2 {
+       status = "okay";
+};
+
+&rtc0 {
+       status = "okay";
+};
+
+&i2c0 {
+       status = "okay";
+       clock-frequency = <100000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c0_pins>;
+
+       tps: tps@48 {
+               reg = <0x48>;
+       };
+       tlv320aic3106: tlv320aic3106@18 {
+               #sound-dai-cells = <0>;
+               compatible = "ti,tlv320aic3106";
+               reg = <0x18>;
+               status = "okay";
+
+               /* Regulators */
+               IOVDD-supply = <&vdcdc2_reg>;
+               /* Derived from VBAT: Baseboard 3.3V / 1.8V */
+               AVDD-supply = <&vbat>;
+               DRVDD-supply = <&vbat>;
+               DVDD-supply = <&vbat>;
+       };
+       tca6416: gpio@20 {
+               compatible = "ti,tca6416";
+               reg = <0x20>;
+               gpio-controller;
+               #gpio-cells = <2>;
+       };
+};
+
+&wdt {
+       status = "okay";
+};
+
+&mmc0 {
+       max-frequency = <50000000>;
+       bus-width = <4>;
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&mmc0_pins>;
+       cd-gpios = <&gpio 64 GPIO_ACTIVE_LOW>;
+       wp-gpios = <&gpio 65 GPIO_ACTIVE_HIGH>;
+};
+
+&spi1 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi1_pins &spi1_cs0_pin>;
+       flash: m25p80@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "m25p64";
+               spi-max-frequency = <30000000>;
+               m25p,fast-read;
+               reg = <0>;
+               partition@0 {
+                       label = "U-Boot-SPL";
+                       reg = <0x00000000 0x00010000>;
+                       read-only;
+               };
+               partition@1 {
+                       label = "U-Boot";
+                       reg = <0x00010000 0x00080000>;
+                       read-only;
+               };
+               partition@2 {
+                       label = "U-Boot-Env";
+                       reg = <0x00090000 0x00010000>;
+                       read-only;
+               };
+               partition@3 {
+                       label = "Kernel";
+                       reg = <0x000a0000 0x00280000>;
+               };
+               partition@4 {
+                       label = "Filesystem";
+                       reg = <0x00320000 0x00400000>;
+               };
+               partition@5 {
+                       label = "MAC-Address";
+                       reg = <0x007f0000 0x00010000>;
+                       read-only;
+               };
+       };
+};
+
+&mdio {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&mdio_pins>;
+       bus_freq = <2200000>;
+};
+
+&eth0 {
+       status = "okay";
+       pinctrl-names = "default";
+       pinctrl-0 = <&mii_pins>;
+};
+
+&gpio {
+       status = "okay";
+};
+
 /include/ "tps6507x.dtsi"
 
 &tps {
@@ -309,6 +321,18 @@ nand@2000000,0 {
        };
 };
 
+&usb_phy {
+       status = "okay";
+};
+
+&usb0 {
+       status = "okay";
+};
+
+&usb1 {
+       status = "okay";
+};
+
 &vpif {
        pinctrl-names = "default";
        pinctrl-0 = <&vpif_capture_pins>, <&vpif_display_pins>;
index 1ffd87796cac540b0c709a7e631605b24badcd18..ee3932475ce7b906d0e6305de117d51277f857e6 100644 (file)
@@ -33,11 +33,9 @@ memory@c0000000 {
         */
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
                label = "EV3 Brick Buttons";
                pinctrl-names = "default";
-               pinctrl-0 = <&button_pins>, <&button_bias>;
+               pinctrl-0 = <&button_bias>;
 
                center {
                        label = "Center";
@@ -81,8 +79,6 @@ up {
         */
        leds {
                compatible = "gpio-leds";
-               pinctrl-names = "default";
-               pinctrl-0 = <&led_pins>;
 
                left_green {
                        label = "led0:green:brick-status";
@@ -119,8 +115,6 @@ right_green {
        gpio-poweroff {
                compatible = "gpio-poweroff";
                gpios = <&gpio 107 GPIO_ACTIVE_LOW>;
-               pinctrl-names = "default";
-               pinctrl-0 = <&system_power_pin>;
        };
 
        sound {
@@ -136,8 +130,6 @@ sound {
         * the sensor (input) ports, the motor (output) ports and the A/DC.
         */
        vcc5v: regulator1 {
-               pinctrl-names = "default";
-               pinctrl-0 = <&vcc5v_pins>;
                compatible = "regulator-fixed";
                regulator-name = "vcc5v";
                regulator-min-microvolt = <5000000>;
@@ -165,8 +157,6 @@ adc_ref: regulator2 {
         * This is the amplifier for the speaker.
         */
        amp: regulator3 {
-               pinctrl-names = "default";
-               pinctrl-0 = <&amp_pins>;
                compatible = "regulator-fixed";
                regulator-name = "amp";
                gpio = <&gpio 111 GPIO_ACTIVE_HIGH>;
@@ -177,8 +167,6 @@ amp: regulator3 {
         * The EV3 can use 6-AA batteries or a rechargeable Li-ion battery pack.
         */
        battery {
-               pinctrl-names = "default";
-               pinctrl-0 = <&battery_pins>;
                compatible = "lego,ev3-battery";
                io-channels = <&adc 4>, <&adc 3>;
                io-channel-names = "voltage", "current";
@@ -206,73 +194,10 @@ reboot-mode {
 &pmx_core {
        status = "okay";
 
-       mmc0_cd_pin: pinmux_mmc0_cd {
-               pinctrl-single,bits = <
-                       /* GP5[14] */
-                       0x2C 0x00000080 0x000000f0
-               >;
-       };
-
-       button_pins: pinmux_button_pins {
-               pinctrl-single,bits = <
-                       /* GP1[13] */
-                       0x8 0x00000800 0x00000f00
-                       /* GP6[10] */
-                       0x34 0x00800000 0x00f00000
-                       /* GP6[6] */
-                       0x38 0x00000080 0x000000f0
-                       /* GP7[12], GP7[14], GP7[15] */
-                       0x40 0x00808800 0x00f0ff00
-               >;
-       };
-
-       led_pins: pinmux_led_pins {
-               pinctrl-single,bits = <
-                       /* GP6[12], GP6[13], GP6[14] */
-                       0x34 0x00008880 0x0000fff0
-                       /* GP6[7] */
-                       0x38 0x00000008 0x0000000f
-               >;
-       };
-
-       system_power_pin: pinmux_system_power {
-               pinctrl-single,bits = <
-                       /* GP6[11] */
-                       0x34 0x00080000 0x000f0000
-               >;
-       };
-
-       vcc5v_pins: pinmux_vcc5v {
-               pinctrl-single,bits = <
-                       /* GP6[5] */
-                       0x40 0x00000080 0x000000f0
-                       /* GP6[3] */
-                       0x4c 0x00008000 0x0000f000
-               >;
-       };
-
-       amp_pins: pinmux_amp_pins {
-               pinctrl-single,bits = <
-                       /* GP6[15] */
-                       0x34 0x00000008 0x0000000f
-               >;
-       };
-
-       battery_pins: pinmux_battery_pins {
-               pinctrl-single,bits = <
-                       /* GP0[6] */
-                       0x04 0x00000080 0x000000f0
-                       /* GP8[8] */
-                       0x4c 0x00000080 0x000000f0
-               >;
-       };
-
        ev3_lcd_pins: pinmux_lcd {
                pinctrl-single,bits = <
-                       /* SIMO, GP2[11], GP2[12], CLK */
-                       0x14 0x00188100 0x00ffff00
-                       /* GP5[0] */
-                       0x30 0x80000000 0xf0000000
+                       /* SIMO, CLK */
+                       0x14 0x00100100 0x00f00f00
                >;
        };
 };
@@ -327,7 +252,7 @@ &mmc0 {
        bus-width = <4>;
        cd-gpios = <&gpio 94 GPIO_ACTIVE_LOW>;
        pinctrl-names = "default";
-       pinctrl-0 = <&mmc0_pins>, <&mmc0_cd_pin>;
+       pinctrl-0 = <&mmc0_pins>;
 };
 
 &spi0 {
index 12010002dbdb65cbdf9b87d2f37bf39e72903b3e..f6f1597b03df931a1dea057921a43cea9f929a31 100644 (file)
@@ -59,8 +59,18 @@ pmx_core: pinmux@14120 {
                        pinctrl-single,bit-per-mux;
                        pinctrl-single,register-width = <32>;
                        pinctrl-single,function-mask = <0xf>;
+                       /* pin base, nr pins & gpio function */
+                       pinctrl-single,gpio-range = <&range   0 17 0x8>,
+                                                   <&range  17  8 0x4>,
+                                                   <&range  26  8 0x4>,
+                                                   <&range  34 80 0x8>,
+                                                   <&range 129 31 0x8>;
                        status = "disabled";
 
+                       range: gpio-range {
+                               #pinctrl-single,gpio-range-cells = <3>;
+                       };
+
                        serial0_rtscts_pins: pinmux_serial0_rtscts_pins {
                                pinctrl-single,bits = <
                                        /* UART0_RTS UART0_CTS */
@@ -549,6 +559,150 @@ gpio: gpio@226000 {
                        status = "disabled";
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx_core   0  15 1>,
+                                     <&pmx_core   1  14 1>,
+                                     <&pmx_core   2  13 1>,
+                                     <&pmx_core   3  12 1>,
+                                     <&pmx_core   4  11 1>,
+                                     <&pmx_core   5  10 1>,
+                                     <&pmx_core   6   9 1>,
+                                     <&pmx_core   7   8 1>,
+                                     <&pmx_core   8   7 1>,
+                                     <&pmx_core   9   6 1>,
+                                     <&pmx_core  10   5 1>,
+                                     <&pmx_core  11   4 1>,
+                                     <&pmx_core  12   3 1>,
+                                     <&pmx_core  13   2 1>,
+                                     <&pmx_core  14   1 1>,
+                                     <&pmx_core  15   0 1>,
+                                     <&pmx_core  16  39 1>,
+                                     <&pmx_core  17  38 1>,
+                                     <&pmx_core  18  37 1>,
+                                     <&pmx_core  19  36 1>,
+                                     <&pmx_core  20  35 1>,
+                                     <&pmx_core  21  34 1>,
+                                     <&pmx_core  22  33 1>,
+                                     <&pmx_core  23  32 1>,
+                                     <&pmx_core  24  24 1>,
+                                     <&pmx_core  25  22 1>,
+                                     <&pmx_core  26  21 1>,
+                                     <&pmx_core  27  20 1>,
+                                     <&pmx_core  28  19 1>,
+                                     <&pmx_core  29  18 1>,
+                                     <&pmx_core  30  17 1>,
+                                     <&pmx_core  31  16 1>,
+                                     <&pmx_core  32  55 1>,
+                                     <&pmx_core  33  54 1>,
+                                     <&pmx_core  34  53 1>,
+                                     <&pmx_core  35  52 1>,
+                                     <&pmx_core  36  51 1>,
+                                     <&pmx_core  37  50 1>,
+                                     <&pmx_core  38  49 1>,
+                                     <&pmx_core  39  48 1>,
+                                     <&pmx_core  40  47 1>,
+                                     <&pmx_core  41  46 1>,
+                                     <&pmx_core  42  45 1>,
+                                     <&pmx_core  43  44 1>,
+                                     <&pmx_core  44  43 1>,
+                                     <&pmx_core  45  42 1>,
+                                     <&pmx_core  46  41 1>,
+                                     <&pmx_core  47  40 1>,
+                                     <&pmx_core  48  71 1>,
+                                     <&pmx_core  49  70 1>,
+                                     <&pmx_core  50  69 1>,
+                                     <&pmx_core  51  68 1>,
+                                     <&pmx_core  52  67 1>,
+                                     <&pmx_core  53  66 1>,
+                                     <&pmx_core  54  65 1>,
+                                     <&pmx_core  55  64 1>,
+                                     <&pmx_core  56  63 1>,
+                                     <&pmx_core  57  62 1>,
+                                     <&pmx_core  58  61 1>,
+                                     <&pmx_core  59  60 1>,
+                                     <&pmx_core  60  59 1>,
+                                     <&pmx_core  61  58 1>,
+                                     <&pmx_core  62  57 1>,
+                                     <&pmx_core  63  56 1>,
+                                     <&pmx_core  64  87 1>,
+                                     <&pmx_core  65  86 1>,
+                                     <&pmx_core  66  85 1>,
+                                     <&pmx_core  67  84 1>,
+                                     <&pmx_core  68  83 1>,
+                                     <&pmx_core  69  82 1>,
+                                     <&pmx_core  70  81 1>,
+                                     <&pmx_core  71  80 1>,
+                                     <&pmx_core  72  70 1>,
+                                     <&pmx_core  73  78 1>,
+                                     <&pmx_core  74  77 1>,
+                                     <&pmx_core  75  76 1>,
+                                     <&pmx_core  76  75 1>,
+                                     <&pmx_core  77  74 1>,
+                                     <&pmx_core  78  73 1>,
+                                     <&pmx_core  79  72 1>,
+                                     <&pmx_core  80 103 1>,
+                                     <&pmx_core  81 102 1>,
+                                     <&pmx_core  82 101 1>,
+                                     <&pmx_core  83 100 1>,
+                                     <&pmx_core  84  99 1>,
+                                     <&pmx_core  85  98 1>,
+                                     <&pmx_core  86  97 1>,
+                                     <&pmx_core  87  96 1>,
+                                     <&pmx_core  88  95 1>,
+                                     <&pmx_core  89  94 1>,
+                                     <&pmx_core  90  93 1>,
+                                     <&pmx_core  91  92 1>,
+                                     <&pmx_core  92  91 1>,
+                                     <&pmx_core  93  90 1>,
+                                     <&pmx_core  94  89 1>,
+                                     <&pmx_core  95  88 1>,
+                                     <&pmx_core  96 158 1>,
+                                     <&pmx_core  97 157 1>,
+                                     <&pmx_core  98 156 1>,
+                                     <&pmx_core  99 155 1>,
+                                     <&pmx_core 100 154 1>,
+                                     <&pmx_core 101 129 1>,
+                                     <&pmx_core 102 113 1>,
+                                     <&pmx_core 103 112 1>,
+                                     <&pmx_core 104 111 1>,
+                                     <&pmx_core 105 110 1>,
+                                     <&pmx_core 106 109 1>,
+                                     <&pmx_core 107 108 1>,
+                                     <&pmx_core 108 107 1>,
+                                     <&pmx_core 109 106 1>,
+                                     <&pmx_core 110 105 1>,
+                                     <&pmx_core 111 104 1>,
+                                     <&pmx_core 112 145 1>,
+                                     <&pmx_core 113 144 1>,
+                                     <&pmx_core 114 143 1>,
+                                     <&pmx_core 115 142 1>,
+                                     <&pmx_core 116 141 1>,
+                                     <&pmx_core 117 140 1>,
+                                     <&pmx_core 118 139 1>,
+                                     <&pmx_core 119 138 1>,
+                                     <&pmx_core 120 137 1>,
+                                     <&pmx_core 121 136 1>,
+                                     <&pmx_core 122 135 1>,
+                                     <&pmx_core 123 134 1>,
+                                     <&pmx_core 124 133 1>,
+                                     <&pmx_core 125 132 1>,
+                                     <&pmx_core 126 131 1>,
+                                     <&pmx_core 127 130 1>,
+                                     <&pmx_core 128 159 1>,
+                                     <&pmx_core 129  31 1>,
+                                     <&pmx_core 130  30 1>,
+                                     <&pmx_core 131  20 1>,
+                                     <&pmx_core 132  28 1>,
+                                     <&pmx_core 133  27 1>,
+                                     <&pmx_core 134  26 1>,
+                                     <&pmx_core 135  23 1>,
+                                     <&pmx_core 136 153 1>,
+                                     <&pmx_core 137 152 1>,
+                                     <&pmx_core 138 151 1>,
+                                     <&pmx_core 139 150 1>,
+                                     <&pmx_core 140 149 1>,
+                                     <&pmx_core 141 148 1>,
+                                     <&pmx_core 142 147 1>,
+                                     <&pmx_core 143 146 1>;
                };
                pinconf: pin-controller@22c00c {
                        compatible = "ti,da850-pupd";
index 6418f9cdbe83faaada09aeb75371724afe5bdda1..c46a227b543dd9af35afabe29bf0f33890df1fd5 100644 (file)
@@ -77,7 +77,7 @@ DM814X_IOPAD(0x09d8, PIN_INPUT_PULLUP | 0x1)  /* SD2_DAT[1] */
                        DM814X_IOPAD(0x09dc, PIN_INPUT_PULLUP | 0x1)    /* SD2_DAT[0] */
                        DM814X_IOPAD(0x09e0, PIN_INPUT | 0x1)           /* SD2_CLK */
                        DM814X_IOPAD(0x09f4, PIN_INPUT_PULLUP | 0x2)    /* SD2_CMD */
-                       DM814X_IOPAD(0x0920, PIN_INPUT | 40)    /* SD2_SDCD */
+                       DM814X_IOPAD(0x0920, PIN_INPUT | 0x40)  /* SD2_SDCD */
                        >;
        };
 
index 05a7b1a01bc338b0c4981aa620bd9045daf13456..33230c8b295172fccb929bd694a63b143e3043f8 100644 (file)
@@ -260,3 +260,18 @@ mbox_dsp2_ipc3x: mbox_dsp2_ipc3x {
 &pcie1_rc {
        status = "okay";
 };
+
+&mmc4 {
+       bus-width = <4>;
+       cap-power-off-card;
+       keep-power-in-suspend;
+       non-removable;
+       #address-cells = <1>;
+       #size-cells = <0>;
+       wifi@2 {
+               compatible = "ti,wl1835";
+               reg = <2>;
+               interrupt-parent = <&gpio5>;
+               interrupts = <7 IRQ_TYPE_EDGE_RISING>;
+       };
+};
index f1425b0f3a54ae0191a60296eca828fccad93bf2..0894593860d6dd622b169c10c9f5a9c75354483a 100644 (file)
@@ -20,6 +20,16 @@ memory@0 {
                reg = <0x0 0x80000000 0x0 0x60000000>; /* 1536 MB */
        };
 
+       evm_12v0: fixedregulator-evm_12v0 {
+               /* main supply */
+               compatible = "regulator-fixed";
+               regulator-name = "evm_12v0";
+               regulator-min-microvolt = <12000000>;
+               regulator-max-microvolt = <12000000>;
+               regulator-always-on;
+               regulator-boot-on;
+       };
+
        evm_1v8_sw: fixedregulator-evm_1v8 {
                compatible = "regulator-fixed";
                regulator-name = "evm_1v8";
@@ -54,6 +64,48 @@ aic_dvdd: fixedregulator-aic_dvdd {
                regulator-max-microvolt = <1800000>;
        };
 
+       evm_3v3: fixedregulator-evm3v3 {
+               /* Output of Cntlr A of TPS43351-Q1 on dra7-evm */
+               compatible = "regulator-fixed";
+               regulator-name = "evm_3v3";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               vin-supply = <&evm_12v0>;
+               regulator-always-on;
+               regulator-boot-on;
+       };
+
+       evm_5v0: fixedregulator-evm_5v0 {
+               /* Output of Cntlr B of TPS43351-Q1 on dra7-evm */
+               compatible = "regulator-fixed";
+               regulator-name = "evm_5v0";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               vin-supply = <&evm_12v0>;
+               regulator-always-on;
+               regulator-boot-on;
+       };
+
+       evm_3v6: fixedregulator-evm_3v6 {
+               compatible = "regulator-fixed";
+               regulator-name = "evm_3v6";
+               regulator-min-microvolt = <3600000>;
+               regulator-max-microvolt = <3600000>;
+               vin-supply = <&evm_5v0>;
+               regulator-always-on;
+               regulator-boot-on;
+       };
+
+       vmmcwl_fixed: fixedregulator-mmcwl {
+               compatible = "regulator-fixed";
+               regulator-name = "vmmcwl_fixed";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               gpio = <&gpio5 8 0>;
+               startup-delay-us = <70000>;
+               enable-active-high;
+       };
+
        extcon_usb2: extcon_usb2 {
                compatible = "linux,extcon-usb-gpio";
                id-gpio = <&pcf_gpio_21 2 GPIO_ACTIVE_HIGH>;
@@ -325,6 +377,7 @@ &mmc2 {
        vmmc-supply = <&evm_1v8_sw>;
        vqmmc-supply = <&evm_1v8_sw>;
        bus-width = <8>;
+       non-removable;
        pinctrl-names = "default", "hs", "ddr_1_8v-rev11", "ddr_1_8v", "hs200_1_8v-rev11", "hs200_1_8v";
        pinctrl-0 = <&mmc2_pins_default>;
        pinctrl-1 = <&mmc2_pins_hs>;
@@ -334,6 +387,21 @@ &mmc2 {
        pinctrl-5 = <&mmc2_pins_hs200 &mmc2_iodelay_hs200_rev20_conf>;
 };
 
+&mmc4 {
+       status = "okay";
+       vmmc-supply = <&evm_3v6>;
+       vqmmc-supply = <&vmmcwl_fixed>;
+       pinctrl-names = "default-rev11", "default", "hs-rev11", "hs", "sdr12-rev11", "sdr12", "sdr25-rev11", "sdr25";
+       pinctrl-0 = <&mmc4_pins_default &mmc4_iodelay_ds_rev11_conf>;
+       pinctrl-1 = <&mmc4_pins_default &mmc4_iodelay_ds_rev20_conf>;
+       pinctrl-2 = <&mmc4_pins_hs &mmc4_iodelay_sdr12_hs_sdr25_rev11_conf>;
+       pinctrl-3 = <&mmc4_pins_hs &mmc4_iodelay_sdr12_hs_sdr25_rev20_conf>;
+       pinctrl-4 = <&mmc4_pins_sdr12 &mmc4_iodelay_sdr12_hs_sdr25_rev11_conf>;
+       pinctrl-5 = <&mmc4_pins_sdr12 &mmc4_iodelay_sdr12_hs_sdr25_rev20_conf>;
+       pinctrl-6 = <&mmc4_pins_sdr25 &mmc4_iodelay_sdr12_hs_sdr25_rev11_conf>;
+       pinctrl-7 = <&mmc4_pins_sdr25 &mmc4_iodelay_sdr12_hs_sdr25_rev20_conf>;
+};
+
 &cpu0 {
        vdd-supply = <&smps123_reg>;
 };
diff --git a/arch/arm/boot/dts/dra7-mmc-iodelay.dtsi b/arch/arm/boot/dts/dra7-mmc-iodelay.dtsi
new file mode 100644 (file)
index 0000000..aa09472
--- /dev/null
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * MMC IOdelay values for TI's DRA7xx SoCs.
+ * Copyright (C) 2018 Texas Instruments
+ * Author: Kishon Vijay Abraham I <kishon@ti.com>
+ */
+
+&dra7_pmx_core {
+       mmc1_pins_default_no_clk_pu: mmc1_pins_default_no_clk_pu {
+               pinctrl-single,pins = <
+                       DRA7XX_CORE_IOPAD(0x3754, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mmc1_clk.clk */
+                       DRA7XX_CORE_IOPAD(0x3758, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_cmd.cmd */
+                       DRA7XX_CORE_IOPAD(0x375c, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat0.dat0 */
+                       DRA7XX_CORE_IOPAD(0x3760, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat1.dat1 */
+                       DRA7XX_CORE_IOPAD(0x3764, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat2.dat2 */
+                       DRA7XX_CORE_IOPAD(0x3768, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat3.dat3 */
+               >;
+       };
+};
index f4ddd86f2c774a452cb4d711c434fa0f283310d6..9dcd14edc20287f80c73a3b95d21e303ffa6d39c 100644 (file)
@@ -1079,17 +1079,15 @@ i2c5: i2c@4807c000 {
                };
 
                mmc1: mmc@4809c000 {
-                       compatible = "ti,omap4-hsmmc";
+                       compatible = "ti,dra7-sdhci";
                        reg = <0x4809c000 0x400>;
                        interrupts = <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>;
                        ti,hwmods = "mmc1";
-                       ti,dual-volt;
-                       ti,needs-special-reset;
-                       dmas = <&sdma_xbar 61>, <&sdma_xbar 62>;
-                       dma-names = "tx", "rx";
                        status = "disabled";
                        pbias-supply = <&pbias_mmc_reg>;
                        max-frequency = <192000000>;
+                       mmc-ddr-1_8v;
+                       mmc-ddr-3_3v;
                };
 
                hdqw1w: 1w@480b2000 {
@@ -1100,40 +1098,40 @@ hdqw1w: 1w@480b2000 {
                };
 
                mmc2: mmc@480b4000 {
-                       compatible = "ti,omap4-hsmmc";
+                       compatible = "ti,dra7-sdhci";
                        reg = <0x480b4000 0x400>;
                        interrupts = <GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH>;
                        ti,hwmods = "mmc2";
-                       ti,needs-special-reset;
-                       dmas = <&sdma_xbar 47>, <&sdma_xbar 48>;
-                       dma-names = "tx", "rx";
                        status = "disabled";
                        max-frequency = <192000000>;
+                       /* SDR104/DDR50/SDR50 bits in CAPA2 is not supported */
+                       sdhci-caps-mask = <0x7 0x0>;
+                       mmc-hs200-1_8v;
+                       mmc-ddr-1_8v;
+                       mmc-ddr-3_3v;
                };
 
                mmc3: mmc@480ad000 {
-                       compatible = "ti,omap4-hsmmc";
+                       compatible = "ti,dra7-sdhci";
                        reg = <0x480ad000 0x400>;
                        interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
                        ti,hwmods = "mmc3";
-                       ti,needs-special-reset;
-                       dmas = <&sdma_xbar 77>, <&sdma_xbar 78>;
-                       dma-names = "tx", "rx";
                        status = "disabled";
                        /* Errata i887 limits max-frequency of MMC3 to 64 MHz */
                        max-frequency = <64000000>;
+                       /* SDMA is not supported */
+                       sdhci-caps-mask = <0x0 0x400000>;
                };
 
                mmc4: mmc@480d1000 {
-                       compatible = "ti,omap4-hsmmc";
+                       compatible = "ti,dra7-sdhci";
                        reg = <0x480d1000 0x400>;
                        interrupts = <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>;
                        ti,hwmods = "mmc4";
-                       ti,needs-special-reset;
-                       dmas = <&sdma_xbar 57>, <&sdma_xbar 58>;
-                       dma-names = "tx", "rx";
                        status = "disabled";
                        max-frequency = <192000000>;
+                       /* SDMA is not supported */
+                       sdhci-caps-mask = <0x0 0x400000>;
                };
 
                mmu0_dsp1: mmu@40d01000 {
index ebc4bbae981e25421da9e0ecc5f116bc2bdcfabc..b7aeaeeead3b80701c06cf7b20f965204d0e3d26 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include "dra72-evm-common.dtsi"
+#include "dra7-mmc-iodelay.dtsi"
 #include "dra72x-mmc-iodelay.dtsi"
 #include <dt-bindings/net/ti-dp83867.h>
 
@@ -50,19 +51,6 @@ poweroff: gpio-poweroff {
        };
 };
 
-&dra7_pmx_core {
-       mmc1_pins_default: mmc1_pins_default {
-               pinctrl-single,pins = <
-                       DRA7XX_CORE_IOPAD(0x3754, PIN_INPUT_PULLDOWN | MUX_MODE0) /* mmc1_clk.clk */
-                       DRA7XX_CORE_IOPAD(0x3758, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_cmd.cmd */
-                       DRA7XX_CORE_IOPAD(0x375c, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat0.dat0 */
-                       DRA7XX_CORE_IOPAD(0x3760, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat1.dat1 */
-                       DRA7XX_CORE_IOPAD(0x3764, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat2.dat2 */
-                       DRA7XX_CORE_IOPAD(0x3768, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat3.dat3 */
-               >;
-       };
-};
-
 &i2c1 {
        status = "okay";
        clock-frequency = <400000>;
@@ -187,7 +175,7 @@ p0 {
 
 &mmc1 {
        pinctrl-names = "default", "hs", "sdr12", "sdr25", "sdr50", "ddr50", "sdr104";
-       pinctrl-0 = <&mmc1_pins_default>;
+       pinctrl-0 = <&mmc1_pins_default_no_clk_pu>;
        pinctrl-1 = <&mmc1_pins_hs>;
        pinctrl-2 = <&mmc1_pins_sdr12>;
        pinctrl-3 = <&mmc1_pins_sdr25>;
@@ -204,6 +192,7 @@ &mmc2 {
        pinctrl-2 = <&mmc2_pins_ddr_rev20 &mmc2_iodelay_ddr_conf>;
        pinctrl-3 = <&mmc2_pins_hs200 &mmc2_iodelay_hs200_rev20_conf>;
        vmmc-supply = <&evm_1v8_sw>;
+       vqmmc-supply = <&evm_1v8_sw>;
 };
 
 &mac {
index e85f560a2f787cc8a8d6aba99fa2024ec8188313..df174f5c15d1d4161721ef9ec06b91806f56e548 100644 (file)
@@ -44,6 +44,16 @@ evm_5v0: fixedregulator-evm5v0 {
                regulator-boot-on;
        };
 
+       evm_3v6: fixedregulator-evm_3v6 {
+               compatible = "regulator-fixed";
+               regulator-name = "evm_3v6";
+               regulator-min-microvolt = <3600000>;
+               regulator-max-microvolt = <3600000>;
+               vin-supply = <&evm_5v0>;
+               regulator-always-on;
+               regulator-boot-on;
+       };
+
        vsys_3v3: fixedregulator-vsys3v3 {
                /* Output 2 of TPS43351QDAPRQ1 on dra72-evm */
                /* Output 2 of LM5140QRWGTQ1 on dra71-evm */
@@ -171,36 +181,18 @@ simple-audio-card,codec {
                        clocks = <&atl_clkin2_ck>;
                };
        };
-};
-
-&dra7_pmx_core {
-       mmc1_pins_default: mmc1_pins_default {
-               pinctrl-single,pins = <
-                       DRA7XX_CORE_IOPAD(0x376c, PIN_INPUT | MUX_MODE14)       /* mmc1sdcd.gpio219 */
-                       DRA7XX_CORE_IOPAD(0x3754, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_clk.clk */
-                       DRA7XX_CORE_IOPAD(0x3758, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_cmd.cmd */
-                       DRA7XX_CORE_IOPAD(0x375c, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat0.dat0 */
-                       DRA7XX_CORE_IOPAD(0x3760, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat1.dat1 */
-                       DRA7XX_CORE_IOPAD(0x3764, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat2.dat2 */
-                       DRA7XX_CORE_IOPAD(0x3768, PIN_INPUT_PULLUP | MUX_MODE0) /* mmc1_dat3.dat3 */
-               >;
-       };
 
-       mmc2_pins_default: mmc2_pins_default {
-               pinctrl-single,pins = <
-                       DRA7XX_CORE_IOPAD(0x349c, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_a23.mmc2_clk */
-                       DRA7XX_CORE_IOPAD(0x34b0, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_cs1.mmc2_cmd */
-                       DRA7XX_CORE_IOPAD(0x34a0, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_a24.mmc2_dat0 */
-                       DRA7XX_CORE_IOPAD(0x34a4, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_a25.mmc2_dat1 */
-                       DRA7XX_CORE_IOPAD(0x34a8, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_a26.mmc2_dat2 */
-                       DRA7XX_CORE_IOPAD(0x34ac, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_a27.mmc2_dat3 */
-                       DRA7XX_CORE_IOPAD(0x348c, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_a19.mmc2_dat4 */
-                       DRA7XX_CORE_IOPAD(0x3490, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_a20.mmc2_dat5 */
-                       DRA7XX_CORE_IOPAD(0x3494, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_a21.mmc2_dat6 */
-                       DRA7XX_CORE_IOPAD(0x3498, PIN_INPUT_PULLUP | MUX_MODE1) /* gpmc_a22.mmc2_dat7 */
-               >;
+       vmmcwl_fixed: fixedregulator-mmcwl {
+               compatible = "regulator-fixed";
+               regulator-name = "vmmcwl_fixed";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               gpio = <&gpio5 8 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
        };
+};
 
+&dra7_pmx_core {
        dcan1_pins_default: dcan1_pins_default {
                pinctrl-single,pins = <
                        DRA7XX_CORE_IOPAD(0x37d0, PIN_OUTPUT_PULLUP | MUX_MODE0) /* dcan1_tx */
@@ -421,10 +413,33 @@ &mmc2 {
        pinctrl-names = "default";
        pinctrl-0 = <&mmc2_pins_default>;
        bus-width = <8>;
-       ti,non-removable;
+       non-removable;
        max-frequency = <192000000>;
 };
 
+&mmc4 {
+       status = "okay";
+       vmmc-supply = <&evm_3v6>;
+       vqmmc-supply = <&vmmcwl_fixed>;
+       bus-width = <4>;
+       cap-power-off-card;
+       keep-power-in-suspend;
+       non-removable;
+       pinctrl-names = "default", "hs", "sdr12", "sdr25";
+       pinctrl-0 = <&mmc4_pins_default>;
+       pinctrl-1 = <&mmc4_pins_default>;
+       pinctrl-2 = <&mmc4_pins_default>;
+       pinctrl-3 = <&mmc4_pins_default>;
+       #address-cells = <1>;
+       #size-cells = <0>;
+       wifi@2 {
+               compatible = "ti,wl1835";
+               reg = <2>;
+               interrupt-parent = <&gpio5>;
+               interrupts = <7 IRQ_TYPE_EDGE_RISING>;
+       };
+};
+
 &mac {
        status = "okay";
 };
index 088013c6dc6ed4bdb9665179ae267f84700dc272..edad87c4292cf6fd87db54fbdfa4b72fbe903c42 100644 (file)
@@ -202,6 +202,17 @@ DRA7XX_CORE_IOPAD(0x3494, PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE1) /* gpmc_a2
                        DRA7XX_CORE_IOPAD(0x3498, PIN_INPUT_PULLUP | MODE_SELECT | MUX_MODE1) /* gpmc_a22.mmc2_dat7 */
                >;
        };
+
+       mmc4_pins_default: mmc4_pins_default {
+               pinctrl-single,pins = <
+                       DRA7XX_CORE_IOPAD(0x37e8, PIN_INPUT_PULLUP | MUX_MODE3) /* uart1_ctsn.mmc4_clk */
+                       DRA7XX_CORE_IOPAD(0x37ec, PIN_INPUT_PULLUP | MUX_MODE3) /* uart1_rtsn.mmc4_cmd */
+                       DRA7XX_CORE_IOPAD(0x37f0, PIN_INPUT_PULLUP | MUX_MODE3) /* uart2_rxd.mmc4_dat0 */
+                       DRA7XX_CORE_IOPAD(0x37f4, PIN_INPUT_PULLUP | MUX_MODE3) /* uart2_txd.mmc4_dat1 */
+                       DRA7XX_CORE_IOPAD(0x37f8, PIN_INPUT_PULLUP | MUX_MODE3) /* uart2_ctsn.mmc4_dat2 */
+                       DRA7XX_CORE_IOPAD(0x37fc, PIN_INPUT_PULLUP | MUX_MODE3) /* uart2_rtsn.mmc4_dat3 */
+               >;
+       };
 };
 
 &dra7_iodelay_core {
index 2deb96405d0669a5df699496e2bf79290bc34224..c07f0051844dcace1d6093371d89c037cc4a7b6b 100644 (file)
@@ -42,6 +42,16 @@ vsys_5v0: fixedregulator-vsys5v0 {
                regulator-boot-on;
        };
 
+       vio_3v6: fixedregulator-vio_3v6 {
+               compatible = "regulator-fixed";
+               regulator-name = "vio_3v6";
+               regulator-min-microvolt = <3600000>;
+               regulator-max-microvolt = <3600000>;
+               vin-supply = <&vsys_5v0>;
+               regulator-always-on;
+               regulator-boot-on;
+       };
+
        vsys_3v3: fixedregulator-vsys3v3 {
                /* Output of Cntlr A of TPS43351-Q1 on dra76-evm */
                compatible = "regulator-fixed";
@@ -81,6 +91,16 @@ vio_1v8: fixedregulator-vio_1v8 {
                vin-supply = <&smps5_reg>;
        };
 
+       vmmcwl_fixed: fixedregulator-mmcwl {
+               compatible = "regulator-fixed";
+               regulator-name = "vmmcwl_fixed";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               gpio = <&gpio5 8 0>;    /* gpio5_8 */
+               startup-delay-us = <70000>;
+               enable-active-high;
+       };
+
        vtt_fixed: fixedregulator-vtt {
                compatible = "regulator-fixed";
                regulator-name = "vtt_fixed";
@@ -307,7 +327,7 @@ &cpu0 {
 &mmc1 {
        status = "okay";
        vmmc-supply = <&vio_3v3_sd>;
-       vmmc_aux-supply = <&ldo4_reg>;
+       vqmmc-supply = <&ldo4_reg>;
        bus-width = <4>;
        /*
         * SDCD signal is not being used here - using the fact that GPIO mode
@@ -324,6 +344,7 @@ &mmc2 {
        vmmc-supply = <&vio_1v8>;
        vqmmc-supply = <&vio_1v8>;
        bus-width = <8>;
+       non-removable;
        pinctrl-names = "default", "hs", "ddr_1_8v", "hs200_1_8v";
        pinctrl-0 = <&mmc2_pins_default>;
        pinctrl-1 = <&mmc2_pins_default>;
@@ -331,6 +352,17 @@ &mmc2 {
        pinctrl-3 = <&mmc2_pins_hs200 &mmc2_iodelay_hs200_conf>;
 };
 
+&mmc4 {
+       status = "okay";
+       vmmc-supply = <&vio_3v6>;
+       vqmmc-supply = <&vmmcwl_fixed>;
+       pinctrl-names = "default", "hs", "sdr12", "sdr25";
+       pinctrl-0 = <&mmc4_pins_hs &mmc4_iodelay_default_conf>;
+       pinctrl-1 = <&mmc4_pins_hs &mmc4_iodelay_manual1_conf>;
+       pinctrl-2 = <&mmc4_pins_hs &mmc4_iodelay_manual1_conf>;
+       pinctrl-3 = <&mmc4_pins_hs &mmc4_iodelay_manual1_conf>;
+};
+
 /* No RTC on this device */
 &rtc {
        status = "disabled";
index c238407133bfe2d77abae45308771c81a34efd6e..0af44b7eadb9a5567b0f8decc32c445f53aceace 100644 (file)
@@ -34,9 +34,6 @@ chosen {
 
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                one {
                        debounce-interval = <50>;
                        wakeup-source;
index 42ea246e71cb4e207d2e451da2df4d7ce465856f..fec1241b858ff96f316cd5988f3cbb8ba778fb62 100644 (file)
@@ -31,13 +31,13 @@ cpus {
                #address-cells = <1>;
                #size-cells = <0>;
 
-               cpu@0 {
+               cpu0: cpu@0 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <0>;
                        clock-frequency = <533000000>;
                };
-               cpu@1 {
+               cpu1: cpu@1 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <1>;
@@ -57,6 +57,7 @@ pmu {
                compatible = "arm,cortex-a9-pmu";
                interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>;
        };
 
        clocks@e0110000 {
index 4b3dd0549a540989c8ee1facd77841f301e76817..ecf416690a15290f0d08be5b4c1cdca49868ab8d 100644 (file)
@@ -3,22 +3,18 @@
  * Samsung's Exynos SoC syscon reboot/poweroff nodes common definition.
  */
 
-/ {
-       soc {
-               compatible = "simple-bus";
-
-               poweroff: syscon-poweroff {
-                       compatible = "syscon-poweroff";
-                       regmap = <&pmu_system_controller>;
-                       offset = <0x330C>; /* PS_HOLD_CONTROL */
-                       mask = <0x5200>; /* reset value */
-               };
+&pmu_system_controller {
+       poweroff: syscon-poweroff {
+               compatible = "syscon-poweroff";
+               regmap = <&pmu_system_controller>;
+               offset = <0x330C>; /* PS_HOLD_CONTROL */
+               mask = <0x5200>; /* reset value */
+       };
 
-               reboot: syscon-reboot {
-                       compatible = "syscon-reboot";
-                       regmap = <&pmu_system_controller>;
-                       offset = <0x0400>; /* SWRESET */
-                       mask = <0x1>;
-               };
+       reboot: syscon-reboot {
+               compatible = "syscon-reboot";
+               regmap = <&pmu_system_controller>;
+               offset = <0x0400>; /* SWRESET */
+               mask = <0x1>;
        };
 };
index 2c3460781cc60d5436d921fa40faf4abed8cff81..2a6b828c01b7c7f2bad3599736bdb8bed92eaf60 100644 (file)
@@ -24,6 +24,10 @@ aliases {
                i2c7 = &i2c_max77836;
        };
 
+       chosen {
+               stdout-path = &serial_1;
+       };
+
        memory@40000000 {
                device_type = "memory";
                reg =  <0x40000000 0x1ff00000>;
index 0a5f989d963b6fa6c65dde5732d037a639936067..962af97c188315c5cd525f8d3513b89eb8059835 100644 (file)
@@ -15,7 +15,6 @@
  */
 
 #include "exynos4-cpu-thermal.dtsi"
-#include "exynos-syscon-restart.dtsi"
 #include <dt-bindings/clock/exynos3250.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/interrupt-controller/irq.h>
@@ -919,3 +918,4 @@ opp-100000000 {
 };
 
 #include "exynos3250-pinctrl.dtsi"
+#include "exynos-syscon-restart.dtsi"
index 909a9f2bf5be6cd87efa23d2901400e9bf10d314..dfe41b69874571c01c43ba2114cd41e1ace99c90 100644 (file)
@@ -20,7 +20,6 @@
 #include <dt-bindings/clock/exynos-audss-clk.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/interrupt-controller/irq.h>
-#include "exynos-syscon-restart.dtsi"
 
 / {
        interrupt-parent = <&gic>;
@@ -1025,3 +1024,5 @@ prng: rng@10830400 {
                };
        };
 };
+
+#include "exynos-syscon-restart.dtsi"
index 9a310e841d5de17f9cd957be6558277c280f789d..2ab99f9f3d0ac2769bf1c504f3926707f59cc012 100644 (file)
@@ -34,26 +34,17 @@ chosen {
                stdout-path = &serial_2;
        };
 
-       regulators {
-               compatible = "simple-bus";
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               mmc_reg: regulator@0 {
-                       compatible = "regulator-fixed";
-                       reg = <0>;
-                       regulator-name = "VMEM_VDD_2.8V";
-                       regulator-min-microvolt = <2800000>;
-                       regulator-max-microvolt = <2800000>;
-                       gpio = <&gpx1 1 GPIO_ACTIVE_HIGH>;
-                       enable-active-high;
-               };
+       mmc_reg: voltage-regulator {
+               compatible = "regulator-fixed";
+               regulator-name = "VMEM_VDD_2.8V";
+               regulator-min-microvolt = <2800000>;
+               regulator-max-microvolt = <2800000>;
+               gpio = <&gpx1 1 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
        };
 
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
                up {
                        label = "Up";
@@ -131,12 +122,23 @@ &cpu0 {
        cpu0-supply = <&buck1_reg>;
 };
 
+&exynos_usbphy {
+       status = "okay";
+};
+
 &fimd {
        pinctrl-0 = <&lcd_en &lcd_clk &lcd_data24 &pwm0_out>;
        pinctrl-names = "default";
        status = "okay";
 };
 
+&hsotg {
+       vusb_d-supply = <&ldo3_reg>;
+       vusb_a-supply = <&ldo8_reg>;
+       dr_mode = "peripheral";
+       status = "okay";
+};
+
 &i2c_0 {
        status = "okay";
        samsung,i2c-sda-delay = <100>;
index eaeeb4f6b84ab732570a1abf899c51d523023b68..6f1d76cb795157b9947a52e538a1aba8c1595ea7 100644 (file)
@@ -259,8 +259,8 @@ mms114-touchscreen@48 {
                reg = <0x48>;
                interrupt-parent = <&gpx0>;
                interrupts = <4 IRQ_TYPE_EDGE_FALLING>;
-               x-size = <720>;
-               y-size = <1280>;
+               touchscreen-size-x = <720>;
+               touchscreen-size-y = <1280>;
                avdd-supply = <&tsp_reg>;
                vdd-supply = <&tsp_reg>;
        };
index ee8e1f445370003438296606a3b43d7b5b725053..30eee5942effeff02e3095d6c49d0dd6e35a97d0 100644 (file)
@@ -15,24 +15,22 @@ aliases {
                i2c10 = &i2c_cm36651;
        };
 
-       regulators {
-               lcd_vdd3_reg: voltage-regulator-2 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "LCD_VDD_2.2V";
-                       regulator-min-microvolt = <2200000>;
-                       regulator-max-microvolt = <2200000>;
-                       gpio = <&gpc0 1 GPIO_ACTIVE_HIGH>;
-                       enable-active-high;
-               };
+       lcd_vdd3_reg: voltage-regulator-6 {
+               compatible = "regulator-fixed";
+               regulator-name = "LCD_VDD_2.2V";
+               regulator-min-microvolt = <2200000>;
+               regulator-max-microvolt = <2200000>;
+               gpio = <&gpc0 1 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
 
-               ps_als_reg: voltage-regulator-5 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "LED_A_3.0V";
-                       regulator-min-microvolt = <3000000>;
-                       regulator-max-microvolt = <3000000>;
-                       gpio = <&gpj0 5 GPIO_ACTIVE_HIGH>;
-                       enable-active-high;
-               };
+       ps_als_reg: voltage-regulator-7 {
+               compatible = "regulator-fixed";
+               regulator-name = "LED_A_3.0V";
+               regulator-min-microvolt = <3000000>;
+               regulator-max-microvolt = <3000000>;
+               gpio = <&gpj0 5 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
        };
 
        i2c_ak8975: i2c-gpio-0 {
@@ -120,8 +118,8 @@ mms114-touchscreen@48 {
                reg = <0x48>;
                interrupt-parent = <&gpm2>;
                interrupts = <3 IRQ_TYPE_EDGE_FALLING>;
-               x-size = <720>;
-               y-size = <1280>;
+               touchscreen-size-x = <720>;
+               touchscreen-size-y = <1280>;
                avdd-supply = <&ldo23_reg>;
                vdd-supply = <&ldo24_reg>;
        };
index 76f2b30f173189ec795402df7812d2fa40df003a..dc11ca1673e8b21f9c49e7982813a6e2fd3e0d1a 100644 (file)
@@ -46,56 +46,50 @@ xusbxti {
                };
        };
 
-       regulators {
-               compatible = "simple-bus";
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               cam_io_reg: voltage-regulator-1 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "CAM_SENSOR_A";
-                       regulator-min-microvolt = <2800000>;
-                       regulator-max-microvolt = <2800000>;
-                       enable-active-high;
-                       status = "disabled";
-               };
+       cam_io_reg: voltage-regulator-1 {
+               compatible = "regulator-fixed";
+               regulator-name = "CAM_SENSOR_A";
+               regulator-min-microvolt = <2800000>;
+               regulator-max-microvolt = <2800000>;
+               enable-active-high;
+               status = "disabled";
+       };
 
-               cam_af_reg: voltage-regulator-3 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "CAM_AF";
-                       regulator-min-microvolt = <2800000>;
-                       regulator-max-microvolt = <2800000>;
-                       enable-active-high;
-                       status = "disabled";
-               };
+       cam_af_reg: voltage-regulator-2 {
+               compatible = "regulator-fixed";
+               regulator-name = "CAM_AF";
+               regulator-min-microvolt = <2800000>;
+               regulator-max-microvolt = <2800000>;
+               enable-active-high;
+               status = "disabled";
+       };
 
-               vsil12: voltage-regulator-6 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "VSIL_1.2V";
-                       regulator-min-microvolt = <1200000>;
-                       regulator-max-microvolt = <1200000>;
-                       gpio = <&gpl0 4 GPIO_ACTIVE_HIGH>;
-                       enable-active-high;
-                       vin-supply = <&buck7_reg>;
-               };
+       vsil12: voltage-regulator-3 {
+               compatible = "regulator-fixed";
+               regulator-name = "VSIL_1.2V";
+               regulator-min-microvolt = <1200000>;
+               regulator-max-microvolt = <1200000>;
+               gpio = <&gpl0 4 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+               vin-supply = <&buck7_reg>;
+       };
 
-               vcc33mhl: voltage-regulator-7 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "VCC_3.3_MHL";
-                       regulator-min-microvolt = <3300000>;
-                       regulator-max-microvolt = <3300000>;
-                       gpio = <&gpl0 4 GPIO_ACTIVE_HIGH>;
-                       enable-active-high;
-               };
+       vcc33mhl: voltage-regulator-4 {
+               compatible = "regulator-fixed";
+               regulator-name = "VCC_3.3_MHL";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               gpio = <&gpl0 4 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
 
-               vcc18mhl: voltage-regulator-8 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "VCC_1.8_MHL";
-                       regulator-min-microvolt = <1800000>;
-                       regulator-max-microvolt = <1800000>;
-                       gpio = <&gpl0 4 GPIO_ACTIVE_HIGH>;
-                       enable-active-high;
-               };
+       vcc18mhl: voltage-regulator-5 {
+               compatible = "regulator-fixed";
+               regulator-name = "VCC_1.8_MHL";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               gpio = <&gpl0 4 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
        };
 
        gpio-keys {
index eb402a0d66518a130aa04e3e65bfe70c9d520b77..fe2bfd76cc4e9dff1d9e5c3853f1f70b75e59f72 100644 (file)
@@ -13,15 +13,13 @@ memory@40000000 {
 
        /* bootargs are passed in by bootloader */
 
-       regulators {
-               cam_vdda_reg: voltage-regulator-9 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "CAM_SENSOR_CORE_1.2V";
-                       regulator-min-microvolt = <1200000>;
-                       regulator-max-microvolt = <1200000>;
-                       gpio = <&gpm4 1 GPIO_ACTIVE_HIGH>;
-                       enable-active-high;
-               };
+       cam_vdda_reg: voltage-regulator-6 {
+               compatible = "regulator-fixed";
+               regulator-name = "CAM_SENSOR_CORE_1.2V";
+               regulator-min-microvolt = <1200000>;
+               regulator-max-microvolt = <1200000>;
+               gpio = <&gpm4 1 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
        };
 };
 
index d7ad07fd48f99abea9842c07529857e80b9033b6..a09e46c9dbc04cbedfc626604339d9f4343f242c 100644 (file)
@@ -37,20 +37,14 @@ power_key {
        };
 
        sound: sound {
-               compatible = "simple-audio-card";
+               compatible = "hardkernel,odroid-xu4-audio";
 
-               simple-audio-card,format = "i2s";
-               simple-audio-card,bitclock-master = <&link0_codec>;
-               simple-audio-card,frame-master = <&link0_codec>;
-
-               simple-audio-card,cpu {
+               cpu {
                        sound-dai = <&i2s0 0>;
-                       system-clock-frequency = <19200000>;
                };
 
-               link0_codec: simple-audio-card,codec {
-                       sound-dai = <&max98090>;
-                       clocks = <&i2s0 CLK_I2S_CDCLK>;
+               codec {
+                       sound-dai = <&hdmi>, <&max98090>;
                };
        };
 
@@ -142,14 +136,25 @@ &camera {
        pinctrl-0 = <>;
 };
 
+&clock {
+       assigned-clocks = <&clock CLK_FOUT_EPLL>;
+       assigned-clock-rates = <45158401>;
+};
+
 &clock_audss {
        assigned-clocks = <&clock_audss EXYNOS_MOUT_AUDSS>,
                        <&clock_audss EXYNOS_MOUT_I2S>,
                        <&clock_audss EXYNOS_DOUT_SRP>,
-                       <&clock_audss EXYNOS_DOUT_AUD_BUS>;
+                       <&clock_audss EXYNOS_DOUT_AUD_BUS>,
+                       <&clock_audss EXYNOS_DOUT_I2S>;
+
        assigned-clock-parents = <&clock CLK_FOUT_EPLL>,
-                       <&clock_audss EXYNOS_MOUT_AUDSS>;
-       assigned-clock-rates = <0>, <0>, <192000000>, <19200000>;
+                         <&clock_audss EXYNOS_MOUT_AUDSS>;
+
+       assigned-clock-rates = <0>, <0>,
+                       <196608001>,
+                       <(196608001 / 2)>,
+                       <(196608001 / 8)>;
 };
 
 &cpu0 {
@@ -498,6 +503,8 @@ &i2s0 {
        pinctrl-0 = <&i2s0_bus>;
        pinctrl-names = "default";
        status = "okay";
+       assigned-clocks = <&i2s0 CLK_I2S_RCLK_SRC>;
+       assigned-clock-parents = <&clock_audss EXYNOS_SCLK_I2S>;
 };
 
 &mixer {
index bdcd4523cc1cc70ce3bc1b02dc56d30f11413e95..459919b65df814b2405db95043000607d39f86fa 100644 (file)
@@ -113,11 +113,11 @@ port@2 {
 };
 
 &sound {
-       simple-audio-card,name = "Odroid-U3";
-       simple-audio-card,widgets =
+       model = "Odroid-U3";
+       samsung,audio-widgets =
                "Headphone", "Headphone Jack",
                "Speakers", "Speakers";
-       simple-audio-card,routing =
+       samsung,audio-routing =
                "Headphone Jack", "HPL",
                "Headphone Jack", "HPR",
                "Headphone Jack", "MICBIAS",
index 2dff129bc2adbbc83fa931e6b8811bdeaae9476e..348556fcdd9d9dd010f71b65495bc8627a00b1d1 100644 (file)
@@ -97,12 +97,12 @@ &serial_3 {
 };
 
 &sound {
-       simple-audio-card,name = "Odroid-X";
-       simple-audio-card,widgets =
+       model = "Odroid-X";
+       samsung,audio-widgets =
                "Headphone", "Headphone Jack",
                "Microphone", "Mic Jack",
                "Microphone", "DMIC";
-       simple-audio-card,routing =
+       samsung,audio-routing =
                "Headphone Jack", "HPL",
                "Headphone Jack", "HPR",
                "IN1", "Mic Jack",
index 1514f0dbaff8d707ae7434bc56ecbb10d439c8d2..346f7193245715095f713b517987a248d579d10f 100644 (file)
@@ -90,7 +90,7 @@ &ehci {
        samsung,vbus-gpio = <&gpx3 5 1>;
        status = "okay";
 
-       port@1{
+       port@1 {
                status = "okay";
        };
        port@2 {
index 2ae1ab602f4bd2283e0f7224d564b616bcd29301..7b43c10c510bf92f73536c36fac989f5864f666d 100644 (file)
@@ -298,7 +298,7 @@ mshc_0: mmc@12550000 {
                        status = "disabled";
                };
 
-               sysmmu_g2d: sysmmu@10A40000{
+               sysmmu_g2d: sysmmu@10a40000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x10A40000 0x1000>;
                        interrupt-parent = <&combiner>;
index f8d7de1144f128f169e33caa930f7ac6743fede7..5d2f0a06fbeff6bf38e9eb52851bd0fc59241a3d 100644 (file)
@@ -12,7 +12,6 @@
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/interrupt-controller/irq.h>
-#include "exynos-syscon-restart.dtsi"
 
 / {
        interrupt-parent = <&gic>;
@@ -197,8 +196,6 @@ dp: dp-controller@145b0000 {
                        reg = <0x145B0000 0x1000>;
                        interrupts = <10 3>;
                        interrupt-parent = <&combiner>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
                        status = "disabled";
                };
 
index 45283a6c5eee767e189679709d4e8ad024a761d9..2daf505b3d08e2f0877fcfc72e3ea8ef0860795a 100644 (file)
@@ -132,10 +132,6 @@ pd_disp1: power-domain@100440a0 {
                        reg = <0x100440A0 0x20>;
                        #power-domain-cells = <0>;
                        label = "DISP1";
-                       clocks = <&clock CLK_FIN_PLL>,
-                                <&clock CLK_MOUT_ACLK200_DISP1_SUB>,
-                                <&clock CLK_MOUT_ACLK300_DISP1_SUB>;
-                       clock-names = "oscclk", "clk0", "clk1";
                };
 
                pd_mau: power-domain@100440c0 {
@@ -882,7 +878,7 @@ sysmmu_fimc_dis0: sysmmu@132d0000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_fimc_dis1: sysmmu@132E0000{
+               sysmmu_fimc_dis1: sysmmu@132e0000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x132E0000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -1117,3 +1113,4 @@ &trng {
 };
 
 #include "exynos5250-pinctrl.dtsi"
+#include "exynos-syscon-restart.dtsi"
index 55509c690328fe824529050bd43aa5c379e1db7a..20e789ea136f42ca32af515b24c216ee8dbc1c7e 100644 (file)
@@ -439,3 +439,4 @@ &watchdog {
 };
 
 #include "exynos5410-pinctrl.dtsi"
+#include "exynos-syscon-restart.dtsi"
index 244f0091c21f5aa20593e9ab0e566fadfb3dba11..57c2332bf28247b354592c0dbe839fa5a8ed6560 100644 (file)
@@ -29,7 +29,7 @@ / {
 
        aliases {
                /* Assign 20 so we don't get confused w/ builtin ones */
-               i2c20 = "/spi@12d40000/cros-ec@0/i2c-tunnel";
+               i2c20 = &i2c_tunnel;
        };
 
        backlight: backlight {
@@ -970,7 +970,7 @@ controller-data {
                        samsung,spi-feedback-delay = <1>;
                };
 
-               i2c-tunnel {
+               i2c_tunnel: i2c-tunnel {
                        compatible = "google,cros-ec-i2c-tunnel";
                        #address-cells = <1>;
                        #size-cells = <0>;
index 2f3cb2a97f719952df23468b2234315e8f4e0d1f..f4e8c5823bc2cc5371a90a7fa220580038fd40de 100644 (file)
@@ -276,10 +276,6 @@ gsc_pd: power-domain@10044000 {
                        reg = <0x10044000 0x20>;
                        #power-domain-cells = <0>;
                        label = "GSC";
-                       clocks = <&clock CLK_FIN_PLL>,
-                                <&clock CLK_MOUT_USER_ACLK300_GSCL>,
-                                <&clock CLK_GSCL0>, <&clock CLK_GSCL1>;
-                       clock-names = "oscclk", "clk0", "asb0", "asb1";
                };
 
                isp_pd: power-domain@10044020 {
@@ -292,10 +288,6 @@ isp_pd: power-domain@10044020 {
                mfc_pd: power-domain@10044060 {
                        compatible = "samsung,exynos4210-pd";
                        reg = <0x10044060 0x20>;
-                       clocks = <&clock CLK_FIN_PLL>,
-                                <&clock CLK_MOUT_USER_ACLK333>,
-                                <&clock CLK_ACLK333>;
-                       clock-names = "oscclk", "clk0","asb0";
                        #power-domain-cells = <0>;
                        label = "MFC";
                };
@@ -312,12 +304,6 @@ disp_pd: power-domain@100440c0 {
                        reg = <0x100440C0 0x20>;
                        #power-domain-cells = <0>;
                        label = "DISP";
-                       clocks = <&clock CLK_FIN_PLL>,
-                                <&clock CLK_MOUT_USER_ACLK200_DISP1>,
-                                <&clock CLK_MOUT_USER_ACLK300_DISP1>,
-                                <&clock CLK_MOUT_USER_ACLK400_DISP1>,
-                                <&clock CLK_FIMD1>, <&clock CLK_MIXER>;
-                       clock-names = "oscclk", "clk0", "clk1", "clk2", "asb0", "asb1";
                };
 
                mau_pd: power-domain@100440e0 {
@@ -687,6 +673,36 @@ gsc_1: video-scaler@13e10000 {
                        iommus = <&sysmmu_gscl1>;
                };
 
+               scaler_0: scaler@12800000 {
+                       compatible = "samsung,exynos5420-scaler";
+                       reg = <0x12800000 0x1294>;
+                       interrupts = <0 220 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&clock CLK_MSCL0>;
+                       clock-names = "mscl";
+                       power-domains = <&msc_pd>;
+                       iommus = <&sysmmu_scaler0r>, <&sysmmu_scaler0w>;
+               };
+
+               scaler_1: scaler@12810000 {
+                       compatible = "samsung,exynos5420-scaler";
+                       reg = <0x12810000 0x1294>;
+                       interrupts = <0 221 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&clock CLK_MSCL1>;
+                       clock-names = "mscl";
+                       power-domains = <&msc_pd>;
+                       iommus = <&sysmmu_scaler1r>, <&sysmmu_scaler1w>;
+               };
+
+               scaler_2: scaler@12820000 {
+                       compatible = "samsung,exynos5420-scaler";
+                       reg = <0x12820000 0x1294>;
+                       interrupts = <0 222 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&clock CLK_MSCL2>;
+                       clock-names = "mscl";
+                       power-domains = <&msc_pd>;
+                       iommus = <&sysmmu_scaler2r>, <&sysmmu_scaler2w>;
+               };
+
                jpeg_0: jpeg@11f50000 {
                        compatible = "samsung,exynos5420-jpeg";
                        reg = <0x11F50000 0x1000>;
@@ -761,7 +777,7 @@ tmu_gpu: tmu@100a0000 {
                        #include "exynos5420-tmu-sensor-conf.dtsi"
                };
 
-               sysmmu_g2dr: sysmmu@0x10A60000 {
+               sysmmu_g2dr: sysmmu@10a60000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x10A60000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -771,7 +787,7 @@ sysmmu_g2dr: sysmmu@0x10A60000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_g2dw: sysmmu@0x10A70000 {
+               sysmmu_g2dw: sysmmu@10a70000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x10A70000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -781,7 +797,7 @@ sysmmu_g2dw: sysmmu@0x10A70000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_tv: sysmmu@0x14650000 {
+               sysmmu_tv: sysmmu@14650000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x14650000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -792,7 +808,7 @@ sysmmu_tv: sysmmu@0x14650000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_gscl0: sysmmu@0x13E80000 {
+               sysmmu_gscl0: sysmmu@13e80000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x13E80000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -803,7 +819,7 @@ sysmmu_gscl0: sysmmu@0x13E80000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_gscl1: sysmmu@0x13E90000 {
+               sysmmu_gscl1: sysmmu@13e90000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x13E90000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -814,65 +830,71 @@ sysmmu_gscl1: sysmmu@0x13E90000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_scaler0r: sysmmu@0x12880000 {
+               sysmmu_scaler0r: sysmmu@12880000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x12880000 0x1000>;
                        interrupt-parent = <&combiner>;
                        interrupts = <22 4>;
                        clock-names = "sysmmu", "master";
                        clocks = <&clock CLK_SMMU_MSCL0>, <&clock CLK_MSCL0>;
+                       power-domains = <&msc_pd>;
                        #iommu-cells = <0>;
                };
 
-               sysmmu_scaler1r: sysmmu@0x12890000 {
+               sysmmu_scaler1r: sysmmu@12890000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x12890000 0x1000>;
                        interrupts = <GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>;
                        clock-names = "sysmmu", "master";
                        clocks = <&clock CLK_SMMU_MSCL1>, <&clock CLK_MSCL1>;
+                       power-domains = <&msc_pd>;
                        #iommu-cells = <0>;
                };
 
-               sysmmu_scaler2r: sysmmu@0x128A0000 {
+               sysmmu_scaler2r: sysmmu@128a0000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x128A0000 0x1000>;
                        interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
                        clock-names = "sysmmu", "master";
                        clocks = <&clock CLK_SMMU_MSCL2>, <&clock CLK_MSCL2>;
+                       power-domains = <&msc_pd>;
                        #iommu-cells = <0>;
                };
 
-               sysmmu_scaler0w: sysmmu@0x128C0000 {
+               sysmmu_scaler0w: sysmmu@128c0000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x128C0000 0x1000>;
                        interrupt-parent = <&combiner>;
                        interrupts = <27 2>;
                        clock-names = "sysmmu", "master";
                        clocks = <&clock CLK_SMMU_MSCL0>, <&clock CLK_MSCL0>;
+                       power-domains = <&msc_pd>;
                        #iommu-cells = <0>;
                };
 
-               sysmmu_scaler1w: sysmmu@0x128D0000 {
+               sysmmu_scaler1w: sysmmu@128d0000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x128D0000 0x1000>;
                        interrupt-parent = <&combiner>;
                        interrupts = <22 6>;
                        clock-names = "sysmmu", "master";
                        clocks = <&clock CLK_SMMU_MSCL1>, <&clock CLK_MSCL1>;
+                       power-domains = <&msc_pd>;
                        #iommu-cells = <0>;
                };
 
-               sysmmu_scaler2w: sysmmu@0x128E0000 {
+               sysmmu_scaler2w: sysmmu@128e0000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x128E0000 0x1000>;
                        interrupt-parent = <&combiner>;
                        interrupts = <19 6>;
                        clock-names = "sysmmu", "master";
                        clocks = <&clock CLK_SMMU_MSCL2>, <&clock CLK_MSCL2>;
+                       power-domains = <&msc_pd>;
                        #iommu-cells = <0>;
                };
 
-               sysmmu_rotator: sysmmu@0x11D40000 {
+               sysmmu_rotator: sysmmu@11d40000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x11D40000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -882,7 +904,7 @@ sysmmu_rotator: sysmmu@0x11D40000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_jpeg0: sysmmu@0x11F10000 {
+               sysmmu_jpeg0: sysmmu@11f10000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x11F10000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -892,7 +914,7 @@ sysmmu_jpeg0: sysmmu@0x11F10000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_jpeg1: sysmmu@0x11F20000 {
+               sysmmu_jpeg1: sysmmu@11f20000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x11F20000 0x1000>;
                        interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>;
@@ -901,7 +923,7 @@ sysmmu_jpeg1: sysmmu@0x11F20000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_mfc_l: sysmmu@0x11200000 {
+               sysmmu_mfc_l: sysmmu@11200000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x11200000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -912,7 +934,7 @@ sysmmu_mfc_l: sysmmu@0x11200000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_mfc_r: sysmmu@0x11210000 {
+               sysmmu_mfc_r: sysmmu@11210000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x11210000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -923,7 +945,7 @@ sysmmu_mfc_r: sysmmu@0x11210000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_fimd1_0: sysmmu@0x14640000 {
+               sysmmu_fimd1_0: sysmmu@14640000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x14640000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -934,7 +956,7 @@ sysmmu_fimd1_0: sysmmu@0x14640000 {
                        #iommu-cells = <0>;
                };
 
-               sysmmu_fimd1_1: sysmmu@0x14680000 {
+               sysmmu_fimd1_1: sysmmu@14680000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x14680000 0x1000>;
                        interrupt-parent = <&combiner>;
@@ -1531,3 +1553,4 @@ &watchdog {
 };
 
 #include "exynos5420-pinctrl.dtsi"
+#include "exynos-syscon-restart.dtsi"
index d31249f25ccf41aa32ecd2cc68889e420414bac9..2f4f40882daba05c1436091f332f80f7f65d8244 100644 (file)
@@ -23,7 +23,7 @@ chosen {
                stdout-path = "serial2:115200n8";
        };
 
-       firmware@02073000 {
+       firmware@2073000 {
                compatible = "samsung,secure-firmware";
                reg = <0x02073000 0x1000>;
        };
diff --git a/arch/arm/boot/dts/exynos5440-sd5v1.dts b/arch/arm/boot/dts/exynos5440-sd5v1.dts
deleted file mode 100644 (file)
index c4b8392..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * SAMSUNG SD5v1 board device tree source
- *
- * Copyright (c) 2013 Samsung Electronics Co., Ltd.
- *             http://www.samsung.com
- */
-
-/dts-v1/;
-#include "exynos5440.dtsi"
-
-/ {
-       model = "SAMSUNG SD5v1 board based on EXYNOS5440";
-       compatible = "samsung,sd5v1", "samsung,exynos5440", "samsung,exynos5";
-
-       chosen {
-               bootargs = "root=/dev/sda2 rw rootwait ignore_loglevel earlyprintk no_console_suspend mem=2048M@0x80000000 mem=6144M@0x100000000 console=ttySAC0,115200";
-       };
-
-       /* FIXME: set reg property with correct start address and size */
-       memory@0 {
-               device_type = "memory";
-               reg = <0 0>;
-       };
-
-       fixed-rate-clocks {
-               xtal {
-                       compatible = "samsung,clock-xtal";
-                       clock-frequency = <50000000>;
-               };
-       };
-
-       spi {
-               status = "disabled";
-       };
-
-};
-
-&gmac {
-       fixed_phy;
-       phy_addr = <1>;
-};
diff --git a/arch/arm/boot/dts/exynos5440-ssdk5440.dts b/arch/arm/boot/dts/exynos5440-ssdk5440.dts
deleted file mode 100644 (file)
index a33c4fc..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * SAMSUNG SSDK5440 board device tree source
- *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd.
- *             http://www.samsung.com
- */
-
-/dts-v1/;
-#include "exynos5440.dtsi"
-#include <dt-bindings/gpio/gpio.h>
-
-/ {
-       model = "SAMSUNG SSDK5440 board based on EXYNOS5440";
-       compatible = "samsung,ssdk5440", "samsung,exynos5440", "samsung,exynos5";
-
-       chosen {
-               bootargs = "root=/dev/sda2 rw rootwait ignore_loglevel earlyprintk no_console_suspend mem=2048M@0x80000000 mem=6144M@0x100000000 console=ttySAC0,115200";
-       };
-
-       /* FIXME: set reg property with correct start address and size */
-       memory@0 {
-               device_type = "memory";
-               reg = <0 0>;
-       };
-
-       fixed-rate-clocks {
-               xtal {
-                       compatible = "samsung,clock-xtal";
-                       clock-frequency = <50000000>;
-               };
-       };
-};
-
-&pcie_0 {
-       reset-gpio = <&pin_ctrl 5 GPIO_ACTIVE_HIGH>;
-       status = "okay";
-};
-
-&pcie_1 {
-       reset-gpio = <&pin_ctrl 22 GPIO_ACTIVE_HIGH>;
-       status = "okay";
-};
-
-&spi_0 {
-       flash: w25q128@0 {
-               #address-cells = <1>;
-               #size-cells = <1>;
-               compatible = "winbond,w25q128";
-               spi-max-frequency = <15625000>;
-               reg = <0>;
-               controller-data {
-                       samsung,spi-feedback-delay = <0>;
-               };
-
-               partition@0 {
-                       label = "BootLoader";
-                       reg = <0x60000 0x80000>;
-                       read-only;
-               };
-
-               partition@e0000 {
-                       label = "Recovery-Kernel";
-                       reg = <0xe0000 0x300000>;
-                       read-only;
-               };
-
-               partition@3e0000 {
-                       label = "CRAM-FS";
-                       reg = <0x3e0000 0x700000>;
-                       read-only;
-               };
-
-               partition@ae0000 {
-                       label = "User-Data";
-                       reg = <0xae0000 0x520000>;
-               };
-
-       };
-
-};
diff --git a/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi b/arch/arm/boot/dts/exynos5440-tmu-sensor-conf.dtsi
deleted file mode 100644 (file)
index 0421c3d..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Device tree sources for Exynos5440 TMU sensor configuration
- *
- * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
- */
-
-#include <dt-bindings/thermal/thermal_exynos.h>
-
-#thermal-sensor-cells = <0>;
-samsung,tmu_gain = <5>;
-samsung,tmu_reference_voltage = <16>;
-samsung,tmu_noise_cancel_mode = <4>;
-samsung,tmu_efuse_value = <0x5d2d>;
-samsung,tmu_min_efuse_value = <16>;
-samsung,tmu_max_efuse_value = <76>;
-samsung,tmu_first_point_trim = <25>;
-samsung,tmu_second_point_trim = <70>;
-samsung,tmu_default_temp_offset = <25>;
-samsung,tmu_cal_type = <TYPE_ONE_POINT_TRIMMING>;
diff --git a/arch/arm/boot/dts/exynos5440-trip-points.dtsi b/arch/arm/boot/dts/exynos5440-trip-points.dtsi
deleted file mode 100644 (file)
index a2b04fe..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Device tree sources for default Exynos5440 thermal zone definition
- *
- * Copyright (c) 2014 Lukasz Majewski <l.majewski@samsung.com>
- */
-
-polling-delay-passive = <0>;
-polling-delay = <0>;
-trips {
-       cpu-alert-0 {
-               temperature = <100000>; /* millicelsius */
-               hysteresis = <0>; /* millicelsius */
-               type = "active";
-       };
-       cpu-crit-0 {
-               temperature = <105000>; /* millicelsius */
-               hysteresis = <0>; /* millicelsius */
-               type = "critical";
-       };
-};
diff --git a/arch/arm/boot/dts/exynos5440.dtsi b/arch/arm/boot/dts/exynos5440.dtsi
deleted file mode 100644 (file)
index f3abecc..0000000
+++ /dev/null
@@ -1,355 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * SAMSUNG EXYNOS5440 SoC device tree source
- *
- * Copyright (c) 2012 Samsung Electronics Co., Ltd.
- *             http://www.samsung.com
- */
-
-#include <dt-bindings/clock/exynos5440.h>
-#include <dt-bindings/interrupt-controller/arm-gic.h>
-#include <dt-bindings/interrupt-controller/irq.h>
-
-/ {
-       compatible = "samsung,exynos5440", "samsung,exynos5";
-
-       interrupt-parent = <&gic>;
-       #address-cells = <1>;
-       #size-cells = <1>;
-
-       aliases {
-               serial0 = &serial_0;
-               serial1 = &serial_1;
-               spi0 = &spi_0;
-               tmuctrl0 = &tmuctrl_0;
-               tmuctrl1 = &tmuctrl_1;
-               tmuctrl2 = &tmuctrl_2;
-       };
-
-       cpus {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               cpu@0 {
-                       device_type = "cpu";
-                       compatible = "arm,cortex-a15";
-                       reg = <0>;
-               };
-               cpu@1 {
-                       device_type = "cpu";
-                       compatible = "arm,cortex-a15";
-                       reg = <1>;
-               };
-               cpu@2 {
-                       device_type = "cpu";
-                       compatible = "arm,cortex-a15";
-                       reg = <2>;
-               };
-               cpu@3 {
-                       device_type = "cpu";
-                       compatible = "arm,cortex-a15";
-                       reg = <3>;
-               };
-       };
-
-       soc: soc {
-               compatible = "simple-bus";
-               #address-cells = <1>;
-               #size-cells = <1>;
-               ranges;
-
-               clock: clock-controller@160000 {
-                       compatible = "samsung,exynos5440-clock";
-                       reg = <0x160000 0x1000>;
-                       #clock-cells = <1>;
-               };
-
-               gic: interrupt-controller@2e0000 {
-                       compatible = "arm,cortex-a15-gic";
-                       #interrupt-cells = <3>;
-                       interrupt-controller;
-                       reg =   <0x2E1000 0x1000>,
-                               <0x2E2000 0x2000>,
-                               <0x2E4000 0x2000>,
-                               <0x2E6000 0x2000>;
-                       interrupts = <GIC_PPI 9
-                                       (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
-               };
-
-
-               arm-pmu {
-                       compatible = "arm,cortex-a15-pmu", "arm,cortex-a9-pmu";
-                       interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>;
-               };
-
-               timer {
-                       compatible = "arm,cortex-a15-timer",
-                                    "arm,armv7-timer";
-                       interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                                    <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                                    <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                                    <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
-                       clock-frequency = <50000000>;
-               };
-
-               cpufreq@160000 {
-                       compatible = "samsung,exynos5440-cpufreq";
-                       reg = <0x160000 0x1000>;
-                       interrupts = <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>;
-                       operating-points = <
-                                       /* KHz    uV */
-                                       1500000 1100000
-                                       1400000 1075000
-                                       1300000 1050000
-                                       1200000 1025000
-                                       1100000 1000000
-                                       1000000 975000
-                                       900000  950000
-                                       800000  925000
-                       >;
-               };
-
-               serial_0: serial@b0000 {
-                       compatible = "samsung,exynos4210-uart";
-                       reg = <0xB0000 0x1000>;
-                       interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_B_125>, <&clock CLK_B_125>;
-                       clock-names = "uart", "clk_uart_baud0";
-               };
-
-               serial_1: serial@c0000 {
-                       compatible = "samsung,exynos4210-uart";
-                       reg = <0xC0000 0x1000>;
-                       interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_B_125>, <&clock CLK_B_125>;
-                       clock-names = "uart", "clk_uart_baud0";
-               };
-
-               spi_0: spi@d0000 {
-                       compatible = "samsung,exynos5440-spi";
-                       reg = <0xD0000 0x100>;
-                       interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       samsung,spi-src-clk = <0>;
-                       num-cs = <1>;
-                       clocks = <&clock CLK_B_125>, <&clock CLK_SPI_BAUD>;
-                       clock-names = "spi", "spi_busclk0";
-               };
-
-               pin_ctrl: pinctrl@e0000 {
-                       compatible = "samsung,exynos5440-pinctrl";
-                       reg = <0xE0000 0x1000>;
-                       interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-controller;
-                       #interrupt-cells = <2>;
-                       #gpio-cells = <2>;
-
-                       fan: fan {
-                               samsung,exynos5440-pin-function = <1>;
-                       };
-
-                       hdd_led0: hdd_led0 {
-                               samsung,exynos5440-pin-function = <2>;
-                       };
-
-                       hdd_led1: hdd_led1 {
-                               samsung,exynos5440-pin-function = <3>;
-                       };
-
-                       uart1: uart1 {
-                               samsung,exynos5440-pin-function = <4>;
-                       };
-               };
-
-               i2c@f0000 {
-                       compatible = "samsung,exynos5440-i2c";
-                       reg = <0xF0000 0x1000>;
-                       interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       clocks = <&clock CLK_B_125>;
-                       clock-names = "i2c";
-               };
-
-               i2c@100000 {
-                       compatible = "samsung,exynos5440-i2c";
-                       reg = <0x100000 0x1000>;
-                       interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       clocks = <&clock CLK_B_125>;
-                       clock-names = "i2c";
-               };
-
-               watchdog@110000 {
-                       compatible = "samsung,s3c6410-wdt";
-                       reg = <0x110000 0x1000>;
-                       interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_B_125>;
-                       clock-names = "watchdog";
-               };
-
-               gmac: ethernet@230000 {
-                       compatible = "snps,dwmac-3.70a", "snps,dwmac";
-                       reg = <0x00230000 0x8000>;
-                       interrupt-parent = <&gic>;
-                       interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "macirq";
-                       phy-mode = "sgmii";
-                       clocks = <&clock CLK_GMAC0>;
-                       clock-names = "stmmaceth";
-               };
-
-               amba {
-                       #address-cells = <1>;
-                       #size-cells = <1>;
-                       compatible = "simple-bus";
-                       interrupt-parent = <&gic>;
-                       ranges;
-               };
-
-               rtc@130000 {
-                       compatible = "samsung,s3c6410-rtc";
-                       reg = <0x130000 0x1000>;
-                       interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_B_125>;
-                       clock-names = "rtc";
-               };
-
-               tmuctrl_0: tmuctrl@160118 {
-                       compatible = "samsung,exynos5440-tmu";
-                       reg = <0x160118 0x230>, <0x160368 0x10>;
-                       interrupts = <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_B_125>;
-                       clock-names = "tmu_apbif";
-                       #include "exynos5440-tmu-sensor-conf.dtsi"
-               };
-
-               tmuctrl_1: tmuctrl@16011c {
-                       compatible = "samsung,exynos5440-tmu";
-                       reg = <0x16011C 0x230>, <0x160368 0x10>;
-                       interrupts = <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_B_125>;
-                       clock-names = "tmu_apbif";
-                       #include "exynos5440-tmu-sensor-conf.dtsi"
-               };
-
-               tmuctrl_2: tmuctrl@160120 {
-                       compatible = "samsung,exynos5440-tmu";
-                       reg = <0x160120 0x230>, <0x160368 0x10>;
-                       interrupts = <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_B_125>;
-                       clock-names = "tmu_apbif";
-                       #include "exynos5440-tmu-sensor-conf.dtsi"
-               };
-
-               sata@210000 {
-                       compatible = "snps,exynos5440-ahci";
-                       reg = <0x210000 0x10000>;
-                       interrupts = <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_SATA>;
-                       clock-names = "sata";
-               };
-
-               ohci@220000 {
-                       compatible = "samsung,exynos5440-ohci";
-                       reg = <0x220000 0x1000>;
-                       interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_USB>;
-                       clock-names = "usbhost";
-               };
-
-               ehci@221000 {
-                       compatible = "samsung,exynos5440-ehci";
-                       reg = <0x221000 0x1000>;
-                       interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_USB>;
-                       clock-names = "usbhost";
-               };
-
-               pcie_phy0: pcie-phy@270000 {
-                       #phy-cells = <0>;
-                       compatible = "samsung,exynos5440-pcie-phy";
-                       reg = <0x270000 0x1000>, <0x271000 0x40>;
-               };
-
-               pcie_phy1: pcie-phy@272000 {
-                       #phy-cells = <0>;
-                       compatible = "samsung,exynos5440-pcie-phy";
-                       reg = <0x272000 0x1000>, <0x271040 0x40>;
-               };
-
-               pcie_0: pcie@290000 {
-                       compatible = "samsung,exynos5440-pcie", "snps,dw-pcie";
-                       reg = <0x290000 0x1000>, <0x40000000 0x1000>;
-                       reg-names = "elbi", "config";
-                       interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_PR0_250_O>, <&clock CLK_PB0_250_O>;
-                       clock-names = "pcie", "pcie_bus";
-                       #address-cells = <3>;
-                       #size-cells = <2>;
-                       device_type = "pci";
-                       phys = <&pcie_phy0>;
-                       ranges = <0x81000000 0 0          0x40001000 0 0x00010000   /* downstream I/O */
-                                 0x82000000 0 0x40011000 0x40011000 0 0x1ffef000>; /* non-prefetchable memory */
-                       bus-range = <0x00 0xff>;
-                       #interrupt-cells = <1>;
-                       interrupt-map-mask = <0 0 0 0>;
-                       interrupt-map = <0x0 0 &gic 53>;
-                       num-lanes = <4>;
-                       status = "disabled";
-               };
-
-               pcie_1: pcie@2a0000 {
-                       compatible = "samsung,exynos5440-pcie", "snps,dw-pcie";
-                       reg = <0x2a0000 0x1000>, <0x60000000 0x1000>;
-                       reg-names = "elbi", "config";
-                       interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&clock CLK_PR1_250_O>, <&clock CLK_PB0_250_O>;
-                       clock-names = "pcie", "pcie_bus";
-                       #address-cells = <3>;
-                       #size-cells = <2>;
-                       device_type = "pci";
-                       phys = <&pcie_phy1>;
-                       ranges = <0x81000000 0 0          0x60001000 0 0x00010000   /* downstream I/O */
-                                 0x82000000 0 0x60011000 0x60011000 0 0x1ffef000>; /* non-prefetchable memory */
-                       bus-range = <0x00 0xff>;
-                       #interrupt-cells = <1>;
-                       interrupt-map-mask = <0 0 0 0>;
-                       interrupt-map = <0x0 0 &gic 56>;
-                       num-lanes = <4>;
-                       status = "disabled";
-               };
-       };
-
-       thermal-zones {
-               cpu0_thermal: cpu0-thermal {
-                       thermal-sensors = <&tmuctrl_0>;
-                       #include "exynos5440-trip-points.dtsi"
-               };
-               cpu1_thermal: cpu1-thermal {
-                      thermal-sensors = <&tmuctrl_1>;
-                      #include "exynos5440-trip-points.dtsi"
-               };
-               cpu2_thermal: cpu2-thermal {
-                      thermal-sensors = <&tmuctrl_2>;
-                      #include "exynos5440-trip-points.dtsi"
-               };
-       };
-};
index 2f8df9244f72f879cefcf27cf968677fe33c6ef9..d80ab9085da19330b877643345e24cb50439d89c 100644 (file)
@@ -27,7 +27,7 @@ / {
 
        aliases {
                /* Assign 20 so we don't get confused w/ builtin ones */
-               i2c20 = "/spi@12d40000/cros-ec@0/i2c-tunnel";
+               i2c20 = &i2c_tunnel;
        };
 
        backlight: backlight {
@@ -939,7 +939,7 @@ controller-data {
                        samsung,spi-feedback-delay = <1>;
                };
 
-               i2c-tunnel {
+               i2c_tunnel: i2c-tunnel {
                        compatible = "google,cros-ec-i2c-tunnel";
                        #address-cells = <1>;
                        #size-cells = <0>;
index cadde92bc6b5a16205a79feba24ceb347a551f10..fb5c954ab95a2ca98ac3223a2ce27e8ca7581dd8 100644 (file)
@@ -13,22 +13,22 @@ / {
        #address-cells = <1>;
        #size-cells = <1>;
 
-       memory {
+       memory@0 {
                /* 128 MB SDRAM in 2 x Hynix HY5DU121622DTP-D43 */
                device_type = "memory";
                reg = <0x00000000 0x8000000>;
        };
 
        chosen {
-               stdout-path = "uart0:115200n8";
+               bootargs = "console=ttyS0,19200n8 root=/dev/sda1 rw rootwait";
+               stdout-path = "uart0:19200n8";
        };
 
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
+
                button-esc {
-                       debounce_interval = <50>;
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <KEY_ESC>;
                        label = "reset";
@@ -36,7 +36,7 @@ button-esc {
                        gpios = <&gpio0 8 GPIO_ACTIVE_LOW>;
                };
                button-eject {
-                       debounce_interval = <50>;
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <KEY_EJECTCD>;
                        label = "unmount";
@@ -98,7 +98,7 @@ led-wps {
                /*
                 * These two LEDs are on the side of the device.
                 * For electrical reasons, both LEDs cannot be active
-                * at the same time so only blue or orange can on at
+                * at the same time so only blue or orange can be on at
                 * one time. Enabling both makes the LED go dark.
                 * The LEDs both sit inside the unmount button and the
                 * label on the case says "unmount".
@@ -108,12 +108,14 @@ led-blue-hd {
                        /* Collides with LPC_SERIRQ, UART DTR, SSP FSC pins */
                        gpios = <&gpio0 11 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
+                       linux,default-trigger = "disk-read";
                };
                led-orange-hd {
                        label = "dir685:orange:HD";
                        /* Collides with LPC_LAD[2], UART DSR, SSP ECLK pins */
                        gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
+                       linux,default-trigger = "disk-write";
                };
        };
 
index 403364a7aab985094cd3b3adb1fad45d1d9d98f9..d1329322b968540825459b040c96006b9f21eea8 100644 (file)
@@ -15,7 +15,7 @@ / {
        #address-cells = <1>;
        #size-cells = <1>;
 
-       memory {
+       memory@0 {
                /* 64 MB SDRAM in a Nanya NT5DS32M16BS-6K package */
                device_type = "memory";
                reg = <0x00000000 0x4000000>;
@@ -26,15 +26,15 @@ aliases {
        };
 
        chosen {
+               bootargs = "console=ttyS0,19200n8 root=/dev/sda4 rw rootwait";
                stdout-path = "uart0:19200n8";
        };
 
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
+
                button-esc {
-                       debounce_interval = <50>;
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <KEY_ESC>;
                        label = "reset";
@@ -59,14 +59,13 @@ led-disk-green {
                        label = "dns313:green:disk";
                        gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
-                       linux,default-trigger = "ide-disk";
-                       /* Ideally should activate while reading */
+                       linux,default-trigger = "disk-read";
                };
                led-disk-red {
                        label = "dns313:red:disk";
                        gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
-                       /* Ideally should activate while writing */
+                       linux,default-trigger = "disk-write";
                };
        };
 
@@ -158,8 +157,12 @@ phy0: ethernet-phy@1 {
 
        soc {
                flash@30000000 {
+                       /*
+                        * This is a Eon EN29LV400AB 512 KiB flash with
+                        * three partitions.
+                        */
+                       compatible = "cortina,gemini-flash", "jedec-flash";
                        status = "okay";
-                       /* 512KB of flash */
                        reg = <0x30000000 0x00080000>;
 
                        /*
index 4785fbcc41ed840f0e72507163d2374532925395..963ea890c87f2ed52dd02446798aa0fae6f153ae 100644 (file)
@@ -14,7 +14,7 @@ / {
        #address-cells = <1>;
        #size-cells = <1>;
 
-       memory { /* 128 MB */
+       memory@0 { /* 128 MB */
                device_type = "memory";
                reg = <0x00000000 0x8000000>;
        };
@@ -26,19 +26,17 @@ chosen {
 
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
-               button@29 {
-                       debounce_interval = <50>;
+               button-setup {
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <KEY_SETUP>;
                        label = "Backup button";
                        /* Conflict with TVC */
                        gpios = <&gpio1 29 GPIO_ACTIVE_LOW>;
                };
-               button@31 {
-                       debounce_interval = <50>;
+               button-restart {
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <KEY_RESTART>;
                        label = "Softreset button";
@@ -49,13 +47,13 @@ button@31 {
 
        leds {
                compatible = "gpio-leds";
-               led@28 {
+               led-orange-hdd {
                        label = "nas4220b:orange:hdd";
                        /* Conflict with TVC */
                        gpios = <&gpio1 28 GPIO_ACTIVE_HIGH>;
                        default-state = "on";
                };
-               led@30 {
+               led-green-os {
                        label = "nas4220b:green:os";
                        /* Conflict with TVC */
                        gpios = <&gpio1 30 GPIO_ACTIVE_HIGH>;
@@ -202,5 +200,9 @@ ethernet-port@1 {
                ata@63000000 {
                        status = "okay";
                };
+
+               ata@63400000 {
+                       status = "okay";
+               };
        };
 };
index 15f20178642cf6018cbd5b820f276e8f08c580f8..eb4f0bf074da368495b96c8a8f1b146cba812909 100644 (file)
@@ -14,7 +14,7 @@ / {
        #address-cells = <1>;
        #size-cells = <1>;
 
-       memory { /* 128 MB */
+       memory@0 { /* 128 MB */
                device_type = "memory";
                reg = <0x00000000 0x8000000>;
        };
@@ -26,11 +26,9 @@ chosen {
 
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
-               button@28 {
-                       debounce_interval = <50>;
+               button-setup {
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <KEY_SETUP>;
                        label = "Reset to defaults";
@@ -41,14 +39,14 @@ button@28 {
 
        leds {
                compatible = "gpio-leds";
-               led@7 {
+               led-gsm {
                        /* FIXME: add the LED color */
                        label = "rut1xx::gsm";
                        /* Conflict with ICE */
                        gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>;
                        default-state = "on";
                };
-               led@31 {
+               led-power {
                        /* FIXME: add the LED color */
                        label = "rut1xx::power";
                        /* Conflict with NAND CE0 */
index 63c02ca9513c408ee9a67e6d31f718722ea5cef6..e5cf9d1a98cd4f27da7e557c423acf57955bf1e2 100644 (file)
@@ -14,7 +14,7 @@ / {
        #address-cells = <1>;
        #size-cells = <1>;
 
-       memory { /* 128 MB */
+       memory@0 { /* 128 MB */
                device_type = "memory";
                reg = <0x00000000 0x8000000>;
        };
@@ -26,11 +26,9 @@ chosen {
 
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
-               button@18 {
-                       debounce_interval = <50>;
+               button-setup {
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <KEY_SETUP>;
                        label = "factory reset";
@@ -41,14 +39,14 @@ button@18 {
 
        leds {
                compatible = "gpio-leds";
-               led@20 {
+               led-green-info {
                        label = "sq201:green:info";
                        /* Conflict with parallel flash */
                        gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>;
                        default-state = "on";
                        linux,default-trigger = "heartbeat";
                };
-               led@31 {
+               led-green-usb {
                        label = "sq201:green:usb";
                        /* Conflict with parallel and NAND flash */
                        gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>;
index b4ec9ad85d722477df9e5d25b2930930f6d3155c..29af86cd10f7d76f0267784191a1ddd521c8b0f2 100644 (file)
@@ -14,7 +14,8 @@ / {
        #address-cells = <1>;
        #size-cells = <1>;
 
-       memory { /* 128 MB */
+       memory@0 {
+               /* 128 MB */
                device_type = "memory";
                reg = <0x00000000 0x8000000>;
        };
@@ -26,11 +27,9 @@ chosen {
 
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
-               button@5 {
-                       debounce_interval = <50>;
+               button-setup {
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <KEY_SETUP>;
                        label = "reset";
@@ -42,25 +41,25 @@ button@5 {
        leds {
                compatible = "gpio-leds";
 
-               led@1 {
+               led-red-l3 {
                        label = "wbd111:red:L3";
                        /* Conflict with TVC and extended parallel flash */
                        gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
                };
-               led@2 {
+               led-green-l4 {
                        label = "wbd111:green:L4";
                        /* Conflict with TVC and extended parallel flash */
                        gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
                };
-               led@3 {
+               led-red-l4 {
                        label = "wbd111:red:L4";
                        /* Conflict with TVC and extended parallel flash */
                        gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
                };
-               led@5 {
+               led-greeb-l3 {
                        label = "wbd111:green:L3";
                        /* Conflict with TVC and extended parallel flash */
                        gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>;
index 6d25bcc046e7494b25f76770b44ce9410cf895a5..24e6ae3616f7165fbb12f309f529fb6ddb091825 100644 (file)
@@ -14,7 +14,7 @@ / {
        #address-cells = <1>;
        #size-cells = <1>;
 
-       memory { /* 128 MB */
+       memory@0 { /* 128 MB */
                device_type = "memory";
                reg = <0x00000000 0x8000000>;
        };
@@ -26,11 +26,9 @@ chosen {
 
        gpio_keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
-               button@5 {
-                       debounce_interval = <50>;
+               button-setup {
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <KEY_SETUP>;
                        label = "reset";
@@ -42,25 +40,25 @@ button@5 {
        leds {
                compatible = "gpio-leds";
 
-               led@1 {
+               led-red-l3 {
                        label = "wbd111:red:L3";
                        /* Conflict with TVC and extended parallel flash */
                        gpios = <&gpio0 1 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
                };
-               led@2 {
+               led-green-l4 {
                        label = "wbd111:green:L4";
                        /* Conflict with TVC and extended parallel flash */
                        gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
                };
-               led@3 {
+               led-red-l4 {
                        label = "wbd111:red:L4";
                        /* Conflict with TVC and extended parallel flash */
                        gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>;
                        default-state = "off";
                };
-               led@5 {
+               led-green-l3 {
                        label = "wbd111:green:L3";
                        /* Conflict with TVC and extended parallel flash */
                        gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>;
index 0568baca500af174a18f8fc2b000a4eb1f2ef981..eb752e9495de10f8a99339d257f4680ebacf4793 100644 (file)
@@ -3,8 +3,6 @@
  * Device Tree file for Cortina systems Gemini SoC
  */
 
-/include/ "skeleton.dtsi"
-
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/clock/cortina,gemini-clock.h>
 #include <dt-bindings/reset/cortina,gemini-reset.h>
index 6354e4c87313d420fba5e01d55cb69400770b768..a1d81badb5c8ad5b801915be447ee095c90d8ca7 100644 (file)
@@ -23,17 +23,6 @@ chosen {
        memory@8000000 {
                reg = <0x08000000 0x04000000>;
        };
-
-       clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               clk32 {
-                       compatible = "fsl,imx-clk32", "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <32000>;
-               };
-       };
 };
 
 &cspi1 {
index f7b9edf93f5ef3b558b3b1c6a66a813e353eac38..3edc7b5550d88d67d21132231dba61d9bcdc1fcc 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru>
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright (C) 2014 Alexander Shiyan <shc_work@mail.ru>
 
 #include "imx1-pinfunc.h"
 
@@ -62,6 +55,14 @@ cpu@0 {
                };
        };
 
+       clocks {
+               clk32 {
+                       compatible = "fsl,imx-clk32", "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <32000>;
+               };
+       };
+
        soc {
                #address-cells = <1>;
                #size-cells = <1>;
index 9d92ece825606753b8304ae2dee084e563fa023a..9fb47724b9c1fa2dee8a6f1695fba9a68d30e80f 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 #include "imx23.dtsi"
index cb0a3fe3271879f750dd9bd24fc3f21ea39789bd..71bfd2b15609ae5a1b48b9b309b421f88abbd058 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Freescale Semiconductor, Inc.
 
 #include "imx23-pinfunc.h"
 
index 7f9bd052b84ef1c222441b6a59032822eb21e2e9..a5626b46ac4e11baf20eaf3d02bd3f1b32c78486 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright 2013 Freescale Semiconductor, Inc.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2013 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 #include <dt-bindings/gpio/gpio.h>
@@ -291,7 +284,6 @@ MATRIX_KEY(0x3, 0x2, KEY_POWER)
 };
 
 &ssi1 {
-       codec-handle = <&codec>;
        status = "okay";
 };
 
index cf70df20b19ce601381ba78f3bdce81d3e881975..85c15ee63272775f2b0025ef2175f64e2b4c36d3 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright 2012 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de>
 
 #include <dt-bindings/gpio/gpio.h>
 #include "imx25-pinfunc.h"
@@ -70,9 +63,6 @@ asic: asic-interrupt-controller@68000000 {
        };
 
        clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                osc {
                        compatible = "fsl,imx-osc", "fixed-clock";
                        #clock-cells = <0>;
index 66941cdbf2444b17bdffe4a88d307468b35d7d0e..3eddd805a793a3614c9f4fdd14483c93c9081a76 100644 (file)
@@ -22,17 +22,10 @@ / {
        memory@a0000000 {
                reg = <0xa0000000 0x04000000>;
        };
+};
 
-       clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               osc26m {
-                       compatible = "fsl,imx-osc26m", "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <0>;
-               };
-       };
+&clk_osc26m {
+       clock-frequency = <0>;
 };
 
 &iomuxc {
index 924b90c9985d50d22b39853689095ebd0ad1175c..f9a882d99132918b5f0bc364eec2f093d717c678 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright 2012 Sascha Hauer, Pengutronix
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Sascha Hauer, Pengutronix
 
 /dts-v1/;
 #include "imx27.dtsi"
index 6585b00c3917a10d94c6abf45e45e059c84626ad..753d88df1627405953c75116599c7235bd39095b 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright 2012 Sascha Hauer, Pengutronix
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Sascha Hauer, Pengutronix
 
 #include "imx27-pinfunc.h"
 
@@ -57,10 +50,7 @@ aitc: aitc-interrupt-controller@e0000000 {
        };
 
        clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               osc26m {
+               clk_osc26m: osc26m {
                        compatible = "fsl,imx-osc26m", "fixed-clock";
                        #clock-cells = <0>;
                        clock-frequency = <26000000>;
index 60e5c7fd50351f66444ab34914d101d1633a8fed..f1c8315b3e01652ab2894bb7167ba6221c6fd63c 100644 (file)
@@ -398,8 +398,6 @@ gpio_keys {
                compatible = "gpio-keys";
                pinctrl-names = "default";
                pinctrl-0 = <&rotary_btn_pins_cfa10049>;
-               #address-cells = <1>;
-               #size-cells = <0>;
 
                rotary_button {
                        label = "rotary_button";
index 7f8d40a9c67ebe151bb8c3f3c6a505ff2c4733c0..22215337f72a47af306d7b26fb6e021224c04084 100644 (file)
@@ -206,8 +206,6 @@ enocean-green {
 
        gpio-keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
                pinctrl-names = "default";
                pinctrl-0 = <&enocean_button>;
 
index b0d39654aeb3277d4b0d8ba6a5b7dc27ffe29c2e..6b0ae667640f1c29c61390fccc9f3c3844e4d6e2 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 #include "imx28.dtsi"
index 687186358c18f88707eb75a7504e9acc9b486550..b8f46432e2a21150e1ce2fd4c327e4ac414ed31c 100644 (file)
@@ -140,15 +140,10 @@ reg_lcd_reset: regulator-lcd-reset {
                regulator-boot-on;
        };
 
-       clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-               mclk: clock@0 {
-                       compatible = "fixed-clock";
-                       reg = <0>;
-                       #clock-cells = <0>;
-                       clock-frequency = <26000000>;
-               };
+       mclk: clock-mclk {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <26000000>;
        };
 
        sound {
@@ -345,6 +340,7 @@ polytouch: edt-ft5x06@38 {
                interrupts = <5 IRQ_TYPE_EDGE_FALLING>;
                reset-gpios = <&gpio2 6 GPIO_ACTIVE_LOW>;
                wake-gpios = <&gpio4 9 GPIO_ACTIVE_HIGH>;
+               wakeup-source;
        };
 
        touchscreen: tsc2007@48 {
index 9ad8d3556859ceb0c7bc516fc11ac6e671d2f151..5107fdc482ea000d84fc7b15add34bd22be97d2d 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Freescale Semiconductor, Inc.
 
 #include <dt-bindings/gpio/gpio.h>
 #include "imx28-pinfunc.h"
index ebc3f2dbb6fd005482ab36fb1a8504a4d39de09f..4642c8169a65ba490a68e466b1e6e8a046719a58 100644 (file)
@@ -1,13 +1,6 @@
-/*
- * Copyright 2012 Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Denis 'GNUtoo' Carikli <GNUtoo@no-log.org>
 
 / {
        #address-cells = <1>;
index 646b1257bba262f603e6562a4386cecc90d38b95..df613e88fd2c19622aee24020d215c4add0341e5 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2013 Eukréa Electromatique <denis@eukrea.com>
- * Copyright 2014 Freescale Semiconductor, Inc.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2013 Eukréa Electromatique <denis@eukrea.com>
+// Copyright 2014 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 #include "imx35.dtsi"
index 54111ed218b10ff964a721f325b7dc1cc4e98539..1c50b785cad473afc0d4ef28c266664ac8a63ba9 100644 (file)
@@ -1,12 +1,8 @@
-/*
- * Copyright 2012 Steffen Trumtrar, Pengutronix
- *
- * based on imx27.dtsi
- *
- * 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.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright 2012 Steffen Trumtrar, Pengutronix
+//
+// based on imx27.dtsi
 
 #include "imx35-pinfunc.h"
 
index 23f1833e23fab70170961de270e338ba1bb7f09b..f0622ec4ba9c34ae636bac7fbc765a38babc240a 100644 (file)
@@ -1,15 +1,8 @@
-/*
- * Copyright 2013 Greg Ungerer <gerg@uclinux.org>
- * Copyright 2011 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2013 Greg Ungerer <gerg@uclinux.org>
+// Copyright 2011 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 /dts-v1/;
 #include "imx50.dtsi"
index 7954e79d0a169922cb8e64e21de80ef1820eda89..a9b712db9f6c3131158661f684ad26ae9e23efdf 100644 (file)
@@ -60,9 +60,6 @@ tzic: tz-interrupt-controller@fffc000 {
        };
 
        clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                ckil {
                        compatible = "fsl,imx-ckil", "fixed-clock";
                        #clock-cells = <0>;
index cf7a1963df2539f62b53826e20343a0265ec5862..b8ca73d3d379270a6621fa1ae2cf6f353cd8930d 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2011 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 /dts-v1/;
 #include "imx51.dtsi"
index 6464f2560e066b559fd51aa5c806f80f57dd1493..df9eca94d812290afe03affd59f76663ea1ab0ee 100644 (file)
@@ -207,8 +207,6 @@ mdio_gpio: mdio-gpio {
 
                switch@0 {
                        compatible = "marvell,mv88e6085";
-                       #address-cells = <1>;
-                       #size-cells = <0>;
                        reg = <0>;
                        dsa,member = <0 0>;
 
@@ -462,7 +460,10 @@ &esdhc1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_esdhc1>;
        bus-width = <4>;
+       no-1-8-v;
        non-removable;
+       no-sdio;
+       no-sd;
        status = "okay";
 };
 
@@ -591,6 +592,7 @@ &usbh1 {
        phy_type = "ulpi";
        fsl,usbphy = <&usbh1phy>;
        disable-over-current;
+       maximum-speed = "full-speed";
        vbus-supply = <&reg_5p0v_main>;
        status = "okay";
 };
index 5d390a64e976dae95d485e7df2688f0bd876c4dc..fe01b890c715d19c7af3cd5ade82667fb3f72549 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2011 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 #include "imx51-pinfunc.h"
 #include <dt-bindings/clock/imx5-clock.h>
@@ -56,9 +49,6 @@ tzic: tz-interrupt-controller@e0000000 {
        };
 
        clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                ckil {
                        compatible = "fsl,imx-ckil", "fixed-clock";
                        #clock-cells = <0>;
index 80fc00705d92b64dca062210c9236cf786646f9b..117bd002dd1d11bb942ec811ed9dbad4339dd5fa 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 /dts-v1/;
+#include <dt-bindings/input/input.h>
 #include "imx53.dtsi"
 
 / {
@@ -68,34 +69,34 @@ gpio-keys {
                home {
                        label = "Home";
                        gpios = <&gpio5 10 0>;
-                       linux,code = <102>; /* KEY_HOME */
+                       linux,code = <KEY_HOME>;
                        wakeup-source;
                };
 
                back {
                        label = "Back";
                        gpios = <&gpio5 11 0>;
-                       linux,code = <158>; /* KEY_BACK */
+                       linux,code = <KEY_BACK>;
                        wakeup-source;
                };
 
                program {
                        label = "Program";
                        gpios = <&gpio5 12 0>;
-                       linux,code = <362>; /* KEY_PROGRAM */
+                       linux,code = <KEY_PROGRAM >;
                        wakeup-source;
                };
 
                volume-up {
                        label = "Volume Up";
                        gpios = <&gpio5 13 0>;
-                       linux,code = <115>; /* KEY_VOLUMEUP */
+                       linux,code = <KEY_VOLUMEUP>;
                };
 
                volume-down {
                        label = "Volume Down";
                        gpios = <&gpio4 0 0>;
-                       linux,code = <114>; /* KEY_VOLUMEDOWN */
+                       linux,code = <KEY_VOLUMEDOWN>;
                };
        };
 };
index 3da6dd5edb79cad24ff5be7d1af28883bc52a1ab..ce45f08e30514b4a61f1c336b0964071bc40aaa6 100644 (file)
@@ -53,8 +53,6 @@ &i2c2 {
 
        stmpe610@41 {
                compatible = "st,stmpe610";
-               #address-cells = <1>;
-               #size-cells = <0>;
                reg = <0x41>;
                id = <0>;
                blocks = <0x5>;
index d5628af2e301edfdb0036860e702dc1f5b91aa16..3aa6f693fa9fb51a02c2c1300849f979bf2b56c3 100644 (file)
@@ -180,8 +180,6 @@ gpio-restart {
 
        power-gpio-keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
                power-button {
                        label = "Power button";
@@ -192,8 +190,6 @@ power-button {
 
        touch-lock-key {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
                touch-lock-button {
                        label = "Touch lock button";
@@ -300,7 +296,7 @@ da9053@0 {
                compatible = "dlg,da9053-aa";
                reg = <0>;
                interrupt-parent = <&gpio3>;
-               interrupts = <12 0x8>;
+               interrupts = <12 IRQ_TYPE_LEVEL_LOW>;
                spi-max-frequency = <1000000>;
                dlg,tsi-as-adc;
                tsiref-supply = <&reg_tsiref>;
@@ -473,7 +469,7 @@ mma8453q: accelerometer@1c {
                                compatible = "fsl,mma8453";
                                reg = <0x1c>;
                                interrupt-parent = <&gpio1>;
-                               interrupts = <6 0>;
+                               interrupts = <6 IRQ_TYPE_NONE>;
                                interrupt-names = "INT1";
                        };
 
@@ -539,7 +535,7 @@ touchscreen@4b {
                reset-gpio = <&gpio5 19 GPIO_ACTIVE_HIGH>;
                reg = <0x4b>;
                interrupt-parent = <&gpio5>;
-               interrupts = <4 0x8>;
+               interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
        };
 };
 
@@ -559,8 +555,6 @@ lvds0: lvds-channel@0 {
                status = "okay";
 
                port@2 {
-                       reg = <2>;
-
                        lvds0_out: endpoint {
                                remote-endpoint = <&panel_in_lvds0>;
                        };
index 485a69d45e1c90bf6007524f29a7afe15e52bc70..ef7658a788364dfff3d3f2a36cf3f0c4582218ef 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2011 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 #include "imx53.dtsi"
 
index d3d662e376772182e13f24df1152bca84e14df0e..6831836bd726cb759d47821d104595e00c3bfb46 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2011 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 /dts-v1/;
 #include "imx53-qsb-common.dtsi"
@@ -23,7 +16,7 @@ pmic: dialog@48 {
                compatible = "dlg,da9053-aa", "dlg,da9052";
                reg = <0x48>;
                interrupt-parent = <&gpio7>;
-               interrupts = <11 0x8>; /* low-level active IRQ at GPIO7_11 */
+               interrupts = <11 IRQ_TYPE_LEVEL_LOW>; /* low-level active IRQ at GPIO7_11 */
 
                regulators {
                        buck1_reg: buck1 {
index 4e103a905dc9c9adb112caba85f2b7cff8f8ef1d..1bbf24ad308a18bc8216c198afbed9fd7e85fdf4 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2011 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 /dts-v1/;
 
index fd030128666c7ab602d305e608b205f0b678008a..462071c9ddd7399a1234347d2f5db8b69e8a1292 100644 (file)
@@ -1,16 +1,10 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2011 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 /dts-v1/;
+#include <dt-bindings/input/input.h>
 #include "imx53.dtsi"
 
 / {
@@ -27,13 +21,13 @@ gpio-keys {
                volume-up {
                        label = "Volume Up";
                        gpios = <&gpio2 14 0>;
-                       linux,code = <115>; /* KEY_VOLUMEUP */
+                       linux,code = <KEY_VOLUMEUP>;
                };
 
                volume-down {
                        label = "Volume Down";
                        gpios = <&gpio2 15 0>;
-                       linux,code = <114>; /* KEY_VOLUMEDOWN */
+                       linux,code = <KEY_VOLUMEDOWN>;
                };
        };
 };
index af8ec5e4417b69431de9fd436c0cd078274b6a5c..a7f77527269d547c479730e45782ecb63c365822 100644 (file)
@@ -245,6 +245,7 @@ polytouch: edt-ft5x06@38 {
                interrupts = <15 IRQ_TYPE_EDGE_FALLING>;
                reset-gpios = <&gpio2 22 GPIO_ACTIVE_LOW>;
                wake-gpios = <&gpio2 21 GPIO_ACTIVE_HIGH>;
+               wakeup-source;
        };
 
        touchscreen: tsc2007@48 {
index 69a2af7d6c115b1596ac1690d0397e9a6fe09509..54cf3e67069a9c7771d24b93e47a9368f6a6053f 100644 (file)
@@ -58,7 +58,7 @@ aliases {
                can0 = &can2; /* Make the can interface indices consistent with TX28/TX48 modules */
                can1 = &can1;
                ipu = &ipu;
-               reg_can_xcvr = &reg_can_xcvr;
+               reg-can-xcvr = &reg_can_xcvr;
                usbh1 = &usbh1;
                usbotg = &usbotg;
        };
@@ -67,13 +67,12 @@ clocks {
                ckih1 {
                        clock-frequency = <0>;
                };
+       };
 
-               mclk: clock@0 {
-                       compatible = "fixed-clock";
-                       reg = <0>;
-                       #clock-cells = <0>;
-                       clock-frequency = <26000000>;
-               };
+       mclk: clock-mclk {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <26000000>;
        };
 
        gpio-keys {
@@ -550,7 +549,6 @@ &sdma {
 };
 
 &ssi1 {
-       codec-handle = <&sgtl5000>;
        status = "okay";
 };
 
index df8dafe2564dd99badafe331cef704dcb6e1c096..f83a8c62ea531d144d2f7a51d5d02503714a42f1 100644 (file)
@@ -150,7 +150,7 @@ pmic: dialog@48 {
                compatible = "dlg,da9053-aa", "dlg,da9052";
                reg = <0x48>;
                interrupt-parent = <&gpio7>;
-               interrupts = <11 0x8>; /* low-level active IRQ at GPIO7_11 */
+               interrupts = <11 IRQ_TYPE_LEVEL_LOW>; /* low-level active IRQ at GPIO7_11 */
 
                regulators {
                        buck1_reg: buck1 {
index 3d65c0192f6931f6f5997e2de8e5cb1c2f2a8b6e..1a7a7bb3df45f3d7854e41b5a654688fe9159fcc 100644 (file)
@@ -88,9 +88,6 @@ tzic: tz-interrupt-controller@fffc000 {
        };
 
        clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                ckil {
                        compatible = "fsl,imx-ckil", "fixed-clock";
                        #clock-cells = <0>;
@@ -488,6 +485,10 @@ lvds0_in: endpoint {
                                                        remote-endpoint = <&ipu_di0_lvds0>;
                                                };
                                        };
+
+                                       port@2 {
+                                               reg = <2>;
+                                       };
                                };
 
                                lvds-channel@1 {
@@ -503,6 +504,10 @@ lvds1_in: endpoint {
                                                        remote-endpoint = <&ipu_di1_lvds1>;
                                                };
                                        };
+
+                                       port@2 {
+                                               reg = <2>;
+                                       };
                                };
                        };
 
index 7128c76d5721dafe1c4597cd82109678a3cf4fd2..29940ba215a88e24a7677de4762b319947cd7e14 100644 (file)
@@ -78,8 +78,6 @@ display_out: endpoint {
 
 &ecspi1 {
        lcd_panel: display@0 {
-               #address-cells = <1>;
-               #size-cells = <1>;
                compatible = "lg,lg4573";
                spi-max-frequency = <10000000>;
                reg = <0>;
index ea184d1084911effb417086b2b903170552186d6..3dee3af1a4c1628fdad7613fdb75b3a38d427b16 100644 (file)
@@ -72,15 +72,12 @@ chosen {
                stdout-path = "serial0:115200n8";
        };
 
-       clocks {
-               /* Fixed crystal dedicated to mcp251x */
-               clk16m: clk@1 {
-                       compatible = "fixed-clock";
-                       reg = <1>;
-                       #clock-cells = <0>;
-                       clock-frequency = <16000000>;
-                       clock-output-names = "clk16m";
-               };
+       /* Fixed crystal dedicated to mcp251x */
+       clk16m: clock-16m {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <16000000>;
+               clock-output-names = "clk16m";
        };
 
        gpio-keys {
diff --git a/arch/arm/boot/dts/imx6dl-mamoj.dts b/arch/arm/boot/dts/imx6dl-mamoj.dts
new file mode 100644 (file)
index 0000000..6b2d291
--- /dev/null
@@ -0,0 +1,224 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 BTicino
+ * Copyright (C) 2018 Amarula Solutions B.V.
+ */
+
+/dts-v1/;
+
+#include "imx6dl.dtsi"
+
+/ {
+       model = "BTicino i.MX6DL Mamoj board";
+       compatible = "bticino,imx6dl-mamoj", "fsl,imx6dl";
+};
+
+&fec {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_enet>;
+       phy-mode = "mii";
+       status = "okay";
+};
+
+&i2c3 {
+       clock-frequency = <400000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c3>;
+       status = "okay";
+};
+
+&i2c4 {
+       clock-frequency = <100000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c4>;
+       status = "okay";
+
+       pfuze100: pmic@8 {
+               compatible = "fsl,pfuze100";
+               reg = <0x08>;
+
+               regulators {
+                       /* CPU vdd_arm core */
+                       sw1a_reg: sw1ab {
+                               regulator-min-microvolt = <300000>;
+                               regulator-max-microvolt = <1875000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                               regulator-ramp-delay = <6250>;
+                       };
+
+                       /* SOC vdd_soc */
+                       sw1c_reg: sw1c {
+                               regulator-min-microvolt = <300000>;
+                               regulator-max-microvolt = <1875000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                               regulator-ramp-delay = <6250>;
+                       };
+
+                       /* I/O power GEN_3V3 */
+                       sw2_reg: sw2 {
+                               regulator-min-microvolt = <800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       /* DDR memory */
+                       sw3a_reg: sw3a {
+                               regulator-min-microvolt = <400000>;
+                               regulator-max-microvolt = <1975000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       /* DDR memory */
+                       sw3b_reg: sw3b {
+                               regulator-min-microvolt = <400000>;
+                               regulator-max-microvolt = <1975000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       /* not used */
+                       sw4_reg: sw4 {
+                               regulator-min-microvolt = <800000>;
+                               regulator-max-microvolt = <3300000>;
+                       };
+
+                       /* not used */
+                       swbst_reg: swbst {
+                               regulator-min-microvolt = <5000000>;
+                               regulator-max-microvolt = <5150000>;
+                       };
+
+                       /* PMIC vsnvs. EX boot mode */
+                       snvs_reg: vsnvs {
+                               regulator-min-microvolt = <1000000>;
+                               regulator-max-microvolt = <3000000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       vref_reg: vrefddr {
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       /* not used */
+                       vgen1_reg: vgen1 {
+                               regulator-min-microvolt = <800000>;
+                               regulator-max-microvolt = <1550000>;
+                       };
+
+                       /* not used */
+                       vgen2_reg: vgen2 {
+                               regulator-min-microvolt = <800000>;
+                               regulator-max-microvolt = <1550000>;
+                       };
+
+                       /* not used */
+                       vgen3_reg: vgen3 {
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <3300000>;
+                       };
+
+                       /* 1v8 general power */
+                       vgen4_reg: vgen4 {
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+
+                       /* 2v8 general power IMX6 */
+                       vgen5_reg: vgen5 {
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+
+                       /* 3v3 Ethernet */
+                       vgen6_reg: vgen6 {
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+               };
+       };
+};
+
+&uart3 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_uart3>;
+       status = "okay";
+};
+
+&usdhc3 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usdhc3>;
+       bus-width = <8>;
+       non-removable;
+       keep-power-in-suspend;
+       status = "okay";
+};
+
+&iomuxc {
+       pinctrl_enet: enetgrp {
+               fsl,pins = <
+                       MX6QDL_PAD_ENET_MDIO__ENET_MDIO         0x1b0b0
+                       MX6QDL_PAD_ENET_MDC__ENET_MDC           0x1b0b0
+                       MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK    0x1b0b1
+                       MX6QDL_PAD_ENET_TXD0__ENET_TX_DATA0     0x1b0b0
+                       MX6QDL_PAD_ENET_TXD1__ENET_TX_DATA1     0x1b0b0
+                       MX6QDL_PAD_KEY_ROW2__ENET_TX_DATA2      0x1b0b0
+                       MX6QDL_PAD_KEY_ROW0__ENET_TX_DATA3      0x1b0b0
+                       MX6QDL_PAD_ENET_TX_EN__ENET_TX_EN       0x1b0b0
+                       MX6QDL_PAD_GPIO_19__ENET_TX_ER          0x1b0b0
+                       MX6QDL_PAD_GPIO_18__ENET_RX_CLK         0x1b0b1
+                       MX6QDL_PAD_ENET_RXD0__ENET_RX_DATA0     0x1b0b0
+                       MX6QDL_PAD_ENET_RXD1__ENET_RX_DATA1     0x1b0b0
+                       MX6QDL_PAD_KEY_COL2__ENET_RX_DATA2      0x1b0b0
+                       MX6QDL_PAD_KEY_COL0__ENET_RX_DATA3      0x1b0b0
+                       MX6QDL_PAD_ENET_CRS_DV__ENET_RX_EN      0x1b0b0
+                       MX6QDL_PAD_ENET_RX_ER__ENET_RX_ER       0x1b0b0
+                       MX6QDL_PAD_KEY_COL3__ENET_CRS           0x1b0b0
+                       MX6QDL_PAD_KEY_ROW1__ENET_COL           0x1b0b0
+               >;
+       };
+
+       pinctrl_i2c3: i2c3grp {
+               fsl,pins = <
+                       MX6QDL_PAD_GPIO_3__I2C3_SCL     0x4001b8b1
+                       MX6QDL_PAD_GPIO_6__I2C3_SDA     0x4001b8b1
+               >;
+       };
+
+       pinctrl_i2c4: i2c4grp {
+               fsl,pins = <
+                       MX6QDL_PAD_GPIO_7__I2C4_SCL     0x4001b8b1
+                       MX6QDL_PAD_GPIO_8__I2C4_SDA     0x4001b8b1
+               >;
+       };
+
+       pinctrl_uart3: uart3grp {
+               fsl,pins = <
+                       MX6QDL_PAD_EIM_D24__UART3_TX_DATA       0x1b0b1
+                       MX6QDL_PAD_EIM_D25__UART3_RX_DATA       0x1b0b1
+               >;
+       };
+
+       pinctrl_usdhc3: usdhc3grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD3_CMD__SD3_CMD     0x17059
+                       MX6QDL_PAD_SD3_CLK__SD3_CLK     0x10059
+                       MX6QDL_PAD_SD3_DAT0__SD3_DATA0  0x17059
+                       MX6QDL_PAD_SD3_DAT1__SD3_DATA1  0x17059
+                       MX6QDL_PAD_SD3_DAT2__SD3_DATA2  0x17059
+                       MX6QDL_PAD_SD3_DAT3__SD3_DATA3  0x17059
+                       MX6QDL_PAD_SD3_DAT4__SD3_DATA4  0x17059
+                       MX6QDL_PAD_SD3_DAT5__SD3_DATA5  0x17059
+                       MX6QDL_PAD_SD3_DAT6__SD3_DATA6  0x17059
+                       MX6QDL_PAD_SD3_DAT7__SD3_DATA7  0x17059
+               >;
+       };
+};
index a6ce7b487ad72f13a688d6e741aa91cc35b2008b..660d52a245babe5a3fd0f0aafe693a77e2339db5 100644 (file)
@@ -1,10 +1,6 @@
-/*
- * Copyright (C) 2013 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (C) 2013 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 
index 9607afe088fcf9b4f7ee43612133053d3883bd04..cd6bbf22a16f084f00a6e8dc9d68169e8a9b6ea9 100644 (file)
@@ -1,10 +1,6 @@
-/*
- * Copyright (C) 2013 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (C) 2013 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 
index e3713f00e81914957e21a59b0ff23c2243858a08..d871cac1711f7ed9f974fa5e0c079f1fd565f1d5 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 /dts-v1/;
 #include "imx6dl.dtsi"
index 5727fa48cfd56b8779424058ce029ef9021e62c8..738db4fc77023c9b758787279e6d520dcffca321 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 /dts-v1/;
 #include "imx6dl.dtsi"
index a72c07db7dda50c622045f77bfa48e4a6f902aa2..51de6b4bd7d82c7cb2812fa4366f829775178daf 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 /dts-v1/;
 #include "imx6dl.dtsi"
index a09f274cd1f49accf125d445d292e0f233522abe..b43454deaa1aac8da81e5c62c5088de245e084d1 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 /dts-v1/;
 #include "imx6dl.dtsi"
index 558bce81209d2dd26cb218cee80186be6117086f..b384913c34ddaf4ed6df751b083abd35d15b454d 100644 (file)
@@ -1,12 +1,6 @@
-
-/*
- * Copyright 2013 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright 2013 Freescale Semiconductor, Inc.
 
 #include <dt-bindings/interrupt-controller/irq.h>
 #include "imx6dl-pinfunc.h"
index 35edbdc7bcd154e6cbfa4c5c9add0f2f21a6d411..044a5bebe1c5604cfdd715871ba57700d40711d9 100644 (file)
@@ -156,8 +156,6 @@ &mux2_i2c2 {
 
        stdp2690@72 {
                compatible = "megachips,stdp2690-ge-b850v3-fw";
-               #address-cells = <1>;
-               #size-cells = <0>;
                reg = <0x72>;
 
                ports {
@@ -184,8 +182,6 @@ stdp2690_out: endpoint {
 
        stdp4028@73 {
                compatible = "megachips,stdp4028-ge-b850v3-fw";
-               #address-cells = <1>;
-               #size-cells = <0>;
                reg = <0x73>;
                interrupt-parent = <&gpio2>;
                interrupts = <0 IRQ_TYPE_LEVEL_HIGH>;
index bf4bdb385de9e9e1483bcf0a1e449ac71d24b7e5..e903c488287bc57aeabfeb7375f4d1241dfdcd92 100644 (file)
@@ -157,7 +157,12 @@ partition@c0000 {
 
                partition@d0000 {
                        label = "spare";
-                       reg = <0xd0000 0x130000>;
+                       reg = <0xd0000 0x320000>;
+               };
+
+               partition@3f0000 {
+                       label = "mfg";
+                       reg = <0x3f0000 0x10000>;
                };
        };
 };
index 990e411cbca0e7210621929ebfd83960a690f5ce..d3cba09be0cb513273f3dfb28c709ee97c3ec290 100644 (file)
 #include "imx6q-ba16.dtsi"
 
 / {
-       clocks {
-               mclk: clock@0 {
-                       compatible = "fixed-clock";
-                       reg = <0>;
-                       #clock-cells = <0>;
-                       clock-frequency = <22000000>;
-               };
+       mclk: clock-mclk {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <22000000>;
        };
 
        gpio-poweroff {
@@ -107,8 +104,6 @@ mdio0: mdio-gpio {
 
                switch@0 {
                        compatible = "marvell,mv88e6085"; /* 88e6240*/
-                       #address-cells = <1>;
-                       #size-cells = <0>;
                        reg = <0>;
 
                        switch_ports: ports {
diff --git a/arch/arm/boot/dts/imx6q-dhcom-pdk2.dts b/arch/arm/boot/dts/imx6q-dhcom-pdk2.dts
new file mode 100644 (file)
index 0000000..9c61e3b
--- /dev/null
@@ -0,0 +1,151 @@
+// SPDX-License-Identifier: (GPL-2.0+)
+/*
+ * Copyright (C) 2015 DH electronics GmbH
+ * Copyright (C) 2018 Marek Vasut <marex@denx.de>
+ */
+
+/dts-v1/;
+
+#include "imx6q-dhcom-som.dtsi"
+
+/ {
+       model = "Freescale i.MX6 Quad DHCOM Premium Developer Kit (2)";
+       compatible = "dh,imx6q-dhcom-pdk2", "dh,imx6q-dhcom-som", "fsl,imx6q";
+
+       chosen {
+               stdout-path = &uart1;
+       };
+
+       clk_ext_audio_codec: clock-codec {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <24000000>;
+       };
+
+       sound {
+               compatible = "fsl,imx-audio-sgtl5000";
+               model = "imx-sgtl5000";
+               ssi-controller = <&ssi1>;
+               audio-codec = <&sgtl5000>;
+               audio-routing =
+                       "MIC_IN", "Mic Jack",
+                       "Mic Jack", "Mic Bias",
+                       "LINE_IN", "Line In Jack",
+                       "Headphone Jack", "HP_OUT";
+               mux-int-port = <1>;
+               mux-ext-port = <3>;
+       };
+};
+
+&audmux {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_audmux_ext>;
+       status = "okay";
+};
+
+&hdmi {
+       ddc-i2c-bus = <&i2c2>;
+       status = "okay";
+};
+
+&i2c2 {
+       sgtl5000: codec@a {
+               compatible = "fsl,sgtl5000";
+               reg = <0x0a>;
+               #sound-dai-cells = <0>;
+               clocks = <&clk_ext_audio_codec>;
+               VDDA-supply = <&reg_3p3v>;
+               VDDIO-supply = <&reg_3p3v>;
+       };
+};
+
+&iomuxc {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_hog_base &pinctrl_hog>;
+
+       pinctrl_hog: hog-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_GPIO_2__GPIO1_IO02           0x400120b0
+                       MX6QDL_PAD_GPIO_4__GPIO1_IO04           0x400120b0
+                       MX6QDL_PAD_GPIO_5__GPIO1_IO05           0x400120b0
+                       MX6QDL_PAD_CSI0_DAT17__GPIO6_IO03       0x400120b0
+                       MX6QDL_PAD_GPIO_19__GPIO4_IO05          0x120b0
+                       MX6QDL_PAD_DI0_PIN4__GPIO4_IO20         0x400120b0
+                       MX6QDL_PAD_EIM_D27__GPIO3_IO27          0x120b0
+                       MX6QDL_PAD_KEY_ROW0__GPIO4_IO07         0x120b0
+                       MX6QDL_PAD_KEY_COL1__GPIO4_IO08         0x400120b0
+                       MX6QDL_PAD_NANDF_CS1__GPIO6_IO14        0x400120b0
+                       MX6QDL_PAD_NANDF_CS2__GPIO6_IO15        0x400120b0
+                       MX6QDL_PAD_KEY_ROW1__GPIO4_IO09         0x400120b0
+                       MX6QDL_PAD_SD3_DAT5__GPIO7_IO00         0x400120b0
+                       MX6QDL_PAD_SD3_DAT4__GPIO7_IO01         0x400120b0
+                       MX6QDL_PAD_CSI0_VSYNC__GPIO5_IO21       0x400120b0
+                       MX6QDL_PAD_GPIO_18__GPIO7_IO13          0x400120b0
+                       MX6QDL_PAD_SD1_CMD__GPIO1_IO18          0x400120b0
+                       MX6QDL_PAD_SD1_DAT0__GPIO1_IO16         0x400120b0
+                       MX6QDL_PAD_SD1_DAT1__GPIO1_IO17         0x400120b0
+                       MX6QDL_PAD_SD1_DAT2__GPIO1_IO19         0x400120b0
+                       MX6QDL_PAD_SD1_CLK__GPIO1_IO20          0x400120b0
+                       MX6QDL_PAD_CSI0_PIXCLK__GPIO5_IO18      0x400120b0
+                       MX6QDL_PAD_CSI0_MCLK__GPIO5_IO19        0x400120b0
+                       MX6QDL_PAD_KEY_COL0__GPIO4_IO06         0x400120b0
+               >;
+       };
+
+       pinctrl_audmux_ext: audmux-ext-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_CSI0_DAT7__AUD3_RXD          0x130b0
+                       MX6QDL_PAD_CSI0_DAT4__AUD3_TXC          0x130b0
+                       MX6QDL_PAD_CSI0_DAT5__AUD3_TXD          0x110b0
+                       MX6QDL_PAD_CSI0_DAT6__AUD3_TXFS         0x130b0
+               >;
+       };
+
+       pinctrl_enet_1G: enet-1G-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_ENET_MDIO__ENET_MDIO         0x100b0
+                       MX6QDL_PAD_ENET_MDC__ENET_MDC           0x100b0
+                       MX6QDL_PAD_RGMII_TXC__RGMII_TXC         0x100b0
+                       MX6QDL_PAD_RGMII_TD0__RGMII_TD0         0x100b0
+                       MX6QDL_PAD_RGMII_TD1__RGMII_TD1         0x100b0
+                       MX6QDL_PAD_RGMII_TD2__RGMII_TD2         0x100b0
+                       MX6QDL_PAD_RGMII_TD3__RGMII_TD3         0x100b0
+                       MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL   0x100b0
+                       MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK    0x100b0
+                       MX6QDL_PAD_RGMII_RXC__RGMII_RXC         0x1b0b0
+                       MX6QDL_PAD_RGMII_RD0__RGMII_RD0         0x1b0b0
+                       MX6QDL_PAD_RGMII_RD1__RGMII_RD1         0x1b0b0
+                       MX6QDL_PAD_RGMII_RD2__RGMII_RD2         0x1b0b0
+                       MX6QDL_PAD_RGMII_RD3__RGMII_RD3         0x1b0b0
+                       MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL   0x1b0b0
+                       MX6QDL_PAD_EIM_D29__GPIO3_IO29          0x000b0
+                       MX6QDL_PAD_GPIO_0__GPIO1_IO00           0x000b1
+                       MX6QDL_PAD_EIM_D26__GPIO3_IO26          0x000b1
+               >;
+       };
+
+       pinctrl_pcie: pcie-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_CSI0_DATA_EN__GPIO5_IO20     0x1b0b1
+               >;
+       };
+};
+
+&pcie {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_pcie>;
+       reset-gpio = <&gpio6 14 GPIO_ACTIVE_LOW>;
+       status = "okay";
+};
+
+&ssi1 {
+       status = "okay";
+};
+
+&sata {
+       status = "okay";
+};
+
+&usdhc3 {
+       status = "okay";
+};
diff --git a/arch/arm/boot/dts/imx6q-dhcom-som.dtsi b/arch/arm/boot/dts/imx6q-dhcom-som.dtsi
new file mode 100644 (file)
index 0000000..bbba067
--- /dev/null
@@ -0,0 +1,476 @@
+// SPDX-License-Identifier: (GPL-2.0+)
+/*
+ * Copyright (C) 2015 DH electronics GmbH
+ * Copyright (C) 2018 Marek Vasut <marex@denx.de>
+ */
+
+#include "imx6q.dtsi"
+#include <dt-bindings/pwm/pwm.h>
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/clock/imx6qdl-clock.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       aliases {
+               mmc0 = &usdhc2;
+               mmc1 = &usdhc3;
+               mmc2 = &usdhc4;
+               mmc3 = &usdhc1;
+       };
+
+       memory@10000000 {
+               reg = <0x10000000 0x40000000>;
+       };
+
+       reg_usb_otg_vbus: regulator-usb-otg-vbus {
+               compatible = "regulator-fixed";
+               regulator-name = "usb_otg_vbus";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+       };
+
+       reg_usb_h1_vbus: regulator-usb-h1-vbus {
+               compatible = "regulator-fixed";
+               regulator-name = "usb_h1_vbus";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               gpio = <&gpio3 31 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+
+       reg_3p3v: regulator-3P3V {
+               compatible = "regulator-fixed";
+               regulator-name = "3P3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-always-on;
+       };
+};
+
+&can1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_flexcan1>;
+       status = "okay";
+};
+
+&can2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_flexcan2>;
+       status = "okay";
+};
+
+&ecspi1 {
+       cs-gpios = <&gpio2 30 GPIO_ACTIVE_HIGH>, <&gpio4 11 GPIO_ACTIVE_HIGH>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_ecspi1>;
+       status = "okay";
+
+       flash@0 {       /* S25FL116K */
+               #address-cells = <1>;
+               #size-cells = <1>;
+               compatible = "jedec,spi-nor";
+               spi-max-frequency = <50000000>;
+               reg = <0>;
+               m25p,fast-read;
+       };
+};
+
+&ecspi2 {
+       cs-gpios = <&gpio5 29 GPIO_ACTIVE_LOW>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_ecspi2>;
+       status = "okay";
+};
+
+&fec {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_enet_100M>;
+       phy-mode = "rmii";
+       phy-handle = <&ethphy0>;
+       status = "okay";
+
+       mdio {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               ethphy0: ethernet-phy@0 {       /* SMSC LAN8710Ai */
+                       reg = <0>;
+                       max-speed = <100>;
+                       reset-gpios = <&gpio5 0 GPIO_ACTIVE_LOW>;
+                       reset-delay-us = <1000>;
+                       reset-post-delay-us = <1000>;
+               };
+       };
+};
+
+&i2c1 {
+       clock-frequency = <100000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c1>;
+       status = "okay";
+};
+
+&i2c2 {
+       clock-frequency = <100000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c2>;
+       status = "okay";
+};
+
+&i2c3 {
+       clock-frequency = <100000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c3>;
+       status = "okay";
+
+       ltc3676: pmic@3c {
+               compatible = "lltc,ltc3676";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_pmic_hw300>;
+               reg = <0x3c>;
+               interrupt-parent = <&gpio5>;
+               interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
+
+               regulators {
+                       sw1_reg: sw1 {
+                               regulator-min-microvolt = <787500>;
+                               regulator-max-microvolt = <1527272>;
+                               lltc,fb-voltage-divider = <100000 110000>;
+                               regulator-suspend-mem-microvolt = <1040000>;
+                               regulator-ramp-delay = <7000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       sw2_reg: sw2 {
+                               regulator-min-microvolt = <1885714>;
+                               regulator-max-microvolt = <3657142>;
+                               lltc,fb-voltage-divider = <100000 28000>;
+                               regulator-ramp-delay = <7000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       sw3_reg: sw3 {
+                               regulator-min-microvolt = <787500>;
+                               regulator-max-microvolt = <1527272>;
+                               lltc,fb-voltage-divider = <100000 110000>;
+                               regulator-suspend-mem-microvolt = <980000>;
+                               regulator-ramp-delay = <7000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       sw4_reg: sw4 {
+                               regulator-min-microvolt = <855571>;
+                               regulator-max-microvolt = <1659291>;
+                               lltc,fb-voltage-divider = <100000 93100>;
+                               regulator-ramp-delay = <7000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       ldo1_reg: ldo1 {
+                               regulator-min-microvolt = <3240306>;
+                               regulator-max-microvolt = <3240306>;
+                               lltc,fb-voltage-divider = <102000 29400>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       ldo2_reg: ldo2 {
+                               regulator-min-microvolt = <2484708>;
+                               regulator-max-microvolt = <2484708>;
+                               lltc,fb-voltage-divider = <100000 41200>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+               };
+       };
+
+       touchscreen@49 {        /* TSC2004 */
+               compatible = "ti,tsc2004";
+               reg = <0x49>;
+               vio-supply = <&reg_3p3v>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_tsc2004_hw300>;
+               interrupts-extended = <&gpio4 14 IRQ_TYPE_EDGE_FALLING>;
+               status = "disabled";
+       };
+
+       eeprom@50 {
+               compatible = "atmel,24c02";
+               reg = <0x50>;
+               pagesize = <16>;
+       };
+
+       rtc@56 {
+               compatible = "rv3029c2";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_rtc_hw300>;
+               reg = <0x56>;
+               interrupt-parent = <&gpio7>;
+               interrupts = <12 2>;
+       };
+};
+
+&iomuxc {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_hog_base>;
+
+       pinctrl_hog_base: hog-base-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_EIM_A19__GPIO2_IO19          0x120b0
+                       MX6QDL_PAD_EIM_A23__GPIO6_IO06          0x120b0
+                       MX6QDL_PAD_EIM_A22__GPIO2_IO16          0x120b0
+                       MX6QDL_PAD_EIM_A16__GPIO2_IO22          0x120b0
+                       MX6QDL_PAD_EIM_A17__GPIO2_IO21          0x120b0
+               >;
+       };
+
+       pinctrl_ecspi1: ecspi1-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_EIM_D17__ECSPI1_MISO         0x100b1
+                       MX6QDL_PAD_EIM_D18__ECSPI1_MOSI         0x100b1
+                       MX6QDL_PAD_EIM_D16__ECSPI1_SCLK         0x100b1
+                       MX6QDL_PAD_EIM_EB2__GPIO2_IO30          0x1b0b0
+                       MX6QDL_PAD_KEY_ROW2__GPIO4_IO11         0x1b0b0
+               >;
+       };
+
+       pinctrl_ecspi2: ecspi2-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_CSI0_DAT10__ECSPI2_MISO      0x100b1
+                       MX6QDL_PAD_CSI0_DAT9__ECSPI2_MOSI       0x100b1
+                       MX6QDL_PAD_CSI0_DAT8__ECSPI2_SCLK       0x100b1
+                       MX6QDL_PAD_CSI0_DAT11__GPIO5_IO29       0x1b0b0
+               >;
+       };
+
+       pinctrl_enet_100M: enet-100M-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_ENET_MDIO__ENET_MDIO         0x1b0b0
+                       MX6QDL_PAD_ENET_MDC__ENET_MDC           0x1b0b0
+                       MX6QDL_PAD_ENET_CRS_DV__ENET_RX_EN      0x1b0b0
+                       MX6QDL_PAD_ENET_RX_ER__ENET_RX_ER       0x1b0b0
+                       MX6QDL_PAD_ENET_RXD0__ENET_RX_DATA0     0x1b0b0
+                       MX6QDL_PAD_ENET_RXD1__ENET_RX_DATA1     0x1b0b0
+                       MX6QDL_PAD_ENET_TX_EN__ENET_TX_EN       0x1b0b0
+                       MX6QDL_PAD_ENET_TXD0__ENET_TX_DATA0     0x1b0b0
+                       MX6QDL_PAD_ENET_TXD1__ENET_TX_DATA1     0x1b0b0
+                       MX6QDL_PAD_GPIO_16__ENET_REF_CLK        0x4001b0a8
+                       MX6QDL_PAD_EIM_WAIT__GPIO5_IO00         0x000b0
+                       MX6QDL_PAD_KEY_ROW4__GPIO4_IO15         0x000b1
+                       MX6QDL_PAD_GPIO_7__GPIO1_IO07           0x120b0
+               >;
+       };
+
+       pinctrl_flexcan1: flexcan1-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_KEY_COL2__FLEXCAN1_TX        0x1b0b0
+                       MX6QDL_PAD_GPIO_8__FLEXCAN1_RX          0x1b0b0
+               >;
+       };
+
+       pinctrl_flexcan2: flexcan2-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD3_DAT0__FLEXCAN2_TX        0x1b0b0
+                       MX6QDL_PAD_SD3_DAT1__FLEXCAN2_RX        0x1b0b0
+               >;
+       };
+
+       pinctrl_i2c1: i2c1-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_EIM_D21__I2C1_SCL            0x4001b8b1
+                       MX6QDL_PAD_EIM_D28__I2C1_SDA            0x4001b8b1
+               >;
+       };
+
+       pinctrl_i2c2: i2c2-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_KEY_COL3__I2C2_SCL           0x4001b8b1
+                       MX6QDL_PAD_KEY_ROW3__I2C2_SDA           0x4001b8b1
+               >;
+       };
+
+       pinctrl_i2c3: i2c3-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_GPIO_3__I2C3_SCL             0x4001b8b1
+                       MX6QDL_PAD_GPIO_6__I2C3_SDA             0x4001b8b1
+               >;
+       };
+
+       pinctrl_pmic_hw300: pmic-hw300-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_EIM_A25__GPIO5_IO02          0x1B0B0
+               >;
+       };
+
+       pinctrl_rtc_hw300: rtc-hw300-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_GPIO_17__GPIO7_IO12          0x120B0
+               >;
+       };
+
+       pinctrl_tsc2004_hw300: tsc2004-hw300-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_KEY_COL4__GPIO4_IO14         0x120B0
+               >;
+       };
+
+       pinctrl_uart1: uart1-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD3_DAT7__UART1_TX_DATA      0x1b0b1
+                       MX6QDL_PAD_SD3_DAT6__UART1_RX_DATA      0x1b0b1
+                       MX6QDL_PAD_EIM_D20__UART1_RTS_B         0x1b0b1
+                       MX6QDL_PAD_EIM_D19__UART1_CTS_B         0x4001b0b1
+                       MX6QDL_PAD_EIM_D23__GPIO3_IO23          0x4001b0b1
+                       MX6QDL_PAD_EIM_D24__GPIO3_IO24          0x4001b0b1
+                       MX6QDL_PAD_EIM_D25__GPIO3_IO25          0x4001b0b1
+                       MX6QDL_PAD_EIM_EB3__GPIO2_IO31          0x4001b0b1
+               >;
+       };
+
+       pinctrl_uart4: uart4-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_CSI0_DAT12__UART4_TX_DATA    0x1b0b1
+                       MX6QDL_PAD_CSI0_DAT13__UART4_RX_DATA    0x1b0b1
+               >;
+       };
+
+       pinctrl_uart5: uart5-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_CSI0_DAT14__UART5_TX_DATA    0x1b0b1
+                       MX6QDL_PAD_CSI0_DAT15__UART5_RX_DATA    0x1b0b1
+                       MX6QDL_PAD_CSI0_DAT18__UART5_RTS_B      0x1b0b1
+                       MX6QDL_PAD_CSI0_DAT19__UART5_CTS_B      0x4001b0b1
+               >;
+       };
+
+       pinctrl_usbh1: usbh1-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_EIM_D31__GPIO3_IO31          0x120B0
+               >;
+       };
+
+       pinctrl_usbotg: usbotg-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_GPIO_1__USB_OTG_ID           0x17059
+               >;
+       };
+
+       pinctrl_usdhc2: usdhc2-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD2_CMD__SD2_CMD             0x17059
+                       MX6QDL_PAD_SD2_CLK__SD2_CLK             0x10059
+                       MX6QDL_PAD_SD2_DAT0__SD2_DATA0          0x17059
+                       MX6QDL_PAD_SD2_DAT1__SD2_DATA1          0x17059
+                       MX6QDL_PAD_SD2_DAT2__SD2_DATA2          0x17059
+                       MX6QDL_PAD_SD2_DAT3__SD2_DATA3          0x17059
+                       MX6QDL_PAD_NANDF_CS3__GPIO6_IO16        0x120B0
+               >;
+       };
+
+       pinctrl_usdhc3: usdhc3-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD3_CMD__SD3_CMD             0x17059
+                       MX6QDL_PAD_SD3_CLK__SD3_CLK             0x10059
+                       MX6QDL_PAD_SD3_DAT0__SD3_DATA0          0x17059
+                       MX6QDL_PAD_SD3_DAT1__SD3_DATA1          0x17059
+                       MX6QDL_PAD_SD3_DAT2__SD3_DATA2          0x17059
+                       MX6QDL_PAD_SD3_DAT3__SD3_DATA3          0x17059
+                       MX6QDL_PAD_SD3_RST__GPIO7_IO08          0x120B0
+               >;
+       };
+
+       pinctrl_usdhc4: usdhc4-grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD4_CMD__SD4_CMD             0x17059
+                       MX6QDL_PAD_SD4_CLK__SD4_CLK             0x10059
+                       MX6QDL_PAD_SD4_DAT0__SD4_DATA0          0x17059
+                       MX6QDL_PAD_SD4_DAT1__SD4_DATA1          0x17059
+                       MX6QDL_PAD_SD4_DAT2__SD4_DATA2          0x17059
+                       MX6QDL_PAD_SD4_DAT3__SD4_DATA3          0x17059
+                       MX6QDL_PAD_SD4_DAT4__SD4_DATA4          0x17059
+                       MX6QDL_PAD_SD4_DAT5__SD4_DATA5          0x17059
+                       MX6QDL_PAD_SD4_DAT6__SD4_DATA6          0x17059
+                       MX6QDL_PAD_SD4_DAT7__SD4_DATA7          0x17059
+               >;
+       };
+};
+
+&reg_arm {
+       vin-supply = <&sw3_reg>;
+};
+
+&reg_soc {
+       vin-supply = <&sw1_reg>;
+};
+
+&uart1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_uart1>;
+       uart-has-rtscts;
+       dtr-gpios = <&gpio3 24 GPIO_ACTIVE_LOW>;
+       dsr-gpios = <&gpio3 25 GPIO_ACTIVE_LOW>;
+       dcd-gpios = <&gpio3 23 GPIO_ACTIVE_LOW>;
+       rng-gpios = <&gpio2 31 GPIO_ACTIVE_LOW>;
+       status = "okay";
+};
+
+&uart4 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_uart4>;
+       status = "okay";
+};
+
+&uart5 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_uart5>;
+       uart-has-rtscts;
+       status = "okay";
+};
+
+&usbh1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usbh1>;
+       vbus-supply = <&reg_usb_h1_vbus>;
+       dr_mode = "host";
+       status = "okay";
+};
+
+&usbotg {
+       vbus-supply = <&reg_usb_otg_vbus>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usbotg>;
+       disable-over-current;
+       dr_mode = "otg";
+       status = "okay";
+};
+
+&usdhc2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usdhc2>;
+       cd-gpios = <&gpio6 16 GPIO_ACTIVE_HIGH>;
+       keep-power-in-suspend;
+       status = "okay";
+};
+
+&usdhc3 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usdhc3>;
+       cd-gpios = <&gpio7 8 GPIO_ACTIVE_LOW>;
+       fsl,wp-controller;
+       keep-power-in-suspend;
+       status = "disabled";
+};
+
+&usdhc4 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usdhc4>;
+       non-removable;
+       bus-width = <8>;
+       no-1-8-v;
+       keep-power-in-suspend;
+       status = "okay";
+};
index 0be375611382d687494bab346e2086aa99746238..84d3540b3a97f0d39f2b810eb65ba9eab3d3c263 100644 (file)
@@ -8,6 +8,7 @@
 
 /dts-v1/;
 #include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
 #include "imx6q.dtsi"
 
 / {
@@ -43,7 +44,7 @@ gpio-keys {
                recovery-button {
                        label = "recovery";
                        gpios = <&gpio3 16 1>;
-                       linux,code = <0x198>; /* KEY_RESTART */
+                       linux,code = <KEY_RESTART>;
                        wakeup-source;
                };
        };
diff --git a/arch/arm/boot/dts/imx6q-icore-mipi.dts b/arch/arm/boot/dts/imx6q-icore-mipi.dts
new file mode 100644 (file)
index 0000000..acd3d33
--- /dev/null
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2017 Engicam S.r.l.
+ * Copyright (C) 2017 Amarula Solutions B.V.
+ * Author: Jagan Teki <jagan@amarulasolutions.com>
+ */
+
+/dts-v1/;
+
+#include "imx6q.dtsi"
+#include "imx6qdl-icore.dtsi"
+
+/ {
+       model = "Engicam i.CoreM6 Quad/Dual MIPI Starter Kit";
+       compatible = "engicam,imx6-icore", "fsl,imx6q";
+};
+
+&hdmi {
+       ddc-i2c-bus = <&i2c2>;
+       status = "okay";
+};
+
+&usdhc3 {
+       status = "okay";
+};
index 9e230f56c5fb74ff601df8c6e4c42116ba215e09..6e27c8143f82157e8e0d98becd3805d857cca9bd 100644 (file)
 / {
        model = "Engicam i.CoreM6 Quad/Dual OpenFrame Capacitive touch 12 Kit";
        compatible = "engicam,imx6-icore", "fsl,imx6q";
+
+       panel {
+               compatible = "koe,tx31d200vm0baa";
+               backlight = <&backlight_lvds>;
+
+               port {
+                       panel_in: endpoint {
+                               remote-endpoint = <&lvds0_out>;
+                       };
+               };
+       };
 };
 
 &ldb {
        status = "okay";
 
        lvds-channel@0 {
-               fsl,data-mapping = "spwg";
-               fsl,data-width = <18>;
+               reg = <0>;
                status = "okay";
 
-               display-timings {
-                       native-mode = <&timing0>;
-                       timing0: timing0 {
-                               clock-frequency = <46800000>;
-                               hactive = <1280>;
-                               vactive = <480>;
-                               hback-porch = <353>;
-                               hfront-porch = <47>;
-                               vback-porch = <39>;
-                               vfront-porch = <4>;
-                               hsync-len = <8>;
-                               vsync-len = <2>;
+               port@4 {
+                       reg = <4>;
+
+                       lvds0_out: endpoint {
+                               remote-endpoint = <&panel_in>;
                        };
                };
        };
diff --git a/arch/arm/boot/dts/imx6q-kp-tpc.dts b/arch/arm/boot/dts/imx6q-kp-tpc.dts
new file mode 100644 (file)
index 0000000..302d8d0
--- /dev/null
@@ -0,0 +1,22 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2018
+ * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
+ */
+
+/dts-v1/;
+
+#include "imx6q-kp.dtsi"
+
+/ {
+       model = "Freescale i.MX6 Qwuad K+P TPC Board";
+       compatible = "kiebackpeter,imx6q-tpc", "fsl,imx6q";
+
+       memory@10000000 {
+               reg = <0x10000000 0x40000000>;
+       };
+};
+
+&ipu1_di0_disp0 {
+       remote-endpoint = <&lcd_display_in>;
+};
diff --git a/arch/arm/boot/dts/imx6q-kp.dtsi b/arch/arm/boot/dts/imx6q-kp.dtsi
new file mode 100644 (file)
index 0000000..24c8169
--- /dev/null
@@ -0,0 +1,432 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright 2018
+ * Lukasz Majewski, DENX Software Engineering, lukma@denx.de
+ */
+
+/dts-v1/;
+
+#include "imx6q.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/pwm/pwm.h>
+#include <dt-bindings/sound/fsl-imx-audmux.h>
+
+/ {
+       backlight_lcd: backlight-lcd {
+               compatible = "pwm-backlight";
+               pwms = <&pwm1 0 5000000>;
+               brightness-levels = <0 255>;
+               num-interpolated-steps = <255>;
+               default-brightness-level = <250>;
+       };
+
+       beeper {
+               compatible = "pwm-beeper";
+               pwms = <&pwm2 0 500000>;
+       };
+
+       lcd_display: display {
+               compatible = "fsl,imx-parallel-display";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               interface-pix-fmt = "rgb24";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_ipu1>;
+
+               port@0 {
+                       reg = <0>;
+
+                       lcd_display_in: endpoint {
+                               remote-endpoint = <&ipu1_di0_disp0>;
+                       };
+               };
+
+               port@1 {
+                       reg = <1>;
+
+                       lcd_display_out: endpoint {
+                               remote-endpoint = <&lcd_panel_in>;
+                       };
+               };
+       };
+
+       lcd_panel: lcd-panel {
+               compatible = "auo,g070vvn01";
+               backlight = <&backlight_lcd>;
+               power-supply = <&reg_display>;
+
+               port {
+                       lcd_panel_in: endpoint {
+                               remote-endpoint = <&lcd_display_out>;
+                       };
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               green {
+                       label = "led1";
+                       gpios = <&gpio3 16 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "gpio";
+                       default-state = "off";
+               };
+
+               red {
+                       label = "led0";
+                       gpios = <&gpio3 23 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "gpio";
+                       default-state = "off";
+               };
+       };
+
+       reg_3p3v: regulator-3p3v {
+               compatible = "regulator-fixed";
+               regulator-name = "3P3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-always-on;
+       };
+
+       reg_audio: regulator-audio {
+               compatible = "regulator-fixed";
+               regulator-name = "sgtl5000-supply";
+               gpio = <&gpio6 31 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+               regulator-always-on;
+       };
+
+       reg_display: regulator-display {
+               compatible = "regulator-fixed";
+               regulator-name = "display-supply";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-always-on;
+       };
+
+       reg_usb_h1_vbus: regulator-usb_h1_vbus {
+               compatible = "regulator-fixed";
+               regulator-name = "usb_h1_vbus";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               enable-active-high;
+       };
+
+       sound {
+               compatible = "simple-audio-card";
+               simple-audio-card,name = "imx6q-sgtl5000-audio";
+               simple-audio-card,format = "i2s";
+               simple-audio-card,bitclock-master = <&codec_dai>;
+               simple-audio-card,frame-master = <&codec_dai>;
+
+               cpu_dai: simple-audio-card,cpu {
+                       sound-dai = <&ssi1>;
+               };
+
+               codec_dai: simple-audio-card,codec {
+                       sound-dai = <&sgtl5000>;
+               };
+       };
+};
+
+&audmux {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_audmux>;
+       status = "okay";
+
+       ssi1 {
+               fsl,audmux-port = <0>;
+               fsl,port-config = <
+                       (IMX_AUDMUX_V2_PTCR_SYN |
+                       IMX_AUDMUX_V2_PTCR_TFSEL(2) |
+                       IMX_AUDMUX_V2_PTCR_TCSEL(2) |
+                       IMX_AUDMUX_V2_PTCR_TFSDIR |
+                       IMX_AUDMUX_V2_PTCR_TCLKDIR)
+                       IMX_AUDMUX_V2_PDCR_RXDSEL(2)
+               >;
+       };
+
+       aud3 {
+               fsl,audmux-port = <2>;
+               fsl,port-config = <
+                       IMX_AUDMUX_V2_PTCR_SYN
+                       IMX_AUDMUX_V2_PDCR_RXDSEL(0)
+               >;
+       };
+};
+
+&can1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_flexcan1>;
+};
+
+&can2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_flexcan2>;
+};
+
+&fec {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_enet>;
+       phy-mode = "rgmii";
+       fsl,magic-packet;
+       status = "okay";
+};
+
+&i2c1 {
+       clock-frequency = <400000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c1>;
+       status = "okay";
+
+       touchscreen@5d {
+               compatible = "goodix,gt911";
+               reg = <0x5d>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_ts>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <9 IRQ_TYPE_EDGE_FALLING>;
+               irq-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>;
+               reset-gpios = <&gpio5 2 GPIO_ACTIVE_HIGH>;
+       };
+
+       ds1307: rtc@32 {
+               compatible = "dallas,ds1307";
+               reg = <0x32>;
+       };
+};
+
+&i2c2 {
+       clock-frequency = <400000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c2>;
+       status = "okay";
+
+       sgtl5000: audio-codec@a {
+               compatible = "fsl,sgtl5000";
+               #sound-dai-cells = <0>;
+               reg = <0x0a>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_codec>;
+               clocks = <&clks IMX6QDL_CLK_CKO>;
+               VDDA-supply = <&reg_3p3v>;
+               VDDIO-supply = <&reg_3p3v>;
+       };
+};
+
+&iomuxc {
+       pinctrl_audmux: audmuxgrp {
+               fsl,pins = <
+                       MX6QDL_PAD_CSI0_DAT7__AUD3_RXD          0x130b0
+                       MX6QDL_PAD_CSI0_DAT4__AUD3_TXC          0x130b0
+                       MX6QDL_PAD_CSI0_DAT5__AUD3_TXD          0x110b0
+                       MX6QDL_PAD_CSI0_DAT6__AUD3_TXFS 0x130b0
+               >;
+       };
+
+       pinctrl_codec: codecgrp {
+               fsl,pins = <
+                       MX6QDL_PAD_EIM_BCLK__GPIO6_IO31   0x1b0b0
+                       /* sgtl5000 sys_mclk clock routed to CLKO1 */
+                       MX6QDL_PAD_GPIO_0__CCM_CLKO1      0x000b0
+               >;
+       };
+
+       pinctrl_enet: enetgrp {
+               fsl,pins = <
+                       MX6QDL_PAD_ENET_MDIO__ENET_MDIO 0x1b0b0
+                       MX6QDL_PAD_ENET_MDC__ENET_MDC           0x1b0b0
+                       MX6QDL_PAD_RGMII_TXC__RGMII_TXC 0x1b0b0
+                       MX6QDL_PAD_RGMII_TD0__RGMII_TD0 0x1b0b0
+                       MX6QDL_PAD_RGMII_TD1__RGMII_TD1 0x1b0b0
+                       MX6QDL_PAD_RGMII_TD2__RGMII_TD2 0x1b0b0
+                       MX6QDL_PAD_RGMII_TD3__RGMII_TD3 0x1b0b0
+                       MX6QDL_PAD_RGMII_TX_CTL__RGMII_TX_CTL   0x1b0b0
+                       MX6QDL_PAD_ENET_REF_CLK__ENET_TX_CLK    0x1b0b0
+                       MX6QDL_PAD_RGMII_RXC__RGMII_RXC 0x1b0b0
+                       MX6QDL_PAD_RGMII_RD0__RGMII_RD0 0x1b0b0
+                       MX6QDL_PAD_RGMII_RD1__RGMII_RD1 0x1b0b0
+                       MX6QDL_PAD_RGMII_RD2__RGMII_RD2 0x1b0b0
+                       MX6QDL_PAD_RGMII_RD3__RGMII_RD3 0x1b0b0
+                       MX6QDL_PAD_RGMII_RX_CTL__RGMII_RX_CTL   0x1b0b0
+                       MX6QDL_PAD_GPIO_16__ENET_REF_CLK 0x4001b0a8
+               >;
+       };
+
+       pinctrl_flexcan1: can1grp {
+               fsl,pins = <
+                       MX6QDL_PAD_GPIO_7__FLEXCAN1_TX        0x1b0b0
+                       MX6QDL_PAD_GPIO_8__FLEXCAN1_RX        0x1b0b0
+               >;
+       };
+
+       pinctrl_flexcan2: can2grp {
+               fsl,pins = <
+                       MX6QDL_PAD_KEY_COL4__FLEXCAN2_TX        0x1b0b0
+                       MX6QDL_PAD_KEY_ROW4__FLEXCAN2_RX        0x1b0b0
+               >;
+       };
+
+       pinctrl_i2c1: i2c1grp {
+               fsl,pins = <
+                       MX6QDL_PAD_CSI0_DAT8__I2C1_SDA  0x4001b8b1
+                       MX6QDL_PAD_CSI0_DAT9__I2C1_SCL  0x4001b8b1
+               >;
+       };
+
+       pinctrl_i2c2: i2c2grp {
+               fsl,pins = <
+                       MX6QDL_PAD_KEY_COL3__I2C2_SCL   0x4001b8b1
+                       MX6QDL_PAD_KEY_ROW3__I2C2_SDA   0x4001b8b1
+                >;
+       };
+
+       pinctrl_ipu1: ipu1grp {
+               fsl,pins = <
+                       MX6QDL_PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK 0x10
+                       MX6QDL_PAD_DI0_PIN15__IPU1_DI0_PIN15       0x10
+                       MX6QDL_PAD_DI0_PIN2__IPU1_DI0_PIN02        0x10
+                       MX6QDL_PAD_DI0_PIN3__IPU1_DI0_PIN03        0x10
+                       MX6QDL_PAD_DISP0_DAT0__IPU1_DISP0_DATA00   0x10
+                       MX6QDL_PAD_DISP0_DAT1__IPU1_DISP0_DATA01   0x10
+                       MX6QDL_PAD_DISP0_DAT2__IPU1_DISP0_DATA02   0x10
+                       MX6QDL_PAD_DISP0_DAT3__IPU1_DISP0_DATA03   0x10
+                       MX6QDL_PAD_DISP0_DAT4__IPU1_DISP0_DATA04   0x10
+                       MX6QDL_PAD_DISP0_DAT5__IPU1_DISP0_DATA05   0x10
+                       MX6QDL_PAD_DISP0_DAT6__IPU1_DISP0_DATA06   0x10
+                       MX6QDL_PAD_DISP0_DAT7__IPU1_DISP0_DATA07   0x10
+                       MX6QDL_PAD_DISP0_DAT8__IPU1_DISP0_DATA08   0x10
+                       MX6QDL_PAD_DISP0_DAT9__IPU1_DISP0_DATA09   0x10
+                       MX6QDL_PAD_DISP0_DAT10__IPU1_DISP0_DATA10  0x10
+                       MX6QDL_PAD_DISP0_DAT11__IPU1_DISP0_DATA11  0x10
+                       MX6QDL_PAD_DISP0_DAT12__IPU1_DISP0_DATA12  0x10
+                       MX6QDL_PAD_DISP0_DAT13__IPU1_DISP0_DATA13  0x10
+                       MX6QDL_PAD_DISP0_DAT14__IPU1_DISP0_DATA14  0x10
+                       MX6QDL_PAD_DISP0_DAT15__IPU1_DISP0_DATA15  0x10
+                       MX6QDL_PAD_DISP0_DAT16__IPU1_DISP0_DATA16  0x10
+                       MX6QDL_PAD_DISP0_DAT17__IPU1_DISP0_DATA17  0x10
+                       MX6QDL_PAD_DISP0_DAT18__IPU1_DISP0_DATA18  0x10
+                       MX6QDL_PAD_DISP0_DAT19__IPU1_DISP0_DATA19  0x10
+                       MX6QDL_PAD_DISP0_DAT20__IPU1_DISP0_DATA20  0x10
+                       MX6QDL_PAD_DISP0_DAT21__IPU1_DISP0_DATA21  0x10
+                       MX6QDL_PAD_DISP0_DAT22__IPU1_DISP0_DATA22  0x10
+                       MX6QDL_PAD_DISP0_DAT23__IPU1_DISP0_DATA23  0x10
+               >;
+       };
+
+       pinctrl_pwm1: pwm1grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD1_DAT3__PWM1_OUT           0x1b0b1
+               >;
+       };
+
+       pinctrl_pwm2: pwm2grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD1_DAT2__PWM2_OUT           0x1b0b1
+               >;
+       };
+
+       pinctrl_ts: tsgrp {
+               fsl,pins = <
+                       MX6QDL_PAD_GPIO_9__GPIO1_IO09 0x1b0b0
+                       MX6QDL_PAD_EIM_A25__GPIO5_IO02 0x1b0b0
+               >;
+       };
+
+       pinctrl_uart1: uart1grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD3_DAT7__UART1_TX_DATA      0x1b0b1
+                       MX6QDL_PAD_SD3_DAT6__UART1_RX_DATA      0x1b0b1
+               >;
+       };
+
+       pinctrl_uart2: uart2grp {
+               fsl,pins = <
+                       MX6QDL_PAD_EIM_D26__UART2_TX_DATA       0x1b0b1
+                       MX6QDL_PAD_EIM_D27__UART2_RX_DATA       0x1b0b1
+                       MX6QDL_PAD_EIM_D28__UART2_CTS_B         0x1b0b1
+                       MX6QDL_PAD_EIM_D29__UART2_RTS_B         0x1b0b1
+               >;
+       };
+
+       pinctrl_usdhc2: usdhc2grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD2_CMD__SD2_CMD             0x17059
+                       MX6QDL_PAD_SD2_CLK__SD2_CLK             0x10059
+                       MX6QDL_PAD_SD2_DAT0__SD2_DATA0          0x17059
+                       MX6QDL_PAD_SD2_DAT1__SD2_DATA1          0x17059
+                       MX6QDL_PAD_SD2_DAT2__SD2_DATA2          0x17059
+                       MX6QDL_PAD_SD2_DAT3__SD2_DATA3          0x17059
+               >;
+       };
+
+       pinctrl_usdhc4: usdhc4grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD4_CMD__SD4_CMD             0x17059
+                       MX6QDL_PAD_SD4_CLK__SD4_CLK             0x10059
+                       MX6QDL_PAD_SD4_DAT0__SD4_DATA0          0x17059
+                       MX6QDL_PAD_SD4_DAT1__SD4_DATA1          0x17059
+                       MX6QDL_PAD_SD4_DAT2__SD4_DATA2          0x17059
+                       MX6QDL_PAD_SD4_DAT3__SD4_DATA3          0x17059
+                       MX6QDL_PAD_SD4_DAT4__SD4_DATA4          0x17059
+                       MX6QDL_PAD_SD4_DAT5__SD4_DATA5          0x17059
+                       MX6QDL_PAD_SD4_DAT6__SD4_DATA6          0x17059
+                       MX6QDL_PAD_SD4_DAT7__SD4_DATA7          0x17059
+               >;
+       };
+};
+
+&pwm1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_pwm1>;
+       status = "okay";
+};
+
+&pwm2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_pwm2>;
+       status = "okay";
+};
+
+&ssi1 {
+       status = "okay";
+};
+
+&uart1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_uart1>;
+       status = "okay";
+};
+
+&uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_uart2>;
+       uart-has-rtscts;
+};
+
+&usbh1 {
+       status = "okay";
+};
+
+&usdhc2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usdhc2>;
+       bus-width = <4>;
+       cd-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>;
+       status = "okay";
+};
+
+&usdhc4 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usdhc4>;
+       bus-width = <8>;
+       non-removable;
+       no-1-8-v;
+       keep-power-in-suspend;
+       status = "okay";
+};
+
+&wdog1 {
+       status = "okay";
+};
index 52f39371188dfab69d5b991d6b2dadbe6c87fbae..fcd824dc485bb6009ea751d38b8b703f29e61667 100644 (file)
@@ -268,8 +268,6 @@ sbs_battery: bq20z75@b {
        touch: stmpe811@44 {
                compatible = "st,stmpe811";
                reg = <0x44>;
-               #address-cells = <1>;
-               #size-cells = <0>;
                irq-gpio = <&gpio5 13 GPIO_ACTIVE_HIGH>;
                id = <0>;
                blocks = <0x5>;
index bd57b3b74db757e11dc8ac44ad56c5dff9b0b133..a31e83cd07a30a3c597a8d68805e3d5e1eacbf46 100644 (file)
@@ -614,7 +614,7 @@ &uart4 {
 &uart5 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_uart5>;
-       fsl,uart-has-rtscts;
+       uart-has-rtscts;
        status = "okay";
 };
 
index 334b9247e78cefff1e5e30e4d033cad89c5d5d11..6e981a3e0a839088f9a08c86a2b7d366467ec1f3 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 /dts-v1/;
 
index 527772b62fee5d48bcc1820c2d23e469e3c9150a..eec944673c0bf80058e1640b604cfed2d016a5ee 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 /dts-v1/;
 
index c3e64ff3d544655f22650cf8c4ab3b023a9dbe02..52e9f4a211d08f6f1e90c3b62907e61f2783c5d0 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 /dts-v1/;
 #include "imx6q.dtsi"
index f5d9c34b0d392caca7b3b9e8aa8e6c40ab40de1b..d16ff2083d626c465cc0fad79b640b92152dd703 100644 (file)
@@ -61,8 +61,6 @@ aliases {
 
        encoder {
                compatible = "ti,tfp410";
-               #address-cells = <1>;
-               #size-cells = <0>;
 
                ports {
                        #address-cells = <1>;
index e0728d475f6f7fe8204338ecd72766184f049a89..f2368a073d07ecd73430dd3870d75291dfe73c3b 100644 (file)
@@ -26,8 +26,6 @@ backlight_lvds: backlight {
 
        gpio-keys {
                compatible = "gpio-keys";
-               #address-cells = <1>;
-               #size-cells = <0>;
                autorepeat;
 
                back {
index b763352cddaebac12932e1de286abcbd8373ffa6..be85b980bdfef2474b8130b943adf6625037c7ec 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 /dts-v1/;
 #include "imx6q.dtsi"
index 8691fab21058191f0a36119eb4fb92b7d3067cf0..fcfba28764d4ad7b48913bb209dd86adc5873cec 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 /dts-v1/;
 #include "imx6q.dtsi"
index 2a3d98c1489a724ba89949349cbd55b28ac93afa..fa36fe183fc0b9d9024e02882475399354391bce 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 /dts-v1/;
 #include "imx6q.dtsi"
index ae7b3f10789341597ec2723f3520dee39b63e272..70483ce72ba6cf648809acb7f24be3af11817674 100644 (file)
@@ -1,12 +1,6 @@
-
-/*
- * Copyright 2013 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright 2013 Freescale Semiconductor, Inc.
 
 #include <dt-bindings/interrupt-controller/irq.h>
 #include "imx6q-pinfunc.h"
@@ -162,22 +156,27 @@ ipu2_di0: port@2 {
                                #size-cells = <0>;
                                reg = <2>;
 
-                               ipu2_di0_disp0: disp0-endpoint {
+                               ipu2_di0_disp0: endpoint@0 {
+                                       reg = <0>;
                                };
 
-                               ipu2_di0_hdmi: hdmi-endpoint {
+                               ipu2_di0_hdmi: endpoint@1 {
+                                       reg = <1>;
                                        remote-endpoint = <&hdmi_mux_2>;
                                };
 
-                               ipu2_di0_mipi: mipi-endpoint {
+                               ipu2_di0_mipi: endpoint@2 {
+                                       reg = <2>;
                                        remote-endpoint = <&mipi_mux_2>;
                                };
 
-                               ipu2_di0_lvds0: lvds0-endpoint {
+                               ipu2_di0_lvds0: endpoint@3 {
+                                       reg = <3>;
                                        remote-endpoint = <&lvds0_mux_2>;
                                };
 
-                               ipu2_di0_lvds1: lvds1-endpoint {
+                               ipu2_di0_lvds1: endpoint@4 {
+                                       reg = <4>;
                                        remote-endpoint = <&lvds1_mux_2>;
                                };
                        };
@@ -187,19 +186,23 @@ ipu2_di1: port@3 {
                                #size-cells = <0>;
                                reg = <3>;
 
-                               ipu2_di1_hdmi: hdmi-endpoint {
+                               ipu2_di1_hdmi: endpoint@1 {
+                                       reg = <1>;
                                        remote-endpoint = <&hdmi_mux_3>;
                                };
 
-                               ipu2_di1_mipi: mipi-endpoint {
+                               ipu2_di1_mipi: endpoint@2 {
+                                       reg = <2>;
                                        remote-endpoint = <&mipi_mux_3>;
                                };
 
-                               ipu2_di1_lvds0: lvds0-endpoint {
+                               ipu2_di1_lvds0: endpoint@3 {
+                                       reg = <3>;
                                        remote-endpoint = <&lvds0_mux_3>;
                                };
 
-                               ipu2_di1_lvds1: lvds1-endpoint {
+                               ipu2_di1_lvds1: endpoint@4 {
+                                       reg = <4>;
                                        remote-endpoint = <&lvds1_mux_3>;
                                };
                        };
index 8206683172d205ed9476096e8f97ba1dc162f540..64fbee61de4492d733d236e0cc6cf667e6a1cee1 100644 (file)
@@ -331,8 +331,6 @@ stmpe811@41 {
                compatible = "st,stmpe811";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_touch_int>;
-               #address-cells = <1>;
-               #size-cells = <0>;
                reg = <0x41>;
                interrupts = <10 IRQ_TYPE_LEVEL_LOW>;
                interrupt-parent = <&gpio4>;
index e4eb300549d4fe15b83514f2f1ff33c3d5251349..76035db96f67831bc576cbea7f50f4b6ffe6d5b4 100644 (file)
@@ -262,8 +262,6 @@ stmpe811@41 {
                compatible = "st,stmpe811";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_touch_int>;
-               #address-cells = <1>;
-               #size-cells = <0>;
                reg = <0x41>;
                interrupts = <20 IRQ_TYPE_LEVEL_LOW>;
                interrupt-parent = <&gpio6>;
index 58124adfd65b55b2f43e18844f1927f131898ef0..3c52bdb453f332cacbd0f7438cc5d799f3a2758b 100644 (file)
@@ -162,8 +162,6 @@ mdio {
 
                switch@0 {
                        compatible = "marvell,mv88e6085";
-                       #address-cells = <1>;
-                       #size-cells = <0>;
                        reg = <0>;
 
                        ports {
index 7e20b47de839b4c7923f1b9b24735260c8d39ae6..0e64016e765f91806a4386081a12f98901048f5f 100644 (file)
@@ -38,6 +38,7 @@
  *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  *     OTHER DEALINGS IN THE SOFTWARE.
  */
+#include <dt-bindings/sound/fsl-imx-audmux.h>
 
 / {
        /* Will be filled by the bootloader */
@@ -110,17 +111,27 @@ v_usb1: regulator-v-usb1 {
                vin-supply = <&v_5v0>;
        };
 
-       sound-sgtl5000 {
-               audio-codec = <&sgtl5000>;
-               audio-routing =
-                       "MIC_IN", "Mic Jack",
-                       "Mic Jack", "Mic Bias",
+       audio: sound-sgtl5000 {
+               compatible = "simple-audio-card";
+               simple-audio-card,name = "On-board Codec";
+               simple-audio-card,format = "i2s";
+               simple-audio-card,bitclock-master = <&sound_codec>;
+               simple-audio-card,frame-master = <&sound_codec>;
+               simple-audio-card,widgets =
+                       "Microphone", "Headphone Jack",
+                       "Headphone", "Headphone Jack";
+               simple-audio-card,routing =
+                       "MIC_IN", "Headphone Jack",
+                       "Headphone Jack", "Mic Bias",
                        "Headphone Jack", "HP_OUT";
-               compatible = "fsl,imx-audio-sgtl5000";
-               model = "On-board Codec";
-               mux-ext-port = <5>;
-               mux-int-port = <1>;
-               ssi-controller = <&ssi1>;
+
+               sound_cpu: simple-audio-card,cpu {
+                       sound-dai = <&ssi1>;
+               };
+
+               sound_codec: simple-audio-card,codec {
+                       sound-dai = <&sgtl5000>;
+               };
        };
 
        sound-spdif {
@@ -134,6 +145,26 @@ sound-spdif {
 
 &audmux {
        status = "okay";
+
+       ssi1 {
+               fsl,audmux-port = <0>;
+               fsl,port-config = <
+                       (IMX_AUDMUX_V2_PTCR_SYN |
+                        IMX_AUDMUX_V2_PTCR_TFSEL(4) |
+                        IMX_AUDMUX_V2_PTCR_TCSEL(4) |
+                        IMX_AUDMUX_V2_PTCR_TFSDIR |
+                        IMX_AUDMUX_V2_PTCR_TCLKDIR)
+                        IMX_AUDMUX_V2_PDCR_RXDSEL(4)
+               >;
+       };
+
+       pins5 {
+               fsl,audmux-port = <4>;
+               fsl,port-config = <
+                       IMX_AUDMUX_V2_PTCR_SYN
+                       IMX_AUDMUX_V2_PDCR_RXDSEL(0)
+               >;
+       };
 };
 
 &can1 {
@@ -166,6 +197,7 @@ sgtl5000: codec@a {
                compatible = "fsl,sgtl5000";
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_hummingboard_sgtl5000>;
+               #sound-dai-cells = <0>;
                reg = <0x0a>;
                VDDA-supply = <&v_3v2>;
                VDDIO-supply = <&v_3v2>;
index 98241acb08a64e3605b4311ddd72e11ab00dd378..c413f9c3540fb99fc423db5c98b6030b64e69050 100644 (file)
@@ -38,6 +38,7 @@
  *     FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  *     OTHER DEALINGS IN THE SOFTWARE.
  */
+#include <dt-bindings/sound/fsl-imx-audmux.h>
 
 / {
        /* Will be filled by the bootloader */
@@ -150,22 +151,52 @@ v_usb4: regulator-v-usb4 {
                vin-supply = <&v_5v0>;
        };
 
-       sound-sgtl5000 {
-               audio-codec = <&sgtl5000>;
-               audio-routing =
+       audio: sound-sgtl5000 {
+               compatible = "simple-audio-card";
+               simple-audio-card,name = "On-board Codec";
+               simple-audio-card,format = "i2s";
+               simple-audio-card,bitclock-master = <&sound_codec>;
+               simple-audio-card,frame-master = <&sound_codec>;
+               simple-audio-card,widgets =
+                       "Microphone", "Mic Jack",
+                       "Headphone", "Headphone Jack";
+               simple-audio-card,routing =
                        "MIC_IN", "Mic Jack",
                        "Mic Jack", "Mic Bias",
                        "Headphone Jack", "HP_OUT";
-               compatible = "fsl,imx-audio-sgtl5000";
-               model = "On-board Codec";
-               mux-ext-port = <5>;
-               mux-int-port = <1>;
-               ssi-controller = <&ssi1>;
+
+               sound_cpu: simple-audio-card,cpu {
+                       sound-dai = <&ssi1>;
+               };
+
+               sound_codec: simple-audio-card,codec {
+                       sound-dai = <&sgtl5000>;
+               };
        };
 };
 
 &audmux {
        status = "okay";
+
+       ssi1 {
+               fsl,audmux-port = <0>;
+               fsl,port-config = <
+                       (IMX_AUDMUX_V2_PTCR_SYN |
+                        IMX_AUDMUX_V2_PTCR_TFSEL(4) |
+                        IMX_AUDMUX_V2_PTCR_TCSEL(4) |
+                        IMX_AUDMUX_V2_PTCR_TFSDIR |
+                        IMX_AUDMUX_V2_PTCR_TCLKDIR)
+                        IMX_AUDMUX_V2_PDCR_RXDSEL(4)
+               >;
+       };
+
+       pins5 {
+               fsl,audmux-port = <4>;
+               fsl,port-config = <
+                       IMX_AUDMUX_V2_PTCR_SYN
+                       IMX_AUDMUX_V2_PDCR_RXDSEL(0)
+               >;
+       };
 };
 
 &ecspi2 {
index b3a463a5908b590b356f3d95f59c77211bd8bb63..0a1574998fc6a89a423b706f143c4376e75c337c 100644 (file)
@@ -49,7 +49,7 @@ memory@10000000 {
                reg = <0x10000000 0x80000000>;
        };
 
-       backlight {
+       backlight_lvds: backlight-lvds {
                compatible = "pwm-backlight";
                pwms = <&pwm3 0 100000>;
                brightness-levels = <0 4 8 16 32 64 128 255>;
@@ -265,6 +265,14 @@ &usdhc1 {
        status = "okay";
 };
 
+&usdhc3 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_usdhc3>;
+       no-1-8-v;
+       non-removable;
+       status = "disabled";
+};
+
 &iomuxc {
        pinctrl_audmux: audmux {
                fsl,pins = <
@@ -378,4 +386,19 @@ MX6QDL_PAD_SD1_DAT2__SD1_DATA2 0x17070
                        MX6QDL_PAD_SD1_DAT3__SD1_DATA3 0x17070
                >;
        };
+
+       pinctrl_usdhc3: usdhc3grp {
+               fsl,pins = <
+                       MX6QDL_PAD_SD3_CMD__SD3_CMD    0x17059
+                       MX6QDL_PAD_SD3_CLK__SD3_CLK    0x10059
+                       MX6QDL_PAD_SD3_DAT0__SD3_DATA0 0x17059
+                       MX6QDL_PAD_SD3_DAT1__SD3_DATA1 0x17059
+                       MX6QDL_PAD_SD3_DAT2__SD3_DATA2 0x17059
+                       MX6QDL_PAD_SD3_DAT3__SD3_DATA3 0x17059
+                       MX6QDL_PAD_SD3_DAT4__SD3_DATA4 0x17059
+                       MX6QDL_PAD_SD3_DAT5__SD3_DATA5 0x17059
+                       MX6QDL_PAD_SD3_DAT6__SD3_DATA6 0x17059
+                       MX6QDL_PAD_SD3_DAT7__SD3_DATA7 0x17059
+               >;
+       };
 };
index c58f3443d55dd80b038ae0b1ddaba30e82343b1f..ed1aafd569735a4dcd6e308767158ae809c27442 100644 (file)
@@ -115,7 +115,7 @@ pmic@58 {
                compatible = "dlg,da9063";
                reg = <0x58>;
                interrupt-parent = <&gpio2>;
-               interrupts = <9 0x8>; /* active-low GPIO2_9 */
+               interrupts = <9 IRQ_TYPE_LEVEL_LOW>; /* active-low GPIO2_9 */
 
                regulators {
                        vddcore_reg: bcore1 {
index 54b0139e978d36b17d9be53c6c7d2a06506db1d9..0e28e36ddbb2d2431c8c815a0bdd6c4ac116481f 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 #include <dt-bindings/gpio/gpio.h>
 
index 18b65052553dd6d103e335e8e4bfb5264cfd911f..654cf2c9b07342fec5c7046534cd4a1d356ae855 100644 (file)
@@ -379,9 +379,6 @@ ov5640: camera@40 {
                powerdown-gpios = <&gpio6 9 GPIO_ACTIVE_HIGH>; /* NANDF_WP_B */
 
                port {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-
                        ov5640_to_mipi_csi2: endpoint {
                                remote-endpoint = <&mipi_csi2_in>;
                                clock-lanes = <0>;
index f019f990036907e3caba124382c3462ea6c5ee6c..15744ad52535cae0ebec5fba5f14bdab52e87136 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2012 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2012 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 #include <dt-bindings/clock/imx6qdl-clock.h>
 #include <dt-bindings/gpio/gpio.h>
@@ -294,9 +287,6 @@ rev B board is VGEN5 */
                reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>;
 
                port {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-
                        ov5640_to_mipi_csi2: endpoint {
                                remote-endpoint = <&mipi_csi2_in>;
                                clock-lanes = <0>;
index 5102fc47380b0305cd5eb8be17b8b248c3e1b141..79f2354886b7d6627e99eec45c2623c45e5a1b0b 100644 (file)
@@ -77,7 +77,6 @@ lcd_panel: lcd-panel {
                enable-gpios = <&gpio3 29 GPIO_ACTIVE_HIGH>;
                power-supply = <&reg_3v3>;
                backlight = <&backlight>;
-               bus-format-override = "rgb24";
 
                port {
                        lcd_panel_in: endpoint {
index 4c4e2e1a931f8a965c24142fd04c2195a3224fc1..410972e1dca96ba5466704b5e747bdfadcacc55e 100644 (file)
@@ -54,19 +54,16 @@ backlight1 {
 
        lcd-panel {
                compatible = "edt,et057090dhu";
-               bus-format-override = "rgb24";
                pixelclk-active = <0>;
        };
 
        lvds0-panel {
                compatible = "edt,etml1010g0dka";
-               bus-format-override = "spwg-18";
                pixelclk-active = <0>;
        };
 
        lvds1-panel {
                compatible = "edt,etml1010g0dka";
-               bus-format-override = "spwg-18";
                pixelclk-active = <0>;
        };
 };
index f015e2d1cf353954b069a5b4cbfb40dd3188adc4..a98fb2564c63f47ed59699ac4fc9a5510e158ca3 100644 (file)
@@ -50,11 +50,11 @@ aliases {
                can0 = &can2;
                can1 = &can1;
                ethernet0 = &fec;
-               lcdif_23bit_pins_a = &pinctrl_disp0_1;
-               lcdif_24bit_pins_a = &pinctrl_disp0_2;
+               lcdif-23bit-pins-a = &pinctrl_disp0_1;
+               lcdif-24bit-pins-a = &pinctrl_disp0_2;
                pwm0 = &pwm1;
                pwm1 = &pwm2;
-               reg_can_xcvr = &reg_can_xcvr;
+               reg-can-xcvr = &reg_can_xcvr;
                stk5led = &user_led;
                usbotg = &usbotg;
                sdhc0 = &usdhc1;
index 906387915dc5ee71ea2007cba5405f0925ded71d..4f27861bbb32405cae88e134177223a2de60165f 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 
 / {
index a3208913226395ebfc98665770bc5faefb0129b2..855dc6f9df75f00326d8d0be51ea34343124ed66 100644 (file)
@@ -17,7 +17,6 @@ &iomuxc {
        imx6qdl-wandboard {
                pinctrl_hog: hoggrp {
                        fsl,pins = <
-                               MX6QDL_PAD_GPIO_0__CCM_CLKO1            0x130b0         /* GPIO_0_CLKO */
                                MX6QDL_PAD_GPIO_2__GPIO1_IO02           0x80000000      /* uSDHC1 CD */
                                MX6QDL_PAD_EIM_DA9__GPIO3_IO09          0x80000000      /* uSDHC3 CD */
                                MX6QDL_PAD_EIM_EB1__GPIO2_IO29          0x0f0b0         /* WL_REF_ON */
index 8d893a78cdf0c4dbbb44627de526c9aa81fd1d41..49a0a557e62ef8a76f9164e896f44cadd9eb945f 100644 (file)
@@ -17,7 +17,6 @@ &iomuxc {
        imx6qdl-wandboard {
                pinctrl_hog: hoggrp {
                        fsl,pins = <
-                               MX6QDL_PAD_GPIO_0__CCM_CLKO1            0x130b0         /* GPIO_0_CLKO */
                                MX6QDL_PAD_GPIO_2__GPIO1_IO02           0x80000000      /* uSDHC1 CD */
                                MX6QDL_PAD_EIM_DA9__GPIO3_IO09          0x80000000      /* uSDHC3 CD */
                                MX6QDL_PAD_CSI0_DAT14__GPIO6_IO00       0x0f0b0         /* WIFI_ON (reset, active low) */
index 3a8a4952d45e09d0d74171ec1092a731833b2b5d..69d9c8661439bd960b72380b9cac11022cce7a20 100644 (file)
@@ -147,7 +147,6 @@ &iomuxc {
        imx6qdl-wandboard {
                pinctrl_hog: hoggrp {
                        fsl,pins = <
-                               MX6QDL_PAD_GPIO_0__CCM_CLKO1            0x130b0
                                MX6QDL_PAD_EIM_D22__USB_OTG_PWR         0x80000000      /* USB Power Enable */
                                MX6QDL_PAD_GPIO_2__GPIO1_IO02           0x80000000      /* USDHC1 CD */
                                MX6QDL_PAD_EIM_DA9__GPIO3_IO09          0x80000000      /* uSDHC3 CD */
index ed96d7b5feabdb276de7f0750c25c5dba26d6c1c..e1afa54404d0f2afa473045acc9b0b3898501bd3 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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 <dt-bindings/gpio/gpio.h>
@@ -83,6 +79,8 @@ &i2c2 {
        status = "okay";
 
        codec: sgtl5000@a {
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_mclk>;
                compatible = "fsl,sgtl5000";
                reg = <0x0a>;
                clocks = <&clks IMX6QDL_CLK_CKO>;
@@ -142,6 +140,12 @@ MX6QDL_PAD_KEY_ROW3__I2C2_SDA              0x4001b8b1
                        >;
                };
 
+               pinctrl_mclk: mclkgrp {
+                       fsl,pins = <
+                               MX6QDL_PAD_GPIO_0__CCM_CLKO1            0x130b0
+                       >;
+               };
+
                pinctrl_spdif: spdifgrp {
                        fsl,pins = <
                                MX6QDL_PAD_ENET_RXD0__SPDIF_OUT         0x1b0b0
index 911f7f0e3ceabb9f15c053ca30bfee53e103078f..19a075aee19eabfb5ac2b127db45199bca2f0d6a 100644 (file)
@@ -263,6 +263,17 @@ edp_refclk: edp-refclk {
        };
 };
 
+&cpu0 {
+       fsl,soc-operating-points = <
+               /* ARM kHz  SOC-PU uV */
+               1200000 1300000
+               996000  1275000
+               852000  1275000
+               792000  1200000
+               396000  1200000
+       >;
+};
+
 &reg_arm {
        vin-supply = <&sw1a_reg>;
 };
@@ -571,6 +582,17 @@ rmi4-f12@12 {
                };
        };
 
+       touchscreen@2a {
+               compatible = "eeti,egalax_ts";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_ts>;
+               reg = <0x2a>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <8 IRQ_TYPE_LEVEL_LOW>;
+               wakeup-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
+               status = "disabled";
+       };
+
        hpa1: amp@60 {
                compatible = "ti,tpa6130a2";
                pinctrl-names = "default";
@@ -666,8 +688,6 @@ switch: switch@0 {
                        compatible = "marvell,mv88e6085";
                        pinctrl-0 = <&pinctrl_switch_irq>;
                        pinctrl-names = "default";
-                       #address-cells = <1>;
-                       #size-cells = <0>;
                        reg = <0>;
                        dsa,member = <0 0>;
                        eeprom-length = <512>;
index c003e62bf2902defdc74678542c6c40dc97e96e0..911141e246810fe654db3d44dd147afca7122569 100644 (file)
@@ -1,14 +1,7 @@
-/*
- * Copyright 2011 Freescale Semiconductor, Inc.
- * Copyright 2011 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
+// SPDX-License-Identifier: GPL-2.0+
+//
+// Copyright 2011 Freescale Semiconductor, Inc.
+// Copyright 2011 Linaro Ltd.
 
 #include <dt-bindings/clock/imx6qdl-clock.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
@@ -58,9 +51,6 @@ aliases {
        };
 
        clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                ckil {
                        compatible = "fsl,imx-ckil", "fixed-clock";
                        #clock-cells = <0>;
@@ -695,11 +685,8 @@ anatop: anatop@20c8000 {
                                interrupts = <0 49 IRQ_TYPE_LEVEL_HIGH>,
                                             <0 54 IRQ_TYPE_LEVEL_HIGH>,
                                             <0 127 IRQ_TYPE_LEVEL_HIGH>;
-                               #address-cells = <1>;
-                               #size-cells = <0>;
 
-                               regulator-1p1@20c8110 {
-                                       reg = <0x20c8110>;
+                               regulator-1p1 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd1p1";
                                        regulator-min-microvolt = <1000000>;
@@ -714,8 +701,7 @@ regulator-1p1@20c8110 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               regulator-3p0@20c8120 {
-                                       reg = <0x20c8120>;
+                               regulator-3p0 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd3p0";
                                        regulator-min-microvolt = <2800000>;
@@ -730,8 +716,7 @@ regulator-3p0@20c8120 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               regulator-2p5@20c8130 {
-                                       reg = <0x20c8130>;
+                               regulator-2p5 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd2p5";
                                        regulator-min-microvolt = <2250000>;
@@ -746,8 +731,7 @@ regulator-2p5@20c8130 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               reg_arm: regulator-vddcore@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_arm: regulator-vddcore {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddarm";
                                        regulator-min-microvolt = <725000>;
@@ -764,8 +748,7 @@ reg_arm: regulator-vddcore@20c8140 {
                                        anatop-max-voltage = <1450000>;
                                };
 
-                               reg_pu: regulator-vddpu@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_pu: regulator-vddpu {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddpu";
                                        regulator-min-microvolt = <725000>;
@@ -782,8 +765,7 @@ reg_pu: regulator-vddpu@20c8140 {
                                        anatop-max-voltage = <1450000>;
                                };
 
-                               reg_soc: regulator-vddsoc@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_soc: regulator-vddsoc {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddsoc";
                                        regulator-min-microvolt = <725000>;
@@ -1187,8 +1169,6 @@ mipi_csi: mipi@21dc000 {
                        };
 
                        mipi_dsi: mipi@21e0000 {
-                               #address-cells = <1>;
-                               #size-cells = <0>;
                                reg = <0x021e0000 0x4000>;
                                status = "disabled";
 
@@ -1300,22 +1280,27 @@ ipu1_di0: port@2 {
                                #size-cells = <0>;
                                reg = <2>;
 
-                               ipu1_di0_disp0: disp0-endpoint {
+                               ipu1_di0_disp0: endpoint@0 {
+                                       reg = <0>;
                                };
 
-                               ipu1_di0_hdmi: hdmi-endpoint {
+                               ipu1_di0_hdmi: endpoint@1 {
+                                       reg = <1>;
                                        remote-endpoint = <&hdmi_mux_0>;
                                };
 
-                               ipu1_di0_mipi: mipi-endpoint {
+                               ipu1_di0_mipi: endpoint@2 {
+                                       reg = <2>;
                                        remote-endpoint = <&mipi_mux_0>;
                                };
 
-                               ipu1_di0_lvds0: lvds0-endpoint {
+                               ipu1_di0_lvds0: endpoint@3 {
+                                       reg = <3>;
                                        remote-endpoint = <&lvds0_mux_0>;
                                };
 
-                               ipu1_di0_lvds1: lvds1-endpoint {
+                               ipu1_di0_lvds1: endpoint@4 {
+                                       reg = <4>;
                                        remote-endpoint = <&lvds1_mux_0>;
                                };
                        };
@@ -1325,22 +1310,27 @@ ipu1_di1: port@3 {
                                #size-cells = <0>;
                                reg = <3>;
 
-                               ipu1_di1_disp1: disp1-endpoint {
+                               ipu1_di1_disp1: endpoint@0 {
+                                       reg = <0>;
                                };
 
-                               ipu1_di1_hdmi: hdmi-endpoint {
+                               ipu1_di1_hdmi: endpoint@1 {
+                                       reg = <1>;
                                        remote-endpoint = <&hdmi_mux_1>;
                                };
 
-                               ipu1_di1_mipi: mipi-endpoint {
+                               ipu1_di1_mipi: endpoint@2 {
+                                       reg = <2>;
                                        remote-endpoint = <&mipi_mux_1>;
                                };
 
-                               ipu1_di1_lvds0: lvds0-endpoint {
+                               ipu1_di1_lvds0: endpoint@3 {
+                                       reg = <3>;
                                        remote-endpoint = <&lvds0_mux_1>;
                                };
 
-                               ipu1_di1_lvds1: lvds1-endpoint {
+                               ipu1_di1_lvds1: endpoint@4 {
+                                       reg = <4>;
                                        remote-endpoint = <&lvds1_mux_1>;
                                };
                        };
index 5ce3840d83d3f5315b85050e67247e4b807e50a4..d4caeeb0af703e5f9e9438289eb176a65c34f6f6 100644 (file)
@@ -1,44 +1,6 @@
-/*
- * Copyright 2016 Freescale Semiconductor, Inc.
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file 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 file 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.
- *
- * Or, alternatively,
- *
- *  b) 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.
- */
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+//
+// Copyright 2016 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 
index a8a5004dd9c8615c877a6de92eb06df17ccc9c12..f1b9cb104fddc0d7887cf49f8bfd56517b6e2f39 100644 (file)
@@ -1,44 +1,6 @@
-/*
- * Copyright 2016 Freescale Semiconductor, Inc.
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file 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 file 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.
- *
- * Or, alternatively,
- *
- *  b) 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.
- */
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+//
+// Copyright 2016 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 
index 907ba0c74ba6465a7adb404c2d61353e0888e238..bcca5ac5fa51087f68c5a5cab5c2734de43f7a9a 100644 (file)
@@ -1,12 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright 2013 Freescale Semiconductor, Inc.
  *
  * Author: Fabio Estevam <fabio.estevam@freescale.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.
- *
  */
 /dts-v1/;
 #include "imx6qp.dtsi"
index de5b50df833cd5c729ff022b804bd25356f7e0ef..8c293e9f36a701ab1f23feab9c5078f6a3807057 100644 (file)
@@ -53,3 +53,8 @@ memory@10000000 {
                reg = <0x10000000 0>;
        };
 };
+
+&gpu_3d {
+       assigned-clocks = <&clks IMX6QDL_CLK_GPU3D_SHADER_SEL>;
+       assigned-clock-parents = <&clks IMX6QDL_CLK_PLL2_PFD1_594M>;
+};
index 5f4fdce715c1941e24cab61074bfc8005db03a03..5f51f8e5c1faeee6bfff1f55d94134ea93292688 100644 (file)
@@ -1,44 +1,6 @@
-/*
- * Copyright 2016 Freescale Semiconductor, Inc.
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file 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 file 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.
- *
- * Or, alternatively,
- *
- *  b) 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.
- */
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+//
+// Copyright 2016 Freescale Semiconductor, Inc.
 
 #include "imx6q.dtsi"
 
index 37e792fdc16021dc9e9eb0e96ecfd099047ac0db..92ad01f676e345f4f7e97f602026c50135c97039 100644 (file)
@@ -1,10 +1,6 @@
-/*
- * Copyright (C) 2013 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+//Copyright (C) 2013 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 
index ab6a7e2e7e8f67680b7ec06e37989610ea9a450a..994e48dc1df0a01e1be33c2bc8750e453b83ddb4 100644 (file)
@@ -1,11 +1,6 @@
-/*
- * Copyright 2013 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright 2013 Freescale Semiconductor, Inc.
 
 #include <dt-bindings/interrupt-controller/irq.h>
 #include "imx6sl-pinfunc.h"
@@ -86,9 +81,6 @@ intc: interrupt-controller@a01000 {
        };
 
        clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                ckil {
                        compatible = "fixed-clock";
                        #clock-cells = <0>;
@@ -527,11 +519,8 @@ anatop: anatop@20c8000 {
                                interrupts = <0 49 IRQ_TYPE_LEVEL_HIGH>,
                                             <0 54 IRQ_TYPE_LEVEL_HIGH>,
                                             <0 127 IRQ_TYPE_LEVEL_HIGH>;
-                               #address-cells = <1>;
-                               #size-cells = <0>;
 
-                               regulator-1p1@20c8110 {
-                                       reg = <0x20c8110>;
+                               regulator-1p1 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd1p1";
                                        regulator-min-microvolt = <800000>;
@@ -546,8 +535,7 @@ regulator-1p1@20c8110 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               regulator-3p0@20c8120 {
-                                       reg = <0x20c8120>;
+                               regulator-3p0 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd3p0";
                                        regulator-min-microvolt = <2800000>;
@@ -562,8 +550,7 @@ regulator-3p0@20c8120 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               regulator-2p5@20c8130 {
-                                       reg = <0x20c8130>;
+                               regulator-2p5 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd2p5";
                                        regulator-min-microvolt = <2100000>;
@@ -578,8 +565,7 @@ regulator-2p5@20c8130 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               reg_arm: regulator-vddcore@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_arm: regulator-vddcore {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddarm";
                                        regulator-min-microvolt = <725000>;
@@ -596,8 +582,7 @@ reg_arm: regulator-vddcore@20c8140 {
                                        anatop-max-voltage = <1450000>;
                                };
 
-                               reg_pu: regulator-vddpu@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_pu: regulator-vddpu {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddpu";
                                        regulator-min-microvolt = <725000>;
@@ -614,8 +599,7 @@ reg_pu: regulator-vddpu@20c8140 {
                                        anatop-max-voltage = <1450000>;
                                };
 
-                               reg_soc: regulator-vddsoc@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_soc: regulator-vddsoc {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddsoc";
                                        regulator-min-microvolt = <725000>;
index b58f770c40d96f4b6e90d20c88ca3b03df48d354..59e52f504922f23174ad2c492a7eaf97040c5f56 100644 (file)
@@ -48,8 +48,8 @@ / {
        compatible = "boundary,imx6sx-nitrogen6sx", "fsl,imx6sx";
 
        aliases {
-               fb_lcd = &lcdif1;
-               t_lcd = &t_lcd;
+               fb-lcd = &lcdif1;
+               t-lcd = &t_lcd;
        };
 
        memory@80000000 {
index 72da5acf35a2bcdd7bf3c791288880fa9f9fbc89..841a27f3198ff88b4f58e9fd3286ce080ad3117c 100644 (file)
@@ -1,10 +1,6 @@
-/*
- * Copyright (C) 2014 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (C) 2014 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 
@@ -18,25 +14,67 @@ memory@80000000 {
                reg = <0x80000000 0x80000000>;
        };
 
-       regulators {
-               compatible = "simple-bus";
+       leds {
+               compatible = "gpio-leds";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_led>;
+
+               user {
+                       label = "debug";
+                       gpios = <&gpio1 24 GPIO_ACTIVE_HIGH>;
+                       linux,default-trigger = "heartbeat";
+               };
+       };
+
+       vcc_sd3: regulator-vcc-sd3 {
+               compatible = "regulator-fixed";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_vcc_sd3>;
+               regulator-name = "VCC_SD3";
+               regulator-min-microvolt = <3000000>;
+               regulator-max-microvolt = <3000000>;
+               gpio = <&gpio2 11 GPIO_ACTIVE_HIGH>;
+               enable-active-high;
+       };
+};
+
+&anaclk2 {
+       clock-frequency = <24576000>;
+};
+
+&fec1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_enet1>;
+       phy-mode = "rgmii";
+       phy-handle = <&ethphy1>;
+       fsl,magic-packet;
+       status = "okay";
+
+       mdio {
                #address-cells = <1>;
                #size-cells = <0>;
 
-               vcc_sd3: regulator@0 {
-                       compatible = "regulator-fixed";
+               ethphy0: ethernet-phy@0 {
+                       compatible = "ethernet-phy-ieee802.3-c22";
                        reg = <0>;
-                       pinctrl-names = "default";
-                       pinctrl-0 = <&pinctrl_vcc_sd3>;
-                       regulator-name = "VCC_SD3";
-                       regulator-min-microvolt = <3000000>;
-                       regulator-max-microvolt = <3000000>;
-                       gpio = <&gpio2 11 GPIO_ACTIVE_HIGH>;
-                       enable-active-high;
+               };
+
+               ethphy1: ethernet-phy@1 {
+                       compatible = "ethernet-phy-ieee802.3-c22";
+                       reg = <1>;
                };
        };
 };
 
+&fec2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_enet2>;
+       phy-mode = "rgmii";
+       phy-handle = <&ethphy0>;
+       fsl,magic-packet;
+       status = "okay";
+};
+
 &uart1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_uart1>;
@@ -69,78 +107,297 @@ &usdhc4 {
 };
 
 &iomuxc {
-       imx6x-sabreauto {
-               pinctrl_uart1: uart1grp {
-                       fsl,pins = <
-                               MX6SX_PAD_GPIO1_IO04__UART1_TX          0x1b0b1
-                               MX6SX_PAD_GPIO1_IO05__UART1_RX          0x1b0b1
-                       >;
-               };
+       pinctrl_egalax_int: egalax-intgrp {
+               fsl,pins = <
+                       MX6SX_PAD_SD4_RESET_B__GPIO6_IO_22      0x10b0
+               >;
+       };
 
-               pinctrl_usdhc3: usdhc3grp {
-                       fsl,pins = <
-                               MX6SX_PAD_SD3_CMD__USDHC3_CMD           0x17059
-                               MX6SX_PAD_SD3_CLK__USDHC3_CLK           0x10059
-                               MX6SX_PAD_SD3_DATA0__USDHC3_DATA0       0x17059
-                               MX6SX_PAD_SD3_DATA1__USDHC3_DATA1       0x17059
-                               MX6SX_PAD_SD3_DATA2__USDHC3_DATA2       0x17059
-                               MX6SX_PAD_SD3_DATA3__USDHC3_DATA3       0x17059
-                               MX6SX_PAD_SD3_DATA4__USDHC3_DATA4       0x17059
-                               MX6SX_PAD_SD3_DATA5__USDHC3_DATA5       0x17059
-                               MX6SX_PAD_SD3_DATA6__USDHC3_DATA6       0x17059
-                               MX6SX_PAD_SD3_DATA7__USDHC3_DATA7       0x17059
-                               MX6SX_PAD_KEY_COL0__GPIO2_IO_10         0x17059 /* CD */
-                               MX6SX_PAD_KEY_ROW0__GPIO2_IO_15         0x17059 /* WP */
-                       >;
-               };
+       pinctrl_enet1: enet1grp {
+               fsl,pins = <
+                       MX6SX_PAD_ENET1_MDIO__ENET1_MDIO        0xa0b1
+                       MX6SX_PAD_ENET1_MDC__ENET1_MDC          0xa0b1
+                       MX6SX_PAD_RGMII1_TXC__ENET1_RGMII_TXC   0xa0b9
+                       MX6SX_PAD_RGMII1_TD0__ENET1_TX_DATA_0   0xa0b1
+                       MX6SX_PAD_RGMII1_TD1__ENET1_TX_DATA_1   0xa0b1
+                       MX6SX_PAD_RGMII1_TD2__ENET1_TX_DATA_2   0xa0b1
+                       MX6SX_PAD_RGMII1_TD3__ENET1_TX_DATA_3   0xa0b1
+                       MX6SX_PAD_RGMII1_TX_CTL__ENET1_TX_EN    0xa0b1
+                       MX6SX_PAD_RGMII1_RXC__ENET1_RX_CLK      0x3081
+                       MX6SX_PAD_RGMII1_RD0__ENET1_RX_DATA_0   0x3081
+                       MX6SX_PAD_RGMII1_RD1__ENET1_RX_DATA_1   0x3081
+                       MX6SX_PAD_RGMII1_RD2__ENET1_RX_DATA_2   0x3081
+                       MX6SX_PAD_RGMII1_RD3__ENET1_RX_DATA_3   0x3081
+                       MX6SX_PAD_RGMII1_RX_CTL__ENET1_RX_EN    0x3081
+               >;
+       };
 
-               pinctrl_usdhc3_100mhz: usdhc3grp-100mhz {
-                       fsl,pins = <
-                               MX6SX_PAD_SD3_CMD__USDHC3_CMD           0x170b9
-                               MX6SX_PAD_SD3_CLK__USDHC3_CLK           0x100b9
-                               MX6SX_PAD_SD3_DATA0__USDHC3_DATA0       0x170b9
-                               MX6SX_PAD_SD3_DATA1__USDHC3_DATA1       0x170b9
-                               MX6SX_PAD_SD3_DATA2__USDHC3_DATA2       0x170b9
-                               MX6SX_PAD_SD3_DATA3__USDHC3_DATA3       0x170b9
-                               MX6SX_PAD_SD3_DATA4__USDHC3_DATA4       0x170b9
-                               MX6SX_PAD_SD3_DATA5__USDHC3_DATA5       0x170b9
-                               MX6SX_PAD_SD3_DATA6__USDHC3_DATA6       0x170b9
-                               MX6SX_PAD_SD3_DATA7__USDHC3_DATA7       0x170b9
-                       >;
-               };
+       pinctrl_enet2: enet2grp {
+               fsl,pins = <
+                       MX6SX_PAD_RGMII2_TXC__ENET2_RGMII_TXC   0xa0b9
+                       MX6SX_PAD_RGMII2_TD0__ENET2_TX_DATA_0   0xa0b1
+                       MX6SX_PAD_RGMII2_TD1__ENET2_TX_DATA_1   0xa0b1
+                       MX6SX_PAD_RGMII2_TD2__ENET2_TX_DATA_2   0xa0b1
+                       MX6SX_PAD_RGMII2_TD3__ENET2_TX_DATA_3   0xa0b1
+                       MX6SX_PAD_RGMII2_TX_CTL__ENET2_TX_EN    0xa0b1
+                       MX6SX_PAD_RGMII2_RXC__ENET2_RX_CLK      0x3081
+                       MX6SX_PAD_RGMII2_RD0__ENET2_RX_DATA_0   0x3081
+                       MX6SX_PAD_RGMII2_RD1__ENET2_RX_DATA_1   0x3081
+                       MX6SX_PAD_RGMII2_RD2__ENET2_RX_DATA_2   0x3081
+                       MX6SX_PAD_RGMII2_RD3__ENET2_RX_DATA_3   0x3081
+                       MX6SX_PAD_RGMII2_RX_CTL__ENET2_RX_EN    0x3081
+               >;
+       };
 
-               pinctrl_usdhc3_200mhz: usdhc3grp-200mhz {
-                       fsl,pins = <
-                               MX6SX_PAD_SD3_CMD__USDHC3_CMD           0x170f9
-                               MX6SX_PAD_SD3_CLK__USDHC3_CLK           0x100f9
-                               MX6SX_PAD_SD3_DATA0__USDHC3_DATA0       0x170f9
-                               MX6SX_PAD_SD3_DATA1__USDHC3_DATA1       0x170f9
-                               MX6SX_PAD_SD3_DATA2__USDHC3_DATA2       0x170f9
-                               MX6SX_PAD_SD3_DATA3__USDHC3_DATA3       0x170f9
-                               MX6SX_PAD_SD3_DATA4__USDHC3_DATA4       0x170f9
-                               MX6SX_PAD_SD3_DATA5__USDHC3_DATA5       0x170f9
-                               MX6SX_PAD_SD3_DATA6__USDHC3_DATA6       0x170f9
-                               MX6SX_PAD_SD3_DATA7__USDHC3_DATA7       0x170f9
-                       >;
-               };
+       pinctrl_i2c2: i2c2grp {
+               fsl,pins = <
+                       MX6SX_PAD_GPIO1_IO03__I2C2_SDA          0x4001b8b1
+                       MX6SX_PAD_GPIO1_IO02__I2C2_SCL          0x4001b8b1
+               >;
+       };
 
-               pinctrl_usdhc4: usdhc4grp {
-                       fsl,pins = <
-                               MX6SX_PAD_SD4_CMD__USDHC4_CMD           0x17059
-                               MX6SX_PAD_SD4_CLK__USDHC4_CLK           0x10059
-                               MX6SX_PAD_SD4_DATA0__USDHC4_DATA0       0x17059
-                               MX6SX_PAD_SD4_DATA1__USDHC4_DATA1       0x17059
-                               MX6SX_PAD_SD4_DATA2__USDHC4_DATA2       0x17059
-                               MX6SX_PAD_SD4_DATA3__USDHC4_DATA3       0x17059
-                               MX6SX_PAD_SD4_DATA7__GPIO6_IO_21        0x17059 /* CD */
-                               MX6SX_PAD_SD4_DATA6__GPIO6_IO_20        0x17059 /* WP */
-                       >;
-               };
+       pinctrl_i2c3: i2c3grp {
+               fsl,pins = <
+                       MX6SX_PAD_KEY_ROW4__I2C3_SDA            0x4001b8b1
+                       MX6SX_PAD_KEY_COL4__I2C3_SCL            0x4001b8b1
+               >;
+       };
+
+       pinctrl_led: ledgrp {
+               fsl,pins = <
+                       MX6SX_PAD_CSI_PIXCLK__GPIO1_IO_24 0x17059
+               >;
+       };
+
+       pinctrl_uart1: uart1grp {
+               fsl,pins = <
+                       MX6SX_PAD_GPIO1_IO04__UART1_TX          0x1b0b1
+                       MX6SX_PAD_GPIO1_IO05__UART1_RX          0x1b0b1
+               >;
+       };
+
+       pinctrl_usdhc3: usdhc3grp {
+               fsl,pins = <
+                       MX6SX_PAD_SD3_CMD__USDHC3_CMD           0x17059
+                       MX6SX_PAD_SD3_CLK__USDHC3_CLK           0x10059
+                       MX6SX_PAD_SD3_DATA0__USDHC3_DATA0       0x17059
+                       MX6SX_PAD_SD3_DATA1__USDHC3_DATA1       0x17059
+                       MX6SX_PAD_SD3_DATA2__USDHC3_DATA2       0x17059
+                       MX6SX_PAD_SD3_DATA3__USDHC3_DATA3       0x17059
+                       MX6SX_PAD_SD3_DATA4__USDHC3_DATA4       0x17059
+                       MX6SX_PAD_SD3_DATA5__USDHC3_DATA5       0x17059
+                       MX6SX_PAD_SD3_DATA6__USDHC3_DATA6       0x17059
+                       MX6SX_PAD_SD3_DATA7__USDHC3_DATA7       0x17059
+                       MX6SX_PAD_KEY_COL0__GPIO2_IO_10         0x17059 /* CD */
+                       MX6SX_PAD_KEY_ROW0__GPIO2_IO_15         0x17059 /* WP */
+               >;
+       };
+
+       pinctrl_usdhc3_100mhz: usdhc3grp-100mhz {
+               fsl,pins = <
+                       MX6SX_PAD_SD3_CMD__USDHC3_CMD           0x170b9
+                       MX6SX_PAD_SD3_CLK__USDHC3_CLK           0x100b9
+                       MX6SX_PAD_SD3_DATA0__USDHC3_DATA0       0x170b9
+                       MX6SX_PAD_SD3_DATA1__USDHC3_DATA1       0x170b9
+                       MX6SX_PAD_SD3_DATA2__USDHC3_DATA2       0x170b9
+                       MX6SX_PAD_SD3_DATA3__USDHC3_DATA3       0x170b9
+                       MX6SX_PAD_SD3_DATA4__USDHC3_DATA4       0x170b9
+                       MX6SX_PAD_SD3_DATA5__USDHC3_DATA5       0x170b9
+                       MX6SX_PAD_SD3_DATA6__USDHC3_DATA6       0x170b9
+                       MX6SX_PAD_SD3_DATA7__USDHC3_DATA7       0x170b9
+               >;
+       };
+
+       pinctrl_usdhc3_200mhz: usdhc3grp-200mhz {
+               fsl,pins = <
+                       MX6SX_PAD_SD3_CMD__USDHC3_CMD           0x170f9
+                       MX6SX_PAD_SD3_CLK__USDHC3_CLK           0x100f9
+                       MX6SX_PAD_SD3_DATA0__USDHC3_DATA0       0x170f9
+                       MX6SX_PAD_SD3_DATA1__USDHC3_DATA1       0x170f9
+                       MX6SX_PAD_SD3_DATA2__USDHC3_DATA2       0x170f9
+                       MX6SX_PAD_SD3_DATA3__USDHC3_DATA3       0x170f9
+                       MX6SX_PAD_SD3_DATA4__USDHC3_DATA4       0x170f9
+                       MX6SX_PAD_SD3_DATA5__USDHC3_DATA5       0x170f9
+                       MX6SX_PAD_SD3_DATA6__USDHC3_DATA6       0x170f9
+                       MX6SX_PAD_SD3_DATA7__USDHC3_DATA7       0x170f9
+               >;
+       };
+
+       pinctrl_usdhc4: usdhc4grp {
+               fsl,pins = <
+                       MX6SX_PAD_SD4_CMD__USDHC4_CMD           0x17059
+                       MX6SX_PAD_SD4_CLK__USDHC4_CLK           0x10059
+                       MX6SX_PAD_SD4_DATA0__USDHC4_DATA0       0x17059
+                       MX6SX_PAD_SD4_DATA1__USDHC4_DATA1       0x17059
+                       MX6SX_PAD_SD4_DATA2__USDHC4_DATA2       0x17059
+                       MX6SX_PAD_SD4_DATA3__USDHC4_DATA3       0x17059
+                       MX6SX_PAD_SD4_DATA7__GPIO6_IO_21        0x17059 /* CD */
+                       MX6SX_PAD_SD4_DATA6__GPIO6_IO_20        0x17059 /* WP */
+               >;
+       };
+
+       pinctrl_vcc_sd3: vccsd3grp {
+               fsl,pins = <
+                       MX6SX_PAD_KEY_COL1__GPIO2_IO_11         0x17059
+               >;
+       };
+
+       pinctrl_wdog: wdoggrp {
+               fsl,pins = <
+                       MX6SX_PAD_GPIO1_IO13__WDOG1_WDOG_ANY    0x30b0
+               >;
+       };
+};
+
+&i2c2 {
+       clock-frequency = <100000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c2>;
+       status = "okay";
+
+       touchscreen@4 {
+               compatible = "eeti,egalax_ts";
+               reg = <0x04>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_egalax_int>;
+               interrupt-parent = <&gpio6>;
+               interrupts = <22 IRQ_TYPE_EDGE_FALLING>;
+               wakeup-gpios = <&gpio6 22 GPIO_ACTIVE_HIGH>;
+       };
+
+       pfuze100: pmic@8 {
+               compatible = "fsl,pfuze100";
+               reg = <0x08>;
+
+               regulators {
+                       sw1a_reg: sw1ab {
+                               regulator-min-microvolt = <300000>;
+                               regulator-max-microvolt = <1875000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                               regulator-ramp-delay = <6250>;
+                       };
+
+                       sw1c_reg: sw1c {
+                               regulator-min-microvolt = <300000>;
+                               regulator-max-microvolt = <1875000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                               regulator-ramp-delay = <6250>;
+                       };
+
+                       sw2_reg: sw2 {
+                               regulator-min-microvolt = <800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       sw3a_reg: sw3a {
+                               regulator-min-microvolt = <400000>;
+                               regulator-max-microvolt = <1975000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       sw3b_reg: sw3b {
+                               regulator-min-microvolt = <400000>;
+                               regulator-max-microvolt = <1975000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       sw4_reg: sw4 {
+                               regulator-min-microvolt = <800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+
+                       swbst_reg: swbst {
+                               regulator-min-microvolt = <5000000>;
+                               regulator-max-microvolt = <5150000>;
+                       };
+
+                       snvs_reg: vsnvs {
+                               regulator-min-microvolt = <1000000>;
+                               regulator-max-microvolt = <3000000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
 
-               pinctrl_vcc_sd3: vccsd3grp {
-                       fsl,pins = <
-                               MX6SX_PAD_KEY_COL1__GPIO2_IO_11         0x17059
-                       >;
+                       vref_reg: vrefddr {
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       vgen1_reg: vgen1 {
+                               regulator-min-microvolt = <800000>;
+                               regulator-max-microvolt = <1550000>;
+                               regulator-always-on;
+                       };
+
+                       vgen2_reg: vgen2 {
+                               regulator-min-microvolt = <800000>;
+                               regulator-max-microvolt = <1550000>;
+                       };
+
+                       vgen3_reg: vgen3 {
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+
+                       vgen4_reg: vgen4 {
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+
+                       vgen5_reg: vgen5 {
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
+
+                       vgen6_reg: vgen6 {
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
                };
        };
+
+       max7322: gpio@68 {
+               compatible = "maxim,max7322";
+               reg = <0x68>;
+               gpio-controller;
+               #gpio-cells = <2>;
+       };
+};
+
+&i2c3 {
+       clock-frequency = <100000>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_i2c3>;
+       status = "okay";
+
+       max7310_a: gpio@30 {
+               compatible = "maxim,max7310";
+               reg = <0x30>;
+               gpio-controller;
+               #gpio-cells = <2>;
+       };
+
+       max7310_b: gpio@32 {
+               compatible = "maxim,max7310";
+               reg = <0x32>;
+               gpio-controller;
+               #gpio-cells = <2>;
+       };
+};
+
+&wdog1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pinctrl_wdog>;
+       fsl,ext-reset-output;
 };
index 49c7205b8db818cc7e12fd0d652fb1922f052fca..d8b94f47498b67051ade669f23d2796a0b1e7433 100644 (file)
@@ -1,10 +1,6 @@
-/*
- * Copyright 2014 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright 2014 Freescale Semiconductor, Inc.
 
 #include <dt-bindings/clock/imx6sx-clock.h>
 #include <dt-bindings/gpio/gpio.h>
@@ -104,41 +100,46 @@ intc: interrupt-controller@a01000 {
                interrupt-parent = <&intc>;
        };
 
-       clocks {
-               #address-cells = <1>;
-               #size-cells = <0>;
+       ckil: clock-ckil {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <32768>;
+               clock-output-names = "ckil";
+       };
 
-               ckil: clock@0 {
-                       compatible = "fixed-clock";
-                       reg = <0>;
-                       #clock-cells = <0>;
-                       clock-frequency = <32768>;
-                       clock-output-names = "ckil";
-               };
+       osc: clock-osc {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <24000000>;
+               clock-output-names = "osc";
+       };
 
-               osc: clock@1 {
-                       compatible = "fixed-clock";
-                       reg = <1>;
-                       #clock-cells = <0>;
-                       clock-frequency = <24000000>;
-                       clock-output-names = "osc";
-               };
+       ipp_di0: clock-ipp-di0 {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+               clock-output-names = "ipp_di0";
+       };
 
-               ipp_di0: clock@2 {
-                       compatible = "fixed-clock";
-                       reg = <2>;
-                       #clock-cells = <0>;
-                       clock-frequency = <0>;
-                       clock-output-names = "ipp_di0";
-               };
+       ipp_di1: clock-ipp-di1 {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+               clock-output-names = "ipp_di1";
+       };
 
-               ipp_di1: clock@3 {
-                       compatible = "fixed-clock";
-                       reg = <3>;
-                       #clock-cells = <0>;
-                       clock-frequency = <0>;
-                       clock-output-names = "ipp_di1";
-               };
+       anaclk1: clock-anaclk1 {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+               clock-output-names = "anaclk1";
+       };
+
+       anaclk2: clock-anaclk2 {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+               clock-output-names = "anaclk2";
        };
 
        tempmon: tempmon {
@@ -575,8 +576,8 @@ clks: ccm@20c4000 {
                                interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>,
                                             <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>;
                                #clock-cells = <1>;
-                               clocks = <&ckil>, <&osc>, <&ipp_di0>, <&ipp_di1>;
-                               clock-names = "ckil", "osc", "ipp_di0", "ipp_di1";
+                               clocks = <&ckil>, <&osc>, <&ipp_di0>, <&ipp_di1>, <&anaclk1>, <&anaclk2>;
+                               clock-names = "ckil", "osc", "ipp_di0", "ipp_di1", "anaclk1", "anaclk2";
                        };
 
                        anatop: anatop@20c8000 {
@@ -586,11 +587,8 @@ anatop: anatop@20c8000 {
                                interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
                                             <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
                                             <GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>;
-                               #address-cells = <1>;
-                               #size-cells = <0>;
 
-                               regulator-1p1@20c8110 {
-                                       reg = <0x20c8110>;
+                               regulator-1p1 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd1p1";
                                        regulator-min-microvolt = <800000>;
@@ -605,8 +603,7 @@ regulator-1p1@20c8110 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               regulator-3p0@20c8120 {
-                                       reg = <0x20c8120>;
+                               regulator-3p0 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd3p0";
                                        regulator-min-microvolt = <2800000>;
@@ -621,8 +618,7 @@ regulator-3p0@20c8120 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               regulator-2p5@20c8130 {
-                                       reg = <0x20c8130>;
+                               regulator-2p5 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd2p5";
                                        regulator-min-microvolt = <2100000>;
@@ -637,8 +633,7 @@ regulator-2p5@20c8130 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               reg_arm: regulator-vddcore@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_arm: regulator-vddcore {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddarm";
                                        regulator-min-microvolt = <725000>;
@@ -655,8 +650,7 @@ reg_arm: regulator-vddcore@20c8140 {
                                        anatop-max-voltage = <1450000>;
                                };
 
-                               reg_pcie: regulator-vddpcie@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_pcie: regulator-vddpcie {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddpcie";
                                        regulator-min-microvolt = <725000>;
@@ -672,8 +666,7 @@ reg_pcie: regulator-vddpcie@20c8140 {
                                        anatop-max-voltage = <1450000>;
                                };
 
-                               reg_soc: regulator-vddsoc@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_soc: regulator-vddsoc {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddsoc";
                                        regulator-min-microvolt = <725000>;
index 6d720b20e7ed7d56b5447c44b1dd5fe3d6866920..2438669f149a2785b362c33f72c1710b66551bfe 100644 (file)
@@ -1,10 +1,6 @@
-/*
- * Copyright (C) 2015 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright (C) 2015 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 
index 921e12c69a002e52742b18abb358b57288d3a09e..cd99285511544cc7862dd27d1da71ecf28de1a0c 100644 (file)
@@ -153,8 +153,6 @@ sgtl5000: codec@a {
        stmpe811: gpio-expander@44 {
                compatible = "st,stmpe811";
                reg = <0x44>;
-               #address-cells = <1>;
-               #size-cells = <0>;
                pinctrl-names = "default";
                pinctrl-0 = <&pinctrl_stmpe>;
                interrupt-parent = <&gpio1>;
index 2d80f7b50bc03bce0ddc66d855ac4f8199644353..97686097a86ec50d51f8ac2ebc85f9eaeed7df89 100644 (file)
@@ -48,7 +48,7 @@ / {
        compatible = "karo,imx6ul-tx6ul", "fsl,imx6ul";
 
        aliases {
-               lcdif_24bit_pins_a = &pinctrl_disp0_3;
+               lcdif-24bit-pins-a = &pinctrl_disp0_3;
                mmc0 = &usdhc1;
                /delete-property/ mmc1;
                serial2 = &uart3;
index f678d18ad44ab2c31fd5da091e0a1c80ac08c565..02b5ba42cd5911cdc95f61987d0641aed6e37039 100644 (file)
@@ -53,10 +53,10 @@ aliases {
                i2c2 = &i2c1;
                i2c3 = &i2c3;
                i2c4 = &i2c4;
-               lcdif_23bit_pins_a = &pinctrl_disp0_1;
-               lcdif_24bit_pins_a = &pinctrl_disp0_2;
+               lcdif-23bit-pins-a = &pinctrl_disp0_1;
+               lcdif-24bit-pins-a = &pinctrl_disp0_2;
                pwm0 = &pwm5;
-               reg_can_xcvr = &reg_can_xcvr;
+               reg-can-xcvr = &reg_can_xcvr;
                serial2 = &uart5;
                serial4 = &uart3;
                spi0 = &ecspi2;
index 1241972b16ba5472dcb4e1e9cd935255266122cf..47a3453a4211fe2bebe5bb72c0d42ae370c66b43 100644 (file)
@@ -1,10 +1,6 @@
-/*
- * Copyright 2015 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright 2015 Freescale Semiconductor, Inc.
 
 #include <dt-bindings/clock/imx6ul-clock.h>
 #include <dt-bindings/gpio/gpio.h>
@@ -551,11 +547,8 @@ anatop: anatop@20c8000 {
                                interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
                                             <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
                                             <GIC_SPI 127 IRQ_TYPE_LEVEL_HIGH>;
-                               #address-cells = <1>;
-                               #size-cells = <0>;
 
-                               reg_3p0: regulator-3p0@20c8110 {
-                                       reg = <0x20c8110>;
+                               reg_3p0: regulator-3p0 {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd3p0";
                                        regulator-min-microvolt = <2625000>;
@@ -569,8 +562,7 @@ reg_3p0: regulator-3p0@20c8110 {
                                        anatop-enable-bit = <0>;
                                };
 
-                               reg_arm: regulator-vddcore@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_arm: regulator-vddcore {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "cpu";
                                        regulator-min-microvolt = <725000>;
@@ -587,8 +579,7 @@ reg_arm: regulator-vddcore@20c8140 {
                                        anatop-max-voltage = <1450000>;
                                };
 
-                               reg_soc: regulator-vddsoc@20c8140 {
-                                       reg = <0x20c8140>;
+                               reg_soc: regulator-vddsoc {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vddsoc";
                                        regulator-min-microvolt = <725000>;
@@ -769,6 +760,36 @@ aips2: aips-bus@2100000 {
                        reg = <0x02100000 0x100000>;
                        ranges;
 
+                       crypto: caam@2140000 {
+                               compatible = "fsl,imx6ul-caam", "fsl,sec-v4.0";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+                               reg = <0x2140000 0x3c000>;
+                               ranges = <0 0x2140000 0x3c000>;
+                               interrupts = <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>;
+                               clocks = <&clks IMX6UL_CLK_CAAM_IPG>, <&clks IMX6UL_CLK_CAAM_ACLK>,
+                                        <&clks IMX6UL_CLK_CAAM_MEM>;
+                               clock-names = "ipg", "aclk", "mem";
+
+                               sec_jr0: jr0@1000 {
+                                       compatible = "fsl,sec-v4.0-job-ring";
+                                       reg = <0x1000 0x1000>;
+                                       interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
+                               };
+
+                               sec_jr1: jr1@2000 {
+                                       compatible = "fsl,sec-v4.0-job-ring";
+                                       reg = <0x2000 0x1000>;
+                                       interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+                               };
+
+                               sec_jr2: jr2@3000 {
+                                       compatible = "fsl,sec-v4.0-job-ring";
+                                       reg = <0x3000 0x1000>;
+                                       interrupts = <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>;
+                               };
+                       };
+
                        usbotg1: usb@2184000 {
                                compatible = "fsl,imx6ul-usb", "fsl,imx27-usb";
                                reg = <0x02184000 0x200>;
index 11820233669125731432a8f4f688159ce1e0607e..fdc46bb09cc1afe647ac2e931caace08f0e0655b 100644 (file)
  * The pin function ID is a tuple of
  * <mux_reg conf_reg input_reg mux_mode input_val>
  */
+#define MX6ULL_PAD_UART1_TX_DATA__UART5_DTE_RX                    0x0084 0x0310 0x0644 0x9 0x4
+#define MX6ULL_PAD_UART1_RX_DATA__UART5_DCE_RX                    0x0088 0x0314 0x0644 0x9 0x5
+#define MX6ULL_PAD_UART1_CTS_B__UART5_DCE_RTS                     0x008C 0x0318 0x0640 0x9 0x3
+#define MX6ULL_PAD_UART1_RTS_B__UART5_DTE_RTS                     0x0090 0x031C 0x0640 0x9 0x4
+#define MX6ULL_PAD_UART5_TX_DATA__UART5_DTE_RX                    0x00BC 0x0348 0x0644 0x0 0x6
+#define MX6ULL_PAD_UART5_RX_DATA__UART5_DCE_RX                    0x00C0 0x034C 0x0644 0x0 0x7
+#define MX6ULL_PAD_ENET1_RX_EN__UART5_DCE_RTS                     0x00CC 0x0358 0x0640 0x1 0x5
+#define MX6ULL_PAD_ENET1_TX_DATA0__UART5_DTE_RTS                  0x00D0 0x035C 0x0640 0x1 0x6
 #define MX6ULL_PAD_ENET2_RX_DATA0__EPDC_SDDO08                    0x00E4 0x0370 0x0000 0x9 0x0
 #define MX6ULL_PAD_ENET2_RX_DATA1__EPDC_SDDO09                    0x00E8 0x0374 0x0000 0x9 0x0
 #define MX6ULL_PAD_ENET2_RX_EN__EPDC_SDDO10                       0x00EC 0x0378 0x0000 0x9 0x0
@@ -47,6 +55,7 @@
 #define MX6ULL_PAD_CSI_DATA00__ESAI_TX_HF_CLK                     0x01E4 0x0470 0x0000 0x9 0x0
 #define MX6ULL_PAD_CSI_DATA01__ESAI_RX_HF_CLK                     0x01E8 0x0474 0x0000 0x9 0x0
 #define MX6ULL_PAD_CSI_DATA02__ESAI_RX_FS                         0x01EC 0x0478 0x0000 0x9 0x0
+#define MX6ULL_PAD_CSI_DATA02__UART5_DCE_RTS                      0x01EC 0x0478 0x0640 0x8 0x7
 #define MX6ULL_PAD_CSI_DATA03__ESAI_RX_CLK                        0x01F0 0x047C 0x0000 0x9 0x0
 #define MX6ULL_PAD_CSI_DATA04__ESAI_TX_FS                         0x01F4 0x0480 0x0000 0x9 0x0
 #define MX6ULL_PAD_CSI_DATA05__ESAI_TX_CLK                        0x01F8 0x0484 0x0000 0x9 0x0
index 571ddd71cdba834c7ed3ffdf3e5c852e83b2d802..ebc25c98e5e141382e6dde0e90cc8e78af1fb553 100644 (file)
@@ -45,6 +45,8 @@
 
 /* Delete UART8 in AIPS-1 (i.MX6UL specific) */
 /delete-node/ &uart8;
+/* Delete CAAM node in AIPS-2 (i.MX6UL specific) */
+/delete-node/ &crypto;
 
 / {
        soc {
index 7f645683f53b0951d220ed5ab45224e9f70d5633..8bf365d28cacfd3731648922e705b011cb81b7b1 100644 (file)
@@ -33,7 +33,7 @@ reg_usb_otg1_vbus: regulator-vbus {
 };
 
 &cpu0 {
-       arm-supply = <&sw1a_reg>;
+       cpu-supply = <&sw1a_reg>;
 };
 
 &fec1 {
index 52167298984d72e387741cb2a49f2b9db8226016..70c53e50b2fcd2cd9cc4d1cfb91d43faa1dd588c 100644 (file)
@@ -49,8 +49,8 @@ / {
        compatible = "boundary,imx7d-nitrogen7", "fsl,imx7d";
 
        aliases {
-               fb_lcd = &lcdif;
-               t_lcd = &t_lcd;
+               fb-lcd = &lcdif;
+               t-lcd = &t_lcd;
        };
 
        memory@80000000 {
@@ -144,7 +144,7 @@ &clks {
 };
 
 &cpu0 {
-       arm-supply = <&sw1a_reg>;
+       cpu-supply = <&sw1a_reg>;
 };
 
 &fec1 {
index f2493bc63da42b2d82875e9399141c2f806f34f9..aa9dbead4b8b9373569fa2c41b444a6c7b8ad916 100644 (file)
 #define MX7D_PAD_UART2_RX_DATA__UART2_DCE_RX                      0x0130 0x03A0 0x06FC 0x0 0x2
 #define MX7D_PAD_UART2_RX_DATA__UART2_DTE_TX                      0x0130 0x03A0 0x0000 0x0 0x0
 #define MX7D_PAD_UART2_RX_DATA__I2C2_SCL                          0x0130 0x03A0 0x05DC 0x1 0x0
-#define MX7D_PAD_UART2_RX_DATA__SAI3_RX_BCLK                      0x0130 0x03A0 0x0000 0x2 0x0
+#define MX7D_PAD_UART2_RX_DATA__SAI3_RX_BCLK                      0x0130 0x03A0 0x06C4 0x2 0x0
 #define MX7D_PAD_UART2_RX_DATA__ECSPI1_SS3                        0x0130 0x03A0 0x0000 0x3 0x0
 #define MX7D_PAD_UART2_RX_DATA__ENET2_1588_EVENT1_IN              0x0130 0x03A0 0x0000 0x4 0x0
 #define MX7D_PAD_UART2_RX_DATA__GPIO4_IO2                         0x0130 0x03A0 0x0000 0x5 0x0
 #define MX7D_PAD_ENET1_RGMII_TD3__GPIO7_IO9                       0x0250 0x04C0 0x0000 0x5 0x0
 #define MX7D_PAD_ENET1_RGMII_TD3__CAAM_RNG_OSC_OBS                0x0250 0x04C0 0x0000 0x7 0x0
 #define MX7D_PAD_ENET1_RGMII_TX_CTL__ENET1_RGMII_TX_CTL           0x0254 0x04C4 0x0000 0x0 0x0
-#define MX7D_PAD_ENET1_RGMII_TX_CTL__SAI1_RX_SYNC                 0x0254 0x04C4 0x0000 0x2 0x0
+#define MX7D_PAD_ENET1_RGMII_TX_CTL__SAI1_RX_SYNC                 0x0254 0x04C4 0x06A4 0x2 0x1
 #define MX7D_PAD_ENET1_RGMII_TX_CTL__GPT2_COMPARE1                0x0254 0x04C4 0x0000 0x3 0x0
 #define MX7D_PAD_ENET1_RGMII_TX_CTL__EPDC_PWR_CTRL2               0x0254 0x04C4 0x0000 0x4 0x0
 #define MX7D_PAD_ENET1_RGMII_TX_CTL__GPIO7_IO10                   0x0254 0x04C4 0x0000 0x5 0x0
 #define MX7D_PAD_ENET1_RGMII_TXC__ENET1_RGMII_TXC                 0x0258 0x04C8 0x0000 0x0 0x0
 #define MX7D_PAD_ENET1_RGMII_TXC__ENET1_TX_ER                     0x0258 0x04C8 0x0000 0x1 0x0
-#define MX7D_PAD_ENET1_RGMII_TXC__SAI1_RX_BCLK                    0x0258 0x04C8 0x0000 0x2 0x0
+#define MX7D_PAD_ENET1_RGMII_TXC__SAI1_RX_BCLK                    0x0258 0x04C8 0x069C 0x2 0x1
 #define MX7D_PAD_ENET1_RGMII_TXC__GPT2_COMPARE2                   0x0258 0x04C8 0x0000 0x3 0x0
 #define MX7D_PAD_ENET1_RGMII_TXC__EPDC_PWR_CTRL3                  0x0258 0x04C8 0x0000 0x4 0x0
 #define MX7D_PAD_ENET1_RGMII_TXC__GPIO7_IO11                      0x0258 0x04C8 0x0000 0x5 0x0
index 64a20ed1713ad6f4caf638e90b1646779887e929..996555596d4026395ba1ad3d4c805c5843719b4b 100644 (file)
@@ -1,44 +1,6 @@
-/*
- * Copyright (C) 2015 Freescale Semiconductor, Inc.
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file 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 file 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.
- *
- * Or, alternatively,
- *
- *  b) 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.
- */
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+//
+// Copyright (C) 2015 Freescale Semiconductor, Inc.
 
 #include "imx7d-sdb.dts"
 
index 5d6a08be397f211c82eddbb9cef1bf0da1b462a8..9408491631042d4adc816f7f9dec1c0b87a9aa23 100644 (file)
@@ -1,44 +1,6 @@
-/*
- * Copyright (C) 2015 Freescale Semiconductor, Inc.
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file 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 file 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.
- *
- * Or, alternatively,
- *
- *  b) 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.
- */
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+//
+// Copyright (C) 2015 Freescale Semiconductor, Inc.
 
 /dts-v1/;
 
@@ -52,6 +14,24 @@ memory@80000000 {
                reg = <0x80000000 0x80000000>;
        };
 
+       gpio-keys {
+               compatible = "gpio-keys";
+               pinctrl-names = "default";
+               pinctrl-0 = <&pinctrl_gpio_keys>;
+
+               volume-up {
+                       label = "Volume Up";
+                       gpios = <&gpio5 11 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_VOLUMEUP>;
+               };
+
+               volume-down {
+                       label = "Volume Down";
+                       gpios = <&gpio5 10 GPIO_ACTIVE_LOW>;
+                       linux,code = <KEY_VOLUMEDOWN>;
+               };
+       };
+
        spi4 {
                compatible = "spi-gpio";
                pinctrl-names = "default";
@@ -161,7 +141,7 @@ &adc2 {
 };
 
 &cpu0 {
-       arm-supply = <&sw1a_reg>;
+       cpu-supply = <&sw1a_reg>;
 };
 
 &ecspi3 {
@@ -519,6 +499,12 @@ MX7D_PAD_EPDC_DATA14__GPIO2_IO14   0x59    /* CAN_STBY */
                        >;
                };
 
+               pinctrl_gpio_keys: gpio_keysgrp {
+                       fsl,pins = <
+                               MX7D_PAD_SD2_RESET_B__GPIO5_IO11        0x59
+                               MX7D_PAD_SD2_WP__GPIO5_IO10             0x59
+                       >;
+               };
 
                pinctrl_hog: hoggrp {
                        fsl,pins = <
index d74dd7f19507269d8cc598a02871d713c9ff7d89..8d3d123d0a5c679c5fecd7ca756c9cd4d76ef727 100644 (file)
@@ -1,45 +1,7 @@
-/*
- * Copyright 2015 Freescale Semiconductor, Inc.
- * Copyright 2016 Toradex AG
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file 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 file 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.
- *
- * Or, alternatively,
- *
- *  b) 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.
- */
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+//
+// Copyright 2015 Freescale Semiconductor, Inc.
+// Copyright 2016 Toradex AG
 
 #include "imx7s.dtsi"
 #include <dt-bindings/reset/imx7-reset.h>
@@ -47,12 +9,8 @@
 / {
        cpus {
                cpu0: cpu@0 {
-                       operating-points = <
-                               /* KHz  uV */
-                               996000  1075000
-                               792000  975000
-                       >;
                        clock-frequency = <996000000>;
+                       operating-points-v2 = <&cpu0_opp_table>;
                };
 
                cpu1: cpu@1 {
@@ -60,6 +18,25 @@ cpu1: cpu@1 {
                        device_type = "cpu";
                        reg = <1>;
                        clock-frequency = <996000000>;
+                       operating-points-v2 = <&cpu0_opp_table>;
+               };
+       };
+
+       cpu0_opp_table: opp-table {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp-792000000 {
+                       opp-hz = /bits/ 64 <792000000>;
+                       opp-microvolt = <975000>;
+                       clock-latency-ns = <150000>;
+               };
+
+               opp-996000000 {
+                       opp-hz = /bits/ 64 <996000000>;
+                       opp-microvolt = <1075000>;
+                       clock-latency-ns = <150000>;
+                       opp-suspend;
                };
        };
 
index 8a30b148534d08774494fe0cca83b23b9d2f7d59..fa390da636de761fabe196c9c16e2b41b26ba41d 100644 (file)
@@ -113,10 +113,6 @@ &clks {
        assigned-clock-rates = <884736000>;
 };
 
-&cpu0 {
-       arm-supply = <&sw1a_reg>;
-};
-
 &i2c1 {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_i2c1>;
index 69436b9a404cd0b91e2e3c62a0993937ef021d0a..9ced589bfa9623cc7ee16ea50d0d7f6ad55b2a1f 100644 (file)
@@ -1,45 +1,7 @@
-/*
- * Copyright 2015 Freescale Semiconductor, Inc.
- * Copyright 2016 Toradex AG
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPL or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This file 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 file 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.
- *
- * Or, alternatively,
- *
- *  b) 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.
- */
+// SPDX-License-Identifier: GPL-2.0+ OR MIT
+//
+// Copyright 2015 Freescale Semiconductor, Inc.
+// Copyright 2016 Toradex AG
 
 #include <dt-bindings/clock/imx7d-clock.h>
 #include <dt-bindings/power/imx7-power.h>
@@ -173,6 +135,17 @@ replicator_in_port0: endpoint {
                };
        };
 
+       tempmon: tempmon {
+               compatible = "fsl,imx7d-tempmon";
+               interrupt-parent = <&gpc>;
+               interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
+               fsl,tempmon =<&anatop>;
+               nvmem-cells = <&tempmon_calib>,
+                       <&tempmon_temp_grade>;
+               nvmem-cell-names = "calib", "temp_grade";
+               clocks = <&clks IMX7D_PLL_SYS_MAIN_CLK>;
+       };
+
        timer {
                compatible = "arm,armv7-timer";
                interrupt-parent = <&intc>;
@@ -321,7 +294,7 @@ tpiu@30087000 {
                        port {
                                tpiu_in_port: endpoint {
                                        slave-mode;
-                                       remote-endpoint = <&replicator_out_port1>;
+                                       remote-endpoint = <&replicator_out_port0>;
                                };
                        };
                };
@@ -540,27 +513,14 @@ tempmon_temp_grade: temp-grade@10 {
                                };
                        };
 
-                       tempmon: tempmon {
-                               compatible = "fsl,imx7d-tempmon";
-                               interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>;
-                               fsl,tempmon =<&anatop>;
-                               nvmem-cells = <&tempmon_calib>,
-                                       <&tempmon_temp_grade>;
-                               nvmem-cell-names = "calib", "temp_grade";
-                               clocks = <&clks IMX7D_PLL_SYS_MAIN_CLK>;
-                       };
-
                        anatop: anatop@30360000 {
                                compatible = "fsl,imx7d-anatop", "fsl,imx6q-anatop",
                                        "syscon", "simple-bus";
                                reg = <0x30360000 0x10000>;
                                interrupts = <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
                                        <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>;
-                               #address-cells = <1>;
-                               #size-cells = <0>;
 
-                               reg_1p0d: regulator-vdd1p0d@30360210 {
-                                       reg = <0x30360210>;
+                               reg_1p0d: regulator-vdd1p0d {
                                        compatible = "fsl,anatop-regulator";
                                        regulator-name = "vdd1p0d";
                                        regulator-min-microvolt = <800000>;
@@ -573,6 +533,20 @@ reg_1p0d: regulator-vdd1p0d@30360210 {
                                        anatop-max-voltage = <1200000>;
                                        anatop-enable-bit = <0>;
                                };
+
+                               reg_1p2: regulator-vdd1p2 {
+                                       compatible = "fsl,anatop-regulator";
+                                       regulator-name = "vdd1p2";
+                                       regulator-min-microvolt = <1100000>;
+                                       regulator-max-microvolt = <1300000>;
+                                       anatop-reg-offset = <0x220>;
+                                       anatop-vol-bit-shift = <8>;
+                                       anatop-vol-bit-width = <5>;
+                                       anatop-min-bit-val = <0x14>;
+                                       anatop-min-voltage = <1100000>;
+                                       anatop-max-voltage = <1300000>;
+                                       anatop-enable-bit = <0>;
+                               };
                        };
 
                        snvs: snvs@30370000 {
index 6a4657799b99f055b3c13c9b6cc19086121a439d..154fdd7a7022c982701db26bc23c012669996ac7 100644 (file)
@@ -114,6 +114,20 @@ K2G_CORE_IOPAD(0x11ec) (BUFFER_CLASS_B | PULL_DISABLE | MUX_MODE0)      /* uart2
                        K2G_CORE_IOPAD(0x11f0) (BUFFER_CLASS_B | PIN_PULLDOWN | MUX_MODE0)      /* uart2_txd.uart2_txd */
                >;
        };
+
+       dcan0_pins: pinmux_dcan0_pins {
+               pinctrl-single,pins = <
+                       K2G_CORE_IOPAD(0x11fc) (BUFFER_CLASS_B | PULL_DISABLE  | MUX_MODE0)     /* dcan0tx.dcan0tx */
+                       K2G_CORE_IOPAD(0x1200) (BUFFER_CLASS_B | PIN_PULLDOWN  | MUX_MODE0)     /* dcan0rx.dcan0rx */
+               >;
+       };
+
+       dcan1_pins: pinmux_dcan1_pins {
+               pinctrl-single,pins = <
+                       K2G_CORE_IOPAD(0x1224) (BUFFER_CLASS_B | PULL_DISABLE  | MUX_MODE1)     /* qspicsn2.dcan1tx */
+                       K2G_CORE_IOPAD(0x1228) (BUFFER_CLASS_B | PIN_PULLDOWN  | MUX_MODE1)     /* qspicsn3.dcan1rx */
+               >;
+       };
 };
 
 &uart0 {
@@ -268,3 +282,15 @@ &uart2 {
        pinctrl-0 = <&uart2_pins>;
        status = "okay";
 };
+
+&dcan0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&dcan0_pins>;
+       status = "okay";
+};
+
+&dcan1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&dcan1_pins>;
+       status = "okay";
+};
index 6fa7bba3e801508fde024cac085e0d9f7b43e96c..3bb28c03ca74efb92caf73f06b01cd8428ba6828 100644 (file)
@@ -35,6 +35,13 @@ hsusb2_phy: hsusb2_phy {
                reset-gpios = <&gpio1 4 GPIO_ACTIVE_LOW>; /* gpio_4 */
                #phy-cells = <0>;
        };
+
+       /* fixed 26MHz oscillator */
+       hfclk_26m: oscillator {
+               #clock-cells = <0>;
+               compatible = "fixed-clock";
+               clock-frequency = <26000000>;
+       };
 };
 
 &gpmc {
@@ -79,6 +86,8 @@ twl: twl@48 {
                reg = <0x48>;
                interrupts = <7>; /* SYS_NIRQ cascaded to intc */
                interrupt-parent = <&intc>;
+               clocks = <&hfclk_26m>;
+               clock-names = "fck";
                twl_audio: audio {
                        compatible = "ti,twl4030-audio";
                        codec {
@@ -98,6 +107,25 @@ &i2c3 {
        pinctrl-names = "default";
        pinctrl-0 = <&i2c3_pins>;
        clock-frequency = <400000>;
+
+       touchscreen: tsc2004@48 {
+               compatible = "ti,tsc2004";
+               reg = <0x48>;
+               vio-supply = <&vaux1>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&tsc2004_pins>;
+               interrupts-extended = <&gpio5 25 IRQ_TYPE_EDGE_RISING>; /* gpio 153 */
+
+               touchscreen-fuzz-x = <4>;
+               touchscreen-fuzz-y = <7>;
+               touchscreen-fuzz-pressure = <2>;
+               touchscreen-size-x = <4096>;
+               touchscreen-size-y = <4096>;
+               touchscreen-max-pressure = <2048>;
+
+               ti,x-plate-ohms = <280>;
+               ti,esd-recovery-timeout-ms = <8000>;
+       };
 };
 
 &mmc3 {
@@ -203,6 +231,12 @@ OMAP3_CORE1_IOPAD(0x21bc, PIN_INPUT | MUX_MODE0)        /* i2c1_sda.i2c1_sda */
                        OMAP3_CORE1_IOPAD(0x20ba, PIN_OUTPUT | MUX_MODE4)        /* gpmc_ncs6.gpio_57 */
                >;
        };
+
+       tsc2004_pins: pinmux_tsc2004_pins {
+               pinctrl-single,pins = <
+                       OMAP3_CORE1_IOPAD(0x2186, PIN_INPUT | MUX_MODE4)        /* mcbsp4_dr.gpio_153 */
+               >;
+       };
 };
 
 &omap3_pmx_wkup {
index 3e174e474d3d03f56d4df44d0762a4170b07785d..7d2302e8706c969f5ba4da112b206f54baa5cf44 100644 (file)
@@ -30,6 +30,13 @@ user0 {
                        linux,default-trigger = "none";
                };
        };
+
+       /* fixed 26MHz oscillator */
+       hfclk_26m: oscillator {
+               #clock-cells = <0>;
+               compatible = "fixed-clock";
+               clock-frequency = <26000000>;
+       };
 };
 
 &gpmc {
@@ -74,6 +81,9 @@ twl: twl@48 {
                reg = <0x48>;
                interrupts = <7>; /* SYS_NIRQ cascaded to intc */
                interrupt-parent = <&intc>;
+               clocks = <&hfclk_26m>;
+               clock-names = "fck";
+
                twl_audio: audio {
                        compatible = "ti,twl4030-audio";
                        codec {
index dcc9292d2ffaa055d388f0b6291752ad62bd5d5d..d77dcf890cfc82b5c05c88149694f8687e14072c 100644 (file)
@@ -57,7 +57,7 @@ cpus {
                #address-cells = <1>;
                #size-cells = <0>;
 
-               cpu@200 {
+               cpu0: cpu@200 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        next-level-cache = <&L2>;
@@ -66,7 +66,7 @@ cpu@200 {
                        resets = <&clkc CLKC_RESET_CPU0_SOFT_RESET>;
                };
 
-               cpu@201 {
+               cpu1: cpu@201 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        next-level-cache = <&L2>;
@@ -75,7 +75,7 @@ cpu@201 {
                        resets = <&clkc CLKC_RESET_CPU1_SOFT_RESET>;
                };
 
-               cpu@202 {
+               cpu2: cpu@202 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        next-level-cache = <&L2>;
@@ -84,7 +84,7 @@ cpu@202 {
                        resets = <&clkc CLKC_RESET_CPU2_SOFT_RESET>;
                };
 
-               cpu@203 {
+               cpu3: cpu@203 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        next-level-cache = <&L2>;
@@ -94,6 +94,15 @@ cpu@203 {
                };
        };
 
+       pmu {
+               compatible = "arm,cortex-a9-pmu";
+               interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+       };
+
        reserved-memory {
                #address-cells = <1>;
                #size-cells = <1>;
@@ -272,6 +281,22 @@ mux {
                                function = "pwm_e";
                        };
                };
+
+               uart_a1_pins: uart-a1 {
+                       mux {
+                               groups = "uart_tx_a1",
+                                      "uart_rx_a1";
+                               function = "uart_a";
+                       };
+               };
+
+               uart_a1_cts_rts_pins: uart-a1-cts-rts {
+                       mux {
+                               groups = "uart_cts_a1",
+                                      "uart_rts_a1";
+                               function = "uart_a";
+                       };
+               };
        };
 };
 
index 3a5603d95b70303cb96820e6532fc4e3735572f9..ef3177d3da3dc85d5cb2d2d786a59d368c4189cd 100644 (file)
@@ -103,10 +103,34 @@ tf_io: gpio-regulator-tf_io {
        };
 };
 
-&uart_AO {
+&ethmac {
        status = "okay";
-       pinctrl-0 = <&uart_ao_a_pins>;
+
+       snps,reset-gpio = <&gpio GPIOH_4 GPIO_ACTIVE_HIGH>;
+       snps,reset-active-low;
+       snps,reset-delays-us = <0 10000 30000>;
+
+       pinctrl-0 = <&eth_rgmii_pins>;
        pinctrl-names = "default";
+
+       phy-mode = "rgmii";
+       phy-handle = <&eth_phy>;
+       amlogic,tx-delay-ns = <4>;
+
+       mdio {
+               compatible = "snps,dwmac-mdio";
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               /* Realtek RTL8211F (0x001cc916) */
+               eth_phy: ethernet-phy@0 {
+                       reg = <0>;
+                       eee-broken-1000t;
+                       interrupt-parent = <&gpio_intc>;
+                       /* GPIOH_3 */
+                       interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
+               };
+       };
 };
 
 &gpio_ao {
@@ -124,12 +148,10 @@ usb-hub {
        };
 };
 
-&usb1_phy {
-       status = "okay";
-};
-
-&usb1 {
+&ir_receiver {
        status = "okay";
+       pinctrl-0 = <&ir_recv_pins>;
+       pinctrl-names = "default";
 };
 
 &sdio {
@@ -158,32 +180,16 @@ sd_card_slot: slot@1 {
        };
 };
 
-&ethmac {
+&uart_AO {
        status = "okay";
-
-       snps,reset-gpio = <&gpio GPIOH_4 GPIO_ACTIVE_HIGH>;
-       snps,reset-active-low;
-       snps,reset-delays-us = <0 10000 30000>;
-
-       pinctrl-0 = <&eth_rgmii_pins>;
+       pinctrl-0 = <&uart_ao_a_pins>;
        pinctrl-names = "default";
+};
 
-       phy-mode = "rgmii";
-       phy-handle = <&eth_phy>;
-       amlogic,tx-delay-ns = <4>;
-
-       mdio {
-               compatible = "snps,dwmac-mdio";
-               #address-cells = <1>;
-               #size-cells = <0>;
+&usb1_phy {
+       status = "okay";
+};
 
-               /* Realtek RTL8211F (0x001cc916) */
-               eth_phy: ethernet-phy@0 {
-                       reg = <0>;
-                       eee-broken-1000t;
-                       interrupt-parent = <&gpio_intc>;
-                       /* GPIOH_3 */
-                       interrupts = <17 IRQ_TYPE_LEVEL_LOW>;
-               };
-       };
+&usb1 {
+       status = "okay";
 };
index 553b82174604eb207c1d877553ef8600e2229c0f..08f7f6be7254e5e54e0f9bd5ff6790fbfa108dea 100644 (file)
@@ -55,7 +55,7 @@ cpus {
                #address-cells = <1>;
                #size-cells = <0>;
 
-               cpu@200 {
+               cpu0: cpu@200 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a5";
                        next-level-cache = <&L2>;
@@ -64,7 +64,7 @@ cpu@200 {
                        resets = <&clkc CLKC_RESET_CPU0_SOFT_RESET>;
                };
 
-               cpu@201 {
+               cpu1: cpu@201 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a5";
                        next-level-cache = <&L2>;
@@ -73,7 +73,7 @@ cpu@201 {
                        resets = <&clkc CLKC_RESET_CPU1_SOFT_RESET>;
                };
 
-               cpu@202 {
+               cpu2: cpu@202 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a5";
                        next-level-cache = <&L2>;
@@ -82,7 +82,7 @@ cpu@202 {
                        resets = <&clkc CLKC_RESET_CPU2_SOFT_RESET>;
                };
 
-               cpu@203 {
+               cpu3: cpu@203 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a5";
                        next-level-cache = <&L2>;
@@ -92,6 +92,15 @@ cpu@203 {
                };
        };
 
+       pmu {
+               compatible = "arm,cortex-a5-pmu";
+               interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>,
+                            <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+       };
+
        reserved-memory {
                #address-cells = <1>;
                #size-cells = <1>;
@@ -139,6 +148,13 @@ mux {
                                function = "uart_ao";
                        };
                };
+
+               ir_recv_pins: remote {
+                       mux {
+                               groups = "remote_input";
+                               function = "remote";
+                       };
+               };
        };
 };
 
diff --git a/arch/arm/boot/dts/meson8m2-mxiii-plus.dts b/arch/arm/boot/dts/meson8m2-mxiii-plus.dts
new file mode 100644 (file)
index 0000000..f585361
--- /dev/null
@@ -0,0 +1,244 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2018 Oleg Ivanov <balbes-150@yandex.ru>
+ * Copyright (c) 2018 Martin Blumenstingl <martin.blumenstingl@googlemail.com>
+ */
+
+/dts-v1/;
+
+#include "meson8m2.dtsi"
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       model = "Tronsmart MXIII Plus";
+       compatible = "tronsmart,mxiii-plus", "amlogic,meson8m2";
+
+       aliases {
+               ethernet0 = &ethmac;
+               i2c0 = &i2c_AO;
+               serial0 = &uart_AO;
+               serial1 = &uart_A;
+               mmc0 = &sd_card_slot;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       memory {
+               reg = <0x40000000 0x80000000>;
+       };
+
+       adc-keys {
+               compatible = "adc-keys";
+               io-channels = <&saradc 0>;
+               io-channel-names = "buttons";
+               keyup-threshold-microvolt = <1710000>;
+
+               button-function {
+                       label = "Function";
+                       linux,code = <KEY_FN>;
+                       press-threshold-microvolt = <10000>;
+               };
+       };
+
+       vcc_3v3: regulator-vcc3v3 {
+               compatible = "regulator-fixed";
+               regulator-name = "VCC3V3";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+       };
+};
+
+&cpu0 {
+       cpu-supply = <&vcck>;
+};
+
+&ethmac {
+       status = "okay";
+
+       pinctrl-0 = <&eth_rgmii_pins>;
+       pinctrl-names = "default";
+
+       phy-handle = <&eth_phy0>;
+       phy-mode = "rgmii";
+
+       amlogic,tx-delay-ns = <4>;
+
+       snps,reset-gpio = <&gpio GPIOH_4 0>;
+       snps,reset-delays-us = <0 10000 1000000>;
+       snps,reset-active-low;
+
+       mdio {
+               compatible = "snps,dwmac-mdio";
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               eth_phy0: ethernet-phy@0 {
+                       /* Realtek RTL8211F (0x001cc916) */
+                       reg = <0>;
+               };
+       };
+};
+
+&ir_receiver {
+       status = "okay";
+       pinctrl-0 = <&ir_recv_pins>;
+       pinctrl-names = "default";
+};
+
+&i2c_AO {
+       status = "okay";
+       pinctrl-0 = <&i2c_ao_pins>;
+       pinctrl-names = "default";
+
+       pmic@32 {
+               compatible = "ricoh,rn5t618";
+               reg = <0x32>;
+               system-power-controller;
+
+               regulators {
+                       vcck: DCDC1 {
+                               regulator-name = "VCCK";
+                               regulator-min-microvolt = <825000>;
+                               regulator-max-microvolt = <1150000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       DCDC2 {
+                               regulator-name = "VDDAO";
+                               regulator-min-microvolt = <950000>;
+                               regulator-max-microvolt = <1150000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       DCDC3 {
+                               regulator-name = "VDD_DDR";
+                               regulator-min-microvolt = <1500000>;
+                               regulator-max-microvolt = <1500000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       LDO1 {
+                               regulator-name = "VDDIO_AO28";
+                               regulator-min-microvolt = <2900000>;
+                               regulator-max-microvolt = <2900000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       vddio_ao1v8: LDO2 {
+                               regulator-name = "VDDIO_AO18";
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <1800000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       LDO3 {
+                               regulator-name = "VCC1V8";
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <1800000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       LDO4 {
+                               regulator-name = "VCC2V8";
+                               regulator-min-microvolt = <2850000>;
+                               regulator-max-microvolt = <2850000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       LDO5 {
+                               regulator-name = "AVDD1V8";
+                               regulator-min-microvolt = <1800000>;
+                               regulator-max-microvolt = <1800000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       LDORTC1 {
+                               regulator-name = "VDD_LDO";
+                               regulator-min-microvolt = <2700000>;
+                               regulator-max-microvolt = <2700000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+
+                       LDORTC2 {
+                               regulator-name = "RTC_0V9";
+                               regulator-min-microvolt = <900000>;
+                               regulator-max-microvolt = <900000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+               };
+       };
+};
+
+&saradc {
+       status = "okay";
+       vref-supply = <&vddio_ao1v8>;
+};
+
+&sdio {
+       status = "okay";
+
+       pinctrl-0 = <&sd_b_pins>;
+       pinctrl-names = "default";
+
+       /* SD card */
+       sd_card_slot: slot@1 {
+               compatible = "mmc-slot";
+               reg = <1>;
+               status = "okay";
+
+               bus-width = <4>;
+               no-sdio;
+               cap-mmc-highspeed;
+               cap-sd-highspeed;
+               disable-wp;
+
+               cd-gpios = <&gpio CARD_6 GPIO_ACTIVE_HIGH>;
+               cd-inverted;
+
+               vmmc-supply = <&vcc_3v3>;
+       };
+};
+
+/* connected to the Bluetooth module */
+&uart_A {
+       status = "okay";
+       pinctrl-0 = <&uart_a1_pins>, <&uart_a1_cts_rts_pins>;
+       pinctrl-names = "default";
+       uart-has-rtscts;
+};
+
+&uart_AO {
+       status = "okay";
+       pinctrl-0 = <&uart_ao_a_pins>;
+       pinctrl-names = "default";
+};
+
+&usb0 {
+       status = "okay";
+};
+
+&usb1 {
+       status = "okay";
+};
+
+&usb0_phy {
+       status = "okay";
+};
+
+&usb1_phy {
+       status = "okay";
+};
diff --git a/arch/arm/boot/dts/meson8m2.dtsi b/arch/arm/boot/dts/meson8m2.dtsi
new file mode 100644 (file)
index 0000000..3e1f922
--- /dev/null
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Martin Blumenstingl <martin.blumenstingl@googlemail.com>.
+ */
+
+#include "meson8.dtsi"
+
+/ {
+       model = "Amlogic Meson8m2 SoC";
+       compatible = "amlogic,meson8m2";
+}; /* end of / */
+
+&clkc {
+       compatible = "amlogic,meson8m2-clkc", "amlogic,meson8-clkc";
+};
+
+&ethmac {
+       compatible = "amlogic,meson8m2-dwmac", "snps,dwmac";
+       reg = <0xc9410000 0x10000
+               0xc1108140 0x8>;
+       clocks = <&clkc CLKID_ETH>,
+                <&clkc CLKID_MPLL2>,
+                <&clkc CLKID_MPLL2>;
+       clock-names = "stmmaceth", "clkin0", "clkin1";
+       resets = <&reset RESET_ETHERNET>;
+       reset-names = "stmmaceth";
+};
+
+&pinctrl_aobus {
+       compatible = "amlogic,meson8m2-aobus-pinctrl",
+                    "amlogic,meson8-aobus-pinctrl";
+};
+
+&pinctrl_cbus {
+       compatible = "amlogic,meson8m2-cbus-pinctrl",
+                    "amlogic,meson8-cbus-pinctrl";
+
+       eth_rgmii_pins: ethernet {
+               mux {
+                       groups = "eth_tx_clk_50m", "eth_tx_en",
+                                "eth_txd3", "eth_txd2",
+                                "eth_txd1", "eth_txd0",
+                                "eth_rx_clk_in", "eth_rx_dv",
+                                "eth_rxd3", "eth_rxd2",
+                                "eth_rxd1", "eth_rxd0",
+                                "eth_mdio", "eth_mdc";
+                       function = "ethernet";
+               };
+       };
+};
+
+&wdt {
+       compatible = "amlogic,meson8m2-wdt", "amlogic,meson8b-wdt";
+};
index 63af4b13a36f040c41d6d5d34f91d6a91d9c1b38..be0edb3dae6c6299a3a5cf9dd7b42117c3e6928f 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2015 MediaTek Inc.
  * Author: Erin Lo <erin.lo@mediatek.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.
  */
 
 /dts-v1/;
index 05557fce0f1d98a6e4f56dd5b6d643444635409b..180377e56ef49e437387b3cf536ecc0a5261618e 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2015 MediaTek Inc.
  * Author: Erin.Lo <erin.lo@mediatek.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.
  */
 
 #include <dt-bindings/clock/mt2701-clk.h>
@@ -426,104 +419,96 @@ spi2: spi@11017000 {
                status = "disabled";
        };
 
-       afe: audio-controller@11220000 {
-               compatible = "mediatek,mt2701-audio";
-               reg = <0 0x11220000 0 0x2000>,
-                     <0 0x112a0000 0 0x20000>;
-               interrupts =  <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>,
-                             <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>;
-               interrupt-names = "afe", "asys";
-               power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
-
-               clocks = <&infracfg CLK_INFRA_AUDIO>,
-                        <&topckgen CLK_TOP_AUD_MUX1_SEL>,
-                        <&topckgen CLK_TOP_AUD_MUX2_SEL>,
-                        <&topckgen CLK_TOP_AUD_MUX1_DIV>,
-                        <&topckgen CLK_TOP_AUD_MUX2_DIV>,
-                        <&topckgen CLK_TOP_AUD_48K_TIMING>,
-                        <&topckgen CLK_TOP_AUD_44K_TIMING>,
-                        <&topckgen CLK_TOP_AUDPLL_MUX_SEL>,
-                        <&topckgen CLK_TOP_APLL_SEL>,
-                        <&topckgen CLK_TOP_AUD1PLL_98M>,
-                        <&topckgen CLK_TOP_AUD2PLL_90M>,
-                        <&topckgen CLK_TOP_HADDS2PLL_98M>,
-                        <&topckgen CLK_TOP_HADDS2PLL_294M>,
-                        <&topckgen CLK_TOP_AUDPLL>,
-                        <&topckgen CLK_TOP_AUDPLL_D4>,
-                        <&topckgen CLK_TOP_AUDPLL_D8>,
-                        <&topckgen CLK_TOP_AUDPLL_D16>,
-                        <&topckgen CLK_TOP_AUDPLL_D24>,
-                        <&topckgen CLK_TOP_AUDINTBUS_SEL>,
-                        <&clk26m>,
-                        <&topckgen CLK_TOP_SYSPLL1_D4>,
-                        <&topckgen CLK_TOP_AUD_K1_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K2_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K3_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K4_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K5_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K6_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K1_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K2_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K3_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K4_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K5_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K6_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_I2S1_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S2_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S3_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S4_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S5_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S6_MCLK>,
-                        <&topckgen CLK_TOP_ASM_M_SEL>,
-                        <&topckgen CLK_TOP_ASM_H_SEL>,
-                        <&topckgen CLK_TOP_UNIVPLL2_D4>,
-                        <&topckgen CLK_TOP_UNIVPLL2_D2>,
-                        <&topckgen CLK_TOP_SYSPLL_D5>;
-
-               clock-names = "infra_sys_audio_clk",
-                        "top_audio_mux1_sel",
-                        "top_audio_mux2_sel",
-                        "top_audio_mux1_div",
-                        "top_audio_mux2_div",
-                        "top_audio_48k_timing",
-                        "top_audio_44k_timing",
-                        "top_audpll_mux_sel",
-                        "top_apll_sel",
-                        "top_aud1_pll_98M",
-                        "top_aud2_pll_90M",
-                        "top_hadds2_pll_98M",
-                        "top_hadds2_pll_294M",
-                        "top_audpll",
-                        "top_audpll_d4",
-                        "top_audpll_d8",
-                        "top_audpll_d16",
-                        "top_audpll_d24",
-                        "top_audintbus_sel",
-                        "clk_26m",
-                        "top_syspll1_d4",
-                        "top_aud_k1_src_sel",
-                        "top_aud_k2_src_sel",
-                        "top_aud_k3_src_sel",
-                        "top_aud_k4_src_sel",
-                        "top_aud_k5_src_sel",
-                        "top_aud_k6_src_sel",
-                        "top_aud_k1_src_div",
-                        "top_aud_k2_src_div",
-                        "top_aud_k3_src_div",
-                        "top_aud_k4_src_div",
-                        "top_aud_k5_src_div",
-                        "top_aud_k6_src_div",
-                        "top_aud_i2s1_mclk",
-                        "top_aud_i2s2_mclk",
-                        "top_aud_i2s3_mclk",
-                        "top_aud_i2s4_mclk",
-                        "top_aud_i2s5_mclk",
-                        "top_aud_i2s6_mclk",
-                        "top_asm_m_sel",
-                        "top_asm_h_sel",
-                        "top_univpll2_d4",
-                        "top_univpll2_d2",
-                        "top_syspll_d5";
+       audsys: clock-controller@11220000 {
+               compatible = "mediatek,mt2701-audsys", "syscon";
+               reg = <0 0x11220000 0 0x2000>;
+               #clock-cells = <1>;
+
+               afe: audio-controller {
+                       compatible = "mediatek,mt2701-audio";
+                       interrupts =  <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>,
+                                     <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>;
+                       interrupt-names = "afe", "asys";
+                       power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
+
+                       clocks = <&infracfg CLK_INFRA_AUDIO>,
+                                <&topckgen CLK_TOP_AUD_MUX1_SEL>,
+                                <&topckgen CLK_TOP_AUD_MUX2_SEL>,
+                                <&topckgen CLK_TOP_AUD_48K_TIMING>,
+                                <&topckgen CLK_TOP_AUD_44K_TIMING>,
+                                <&topckgen CLK_TOP_AUD_K1_SRC_SEL>,
+                                <&topckgen CLK_TOP_AUD_K2_SRC_SEL>,
+                                <&topckgen CLK_TOP_AUD_K3_SRC_SEL>,
+                                <&topckgen CLK_TOP_AUD_K4_SRC_SEL>,
+                                <&topckgen CLK_TOP_AUD_K1_SRC_DIV>,
+                                <&topckgen CLK_TOP_AUD_K2_SRC_DIV>,
+                                <&topckgen CLK_TOP_AUD_K3_SRC_DIV>,
+                                <&topckgen CLK_TOP_AUD_K4_SRC_DIV>,
+                                <&topckgen CLK_TOP_AUD_I2S1_MCLK>,
+                                <&topckgen CLK_TOP_AUD_I2S2_MCLK>,
+                                <&topckgen CLK_TOP_AUD_I2S3_MCLK>,
+                                <&topckgen CLK_TOP_AUD_I2S4_MCLK>,
+                                <&audsys CLK_AUD_I2SO1>,
+                                <&audsys CLK_AUD_I2SO2>,
+                                <&audsys CLK_AUD_I2SO3>,
+                                <&audsys CLK_AUD_I2SO4>,
+                                <&audsys CLK_AUD_I2SIN1>,
+                                <&audsys CLK_AUD_I2SIN2>,
+                                <&audsys CLK_AUD_I2SIN3>,
+                                <&audsys CLK_AUD_I2SIN4>,
+                                <&audsys CLK_AUD_ASRCO1>,
+                                <&audsys CLK_AUD_ASRCO2>,
+                                <&audsys CLK_AUD_ASRCO3>,
+                                <&audsys CLK_AUD_ASRCO4>,
+                                <&audsys CLK_AUD_AFE>,
+                                <&audsys CLK_AUD_AFE_CONN>,
+                                <&audsys CLK_AUD_A1SYS>,
+                                <&audsys CLK_AUD_A2SYS>,
+                                <&audsys CLK_AUD_AFE_MRGIF>;
+
+                       clock-names = "infra_sys_audio_clk",
+                                     "top_audio_mux1_sel",
+                                     "top_audio_mux2_sel",
+                                     "top_audio_a1sys_hp",
+                                     "top_audio_a2sys_hp",
+                                     "i2s0_src_sel",
+                                     "i2s1_src_sel",
+                                     "i2s2_src_sel",
+                                     "i2s3_src_sel",
+                                     "i2s0_src_div",
+                                     "i2s1_src_div",
+                                     "i2s2_src_div",
+                                     "i2s3_src_div",
+                                     "i2s0_mclk_en",
+                                     "i2s1_mclk_en",
+                                     "i2s2_mclk_en",
+                                     "i2s3_mclk_en",
+                                     "i2so0_hop_ck",
+                                     "i2so1_hop_ck",
+                                     "i2so2_hop_ck",
+                                     "i2so3_hop_ck",
+                                     "i2si0_hop_ck",
+                                     "i2si1_hop_ck",
+                                     "i2si2_hop_ck",
+                                     "i2si3_hop_ck",
+                                     "asrc0_out_ck",
+                                     "asrc1_out_ck",
+                                     "asrc2_out_ck",
+                                     "asrc3_out_ck",
+                                     "audio_afe_pd",
+                                     "audio_afe_conn_pd",
+                                     "audio_a1sys_pd",
+                                     "audio_a2sys_pd",
+                                     "audio_mrgif_pd";
+
+                       assigned-clocks = <&topckgen CLK_TOP_AUD_MUX1_SEL>,
+                                         <&topckgen CLK_TOP_AUD_MUX2_SEL>,
+                                         <&topckgen CLK_TOP_AUD_MUX1_DIV>,
+                                         <&topckgen CLK_TOP_AUD_MUX2_DIV>;
+                       assigned-clock-parents = <&topckgen CLK_TOP_AUD1PLL_98M>,
+                                                <&topckgen CLK_TOP_AUD2PLL_90M>;
+                       assigned-clock-rates = <0>, <0>, <49152000>, <45158400>;
+               };
        };
 
        mmsys: syscon@14000000 {
index 7c783d6c750e31e232828276471844340be111a4..ba397407c1dd0f4ce6bdf36bf61714ea4fc12cbf 100644 (file)
@@ -1,15 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2017 MediaTek Inc.
+ * Copyright (c) 2017-2018 MediaTek Inc.
  * Author: John Crispin <john@phrozen.org>
  *        Sean Wang <sean.wang@mediatek.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.
  */
 
 &pwrap {
@@ -20,6 +14,13 @@ pmic: mt6323 {
                interrupt-controller;
                #interrupt-cells = <2>;
 
+               mt6323_leds: leds {
+                       compatible = "mediatek,mt6323-led";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
                mt6323regulator: mt6323regulator{
                        compatible = "mediatek,mt6323-regulator";
 
index 17daeae6bbe8f789edef18d0d09c1fce9f9896c2..ca137897ed600eade79f6e2bae0bcafdc18c039b 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2015 MediaTek Inc.
  * Author: Mars.C <mars.cheng@mediatek.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.
  */
 
 /dts-v1/;
index a349dba5ff797807f25e5956bb923a70d2e89390..2bdc5ed12fca2ac7e341135485b8d397324cac21 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2015 MediaTek Inc.
  * Author: Mars.C <mars.cheng@mediatek.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.
  */
 
 #include <dt-bindings/interrupt-controller/irq.h>
index 594a6f3bebda9f534923a3de407e5d12921d809d..7bbaa1279a26a1252822350be264d8764b0a4ece 100644 (file)
@@ -1,16 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2014 MundoReader S.L.
  * Author: Matthias Brugger <matthias.bgg@gmail.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 /dts-v1/;
index 41df742d78914b96eae2b2f7fa2e9b2154b1c3fc..28df8495686ad19d15ec64b62a820205b5eaefc9 100644 (file)
@@ -1,17 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2014 MundoReader S.L.
  * Author: Matthias Brugger <matthias.bgg@gmail.com>
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+*/
 
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
index b57237e6394a2afb0caf086b0c414203a66fa0f2..02849f6548e3c5ebbb4be8834a32f011dc2d472d 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 MediaTek Inc.
  * Author: Howard Chen <ibanezchen@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.
  */
 
 /dts-v1/;
index c69201ffff721832cdccac36315aee518a7ab50a..8696ac891d60970f221ebe264e4bfe381fa2aca9 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 MediaTek Inc.
  * Author: Howard Chen <ibanezchen@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.
  */
 
 #include <dt-bindings/interrupt-controller/irq.h>
index e10c034965246fb591f9e4383737b3edf891fe3d..d1eb123bc73b8200989a197e3559eb7e2d543441 100644 (file)
@@ -1,16 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2017 MediaTek Inc.
+ * Copyright (c) 2017-2018 MediaTek Inc.
  * Author: John Crispin <john@phrozen.org>
  *        Sean Wang <sean.wang@mediatek.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.
  */
 
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/phy/phy.h>
 #include <dt-bindings/reset/mt2701-resets.h>
 #include <dt-bindings/thermal/thermal.h>
-#include "skeleton64.dtsi"
 
 / {
        compatible = "mediatek,mt7623";
        interrupt-parent = <&sysirq>;
+       #address-cells = <2>;
+       #size-cells = <2>;
 
        cpu_opp_table: opp-table {
                compatible = "operating-points-v2";
@@ -130,14 +124,14 @@ system_clk: dummy13m {
                #clock-cells = <0>;
        };
 
-       rtc32k: oscillator@1 {
+       rtc32k: oscillator-1 {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency = <32000>;
                clock-output-names = "rtc32k";
        };
 
-       clk26m: oscillator@0 {
+       clk26m: oscillator-0 {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency = <26000000>;
@@ -492,6 +486,18 @@ thermal: thermal@1100b000 {
                nvmem-cell-names = "calibration-data";
        };
 
+       btif: serial@1100c000 {
+               compatible = "mediatek,mt7623-btif",
+                            "mediatek,mtk-btif";
+               reg = <0 0x1100c000 0 0x1000>;
+               interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_LOW>;
+               clocks = <&pericfg CLK_PERI_BTIF>;
+               clock-names = "main";
+               reg-shift = <2>;
+               reg-io-width = <4>;
+               status = "disabled";
+       };
+
        nandc: nfi@1100d000 {
                compatible = "mediatek,mt7623-nfc",
                             "mediatek,mt2701-nfc";
@@ -517,6 +523,18 @@ bch: ecc@1100e000 {
                status = "disabled";
        };
 
+       nor_flash: spi@11014000 {
+               compatible = "mediatek,mt7623-nor",
+                            "mediatek,mt8173-nor";
+               reg = <0 0x11014000 0 0x1000>;
+               clocks = <&pericfg CLK_PERI_FLASH>,
+                        <&topckgen CLK_TOP_FLASH_SEL>;
+               clock-names = "spi", "sf";
+               #address-cells = <1>;
+               #size-cells = <0>;
+               status = "disabled";
+       };
+
        spi1: spi@11016000 {
                compatible = "mediatek,mt7623-spi",
                             "mediatek,mt2701-spi";
@@ -545,105 +563,99 @@ spi2: spi@11017000 {
                status = "disabled";
        };
 
-       afe: audio-controller@11220000 {
-               compatible = "mediatek,mt7623-audio",
-                            "mediatek,mt2701-audio";
-               reg = <0 0x11220000 0 0x2000>,
-                     <0 0x112a0000 0 0x20000>;
-               interrupts =  <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>,
-                             <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>;
-               interrupt-names = "afe", "asys";
-               power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
+       audsys: clock-controller@11220000 {
+               compatible = "mediatek,mt7623-audsys",
+                            "mediatek,mt2701-audsys",
+                            "syscon";
+               reg = <0 0x11220000 0 0x2000>;
+               #clock-cells = <1>;
 
-               clocks = <&infracfg CLK_INFRA_AUDIO>,
-                        <&topckgen CLK_TOP_AUD_MUX1_SEL>,
-                        <&topckgen CLK_TOP_AUD_MUX2_SEL>,
-                        <&topckgen CLK_TOP_AUD_MUX1_DIV>,
-                        <&topckgen CLK_TOP_AUD_MUX2_DIV>,
-                        <&topckgen CLK_TOP_AUD_48K_TIMING>,
-                        <&topckgen CLK_TOP_AUD_44K_TIMING>,
-                        <&topckgen CLK_TOP_AUDPLL_MUX_SEL>,
-                        <&topckgen CLK_TOP_APLL_SEL>,
-                        <&topckgen CLK_TOP_AUD1PLL_98M>,
-                        <&topckgen CLK_TOP_AUD2PLL_90M>,
-                        <&topckgen CLK_TOP_HADDS2PLL_98M>,
-                        <&topckgen CLK_TOP_HADDS2PLL_294M>,
-                        <&topckgen CLK_TOP_AUDPLL>,
-                        <&topckgen CLK_TOP_AUDPLL_D4>,
-                        <&topckgen CLK_TOP_AUDPLL_D8>,
-                        <&topckgen CLK_TOP_AUDPLL_D16>,
-                        <&topckgen CLK_TOP_AUDPLL_D24>,
-                        <&topckgen CLK_TOP_AUDINTBUS_SEL>,
-                        <&clk26m>,
-                        <&topckgen CLK_TOP_SYSPLL1_D4>,
-                        <&topckgen CLK_TOP_AUD_K1_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K2_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K3_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K4_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K5_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K6_SRC_SEL>,
-                        <&topckgen CLK_TOP_AUD_K1_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K2_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K3_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K4_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K5_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_K6_SRC_DIV>,
-                        <&topckgen CLK_TOP_AUD_I2S1_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S2_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S3_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S4_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S5_MCLK>,
-                        <&topckgen CLK_TOP_AUD_I2S6_MCLK>,
-                        <&topckgen CLK_TOP_ASM_M_SEL>,
-                        <&topckgen CLK_TOP_ASM_H_SEL>,
-                        <&topckgen CLK_TOP_UNIVPLL2_D4>,
-                        <&topckgen CLK_TOP_UNIVPLL2_D2>,
-                        <&topckgen CLK_TOP_SYSPLL_D5>;
-
-               clock-names = "infra_sys_audio_clk",
-                        "top_audio_mux1_sel",
-                        "top_audio_mux2_sel",
-                        "top_audio_mux1_div",
-                        "top_audio_mux2_div",
-                        "top_audio_48k_timing",
-                        "top_audio_44k_timing",
-                        "top_audpll_mux_sel",
-                        "top_apll_sel",
-                        "top_aud1_pll_98M",
-                        "top_aud2_pll_90M",
-                        "top_hadds2_pll_98M",
-                        "top_hadds2_pll_294M",
-                        "top_audpll",
-                        "top_audpll_d4",
-                        "top_audpll_d8",
-                        "top_audpll_d16",
-                        "top_audpll_d24",
-                        "top_audintbus_sel",
-                        "clk_26m",
-                        "top_syspll1_d4",
-                        "top_aud_k1_src_sel",
-                        "top_aud_k2_src_sel",
-                        "top_aud_k3_src_sel",
-                        "top_aud_k4_src_sel",
-                        "top_aud_k5_src_sel",
-                        "top_aud_k6_src_sel",
-                        "top_aud_k1_src_div",
-                        "top_aud_k2_src_div",
-                        "top_aud_k3_src_div",
-                        "top_aud_k4_src_div",
-                        "top_aud_k5_src_div",
-                        "top_aud_k6_src_div",
-                        "top_aud_i2s1_mclk",
-                        "top_aud_i2s2_mclk",
-                        "top_aud_i2s3_mclk",
-                        "top_aud_i2s4_mclk",
-                        "top_aud_i2s5_mclk",
-                        "top_aud_i2s6_mclk",
-                        "top_asm_m_sel",
-                        "top_asm_h_sel",
-                        "top_univpll2_d4",
-                        "top_univpll2_d2",
-                        "top_syspll_d5";
+               afe: audio-controller {
+                       compatible = "mediatek,mt7623-audio",
+                                    "mediatek,mt2701-audio";
+                       interrupts =  <GIC_SPI 104 IRQ_TYPE_LEVEL_LOW>,
+                                     <GIC_SPI 132 IRQ_TYPE_LEVEL_LOW>;
+                       interrupt-names = "afe", "asys";
+                       power-domains = <&scpsys MT2701_POWER_DOMAIN_IFR_MSC>;
+
+                       clocks = <&infracfg CLK_INFRA_AUDIO>,
+                                <&topckgen CLK_TOP_AUD_MUX1_SEL>,
+                                <&topckgen CLK_TOP_AUD_MUX2_SEL>,
+                                <&topckgen CLK_TOP_AUD_48K_TIMING>,
+                                <&topckgen CLK_TOP_AUD_44K_TIMING>,
+                                <&topckgen CLK_TOP_AUD_K1_SRC_SEL>,
+                                <&topckgen CLK_TOP_AUD_K2_SRC_SEL>,
+                                <&topckgen CLK_TOP_AUD_K3_SRC_SEL>,
+                                <&topckgen CLK_TOP_AUD_K4_SRC_SEL>,
+                                <&topckgen CLK_TOP_AUD_K1_SRC_DIV>,
+                                <&topckgen CLK_TOP_AUD_K2_SRC_DIV>,
+                                <&topckgen CLK_TOP_AUD_K3_SRC_DIV>,
+                                <&topckgen CLK_TOP_AUD_K4_SRC_DIV>,
+                                <&topckgen CLK_TOP_AUD_I2S1_MCLK>,
+                                <&topckgen CLK_TOP_AUD_I2S2_MCLK>,
+                                <&topckgen CLK_TOP_AUD_I2S3_MCLK>,
+                                <&topckgen CLK_TOP_AUD_I2S4_MCLK>,
+                                <&audsys CLK_AUD_I2SO1>,
+                                <&audsys CLK_AUD_I2SO2>,
+                                <&audsys CLK_AUD_I2SO3>,
+                                <&audsys CLK_AUD_I2SO4>,
+                                <&audsys CLK_AUD_I2SIN1>,
+                                <&audsys CLK_AUD_I2SIN2>,
+                                <&audsys CLK_AUD_I2SIN3>,
+                                <&audsys CLK_AUD_I2SIN4>,
+                                <&audsys CLK_AUD_ASRCO1>,
+                                <&audsys CLK_AUD_ASRCO2>,
+                                <&audsys CLK_AUD_ASRCO3>,
+                                <&audsys CLK_AUD_ASRCO4>,
+                                <&audsys CLK_AUD_AFE>,
+                                <&audsys CLK_AUD_AFE_CONN>,
+                                <&audsys CLK_AUD_A1SYS>,
+                                <&audsys CLK_AUD_A2SYS>,
+                                <&audsys CLK_AUD_AFE_MRGIF>;
+
+                       clock-names = "infra_sys_audio_clk",
+                                     "top_audio_mux1_sel",
+                                     "top_audio_mux2_sel",
+                                     "top_audio_a1sys_hp",
+                                     "top_audio_a2sys_hp",
+                                     "i2s0_src_sel",
+                                     "i2s1_src_sel",
+                                     "i2s2_src_sel",
+                                     "i2s3_src_sel",
+                                     "i2s0_src_div",
+                                     "i2s1_src_div",
+                                     "i2s2_src_div",
+                                     "i2s3_src_div",
+                                     "i2s0_mclk_en",
+                                     "i2s1_mclk_en",
+                                     "i2s2_mclk_en",
+                                     "i2s3_mclk_en",
+                                     "i2so0_hop_ck",
+                                     "i2so1_hop_ck",
+                                     "i2so2_hop_ck",
+                                     "i2so3_hop_ck",
+                                     "i2si0_hop_ck",
+                                     "i2si1_hop_ck",
+                                     "i2si2_hop_ck",
+                                     "i2si3_hop_ck",
+                                     "asrc0_out_ck",
+                                     "asrc1_out_ck",
+                                     "asrc2_out_ck",
+                                     "asrc3_out_ck",
+                                     "audio_afe_pd",
+                                     "audio_afe_conn_pd",
+                                     "audio_a1sys_pd",
+                                     "audio_a2sys_pd",
+                                     "audio_mrgif_pd";
+
+                       assigned-clocks = <&topckgen CLK_TOP_AUD_MUX1_SEL>,
+                                         <&topckgen CLK_TOP_AUD_MUX2_SEL>,
+                                         <&topckgen CLK_TOP_AUD_MUX1_DIV>,
+                                         <&topckgen CLK_TOP_AUD_MUX2_DIV>;
+                       assigned-clock-parents = <&topckgen CLK_TOP_AUD1PLL_98M>,
+                                                <&topckgen CLK_TOP_AUD2PLL_90M>;
+                       assigned-clock-rates = <0>, <0>, <49152000>, <45158400>;
+               };
        };
 
        mmc0: mmc@11230000 {
@@ -873,6 +885,16 @@ ethsys: syscon@1b000000 {
                #reset-cells = <1>;
        };
 
+       hsdma: dma-controller@1b007000 {
+               compatible = "mediatek,mt7623-hsdma";
+               reg = <0 0x1b007000 0 0x1000>;
+               interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_LOW>;
+               clocks = <&ethsys CLK_ETHSYS_HSDMA>;
+               clock-names = "hsdma";
+               power-domains = <&scpsys MT2701_POWER_DOMAIN_ETH>;
+               #dma-cells = <1>;
+       };
+
        eth: ethernet@1b100000 {
                compatible = "mediatek,mt7623-eth",
                             "mediatek,mt2701-eth",
@@ -913,3 +935,298 @@ crypto: crypto@1b240000 {
                status = "disabled";
        };
 };
+
+&pio {
+       cir_pins_a:cir-default {
+               pins-cir {
+                       pinmux = <MT7623_PIN_46_IR_FUNC_IR>;
+                       bias-disable;
+               };
+       };
+
+       i2c0_pins_a: i2c0-default {
+               pins-i2c0 {
+                       pinmux = <MT7623_PIN_75_SDA0_FUNC_SDA0>,
+                                <MT7623_PIN_76_SCL0_FUNC_SCL0>;
+                       bias-disable;
+               };
+       };
+
+       i2c1_pins_a: i2c1-default {
+               pin-i2c1 {
+                       pinmux = <MT7623_PIN_57_SDA1_FUNC_SDA1>,
+                                <MT7623_PIN_58_SCL1_FUNC_SCL1>;
+                       bias-disable;
+               };
+       };
+
+       i2c1_pins_b: i2c1-alt {
+               pin-i2c1 {
+                       pinmux = <MT7623_PIN_242_URTS2_FUNC_SCL1>,
+                                <MT7623_PIN_243_UCTS2_FUNC_SDA1>;
+                       bias-disable;
+               };
+       };
+
+       i2c2_pins_a: i2c2-default {
+               pin-i2c2 {
+                       pinmux = <MT7623_PIN_77_SDA2_FUNC_SDA2>,
+                                <MT7623_PIN_78_SCL2_FUNC_SCL2>;
+                       bias-disable;
+               };
+       };
+
+       i2c2_pins_b: i2c2-alt {
+               pin-i2c2 {
+                       pinmux = <MT7623_PIN_122_GPIO122_FUNC_SDA2>,
+                                <MT7623_PIN_123_HTPLG_FUNC_SCL2>;
+                       bias-disable;
+               };
+       };
+
+       i2s0_pins_a: i2s0-default {
+               pin-i2s0 {
+                       pinmux = <MT7623_PIN_49_I2S0_DATA_FUNC_I2S0_DATA>,
+                                <MT7623_PIN_72_I2S0_DATA_IN_FUNC_I2S0_DATA_IN>,
+                                <MT7623_PIN_73_I2S0_LRCK_FUNC_I2S0_LRCK>,
+                                <MT7623_PIN_74_I2S0_BCK_FUNC_I2S0_BCK>,
+                                <MT7623_PIN_126_I2S0_MCLK_FUNC_I2S0_MCLK>;
+                       drive-strength = <MTK_DRIVE_12mA>;
+                       bias-pull-down;
+               };
+       };
+
+       i2s1_pins_a: i2s1-default {
+               pin-i2s1 {
+                       pinmux = <MT7623_PIN_33_I2S1_DATA_FUNC_I2S1_DATA>,
+                                <MT7623_PIN_34_I2S1_DATA_IN_FUNC_I2S1_DATA_IN>,
+                                <MT7623_PIN_35_I2S1_BCK_FUNC_I2S1_BCK>,
+                                <MT7623_PIN_36_I2S1_LRCK_FUNC_I2S1_LRCK>,
+                                <MT7623_PIN_37_I2S1_MCLK_FUNC_I2S1_MCLK>;
+                       drive-strength = <MTK_DRIVE_12mA>;
+                       bias-pull-down;
+               };
+       };
+
+       key_pins_a: keys-alt {
+               pins-keys {
+                       pinmux = <MT7623_PIN_256_GPIO256_FUNC_GPIO256>,
+                                <MT7623_PIN_257_GPIO257_FUNC_GPIO257> ;
+                       input-enable;
+               };
+       };
+
+       led_pins_a: leds-alt {
+               pins-leds {
+                       pinmux = <MT7623_PIN_239_EXT_SDIO0_FUNC_GPIO239>,
+                                <MT7623_PIN_240_EXT_XCS_FUNC_GPIO240>,
+                                <MT7623_PIN_241_EXT_SCK_FUNC_GPIO241>;
+               };
+       };
+
+       mmc0_pins_default: mmc0default {
+               pins-cmd-dat {
+                       pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
+                                <MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
+                                <MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
+                                <MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
+                                <MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
+                                <MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
+                                <MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
+                                <MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
+                                <MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
+                       input-enable;
+                       bias-pull-up;
+               };
+
+               pins-clk {
+                       pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
+                       bias-pull-down;
+               };
+
+               pins-rst {
+                       pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
+                       bias-pull-up;
+               };
+       };
+
+       mmc0_pins_uhs: mmc0 {
+               pins-cmd-dat {
+                       pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
+                                <MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
+                                <MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
+                                <MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
+                                <MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
+                                <MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
+                                <MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
+                                <MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
+                                <MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
+                       input-enable;
+                       drive-strength = <MTK_DRIVE_2mA>;
+                       bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
+               };
+
+               pins-clk {
+                       pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
+                       drive-strength = <MTK_DRIVE_2mA>;
+                       bias-pull-down = <MTK_PUPD_SET_R1R0_01>;
+               };
+
+               pins-rst {
+                       pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
+                       bias-pull-up;
+               };
+       };
+
+       mmc1_pins_default: mmc1default {
+               pins-cmd-dat {
+                       pinmux = <MT7623_PIN_107_MSDC1_DAT0_FUNC_MSDC1_DAT0>,
+                                <MT7623_PIN_108_MSDC1_DAT1_FUNC_MSDC1_DAT1>,
+                                <MT7623_PIN_109_MSDC1_DAT2_FUNC_MSDC1_DAT2>,
+                                <MT7623_PIN_110_MSDC1_DAT3_FUNC_MSDC1_DAT3>,
+                                <MT7623_PIN_105_MSDC1_CMD_FUNC_MSDC1_CMD>;
+                       input-enable;
+                       drive-strength = <MTK_DRIVE_4mA>;
+                       bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
+               };
+
+               pins-clk {
+                       pinmux = <MT7623_PIN_106_MSDC1_CLK_FUNC_MSDC1_CLK>;
+                       bias-pull-down;
+                       drive-strength = <MTK_DRIVE_4mA>;
+               };
+
+               pins-wp {
+                       pinmux = <MT7623_PIN_29_EINT7_FUNC_MSDC1_WP>;
+                       input-enable;
+                       bias-pull-up;
+               };
+
+               pins-insert {
+                       pinmux = <MT7623_PIN_261_MSDC1_INS_FUNC_GPIO261>;
+                       bias-pull-up;
+               };
+       };
+
+       mmc1_pins_uhs: mmc1 {
+               pins-cmd-dat {
+                       pinmux = <MT7623_PIN_107_MSDC1_DAT0_FUNC_MSDC1_DAT0>,
+                                <MT7623_PIN_108_MSDC1_DAT1_FUNC_MSDC1_DAT1>,
+                                <MT7623_PIN_109_MSDC1_DAT2_FUNC_MSDC1_DAT2>,
+                                <MT7623_PIN_110_MSDC1_DAT3_FUNC_MSDC1_DAT3>,
+                                <MT7623_PIN_105_MSDC1_CMD_FUNC_MSDC1_CMD>;
+                       input-enable;
+                       drive-strength = <MTK_DRIVE_4mA>;
+                       bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
+               };
+
+               pins-clk {
+                       pinmux = <MT7623_PIN_106_MSDC1_CLK_FUNC_MSDC1_CLK>;
+                       drive-strength = <MTK_DRIVE_4mA>;
+                       bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
+               };
+       };
+
+       nand_pins_default: nanddefault {
+               pins-ale {
+                       pinmux = <MT7623_PIN_116_MSDC0_CMD_FUNC_NALE>;
+                       drive-strength = <MTK_DRIVE_8mA>;
+                       bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
+               };
+
+               pins-dat {
+                       pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_NLD7>,
+                                <MT7623_PIN_112_MSDC0_DAT6_FUNC_NLD6>,
+                                <MT7623_PIN_114_MSDC0_DAT4_FUNC_NLD4>,
+                                <MT7623_PIN_118_MSDC0_DAT3_FUNC_NLD3>,
+                                <MT7623_PIN_121_MSDC0_DAT0_FUNC_NLD0>,
+                                <MT7623_PIN_120_MSDC0_DAT1_FUNC_NLD1>,
+                                <MT7623_PIN_113_MSDC0_DAT5_FUNC_NLD5>,
+                                <MT7623_PIN_115_MSDC0_RSTB_FUNC_NLD8>,
+                                <MT7623_PIN_119_MSDC0_DAT2_FUNC_NLD2>;
+                       input-enable;
+                       drive-strength = <MTK_DRIVE_8mA>;
+                       bias-pull-up;
+               };
+
+               pins-we {
+                       pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_NWEB>;
+                       drive-strength = <MTK_DRIVE_8mA>;
+                       bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
+               };
+       };
+
+       pcie_default: pcie_pin_default {
+               pins_cmd_dat {
+                       pinmux = <MT7623_PIN_208_AUD_EXT_CK1_FUNC_PCIE0_PERST_N>,
+                                <MT7623_PIN_209_AUD_EXT_CK2_FUNC_PCIE1_PERST_N>;
+                       bias-disable;
+               };
+       };
+
+       pwm_pins_a: pwm-default {
+               pins-pwm {
+                       pinmux = <MT7623_PIN_203_PWM0_FUNC_PWM0>,
+                                <MT7623_PIN_204_PWM1_FUNC_PWM1>,
+                                <MT7623_PIN_205_PWM2_FUNC_PWM2>,
+                                <MT7623_PIN_206_PWM3_FUNC_PWM3>,
+                                <MT7623_PIN_207_PWM4_FUNC_PWM4>;
+               };
+       };
+
+       spi0_pins_a: spi0-default {
+               pins-spi {
+                       pinmux = <MT7623_PIN_53_SPI0_CSN_FUNC_SPI0_CS>,
+                               <MT7623_PIN_54_SPI0_CK_FUNC_SPI0_CK>,
+                               <MT7623_PIN_55_SPI0_MI_FUNC_SPI0_MI>,
+                               <MT7623_PIN_56_SPI0_MO_FUNC_SPI0_MO>;
+                       bias-disable;
+               };
+       };
+
+       spi1_pins_a: spi1-default {
+               pins-spi {
+                       pinmux = <MT7623_PIN_7_SPI1_CSN_FUNC_SPI1_CS>,
+                               <MT7623_PIN_199_SPI1_CK_FUNC_SPI1_CK>,
+                               <MT7623_PIN_8_SPI1_MI_FUNC_SPI1_MI>,
+                               <MT7623_PIN_9_SPI1_MO_FUNC_SPI1_MO>;
+               };
+       };
+
+       spi2_pins_a: spi2-default {
+               pins-spi {
+                       pinmux = <MT7623_PIN_101_SPI2_CSN_FUNC_SPI2_CS>,
+                                <MT7623_PIN_104_SPI2_CK_FUNC_SPI2_CK>,
+                                <MT7623_PIN_102_SPI2_MI_FUNC_SPI2_MI>,
+                                <MT7623_PIN_103_SPI2_MO_FUNC_SPI2_MO>;
+               };
+       };
+
+       uart0_pins_a: uart0-default {
+               pins-dat {
+                       pinmux = <MT7623_PIN_79_URXD0_FUNC_URXD0>,
+                                <MT7623_PIN_80_UTXD0_FUNC_UTXD0>;
+               };
+       };
+
+       uart1_pins_a: uart1-default {
+               pins-dat {
+                       pinmux = <MT7623_PIN_81_URXD1_FUNC_URXD1>,
+                                <MT7623_PIN_82_UTXD1_FUNC_UTXD1>;
+               };
+       };
+
+       uart2_pins_a: uart2-default {
+               pins-dat {
+                       pinmux = <MT7623_PIN_14_GPIO14_FUNC_URXD2>,
+                                <MT7623_PIN_15_GPIO15_FUNC_UTXD2>;
+               };
+       };
+
+       uart2_pins_b: uart2-alt {
+               pins-dat {
+                       pinmux = <MT7623_PIN_200_URXD2_FUNC_URXD2>,
+                                <MT7623_PIN_201_UTXD2_FUNC_UTXD2>;
+               };
+       };
+};
diff --git a/arch/arm/boot/dts/mt7623a-rfb-emmc.dts b/arch/arm/boot/dts/mt7623a-rfb-emmc.dts
new file mode 100644 (file)
index 0000000..13c8693
--- /dev/null
@@ -0,0 +1,291 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2018 MediaTek Inc.
+ * Author: Sean Wang <sean.wang@mediatek.com>
+ *
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include "mt7623a.dtsi"
+#include "mt6323.dtsi"
+
+/ {
+       model = "MediaTek MT7623A with eMMC reference board";
+       compatible = "mediatek,mt7623a-rfb-emmc", "mediatek,mt7623";
+
+       aliases {
+               serial2 = &uart2;
+       };
+
+       chosen {
+               stdout-path = "serial2:115200n8";
+       };
+
+       cpus {
+               cpu@0 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+
+               cpu@1 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+
+               cpu@2 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+
+               cpu@3 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+       };
+
+       gpio-keys {
+               compatible = "gpio-keys";
+               pinctrl-names = "default";
+               pinctrl-0 = <&key_pins_a>;
+
+               factory {
+                       label = "factory";
+                       linux,code = <BTN_0>;
+                       gpios = <&pio 256 GPIO_ACTIVE_LOW>;
+               };
+
+               wps {
+                       label = "wps";
+                       linux,code = <KEY_WPS_BUTTON>;
+                       gpios = <&pio 257 GPIO_ACTIVE_HIGH>;
+               };
+       };
+
+       memory@80000000 {
+               device_type = "memory";
+               reg = <0 0x80000000 0 0x20000000>;
+       };
+
+       reg_1p8v: regulator-1p8v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-1.8V";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       reg_3p3v: regulator-3p3v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       reg_5v: regulator-5v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-5V";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       sound {
+               compatible = "mediatek,mt2701-wm8960-machine";
+               mediatek,platform = <&afe>;
+               audio-routing =
+                       "Headphone", "HP_L",
+                       "Headphone", "HP_R",
+                       "LINPUT1", "AMIC",
+                       "RINPUT1", "AMIC";
+               mediatek,audio-codec = <&wm8960>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&i2s0_pins_a>;
+       };
+};
+
+&btif {
+       status = "okay";
+};
+
+&crypto {
+       status = "okay";
+};
+
+&eth {
+       status = "okay";
+
+       gmac0: mac@0 {
+               compatible = "mediatek,eth-mac";
+               reg = <0>;
+               phy-mode = "trgmii";
+
+               fixed-link {
+                       speed = <1000>;
+                       full-duplex;
+                       pause;
+               };
+       };
+
+       mdio-bus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               switch@0 {
+                       compatible = "mediatek,mt7530";
+                       reg = <0>;
+                       mediatek,mcm;
+                       resets = <&ethsys MT2701_ETHSYS_MCM_RST>;
+                       reset-names = "mcm";
+                       core-supply = <&mt6323_vpa_reg>;
+                       io-supply = <&mt6323_vemc3v3_reg>;
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@0 {
+                                       reg = <0>;
+                                       label = "lan0";
+                               };
+
+                               port@1 {
+                                       reg = <1>;
+                                       label = "lan1";
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+                                       label = "lan2";
+                               };
+
+                               port@3 {
+                                       reg = <3>;
+                                       label = "lan3";
+                               };
+
+                               port@4 {
+                                       reg = <4>;
+                                       label = "wan";
+                               };
+
+                               port@6 {
+                                       reg = <6>;
+                                       label = "cpu";
+                                       ethernet = <&gmac0>;
+                                       phy-mode = "trgmii";
+
+                                       fixed-link {
+                                               speed = <1000>;
+                                               full-duplex;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+
+&i2c0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c0_pins_a>;
+       status = "okay";
+};
+
+&i2c1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c1_pins_b>;
+       status = "okay";
+
+       wm8960: wm8960@1a {
+               compatible = "wlf,wm8960";
+               reg = <0x1a>;
+       };
+};
+
+&i2c2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c2_pins_b>;
+       status = "okay";
+};
+
+&mmc0 {
+       pinctrl-names = "default", "state_uhs";
+       pinctrl-0 = <&mmc0_pins_default>;
+       pinctrl-1 = <&mmc0_pins_uhs>;
+       status = "okay";
+       bus-width = <8>;
+       max-frequency = <50000000>;
+       cap-mmc-highspeed;
+       vmmc-supply = <&reg_3p3v>;
+       vqmmc-supply = <&reg_1p8v>;
+       non-removable;
+};
+
+&mmc1 {
+       pinctrl-names = "default", "state_uhs";
+       pinctrl-0 = <&mmc1_pins_default>;
+       pinctrl-1 = <&mmc1_pins_uhs>;
+       status = "okay";
+       bus-width = <4>;
+       max-frequency = <50000000>;
+       cap-sd-highspeed;
+       cd-gpios = <&pio 261 GPIO_ACTIVE_LOW>;
+       vmmc-supply = <&reg_3p3v>;
+       vqmmc-supply = <&reg_3p3v>;
+};
+
+&pcie {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pcie_default>;
+       status = "okay";
+
+       pcie@0,0 {
+               status = "okay";
+       };
+
+       pcie@1,0 {
+               status = "okay";
+       };
+};
+
+&pcie0_phy {
+       status = "okay";
+};
+
+&pcie1_phy {
+       status = "okay";
+};
+
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm_pins_a>;
+       status = "okay";
+};
+
+&spi0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi0_pins_a>;
+       status = "okay";
+};
+
+&spi1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi1_pins_a>;
+       status = "okay";
+};
+
+&uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart2_pins_b>;
+       status = "okay";
+};
+
+&usb1 {
+       vusb33-supply = <&reg_3p3v>;
+       vbus-supply = <&reg_5v>;
+       status = "okay";
+};
+
+&u3phy1 {
+       status = "okay";
+};
diff --git a/arch/arm/boot/dts/mt7623a-rfb-nand.dts b/arch/arm/boot/dts/mt7623a-rfb-nand.dts
new file mode 100644 (file)
index 0000000..88d8f0b
--- /dev/null
@@ -0,0 +1,337 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2018 MediaTek Inc.
+ * Author: Sean Wang <sean.wang@mediatek.com>
+ *
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include "mt7623a.dtsi"
+#include "mt6323.dtsi"
+
+/ {
+       model = "MediaTek MT7623A with NAND reference board";
+       compatible = "mediatek,mt7623a-rfb-nand", "mediatek,mt7623";
+
+       aliases {
+               serial2 = &uart2;
+       };
+
+       chosen {
+               stdout-path = "serial2:115200n8";
+       };
+
+       cpus {
+               cpu@0 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+
+               cpu@1 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+
+               cpu@2 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+
+               cpu@3 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+       };
+
+       gpio-keys {
+               compatible = "gpio-keys";
+               pinctrl-names = "default";
+               pinctrl-0 = <&key_pins_a>;
+
+               factory {
+                       label = "factory";
+                       linux,code = <BTN_0>;
+                       gpios = <&pio 256 GPIO_ACTIVE_LOW>;
+               };
+
+               wps {
+                       label = "wps";
+                       linux,code = <KEY_WPS_BUTTON>;
+                       gpios = <&pio 257 GPIO_ACTIVE_HIGH>;
+               };
+       };
+
+       memory@80000000 {
+               device_type = "memory";
+               reg = <0 0x80000000 0 0x20000000>;
+       };
+
+       reg_1p8v: regulator-1p8v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-1.8V";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       reg_3p3v: regulator-3p3v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       reg_5v: regulator-5v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-5V";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       sound {
+               compatible = "mediatek,mt2701-wm8960-machine";
+               mediatek,platform = <&afe>;
+               audio-routing =
+                       "Headphone", "HP_L",
+                       "Headphone", "HP_R",
+                       "LINPUT1", "AMIC",
+                       "RINPUT1", "AMIC";
+               mediatek,audio-codec = <&wm8960>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&i2s0_pins_a>;
+       };
+};
+
+&bch {
+       status = "okay";
+};
+
+&btif {
+       status = "okay";
+};
+
+&crypto {
+       status = "okay";
+};
+
+&eth {
+       status = "okay";
+
+       gmac0: mac@0 {
+               compatible = "mediatek,eth-mac";
+               reg = <0>;
+               phy-mode = "trgmii";
+
+               fixed-link {
+                       speed = <1000>;
+                       full-duplex;
+                       pause;
+               };
+       };
+
+       mdio-bus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               switch@0 {
+                       compatible = "mediatek,mt7530";
+                       reg = <0>;
+                       mediatek,mcm;
+                       resets = <&ethsys MT2701_ETHSYS_MCM_RST>;
+                       reset-names = "mcm";
+                       core-supply = <&mt6323_vpa_reg>;
+                       io-supply = <&mt6323_vemc3v3_reg>;
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@0 {
+                                       reg = <0>;
+                                       label = "lan0";
+                               };
+
+                               port@1 {
+                                       reg = <1>;
+                                       label = "lan1";
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+                                       label = "lan2";
+                               };
+
+                               port@3 {
+                                       reg = <3>;
+                                       label = "lan3";
+                               };
+
+                               port@4 {
+                                       reg = <4>;
+                                       label = "wan";
+                               };
+
+                               port@6 {
+                                       reg = <6>;
+                                       label = "cpu";
+                                       ethernet = <&gmac0>;
+                                       phy-mode = "trgmii";
+
+                                       fixed-link {
+                                               speed = <1000>;
+                                               full-duplex;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+
+&i2c0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c0_pins_a>;
+       status = "okay";
+};
+
+&i2c1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c1_pins_b>;
+       status = "okay";
+
+       wm8960: wm8960@1a {
+               compatible = "wlf,wm8960";
+               reg = <0x1a>;
+       };
+};
+
+&i2c2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c2_pins_b>;
+       status = "okay";
+};
+
+&mmc1 {
+       pinctrl-names = "default", "state_uhs";
+       pinctrl-0 = <&mmc1_pins_default>;
+       pinctrl-1 = <&mmc1_pins_uhs>;
+       status = "okay";
+       bus-width = <4>;
+       max-frequency = <50000000>;
+       cap-sd-highspeed;
+       cd-gpios = <&pio 261 GPIO_ACTIVE_LOW>;
+       vmmc-supply = <&reg_3p3v>;
+       vqmmc-supply = <&reg_3p3v>;
+};
+
+&nandc {
+       pinctrl-names = "default";
+       pinctrl-0 = <&nand_pins_default>;
+       status = "okay";
+
+       nand@0 {
+               reg = <0>;
+               spare_per_sector = <64>;
+               nand-ecc-mode = "hw";
+               nand-ecc-strength = <12>;
+               nand-ecc-step-size = <1024>;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "preloader";
+                               reg = <0x0 0x40000>;
+                       };
+
+                       partition@40000 {
+                               label = "uboot";
+                               reg = <0x40000 0x80000>;
+                       };
+
+                       partition@c0000 {
+                               label = "uboot-env";
+                               reg = <0xC0000 0x40000>;
+                       };
+
+                       partition@140000 {
+                               label = "bootimg";
+                               reg = <0x140000 0x2000000>;
+                       };
+
+                       partition@2140000 {
+                               label = "recovery";
+                               reg = <0x2140000 0x2000000>;
+                       };
+
+                       partition@4140000 {
+                               label = "rootfs";
+                               reg = <0x4140000 0x1000000>;
+                       };
+
+                       partition@5140000 {
+                               label = "usrdata";
+                               reg = <0x5140000 0x1000000>;
+                       };
+               };
+       };
+};
+
+&pcie {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pcie_default>;
+       status = "okay";
+
+       pcie@0,0 {
+               status = "okay";
+       };
+
+       pcie@1,0 {
+               status = "okay";
+       };
+};
+
+&pcie0_phy {
+       status = "okay";
+};
+
+&pcie1_phy {
+       status = "okay";
+};
+
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm_pins_a>;
+       status = "okay";
+};
+
+&spi0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi0_pins_a>;
+       status = "okay";
+};
+
+&spi1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi1_pins_a>;
+       status = "okay";
+};
+
+&uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart2_pins_b>;
+       status = "okay";
+};
+
+&usb1 {
+       vusb33-supply = <&reg_3p3v>;
+       vbus-supply = <&reg_5v>;
+       status = "okay";
+};
+
+&u3phy1 {
+       status = "okay";
+};
diff --git a/arch/arm/boot/dts/mt7623a.dtsi b/arch/arm/boot/dts/mt7623a.dtsi
new file mode 100644 (file)
index 0000000..0735a1f
--- /dev/null
@@ -0,0 +1,44 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2018 MediaTek Inc.
+ * Author: Sean Wang <sean.wang@mediatek.com>
+ *
+ */
+
+/dts-v1/;
+#include <dt-bindings/power/mt7623a-power.h>
+#include "mt7623.dtsi"
+
+&afe {
+       power-domains = <&scpsys MT7623A_POWER_DOMAIN_IFR_MSC>;
+};
+
+&crypto {
+       power-domains = <&scpsys MT7623A_POWER_DOMAIN_ETH>;
+};
+
+&eth {
+       power-domains = <&scpsys MT7623A_POWER_DOMAIN_ETH>;
+};
+
+&nandc {
+       power-domains = <&scpsys MT7623A_POWER_DOMAIN_IFR_MSC>;
+};
+
+&pcie {
+       power-domains = <&scpsys MT7623A_POWER_DOMAIN_HIF>;
+};
+
+&scpsys {
+       compatible = "mediatek,mt7623a-scpsys";
+       clocks = <&topckgen CLK_TOP_ETHIF_SEL>;
+       clock-names = "ethif";
+};
+
+&usb1 {
+       power-domains = <&scpsys MT7623A_POWER_DOMAIN_HIF>;
+};
+
+&usb2 {
+       power-domains = <&scpsys MT7623A_POWER_DOMAIN_HIF>;
+};
index bbf56f855e468b9ef1636629ed14be6d9144b869..531d905d924ffd027daffe31eafbabb944484c31 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Sean Wang <sean.wang@mediatek.com>
+ * Copyright 2017-2018 Sean Wang <sean.wang@mediatek.com>
  *
  * SPDX-License-Identifier: (GPL-2.0+ OR MIT)
  */
@@ -109,10 +109,15 @@ red {
        };
 
        memory@80000000 {
-               reg = <0 0x80000000 0 0x40000000>;
+               device_type = "memory";
+               reg = <0 0x80000000 0 0x80000000>;
        };
 };
 
+&btif {
+       status = "okay";
+};
+
 &cir {
        pinctrl-names = "default";
        pinctrl-0 = <&cir_pins_a>;
@@ -144,8 +149,6 @@ mdio: mdio-bus {
 
                switch@0 {
                        compatible = "mediatek,mt7530";
-                       #address-cells = <1>;
-                       #size-cells = <0>;
                        reg = <0>;
                        reset-gpios = <&pio 33 0>;
                        core-supply = <&mt6323_vpa_reg>;
@@ -154,7 +157,6 @@ switch@0 {
                        ports {
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               reg = <0>;
 
                                port@0 {
                                        reg = <0>;
@@ -235,6 +237,28 @@ &mmc1 {
        vqmmc-supply = <&reg_3p3v>;
 };
 
+&mt6323_leds {
+       status = "okay";
+
+       led@0 {
+               reg = <0>;
+               label = "bpi-r2:isink:green";
+               default-state = "off";
+       };
+
+       led@1 {
+               reg = <1>;
+               label = "bpi-r2:isink:red";
+               default-state = "off";
+       };
+
+       led@2 {
+               reg = <2>;
+               label = "bpi-r2:isink:blue";
+               default-state = "off";
+       };
+};
+
 &pcie {
        pinctrl-names = "default";
        pinctrl-0 = <&pcie_default>;
@@ -257,257 +281,12 @@ &pcie1_phy {
        status = "okay";
 };
 
-&pio {
-       cir_pins_a:cir@0 {
-               pins-cir {
-                       pinmux = <MT7623_PIN_46_IR_FUNC_IR>;
-                       bias-disable;
-               };
-       };
-
-       i2c0_pins_a: i2c@0 {
-               pins-i2c0 {
-                       pinmux = <MT7623_PIN_75_SDA0_FUNC_SDA0>,
-                                <MT7623_PIN_76_SCL0_FUNC_SCL0>;
-                       bias-disable;
-               };
-       };
-
-       i2c1_pins_a: i2c@1 {
-               pin-i2c1 {
-                       pinmux = <MT7623_PIN_57_SDA1_FUNC_SDA1>,
-                                <MT7623_PIN_58_SCL1_FUNC_SCL1>;
-                       bias-disable;
-               };
-       };
-
-       i2s0_pins_a: i2s@0 {
-               pin-i2s0 {
-                       pinmux = <MT7623_PIN_49_I2S0_DATA_FUNC_I2S0_DATA>,
-                                <MT7623_PIN_72_I2S0_DATA_IN_FUNC_I2S0_DATA_IN>,
-                                <MT7623_PIN_73_I2S0_LRCK_FUNC_I2S0_LRCK>,
-                                <MT7623_PIN_74_I2S0_BCK_FUNC_I2S0_BCK>,
-                                <MT7623_PIN_126_I2S0_MCLK_FUNC_I2S0_MCLK>;
-                       drive-strength = <MTK_DRIVE_12mA>;
-                       bias-pull-down;
-               };
-       };
-
-       i2s1_pins_a: i2s@1 {
-               pin-i2s1 {
-                       pinmux = <MT7623_PIN_33_I2S1_DATA_FUNC_I2S1_DATA>,
-                                <MT7623_PIN_34_I2S1_DATA_IN_FUNC_I2S1_DATA_IN>,
-                                <MT7623_PIN_35_I2S1_BCK_FUNC_I2S1_BCK>,
-                                <MT7623_PIN_36_I2S1_LRCK_FUNC_I2S1_LRCK>,
-                                <MT7623_PIN_37_I2S1_MCLK_FUNC_I2S1_MCLK>;
-                       drive-strength = <MTK_DRIVE_12mA>;
-                       bias-pull-down;
-               };
-       };
-
-       key_pins_a: keys@0 {
-               pins-keys {
-                       pinmux = <MT7623_PIN_256_GPIO256_FUNC_GPIO256>,
-                                <MT7623_PIN_257_GPIO257_FUNC_GPIO257> ;
-                       input-enable;
-               };
-       };
-
-       led_pins_a: leds@0 {
-               pins-leds {
-                       pinmux = <MT7623_PIN_239_EXT_SDIO0_FUNC_GPIO239>,
-                                <MT7623_PIN_240_EXT_XCS_FUNC_GPIO240>,
-                                <MT7623_PIN_241_EXT_SCK_FUNC_GPIO241>;
-               };
-       };
-
-       mmc0_pins_default: mmc0default {
-               pins-cmd-dat {
-                       pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
-                                <MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
-                                <MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
-                                <MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
-                                <MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
-                                <MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
-                                <MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
-                                <MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
-                                <MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
-                       input-enable;
-                       bias-pull-up;
-               };
-
-               pins-clk {
-                       pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
-                       bias-pull-down;
-               };
-
-               pins-rst {
-                       pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
-                       bias-pull-up;
-               };
-       };
-
-       mmc0_pins_uhs: mmc0 {
-               pins-cmd-dat {
-                       pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_MSDC0_DAT7>,
-                                <MT7623_PIN_112_MSDC0_DAT6_FUNC_MSDC0_DAT6>,
-                                <MT7623_PIN_113_MSDC0_DAT5_FUNC_MSDC0_DAT5>,
-                                <MT7623_PIN_114_MSDC0_DAT4_FUNC_MSDC0_DAT4>,
-                                <MT7623_PIN_118_MSDC0_DAT3_FUNC_MSDC0_DAT3>,
-                                <MT7623_PIN_119_MSDC0_DAT2_FUNC_MSDC0_DAT2>,
-                                <MT7623_PIN_120_MSDC0_DAT1_FUNC_MSDC0_DAT1>,
-                                <MT7623_PIN_121_MSDC0_DAT0_FUNC_MSDC0_DAT0>,
-                                <MT7623_PIN_116_MSDC0_CMD_FUNC_MSDC0_CMD>;
-                       input-enable;
-                       drive-strength = <MTK_DRIVE_2mA>;
-                       bias-pull-up = <MTK_PUPD_SET_R1R0_01>;
-               };
-
-               pins-clk {
-                       pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_MSDC0_CLK>;
-                       drive-strength = <MTK_DRIVE_2mA>;
-                       bias-pull-down = <MTK_PUPD_SET_R1R0_01>;
-               };
-
-               pins-rst {
-                       pinmux = <MT7623_PIN_115_MSDC0_RSTB_FUNC_MSDC0_RSTB>;
-                       bias-pull-up;
-               };
-       };
-
-       mmc1_pins_default: mmc1default {
-               pins-cmd-dat {
-                       pinmux = <MT7623_PIN_107_MSDC1_DAT0_FUNC_MSDC1_DAT0>,
-                                <MT7623_PIN_108_MSDC1_DAT1_FUNC_MSDC1_DAT1>,
-                                <MT7623_PIN_109_MSDC1_DAT2_FUNC_MSDC1_DAT2>,
-                                <MT7623_PIN_110_MSDC1_DAT3_FUNC_MSDC1_DAT3>,
-                                <MT7623_PIN_105_MSDC1_CMD_FUNC_MSDC1_CMD>;
-                       input-enable;
-                       drive-strength = <MTK_DRIVE_4mA>;
-                       bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
-               };
-
-               pins-clk {
-                       pinmux = <MT7623_PIN_106_MSDC1_CLK_FUNC_MSDC1_CLK>;
-                       bias-pull-down;
-                       drive-strength = <MTK_DRIVE_4mA>;
-               };
-
-               pins-wp {
-                       pinmux = <MT7623_PIN_29_EINT7_FUNC_MSDC1_WP>;
-                       input-enable;
-                       bias-pull-up;
-               };
-
-               pins-insert {
-                       pinmux = <MT7623_PIN_261_MSDC1_INS_FUNC_GPIO261>;
-                       bias-pull-up;
-               };
-       };
-
-       mmc1_pins_uhs: mmc1 {
-               pins-cmd-dat {
-                       pinmux = <MT7623_PIN_107_MSDC1_DAT0_FUNC_MSDC1_DAT0>,
-                                <MT7623_PIN_108_MSDC1_DAT1_FUNC_MSDC1_DAT1>,
-                                <MT7623_PIN_109_MSDC1_DAT2_FUNC_MSDC1_DAT2>,
-                                <MT7623_PIN_110_MSDC1_DAT3_FUNC_MSDC1_DAT3>,
-                                <MT7623_PIN_105_MSDC1_CMD_FUNC_MSDC1_CMD>;
-                       input-enable;
-                       drive-strength = <MTK_DRIVE_4mA>;
-                       bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
-               };
-
-               pins-clk {
-                       pinmux = <MT7623_PIN_106_MSDC1_CLK_FUNC_MSDC1_CLK>;
-                       drive-strength = <MTK_DRIVE_4mA>;
-                       bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
-               };
-       };
-
-       pcie_default: pcie_pin_default {
-               pins_cmd_dat {
-                       pinmux = <MT7623_PIN_208_AUD_EXT_CK1_FUNC_PCIE0_PERST_N>,
-                                <MT7623_PIN_209_AUD_EXT_CK2_FUNC_PCIE1_PERST_N>;
-                       bias-disable;
-               };
-       };
-
-       pwm_pins_a: pwm@0 {
-               pins-pwm {
-                       pinmux = <MT7623_PIN_203_PWM0_FUNC_PWM0>,
-                                <MT7623_PIN_204_PWM1_FUNC_PWM1>,
-                                <MT7623_PIN_205_PWM2_FUNC_PWM2>,
-                                <MT7623_PIN_206_PWM3_FUNC_PWM3>,
-                                <MT7623_PIN_207_PWM4_FUNC_PWM4>;
-               };
-       };
-
-       spi0_pins_a: spi@0 {
-               pins-spi {
-                       pinmux = <MT7623_PIN_53_SPI0_CSN_FUNC_SPI0_CS>,
-                               <MT7623_PIN_54_SPI0_CK_FUNC_SPI0_CK>,
-                               <MT7623_PIN_55_SPI0_MI_FUNC_SPI0_MI>,
-                               <MT7623_PIN_56_SPI0_MO_FUNC_SPI0_MO>;
-                       bias-disable;
-               };
-       };
-
-       uart0_pins_a: uart@0 {
-               pins-dat {
-                       pinmux = <MT7623_PIN_79_URXD0_FUNC_URXD0>,
-                                <MT7623_PIN_80_UTXD0_FUNC_UTXD0>;
-               };
-       };
-
-       uart1_pins_a: uart@1 {
-               pins-dat {
-                       pinmux = <MT7623_PIN_81_URXD1_FUNC_URXD1>,
-                                <MT7623_PIN_82_UTXD1_FUNC_UTXD1>;
-               };
-       };
-
-       uart2_pins_a: uart@2 {
-               pins-dat {
-                       pinmux = <MT7623_PIN_14_GPIO14_FUNC_URXD2>,
-                                <MT7623_PIN_15_GPIO15_FUNC_UTXD2>;
-               };
-       };
-};
-
 &pwm {
        pinctrl-names = "default";
        pinctrl-0 = <&pwm_pins_a>;
        status = "okay";
 };
 
-&pwrap {
-       mt6323 {
-               mt6323led: led {
-                       compatible = "mediatek,mt6323-led";
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-
-                       led@0 {
-                               reg = <0>;
-                               label = "bpi-r2:isink:green";
-                               default-state = "off";
-                       };
-
-                       led@1 {
-                               reg = <1>;
-                               label = "bpi-r2:isink:red";
-                               default-state = "off";
-                       };
-
-                       led@2 {
-                               reg = <2>;
-                               label = "bpi-r2:isink:blue";
-                               default-state = "off";
-                       };
-               };
-       };
-};
-
 &spi0 {
        pinctrl-names = "default";
        pinctrl-0 = <&spi0_pins_a>;
diff --git a/arch/arm/boot/dts/mt7623n-rfb-emmc.dts b/arch/arm/boot/dts/mt7623n-rfb-emmc.dts
new file mode 100644 (file)
index 0000000..b760613
--- /dev/null
@@ -0,0 +1,326 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2017-2018 MediaTek Inc.
+ * Author: Sean Wang <sean.wang@mediatek.com>
+ *
+ */
+
+/dts-v1/;
+#include <dt-bindings/input/input.h>
+#include "mt7623.dtsi"
+#include "mt6323.dtsi"
+
+/ {
+       model = "MediaTek MT7623N with eMMC reference board";
+       compatible = "mediatek,mt7623n-rfb-emmc", "mediatek,mt7623";
+
+       aliases {
+               serial0 = &uart0;
+               serial1 = &uart1;
+               serial2 = &uart2;
+       };
+
+       chosen {
+               stdout-path = "serial2:115200n8";
+       };
+
+       cpus {
+               cpu@0 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+
+               cpu@1 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+
+               cpu@2 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+
+               cpu@3 {
+                       proc-supply = <&mt6323_vproc_reg>;
+               };
+       };
+
+       gpio-keys {
+               compatible = "gpio-keys";
+               pinctrl-names = "default";
+               pinctrl-0 = <&key_pins_a>;
+
+               factory {
+                       label = "factory";
+                       linux,code = <BTN_0>;
+                       gpios = <&pio 256 GPIO_ACTIVE_LOW>;
+               };
+
+               wps {
+                       label = "wps";
+                       linux,code = <KEY_WPS_BUTTON>;
+                       gpios = <&pio 257 GPIO_ACTIVE_HIGH>;
+               };
+       };
+
+       memory@80000000 {
+               device_type = "memory";
+               reg = <0 0x80000000 0 0x40000000>;
+       };
+
+       reg_1p8v: regulator-1p8v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-1.8V";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       reg_3p3v: regulator-3p3v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       reg_5v: regulator-5v {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-5V";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       sound {
+               compatible = "mediatek,mt2701-wm8960-machine";
+               mediatek,platform = <&afe>;
+               audio-routing =
+                       "Headphone", "HP_L",
+                       "Headphone", "HP_R",
+                       "LINPUT1", "AMIC",
+                       "RINPUT1", "AMIC";
+               mediatek,audio-codec = <&wm8960>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&i2s0_pins_a>;
+       };
+};
+
+&btif {
+       status = "okay";
+};
+
+&cir {
+       pinctrl-names = "default";
+       pinctrl-0 = <&cir_pins_a>;
+       status = "okay";
+};
+
+&crypto {
+       status = "okay";
+};
+
+&eth {
+       status = "okay";
+
+       gmac0: mac@0 {
+               compatible = "mediatek,eth-mac";
+               reg = <0>;
+               phy-mode = "trgmii";
+
+               fixed-link {
+                       speed = <1000>;
+                       full-duplex;
+                       pause;
+               };
+       };
+
+       mac@1 {
+               compatible = "mediatek,eth-mac";
+               reg = <1>;
+               phy-handle = <&phy5>;
+       };
+
+       mdio-bus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               phy5: ethernet-phy@5 {
+                       reg = <5>;
+                       phy-mode = "rgmii-rxid";
+               };
+
+               switch@0 {
+                       compatible = "mediatek,mt7530";
+                       reg = <0>;
+                       reset-gpios = <&pio 33 0>;
+                       core-supply = <&mt6323_vpa_reg>;
+                       io-supply = <&mt6323_vemc3v3_reg>;
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@0 {
+                                       reg = <0>;
+                                       label = "lan0";
+                               };
+
+                               port@1 {
+                                       reg = <1>;
+                                       label = "lan1";
+                               };
+
+                               port@2 {
+                                       reg = <2>;
+                                       label = "lan2";
+                               };
+
+                               port@3 {
+                                       reg = <3>;
+                                       label = "lan3";
+                               };
+
+                               port@4 {
+                                       reg = <4>;
+                                       label = "wan";
+                               };
+
+                               port@6 {
+                                       reg = <6>;
+                                       label = "cpu";
+                                       ethernet = <&gmac0>;
+                                       phy-mode = "trgmii";
+
+                                       fixed-link {
+                                               speed = <1000>;
+                                               full-duplex;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+
+&i2c0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c0_pins_a>;
+       status = "okay";
+};
+
+&i2c1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c1_pins_b>;
+       status = "okay";
+
+       wm8960: wm8960@1a {
+               compatible = "wlf,wm8960";
+               reg = <0x1a>;
+       };
+};
+
+&i2c2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c2_pins_a>;
+       status = "okay";
+};
+
+&mmc0 {
+       pinctrl-names = "default", "state_uhs";
+       pinctrl-0 = <&mmc0_pins_default>;
+       pinctrl-1 = <&mmc0_pins_uhs>;
+       status = "okay";
+       bus-width = <8>;
+       max-frequency = <50000000>;
+       cap-mmc-highspeed;
+       vmmc-supply = <&reg_3p3v>;
+       vqmmc-supply = <&reg_1p8v>;
+       non-removable;
+};
+
+&mmc1 {
+       pinctrl-names = "default", "state_uhs";
+       pinctrl-0 = <&mmc1_pins_default>;
+       pinctrl-1 = <&mmc1_pins_uhs>;
+       status = "okay";
+       bus-width = <4>;
+       max-frequency = <50000000>;
+       cap-sd-highspeed;
+       cd-gpios = <&pio 261 GPIO_ACTIVE_LOW>;
+       vmmc-supply = <&reg_3p3v>;
+       vqmmc-supply = <&reg_3p3v>;
+};
+
+&pcie {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pcie_default>;
+       status = "okay";
+
+       pcie@0,0 {
+               status = "okay";
+       };
+
+       pcie@1,0 {
+               status = "okay";
+       };
+};
+
+&pcie0_phy {
+       status = "okay";
+};
+
+&pcie1_phy {
+       status = "okay";
+};
+
+&pwm {
+       pinctrl-names = "default";
+       pinctrl-0 = <&pwm_pins_a>;
+       status = "okay";
+};
+
+&spi0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi0_pins_a>;
+       status = "okay";
+};
+
+&spi1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi1_pins_a>;
+       status = "okay";
+};
+
+&spi2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&spi2_pins_a>;
+       status = "okay";
+};
+
+&uart0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart0_pins_a>;
+       status = "okay";
+};
+
+&uart1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart1_pins_a>;
+       status = "okay";
+};
+
+&uart2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart2_pins_a>;
+       status = "okay";
+};
+
+&usb1 {
+       vusb33-supply = <&reg_3p3v>;
+       vbus-supply = <&reg_5v>;
+       status = "okay";
+};
+
+&u3phy1 {
+       status = "okay";
+};
index f729c718aba1ad74ba23b4b1da896b28ef31e054..96ff3c9068aee5f117d12267d1e4feb063e1a245 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2017 MediaTek Inc.
  * Author: John Crispin <john@phrozen.org>
  *
- * 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.
  */
 
 /dts-v1/;
@@ -78,34 +71,3 @@ partition@5140000 {
                };
        };
 };
-
-&pio {
-       nand_pins_default: nanddefault {
-               pins-ale {
-                       pinmux = <MT7623_PIN_116_MSDC0_CMD_FUNC_NALE>;
-                       drive-strength = <MTK_DRIVE_8mA>;
-                       bias-pull-down = <MTK_PUPD_SET_R1R0_10>;
-               };
-
-               pins-dat {
-                       pinmux = <MT7623_PIN_111_MSDC0_DAT7_FUNC_NLD7>,
-                                <MT7623_PIN_112_MSDC0_DAT6_FUNC_NLD6>,
-                                <MT7623_PIN_114_MSDC0_DAT4_FUNC_NLD4>,
-                                <MT7623_PIN_118_MSDC0_DAT3_FUNC_NLD3>,
-                                <MT7623_PIN_121_MSDC0_DAT0_FUNC_NLD0>,
-                                <MT7623_PIN_120_MSDC0_DAT1_FUNC_NLD1>,
-                                <MT7623_PIN_113_MSDC0_DAT5_FUNC_NLD5>,
-                                <MT7623_PIN_115_MSDC0_RSTB_FUNC_NLD8>,
-                                <MT7623_PIN_119_MSDC0_DAT2_FUNC_NLD2>;
-                       input-enable;
-                       drive-strength = <MTK_DRIVE_8mA>;
-                       bias-pull-up;
-               };
-
-               pins-we {
-                       pinmux = <MT7623_PIN_117_MSDC0_CLK_FUNC_NWEB>;
-                       drive-strength = <MTK_DRIVE_8mA>;
-                       bias-pull-up = <MTK_PUPD_SET_R1R0_10>;
-               };
-       };
-};
index 256c5fd947bf4344bc6fbd42156ca523a52c3489..5c5cc7da5dd2962fdbb7a0c45909994389ae90f7 100644 (file)
@@ -1,16 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2017 MediaTek Inc.
  * Author: John Crispin <john@phrozen.org>
  *        Sean Wang <sean.wang@mediatek.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.
  */
 
 /dts-v1/;
@@ -47,10 +40,11 @@ cpu3 {
        };
 
        memory@80000000 {
+               device_type = "memory";
                reg = <0 0x80000000 0 0x40000000>;
        };
 
-       usb_p1_vbus: regulator@0 {
+       usb_p1_vbus: regulator-5v {
                compatible = "regulator-fixed";
                regulator-name = "usb_vbus";
                regulator-min-microvolt = <5000000>;
index 073e295a1cb4b499ad3d7c9de174da5f5aefe636..308829b2da863309583dcffda8c63395eb3fbf11 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 MediaTek Inc.
  * Author: Joe.C <yingjoe.chen@mediatek.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.
  */
 
 /dts-v1/;
index 916c095d11b909ea1f6b2a4e08a0a215158501f4..3adfc6f7859cf325aea07f4ee27c02ee9885300a 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 MediaTek Inc.
  * Author: Joe.C <yingjoe.chen@mediatek.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.
  */
 
 #include <dt-bindings/interrupt-controller/irq.h>
index 460db6d05952985d705a96f1c2979f46d91bded1..0ace7a40a60daa6094b8dcead9dd5e164734cbd9 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 MediaTek Inc.
  * Author: Joe.C <yingjoe.chen@mediatek.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.
  */
 
 /dts-v1/;
index a97b4ee4ae797f9ca56fc16ae6d4b37466f4eef7..688069dc15338f8d343401cd658ab765943f08f7 100644 (file)
@@ -1,15 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 MediaTek Inc.
  * Author: Joe.C <yingjoe.chen@mediatek.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.
  */
 
 #include <dt-bindings/clock/mt8135-clk.h>
index 7c485fbfa5353dfc9031e746c5c4539a4a890030..96b9913ecc1f9a281c01473118de715a4e67a076 100644 (file)
@@ -6,11 +6,70 @@
 / {
        model = "Nokia N810";
        compatible = "nokia,n810", "nokia,n8x0", "ti,omap2420", "ti,omap2";
+
+       vio_ape: vio_ape {
+               compatible = "regulator-fixed";
+               regulator-name = "vio_ape";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+       };
+
+       v28_aic: v28_aic {
+               compatible = "regulator-fixed";
+               regulator-name = "v28_aic";
+               regulator-min-microvolt = <2800000>;
+               regulator-max-microvolt = <2800000>;
+       };
+};
+
+&omap2420_pmx {
+       mcbsp2_pins: mcbsp2_pins {
+               pinctrl-single,pins = <
+                       OMAP2420_CORE_IOPAD(0x0124, PIN_INPUT | MUX_MODE1)      /* eac_ac_sclk.mcbsp2_clkx */
+                       OMAP2420_CORE_IOPAD(0x0125, PIN_INPUT | MUX_MODE1)      /* eac_ac_fs.mcbsp2_fsx */
+                       OMAP2420_CORE_IOPAD(0x0126, PIN_INPUT | MUX_MODE1)      /* eac_ac_din.mcbsp2_dr */
+                       OMAP2420_CORE_IOPAD(0x0127, PIN_OUTPUT | MUX_MODE1)     /* eac_ac_dout.mcbsp2_dx */
+               >;
+       };
+
+       aic33_pins: aic33_pins {
+               pinctrl-single,pins = <
+                       OMAP2420_CORE_IOPAD(0x0129, PIN_OUTPUT | MUX_MODE3)     /* eac_ac_rst.gpio118 */
+                       OMAP2420_CORE_IOPAD(0x00e8, PIN_OUTPUT | MUX_MODE2)     /* vlynq_tx1.sys_clkout2 */
+               >;
+       };
 };
 
 &i2c2 {
-       aic3x@18 {
-               compatible = "tlv320aic3x";
+       aic33@18 {
+               compatible = "ti,tlv320aic33";
                reg = <0x18>;
+
+               pinctrl-names = "default";
+               pinctrl-0 = <&aic33_pins>;
+
+               gpio-reset = <&gpio4 22 GPIO_ACTIVE_LOW>; /* gpio118 */
+
+               ai3x-gpio-func = <
+                       10 /* AIC3X_GPIO1_FUNC_DIGITAL_MIC_MODCLK */
+                       5 /* AIC3X_GPIO2_FUNC_DIGITAL_MIC_INPUT */
+               >;
+               ai3x-micbias-vg = <1>; /* 2V */
+
+               AVDD-supply = <&v28_aic>;
+               DRVDD-supply = <&v28_aic>;
+               IOVDD-supply = <&vio_ape>;
+               DVDD-supply = <&vio_ape>;
+
+               assigned-clocks = <&sys_clkout2_src>, <&sys_clkout2>;
+               assigned-clock-parents = <&func_96m_ck>;
+               assigned-clock-rates = <0>, <12000000>;
        };
 };
+
+&mcbsp2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&mcbsp2_pins>;
+
+       status = "okay";
+};
index 0349fcc9dc26ab8d80f568b1d5c8528a78a8a588..d80587de0bbf565d765969b733a769ed45719cc1 100644 (file)
@@ -30,6 +30,13 @@ aliases {
                ethernet = &ethernet;
        };
 
+       /* fixed 26MHz oscillator */
+       hfclk_26m: oscillator {
+               #clock-cells = <0>;
+               compatible = "fixed-clock";
+               clock-frequency = <26000000>;
+       };
+
        leds {
                compatible = "gpio-leds";
 
@@ -274,6 +281,9 @@ twl: twl@48 {
                interrupts = <7>; /* SYS_NIRQ cascaded to intc */
                interrupt-parent = <&intc>;
 
+               clocks = <&hfclk_26m>;
+               clock-names = "fck";
+
                twl_audio: audio {
                        compatible = "ti,twl4030-audio";
                        codec {
index 9dcb18d22cde9dbc7620497256b9e9ead84d06f8..cdb632df152a1fb9d7ca4048b42065309942cabe 100644 (file)
@@ -60,7 +60,7 @@ ads7846reg: ads7846-reg {
                regulator-max-microvolt = <3300000>;
        };
 
-       tv0: connector {
+       tv0: svideo-connector {
                compatible = "svideo-connector";
                label = "tv";
 
index 0c0bb1b01b0ba004af0afbb5c5b4fca099a57055..746a658e84b686d944472aecb00ab3f5f8bd8adb 100644 (file)
@@ -349,10 +349,17 @@ &dss {
        vdda_dac-supply = <&vdac>;
 
        port {
-               dpi_dvi_out: endpoint {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               dpi_dvi_out: endpoint@0 {
+                       reg = <0>;
                        remote-endpoint = <&tfp410_in>;
                        data-lines = <24>;
                };
+
+               endpoint@1 {
+                       reg = <1>;
+               };
        };
 };
 
index 2d64bcffaaa882c382b586e64f9db51b50e1c91d..1093387259e2a0115553b23064ec23ea8b429437 100644 (file)
@@ -30,7 +30,10 @@ lcd_in: endpoint {
 
 &dss {
        port {
-               dpi_lcd_out: endpoint {
+               #address-cells = <1>;
+               #size-cells = <0>;
+               dpi_lcd_out: endpoint@1 {
+                       reg = <1>;
                        remote-endpoint = <&lcd_in>;
                        data-lines = <24>;
                };
index 4170be70460ecdb000ca48bba21caa4f0f794419..ac830b9177763d32a70b8807e02f35cb039efc17 100644 (file)
@@ -30,6 +30,13 @@ aliases {
                display0 = &lcd;
        };
 
+       /* fixed 26MHz oscillator */
+       hfclk_26m: oscillator {
+               #clock-cells = <0>;
+               compatible = "fixed-clock";
+               clock-frequency = <26000000>;
+       };
+
        gpio-keys {
                compatible = "gpio-keys";
 
@@ -312,6 +319,9 @@ twl: twl@48 {
                interrupts = <7>; /* SYS_NIRQ cascaded to intc */
                interrupt-parent = <&intc>;
 
+               clocks = <&hfclk_26m>;
+               clock-names = "fck";
+
                twl_audio: audio {
                        compatible = "ti,twl4030-audio";
                        ti,enable-vibra = <1>;
index f83b1029b3b72b7122289bff8434d9394bd98490..90c98f95b2b3ac8b572655a18e04eaa2f4c95801 100644 (file)
@@ -27,6 +27,13 @@ aliases {
                display0 = &lcd;
        };
 
+       /* fixed 26MHz oscillator */
+       hfclk_26m: oscillator {
+               #clock-cells = <0>;
+               compatible = "fixed-clock";
+               clock-frequency = <26000000>;
+       };
+
        tv: connector {
                compatible = "connector-analog-tv";
                label = "tv";
@@ -357,6 +364,9 @@ twl: twl@48 {
                interrupts = <7>; /* SYS_NIRQ cascaded to intc */
                interrupt-parent = <&intc>;
 
+               clocks = <&hfclk_26m>;
+               clock-names = "fck";
+
                twl_power: power {
                        compatible = "ti,twl4030-power-reset";
                        ti,use_poweroff;
@@ -611,7 +621,7 @@ tsc2046@0 {
                pinctrl-names = "default";
                pinctrl-0 = <&penirq_pins>;
                interrupt-parent = <&gpio3>;
-               interrupts = <30 0>;    /* GPIO_94 */
+               interrupts = <30 IRQ_TYPE_NONE>;        /* GPIO_94 */
                pendown-gpio = <&gpio3 30 GPIO_ACTIVE_HIGH>;
                vcc-supply = <&vaux4>;
 
index 22b4c8bdcc65211f9f3fa8d52caa4d5d7ed0db96..fb9842fa922c3f6bf632c4f29971a9443de5e124 100644 (file)
@@ -34,7 +34,7 @@ tfp410_out: endpoint {
                };
        };
 
-       dvi0: connector {
+       dvi0: dvi-connector {
                compatible = "dvi-connector";
                label = "dvi";
 
index 982d1a62661d4e8d265c66ccba8193635a571962..132a3b8ab14849ad6634f466c2e8320062779662 100644 (file)
@@ -8,6 +8,10 @@
         (gpio <= 98) ? (0x0400 + 4 * (gpio - 27)) :    \
         (gpio <= 127) ? (0x0600 + 4 * (gpio - 99)) :   \
         0)
+#define MFP_PIN_PXA300_2(gpio)                         \
+       ((gpio <= 1) ? (0x674 + 4 * gpio) :             \
+        (gpio <= 6) ? (0x2dc + 4 * gpio) :             \
+        0)
 
 #define MFP_PIN_PXA310(gpio)                           \
        ((gpio <= 2) ? (0x00b4 + 4 * gpio) :            \
         (gpio <= 262) ? 0 :                            \
         (gpio <= 268) ? (0x052c + 4 * (gpio - 263)) :  \
         0)
+#define MFP_PIN_PXA310_2(gpio)                         \
+       ((gpio <= 1) ? (0x674 + 4 * gpio) :             \
+        (gpio <= 6) ? (0x2dc + 4 * gpio) :             \
+        (gpio <= 10) ? (0x52c + 4 * gpio) :            \
+        0)
 
 #define MFP_PIN_PXA320(gpio)                           \
        ((gpio <= 4) ? (0x0124 + 4 * gpio) :            \
         (gpio <= 98) ? (0x04f0 + 4 * (gpio - 74)) :    \
         (gpio <= 127) ? (0x0600 + 4 * (gpio - 99)) :   \
         0)
+#define MFP_PIN_PXA320_2(gpio)                         \
+       ((gpio <= 3) ? (0x674 + 4 * gpio) :             \
+        (gpio <= 5) ? (0x284 + 4 * gpio) :             \
+        0)
 
 /*
  * MFP Alternate functions for pins having a gpio.
@@ -148,6 +161,7 @@ gpio: gpio@40e00000 {
                        compatible = "intel,pxa3xx-gpio";
                        reg = <0x40e00000 0x10000>;
                        clocks = <&clks CLK_GPIO>;
+                       gpio-ranges = <&pinctrl 0 0 128>;
                        interrupt-names = "gpio0", "gpio1", "gpio_mux";
                        interrupts = <8 9 10>;
                        gpio-controller;
@@ -160,7 +174,7 @@ mmc0: mmc@41100000 {
                        compatible = "marvell,pxa-mmc";
                        reg = <0x41100000 0x1000>;
                        interrupts = <23>;
-                       clocks = <&clks CLK_MMC>;
+                       clocks = <&clks CLK_MMC1>;
                        dmas = <&pdma 21 3
                                &pdma 22 3>;
                        dma-names = "rx", "tx";
@@ -171,7 +185,7 @@ mmc1: mmc@42000000 {
                        compatible = "marvell,pxa-mmc";
                        reg = <0x42000000 0x1000>;
                        interrupts = <41>;
-                       clocks = <&clks CLK_MMC1>;
+                       clocks = <&clks CLK_MMC2>;
                        dmas = <&pdma 93 3
                                &pdma 94 3>;
                        dma-names = "rx", "tx";
@@ -182,7 +196,7 @@ mmc2: mmc@42500000 {
                        compatible = "marvell,pxa-mmc";
                        reg = <0x42500000 0x1000>;
                        interrupts = <55>;
-                       clocks = <&clks CLK_MMC2>;
+                       clocks = <&clks CLK_MMC3>;
                        dmas = <&pdma 46 3
                                &pdma 47 3>;
                        dma-names = "rx", "tx";
index 5341a39c0392709d7315a010785ae8524ff1373a..4a99c9255104913964cbe9b984d9150bd52d7ef9 100644 (file)
@@ -444,7 +444,7 @@ gsbi1_serial: serial@12450000 {
                                compatible = "qcom,msm-uartdm-v1.3", "qcom,msm-uartdm";
                                reg = <0x12450000 0x100>,
                                      <0x12400000 0x03>;
-                               interrupts = <0 193 0x0>;
+                               interrupts = <0 193 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI1_UART_CLK>, <&gcc GSBI1_H_CLK>;
                                clock-names = "core", "iface";
                                status = "disabled";
@@ -456,11 +456,12 @@ gsbi1_i2c: i2c@12460000 {
                                pinctrl-1 = <&i2c1_pins_sleep>;
                                pinctrl-names = "default", "sleep";
                                reg = <0x12460000 0x1000>;
-                               interrupts = <0 194 IRQ_TYPE_NONE>;
+                               interrupts = <0 194 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI1_QUP_CLK>, <&gcc GSBI1_H_CLK>;
                                clock-names = "core", "iface";
                                #address-cells = <1>;
                                #size-cells = <0>;
+                               status = "disabled";
                        };
 
                };
@@ -484,11 +485,12 @@ gsbi2_i2c: i2c@124a0000 {
                                pinctrl-0 = <&i2c2_pins>;
                                pinctrl-1 = <&i2c2_pins_sleep>;
                                pinctrl-names = "default", "sleep";
-                               interrupts = <0 196 IRQ_TYPE_NONE>;
+                               interrupts = <0 196 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI2_QUP_CLK>, <&gcc GSBI2_H_CLK>;
                                clock-names = "core", "iface";
                                #address-cells = <1>;
                                #size-cells = <0>;
+                               status = "disabled";
                        };
                };
 
@@ -508,12 +510,13 @@ gsbi3_i2c: i2c@16280000 {
                                pinctrl-1 = <&i2c3_pins_sleep>;
                                pinctrl-names = "default", "sleep";
                                reg = <0x16280000 0x1000>;
-                               interrupts = <GIC_SPI 151 IRQ_TYPE_NONE>;
+                               interrupts = <GIC_SPI 151 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI3_QUP_CLK>,
                                         <&gcc GSBI3_H_CLK>;
                                clock-names = "core", "iface";
                                #address-cells = <1>;
                                #size-cells = <0>;
+                               status = "disabled";
                        };
                };
 
@@ -534,10 +537,11 @@ gsbi4_i2c: i2c@16380000 {
                                pinctrl-1 = <&i2c4_pins_sleep>;
                                pinctrl-names = "default", "sleep";
                                reg = <0x16380000 0x1000>;
-                               interrupts = <GIC_SPI 153 IRQ_TYPE_NONE>;
+                               interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI4_QUP_CLK>,
                                         <&gcc GSBI4_H_CLK>;
                                clock-names = "core", "iface";
+                               status = "disabled";
                        };
                };
 
@@ -556,7 +560,7 @@ gsbi5_serial: serial@1a240000 {
                                compatible = "qcom,msm-uartdm-v1.3", "qcom,msm-uartdm";
                                reg = <0x1a240000 0x100>,
                                      <0x1a200000 0x03>;
-                               interrupts = <0 154 0x0>;
+                               interrupts = <0 154 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI5_UART_CLK>, <&gcc GSBI5_H_CLK>;
                                clock-names = "core", "iface";
                                status = "disabled";
@@ -565,7 +569,7 @@ gsbi5_serial: serial@1a240000 {
                        gsbi5_spi: spi@1a280000 {
                                compatible = "qcom,spi-qup-v1.1.1";
                                reg = <0x1a280000 0x1000>;
-                               interrupts = <0 155 0>;
+                               interrupts = <0 155 IRQ_TYPE_LEVEL_HIGH>;
                                pinctrl-0 = <&spi5_default>;
                                pinctrl-1 = <&spi5_sleep>;
                                pinctrl-names = "default", "sleep";
@@ -592,7 +596,7 @@ gsbi6_serial: serial@16540000 {
                                compatible = "qcom,msm-uartdm-v1.3", "qcom,msm-uartdm";
                                reg = <0x16540000 0x100>,
                                      <0x16500000 0x03>;
-                               interrupts = <0 156 0x0>;
+                               interrupts = <0 156 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI6_UART_CLK>, <&gcc GSBI6_H_CLK>;
                                clock-names = "core", "iface";
                                status = "disabled";
@@ -604,7 +608,7 @@ gsbi6_i2c: i2c@16580000 {
                                pinctrl-1 = <&i2c6_pins_sleep>;
                                pinctrl-names = "default", "sleep";
                                reg = <0x16580000 0x1000>;
-                               interrupts = <GIC_SPI 157 IRQ_TYPE_NONE>;
+                               interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI6_QUP_CLK>,
                                         <&gcc GSBI6_H_CLK>;
                                clock-names = "core", "iface";
@@ -628,7 +632,7 @@ gsbi7_serial: serial@16640000 {
                                compatible = "qcom,msm-uartdm-v1.3", "qcom,msm-uartdm";
                                reg = <0x16640000 0x1000>,
                                      <0x16600000 0x1000>;
-                               interrupts = <0 158 0x0>;
+                               interrupts = <0 158 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI7_UART_CLK>, <&gcc GSBI7_H_CLK>;
                                clock-names = "core", "iface";
                                status = "disabled";
@@ -640,7 +644,7 @@ gsbi7_i2c: i2c@16680000 {
                                pinctrl-1 = <&i2c7_pins_sleep>;
                                pinctrl-names = "default", "sleep";
                                reg = <0x16680000 0x1000>;
-                               interrupts = <GIC_SPI 159 IRQ_TYPE_NONE>;
+                               interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
                                clocks = <&gcc GSBI7_QUP_CLK>,
                                         <&gcc GSBI7_H_CLK>;
                                clock-names = "core", "iface";
@@ -1056,7 +1060,7 @@ sata0: sata@29000000 {
                        compatible              = "qcom,apq8064-ahci", "generic-ahci";
                        status                  = "disabled";
                        reg                     = <0x29000000 0x180>;
-                       interrupts              = <GIC_SPI 209 IRQ_TYPE_NONE>;
+                       interrupts              = <GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH>;
 
                        clocks                  = <&gcc SFAB_SATA_S_H_CLK>,
                                                <&gcc SATA_H_CLK>,
@@ -1082,7 +1086,7 @@ sata0: sata@29000000 {
                sdcc1bam:dma@12402000{
                        compatible = "qcom,bam-v1.3.0";
                        reg = <0x12402000 0x8000>;
-                       interrupts = <0 98 0>;
+                       interrupts = <0 98 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc SDC1_H_CLK>;
                        clock-names = "bam_clk";
                        #dma-cells = <1>;
@@ -1092,7 +1096,7 @@ sdcc1bam:dma@12402000{
                sdcc3bam:dma@12182000{
                        compatible = "qcom,bam-v1.3.0";
                        reg = <0x12182000 0x8000>;
-                       interrupts = <0 96 0>;
+                       interrupts = <0 96 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc SDC3_H_CLK>;
                        clock-names = "bam_clk";
                        #dma-cells = <1>;
@@ -1102,7 +1106,7 @@ sdcc3bam:dma@12182000{
                sdcc4bam:dma@121c2000{
                        compatible = "qcom,bam-v1.3.0";
                        reg = <0x121c2000 0x8000>;
-                       interrupts = <0 95 0>;
+                       interrupts = <0 95 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc SDC4_H_CLK>;
                        clock-names = "bam_clk";
                        #dma-cells = <1>;
@@ -1181,7 +1185,7 @@ gpu: adreno-3xx@4300000 {
                        compatible = "qcom,adreno-3xx";
                        reg = <0x04300000 0x20000>;
                        reg-names = "kgsl_3d0_reg_memory";
-                       interrupts = <GIC_SPI 80 0>;
+                       interrupts = <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "kgsl_3d0_irq";
                        clock-names =
                            "core_clk",
@@ -1281,7 +1285,7 @@ dsi0: mdss_dsi@4700000 {
                        label = "MDSS DSI CTRL->0";
                        #address-cells = <1>;
                        #size-cells = <0>;
-                       interrupts = <GIC_SPI 82 0>;
+                       interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
                        reg = <0x04700000 0x200>;
                        reg-names = "dsi_ctrl";
 
@@ -1350,8 +1354,8 @@ mdp_port0: iommu@7500000 {
                            <&mmcc MDP_AXI_CLK>;
                        reg = <0x07500000 0x100000>;
                        interrupts =
-                           <GIC_SPI 63 0>,
-                           <GIC_SPI 64 0>;
+                           <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>,
+                           <GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
                        qcom,ncb = <2>;
                };
 
@@ -1366,8 +1370,8 @@ mdp_port1: iommu@7600000 {
                            <&mmcc MDP_AXI_CLK>;
                        reg = <0x07600000 0x100000>;
                        interrupts =
-                           <GIC_SPI 61 0>,
-                           <GIC_SPI 62 0>;
+                           <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
+                           <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>;
                        qcom,ncb = <2>;
                };
 
@@ -1382,8 +1386,8 @@ gfx3d: iommu@7c00000 {
                            <&mmcc GFX3D_AXI_CLK>;
                        reg = <0x07c00000 0x100000>;
                        interrupts =
-                           <GIC_SPI 69 0>,
-                           <GIC_SPI 70 0>;
+                           <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>,
+                           <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
                        qcom,ncb = <3>;
                };
 
@@ -1398,8 +1402,8 @@ gfx3d1: iommu@7d00000 {
                            <&mmcc GFX3D_AXI_CLK>;
                        reg = <0x07d00000 0x100000>;
                        interrupts =
-                           <GIC_SPI 210 0>,
-                           <GIC_SPI 211 0>;
+                           <GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH>,
+                           <GIC_SPI 211 IRQ_TYPE_LEVEL_HIGH>;
                        qcom,ncb = <3>;
                };
 
@@ -1417,8 +1421,8 @@ pcie: pci@1b500000 {
                        #address-cells = <3>;
                        #size-cells = <2>;
                        ranges = <0x81000000 0 0 0x0fe00000 0 0x00100000   /* I/O */
-                                 0x82000000 0 0 0x08000000 0 0x07e00000>; /* memory */
-                       interrupts = <GIC_SPI 238 IRQ_TYPE_NONE>;
+                                 0x82000000 0 0x08000000 0x08000000 0 0x07e00000>; /* memory */
+                       interrupts = <GIC_SPI 238 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "msi";
                        #interrupt-cells = <1>;
                        interrupt-map-mask = <0 0 0 0x7>;
index e413b21ee3319be02927dca42aeef0c837698d00..418f9a0223363b8053fac02be4e1b4f5bda8be33 100644 (file)
@@ -20,6 +20,14 @@ / {
        model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK01.1";
        compatible = "qcom,ipq4019";
 
+       aliases {
+               serial0 = &blsp1_uart1;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
        soc {
                rng@22000 {
                        status = "ok";
@@ -61,7 +69,7 @@ blsp_dma: dma@7884000 {
                        status = "ok";
                };
 
-               spi_0: spi@78b5000 {
+               spi@78b5000 {
                        pinctrl-0 = <&spi_0_pins>;
                        pinctrl-names = "default";
                        status = "ok";
diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts b/arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c1.dts
new file mode 100644 (file)
index 0000000..7a96f30
--- /dev/null
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include "qcom-ipq4019-ap.dk04.1.dtsi"
+
+/ {
+       model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK04.1-C1";
+       compatible = "qcom,ipq4019-dk04.1-c1";
+
+       soc {
+               dma@7984000 {
+                       status = "ok";
+               };
+
+               qpic-nand@79b0000 {
+                       status = "ok";
+               };
+       };
+};
diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c3.dts b/arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1-c3.dts
new file mode 100644 (file)
index 0000000..2d1c4c6
--- /dev/null
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include "qcom-ipq4019-ap.dk04.1.dtsi"
+
+/ {
+       model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK04.1-C3";
+       compatible = "qcom,ipq4019-ap-dk04.1-c3";
+};
diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1.dtsi b/arch/arm/boot/dts/qcom-ipq4019-ap.dk04.1.dtsi
new file mode 100644 (file)
index 0000000..7c1eb19
--- /dev/null
@@ -0,0 +1,111 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include "qcom-ipq4019.dtsi"
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+       model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK04.1";
+
+       aliases {
+               serial0 = &blsp1_uart1;
+               serial1 = &blsp1_uart2;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       memory {
+               device_type = "memory";
+               reg = <0x80000000 0x10000000>; /* 256MB */
+       };
+
+       soc {
+               pinctrl@1000000 {
+                       serial_0_pins: serial0-pinmux {
+                               pins = "gpio16", "gpio17";
+                               function = "blsp_uart0";
+                               bias-disable;
+                       };
+
+                       serial_1_pins: serial1-pinmux {
+                               pins = "gpio8", "gpio9",
+                                       "gpio10", "gpio11";
+                               function = "blsp_uart1";
+                               bias-disable;
+                       };
+
+                       spi_0_pins: spi-0-pinmux {
+                               pinmux {
+                                       function = "blsp_spi0";
+                                       pins = "gpio13", "gpio14", "gpio15";
+                                       bias-disable;
+                               };
+                               pinmux_cs {
+                                       function = "gpio";
+                                       pins = "gpio12";
+                                       bias-disable;
+                                       output-high;
+                               };
+                       };
+
+                       i2c_0_pins: i2c-0-pinmux {
+                               pins = "gpio20", "gpio21";
+                               function = "blsp_i2c0";
+                               bias-disable;
+                       };
+
+                       nand_pins: nand-pins {
+                               pins = "gpio53", "gpio55", "gpio56",
+                                       "gpio57", "gpio58", "gpio59",
+                                       "gpio60", "gpio62", "gpio63",
+                                       "gpio64", "gpio65", "gpio66",
+                                       "gpio67", "gpio68", "gpio69";
+                               function = "qpic";
+                       };
+               };
+
+               serial@78af000 {
+                       pinctrl-0 = <&serial_0_pins>;
+                       pinctrl-names = "default";
+                       status = "ok";
+               };
+
+               serial@78b0000 {
+                       pinctrl-0 = <&serial_1_pins>;
+                       pinctrl-names = "default";
+                       status = "ok";
+               };
+
+               dma@7884000 {
+                       status = "ok";
+               };
+
+               spi@78b5000 { /* BLSP1 QUP1 */
+                       pinctrl-0 = <&spi_0_pins>;
+                       pinctrl-names = "default";
+                       status = "ok";
+                       cs-gpios = <&tlmm 12 0>;
+
+                       m25p80@0 {
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+                               reg = <0>;
+                               compatible = "n25q128a11";
+                               spi-max-frequency = <24000000>;
+                       };
+               };
+
+               pci@40000000 {
+                       status = "ok";
+                       perst-gpio = <&tlmm 38 0x1>;
+               };
+
+               qpic-nand@79b0000 {
+                       pinctrl-0 = <&nand_pins>;
+                       pinctrl-names = "default";
+               };
+       };
+};
diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c1.dts b/arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c1.dts
new file mode 100644 (file)
index 0000000..8c7ef65
--- /dev/null
@@ -0,0 +1,64 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include "qcom-ipq4019-ap.dk07.1.dtsi"
+
+/ {
+       model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK07.1-C1";
+       compatible = "qcom,ipq4019-ap-dk07.1-c1";
+
+       soc {
+               pci@40000000 {
+                       status = "ok";
+                       perst-gpio = <&tlmm 38 0x1>;
+               };
+
+               spi@78b6000 {
+                       status = "ok";
+               };
+
+               pinctrl@1000000 {
+                       serial_1_pins: serial1-pinmux {
+                               pins = "gpio8", "gpio9",
+                                       "gpio10", "gpio11";
+                               function = "blsp_uart1";
+                               bias-disable;
+                       };
+
+                       spi_0_pins: spi-0-pinmux {
+                               pinmux {
+                                       function = "blsp_spi0";
+                                       pins = "gpio13", "gpio14", "gpio15";
+                                       bias-disable;
+                               };
+                               pinmux_cs {
+                                       function = "gpio";
+                                       pins = "gpio12";
+                                       bias-disable;
+                                       output-high;
+                               };
+                       };
+               };
+
+               serial@78b0000 {
+                       pinctrl-0 = <&serial_1_pins>;
+                       pinctrl-names = "default";
+                       status = "ok";
+               };
+
+               spi@78b5000 {
+                       pinctrl-0 = <&spi_0_pins>;
+                       pinctrl-names = "default";
+                       status = "ok";
+                       cs-gpios = <&tlmm 12 0>;
+
+                       m25p80@0 {
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+                               reg = <0>;
+                               compatible = "n25q128a11";
+                               spi-max-frequency = <24000000>;
+                       };
+               };
+       };
+};
diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c2.dts b/arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1-c2.dts
new file mode 100644 (file)
index 0000000..af7a902
--- /dev/null
@@ -0,0 +1,25 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include "qcom-ipq4019-ap.dk07.1.dtsi"
+
+/ {
+       model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK07.1-C2";
+       compatible = "qcom,ipq4019-ap-dk07.1-c2";
+
+       soc {
+               pinctrl@1000000 {
+                       serial_1_pins: serial1-pinmux {
+                               pins = "gpio8", "gpio9";
+                               function = "blsp_uart1";
+                               bias-disable;
+                       };
+               };
+
+               serial@78b0000 {
+                       pinctrl-0 = <&serial_1_pins>;
+                       pinctrl-names = "default";
+                       status = "ok";
+               };
+       };
+};
diff --git a/arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1.dtsi b/arch/arm/boot/dts/qcom-ipq4019-ap.dk07.1.dtsi
new file mode 100644 (file)
index 0000000..9f1a5a6
--- /dev/null
@@ -0,0 +1,75 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2018, The Linux Foundation. All rights reserved.
+
+#include "qcom-ipq4019.dtsi"
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+       model = "Qualcomm Technologies, Inc. IPQ4019/AP-DK07.1";
+
+       memory {
+               device_type = "memory";
+               reg = <0x80000000 0x20000000>; /* 512MB */
+       };
+
+       aliases {
+               serial0 = &blsp1_uart1;
+               serial1 = &blsp1_uart2;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       soc {
+               pinctrl@1000000 {
+                       serial_0_pins: serial0-pinmux {
+                               pins = "gpio16", "gpio17";
+                               function = "blsp_uart0";
+                               bias-disable;
+                       };
+
+                       i2c_0_pins: i2c-0-pinmux {
+                               pins = "gpio20", "gpio21";
+                               function = "blsp_i2c0";
+                               bias-disable;
+                       };
+
+                       nand_pins: nand-pins {
+                               pins = "gpio53", "gpio55", "gpio56",
+                                      "gpio57", "gpio58", "gpio59",
+                                      "gpio60", "gpio62", "gpio63",
+                                      "gpio64", "gpio65", "gpio66",
+                                      "gpio67", "gpio68", "gpio69";
+                               function = "qpic";
+                        };
+               };
+
+               serial@78af000 {
+                       pinctrl-0 = <&serial_0_pins>;
+                       pinctrl-names = "default";
+                       status = "ok";
+               };
+
+               dma@7884000 {
+                       status = "ok";
+               };
+
+               i2c@78b7000 { /* BLSP1 QUP2 */
+                       pinctrl-0 = <&i2c_0_pins>;
+                       pinctrl-names = "default";
+                       status = "ok";
+               };
+
+               dma@7984000 {
+                       status = "ok";
+               };
+
+               qpic-nand@79b0000 {
+                       pinctrl-0 = <&nand_pins>;
+                       pinctrl-names = "default";
+                       status = "ok";
+               };
+       };
+};
index 10d112a4078ecef3c1a70dc3482de7a7511e599b..7bcd7635e723825a418bef408ea79f1fa262573a 100644 (file)
@@ -23,9 +23,27 @@ / {
        compatible = "qcom,ipq4019";
        interrupt-parent = <&intc>;
 
+       reserved-memory {
+               #address-cells = <0x1>;
+               #size-cells = <0x1>;
+               ranges;
+
+               smem_region: smem@87e00000 {
+                       reg = <0x87e00000 0x080000>;
+                       no-map;
+               };
+
+               tz@87e80000 {
+                       reg = <0x87e80000 0x180000>;
+                       no-map;
+               };
+       };
+
        aliases {
-               spi0 = &spi_0;
-               i2c0 = &i2c_0;
+               spi0 = &blsp1_spi1;
+               spi1 = &blsp1_spi2;
+               i2c0 = &blsp1_i2c3;
+               i2c1 = &blsp1_i2c4;
        };
 
        cpus {
@@ -45,7 +63,7 @@ cpu@0 {
                                48000   1100000
                                200000  1100000
                                500000  1100000
-                               666000  1100000
+                               716000  1100000
                        >;
                        clock-latency = <256000>;
                };
@@ -104,6 +122,12 @@ xo: xo {
                };
        };
 
+       firmware {
+               scm {
+                       compatible = "qcom,scm-ipq4019";
+               };
+       };
+
        timer {
                compatible = "arm,armv7-timer";
                interrupts = <1 2 0xf08>,
@@ -149,13 +173,13 @@ tlmm: pinctrl@1000000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
-                       interrupts = <0 208 0>;
+                       interrupts = <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>;
                };
 
                blsp_dma: dma@7884000 {
                        compatible = "qcom,bam-v1.7.0";
                        reg = <0x07884000 0x23000>;
-                       interrupts = <GIC_SPI 238 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 238 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc GCC_BLSP1_AHB_CLK>;
                        clock-names = "bam_clk";
                        #dma-cells = <1>;
@@ -163,7 +187,7 @@ blsp_dma: dma@7884000 {
                        status = "disabled";
                };
 
-               spi_0: spi@78b5000 {
+               blsp1_spi1: spi@78b5000 { /* BLSP1 QUP1 */
                        compatible = "qcom,spi-qup-v2.2.1";
                        reg = <0x78b5000 0x600>;
                        interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>;
@@ -172,10 +196,26 @@ spi_0: spi@78b5000 {
                        clock-names = "core", "iface";
                        #address-cells = <1>;
                        #size-cells = <0>;
+                       dmas = <&blsp_dma 5>, <&blsp_dma 4>;
+                       dma-names = "rx", "tx";
+                       status = "disabled";
+               };
+
+               blsp1_spi2: spi@78b6000 { /* BLSP1 QUP2 */
+                       compatible = "qcom,spi-qup-v2.2.1";
+                       reg = <0x78b6000 0x600>;
+                       interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&gcc GCC_BLSP1_QUP2_SPI_APPS_CLK>,
+                               <&gcc GCC_BLSP1_AHB_CLK>;
+                       clock-names = "core", "iface";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       dmas = <&blsp_dma 7>, <&blsp_dma 6>;
+                       dma-names = "rx", "tx";
                        status = "disabled";
                };
 
-               i2c_0: i2c@78b7000 {
+               blsp1_i2c3: i2c@78b7000 { /* BLSP1 QUP3 */
                        compatible = "qcom,i2c-qup-v2.2.1";
                        reg = <0x78b7000 0x600>;
                        interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>;
@@ -184,14 +224,29 @@ i2c_0: i2c@78b7000 {
                        clock-names = "iface", "core";
                        #address-cells = <1>;
                        #size-cells = <0>;
+                       dmas = <&blsp_dma 9>, <&blsp_dma 8>;
+                       dma-names = "rx", "tx";
                        status = "disabled";
                };
 
+               blsp1_i2c4: i2c@78b8000 { /* BLSP1 QUP4 */
+                       compatible = "qcom,i2c-qup-v2.2.1";
+                       reg = <0x78b8000 0x600>;
+                       interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&gcc GCC_BLSP1_AHB_CLK>,
+                                <&gcc GCC_BLSP1_QUP2_I2C_APPS_CLK>;
+                       clock-names = "iface", "core";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       dmas = <&blsp_dma 11>, <&blsp_dma 10>;
+                       dma-names = "rx", "tx";
+                       status = "disabled";
+               };
 
                cryptobam: dma@8e04000 {
                        compatible = "qcom,bam-v1.7.0";
                        reg = <0x08e04000 0x20000>;
-                       interrupts = <GIC_SPI 207 0>;
+                       interrupts = <GIC_SPI 207 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc GCC_CRYPTO_AHB_CLK>;
                        clock-names = "bam_clk";
                        #dma-cells = <1>;
@@ -256,10 +311,10 @@ saw3: regulator@b0b9000 {
                         regulator;
                 };
 
-               serial@78af000 {
+               blsp1_uart1: serial@78af000 {
                        compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
                        reg = <0x78af000 0x200>;
-                       interrupts = <0 107 0>;
+                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
                        status = "disabled";
                        clocks = <&gcc GCC_BLSP1_UART1_APPS_CLK>,
                                <&gcc GCC_BLSP1_AHB_CLK>;
@@ -268,10 +323,10 @@ serial@78af000 {
                        dma-names = "rx", "tx";
                };
 
-               serial@78b0000 {
+               blsp1_uart2: serial@78b0000 {
                        compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
                        reg = <0x78b0000 0x200>;
-                       interrupts = <0 108 0>;
+                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
                        status = "disabled";
                        clocks = <&gcc GCC_BLSP1_UART2_APPS_CLK>,
                                <&gcc GCC_BLSP1_AHB_CLK>;
@@ -293,6 +348,101 @@ restart@4ab000 {
                        reg = <0x4ab000 0x4>;
                };
 
+               pcie0: pci@40000000 {
+                       compatible = "qcom,pcie-ipq4019", "snps,dw-pcie";
+                       reg =  <0x40000000 0xf1d
+                               0x40000f20 0xa8
+                               0x80000 0x2000
+                               0x40100000 0x1000>;
+                       reg-names = "dbi", "elbi", "parf", "config";
+                       device_type = "pci";
+                       linux,pci-domain = <0>;
+                       bus-range = <0x00 0xff>;
+                       num-lanes = <1>;
+                       #address-cells = <3>;
+                       #size-cells = <2>;
+
+                       ranges = <0x81000000 0 0x40200000 0x40200000 0 0x00100000
+                                 0x82000000 0 0x48000000 0x48000000 0 0x10000000>;
+
+                       interrupts = <GIC_SPI 141 IRQ_TYPE_EDGE_RISING>;
+                       interrupt-names = "msi";
+                       #interrupt-cells = <1>;
+                       interrupt-map-mask = <0 0 0 0x7>;
+                       interrupt-map = <0 0 0 1 &intc 0 142 IRQ_TYPE_LEVEL_HIGH>, /* int_a */
+                                       <0 0 0 2 &intc 0 143 IRQ_TYPE_LEVEL_HIGH>, /* int_b */
+                                       <0 0 0 3 &intc 0 144 IRQ_TYPE_LEVEL_HIGH>, /* int_c */
+                                       <0 0 0 4 &intc 0 145 IRQ_TYPE_LEVEL_HIGH>; /* int_d */
+                       clocks = <&gcc GCC_PCIE_AHB_CLK>,
+                                <&gcc GCC_PCIE_AXI_M_CLK>,
+                                <&gcc GCC_PCIE_AXI_S_CLK>;
+                       clock-names = "aux",
+                                     "master_bus",
+                                     "slave_bus";
+
+                       resets = <&gcc PCIE_AXI_M_ARES>,
+                                <&gcc PCIE_AXI_S_ARES>,
+                                <&gcc PCIE_PIPE_ARES>,
+                                <&gcc PCIE_AXI_M_VMIDMT_ARES>,
+                                <&gcc PCIE_AXI_S_XPU_ARES>,
+                                <&gcc PCIE_PARF_XPU_ARES>,
+                                <&gcc PCIE_PHY_ARES>,
+                                <&gcc PCIE_AXI_M_STICKY_ARES>,
+                                <&gcc PCIE_PIPE_STICKY_ARES>,
+                                <&gcc PCIE_PWR_ARES>,
+                                <&gcc PCIE_AHB_ARES>,
+                                <&gcc PCIE_PHY_AHB_ARES>;
+                       reset-names = "axi_m",
+                                     "axi_s",
+                                     "pipe",
+                                     "axi_m_vmid",
+                                     "axi_s_xpu",
+                                     "parf",
+                                     "phy",
+                                     "axi_m_sticky",
+                                     "pipe_sticky",
+                                     "pwr",
+                                     "ahb",
+                                     "phy_ahb";
+
+                       status = "disabled";
+               };
+
+               qpic_bam: dma@7984000 {
+                       compatible = "qcom,bam-v1.7.0";
+                       reg = <0x7984000 0x1a000>;
+                       interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&gcc GCC_QPIC_CLK>;
+                       clock-names = "bam_clk";
+                       #dma-cells = <1>;
+                       qcom,ee = <0>;
+                       status = "disabled";
+               };
+
+               nand: qpic-nand@79b0000 {
+                       compatible = "qcom,ipq4019-nand";
+                       reg = <0x79b0000 0x1000>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       clocks = <&gcc GCC_QPIC_CLK>,
+                                <&gcc GCC_QPIC_AHB_CLK>;
+                       clock-names = "core", "aon";
+
+                       dmas = <&qpic_bam 0>,
+                              <&qpic_bam 1>,
+                              <&qpic_bam 2>;
+                       dma-names = "tx", "rx", "cmd";
+                       status = "disabled";
+
+                       nand@0 {
+                               reg = <0>;
+
+                               nand-ecc-strength = <4>;
+                               nand-ecc-step-size = <512>;
+                               nand-bus-width = <8>;
+                       };
+               };
+
                wifi0: wifi@a000000 {
                        compatible = "qcom,ipq4019-wifi";
                        reg = <0xa000000 0x200000>;
@@ -326,7 +476,7 @@ wifi0: wifi@a000000 {
                                     <GIC_SPI 45 IRQ_TYPE_EDGE_RISING>,
                                     <GIC_SPI 46 IRQ_TYPE_EDGE_RISING>,
                                     <GIC_SPI 47 IRQ_TYPE_EDGE_RISING>,
-                                    <GIC_SPI 168 IRQ_TYPE_NONE>;
+                                    <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names =  "msi0",  "msi1",  "msi2",  "msi3",
                                           "msi4",  "msi5",  "msi6",  "msi7",
                                           "msi8",  "msi9", "msi10", "msi11",
@@ -368,7 +518,7 @@ wifi1: wifi@a800000 {
                                     <GIC_SPI 61 IRQ_TYPE_EDGE_RISING>,
                                     <GIC_SPI 62 IRQ_TYPE_EDGE_RISING>,
                                     <GIC_SPI 63 IRQ_TYPE_EDGE_RISING>,
-                                    <GIC_SPI 169 IRQ_TYPE_NONE>;
+                                    <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names =  "msi0",  "msi1",  "msi2",  "msi3",
                                           "msi4",  "msi5",  "msi6",  "msi7",
                                           "msi8",  "msi9", "msi10", "msi11",
index 33030f9419fefdbf267e4e7ce1e0947def1c77e0..70698941f64c09fdd2072cac169de244c0a2db1e 100644 (file)
@@ -452,7 +452,7 @@ rpm: rpm@104000 {
                        clock-names = "ram";
 
                        rpmcc: clock-controller {
-                               compatible      = "qcom,rpmcc-apq8660", "qcom,rpmcc";
+                               compatible      = "qcom,rpmcc-msm8660", "qcom,rpmcc";
                                #clock-cells = <1>;
                        };
 
diff --git a/arch/arm/boot/dts/qcom-msm8974-sony-xperia-amami.dts b/arch/arm/boot/dts/qcom-msm8974-sony-xperia-amami.dts
new file mode 100644 (file)
index 0000000..5669f5f
--- /dev/null
@@ -0,0 +1,436 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "qcom-msm8974.dtsi"
+#include "qcom-pm8841.dtsi"
+#include "qcom-pm8941.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>
+
+/ {
+       model = "Sony Xperia Z1 Compact";
+       compatible = "sony,xperia-amami", "qcom,msm8974";
+
+       aliases {
+               serial0 = &blsp1_uart2;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       gpio-keys {
+               compatible = "gpio-keys";
+               input-name = "gpio-keys";
+
+               pinctrl-names = "default";
+               pinctrl-0 = <&gpio_keys_pin_a>;
+
+               volume-down {
+                       label = "volume_down";
+                       gpios = <&pm8941_gpios 2 GPIO_ACTIVE_LOW>;
+                       linux,input-type = <1>;
+                       linux,code = <KEY_VOLUMEDOWN>;
+               };
+
+               camera-snapshot {
+                       label = "camera_snapshot";
+                       gpios = <&pm8941_gpios 3 GPIO_ACTIVE_LOW>;
+                       linux,input-type = <1>;
+                       linux,code = <KEY_CAMERA>;
+               };
+
+               camera-focus {
+                       label = "camera_focus";
+                       gpios = <&pm8941_gpios 4 GPIO_ACTIVE_LOW>;
+                       linux,input-type = <1>;
+                       linux,code = <KEY_CAMERA_FOCUS>;
+               };
+
+               volume-up {
+                       label = "volume_up";
+                       gpios = <&pm8941_gpios 5 GPIO_ACTIVE_LOW>;
+                       linux,input-type = <1>;
+                       linux,code = <KEY_VOLUMEUP>;
+               };
+       };
+
+       memory@0 {
+               reg = <0 0x40000000>, <0x40000000 0x40000000>;
+               device_type = "memory";
+       };
+
+       smd {
+               rpm {
+                       rpm_requests {
+                               pm8841-regulators {
+                                       s1 {
+                                               regulator-min-microvolt = <675000>;
+                                               regulator-max-microvolt = <1050000>;
+                                       };
+
+                                       s2 {
+                                               regulator-min-microvolt = <500000>;
+                                               regulator-max-microvolt = <1050000>;
+                                       };
+
+                                       s3 {
+                                               regulator-min-microvolt = <500000>;
+                                               regulator-max-microvolt = <1050000>;
+                                       };
+
+                                       s4 {
+                                               regulator-min-microvolt = <500000>;
+                                               regulator-max-microvolt = <1050000>;
+                                       };
+                               };
+
+                               pm8941-regulators {
+                                       vdd_l1_l3-supply = <&pm8941_s1>;
+                                       vdd_l2_lvs1_2_3-supply = <&pm8941_s3>;
+                                       vdd_l4_l11-supply = <&pm8941_s1>;
+                                       vdd_l5_l7-supply = <&pm8941_s2>;
+                                       vdd_l6_l12_l14_l15-supply = <&pm8941_s2>;
+                                       vdd_l9_l10_l17_l22-supply = <&vreg_boost>;
+                                       vdd_l13_l20_l23_l24-supply = <&vreg_boost>;
+                                       vdd_l21-supply = <&vreg_boost>;
+
+                                       s1 {
+                                               regulator-min-microvolt = <1300000>;
+                                               regulator-max-microvolt = <1300000>;
+                                               regulator-always-on;
+                                               regulator-boot-on;
+                                       };
+
+                                       s2 {
+                                               regulator-min-microvolt = <2150000>;
+                                               regulator-max-microvolt = <2150000>;
+                                               regulator-boot-on;
+                                       };
+
+                                       s3 {
+                                               regulator-min-microvolt = <1800000>;
+                                               regulator-max-microvolt = <1800000>;
+                                               regulator-always-on;
+                                               regulator-boot-on;
+                                       };
+
+                                       s4 {
+                                               regulator-min-microvolt = <5000000>;
+                                               regulator-max-microvolt = <5000000>;
+                                       };
+
+                                       l1 {
+                                               regulator-min-microvolt = <1225000>;
+                                               regulator-max-microvolt = <1225000>;
+
+                                               regulator-always-on;
+                                               regulator-boot-on;
+                                       };
+
+                                       l2 {
+                                               regulator-min-microvolt = <1200000>;
+                                               regulator-max-microvolt = <1200000>;
+                                       };
+
+                                       l3 {
+                                               regulator-min-microvolt = <1200000>;
+                                               regulator-max-microvolt = <1200000>;
+                                       };
+
+                                       l4 {
+                                               regulator-min-microvolt = <1225000>;
+                                               regulator-max-microvolt = <1225000>;
+                                       };
+
+                                       l5 {
+                                               regulator-min-microvolt = <1800000>;
+                                               regulator-max-microvolt = <1800000>;
+                                       };
+
+                                       l6 {
+                                               regulator-min-microvolt = <1800000>;
+                                               regulator-max-microvolt = <1800000>;
+
+                                               regulator-boot-on;
+                                       };
+
+                                       l7 {
+                                               regulator-min-microvolt = <1800000>;
+                                               regulator-max-microvolt = <1800000>;
+
+                                               regulator-boot-on;
+                                       };
+
+                                       l8 {
+                                               regulator-min-microvolt = <1800000>;
+                                               regulator-max-microvolt = <1800000>;
+                                       };
+
+                                       l9 {
+                                               regulator-min-microvolt = <1800000>;
+                                               regulator-max-microvolt = <2950000>;
+                                       };
+
+                                       l11 {
+                                               regulator-min-microvolt = <1300000>;
+                                               regulator-max-microvolt = <1350000>;
+                                       };
+
+                                       l12 {
+                                               regulator-min-microvolt = <1800000>;
+                                               regulator-max-microvolt = <1800000>;
+
+                                               regulator-always-on;
+                                               regulator-boot-on;
+                                       };
+
+                                       l13 {
+                                               regulator-min-microvolt = <1800000>;
+                                               regulator-max-microvolt = <2950000>;
+
+                                               regulator-boot-on;
+                                       };
+
+                                       l14 {
+                                               regulator-min-microvolt = <1800000>;
+                                               regulator-max-microvolt = <1800000>;
+                                       };
+
+                                       l15 {
+                                               regulator-min-microvolt = <2050000>;
+                                               regulator-max-microvolt = <2050000>;
+                                       };
+
+                                       l16 {
+                                               regulator-min-microvolt = <2700000>;
+                                               regulator-max-microvolt = <2700000>;
+                                       };
+
+                                       l17 {
+                                               regulator-min-microvolt = <2700000>;
+                                               regulator-max-microvolt = <2700000>;
+                                       };
+
+                                       l18 {
+                                               regulator-min-microvolt = <2850000>;
+                                               regulator-max-microvolt = <2850000>;
+                                       };
+
+                                       l19 {
+                                               regulator-min-microvolt = <3300000>;
+                                               regulator-max-microvolt = <3300000>;
+                                       };
+
+                                       l20 {
+                                               regulator-min-microvolt = <2950000>;
+                                               regulator-max-microvolt = <2950000>;
+
+                                               regulator-allow-set-load;
+                                               regulator-boot-on;
+                                               regulator-system-load = <200000>;
+                                       };
+
+                                       l21 {
+                                               regulator-min-microvolt = <2950000>;
+                                               regulator-max-microvolt = <2950000>;
+
+                                               regulator-boot-on;
+                                       };
+
+                                       l22 {
+                                               regulator-min-microvolt = <3000000>;
+                                               regulator-max-microvolt = <3000000>;
+                                       };
+
+                                       l23 {
+                                               regulator-min-microvolt = <2800000>;
+                                               regulator-max-microvolt = <2800000>;
+                                       };
+
+                                       l24 {
+                                               regulator-min-microvolt = <3075000>;
+                                               regulator-max-microvolt = <3075000>;
+
+                                               regulator-boot-on;
+                                       };
+                               };
+                       };
+               };
+       };
+};
+
+&soc {
+       sdhci@f9824900 {
+               status = "ok";
+
+               vmmc-supply = <&pm8941_l20>;
+               vqmmc-supply = <&pm8941_s3>;
+
+               bus-width = <8>;
+               non-removable;
+
+               pinctrl-names = "default";
+               pinctrl-0 = <&sdhc1_pin_a>;
+       };
+
+       sdhci@f98a4900 {
+               status = "ok";
+
+               bus-width = <4>;
+
+               vmmc-supply = <&pm8941_l21>;
+               vqmmc-supply = <&pm8941_l13>;
+
+               cd-gpios = <&msmgpio 62 GPIO_ACTIVE_LOW>;
+
+               pinctrl-names = "default";
+               pinctrl-0 = <&sdhc2_pin_a>, <&sdhc2_cd_pin_a>;
+       };
+
+       serial@f991e000 {
+               status = "ok";
+
+               pinctrl-names = "default";
+               pinctrl-0 = <&blsp1_uart2_pin_a>;
+       };
+
+
+       pinctrl@fd510000 {
+               blsp1_uart2_pin_a: blsp1-uart2-pin-active {
+                       rx {
+                               pins = "gpio5";
+                               function = "blsp_uart2";
+
+                               drive-strength = <2>;
+                               bias-pull-up;
+                       };
+
+                       tx {
+                               pins = "gpio4";
+                               function = "blsp_uart2";
+
+                               drive-strength = <4>;
+                               bias-disable;
+                       };
+               };
+
+               i2c2_pins: i2c2 {
+                       mux {
+                               pins = "gpio6", "gpio7";
+                               function = "blsp_i2c2";
+
+                               drive-strength = <2>;
+                               bias-disable;
+                       };
+               };
+
+               sdhc1_pin_a: sdhc1-pin-active {
+                       clk {
+                               pins = "sdc1_clk";
+                               drive-strength = <16>;
+                               bias-disable;
+                       };
+
+                       cmd-data {
+                               pins = "sdc1_cmd", "sdc1_data";
+                               drive-strength = <10>;
+                               bias-pull-up;
+                       };
+               };
+
+               sdhc2_cd_pin_a: sdhc2-cd-pin-active {
+                       pins = "gpio62";
+                       function = "gpio";
+
+                       drive-strength = <2>;
+                       bias-disable;
+                };
+
+               sdhc2_pin_a: sdhc2-pin-active {
+                       clk {
+                               pins = "sdc2_clk";
+                               drive-strength = <10>;
+                               bias-disable;
+                       };
+
+                       cmd-data {
+                               pins = "sdc2_cmd", "sdc2_data";
+                               drive-strength = <6>;
+                               bias-pull-up;
+                       };
+               };
+       };
+
+       dma-controller@f9944000 {
+               qcom,controlled-remotely;
+       };
+
+       usb@f9a55000 {
+               status = "ok";
+
+               phys = <&usb_hs1_phy>;
+               phy-select = <&tcsr 0xb000 0>;
+               extcon = <&smbb>, <&usb_id>;
+               vbus-supply = <&chg_otg>;
+
+               hnp-disable;
+               srp-disable;
+               adp-disable;
+
+               ulpi {
+                       phy@a {
+                               status = "ok";
+
+                               v1p8-supply = <&pm8941_l6>;
+                               v3p3-supply = <&pm8941_l24>;
+
+                               extcon = <&smbb>;
+                               qcom,init-seq = /bits/ 8 <0x1 0x64>;
+                       };
+               };
+       };
+};
+
+&spmi_bus {
+       pm8941@0 {
+               charger@1000 {
+                       qcom,fast-charge-safe-current = <1300000>;
+                       qcom,fast-charge-current-limit = <1300000>;
+                       qcom,dc-current-limit = <1300000>;
+                       qcom,fast-charge-safe-voltage = <4400000>;
+                       qcom,fast-charge-high-threshold-voltage = <4350000>;
+                       qcom,fast-charge-low-threshold-voltage = <3400000>;
+                       qcom,auto-recharge-threshold-voltage = <4200000>;
+                       qcom,minimum-input-voltage = <4300000>;
+               };
+
+               gpios@c000 {
+                       gpio_keys_pin_a: gpio-keys-active {
+                               pins = "gpio2", "gpio3", "gpio4", "gpio5";
+                               function = "normal";
+
+                               bias-pull-up;
+                               power-source = <PM8941_GPIO_S3>;
+                       };
+               };
+
+               coincell@2800 {
+                       status = "ok";
+                       qcom,rset-ohms = <2100>;
+                       qcom,vset-millivolts = <3000>;
+               };
+       };
+
+       pm8941@1 {
+               wled@d800 {
+                       status = "ok";
+
+                       qcom,cs-out;
+                       qcom,current-limit = <20>;
+                       qcom,current-boost-limit = <805>;
+                       qcom,switching-freq = <1600>;
+                       qcom,ovp = <29>;
+                       qcom,num-strings = <2>;
+               };
+       };
+};
index 1d5ef55c7ee52ac3b33808033ec48af442e2def5..2515c5c217ac1ff8776863862aed73d2bcf4d65b 100644 (file)
@@ -139,6 +139,9 @@ pm8941_vadc: vadc@3100 {
                        #size-cells = <0>;
                        #io-channel-cells = <1>;
 
+                       bat_temp {
+                               reg = <VADC_LR_MUX1_BAT_THERM>;
+                       };
                        die_temp {
                                reg = <VADC_DIE_TEMP>;
                        };
@@ -154,6 +157,9 @@ ref_gnd {
                        ref_vdd {
                                reg = <VADC_VDD_VADC>;
                        };
+                       vbat_sns {
+                               reg = <VADC_VBAT_SNS>;
+                       };
                };
 
                pm8941_iadc: iadc@3600 {
index ab9645a42eca3811084c7b09cfddfdeebd497f81..a54822e97bac42ed017203469a9f5f983bccf1bd 100644 (file)
@@ -15,7 +15,6 @@
 
 / {
        compatible = "renesas,r7s72100";
-       interrupt-parent = <&gic>;
        #address-cells = <1>;
        #size-cells = <1>;
 
@@ -31,61 +30,370 @@ aliases {
                spi4 = &spi4;
        };
 
-       clocks {
-               ranges;
+       /* Fixed factor clocks */
+       b_clk: b {
+               #clock-cells = <0>;
+               compatible = "fixed-factor-clock";
+               clocks = <&cpg_clocks R7S72100_CLK_PLL>;
+               clock-mult = <1>;
+               clock-div = <3>;
+       };
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu@0 {
+                       device_type = "cpu";
+                       compatible = "arm,cortex-a9";
+                       reg = <0>;
+                       clock-frequency = <400000000>;
+                       clocks = <&cpg_clocks R7S72100_CLK_I>;
+                       next-level-cache = <&L2>;
+               };
+       };
+
+       /* External clocks */
+       extal_clk: extal {
+               #clock-cells = <0>;
+               compatible = "fixed-clock";
+               /* If clk present, value must be set by board */
+               clock-frequency = <0>;
+       };
+
+       p0_clk: p0 {
+               #clock-cells = <0>;
+               compatible = "fixed-factor-clock";
+               clocks = <&cpg_clocks R7S72100_CLK_PLL>;
+               clock-mult = <1>;
+               clock-div = <12>;
+       };
+
+       p1_clk: p1 {
+               #clock-cells = <0>;
+               compatible = "fixed-factor-clock";
+               clocks = <&cpg_clocks R7S72100_CLK_PLL>;
+               clock-mult = <1>;
+               clock-div = <6>;
+       };
+
+       pmu {
+               compatible = "arm,cortex-a9-pmu";
+               interrupts-extended = <&gic GIC_PPI 0 IRQ_TYPE_LEVEL_HIGH>;
+       };
+
+       rtc_x1_clk: rtc_x1 {
+               #clock-cells = <0>;
+               compatible = "fixed-clock";
+               /* If clk present, value must be set by board to 32678 */
+               clock-frequency = <0>;
+       };
+
+       rtc_x3_clk: rtc_x3 {
+               #clock-cells = <0>;
+               compatible = "fixed-clock";
+               /* If clk present, value must be set by board to 4000000 */
+               clock-frequency = <0>;
+       };
+
+       soc {
+               compatible = "simple-bus";
+               interrupt-parent = <&gic>;
+
                #address-cells = <1>;
                #size-cells = <1>;
+               ranges;
+
+               L2: cache-controller@3ffff000 {
+                       compatible = "arm,pl310-cache";
+                       reg = <0x3ffff000 0x1000>;
+                       interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
+                       arm,early-bresp-disable;
+                       arm,full-line-zero-disable;
+                       cache-unified;
+                       cache-level = <2>;
+               };
+
+               scif0: serial@e8007000 {
+                       compatible = "renesas,scif-r7s72100", "renesas,scif";
+                       reg = <0xe8007000 64>;
+                       interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp4_clks R7S72100_CLK_SCIF0>;
+                       clock-names = "fck";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
+               };
+
+               scif1: serial@e8007800 {
+                       compatible = "renesas,scif-r7s72100", "renesas,scif";
+                       reg = <0xe8007800 64>;
+                       interrupts = <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp4_clks R7S72100_CLK_SCIF1>;
+                       clock-names = "fck";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
+               };
+
+               scif2: serial@e8008000 {
+                       compatible = "renesas,scif-r7s72100", "renesas,scif";
+                       reg = <0xe8008000 64>;
+                       interrupts = <GIC_SPI 198 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 199 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 200 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp4_clks R7S72100_CLK_SCIF2>;
+                       clock-names = "fck";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
+               };
+
+               scif3: serial@e8008800 {
+                       compatible = "renesas,scif-r7s72100", "renesas,scif";
+                       reg = <0xe8008800 64>;
+                       interrupts = <GIC_SPI 202 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 203 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 204 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 201 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp4_clks R7S72100_CLK_SCIF3>;
+                       clock-names = "fck";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
+               };
 
-               /* External clocks */
-               extal_clk: extal {
-                       #clock-cells = <0>;
-                       compatible = "fixed-clock";
-                       /* If clk present, value must be set by board */
-                       clock-frequency = <0>;
+               scif4: serial@e8009000 {
+                       compatible = "renesas,scif-r7s72100", "renesas,scif";
+                       reg = <0xe8009000 64>;
+                       interrupts = <GIC_SPI 206 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 207 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp4_clks R7S72100_CLK_SCIF4>;
+                       clock-names = "fck";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               usb_x1_clk: usb_x1 {
-                       #clock-cells = <0>;
-                       compatible = "fixed-clock";
-                       /* If clk present, value must be set by board */
-                       clock-frequency = <0>;
+               scif5: serial@e8009800 {
+                       compatible = "renesas,scif-r7s72100", "renesas,scif";
+                       reg = <0xe8009800 64>;
+                       interrupts = <GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 211 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp4_clks R7S72100_CLK_SCIF5>;
+                       clock-names = "fck";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               rtc_x1_clk: rtc_x1 {
-                       #clock-cells = <0>;
-                       compatible = "fixed-clock";
-                       /* If clk present, value must be set by board to 32678 */
-                       clock-frequency = <0>;
+               scif6: serial@e800a000 {
+                       compatible = "renesas,scif-r7s72100", "renesas,scif";
+                       reg = <0xe800a000 64>;
+                       interrupts = <GIC_SPI 214 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 216 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 213 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp4_clks R7S72100_CLK_SCIF6>;
+                       clock-names = "fck";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               rtc_x3_clk: rtc_x3 {
-                       #clock-cells = <0>;
-                       compatible = "fixed-clock";
-                       /* If clk present, value must be set by board to 4000000 */
-                       clock-frequency = <0>;
+               scif7: serial@e800a800 {
+                       compatible = "renesas,scif-r7s72100", "renesas,scif";
+                       reg = <0xe800a800 64>;
+                       interrupts = <GIC_SPI 218 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp4_clks R7S72100_CLK_SCIF7>;
+                       clock-names = "fck";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               /* Fixed factor clocks */
-               b_clk: b {
-                       #clock-cells = <0>;
-                       compatible = "fixed-factor-clock";
-                       clocks = <&cpg_clocks R7S72100_CLK_PLL>;
-                       clock-mult = <1>;
-                       clock-div = <3>;
+               spi0: spi@e800c800 {
+                       compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+                       reg = <0xe800c800 0x24>;
+                       interrupts = <GIC_SPI 238 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 239 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 240 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error", "rx", "tx";
+                       clocks = <&mstp10_clks R7S72100_CLK_SPI0>;
+                       power-domains = <&cpg_clocks>;
+                       num-cs = <1>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
                };
-               p1_clk: p1 {
-                       #clock-cells = <0>;
-                       compatible = "fixed-factor-clock";
-                       clocks = <&cpg_clocks R7S72100_CLK_PLL>;
-                       clock-mult = <1>;
-                       clock-div = <6>;
+
+               spi1: spi@e800d000 {
+                       compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+                       reg = <0xe800d000 0x24>;
+                       interrupts = <GIC_SPI 241 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error", "rx", "tx";
+                       clocks = <&mstp10_clks R7S72100_CLK_SPI1>;
+                       power-domains = <&cpg_clocks>;
+                       num-cs = <1>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               spi2: spi@e800d800 {
+                       compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+                       reg = <0xe800d800 0x24>;
+                       interrupts = <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error", "rx", "tx";
+                       clocks = <&mstp10_clks R7S72100_CLK_SPI2>;
+                       power-domains = <&cpg_clocks>;
+                       num-cs = <1>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
                };
-               p0_clk: p0 {
-                       #clock-cells = <0>;
-                       compatible = "fixed-factor-clock";
-                       clocks = <&cpg_clocks R7S72100_CLK_PLL>;
-                       clock-mult = <1>;
-                       clock-div = <12>;
+
+               spi3: spi@e800e000 {
+                       compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+                       reg = <0xe800e000 0x24>;
+                       interrupts = <GIC_SPI 247 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 248 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 249 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error", "rx", "tx";
+                       clocks = <&mstp10_clks R7S72100_CLK_SPI3>;
+                       power-domains = <&cpg_clocks>;
+                       num-cs = <1>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               spi4: spi@e800e800 {
+                       compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
+                       reg = <0xe800e800 0x24>;
+                       interrupts = <GIC_SPI 250 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 251 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 252 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error", "rx", "tx";
+                       clocks = <&mstp10_clks R7S72100_CLK_SPI4>;
+                       power-domains = <&cpg_clocks>;
+                       num-cs = <1>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               usbhs0: usb@e8010000 {
+                       compatible = "renesas,usbhs-r7s72100", "renesas,rza1-usbhs";
+                       reg = <0xe8010000 0x1a0>;
+                       interrupts = <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp7_clks R7S72100_CLK_USB0>;
+                       renesas,buswait = <4>;
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
+               };
+
+               usbhs1: usb@e8207000 {
+                       compatible = "renesas,usbhs-r7s72100", "renesas,rza1-usbhs";
+                       reg = <0xe8207000 0x1a0>;
+                       interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp7_clks R7S72100_CLK_USB1>;
+                       renesas,buswait = <4>;
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
+               };
+
+               mmcif: mmc@e804c800 {
+                       compatible = "renesas,mmcif-r7s72100", "renesas,sh-mmcif";
+                       reg = <0xe804c800 0x80>;
+                       interrupts = <GIC_SPI 268 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 269 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 267 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp8_clks R7S72100_CLK_MMCIF>;
+                       power-domains = <&cpg_clocks>;
+                       reg-io-width = <4>;
+                       bus-width = <8>;
+                       status = "disabled";
+               };
+
+               sdhi0: sd@e804e000 {
+                       compatible = "renesas,sdhi-r7s72100";
+                       reg = <0xe804e000 0x100>;
+                       interrupts = <GIC_SPI 270 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 271 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 272 IRQ_TYPE_LEVEL_HIGH>;
+
+                       clocks = <&mstp12_clks R7S72100_CLK_SDHI00>,
+                                <&mstp12_clks R7S72100_CLK_SDHI01>;
+                       clock-names = "core", "cd";
+                       power-domains = <&cpg_clocks>;
+                       cap-sd-highspeed;
+                       cap-sdio-irq;
+                       status = "disabled";
+               };
+
+               sdhi1: sd@e804e800 {
+                       compatible = "renesas,sdhi-r7s72100";
+                       reg = <0xe804e800 0x100>;
+                       interrupts = <GIC_SPI 273 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 274 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 275 IRQ_TYPE_LEVEL_HIGH>;
+
+                       clocks = <&mstp12_clks R7S72100_CLK_SDHI10>,
+                                <&mstp12_clks R7S72100_CLK_SDHI11>;
+                       clock-names = "core", "cd";
+                       power-domains = <&cpg_clocks>;
+                       cap-sd-highspeed;
+                       cap-sdio-irq;
+                       status = "disabled";
+               };
+
+               gic: interrupt-controller@e8201000 {
+                       compatible = "arm,pl390";
+                       #interrupt-cells = <3>;
+                       #address-cells = <0>;
+                       interrupt-controller;
+                       reg = <0xe8201000 0x1000>,
+                               <0xe8202000 0x1000>;
+               };
+
+               ether: ethernet@e8203000 {
+                       compatible = "renesas,ether-r7s72100";
+                       reg = <0xe8203000 0x800>,
+                             <0xe8204800 0x200>;
+                       interrupts = <GIC_SPI 327 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp7_clks R7S72100_CLK_ETHER>;
+                       power-domains = <&cpg_clocks>;
+                       phy-mode = "mii";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               ceu: camera@e8210000 {
+                       reg = <0xe8210000 0x3000>;
+                       compatible = "renesas,r7s72100-ceu";
+                       interrupts = <GIC_SPI 332 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp6_clks R7S72100_CLK_CEU>;
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
+               };
+
+               wdt: watchdog@fcfe0000 {
+                       compatible = "renesas,r7s72100-wdt", "renesas,rza-wdt";
+                       reg = <0xfcfe0000 0x6>;
+                       interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&p0_clk>;
                };
 
                /* Special CPG clocks */
@@ -135,9 +443,9 @@ mstp6_clks: mstp6_clks@fcfe042c {
                        #clock-cells = <1>;
                        compatible = "renesas,r7s72100-mstp-clocks", "renesas,cpg-mstp-clocks";
                        reg = <0xfcfe042c 4>;
-                       clocks = <&p0_clk>;
-                       clock-indices = <R7S72100_CLK_RTC>;
-                       clock-output-names = "rtc";
+                       clocks = <&b_clk>, <&p0_clk>;
+                       clock-indices = <R7S72100_CLK_CEU R7S72100_CLK_RTC>;
+                       clock-output-names = "ceu", "rtc";
                };
 
                mstp7_clks: mstp7_clks@fcfe0430 {
@@ -192,479 +500,209 @@ R7S72100_CLK_SDHI10 R7S72100_CLK_SDHI11
                        >;
                        clock-output-names = "sdhi00", "sdhi01", "sdhi10", "sdhi11";
                };
-       };
-
-       cpus {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
-               cpu@0 {
-                       device_type = "cpu";
-                       compatible = "arm,cortex-a9";
-                       reg = <0>;
-                       clock-frequency = <400000000>;
-                       clocks = <&cpg_clocks R7S72100_CLK_I>;
-                       next-level-cache = <&L2>;
-               };
-       };
-
-       pinctrl: pin-controller@fcfe3000 {
-               compatible = "renesas,r7s72100-ports";
-
-               reg = <0xfcfe3000 0x4230>;
-
-               port0: gpio-0 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 0 6>;
-               };
-
-               port1: gpio-1 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 16 16>;
-               };
 
-               port2: gpio-2 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 32 16>;
+               pinctrl: pin-controller@fcfe3000 {
+                       compatible = "renesas,r7s72100-ports";
+
+                       reg = <0xfcfe3000 0x4230>;
+
+                       port0: gpio-0 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 0 6>;
+                       };
+
+                       port1: gpio-1 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 16 16>;
+                       };
+
+                       port2: gpio-2 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 32 16>;
+                       };
+
+                       port3: gpio-3 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 48 16>;
+                       };
+
+                       port4: gpio-4 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 64 16>;
+                       };
+
+                       port5: gpio-5 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 80 11>;
+                       };
+
+                       port6: gpio-6 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 96 16>;
+                       };
+
+                       port7: gpio-7 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 112 16>;
+                       };
+
+                       port8: gpio-8 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 128 16>;
+                       };
+
+                       port9: gpio-9 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 144 8>;
+                       };
+
+                       port10: gpio-10 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 160 16>;
+                       };
+
+                       port11: gpio-11 {
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               gpio-ranges = <&pinctrl 0 176 16>;
+                       };
                };
 
-               port3: gpio-3 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 48 16>;
+               ostm0: timer@fcfec000 {
+                       compatible = "renesas,r7s72100-ostm", "renesas,ostm";
+                       reg = <0xfcfec000 0x30>;
+                       interrupts = <GIC_SPI 102 IRQ_TYPE_EDGE_RISING>;
+                       clocks = <&mstp5_clks R7S72100_CLK_OSTM0>;
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               port4: gpio-4 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 64 16>;
+               ostm1: timer@fcfec400 {
+                       compatible = "renesas,r7s72100-ostm", "renesas,ostm";
+                       reg = <0xfcfec400 0x30>;
+                       interrupts = <GIC_SPI 103 IRQ_TYPE_EDGE_RISING>;
+                       clocks = <&mstp5_clks R7S72100_CLK_OSTM1>;
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               port5: gpio-5 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 80 11>;
+               i2c0: i2c@fcfee000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
+                       reg = <0xfcfee000 0x44>;
+                       interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 158 IRQ_TYPE_EDGE_RISING>,
+                                    <GIC_SPI 159 IRQ_TYPE_EDGE_RISING>,
+                                    <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 162 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp9_clks R7S72100_CLK_I2C0>;
+                       clock-frequency = <100000>;
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               port6: gpio-6 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 96 16>;
+               i2c1: i2c@fcfee400 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
+                       reg = <0xfcfee400 0x44>;
+                       interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 166 IRQ_TYPE_EDGE_RISING>,
+                                    <GIC_SPI 167 IRQ_TYPE_EDGE_RISING>,
+                                    <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 172 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp9_clks R7S72100_CLK_I2C1>;
+                       clock-frequency = <100000>;
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               port7: gpio-7 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 112 16>;
+               i2c2: i2c@fcfee800 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
+                       reg = <0xfcfee800 0x44>;
+                       interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 174 IRQ_TYPE_EDGE_RISING>,
+                                    <GIC_SPI 175 IRQ_TYPE_EDGE_RISING>,
+                                    <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 179 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 180 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp9_clks R7S72100_CLK_I2C2>;
+                       clock-frequency = <100000>;
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               port8: gpio-8 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 128 16>;
+               i2c3: i2c@fcfeec00 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
+                       reg = <0xfcfeec00 0x44>;
+                       interrupts = <GIC_SPI 181 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 182 IRQ_TYPE_EDGE_RISING>,
+                                    <GIC_SPI 183 IRQ_TYPE_EDGE_RISING>,
+                                    <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 185 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&mstp9_clks R7S72100_CLK_I2C3>;
+                       clock-frequency = <100000>;
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               port9: gpio-9 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 144 8>;
+               mtu2: timer@fcff0000 {
+                       compatible = "renesas,mtu2-r7s72100", "renesas,mtu2";
+                       reg = <0xfcff0000 0x400>;
+                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "tgi0a";
+                       clocks = <&mstp3_clks R7S72100_CLK_MTU2>;
+                       clock-names = "fck";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
 
-               port10: gpio-10 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 160 16>;
+               rtc: rtc@fcff1000 {
+                       compatible = "renesas,r7s72100-rtc", "renesas,sh-rtc";
+                       reg = <0xfcff1000 0x2e>;
+                       interrupts = <GIC_SPI 276 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 277 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 278 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "alarm", "period", "carry";
+                       clocks = <&mstp6_clks R7S72100_CLK_RTC>, <&rtc_x1_clk>,
+                                <&rtc_x3_clk>, <&extal_clk>;
+                       clock-names = "fck", "rtc_x1", "rtc_x3", "extal";
+                       power-domains = <&cpg_clocks>;
+                       status = "disabled";
                };
-
-               port11: gpio-11 {
-                       gpio-controller;
-                       #gpio-cells = <2>;
-                       gpio-ranges = <&pinctrl 0 176 16>;
-               };
-       };
-
-       scif0: serial@e8007000 {
-               compatible = "renesas,scif-r7s72100", "renesas,scif";
-               reg = <0xe8007000 64>;
-               interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp4_clks R7S72100_CLK_SCIF0>;
-               clock-names = "fck";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       scif1: serial@e8007800 {
-               compatible = "renesas,scif-r7s72100", "renesas,scif";
-               reg = <0xe8007800 64>;
-               interrupts = <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp4_clks R7S72100_CLK_SCIF1>;
-               clock-names = "fck";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       scif2: serial@e8008000 {
-               compatible = "renesas,scif-r7s72100", "renesas,scif";
-               reg = <0xe8008000 64>;
-               interrupts = <GIC_SPI 198 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 199 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 200 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp4_clks R7S72100_CLK_SCIF2>;
-               clock-names = "fck";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       scif3: serial@e8008800 {
-               compatible = "renesas,scif-r7s72100", "renesas,scif";
-               reg = <0xe8008800 64>;
-               interrupts = <GIC_SPI 202 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 203 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 204 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 201 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp4_clks R7S72100_CLK_SCIF3>;
-               clock-names = "fck";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       scif4: serial@e8009000 {
-               compatible = "renesas,scif-r7s72100", "renesas,scif";
-               reg = <0xe8009000 64>;
-               interrupts = <GIC_SPI 206 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 207 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp4_clks R7S72100_CLK_SCIF4>;
-               clock-names = "fck";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       scif5: serial@e8009800 {
-               compatible = "renesas,scif-r7s72100", "renesas,scif";
-               reg = <0xe8009800 64>;
-               interrupts = <GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 211 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp4_clks R7S72100_CLK_SCIF5>;
-               clock-names = "fck";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       scif6: serial@e800a000 {
-               compatible = "renesas,scif-r7s72100", "renesas,scif";
-               reg = <0xe800a000 64>;
-               interrupts = <GIC_SPI 214 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 216 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 213 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp4_clks R7S72100_CLK_SCIF6>;
-               clock-names = "fck";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       scif7: serial@e800a800 {
-               compatible = "renesas,scif-r7s72100", "renesas,scif";
-               reg = <0xe800a800 64>;
-               interrupts = <GIC_SPI 218 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp4_clks R7S72100_CLK_SCIF7>;
-               clock-names = "fck";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       spi0: spi@e800c800 {
-               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
-               reg = <0xe800c800 0x24>;
-               interrupts = <GIC_SPI 238 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 239 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 240 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-names = "error", "rx", "tx";
-               clocks = <&mstp10_clks R7S72100_CLK_SPI0>;
-               power-domains = <&cpg_clocks>;
-               num-cs = <1>;
-               #address-cells = <1>;
-               #size-cells = <0>;
-               status = "disabled";
-       };
-
-       spi1: spi@e800d000 {
-               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
-               reg = <0xe800d000 0x24>;
-               interrupts = <GIC_SPI 241 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 243 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-names = "error", "rx", "tx";
-               clocks = <&mstp10_clks R7S72100_CLK_SPI1>;
-               power-domains = <&cpg_clocks>;
-               num-cs = <1>;
-               #address-cells = <1>;
-               #size-cells = <0>;
-               status = "disabled";
-       };
-
-       spi2: spi@e800d800 {
-               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
-               reg = <0xe800d800 0x24>;
-               interrupts = <GIC_SPI 244 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 245 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-names = "error", "rx", "tx";
-               clocks = <&mstp10_clks R7S72100_CLK_SPI2>;
-               power-domains = <&cpg_clocks>;
-               num-cs = <1>;
-               #address-cells = <1>;
-               #size-cells = <0>;
-               status = "disabled";
-       };
-
-       spi3: spi@e800e000 {
-               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
-               reg = <0xe800e000 0x24>;
-               interrupts = <GIC_SPI 247 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 248 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 249 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-names = "error", "rx", "tx";
-               clocks = <&mstp10_clks R7S72100_CLK_SPI3>;
-               power-domains = <&cpg_clocks>;
-               num-cs = <1>;
-               #address-cells = <1>;
-               #size-cells = <0>;
-               status = "disabled";
-       };
-
-       spi4: spi@e800e800 {
-               compatible = "renesas,rspi-r7s72100", "renesas,rspi-rz";
-               reg = <0xe800e800 0x24>;
-               interrupts = <GIC_SPI 250 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 251 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 252 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-names = "error", "rx", "tx";
-               clocks = <&mstp10_clks R7S72100_CLK_SPI4>;
-               power-domains = <&cpg_clocks>;
-               num-cs = <1>;
-               #address-cells = <1>;
-               #size-cells = <0>;
-               status = "disabled";
-       };
-
-       gic: interrupt-controller@e8201000 {
-               compatible = "arm,pl390";
-               #interrupt-cells = <3>;
-               #address-cells = <0>;
-               interrupt-controller;
-               reg = <0xe8201000 0x1000>,
-                       <0xe8202000 0x1000>;
-       };
-
-       L2: cache-controller@3ffff000 {
-               compatible = "arm,pl310-cache";
-               reg = <0x3ffff000 0x1000>;
-               interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
-               arm,early-bresp-disable;
-               arm,full-line-zero-disable;
-               cache-unified;
-               cache-level = <2>;
-       };
-
-       wdt: watchdog@fcfe0000 {
-               compatible = "renesas,r7s72100-wdt", "renesas,rza-wdt";
-               reg = <0xfcfe0000 0x6>;
-               interrupts = <GIC_SPI 106 IRQ_TYPE_EDGE_RISING>;
-               clocks = <&p0_clk>;
-       };
-
-       i2c0: i2c@fcfee000 {
-               #address-cells = <1>;
-               #size-cells = <0>;
-               compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
-               reg = <0xfcfee000 0x44>;
-               interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 158 IRQ_TYPE_EDGE_RISING>,
-                            <GIC_SPI 159 IRQ_TYPE_EDGE_RISING>,
-                            <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 162 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp9_clks R7S72100_CLK_I2C0>;
-               clock-frequency = <100000>;
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       i2c1: i2c@fcfee400 {
-               #address-cells = <1>;
-               #size-cells = <0>;
-               compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
-               reg = <0xfcfee400 0x44>;
-               interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 166 IRQ_TYPE_EDGE_RISING>,
-                            <GIC_SPI 167 IRQ_TYPE_EDGE_RISING>,
-                            <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 172 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp9_clks R7S72100_CLK_I2C1>;
-               clock-frequency = <100000>;
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       i2c2: i2c@fcfee800 {
-               #address-cells = <1>;
-               #size-cells = <0>;
-               compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
-               reg = <0xfcfee800 0x44>;
-               interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 174 IRQ_TYPE_EDGE_RISING>,
-                            <GIC_SPI 175 IRQ_TYPE_EDGE_RISING>,
-                            <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 177 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 178 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 179 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 180 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp9_clks R7S72100_CLK_I2C2>;
-               clock-frequency = <100000>;
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       i2c3: i2c@fcfeec00 {
-               #address-cells = <1>;
-               #size-cells = <0>;
-               compatible = "renesas,riic-r7s72100", "renesas,riic-rz";
-               reg = <0xfcfeec00 0x44>;
-               interrupts = <GIC_SPI 181 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 182 IRQ_TYPE_EDGE_RISING>,
-                            <GIC_SPI 183 IRQ_TYPE_EDGE_RISING>,
-                            <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 185 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>,
-                            <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp9_clks R7S72100_CLK_I2C3>;
-               clock-frequency = <100000>;
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       mtu2: timer@fcff0000 {
-               compatible = "renesas,mtu2-r7s72100", "renesas,mtu2";
-               reg = <0xfcff0000 0x400>;
-               interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-names = "tgi0a";
-               clocks = <&mstp3_clks R7S72100_CLK_MTU2>;
-               clock-names = "fck";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       ether: ethernet@e8203000 {
-               compatible = "renesas,ether-r7s72100";
-               reg = <0xe8203000 0x800>,
-                     <0xe8204800 0x200>;
-               interrupts = <GIC_SPI 327 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp7_clks R7S72100_CLK_ETHER>;
-               power-domains = <&cpg_clocks>;
-               phy-mode = "mii";
-               #address-cells = <1>;
-               #size-cells = <0>;
-               status = "disabled";
-       };
-
-       mmcif: mmc@e804c800 {
-               compatible = "renesas,mmcif-r7s72100", "renesas,sh-mmcif";
-               reg = <0xe804c800 0x80>;
-               interrupts = <GIC_SPI 268 IRQ_TYPE_LEVEL_HIGH
-                             GIC_SPI 269 IRQ_TYPE_LEVEL_HIGH
-                             GIC_SPI 267 IRQ_TYPE_LEVEL_HIGH>;
-               clocks = <&mstp8_clks R7S72100_CLK_MMCIF>;
-               power-domains = <&cpg_clocks>;
-               reg-io-width = <4>;
-               bus-width = <8>;
-               status = "disabled";
-       };
-
-       sdhi0: sd@e804e000 {
-               compatible = "renesas,sdhi-r7s72100";
-               reg = <0xe804e000 0x100>;
-               interrupts = <GIC_SPI 270 IRQ_TYPE_LEVEL_HIGH
-                             GIC_SPI 271 IRQ_TYPE_LEVEL_HIGH
-                             GIC_SPI 272 IRQ_TYPE_LEVEL_HIGH>;
-
-               clocks = <&mstp12_clks R7S72100_CLK_SDHI00>,
-                        <&mstp12_clks R7S72100_CLK_SDHI01>;
-               clock-names = "core", "cd";
-               power-domains = <&cpg_clocks>;
-               cap-sd-highspeed;
-               cap-sdio-irq;
-               status = "disabled";
-       };
-
-       sdhi1: sd@e804e800 {
-               compatible = "renesas,sdhi-r7s72100";
-               reg = <0xe804e800 0x100>;
-               interrupts = <GIC_SPI 273 IRQ_TYPE_LEVEL_HIGH
-                             GIC_SPI 274 IRQ_TYPE_LEVEL_HIGH
-                             GIC_SPI 275 IRQ_TYPE_LEVEL_HIGH>;
-
-               clocks = <&mstp12_clks R7S72100_CLK_SDHI10>,
-                        <&mstp12_clks R7S72100_CLK_SDHI11>;
-               clock-names = "core", "cd";
-               power-domains = <&cpg_clocks>;
-               cap-sd-highspeed;
-               cap-sdio-irq;
-               status = "disabled";
-       };
-
-       ostm0: timer@fcfec000 {
-               compatible = "renesas,r7s72100-ostm", "renesas,ostm";
-               reg = <0xfcfec000 0x30>;
-               interrupts = <GIC_SPI 102 IRQ_TYPE_EDGE_RISING>;
-               clocks = <&mstp5_clks R7S72100_CLK_OSTM0>;
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
-       };
-
-       ostm1: timer@fcfec400 {
-               compatible = "renesas,r7s72100-ostm", "renesas,ostm";
-               reg = <0xfcfec400 0x30>;
-               interrupts = <GIC_SPI 103 IRQ_TYPE_EDGE_RISING>;
-               clocks = <&mstp5_clks R7S72100_CLK_OSTM1>;
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
        };
 
-       rtc: rtc@fcff1000 {
-               compatible = "renesas,r7s72100-rtc", "renesas,sh-rtc";
-               reg = <0xfcff1000 0x2e>;
-               interrupts = <GIC_SPI 276 IRQ_TYPE_EDGE_RISING
-                             GIC_SPI 277 IRQ_TYPE_EDGE_RISING
-                             GIC_SPI 278 IRQ_TYPE_EDGE_RISING>;
-               interrupt-names = "alarm", "period", "carry";
-               clocks = <&mstp6_clks R7S72100_CLK_RTC>, <&rtc_x1_clk>,
-                        <&rtc_x3_clk>, <&extal_clk>;
-               clock-names = "fck", "rtc_x1", "rtc_x3", "extal";
-               power-domains = <&cpg_clocks>;
-               status = "disabled";
+       usb_x1_clk: usb_x1 {
+               #clock-cells = <0>;
+               compatible = "fixed-clock";
+               /* If clk present, value must be set by board */
+               clock-frequency = <0>;
        };
 };
index ec7c86e06538677a193a0c05b3fb8f4a34701300..125c39c0222fb0cb67c1d8e3f217c765d08a53a2 100644 (file)
@@ -234,7 +234,7 @@ &scifa0 {
 &sdhi0 {
        vmmc-supply = <&vcc_sdhi0>;
        bus-width = <4>;
-       toshiba,mmc-wrprotect-disable;
+       disable-wp;
        pinctrl-names = "default";
        pinctrl-0 = <&sdhi0_pins>;
        status = "okay";
@@ -244,7 +244,7 @@ &sdhi1 {
        vmmc-supply = <&ape6evm_fixed_3v3>;
        bus-width = <4>;
        broken-cd;
-       toshiba,mmc-wrprotect-disable;
+       disable-wp;
        pinctrl-names = "default";
        pinctrl-0 = <&sdhi1_pins>;
        status = "okay";
index 8e48090e4fdc14125225d906163a2a35d18c1660..080d037f5733a8c3352db4d1e65f84fbd2506a8b 100644 (file)
@@ -57,10 +57,10 @@ ptm {
 
        timer {
                compatible = "arm,armv7-timer";
-               interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                            <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                            <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                            <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
+               interrupts = <GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
+                            <GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
+                            <GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
+                            <GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>;
        };
 
        dbsc1: memory-controller@e6790000 {
@@ -464,7 +464,7 @@ gic: interrupt-controller@f1001000 {
                        <0 0xf1002000 0 0x2000>,
                        <0 0xf1004000 0 0x2000>,
                        <0 0xf1006000 0 0x2000>;
-               interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
+               interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>;
                clocks = <&mstp4_clks R8A73A4_CLK_INTC_SYS>;
                clock-names = "clk";
                power-domains = <&pd_c4>;
index afd3bc5e6cf2e23f29e43c284be581ff603e33df..eb9a911deefb0592d58748cb8ada3ee5734dd21f 100644 (file)
@@ -67,6 +67,24 @@ ptm {
                power-domains = <&pd_d4>;
        };
 
+       ceu0: ceu@fe910000 {
+               reg = <0xfe910000 0x3000>;
+               compatible = "renesas,r8a7740-ceu";
+               interrupts = <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp1_clks R8A7740_CLK_CEU20>;
+               power-domains = <&pd_a4r>;
+               status = "disabled";
+       };
+
+       ceu1: ceu@fe914000 {
+               reg = <0xfe914000 0x3000>;
+               compatible = "renesas,r8a7740-ceu";
+               interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&mstp1_clks R8A7740_CLK_CEU21>;
+               power-domains = <&pd_a4r>;
+               status = "disabled";
+       };
+
        cmt1: timer@e6138000 {
                compatible = "renesas,cmt-48-r8a7740", "renesas,cmt-48";
                reg = <0xe6138000 0x170>;
index 1d3e9503c5bdb19bc7be71be5baccfc1aec4d612..d364685d91840efe8b684ab228fb1d20af331291 100644 (file)
@@ -91,6 +91,11 @@ flash: flash@0 {
        };
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &sdhi0 {
        pinctrl-0 = <&sdhi0_pins>;
        pinctrl-names = "default";
index 1d9073ba0ce0458fd56d5bcbff4aa2ad58996d42..142949d7066f3a65cafe3fd065d3043f0841e5d8 100644 (file)
@@ -125,6 +125,13 @@ pcie_bus_clk: pcie_bus {
                clock-frequency = <0>;
        };
 
+       pmu {
+               compatible = "arm,cortex-a15-pmu";
+               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>;
+       };
+
        /* External SCIF clock */
        scif_clk: scif {
                compatible = "fixed-clock";
@@ -297,6 +304,16 @@ rst: reset-controller@e6160000 {
                        reg = <0 0xe6160000 0 0x100>;
                };
 
+               rwdt: watchdog@e6020000 {
+                       compatible = "renesas,r8a7743-wdt",
+                                    "renesas,rcar-gen2-wdt";
+                       reg = <0 0xe6020000 0 0x0c>;
+                       clocks = <&cpg CPG_MOD 402>;
+                       power-domains = <&sysc R8A7743_PD_ALWAYS_ON>;
+                       resets = <&cpg 402>;
+                       status = "disabled";
+               };
+
                sysc: system-controller@e6180000 {
                        compatible = "renesas,r8a7743-sysc";
                        reg = <0 0xe6180000 0 0x200>;
@@ -407,7 +424,7 @@ icram1:     sram@e63c0000 {
 
                        smp-sram@0 {
                                compatible = "renesas,smp-sram";
-                               reg = <0 0x10>;
+                               reg = <0 0x100>;
                        };
                };
 
index 8d0a392b68111edba5d2e508e81d476275f6d868..29b6e10fdf96411cb308805c7419f29d994ae02b 100644 (file)
@@ -91,6 +91,11 @@ flash: flash@0 {
        };
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &sdhi1 {
        pinctrl-0 = <&sdhi1_pins>;
        pinctrl-names = "default";
index dd49a8b48f3e54823e89f33345e5ae0f9baa8fd2..1cb7a7ab0418f29df6d98ad24940cb781b2e50c3 100644 (file)
@@ -105,6 +105,13 @@ extal_clk: extal {
                clock-frequency = <0>;
        };
 
+       pmu {
+               compatible = "arm,cortex-a7-pmu";
+               interrupts-extended = <&gic GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>;
+       };
+
        /* External SCIF clock */
        scif_clk: scif {
                compatible = "fixed-clock";
@@ -262,6 +269,16 @@ rst: reset-controller@e6160000 {
                        reg = <0 0xe6160000 0 0x100>;
                };
 
+               rwdt: watchdog@e6020000 {
+                       compatible = "renesas,r8a7745-wdt",
+                                    "renesas,rcar-gen2-wdt";
+                       reg = <0 0xe6020000 0 0x0c>;
+                       clocks = <&cpg CPG_MOD 402>;
+                       power-domains = <&sysc R8A7745_PD_ALWAYS_ON>;
+                       resets = <&cpg 402>;
+                       status = "disabled";
+               };
+
                sysc: system-controller@e6180000 {
                        compatible = "renesas,r8a7745-sysc";
                        reg = <0 0xe6180000 0 0x200>;
@@ -360,7 +377,7 @@ icram1:     sram@e63c0000 {
 
                        smp-sram@0 {
                                compatible = "renesas,smp-sram";
-                               reg = <0 0x10>;
+                               reg = <0 0x100>;
                        };
                };
 
diff --git a/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts b/arch/arm/boot/dts/r8a77470-iwg23s-sbc.dts
new file mode 100644 (file)
index 0000000..e3585da
--- /dev/null
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree Source for the iWave-RZ/G1C single board computer
+ *
+ * Copyright (C) 2018 Renesas Electronics Corp.
+ */
+
+/dts-v1/;
+#include "r8a77470.dtsi"
+/ {
+       model = "iWave iW-RainboW-G23S single board computer based on RZ/G1C";
+       compatible = "iwave,g23s", "renesas,r8a77470";
+
+       aliases {
+               ethernet0 = &avb;
+               serial1 = &scif1;
+       };
+
+       chosen {
+               bootargs = "ignore_loglevel rw root=/dev/nfs ip=dhcp";
+               stdout-path = "serial1:115200n8";
+       };
+
+       memory@40000000 {
+               device_type = "memory";
+               reg = <0 0x40000000 0 0x20000000>;
+       };
+};
+
+&avb {
+       phy-handle = <&phy3>;
+       phy-mode = "gmii";
+       renesas,no-ether-link;
+       status = "okay";
+
+       phy3: ethernet-phy@3 {
+               reg = <3>;
+               micrel,led-mode = <1>;
+       };
+};
+
+&extal_clk {
+       clock-frequency = <20000000>;
+};
+
+&scif1 {
+       status = "okay";
+};
diff --git a/arch/arm/boot/dts/r8a77470.dtsi b/arch/arm/boot/dts/r8a77470.dtsi
new file mode 100644 (file)
index 0000000..c85032f
--- /dev/null
@@ -0,0 +1,336 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree Source for the r8a77470 SoC
+ *
+ * Copyright (C) 2018 Renesas Electronics Corp.
+ */
+
+#include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/clock/renesas-cpg-mssr.h>
+/ {
+       compatible = "renesas,r8a77470";
+       #address-cells = <2>;
+       #size-cells = <2>;
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               cpu0: cpu@0 {
+                       device_type = "cpu";
+                       compatible = "arm,cortex-a7";
+                       reg = <0>;
+                       clock-frequency = <1000000000>;
+                       clocks = <&cpg CPG_CORE 0>;
+                       power-domains = <&sysc 5>;
+                       next-level-cache = <&L2_CA7>;
+               };
+
+
+               L2_CA7: cache-controller-0 {
+                       compatible = "cache";
+                       cache-unified;
+                       cache-level = <2>;
+                       power-domains = <&sysc 21>;
+               };
+       };
+
+       /* External root clock */
+       extal_clk: extal {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               /* This value must be overridden by the board. */
+               clock-frequency = <0>;
+       };
+
+       /* External SCIF clock */
+       scif_clk: scif {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               /* This value must be overridden by the board. */
+               clock-frequency = <0>;
+       };
+
+       soc {
+               compatible = "simple-bus";
+               interrupt-parent = <&gic>;
+
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;
+
+               cpg: clock-controller@e6150000 {
+                       compatible = "renesas,r8a77470-cpg-mssr";
+                       reg = <0 0xe6150000 0 0x1000>;
+                       clocks = <&extal_clk>, <&usb_extal_clk>;
+                       clock-names = "extal", "usb_extal";
+                       #clock-cells = <2>;
+                       #power-domain-cells = <0>;
+                       #reset-cells = <1>;
+               };
+
+               rst: reset-controller@e6160000 {
+                       compatible = "renesas,r8a77470-rst";
+                       reg = <0 0xe6160000 0 0x100>;
+               };
+
+               sysc: system-controller@e6180000 {
+                       compatible = "renesas,r8a77470-sysc";
+                       reg = <0 0xe6180000 0 0x200>;
+                       #power-domain-cells = <1>;
+               };
+
+               irqc: interrupt-controller@e61c0000 {
+                       compatible = "renesas,irqc-r8a77470", "renesas,irqc";
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       reg = <0 0xe61c0000 0 0x200>;
+                       interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 407>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 407>;
+               };
+
+               icram0: sram@e63a0000 {
+                       compatible = "mmio-sram";
+                       reg = <0 0xe63a0000 0 0x12000>;
+               };
+
+               icram1: sram@e63c0000 {
+                       compatible = "mmio-sram";
+                       reg = <0 0xe63c0000 0 0x1000>;
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       ranges = <0 0 0xe63c0000 0x1000>;
+
+                       smp-sram@0 {
+                               compatible = "renesas,smp-sram";
+                               reg = <0 0x100>;
+                       };
+               };
+
+               icram2: sram@e6300000 {
+                       compatible = "mmio-sram";
+                       reg = <0 0xe6300000 0 0x20000>;
+               };
+
+               dmac0: dma-controller@e6700000 {
+                       compatible = "renesas,dmac-r8a77470",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xe6700000 0 0x20000>;
+                       interrupts = <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 200 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 201 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 202 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 203 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 204 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 206 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 207 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 211 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 213 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 214 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                         "ch0", "ch1", "ch2", "ch3",
+                                         "ch4", "ch5", "ch6", "ch7",
+                                         "ch8", "ch9", "ch10", "ch11",
+                                         "ch12", "ch13", "ch14";
+                       clocks = <&cpg CPG_MOD 219>;
+                       clock-names = "fck";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 219>;
+                       #dma-cells = <1>;
+                       dma-channels = <15>;
+               };
+
+               dmac1: dma-controller@e6720000 {
+                       compatible = "renesas,dmac-r8a77470",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xe6720000 0 0x20000>;
+                       interrupts = <GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 216 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 218 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 313 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 314 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 315 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 316 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 317 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 318 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                         "ch0", "ch1", "ch2", "ch3",
+                                         "ch4", "ch5", "ch6", "ch7",
+                                         "ch8", "ch9", "ch10", "ch11",
+                                         "ch12", "ch13", "ch14";
+                       clocks = <&cpg CPG_MOD 218>;
+                       clock-names = "fck";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 218>;
+                       #dma-cells = <1>;
+                       dma-channels = <15>;
+               };
+
+               avb: ethernet@e6800000 {
+                       compatible = "renesas,etheravb-r8a77470",
+                                    "renesas,etheravb-rcar-gen2";
+                       reg = <0 0xe6800000 0 0x800>, <0 0xee0e8000 0 0x4000>;
+                       interrupts = <GIC_SPI 163 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 812>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 812>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               scif0: serial@e6e60000 {
+                       compatible = "renesas,scif-r8a77470",
+                                    "renesas,rcar-gen2-scif", "renesas,scif";
+                       reg = <0 0xe6e60000 0 0x40>;
+                       interrupts = <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 721>,
+                                <&cpg CPG_CORE 5>, <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0x29>, <&dmac0 0x2a>,
+                              <&dmac1 0x29>, <&dmac1 0x2a>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 721>;
+                       status = "disabled";
+               };
+
+               scif1: serial@e6e68000 {
+                       compatible = "renesas,scif-r8a77470",
+                                    "renesas,rcar-gen2-scif", "renesas,scif";
+                       reg = <0 0xe6e68000 0 0x40>;
+                       interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 720>,
+                                <&cpg CPG_CORE 5>, <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0x2d>, <&dmac0 0x2e>,
+                              <&dmac1 0x2d>, <&dmac1 0x2e>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 720>;
+                       status = "disabled";
+               };
+
+               scif2: serial@e6e58000 {
+                       compatible = "renesas,scif-r8a77470",
+                                    "renesas,rcar-gen2-scif", "renesas,scif";
+                       reg = <0 0xe6e58000 0 0x40>;
+                       interrupts = <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 719>,
+                                <&cpg CPG_CORE 5>, <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0x2b>, <&dmac0 0x2c>,
+                              <&dmac1 0x2b>, <&dmac1 0x2c>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 719>;
+                       status = "disabled";
+               };
+
+               scif3: serial@e6ea8000 {
+                       compatible = "renesas,scif-r8a77470",
+                                    "renesas,rcar-gen2-scif", "renesas,scif";
+                       reg = <0 0xe6ea8000 0 0x40>;
+                       interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 718>,
+                                <&cpg CPG_CORE 5>, <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0x2f>, <&dmac0 0x30>,
+                              <&dmac1 0x2f>, <&dmac1 0x30>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 718>;
+                       status = "disabled";
+               };
+
+               scif4: serial@e6ee0000 {
+                       compatible = "renesas,scif-r8a77470",
+                                    "renesas,rcar-gen2-scif", "renesas,scif";
+                       reg = <0 0xe6ee0000 0 0x40>;
+                       interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 715>,
+                                <&cpg CPG_CORE 5>, <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0xfb>, <&dmac0 0xfc>,
+                              <&dmac1 0xfb>, <&dmac1 0xfc>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 715>;
+                       status = "disabled";
+               };
+
+               scif5: serial@e6ee8000 {
+                       compatible = "renesas,scif-r8a77470",
+                                    "renesas,rcar-gen2-scif", "renesas,scif";
+                       reg = <0 0xe6ee8000 0 0x40>;
+                       interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 714>,
+                                <&cpg CPG_CORE 5>, <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0xfd>, <&dmac0 0xfe>,
+                              <&dmac1 0xfd>, <&dmac1 0xfe>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 714>;
+                       status = "disabled";
+               };
+
+               gic: interrupt-controller@f1001000 {
+                       compatible = "arm,gic-400";
+                       #interrupt-cells = <3>;
+                       #address-cells = <0>;
+                       interrupt-controller;
+                       reg = <0 0xf1001000 0 0x1000>, <0 0xf1002000 0 0x2000>,
+                             <0 0xf1004000 0 0x2000>, <0 0xf1006000 0 0x2000>;
+                       interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_HIGH)>;
+                       clocks = <&cpg CPG_MOD 408>;
+                       clock-names = "clk";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 408>;
+               };
+
+               prr: chipid@ff000044 {
+                       compatible = "renesas,prr";
+                       reg = <0 0xff000044 0 4>;
+               };
+       };
+
+       timer {
+               compatible = "arm,armv7-timer";
+               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
+       };
+
+       /* External USB clock - can be overridden by the board */
+       usb_extal_clk: usb_extal {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <48000000>;
+       };
+};
index f07f9018c3e72e4631967dc3ca3c3da8d6772aef..092610e3f953167c22b71edf7242aa6e2e29c836 100644 (file)
@@ -902,9 +902,6 @@ &vin1 {
        status = "okay";
 
        port {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                vin1ep0: endpoint {
                        remote-endpoint = <&adv7180>;
                        bus-width = <8>;
@@ -929,6 +926,11 @@ dai0 {
        };
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &ssi1 {
        shared-pin;
 };
index 05a0fc23ac88f8ded558fe31da8ae15358c1ad15..4d06b154bd7ebd9eaa07436e6235bdacd76289f9 100644 (file)
@@ -202,6 +202,24 @@ pcie_bus_clk: pcie_bus {
                clock-frequency = <0>;
        };
 
+       pmu-0 {
+               compatible = "arm,cortex-a15-pmu";
+               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+       };
+
+       pmu-1 {
+               compatible = "arm,cortex-a7-pmu";
+               interrupts-extended = <&gic GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu4>, <&cpu5>, <&cpu6>, <&cpu7>;
+       };
+
        /* External SCIF clock */
        scif_clk: scif {
                compatible = "fixed-clock";
@@ -218,6 +236,16 @@ soc {
                #size-cells = <2>;
                ranges;
 
+               rwdt: watchdog@e6020000 {
+                       compatible = "renesas,r8a7790-wdt",
+                                    "renesas,rcar-gen2-wdt";
+                       reg = <0 0xe6020000 0 0x0c>;
+                       clocks = <&cpg CPG_MOD 402>;
+                       power-domains = <&sysc R8A7790_PD_ALWAYS_ON>;
+                       resets = <&cpg 402>;
+                       status = "disabled";
+               };
+
                gpio0: gpio@e6050000 {
                        compatible = "renesas,gpio-r8a7790",
                                     "renesas,rcar-gen2-gpio";
@@ -443,7 +471,7 @@ icram1:     sram@e63c0000 {
 
                        smp-sram@0 {
                                compatible = "renesas,smp-sram";
-                               reg = <0 0x10>;
+                               reg = <0 0x100>;
                        };
                };
 
@@ -1544,7 +1572,7 @@ gic: interrupt-controller@f1001000 {
                        interrupt-controller;
                        reg = <0 0xf1001000 0 0x1000>, <0 0xf1002000 0 0x2000>,
                              <0 0xf1004000 0 0x2000>, <0 0xf1006000 0 0x2000>;
-                       interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
+                       interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>;
                        clocks = <&cpg CPG_MOD 408>;
                        clock-names = "clk";
                        power-domains = <&sysc R8A7790_PD_ALWAYS_ON>;
@@ -1615,6 +1643,33 @@ vsp@fe938000 {
                        resets = <&cpg 127>;
                };
 
+               fdp1@fe940000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe940000 0 0x2400>;
+                       interrupts = <GIC_SPI 262 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 119>;
+                       power-domains = <&sysc R8A7790_PD_ALWAYS_ON>;
+                       resets = <&cpg 119>;
+               };
+
+               fdp1@fe944000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe944000 0 0x2400>;
+                       interrupts = <GIC_SPI 263 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 118>;
+                       power-domains = <&sysc R8A7790_PD_ALWAYS_ON>;
+                       resets = <&cpg 118>;
+               };
+
+               fdp1@fe948000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe948000 0 0x2400>;
+                       interrupts = <GIC_SPI 264 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 117>;
+                       power-domains = <&sysc R8A7790_PD_ALWAYS_ON>;
+                       resets = <&cpg 117>;
+               };
+
                jpu: jpeg-codec@fe980000 {
                        compatible = "renesas,jpu-r8a7790",
                                     "renesas,rcar-gen2-jpu";
@@ -1773,10 +1828,10 @@ cooling-maps {
 
        timer {
                compatible = "arm,armv7-timer";
-               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_LOW)>;
+               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>;
        };
 
        /* External USB clock - can be overridden by the board */
index 9d7213a0b8b826506e14c51b95fe10724434b9b6..8ab793d8b2fd76c894b28e79de34c6b97ddea308 100644 (file)
@@ -643,6 +643,11 @@ &cmt0 {
        status = "okay";
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &sata0 {
        status = "okay";
 };
@@ -850,9 +855,6 @@ &vin0 {
        pinctrl-names = "default";
 
        port {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                vin0ep2: endpoint {
                        remote-endpoint = <&adv7612_out>;
                        bus-width = <24>;
@@ -871,9 +873,6 @@ &vin1 {
        pinctrl-names = "default";
 
        port {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                vin1ep: endpoint {
                        remote-endpoint = <&adv7180>;
                        bus-width = <8>;
index ae9ed9ff53efde994a4d4735227bb0a8199fab81..a01101b49d993c185249009b063d6ef0b80d13bc 100644 (file)
@@ -386,9 +386,6 @@ &vin0 {
        pinctrl-names = "default";
 
        port {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                vin0ep: endpoint {
                        remote-endpoint = <&adv7180>;
                        bus-width = <8>;
@@ -481,6 +478,11 @@ dai0 {
        };
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &ssi1 {
        shared-pin;
 };
index 506b20885413398825a353b6b84938175cfd255f..6e1dd7ad7bd647e7db66c1db8947c1d9718957ce 100644 (file)
@@ -126,6 +126,13 @@ pcie_bus_clk: pcie_bus {
                clock-frequency = <0>;
        };
 
+       pmu {
+               compatible = "arm,cortex-a15-pmu";
+               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>;
+       };
+
        /* External SCIF clock */
        scif_clk: scif {
                compatible = "fixed-clock";
@@ -142,6 +149,16 @@ soc {
                #size-cells = <2>;
                ranges;
 
+               rwdt: watchdog@e6020000 {
+                       compatible = "renesas,r8a7791-wdt",
+                                    "renesas,rcar-gen2-wdt";
+                       reg = <0 0xe6020000 0 0x0c>;
+                       clocks = <&cpg CPG_MOD 402>;
+                       power-domains = <&sysc R8A7791_PD_ALWAYS_ON>;
+                       resets = <&cpg 402>;
+                       status = "disabled";
+               };
+
                gpio0: gpio@e6050000 {
                        compatible = "renesas,gpio-r8a7791",
                                     "renesas,rcar-gen2-gpio";
@@ -407,7 +424,7 @@ icram1:     sram@e63c0000 {
 
                        smp-sram@0 {
                                compatible = "renesas,smp-sram";
-                               reg = <0 0x10>;
+                               reg = <0 0x100>;
                        };
                };
 
@@ -1621,6 +1638,24 @@ vsp@fe938000 {
                        resets = <&cpg 127>;
                };
 
+               fdp1@fe940000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe940000 0 0x2400>;
+                       interrupts = <GIC_SPI 262 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 119>;
+                       power-domains = <&sysc R8A7791_PD_ALWAYS_ON>;
+                       resets = <&cpg 119>;
+               };
+
+               fdp1@fe944000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe944000 0 0x2400>;
+                       interrupts = <GIC_SPI 263 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 118>;
+                       power-domains = <&sysc R8A7791_PD_ALWAYS_ON>;
+                       resets = <&cpg 118>;
+               };
+
                jpu: jpeg-codec@fe980000 {
                        compatible = "renesas,jpu-r8a7791",
                                     "renesas,rcar-gen2-jpu";
index 9b67dca6c9ef550d49e2224c880c61eb5925f568..04fb70931b3b077269a2bbc2a79ae9cd4fd168e7 100644 (file)
@@ -239,6 +239,11 @@ du1_pins: du1 {
        };
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &scif0 {
        pinctrl-0 = <&scif0_pins>;
        pinctrl-names = "default";
index b9471b67b72829de871def622002bcaf6ddbed8e..db01de7a3811ecce28461ecc6dc6334d334aeaf8 100644 (file)
@@ -168,6 +168,11 @@ du1_pins: du1 {
        };
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &scif0 {
        pinctrl-0 = <&scif0_pins>;
        pinctrl-names = "default";
@@ -240,9 +245,15 @@ &i2c4 {
        status = "okay";
        clock-frequency = <400000>;
 
+       /*
+        * The adv75xx resets its addresses to defaults during low power mode.
+        * Because we have two ADV7513 devices on the same bus, we must change
+        * both of them away from the defaults so that they do not conflict.
+        */
        hdmi@3d {
                compatible = "adi,adv7513";
-               reg = <0x3d>;
+               reg = <0x3d>, <0x2d>, <0x4d>, <0x5d>;
+               reg-names = "main", "cec", "edid", "packet";
 
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
@@ -272,7 +283,8 @@ adv7513_0_out: endpoint {
 
        hdmi@39 {
                compatible = "adi,adv7513";
-               reg = <0x39>;
+               reg = <0x39>, <0x29>, <0x49>, <0x59>;
+               reg-names = "main", "cec", "edid", "packet";
 
                adi,input-depth = <8>;
                adi,input-colorspace = "rgb";
index 268987ff020179b09b7c91839ab6a876c98b96b2..f44257dd86f6628962e3cf1df4f026829b886c5a 100644 (file)
@@ -85,6 +85,13 @@ extal_clk: extal {
                clock-frequency = <0>;
        };
 
+       pmu {
+               compatible = "arm,cortex-a15-pmu";
+               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>;
+       };
+
        /* External SCIF clock */
        scif_clk: scif {
                compatible = "fixed-clock";
@@ -101,6 +108,16 @@ soc {
                #size-cells = <2>;
                ranges;
 
+               rwdt: watchdog@e6020000 {
+                       compatible = "renesas,r8a7792-wdt",
+                                    "renesas,rcar-gen2-wdt";
+                       reg = <0 0xe6020000 0 0x0c>;
+                       clocks = <&cpg CPG_MOD 402>;
+                       power-domains = <&sysc R8A7792_PD_ALWAYS_ON>;
+                       resets = <&cpg 402>;
+                       status = "disabled";
+               };
+
                gpio0: gpio@e6050000 {
                        compatible = "renesas,gpio-r8a7792",
                                     "renesas,rcar-gen2-gpio";
@@ -341,7 +358,7 @@ icram1:     sram@e63c0000 {
 
                        smp-sram@0 {
                                compatible = "renesas,smp-sram";
-                               reg = <0 0x10>;
+                               reg = <0 0x100>;
                        };
                };
 
index 96e117d8b2cce0f8e4070d05fdb48995775ee667..aa209f6e5d712e6cf021e9712c8287f1e98104ec 100644 (file)
@@ -599,6 +599,11 @@ &cmt0 {
        status = "okay";
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &scif0 {
        pinctrl-0 = <&scif0_pins>;
        pinctrl-names = "default";
@@ -758,9 +763,6 @@ &vin0 {
        pinctrl-names = "default";
 
        port {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                vin0ep2: endpoint {
                        remote-endpoint = <&adv7612_out>;
                        bus-width = <24>;
@@ -780,9 +782,6 @@ &vin1 {
        status = "okay";
 
        port {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                vin1ep: endpoint {
                        remote-endpoint = <&adv7180_out>;
                        bus-width = <8>;
index 4f526030dc7cb7011e67f8ff26fad601d6af867f..4abecfc0ca98c48346114b5f44600e795182aedb 100644 (file)
@@ -110,6 +110,13 @@ extal_clk: extal {
                clock-frequency = <0>;
        };
 
+       pmu {
+               compatible = "arm,cortex-a15-pmu";
+               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>;
+       };
+
        /* External SCIF clock */
        scif_clk: scif {
                compatible = "fixed-clock";
@@ -126,6 +133,16 @@ soc {
                #size-cells = <2>;
                ranges;
 
+               rwdt: watchdog@e6020000 {
+                       compatible = "renesas,r8a7793-wdt",
+                                    "renesas,rcar-gen2-wdt";
+                       reg = <0 0xe6020000 0 0x0c>;
+                       clocks = <&cpg CPG_MOD 402>;
+                       power-domains = <&sysc R8A7793_PD_ALWAYS_ON>;
+                       resets = <&cpg 402>;
+                       status = "disabled";
+               };
+
                gpio0: gpio@e6050000 {
                        compatible = "renesas,gpio-r8a7793",
                                     "renesas,rcar-gen2-gpio";
@@ -392,7 +409,7 @@ icram1:     sram@e63c0000 {
 
                        smp-sram@0 {
                                compatible = "renesas,smp-sram";
-                               reg = <0 0x10>;
+                               reg = <0 0x100>;
                        };
                };
 
@@ -1290,6 +1307,24 @@ gic: interrupt-controller@f1001000 {
                        resets = <&cpg 408>;
                };
 
+               fdp1@fe940000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe940000 0 0x2400>;
+                       interrupts = <GIC_SPI 262 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 119>;
+                       power-domains = <&sysc R8A7793_PD_ALWAYS_ON>;
+                       resets = <&cpg 119>;
+               };
+
+               fdp1@fe944000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe944000 0 0x2400>;
+                       interrupts = <GIC_SPI 263 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 118>;
+                       power-domains = <&sysc R8A7793_PD_ALWAYS_ON>;
+                       resets = <&cpg 118>;
+               };
+
                du: display@feb00000 {
                        compatible = "renesas,du-r8a7793";
                        reg = <0 0xfeb00000 0 0x40000>;
index 26a883484ea814c8ef48b9434fceef9ff482c126..e17027532941f57c753fed893d6d0f2ff2873fbb 100644 (file)
@@ -181,6 +181,12 @@ adv7180: endpoint {
                                };
                        };
                };
+
+               eeprom@50 {
+                       compatible = "renesas,r1ex24002", "atmel,24c02";
+                       reg = <0x50>;
+                       pagesize = <16>;
+               };
        };
 
        /*
@@ -330,6 +336,11 @@ &mmcif0 {
        status = "okay";
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &sdhi0 {
        pinctrl-0 = <&sdhi0_pins>;
        pinctrl-1 = <&sdhi0_pins_uhs>;
@@ -375,9 +386,6 @@ &vin0 {
        pinctrl-names = "default";
 
        port {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                vin0ep: endpoint {
                        remote-endpoint = <&adv7180>;
                        bus-width = <8>;
index 351cb3b3d966342038646b81aaf2c14d056976d0..7808aaee6644a95dcfdaf1d6e001c3293c265375 100644 (file)
@@ -475,9 +475,6 @@ &vin0 {
        pinctrl-names = "default";
 
        port {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                vin0ep: endpoint {
                        remote-endpoint = <&adv7180>;
                        bus-width = <8>;
@@ -540,6 +537,11 @@ dai0 {
        };
 };
 
+&rwdt {
+       timeout-sec = <60>;
+       status = "okay";
+};
+
 &ssi1 {
        shared-pin;
 };
index d588efa6aeaa0eb2232ef992aad23e70a5c48972..736196903d22f0e09650ac9b7644476369040603 100644 (file)
@@ -103,6 +103,13 @@ extal_clk: extal {
                clock-frequency = <0>;
        };
 
+       pmu {
+               compatible = "arm,cortex-a7-pmu";
+               interrupts-extended = <&gic GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>;
+       };
+
        /* External SCIF clock */
        scif_clk: scif {
                compatible = "fixed-clock";
@@ -119,6 +126,16 @@ soc {
                #size-cells = <2>;
                ranges;
 
+               rwdt: watchdog@e6020000 {
+                       compatible = "renesas,r8a7794-wdt",
+                                    "renesas,rcar-gen2-wdt";
+                       reg = <0 0xe6020000 0 0x0c>;
+                       clocks = <&cpg CPG_MOD 402>;
+                       power-domains = <&sysc R8A7794_PD_ALWAYS_ON>;
+                       resets = <&cpg 402>;
+                       status = "disabled";
+               };
+
                gpio0: gpio@e6050000 {
                        compatible = "renesas,gpio-r8a7794",
                                     "renesas,rcar-gen2-gpio";
@@ -348,7 +365,7 @@ icram1:     sram@e63c0000 {
 
                        smp-sram@0 {
                                compatible = "renesas,smp-sram";
-                               reg = <0 0x10>;
+                               reg = <0 0x100>;
                        };
                };
 
@@ -1323,6 +1340,15 @@ vsp@fe930000 {
                        resets = <&cpg 128>;
                };
 
+               fdp1@fe940000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe940000 0 0x2400>;
+                       interrupts = <GIC_SPI 262 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 119>;
+                       power-domains = <&sysc R8A7794_PD_ALWAYS_ON>;
+                       resets = <&cpg 119>;
+               };
+
                du: display@feb00000 {
                        compatible = "renesas,du-r8a7794";
                        reg = <0 0xfeb00000 0 0x40000>;
index a97458112ff6e80ca198fe1377521372973e8ca4..567a6a725f9cc889ce19a81aad4b8dbb24bb96bb 100644 (file)
@@ -197,6 +197,8 @@ vop_mmu: iommu@10118300 {
                reg = <0x10118300 0x100>;
                interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vop_mmu";
+               clocks = <&cru ACLK_LCDC>, <&cru HCLK_LCDC>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
index df1e478586753ccbd9cf889108466e45d200f2a4..be80e9a2c9af16fbf10e9cb6ee143a4f0d3151c7 100644 (file)
@@ -584,6 +584,8 @@ vpu_mmu: iommu@20020800 {
                reg = <0x20020800 0x100>;
                interrupts = <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vpu_mmu";
+               clocks = <&cru ACLK_VPU>, <&cru HCLK_VPU>;
+               clock-names = "aclk", "iface";
                iommu-cells = <0>;
                status = "disabled";
        };
@@ -593,6 +595,8 @@ vdec_mmu: iommu@20030480 {
                reg = <0x20030480 0x40>, <0x200304c0 0x40>;
                interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vdec_mmu";
+               clocks = <&cru ACLK_RKVDEC>, <&cru HCLK_RKVDEC>;
+               clock-names = "aclk", "iface";
                iommu-cells = <0>;
                status = "disabled";
        };
@@ -602,6 +606,8 @@ vop_mmu: iommu@20053f00 {
                reg = <0x20053f00 0x100>;
                interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vop_mmu";
+               clocks = <&cru ACLK_VOP>, <&cru HCLK_VOP>;
+               clock-names = "aclk", "iface";
                iommu-cells = <0>;
                status = "disabled";
        };
@@ -611,6 +617,8 @@ iep_mmu: iommu@20070800 {
                reg = <0x20070800 0x100>;
                interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "iep_mmu";
+               clocks = <&cru ACLK_IEP>, <&cru HCLK_IEP>;
+               clock-names = "aclk", "iface";
                iommu-cells = <0>;
                status = "disabled";
        };
index f13bcb1cd3d9888ee9caa77d4c326d6f01e10cd5..aaab2d171ffe1da4716fbd959d1e6eacd3e891b9 100644 (file)
@@ -151,6 +151,7 @@ phy0: ethernet-phy@0 {
                        ti,tx-internal-delay = <DP83867_RGMIIDCTL_2_00_NS>;
                        ti,fifo-depth = <DP83867_PHYCR_FIFO_DEPTH_4_B_NIB>;
                        enet-phy-lane-no-swap;
+                       ti,clk-output-sel = <DP83867_CLK_O_SEL_CHN_A_TCLK>;
                };
        };
 };
index 346b0d8b474d9995f000d0dd3fedca46cff755cf..127488f9f17460133f802e206f598c11a766735c 100644 (file)
@@ -49,6 +49,10 @@ / {
        model = "Rockchip RK3288 Tinker Board";
        compatible = "asus,rk3288-tinker", "rockchip,rk3288";
 
+       chosen {
+               stdout-path = "serial2:115200n8";
+       };
+
        memory {
                reg = <0x0 0x0 0x0 0x80000000>;
                device_type = "memory";
index be487111d0252ece0b27c324dab7a1b2bad94b95..b16d570ff029b74da108fa1df3d0d60e1c314953 100644 (file)
@@ -95,7 +95,8 @@ backlight: backlight {
                pinctrl-names = "default";
                pinctrl-0 = <&bl_en>;
                pwms = <&pwm0 0 1000000 0>;
-               pwm-delay-us = <10000>;
+               post-pwm-on-delay-ms = <10>;
+               pwm-off-delay-ms = <10>;
        };
 
        gpio-charger {
index 544de6027aaa0fcb9f4f11a94b9367534f77afab..4c5307e62001e4fc6172e4a1b80a63bdb73c6f20 100644 (file)
@@ -123,6 +123,8 @@ &backlight {
                        240 241 242 243 244 245 246 247
                        248 249 250 251 252 253 254 255>;
        power-supply = <&backlight_regulator>;
+       post-pwm-on-delay-ms = <200>;
+       pwm-off-delay-ms = <200>;
 };
 
 &emmc {
index 354aff45c1afca2dcec62e420602c01237c5b04e..d7e49d29ace540fe4022b8822b84840ebdb5b65a 100644 (file)
@@ -959,6 +959,8 @@ iep_mmu: iommu@ff900800 {
                reg = <0x0 0xff900800 0x0 0x40>;
                interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "iep_mmu";
+               clocks = <&cru ACLK_IEP>, <&cru HCLK_IEP>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -968,6 +970,8 @@ isp_mmu: iommu@ff914000 {
                reg = <0x0 0xff914000 0x0 0x100>, <0x0 0xff915000 0x0 0x100>;
                interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "isp_mmu";
+               clocks = <&cru ACLK_ISP>, <&cru HCLK_ISP>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                rockchip,disable-mmu-reset;
                status = "disabled";
@@ -1027,6 +1031,8 @@ vopb_mmu: iommu@ff930300 {
                reg = <0x0 0xff930300 0x0 0x100>;
                interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vopb_mmu";
+               clocks = <&cru ACLK_VOP0>, <&cru HCLK_VOP0>;
+               clock-names = "aclk", "iface";
                power-domains = <&power RK3288_PD_VIO>;
                #iommu-cells = <0>;
                status = "disabled";
@@ -1075,6 +1081,8 @@ vopl_mmu: iommu@ff940300 {
                reg = <0x0 0xff940300 0x0 0x100>;
                interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vopl_mmu";
+               clocks = <&cru ACLK_VOP1>, <&cru HCLK_VOP1>;
+               clock-names = "aclk", "iface";
                power-domains = <&power RK3288_PD_VIO>;
                #iommu-cells = <0>;
                status = "disabled";
@@ -1206,6 +1214,8 @@ vpu_mmu: iommu@ff9a0800 {
                reg = <0x0 0xff9a0800 0x0 0x100>;
                interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vpu_mmu";
+               clocks = <&cru ACLK_VCODEC>, <&cru HCLK_VCODEC>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -1215,6 +1225,8 @@ hevc_mmu: iommu@ff9c0440 {
                reg = <0x0 0xff9c0440 0x0 0x40>, <0x0 0xff9c0480 0x0 0x40>;
                interrupts = <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "hevc_mmu";
+               clocks = <&cru ACLK_HEVC>, <&cru HCLK_HEVC>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -1848,16 +1860,16 @@ uart3_rts: uart3-rts {
 
                uart4 {
                        uart4_xfer: uart4-xfer {
-                               rockchip,pins = <5 12 3 &pcfg_pull_up>,
-                                               <5 13 3 &pcfg_pull_none>;
+                               rockchip,pins = <5 15 3 &pcfg_pull_up>,
+                                               <5 14 3 &pcfg_pull_none>;
                        };
 
                        uart4_cts: uart4-cts {
-                               rockchip,pins = <5 14 3 &pcfg_pull_up>;
+                               rockchip,pins = <5 12 3 &pcfg_pull_up>;
                        };
 
                        uart4_rts: uart4-rts {
-                               rockchip,pins = <5 15 3 &pcfg_pull_none>;
+                               rockchip,pins = <5 13 3 &pcfg_pull_none>;
                        };
                };
 
index a1c9d8c695ccecdb52f6e6dd89a9915d50713609..5164386aff3a12695dca726a42aa84a64e282aba 100644 (file)
@@ -12,14 +12,13 @@ / {
        model = "SMDK2416";
        compatible = "samsung,s3c2416";
 
-       memory {
+       memory@30000000 {
+               device_type = "memory";
                reg =  <0x30000000 0x4000000>;
        };
 
        clocks {
                compatible = "simple-bus";
-               #address-cells = <1>;
-               #size-cells = <1>;
 
                xti: xti {
                        compatible = "fixed-clock";
index 3c7385cab2485f638b9a39bf86db7ff7d6a1bb7b..6adf64ea3ff29883eaaf667265363abcab385739 100644 (file)
@@ -18,9 +18,6 @@ aliases {
        };
 
        cpus {
-               #address-cells = <1>;
-               #size-cells = <0>;
-
                cpu {
                        compatible = "arm,arm926ej-s";
                };
@@ -30,7 +27,7 @@ interrupt-controller@4a000000 {
                compatible = "samsung,s3c2416-irq";
        };
 
-       clocks: clock-controller@0x4c000000 {
+       clocks: clock-controller@4c000000 {
                compatible = "samsung,s3c2416-clock";
                reg = <0x4c000000 0x40>;
                #clock-cells = <1>;
@@ -69,7 +66,7 @@ uart_2: serial@50008000 {
                                <&clocks SCLK_UART>;
        };
 
-       uart_3: serial@5000C000 {
+       uart_3: serial@5000c000 {
                compatible = "samsung,s3c2440-uart";
                reg = <0x5000C000 0x4000>;
                interrupts = <1 18 24 4>, <1 18 25 4>;
@@ -80,7 +77,7 @@ uart_3: serial@5000C000 {
                status = "disabled";
        };
 
-       sdhci_1: sdhci@4AC00000 {
+       sdhci_1: sdhci@4ac00000 {
                compatible = "samsung,s3c6410-sdhci";
                reg = <0x4AC00000 0x100>;
                interrupts = <0 0 21 3>;
@@ -91,7 +88,7 @@ sdhci_1: sdhci@4AC00000 {
                status = "disabled";
        };
 
-       sdhci_0: sdhci@4A800000 {
+       sdhci_0: sdhci@4a800000 {
                compatible = "samsung,s3c6410-sdhci";
                reg = <0x4A800000 0x100>;
                interrupts = <0 0 20 3>;
index 34c7fe6751cf98da48ee2584e406c1e87f1e2ed2..6d8dd3cdd3c08c19d643aba45a66401a6b333fe9 100644 (file)
@@ -5,11 +5,11 @@
  * Copyright (c) 2013 Heiko Stuebner <heiko@sntech.de>
  */
 
-#include "skeleton.dtsi"
-
 / {
        compatible = "samsung,s3c24xx";
        interrupt-parent = <&intc>;
+       #address-cells = <1>;
+       #size-cells = <1>;
 
        aliases {
                pinctrl0 = &pinctrl_0;
index f68601bd9c91f4d435d0034bd8b542c42b63d4a3..0e159c884f972240914d319aeeccdccdecdf2a93 100644 (file)
@@ -19,7 +19,8 @@ / {
        model = "FriendlyARM Mini6410 board based on S3C6410";
        compatible = "friendlyarm,mini6410", "samsung,s3c6410";
 
-       memory {
+       memory@50000000 {
+               device_type = "memory";
                reg = <0x50000000 0x10000000>;
        };
 
index b6b5afcd76021cafeeac64073b6869b63fbcaefe..a9a5689dc462db0b3f6abe56be1dea2dd6aedbbd 100644 (file)
@@ -19,7 +19,8 @@ / {
        model = "SAMSUNG SMDK6410 board based on S3C6410";
        compatible = "samsung,mini6410", "samsung,s3c6410";
 
-       memory {
+       memory@50000000 {
+               device_type = "memory";
                reg = <0x50000000 0x8000000>;
        };
 
index e2be3fbdd3f3de9b24cf634c51e96af46565b352..2e611df379115790923ce33705ee78628deef90e 100644 (file)
  * nodes can be added to this file.
  */
 
-#include "skeleton.dtsi"
 #include <dt-bindings/clock/samsung,s3c64xx-clock.h>
 
 / {
+       #address-cells = <1>;
+       #size-cells = <1>;
+
        aliases {
                i2c0 = &i2c0;
                pinctrl0 = &pinctrl0;
index 914a7c2a584f90838b872892dfd242879eebbeda..c953648a5f4106b9d996c14866138ab04d6d633c 100644 (file)
@@ -22,7 +22,7 @@ cpus {
                #address-cells = <1>;
                #size-cells = <0>;
 
-               cpu@0 {
+               cpu0: cpu@0 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <0>;
@@ -31,7 +31,7 @@ cpu@0 {
                        power-domains = <&pd_a2sl>;
                        next-level-cache = <&L2>;
                };
-               cpu@1 {
+               cpu1: cpu@1 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a9";
                        reg = <1>;
@@ -91,6 +91,7 @@ pmu {
                compatible = "arm,cortex-a9-pmu";
                interrupts = <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&cpu0>, <&cpu1>;
        };
 
        cmt1: timer@e6138000 {
@@ -336,7 +337,7 @@ sdhi1: sd@ee120000 {
                              GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp3_clks SH73A0_CLK_SDHI1>;
                power-domains = <&pd_a3sp>;
-               toshiba,mmc-wrprotect-disable;
+               disable-wp;
                cap-sd-highspeed;
                status = "disabled";
        };
@@ -348,7 +349,7 @@ sdhi2: sd@ee140000 {
                              GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
                clocks = <&mstp3_clks SH73A0_CLK_SDHI2>;
                power-domains = <&pd_a3sp>;
-               toshiba,mmc-wrprotect-disable;
+               disable-wp;
                cap-sd-highspeed;
                status = "disabled";
        };
diff --git a/arch/arm/boot/dts/ste-ccu8540-pinctrl.dtsi b/arch/arm/boot/dts/ste-ccu8540-pinctrl.dtsi
deleted file mode 100644 (file)
index 52dba2e..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright 2012 ST-Ericsson
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-#include "ste-nomadik-pinctrl.dtsi"
-
-/ {
-       soc {
-               pinctrl {
-                       uart0 {
-                               uart0_default_mux: uart0_mux {
-                                       default_mux {
-                                               function = "u0";
-                                               groups = "u0_a_1";
-                                       };
-                               };
-
-                               uart0_default_mode: uart0_default {
-                                       default_cfg1 {
-                                               pins = "GPIO0", "GPIO2";
-                                               ste,config = <&in_pu>;
-                                       };
-
-                                       default_cfg2 {
-                                               pins = "GPIO1", "GPIO3";
-                                               ste,config = <&out_hi>;
-                                       };
-                               };
-
-                               uart0_sleep_mode: uart0_sleep {
-                                       sleep_cfg1 {
-                                               pins = "GPIO0", "GPIO2";
-                                               ste,config = <&slpm_in_pu>;
-                                       };
-
-                                       sleep_cfg2 {
-                                               pins = "GPIO1", "GPIO3";
-                                               ste,config = <&slpm_out_hi>;
-                                       };
-                               };
-                       };
-
-                       uart2 {
-                               uart2_default_mode: uart2_default {
-                                       default_mux {
-                                               function = "u2";
-                                               groups = "u2txrx_a_1";
-                                       };
-
-                                       default_cfg1 {
-                                               pins = "GPIO120";
-                                               ste,config = <&in_pu>;
-                                       };
-
-                                       default_cfg2 {
-                                               pins = "GPIO121";
-                                               ste,config = <&out_hi>;
-                                       };
-                               };
-
-                               uart2_sleep_mode: uart2_sleep {
-                                       sleep_cfg1 {
-                                               pins = "GPIO120";
-                                               ste,config = <&slpm_in_pu>;
-                                       };
-
-                                       sleep_cfg2 {
-                                               pins = "GPIO121";
-                                               ste,config = <&slpm_out_hi>;
-                                       };
-                               };
-                       };
-
-                       i2c0 {
-                               i2c0_default_mux: i2c_mux {
-                                       default_mux {
-                                               function = "i2c0";
-                                               groups = "i2c0_a_1";
-                                       };
-                               };
-
-                               i2c0_default_mode: i2c_default {
-                                       default_cfg1 {
-                                               pins = "GPIO147", "GPIO148";
-                                               ste,config = <&in_pu>;
-                                       };
-                               };
-
-                               i2c0_sleep_mode: i2c_sleep {
-                                       sleep_cfg1 {
-                                               pins = "GPIO147", "GPIO148";
-                                               ste,config = <&slpm_in_pu>;
-                                       };
-                               };
-                       };
-
-                       i2c1 {
-                               i2c1_default_mux: i2c_mux {
-                                       default_mux {
-                                               function = "i2c1";
-                                               groups = "i2c1_b_2";
-                                       };
-                               };
-
-                               i2c1_default_mode: i2c_default {
-                                       default_cfg1 {
-                                               pins = "GPIO16", "GPIO17";
-                                               ste,config = <&in_pu>;
-                                       };
-                               };
-
-                               i2c1_sleep_mode: i2c_sleep {
-                                       sleep_cfg1 {
-                                               pins = "GPIO16", "GPIO17";
-                                               ste,config = <&slpm_in_pu>;
-                                       };
-                               };
-                       };
-
-                       i2c2 {
-                               i2c2_default_mux: i2c_mux {
-                                       default_mux {
-                                               function = "i2c2";
-                                               groups = "i2c2_b_2";
-                                       };
-                               };
-
-                               i2c2_default_mode: i2c_default {
-                                       default_cfg1 {
-                                               pins = "GPIO10", "GPIO11";
-                                               ste,config = <&in_pu>;
-                                       };
-                               };
-
-                               i2c2_sleep_mode: i2c_sleep {
-                                       sleep_cfg1 {
-                                               pins = "GPIO11", "GPIO11";
-                                               ste,config = <&slpm_in_pu>;
-                                       };
-                               };
-                       };
-
-                       i2c4 {
-                               i2c4_default_mux: i2c_mux {
-                                       default_mux {
-                                               function = "i2c4";
-                                               groups = "i2c4_b_2";
-                                       };
-                               };
-
-                               i2c4_default_mode: i2c_default {
-                                       default_cfg1 {
-                                               pins = "GPIO122", "GPIO123";
-                                               ste,config = <&in_pu>;
-                                       };
-                               };
-
-                               i2c4_sleep_mode: i2c_sleep {
-                                       sleep_cfg1 {
-                                               pins = "GPIO122", "GPIO123";
-                                               ste,config = <&slpm_in_pu>;
-                                       };
-                               };
-                       };
-
-                       i2c5 {
-                               i2c5_default_mux: i2c_mux {
-                                       default_mux {
-                                               function = "i2c5";
-                                               groups = "i2c5_c_2";
-                                       };
-                               };
-
-                               i2c5_default_mode: i2c_default {
-                                       default_cfg1 {
-                                               pins = "GPIO118", "GPIO119";
-                                               ste,config = <&in_pu>;
-                                       };
-                               };
-
-                               i2c5_sleep_mode: i2c_sleep {
-                                       sleep_cfg1 {
-                                               pins = "GPIO118", "GPIO119";
-                                               ste,config = <&slpm_in_pu>;
-                                       };
-                               };
-                       };
-               };
-       };
-};
diff --git a/arch/arm/boot/dts/ste-ccu8540.dts b/arch/arm/boot/dts/ste-ccu8540.dts
deleted file mode 100644 (file)
index 6eaaf63..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2013 ST-Ericsson AB
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-/dts-v1/;
-#include "ste-dbx5x0.dtsi"
-#include "ste-ccu8540-pinctrl.dtsi"
-
-/ {
-       model = "ST-Ericsson U8540 platform with Device Tree";
-       compatible = "st-ericsson,ccu8540", "st-ericsson,u8540";
-
-       /* This stablilizes the serial port enumeration */
-       aliases {
-               serial0 = &ux500_serial0;
-               serial1 = &ux500_serial1;
-               serial2 = &ux500_serial2;
-       };
-
-       memory@0 {
-               device_type = "memory";
-               reg = <0x20000000 0x1f000000>, <0xc0000000 0x3f000000>;
-       };
-
-       soc {
-               pinctrl {
-                       compatible = "stericsson,db8540-pinctrl";
-               };
-
-               prcmu@80157000 {
-                       reg = <0x80157000 0x2000>, <0x801b0000 0x8000>, <0x801b8000 0x3000>;
-                       reg-names = "prcmu", "prcmu-tcpm", "prcmu-tcdm";
-               };
-
-               uart@80120000 {
-                       pinctrl-names = "default", "sleep";
-                       pinctrl-0 = <&uart0_default_mux>, <&uart0_default_mode>;
-                       pinctrl-1 = <&uart0_sleep_mode>;
-                       status = "okay";
-               };
-
-               uart@80121000 {
-                       status = "okay";
-               };
-
-               uart@80007000 {
-                       pinctrl-names = "default", "sleep";
-                       pinctrl-0 = <&uart2_default_mode>;
-                       pinctrl-1 = <&uart2_sleep_mode>;
-                       status = "okay";
-               };
-
-               i2c0: i2c@80004000 {
-                       pinctrl-names = "default","sleep";
-                       pinctrl-0 = <&i2c0_default_mux>, <&i2c0_default_mode>;
-                       pinctrl-1 = <&i2c0_sleep_mode>;
-               };
-
-               i2c1: i2c@80122000 {
-                       pinctrl-names = "default","sleep";
-                       pinctrl-0 = <&i2c1_default_mux>, <&i2c1_default_mode>;
-                       pinctrl-1 = <&i2c1_sleep_mode>;
-               };
-
-               i2c2: i2c@80128000 {
-                       pinctrl-names = "default","sleep";
-                       pinctrl-0 = <&i2c2_default_mux>, <&i2c2_default_mode>;
-                       pinctrl-1 = <&i2c2_sleep_mode>;
-               };
-
-               i2c3: i2c@80110000 {
-                       status = "disabled";
-               };
-
-               i2c4: i2c@8012a000 {
-                       pinctrl-names = "default","sleep";
-                       pinctrl-0 = <&i2c4_default_mux>, <&i2c4_default_mode>;
-                       pinctrl-1 = <&i2c4_sleep_mode>;
-               };
-
-               i2c5: i2c@80001000 {
-                       pinctrl-names = "default","sleep";
-                       pinctrl-0 = <&i2c5_default_mux>, <&i2c5_default_mode>;
-                       pinctrl-1 = <&i2c5_sleep_mode>;
-               };
-       };
-};
diff --git a/arch/arm/boot/dts/ste-ccu9540.dts b/arch/arm/boot/dts/ste-ccu9540.dts
deleted file mode 100644 (file)
index b3b9bb8..0000000
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2012 ST-Ericsson AB
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-/dts-v1/;
-#include "ste-dbx5x0.dtsi"
-
-/ {
-       model = "ST-Ericsson CCU9540 platform with Device Tree";
-       compatible = "st-ericsson,ccu9540", "st-ericsson,u9540";
-
-       /* This stablilizes the serial port enumeration */
-       aliases {
-               serial0 = &ux500_serial0;
-               serial1 = &ux500_serial1;
-               serial2 = &ux500_serial2;
-       };
-
-       memory {
-               reg = <0x00000000 0x20000000>;
-       };
-
-       soc {
-               uart@80120000 {
-                       status = "okay";
-               };
-
-               uart@80121000 {
-                       status = "okay";
-               };
-
-               uart@80007000 {
-                       status = "okay";
-               };
-
-               // External Micro SD slot
-               sdi0_per1@80126000 {
-                       arm,primecell-periphid = <0x10480180>;
-                       max-frequency = <100000000>;
-                       bus-width = <4>;
-                       cap-sd-highspeed;
-                       cap-mmc-highspeed;
-                       vmmc-supply = <&ab8500_ldo_aux3_reg>;
-
-                       cd-gpios  = <&gpio7 6 GPIO_ACTIVE_HIGH>; // 230
-                       cd-inverted;
-
-                       status = "okay";
-               };
-
-
-               // WLAN SDIO channel
-               sdi1_per2@80118000 {
-                       arm,primecell-periphid = <0x10480180>;
-                       max-frequency = <100000000>;
-                       bus-width = <4>;
-
-                       status = "okay";
-               };
-
-               // On-board eMMC
-               sdi4_per2@80114000 {
-                       arm,primecell-periphid = <0x10480180>;
-                       max-frequency = <100000000>;
-                       bus-width = <8>;
-                       cap-mmc-highspeed;
-                       vmmc-supply = <&ab8500_ldo_aux2_reg>;
-
-                       status = "okay";
-               };
-       };
-};
index ade1d0d4e5f45c595f079c251c8b93dbe95742df..b0b94d05309855f4816a05295cbeb19251bc89e5 100644 (file)
@@ -46,35 +46,35 @@ gpio_keys {
                #size-cells = <0>;
 
                button@1 {
-                       debounce_interval = <50>;
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <2>;
                        label = "userpb";
                        gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
                };
                button@2 {
-                       debounce_interval = <50>;
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <3>;
                        label = "extkb1";
                        gpios = <&gpio4 23 GPIO_ACTIVE_HIGH>;
                };
                button@3 {
-                       debounce_interval = <50>;
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <4>;
                        label = "extkb2";
                        gpios = <&gpio4 24 GPIO_ACTIVE_HIGH>;
                };
                button@4 {
-                       debounce_interval = <50>;
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <5>;
                        label = "extkb3";
                        gpios = <&gpio5 1 GPIO_ACTIVE_HIGH>;
                };
                button@5 {
-                       debounce_interval = <50>;
+                       debounce-interval = <50>;
                        wakeup-source;
                        linux,code = <6>;
                        label = "extkb4";
index f7362c31de29a2ad0f75341bf69c0f8dae69261f..9e29a4499938519f8ea89f77f50ecbdc972d5e45 100644 (file)
@@ -206,19 +206,19 @@ irq-syscfg@0 {
                vtg_main: sti-vtg-main@8d02800 {
                        compatible = "st,vtg";
                        reg = <0x8d02800 0x200>;
-                       interrupts = <GIC_SPI 108 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
                };
 
                vtg_aux: sti-vtg-aux@8d00200 {
                        compatible = "st,vtg";
                        reg = <0x8d00200 0x100>;
-                       interrupts = <GIC_SPI 109 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>;
                };
 
                serial@9830000 {
                        compatible = "st,asc";
                        reg = <0x9830000 0x2c>;
-                       interrupts = <GIC_SPI 122 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&clk_s_c0_flexgen CLK_EXT2F_A9>;
                        /* Pinctrl moved out to a per-board configuration */
 
@@ -228,7 +228,7 @@ serial@9830000 {
                serial@9831000 {
                        compatible = "st,asc";
                        reg = <0x9831000 0x2c>;
-                       interrupts = <GIC_SPI 123 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_serial1>;
                        clocks = <&clk_s_c0_flexgen CLK_EXT2F_A9>;
@@ -239,7 +239,7 @@ serial@9831000 {
                serial@9832000 {
                        compatible = "st,asc";
                        reg = <0x9832000 0x2c>;
-                       interrupts = <GIC_SPI 124 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 124 IRQ_TYPE_LEVEL_HIGH>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_serial2>;
                        clocks = <&clk_s_c0_flexgen CLK_EXT2F_A9>;
@@ -251,7 +251,7 @@ serial@9832000 {
                sbc_serial0: serial@9530000 {
                        compatible = "st,asc";
                        reg = <0x9530000 0x2c>;
-                       interrupts = <GIC_SPI 138 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 138 IRQ_TYPE_LEVEL_HIGH>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_sbc_serial0>;
                        clocks = <&clk_sysin>;
@@ -262,7 +262,7 @@ sbc_serial0: serial@9530000 {
                serial@9531000 {
                        compatible = "st,asc";
                        reg = <0x9531000 0x2c>;
-                       interrupts = <GIC_SPI 139 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 139 IRQ_TYPE_LEVEL_HIGH>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_sbc_serial1>;
                        clocks = <&clk_sysin>;
@@ -574,7 +574,7 @@ mmc0: sdhci@9060000 {
                        status = "disabled";
                        reg = <0x09060000 0x7ff>, <0x9061008 0x20>;
                        reg-names = "mmc", "top-mmc-delay";
-                       interrupts = <GIC_SPI 92 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "mmcirq";
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_mmc0>;
@@ -589,7 +589,7 @@ mmc1: sdhci@9080000 {
                        status = "disabled";
                        reg = <0x09080000 0x7ff>;
                        reg-names = "mmc";
-                       interrupts = <GIC_SPI 90 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "mmcirq";
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_sd1>;
@@ -623,7 +623,7 @@ sata0: sata@9b20000 {
                        compatible = "st,ahci";
                        reg = <0x9b20000 0x1000>;
 
-                       interrupts = <GIC_SPI 159 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "hostc";
 
                        phys = <&phy_port0 PHY_TYPE_SATA>;
@@ -646,7 +646,7 @@ sata1: sata@9b28000 {
                        compatible = "st,ahci";
                        reg = <0x9b28000 0x1000>;
 
-                       interrupts = <GIC_SPI 170 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 170 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "hostc";
 
                        phys = <&phy_port1 PHY_TYPE_SATA>;
@@ -687,7 +687,7 @@ st_dwc3: dwc3@8f94000 {
                        dwc3: dwc3@9900000 {
                                compatible      = "snps,dwc3";
                                reg             = <0x09900000 0x100000>;
-                               interrupts      = <GIC_SPI 155 IRQ_TYPE_NONE>;
+                               interrupts      = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>;
                                dr_mode         = "host";
                                phy-names       = "usb2-phy", "usb3-phy";
                                phys            = <&usb2_picophy0>,
@@ -701,7 +701,7 @@ pwm0: pwm@9810000 {
                        compatible      = "st,sti-pwm";
                        #pwm-cells      = <2>;
                        reg             = <0x9810000 0x68>;
-                       interrupts      = <GIC_SPI 128 IRQ_TYPE_NONE>;
+                       interrupts      = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
                        pinctrl-names   = "default";
                        pinctrl-0       = <&pinctrl_pwm0_chan0_default>;
                        clock-names     = "pwm";
@@ -716,7 +716,7 @@ pwm1: pwm@9510000 {
                        compatible      = "st,sti-pwm";
                        #pwm-cells      = <2>;
                        reg             = <0x9510000 0x68>;
-                       interrupts      = <GIC_SPI 131 IRQ_TYPE_NONE>;
+                       interrupts      = <GIC_SPI 131 IRQ_TYPE_LEVEL_HIGH>;
                        pinctrl-names   = "default";
                        pinctrl-0       = <&pinctrl_pwm1_chan0_default
                                        &pinctrl_pwm1_chan1_default
@@ -755,8 +755,8 @@ ethernet0: dwmac@9630000 {
                        resets = <&softreset STIH407_ETH1_SOFTRESET>;
                        reset-names = "stmmaceth";
 
-                       interrupts = <GIC_SPI 98 IRQ_TYPE_NONE>,
-                                    <GIC_SPI 99 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "macirq", "eth_wake_irq";
 
                        /* DMA Bus Mode */
@@ -787,7 +787,7 @@ rng11: rng@8a8a000 {
                mailbox0: mailbox@8f00000  {
                        compatible      = "st,stih407-mailbox";
                        reg             = <0x8f00000 0x1000>;
-                       interrupts      = <GIC_SPI 1 IRQ_TYPE_NONE>;
+                       interrupts      = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
                        #mbox-cells     = <2>;
                        mbox-name       = "a9";
                        status          = "okay";
@@ -857,7 +857,7 @@ fdma0: dma-controller@8e20000 {
                                 <&clk_s_c0_flexgen CLK_EXT2F_A9>,
                                 <&clk_s_c0_flexgen CLK_EXT2F_A9>,
                                 <&clk_s_c0_flexgen CLK_EXT2F_A9>;
-                       interrupts = <GIC_SPI 5 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
                        dma-channels = <16>;
                        #dma-cells = <3>;
                };
@@ -875,7 +875,7 @@ fdma1: dma-controller@8e40000 {
                                <&clk_s_c0_flexgen CLK_TX_ICN_DMU>,
                                <&clk_s_c0_flexgen CLK_EXT2F_A9>;
 
-                       interrupts = <GIC_SPI 7 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
                        dma-channels = <16>;
                        #dma-cells = <3>;
 
@@ -890,7 +890,7 @@ fdma2: dma-controller@8e60000 {
                              <0x8e77000 0x1000>,
                              <0x8e78000 0x8000>;
                        reg-names = "slimcore", "dmem", "peripherals", "imem";
-                       interrupts = <GIC_SPI 9 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
                        dma-channels = <16>;
                        #dma-cells = <3>;
                        clocks = <&clk_s_c0_flexgen CLK_FDMA>,
@@ -910,7 +910,7 @@ sti_uni_player0: sti-uni-player@8d80000 {
                        assigned-clock-parents = <0>, <&clk_s_d0_quadfs 0>;
                        assigned-clock-rates = <50000000>;
                        reg = <0x8d80000 0x158>;
-                       interrupts = <GIC_SPI 84 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
                        dmas = <&fdma0 2 0 1>;
                        dma-names = "tx";
 
@@ -926,7 +926,7 @@ sti_uni_player1: sti-uni-player@8d81000 {
                        assigned-clock-parents = <0>, <&clk_s_d0_quadfs 1>;
                        assigned-clock-rates = <50000000>;
                        reg = <0x8d81000 0x158>;
-                       interrupts = <GIC_SPI 85 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
                        dmas = <&fdma0 3 0 1>;
                        dma-names = "tx";
 
@@ -942,7 +942,7 @@ sti_uni_player2: sti-uni-player@8d82000 {
                        assigned-clock-parents = <0>, <&clk_s_d0_quadfs 2>;
                        assigned-clock-rates = <50000000>;
                        reg = <0x8d82000 0x158>;
-                       interrupts = <GIC_SPI 86 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>;
                        dmas = <&fdma0 4 0 1>;
                        dma-names = "tx";
 
@@ -958,7 +958,7 @@ sti_uni_player3: sti-uni-player@8d85000 {
                        assigned-clock-parents = <0>, <&clk_s_d0_quadfs 3>;
                        assigned-clock-rates = <50000000>;
                        reg = <0x8d85000 0x158>;
-                       interrupts = <GIC_SPI 89 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
                        dmas = <&fdma0 7 0 1>;
                        dma-names = "tx";
 
@@ -970,7 +970,7 @@ sti_uni_reader0: sti-uni-reader@8d83000 {
                        #sound-dai-cells = <0>;
                        st,syscfg = <&syscfg_core>;
                        reg = <0x8d83000 0x158>;
-                       interrupts = <GIC_SPI 87 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>;
                        dmas = <&fdma0 5 0 1>;
                        dma-names = "rx";
 
@@ -982,7 +982,7 @@ sti_uni_reader1: sti-uni-reader@8d84000 {
                        #sound-dai-cells = <0>;
                        st,syscfg = <&syscfg_core>;
                        reg = <0x8d84000 0x158>;
-                       interrupts = <GIC_SPI 88 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>;
                        dmas = <&fdma0 6 0 1>;
                        dma-names = "rx";
 
index 53c6888d1fc0ece2a063f270c097eadb9a0998af..e393519fb84cb96227d8d386c2e52dbf18a02d3e 100644 (file)
@@ -52,7 +52,7 @@ pin-controller-sbc@961f080 {
                        st,syscfg = <&syscfg_sbc>;
                        reg = <0x0961f080 0x4>;
                        reg-names = "irqmux";
-                       interrupts = <GIC_SPI 188 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "irqmux";
                        ranges = <0 0x09610000 0x6000>;
 
@@ -376,7 +376,7 @@ pin-controller-front0@920f080 {
                        st,syscfg = <&syscfg_front>;
                        reg = <0x0920f080 0x4>;
                        reg-names = "irqmux";
-                       interrupts = <GIC_SPI 189 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "irqmux";
                        ranges = <0 0x09200000 0x10000>;
 
@@ -936,7 +936,7 @@ pin-controller-front1@921f080 {
                        st,syscfg = <&syscfg_front>;
                        reg = <0x0921f080 0x4>;
                        reg-names = "irqmux";
-                       interrupts = <GIC_SPI 190 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "irqmux";
                        ranges = <0 0x09210000 0x10000>;
 
@@ -969,7 +969,7 @@ pin-controller-rear@922f080 {
                        st,syscfg = <&syscfg_rear>;
                        reg = <0x0922f080 0x4>;
                        reg-names = "irqmux";
-                       interrupts = <GIC_SPI 191 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "irqmux";
                        ranges = <0 0x09220000 0x6000>;
 
@@ -1164,7 +1164,7 @@ pin-controller-flash@923f080 {
                        st,syscfg = <&syscfg_flash>;
                        reg = <0x0923f080 0x4>;
                        reg-names = "irqmux";
-                       interrupts = <GIC_SPI 192 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "irqmux";
                        ranges = <0 0x09230000 0x3000>;
 
index 57efc87dec2b095927a2660213d751c072b70cdc..5b7951ffc350d7f42bdcef9191862d11217bc2d2 100644 (file)
@@ -108,7 +108,7 @@ sti_hdmi: sti-hdmi@8d04000 {
                                reg = <0x8d04000 0x1000>;
                                reg-names = "hdmi-reg";
                                #sound-dai-cells = <0>;
-                               interrupts = <GIC_SPI 106 IRQ_TYPE_NONE>;
+                               interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
                                interrupt-names = "irq";
                                clock-names = "pix",
                                              "tmds",
index 3313005ee15ce8a7e00cb7df13638205f3aef63e..888548ea9b5cc982e3025706bc98ec80f8ff7cb3 100644 (file)
@@ -43,7 +43,7 @@ usb2_picophy2: phy3@0 {
                ohci0: usb@9a03c00 {
                        compatible = "st,st-ohci-300x";
                        reg = <0x9a03c00 0x100>;
-                       interrupts = <GIC_SPI 180 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 180 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>,
                                 <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>;
                        resets = <&powerdown STIH407_USB2_PORT0_POWERDOWN>,
@@ -58,7 +58,7 @@ ohci0: usb@9a03c00 {
                ehci0: usb@9a03e00 {
                        compatible = "st,st-ehci-300x";
                        reg = <0x9a03e00 0x100>;
-                       interrupts = <GIC_SPI 151 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 151 IRQ_TYPE_LEVEL_HIGH>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_usb0>;
                        clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>,
@@ -75,7 +75,7 @@ ehci0: usb@9a03e00 {
                ohci1: usb@9a83c00 {
                        compatible = "st,st-ohci-300x";
                        reg = <0x9a83c00 0x100>;
-                       interrupts = <GIC_SPI 181 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 181 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>,
                                 <&clk_s_c0_flexgen CLK_RX_ICN_DISP_0>;
                        resets = <&powerdown STIH407_USB2_PORT1_POWERDOWN>,
@@ -90,7 +90,7 @@ ohci1: usb@9a83c00 {
                ehci1: usb@9a83e00 {
                        compatible = "st,st-ehci-300x";
                        reg = <0x9a83e00 0x100>;
-                       interrupts = <GIC_SPI 153 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_usb1>;
                        clocks = <&clk_s_c0_flexgen CLK_TX_ICN_DISP_0>,
@@ -202,7 +202,7 @@ sti_hdmi: sti-hdmi@8d04000 {
                                reg = <0x8d04000 0x1000>;
                                reg-names = "hdmi-reg";
                                #sound-dai-cells = <0>;
-                               interrupts = <GIC_SPI 106 IRQ_TYPE_NONE>;
+                               interrupts = <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>;
                                interrupt-names = "irq";
                                clock-names = "pix",
                                              "tmds",
@@ -254,7 +254,7 @@ sti-hqvdp@9c00000 {
                bdisp0:bdisp@9f10000 {
                        compatible = "st,stih407-bdisp";
                        reg = <0x9f10000 0x1000>;
-                       interrupts = <GIC_SPI 38 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
                        clock-names = "bdisp";
                        clocks = <&clk_s_c0_flexgen CLK_IC_BDISP_0>;
                };
@@ -263,8 +263,8 @@ hva@8c85000 {
                        compatible = "st,st-hva";
                        reg = <0x8c85000 0x400>, <0x6000000 0x40000>;
                        reg-names = "hva_registers", "hva_esram";
-                       interrupts = <GIC_SPI 58 IRQ_TYPE_NONE>,
-                                    <GIC_SPI 59 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>;
                        clock-names = "clk_hva";
                        clocks = <&clk_s_c0_flexgen CLK_HVA>;
                };
@@ -292,7 +292,7 @@ sti-cec@94a087c {
                        reg = <0x94a087c 0x64>;
                        clocks = <&clk_sysin>;
                        clock-names = "cec-clk";
-                       interrupts = <GIC_SPI 140 IRQ_TYPE_NONE>;
+                       interrupts = <GIC_SPI 140 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "cec-irq";
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_cec0_default>;
index c67edb1a812113e83ff8002bbc7b232de2480cbd..4dedfcb0fcb304c4968b82f815df31892e63f23a 100644 (file)
@@ -154,8 +154,8 @@ demux@8a20000 {
                        reg             = <0x08a20000 0x10000>,
                                          <0x08a00000 0x4000>;
                        reg-names       = "c8sectpfe", "c8sectpfe-ram";
-                       interrupts      = <GIC_SPI 34 IRQ_TYPE_NONE>,
-                                         <GIC_SPI 35 IRQ_TYPE_NONE>;
+                       interrupts      = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>,
+                                         <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "c8sectpfe-error-irq",
                                          "c8sectpfe-idle-irq";
                        pinctrl-0       = <&pinctrl_tsin0_serial>;
index 2f76726bf335b4aee8654083fd47893b29cfd9af..3ee768cb86fc96acf9f1e6a214e1348ead71395c 100644 (file)
@@ -46,7 +46,7 @@
  */
 
 /dts-v1/;
-#include "stm32f429.dtsi"
+#include "stm32f469.dtsi"
 #include "stm32f469-pinctrl.dtsi"
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/input/input.h>
@@ -112,7 +112,7 @@ button@0 {
        vcc5v_otg: vcc5v-otg-regulator {
                compatible = "regulator-fixed";
                enable-active-high;
-               gpio = <&gpiob 2 0>;
+               gpio = <&gpiob 2 GPIO_ACTIVE_HIGH>;
                regulator-name = "vcc5_host1";
                regulator-always-on;
        };
@@ -126,6 +126,55 @@ &clk_hse {
        clock-frequency = <8000000>;
 };
 
+&dsi {
+       #address-cells = <1>;
+       #size-cells = <0>;
+       status = "okay";
+
+       ports {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               port@0 {
+                       reg = <0>;
+                       dsi_in: endpoint {
+                               remote-endpoint = <&ltdc_out_dsi>;
+                       };
+               };
+
+               port@1 {
+                       reg = <1>;
+                       dsi_out: endpoint {
+                               remote-endpoint = <&dsi_panel_in>;
+                       };
+               };
+       };
+
+       panel-dsi@0 {
+               compatible = "orisetech,otm8009a";
+               reg = <0>; /* dsi virtual channel (0..3) */
+               reset-gpios = <&gpioh 7 GPIO_ACTIVE_LOW>;
+               status = "okay";
+
+               port {
+                       dsi_panel_in: endpoint {
+                               remote-endpoint = <&dsi_out>;
+                       };
+               };
+       };
+};
+
+&ltdc {
+       dma-ranges;
+       status = "okay";
+
+       port {
+               ltdc_out_dsi: endpoint@0 {
+                       remote-endpoint = <&dsi_in>;
+               };
+       };
+};
+
 &rtc {
        status = "okay";
 };
diff --git a/arch/arm/boot/dts/stm32f469.dtsi b/arch/arm/boot/dts/stm32f469.dtsi
new file mode 100644 (file)
index 0000000..5ae5213
--- /dev/null
@@ -0,0 +1,19 @@
+/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
+/* Copyright (C) STMicroelectronics 2017 - All Rights Reserved */
+
+#include "stm32f429.dtsi"
+
+/ {
+       soc {
+               dsi: dsi@40016c00 {
+                       compatible = "st,stm32-dsi";
+                       reg = <0x40016c00 0x800>;
+                       interrupts = <92>;
+                       resets = <&rcc STM32F4_APB2_RESET(DSI)>;
+                       reset-names = "apb";
+                       clocks = <&rcc 1 CLK_F469_DSI>, <&clk_hse>;
+                       clock-names = "pclk", "ref";
+                       status = "disabled";
+               };
+       };
+};
index be94c6ad7e94a5523476ddf50db0c47ea23b47c7..f9ad71f7c807ce365cc5501e4fdafd4f8476a30f 100644 (file)
@@ -90,6 +90,14 @@ &clk_hse {
        clock-frequency = <25000000>;
 };
 
+&i2c1 {
+       pinctrl-0 = <&i2c1_pins_b>;
+       pinctrl-names = "default";
+       i2c-scl-rising-time-ns = <185>;
+       i2c-scl-falling-time-ns = <20>;
+       status = "okay";
+};
+
 &sdio1 {
        status = "okay";
        vmmc-supply = <&mmc_vcard>;
index 4be2ee575b19c305a0015ae7e9c9f79254bda5ca..1479e3eb05fa455d88dbbbc2c25dc6cc1961ea10 100644 (file)
@@ -345,6 +345,42 @@ i2c1: i2c@40005400 {
                        status = "disabled";
                };
 
+               i2c2: i2c@40005800 {
+                       compatible = "st,stm32f7-i2c";
+                       reg = <0x40005800 0x400>;
+                       interrupts = <33>,
+                                    <34>;
+                       resets = <&rcc STM32F7_APB1_RESET(I2C2)>;
+                       clocks = <&rcc 1 CLK_I2C2>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               i2c3: i2c@40005C00 {
+                       compatible = "st,stm32f7-i2c";
+                       reg = <0x40005C00 0x400>;
+                       interrupts = <72>,
+                                    <73>;
+                       resets = <&rcc STM32F7_APB1_RESET(I2C3)>;
+                       clocks = <&rcc 1 CLK_I2C3>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               i2c4: i2c@40006000 {
+                       compatible = "st,stm32f7-i2c";
+                       reg = <0x40006000 0x400>;
+                       interrupts = <95>,
+                                    <96>;
+                       resets = <&rcc STM32F7_APB1_RESET(I2C4)>;
+                       clocks = <&rcc 1 CLK_I2C4>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
                cec: cec@40006c00 {
                        compatible = "st,stm32-cec";
                        reg = <0x40006C00 0x400>;
index 2241eecdabfe540a7309557a2e510d4839ec20c2..677276ba4dbe8f5c07f67ed493c839ed4f94f96b 100644 (file)
@@ -111,6 +111,14 @@ &clk_hse {
        clock-frequency = <25000000>;
 };
 
+&i2c1 {
+       pinctrl-0 = <&i2c1_pins_b>;
+       pinctrl-names = "default";
+       i2c-scl-rising-time-ns = <185>;
+       i2c-scl-falling-time-ns = <20>;
+       status = "okay";
+};
+
 &rtc {
        status = "okay";
 };
index 0f15dfb98381d8ce9d957e4fa838a6bcdd0e98ab..24be8e63dec88b17889e07dddacece113d1e5d78 100644 (file)
@@ -163,6 +163,16 @@ gpiok: gpio@58022800 {
                                #interrupt-cells = <2>;
                        };
 
+                       i2c1_pins_a: i2c1@0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('B', 6, AF4)>, /* I2C1_SCL */
+                                                <STM32_PINMUX('B', 7, AF4)>; /* I2C1_SDA */
+                                       bias-disable;
+                                       drive-open-drain;
+                                       slew-rate = <0>;
+                               };
+                       };
+
                        usart1_pins: usart1@0 {
                                pins1 {
                                        pinmux = <STM32_PINMUX('B', 14, AF4)>; /* USART1_TX */
index 2bb103e1194da583fee04506e29eabb390351be9..637beffe506700eb869f03e0089bfe63b3776fe9 100644 (file)
@@ -86,6 +86,7 @@ lptimer1: timer@40002400 {
 
                        pwm {
                                compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
                                status = "disabled";
                        };
 
@@ -130,6 +131,42 @@ usart2: serial@40004400 {
                        clocks = <&rcc USART2_CK>;
                };
 
+               i2c1: i2c@40005400 {
+                       compatible = "st,stm32f7-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x40005400 0x400>;
+                       interrupts = <31>,
+                                    <32>;
+                       resets = <&rcc STM32H7_APB1L_RESET(I2C1)>;
+                       clocks = <&rcc I2C1_CK>;
+                       status = "disabled";
+               };
+
+               i2c2: i2c@40005800 {
+                       compatible = "st,stm32f7-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x40005800 0x400>;
+                       interrupts = <33>,
+                                    <34>;
+                       resets = <&rcc STM32H7_APB1L_RESET(I2C2)>;
+                       clocks = <&rcc I2C2_CK>;
+                       status = "disabled";
+               };
+
+               i2c3: i2c@40005C00 {
+                       compatible = "st,stm32f7-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x40005C00 0x400>;
+                       interrupts = <72>,
+                                    <73>;
+                       resets = <&rcc STM32H7_APB1L_RESET(I2C3)>;
+                       clocks = <&rcc I2C3_CK>;
+                       status = "disabled";
+               };
+
                dac: dac@40007400 {
                        compatible = "st,stm32h7-dac-core";
                        reg = <0x40007400 0x400>;
@@ -323,6 +360,18 @@ spi6: spi@58001400 {
                        status = "disabled";
                };
 
+               i2c4: i2c@58001C00 {
+                       compatible = "st,stm32f7-i2c";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x58001C00 0x400>;
+                       interrupts = <95>,
+                                    <96>;
+                       resets = <&rcc STM32H7_APB4_RESET(I2C4)>;
+                       clocks = <&rcc I2C4_CK>;
+                       status = "disabled";
+               };
+
                lptimer2: timer@58002400 {
                        #address-cells = <1>;
                        #size-cells = <0>;
@@ -334,6 +383,7 @@ lptimer2: timer@58002400 {
 
                        pwm {
                                compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
                                status = "disabled";
                        };
 
@@ -360,6 +410,7 @@ lptimer3: timer@58002800 {
 
                        pwm {
                                compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
                                status = "disabled";
                        };
 
@@ -381,6 +432,7 @@ lptimer4: timer@58002c00 {
 
                        pwm {
                                compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
                                status = "disabled";
                        };
                };
@@ -396,6 +448,7 @@ lptimer5: timer@58003000 {
 
                        pwm {
                                compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
                                status = "disabled";
                        };
                };
index c7187e18ea16986853b8b2776f0d734e05970d6b..3f8e0c4a998d0cec39c592bc8f7688e9327bf12b 100644 (file)
@@ -92,6 +92,14 @@ &clk_hse {
        clock-frequency = <25000000>;
 };
 
+&i2c1 {
+       pinctrl-0 = <&i2c1_pins_a>;
+       pinctrl-names = "default";
+       i2c-scl-rising-time-ns = <185>;
+       i2c-scl-falling-time-ns = <20>;
+       status = "okay";
+};
+
 &rtc {
        status = "okay";
 };
index eb96ac3e6c1d4d409589ccc75a7f8fb5bf0881be..4839db146890fd59480ce7c00b075cf381b7d498 100644 (file)
@@ -7,7 +7,7 @@
 
 / {
        soc {
-               pinctrl: pin-controller {
+               pinctrl: pin-controller@50002000 {
                        #address-cells = <1>;
                        #size-cells = <1>;
                        compatible = "st,stm32mp157-pinctrl";
@@ -22,7 +22,7 @@ gpioa: gpio@50002000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x0 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOA>;
                                st,bank-name = "GPIOA";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 0 16>;
@@ -34,7 +34,7 @@ gpiob: gpio@50003000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x1000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOB>;
                                st,bank-name = "GPIOB";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 16 16>;
@@ -46,7 +46,7 @@ gpioc: gpio@50004000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x2000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOC>;
                                st,bank-name = "GPIOC";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 32 16>;
@@ -58,7 +58,7 @@ gpiod: gpio@50005000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x3000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOD>;
                                st,bank-name = "GPIOD";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 48 16>;
@@ -70,7 +70,7 @@ gpioe: gpio@50006000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x4000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOE>;
                                st,bank-name = "GPIOE";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 64 16>;
@@ -82,7 +82,7 @@ gpiof: gpio@50007000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x5000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOF>;
                                st,bank-name = "GPIOF";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 80 16>;
@@ -94,7 +94,7 @@ gpiog: gpio@50008000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x6000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOG>;
                                st,bank-name = "GPIOG";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 96 16>;
@@ -106,7 +106,7 @@ gpioh: gpio@50009000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x7000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOH>;
                                st,bank-name = "GPIOH";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 112 16>;
@@ -118,7 +118,7 @@ gpioi: gpio@5000a000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x8000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOI>;
                                st,bank-name = "GPIOI";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 128 16>;
@@ -130,7 +130,7 @@ gpioj: gpio@5000b000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0x9000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOJ>;
                                st,bank-name = "GPIOJ";
                                ngpios = <16>;
                                gpio-ranges = <&pinctrl 0 144 16>;
@@ -142,13 +142,124 @@ gpiok: gpio@5000c000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0xa000 0x400>;
-                               clocks = <&clk_pll3_p>;
+                               clocks = <&rcc GPIOK>;
                                st,bank-name = "GPIOK";
                                ngpios = <8>;
                                gpio-ranges = <&pinctrl 0 160 8>;
                        };
 
-                       uart4_pins_a: uart4@0 {
+                       cec_pins_a: cec-0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('A', 15, AF4)>;
+                                       bias-disable;
+                                       drive-open-drain;
+                                       slew-rate = <0>;
+                               };
+                       };
+
+                       i2c1_pins_a: i2c1-0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('D', 12, AF5)>, /* I2C1_SCL */
+                                                <STM32_PINMUX('F', 15, AF5)>; /* I2C1_SDA */
+                                       bias-disable;
+                                       drive-open-drain;
+                                       slew-rate = <0>;
+                               };
+                       };
+
+                       i2c2_pins_a: i2c2-0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('H', 4, AF4)>, /* I2C2_SCL */
+                                                <STM32_PINMUX('H', 5, AF4)>; /* I2C2_SDA */
+                                       bias-disable;
+                                       drive-open-drain;
+                                       slew-rate = <0>;
+                               };
+                       };
+
+                       i2c5_pins_a: i2c5-0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('A', 11, AF4)>, /* I2C5_SCL */
+                                                <STM32_PINMUX('A', 12, AF4)>; /* I2C5_SDA */
+                                       bias-disable;
+                                       drive-open-drain;
+                                       slew-rate = <0>;
+                               };
+                       };
+
+                       pwm2_pins_a: pwm2-0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('A', 3, AF1)>; /* TIM2_CH4 */
+                                       bias-pull-down;
+                                       drive-push-pull;
+                                       slew-rate = <0>;
+                               };
+                       };
+
+                       pwm8_pins_a: pwm8-0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('I', 2, AF3)>; /* TIM8_CH4 */
+                                       bias-pull-down;
+                                       drive-push-pull;
+                                       slew-rate = <0>;
+                               };
+                       };
+
+                       pwm12_pins_a: pwm12-0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('H', 6, AF2)>; /* TIM12_CH1 */
+                                       bias-pull-down;
+                                       drive-push-pull;
+                                       slew-rate = <0>;
+                               };
+                       };
+
+                       qspi_clk_pins_a: qspi-clk-0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('F', 10, AF9)>; /* QSPI_CLK */
+                                       bias-disable;
+                                       drive-push-pull;
+                                       slew-rate = <3>;
+                               };
+                       };
+
+                       qspi_bk1_pins_a: qspi-bk1-0 {
+                               pins1 {
+                                       pinmux = <STM32_PINMUX('F', 8, AF10)>, /* QSPI_BK1_IO0 */
+                                                <STM32_PINMUX('F', 9, AF10)>, /* QSPI_BK1_IO1 */
+                                                <STM32_PINMUX('F', 7, AF9)>, /* QSPI_BK1_IO2 */
+                                                <STM32_PINMUX('F', 6, AF9)>; /* QSPI_BK1_IO3 */
+                                       bias-disable;
+                                       drive-push-pull;
+                                       slew-rate = <3>;
+                               };
+                               pins2 {
+                                       pinmux = <STM32_PINMUX('B', 6, AF10)>; /* QSPI_BK1_NCS */
+                                       bias-pull-up;
+                                       drive-push-pull;
+                                       slew-rate = <3>;
+                               };
+                       };
+
+                       qspi_bk2_pins_a: qspi-bk2-0 {
+                               pins1 {
+                                       pinmux = <STM32_PINMUX('H', 2, AF9)>, /* QSPI_BK2_IO0 */
+                                                <STM32_PINMUX('H', 3, AF9)>, /* QSPI_BK2_IO1 */
+                                                <STM32_PINMUX('G', 10, AF11)>, /* QSPI_BK2_IO2 */
+                                                <STM32_PINMUX('G', 7, AF11)>; /* QSPI_BK2_IO3 */
+                                       bias-disable;
+                                       drive-push-pull;
+                                       slew-rate = <3>;
+                               };
+                               pins2 {
+                                       pinmux = <STM32_PINMUX('C', 0, AF10)>; /* QSPI_BK2_NCS */
+                                       bias-pull-up;
+                                       drive-push-pull;
+                                       slew-rate = <3>;
+                               };
+                       };
+
+                       uart4_pins_a: uart4-0 {
                                pins1 {
                                        pinmux = <STM32_PINMUX('G', 11, AF6)>; /* UART4_TX */
                                        bias-disable;
@@ -162,7 +273,7 @@ pins2 {
                        };
                };
 
-               pinctrl_z: pin-controller-z {
+               pinctrl_z: pin-controller-z@54004000 {
                        #address-cells = <1>;
                        #size-cells = <1>;
                        compatible = "st,stm32mp157-z-pinctrl";
@@ -178,12 +289,22 @@ gpioz: gpio@54004000 {
                                interrupt-controller;
                                #interrupt-cells = <2>;
                                reg = <0 0x400>;
-                               clocks = <&clk_pll2_p>;
+                               clocks = <&rcc GPIOZ>;
                                st,bank-name = "GPIOZ";
                                st,bank-ioport = <11>;
                                ngpios = <8>;
                                gpio-ranges = <&pinctrl_z 0 400 8>;
                        };
+
+                       i2c4_pins_a: i2c4-0 {
+                               pins {
+                                       pinmux = <STM32_PINMUX('Z', 4, AF6)>, /* I2C4_SCL */
+                                                <STM32_PINMUX('Z', 5, AF6)>; /* I2C4_SDA */
+                                       bias-disable;
+                                       drive-open-drain;
+                                       slew-rate = <0>;
+                               };
+                       };
                };
        };
 };
index 9f90337a22e388a7c7257a574eb2bd3e76a4e956..ae336530b59b8ec0970a9baef8eabc76378414d6 100644 (file)
@@ -16,13 +16,56 @@ chosen {
                stdout-path = "serial0:115200n8";
        };
 
-       memory {
+       memory@c0000000 {
                reg = <0xC0000000 0x40000000>;
        };
 
        aliases {
                serial0 = &uart4;
        };
+
+       reg11: reg11 {
+               compatible = "regulator-fixed";
+               regulator-name = "reg11";
+               regulator-min-microvolt = <1100000>;
+               regulator-max-microvolt = <1100000>;
+               regulator-always-on;
+       };
+
+       reg18: reg18 {
+               compatible = "regulator-fixed";
+               regulator-name = "reg18";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               regulator-always-on;
+       };
+
+       vdd_usb: vdd-usb {
+               compatible = "regulator-fixed";
+               regulator-name = "vdd_usb";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-always-on;
+       };
+};
+
+&rng1 {
+       status = "okay";
+};
+
+&timers6 {
+       status = "okay";
+       timer@5 {
+               status = "okay";
+       };
+};
+
+&i2c4 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c4_pins_a>;
+       i2c-scl-rising-time-ns = <185>;
+       i2c-scl-falling-time-ns = <20>;
+       status = "okay";
 };
 
 &uart4 {
@@ -30,3 +73,15 @@ &uart4 {
        pinctrl-0 = <&uart4_pins_a>;
        status = "okay";
 };
+
+&usbphyc_port0 {
+       phy-supply = <&vdd_usb>;
+       vdda1v1-supply = <&reg11>;
+       vdda1v8-supply = <&reg18>;
+};
+
+&usbphyc_port1 {
+       phy-supply = <&vdd_usb>;
+       vdda1v1-supply = <&reg11>;
+       vdda1v8-supply = <&reg18>;
+};
index 57e6dbc52e0936f3f6a3f3ce0111b9d746913e77..9382d80630318dde15d69d0b9fa9e62b65b70594 100644 (file)
@@ -19,3 +19,90 @@ aliases {
                serial0 = &uart4;
        };
 };
+
+&cec {
+       pinctrl-names = "default";
+       pinctrl-0 = <&cec_pins_a>;
+       status = "okay";
+};
+
+&i2c2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c2_pins_a>;
+       i2c-scl-rising-time-ns = <185>;
+       i2c-scl-falling-time-ns = <20>;
+       status = "okay";
+};
+
+&i2c5 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&i2c5_pins_a>;
+       i2c-scl-rising-time-ns = <185>;
+       i2c-scl-falling-time-ns = <20>;
+       status = "okay";
+};
+
+&qspi {
+       pinctrl-names = "default";
+       pinctrl-0 = <&qspi_clk_pins_a &qspi_bk1_pins_a &qspi_bk2_pins_a>;
+       reg = <0x58003000 0x1000>, <0x70000000 0x4000000>;
+       #address-cells = <1>;
+       #size-cells = <0>;
+       status = "okay";
+
+       flash0: mx66l51235l@0 {
+               reg = <0>;
+               spi-rx-bus-width = <4>;
+               spi-max-frequency = <108000000>;
+               #address-cells = <1>;
+               #size-cells = <1>;
+       };
+
+       flash1: mx66l51235l@1 {
+               reg = <1>;
+               spi-rx-bus-width = <4>;
+               spi-max-frequency = <108000000>;
+               #address-cells = <1>;
+               #size-cells = <1>;
+       };
+};
+
+&timers2 {
+       status = "disabled";
+       pwm {
+               pinctrl-0 = <&pwm2_pins_a>;
+               pinctrl-names = "default";
+               status = "okay";
+       };
+       timer@1 {
+               status = "okay";
+       };
+};
+
+&timers8 {
+       status = "disabled";
+       pwm {
+               pinctrl-0 = <&pwm8_pins_a>;
+               pinctrl-names = "default";
+               status = "okay";
+       };
+       timer@7 {
+               status = "okay";
+       };
+};
+
+&timers12 {
+       status = "disabled";
+       pwm {
+               pinctrl-0 = <&pwm12_pins_a>;
+               pinctrl-names = "default";
+               status = "okay";
+       };
+       timer@11 {
+               status = "okay";
+       };
+};
+
+&usbphyc {
+       status = "okay";
+};
index 4fa0df853c8a9dad621073706607410e8ee94f1c..7d17538934538239c7634e7cdde7eb5cd2117971 100644 (file)
@@ -4,6 +4,8 @@
  * Author: Ludovic Barre <ludovic.barre@st.com> for STMicroelectronics.
  */
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/clock/stm32mp1-clks.h>
+#include <dt-bindings/reset/stm32mp1-resets.h>
 
 / {
        #address-cells = <1>;
@@ -71,12 +73,6 @@ clk_hse: clk-hse {
                        clock-frequency = <24000000>;
                };
 
-               clk_pll_per: clk-pll-per {
-                       #clock-cells = <0>;
-                       compatible = "fixed-clock";
-                       clock-frequency = <64000000>;
-               };
-
                clk_hsi: clk-hsi {
                        #clock-cells = <0>;
                        compatible = "fixed-clock";
@@ -100,24 +96,6 @@ clk_csi: clk-csi {
                        compatible = "fixed-clock";
                        clock-frequency = <4000000>;
                };
-
-               clk_pclk1: clk-pclk1 {
-                       #clock-cells = <0>;
-                       compatible = "fixed-clock";
-                       clock-frequency = <86000000>;
-               };
-
-               clk_pll3_p: clk-pll3_p {
-                       #clock-cells = <0>;
-                       compatible = "fixed-clock";
-                       clock-frequency = <172000000>;
-               };
-
-               clk_pll2_p: clk-pll2_p {
-                       #clock-cells = <0>;
-                       compatible = "fixed-clock";
-                       clock-frequency = <264000000>;
-               };
        };
 
        soc {
@@ -127,60 +105,506 @@ soc {
                interrupt-parent = <&intc>;
                ranges;
 
+               timers2: timer@40000000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x40000000 0x400>;
+                       clocks = <&rcc TIM2_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@1 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <1>;
+                               status = "disabled";
+                       };
+               };
+
+               timers3: timer@40001000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x40001000 0x400>;
+                       clocks = <&rcc TIM3_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@2 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <2>;
+                               status = "disabled";
+                       };
+               };
+
+               timers4: timer@40002000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x40002000 0x400>;
+                       clocks = <&rcc TIM4_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@3 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <3>;
+                               status = "disabled";
+                       };
+               };
+
+               timers5: timer@40003000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x40003000 0x400>;
+                       clocks = <&rcc TIM5_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@4 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <4>;
+                               status = "disabled";
+                       };
+               };
+
+               timers6: timer@40004000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x40004000 0x400>;
+                       clocks = <&rcc TIM6_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       timer@5 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <5>;
+                               status = "disabled";
+                       };
+               };
+
+               timers7: timer@40005000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x40005000 0x400>;
+                       clocks = <&rcc TIM7_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       timer@6 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <6>;
+                               status = "disabled";
+                       };
+               };
+
+               timers12: timer@40006000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x40006000 0x400>;
+                       clocks = <&rcc TIM12_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@11 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <11>;
+                               status = "disabled";
+                       };
+               };
+
+               timers13: timer@40007000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x40007000 0x400>;
+                       clocks = <&rcc TIM13_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@12 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <12>;
+                               status = "disabled";
+                       };
+               };
+
+               timers14: timer@40008000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x40008000 0x400>;
+                       clocks = <&rcc TIM14_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@13 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <13>;
+                               status = "disabled";
+                       };
+               };
+
+               lptimer1: timer@40009000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-lptimer";
+                       reg = <0x40009000 0x400>;
+                       clocks = <&rcc LPTIM1_K>;
+                       clock-names = "mux";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
+                               status = "disabled";
+                       };
+
+                       trigger@0 {
+                               compatible = "st,stm32-lptimer-trigger";
+                               reg = <0>;
+                               status = "disabled";
+                       };
+
+                       counter {
+                               compatible = "st,stm32-lptimer-counter";
+                               status = "disabled";
+                       };
+               };
+
                usart2: serial@4000e000 {
                        compatible = "st,stm32h7-uart";
                        reg = <0x4000e000 0x400>;
-                       interrupts = <GIC_SPI 38 IRQ_TYPE_NONE>;
-                       clocks = <&clk_pclk1>;
+                       interrupts = <GIC_SPI 38 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc USART2_K>;
                        status = "disabled";
                };
 
                usart3: serial@4000f000 {
                        compatible = "st,stm32h7-uart";
                        reg = <0x4000f000 0x400>;
-                       interrupts = <GIC_SPI 39 IRQ_TYPE_NONE>;
-                       clocks = <&clk_pclk1>;
+                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc USART3_K>;
                        status = "disabled";
                };
 
                uart4: serial@40010000 {
                        compatible = "st,stm32h7-uart";
                        reg = <0x40010000 0x400>;
-                       interrupts = <GIC_SPI 52 IRQ_TYPE_NONE>;
-                       clocks = <&clk_pclk1>;
+                       interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc UART4_K>;
                        status = "disabled";
                };
 
                uart5: serial@40011000 {
                        compatible = "st,stm32h7-uart";
                        reg = <0x40011000 0x400>;
-                       interrupts = <GIC_SPI 53 IRQ_TYPE_NONE>;
-                       clocks = <&clk_pclk1>;
+                       interrupts = <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc UART5_K>;
+                       status = "disabled";
+               };
+
+               i2c1: i2c@40012000 {
+                       compatible = "st,stm32f7-i2c";
+                       reg = <0x40012000 0x400>;
+                       interrupt-names = "event", "error";
+                       interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc I2C1_K>;
+                       resets = <&rcc I2C1_R>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               i2c2: i2c@40013000 {
+                       compatible = "st,stm32f7-i2c";
+                       reg = <0x40013000 0x400>;
+                       interrupt-names = "event", "error";
+                       interrupts = <GIC_SPI 33 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc I2C2_K>;
+                       resets = <&rcc I2C2_R>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               i2c3: i2c@40014000 {
+                       compatible = "st,stm32f7-i2c";
+                       reg = <0x40014000 0x400>;
+                       interrupt-names = "event", "error";
+                       interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc I2C3_K>;
+                       resets = <&rcc I2C3_R>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               i2c5: i2c@40015000 {
+                       compatible = "st,stm32f7-i2c";
+                       reg = <0x40015000 0x400>;
+                       interrupt-names = "event", "error";
+                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc I2C5_K>;
+                       resets = <&rcc I2C5_R>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
                        status = "disabled";
                };
 
+               cec: cec@40016000 {
+                       compatible = "st,stm32-cec";
+                       reg = <0x40016000 0x400>;
+                       interrupts = <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc CEC_K>, <&clk_lse>;
+                       clock-names = "cec", "hdmi-cec";
+                       status = "disabled";
+               };
+
+               dac: dac@40017000 {
+                       compatible = "st,stm32h7-dac-core";
+                       reg = <0x40017000 0x400>;
+                       clocks = <&rcc DAC12>;
+                       clock-names = "pclk";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+
+                       dac1: dac@1 {
+                               compatible = "st,stm32-dac";
+                               #io-channels-cells = <1>;
+                               reg = <1>;
+                               status = "disabled";
+                       };
+
+                       dac2: dac@2 {
+                               compatible = "st,stm32-dac";
+                               #io-channels-cells = <1>;
+                               reg = <2>;
+                               status = "disabled";
+                       };
+               };
+
                uart7: serial@40018000 {
                        compatible = "st,stm32h7-uart";
                        reg = <0x40018000 0x400>;
-                       interrupts = <GIC_SPI 82 IRQ_TYPE_NONE>;
-                       clocks = <&clk_pclk1>;
+                       interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc UART7_K>;
                        status = "disabled";
                };
 
                uart8: serial@40019000 {
                        compatible = "st,stm32h7-uart";
                        reg = <0x40019000 0x400>;
-                       interrupts = <GIC_SPI 83 IRQ_TYPE_NONE>;
-                       clocks = <&clk_pclk1>;
+                       interrupts = <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc UART8_K>;
                        status = "disabled";
                };
 
+               timers1: timer@44000000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x44000000 0x400>;
+                       clocks = <&rcc TIM1_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@0 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <0>;
+                               status = "disabled";
+                       };
+               };
+
+               timers8: timer@44001000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x44001000 0x400>;
+                       clocks = <&rcc TIM8_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@7 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <7>;
+                               status = "disabled";
+                       };
+               };
+
                usart6: serial@44003000 {
                        compatible = "st,stm32h7-uart";
                        reg = <0x44003000 0x400>;
-                       interrupts = <GIC_SPI 71 IRQ_TYPE_NONE>;
-                       clocks = <&clk_pclk1>;
+                       interrupts = <GIC_SPI 71 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc USART6_K>;
+                       status = "disabled";
+               };
+
+               timers15: timer@44006000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x44006000 0x400>;
+                       clocks = <&rcc TIM15_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@14 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <14>;
+                               status = "disabled";
+                       };
+               };
+
+               timers16: timer@44007000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x44007000 0x400>;
+                       clocks = <&rcc TIM16_K>;
+                       clock-names = "int";
                        status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+                       timer@15 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <15>;
+                               status = "disabled";
+                       };
+               };
+
+               timers17: timer@44008000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-timers";
+                       reg = <0x44008000 0x400>;
+                       clocks = <&rcc TIM17_K>;
+                       clock-names = "int";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm";
+                               status = "disabled";
+                       };
+
+                       timer@16 {
+                               compatible = "st,stm32h7-timer-trigger";
+                               reg = <16>;
+                               status = "disabled";
+                       };
+               };
+
+               dma1: dma@48000000 {
+                       compatible = "st,stm32-dma";
+                       reg = <0x48000000 0x400>;
+                       interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc DMA1>;
+                       #dma-cells = <4>;
+                       st,mem2mem;
+                       dma-requests = <8>;
+               };
+
+               dma2: dma@48001000 {
+                       compatible = "st,stm32-dma";
+                       reg = <0x48001000 0x400>;
+                       interrupts = <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 70 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc DMA2>;
+                       #dma-cells = <4>;
+                       st,mem2mem;
+                       dma-requests = <8>;
+               };
+
+               dmamux1: dma-router@48002000 {
+                       compatible = "st,stm32h7-dmamux";
+                       reg = <0x48002000 0x1c>;
+                       #dma-cells = <3>;
+                       dma-requests = <128>;
+                       dma-masters = <&dma1 &dma2>;
+                       dma-channels = <16>;
+                       clocks = <&rcc DMAMUX>;
+               };
+
+               rcc: rcc@50000000 {
+                       compatible = "st,stm32mp1-rcc", "syscon";
+                       reg = <0x50000000 0x1000>;
+                       #clock-cells = <1>;
+                       #reset-cells = <1>;
                };
 
                exti: interrupt-controller@5000d000 {
@@ -190,11 +614,227 @@ exti: interrupt-controller@5000d000 {
                        reg = <0x5000d000 0x400>;
                };
 
+               lptimer2: timer@50021000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-lptimer";
+                       reg = <0x50021000 0x400>;
+                       clocks = <&rcc LPTIM2_K>;
+                       clock-names = "mux";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
+                               status = "disabled";
+                       };
+
+                       trigger@1 {
+                               compatible = "st,stm32-lptimer-trigger";
+                               reg = <1>;
+                               status = "disabled";
+                       };
+
+                       counter {
+                               compatible = "st,stm32-lptimer-counter";
+                               status = "disabled";
+                       };
+               };
+
+               lptimer3: timer@50022000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32-lptimer";
+                       reg = <0x50022000 0x400>;
+                       clocks = <&rcc LPTIM3_K>;
+                       clock-names = "mux";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
+                               status = "disabled";
+                       };
+
+                       trigger@2 {
+                               compatible = "st,stm32-lptimer-trigger";
+                               reg = <2>;
+                               status = "disabled";
+                       };
+               };
+
+               lptimer4: timer@50023000 {
+                       compatible = "st,stm32-lptimer";
+                       reg = <0x50023000 0x400>;
+                       clocks = <&rcc LPTIM4_K>;
+                       clock-names = "mux";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
+                               status = "disabled";
+                       };
+               };
+
+               lptimer5: timer@50024000 {
+                       compatible = "st,stm32-lptimer";
+                       reg = <0x50024000 0x400>;
+                       clocks = <&rcc LPTIM5_K>;
+                       clock-names = "mux";
+                       status = "disabled";
+
+                       pwm {
+                               compatible = "st,stm32-pwm-lp";
+                               #pwm-cells = <3>;
+                               status = "disabled";
+                       };
+               };
+
+               vrefbuf: vrefbuf@50025000 {
+                       compatible = "st,stm32-vrefbuf";
+                       reg = <0x50025000 0x8>;
+                       regulator-min-microvolt = <1500000>;
+                       regulator-max-microvolt = <2500000>;
+                       clocks = <&rcc VREF>;
+                       status = "disabled";
+               };
+
+               cryp1: cryp@54001000 {
+                       compatible = "st,stm32mp1-cryp";
+                       reg = <0x54001000 0x400>;
+                       interrupts = <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc CRYP1>;
+                       resets = <&rcc CRYP1_R>;
+                       status = "disabled";
+               };
+
+               rng1: rng@54003000 {
+                       compatible = "st,stm32-rng";
+                       reg = <0x54003000 0x400>;
+                       clocks = <&rcc RNG1_K>;
+                       resets = <&rcc RNG1_R>;
+                       status = "disabled";
+               };
+
+               mdma1: dma@58000000 {
+                       compatible = "st,stm32h7-mdma";
+                       reg = <0x58000000 0x1000>;
+                       interrupts = <GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc MDMA>;
+                       #dma-cells = <5>;
+                       dma-channels = <32>;
+                       dma-requests = <48>;
+               };
+
+               qspi: qspi@58003000 {
+                       compatible = "st,stm32f469-qspi";
+                       reg = <0x58003000 0x1000>, <0x70000000 0x10000000>;
+                       reg-names = "qspi", "qspi_mm";
+                       interrupts = <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc QSPI_K>;
+                       resets = <&rcc QSPI_R>;
+                       status = "disabled";
+               };
+
+               crc1: crc@58009000 {
+                       compatible = "st,stm32f7-crc";
+                       reg = <0x58009000 0x400>;
+                       clocks = <&rcc CRC1>;
+                       status = "disabled";
+               };
+
+               usbh_ohci: usbh-ohci@5800c000 {
+                       compatible = "generic-ohci";
+                       reg = <0x5800c000 0x1000>;
+                       clocks = <&rcc USBH>;
+                       resets = <&rcc USBH_R>;
+                       interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
+                       status = "disabled";
+               };
+
+               usbh_ehci: usbh-ehci@5800d000 {
+                       compatible = "generic-ehci";
+                       reg = <0x5800d000 0x1000>;
+                       clocks = <&rcc USBH>;
+                       resets = <&rcc USBH_R>;
+                       interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
+                       companion = <&usbh_ohci>;
+                       status = "disabled";
+               };
+
+               dsi: dsi@5a000000 {
+                       compatible = "st,stm32-dsi";
+                       reg = <0x5a000000 0x800>;
+                       clocks = <&rcc DSI_K>, <&clk_hse>, <&rcc DSI_PX>;
+                       clock-names = "pclk", "ref", "px_clk";
+                       resets = <&rcc DSI_R>;
+                       reset-names = "apb";
+                       status = "disabled";
+               };
+
+               ltdc: display-controller@5a001000 {
+                       compatible = "st,stm32-ltdc";
+                       reg = <0x5a001000 0x400>;
+                       interrupts = <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc LTDC_PX>;
+                       clock-names = "lcd";
+                       resets = <&rcc LTDC_R>;
+                       status = "disabled";
+               };
+
+               usbphyc: usbphyc@5a006000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "st,stm32mp1-usbphyc";
+                       reg = <0x5a006000 0x1000>;
+                       clocks = <&rcc USBPHY_K>;
+                       resets = <&rcc USBPHY_R>;
+                       status = "disabled";
+
+                       usbphyc_port0: usb-phy@0 {
+                               #phy-cells = <0>;
+                               reg = <0>;
+                       };
+
+                       usbphyc_port1: usb-phy@1 {
+                               #phy-cells = <1>;
+                               reg = <1>;
+                       };
+               };
+
                usart1: serial@5c000000 {
                        compatible = "st,stm32h7-uart";
                        reg = <0x5c000000 0x400>;
-                       interrupts = <GIC_SPI 37 IRQ_TYPE_NONE>;
-                       clocks = <&clk_pclk1>;
+                       interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc USART1_K>;
+                       status = "disabled";
+               };
+
+               i2c4: i2c@5c002000 {
+                       compatible = "st,stm32f7-i2c";
+                       reg = <0x5c002000 0x400>;
+                       interrupt-names = "event", "error";
+                       interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc I2C4_K>;
+                       resets = <&rcc I2C4_R>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               i2c6: i2c@5c009000 {
+                       compatible = "st,stm32f7-i2c";
+                       reg = <0x5c009000 0x400>;
+                       interrupt-names = "event", "error";
+                       interrupts = <GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&rcc I2C6_K>;
+                       resets = <&rcc I2C6_R>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
                        status = "disabled";
                };
        };
diff --git a/arch/arm/boot/dts/sun7i-a20-olimex-som-evb-emmc.dts b/arch/arm/boot/dts/sun7i-a20-olimex-som-evb-emmc.dts
new file mode 100644 (file)
index 0000000..81ebc97
--- /dev/null
@@ -0,0 +1,37 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Device Tree Source for A20-Olimex-SOM-EVB-eMMC Board
+ *
+ * Copyright (C) 2018 Olimex Ltd.
+ *   Author: Stefan Mavrodiev <stefan@olimex.com>
+ */
+
+/dts-v1/;
+#include "sun7i-a20-olimex-som-evb.dts"
+
+/ {
+
+       model = "Olimex A20-Olimex-SOM-EVB-eMMC";
+       compatible = "olimex,a20-olimex-som-evb-emmc", "allwinner,sun7i-a20";
+
+       mmc2_pwrseq: mmc2_pwrseq {
+               compatible = "mmc-pwrseq-emmc";
+               reset-gpios = <&pio 2 18 GPIO_ACTIVE_LOW>;
+       };
+};
+
+&mmc2 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&mmc2_pins_a>;
+       vmmc-supply = <&reg_vcc3v3>;
+       mmc-pwrseq = <&mmc2_pwrseq>;
+       bus-width = <4>;
+       non-removable;
+       status = "okay";
+
+       emmc: emmc@0 {
+               reg = <0>;
+               compatible = "mmc-card";
+               broken-hpi;
+       };
+};
index eae8e267b9ef25b8603a7ff72e1307e6b99c2f74..3d7b5c848fefe5940aed9e3b68d32f6a28543ade 100644 (file)
@@ -172,8 +172,7 @@ &mmc0 {
        pinctrl-0 = <&mmc0_pins_a>;
        vmmc-supply = <&reg_vcc3v3>;
        bus-width = <4>;
-       cd-gpios = <&pio 7 1 GPIO_ACTIVE_HIGH>;
-       cd-inverted;
+       cd-gpios = <&pio 7 1 GPIO_ACTIVE_LOW>;
        status = "okay";
 };
 
index 971f9be699a7cbe7fe761f3ae671c09335fa337a..44f3cad3de75b44514cb19a4cecb6e86fe9f6417 100644 (file)
@@ -198,6 +198,8 @@ nfc: nand@1c03000 {
                        clock-names = "ahb", "mod";
                        resets = <&ccu RST_BUS_NAND>;
                        reset-names = "ahb";
+                       pinctrl-names = "default";
+                       pinctrl-0 = <&nand_pins &nand_pins_cs0 &nand_pins_rb0>;
                        status = "disabled";
                        #address-cells = <1>;
                        #size-cells = <0>;
@@ -315,6 +317,37 @@ mmc2_8bit_pins: mmc2_8bit {
                                bias-pull-up;
                        };
 
+                       nand_pins: nand-pins {
+                               pins = "PC0", "PC1", "PC2", "PC5",
+                                      "PC8", "PC9", "PC10", "PC11",
+                                      "PC12", "PC13", "PC14", "PC15";
+                               function = "nand0";
+                       };
+
+                       nand_pins_cs0: nand-pins-cs0 {
+                               pins = "PC4";
+                               function = "nand0";
+                               bias-pull-up;
+                       };
+
+                       nand_pins_cs1: nand-pins-cs1 {
+                               pins = "PC3";
+                               function = "nand0";
+                               bias-pull-up;
+                       };
+
+                       nand_pins_rb0: nand-pins-rb0 {
+                               pins = "PC6";
+                               function = "nand0";
+                               bias-pull-up;
+                       };
+
+                       nand_pins_rb1: nand-pins-rb1 {
+                               pins = "PC7";
+                               function = "nand0";
+                               bias-pull-up;
+                       };
+
                        pwm0_pins: pwm0 {
                                pins = "PH0";
                                function = "pwm0";
index a21f2ed07a523a09bed0bf300c22c2b9b76184a8..8d278ee001e97a63b40143393b7d044ac3f7d5cf 100644 (file)
@@ -236,6 +236,11 @@ tcon0_out: port@1 {
                                        #address-cells = <1>;
                                        #size-cells = <0>;
                                        reg = <1>;
+
+                                       tcon0_out_dsi: endpoint@1 {
+                                               reg = <1>;
+                                               remote-endpoint = <&dsi_in_tcon0>;
+                                       };
                                };
                        };
                };
@@ -280,6 +285,45 @@ ths: ths@1c25000 {
                        #io-channel-cells = <0>;
                };
 
+               dsi: dsi@1ca0000 {
+                       compatible = "allwinner,sun6i-a31-mipi-dsi";
+                       reg = <0x01ca0000 0x1000>;
+                       interrupts = <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&ccu CLK_BUS_MIPI_DSI>,
+                                <&ccu CLK_DSI_SCLK>;
+                       clock-names = "bus", "mod";
+                       resets = <&ccu RST_BUS_MIPI_DSI>;
+                       phys = <&dphy>;
+                       phy-names = "dphy";
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@0 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+                                       reg = <0>;
+
+                                       dsi_in_tcon0: endpoint {
+                                               remote-endpoint = <&tcon0_out_dsi>;
+                                       };
+                               };
+                       };
+               };
+
+               dphy: d-phy@1ca1000 {
+                       compatible = "allwinner,sun6i-a31-mipi-dphy";
+                       reg = <0x01ca1000 0x1000>;
+                       clocks = <&ccu CLK_BUS_MIPI_DSI>,
+                                <&ccu CLK_DSI_DPHY>;
+                       clock-names = "bus", "mod";
+                       resets = <&ccu RST_BUS_MIPI_DSI>;
+                       status = "disabled";
+                       #phy-cells = <0>;
+               };
+
                fe0: display-frontend@1e00000 {
                        compatible = "allwinner,sun8i-a33-display-frontend";
                        reg = <0x01e00000 0x20000>;
index 568307639be84905835a9caf44a9873970fdd99d..2be23d600957ce4ed8a99fbf82c84667502a6e2b 100644 (file)
@@ -66,6 +66,8 @@ cpu0: cpu@0 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        operating-points-v2 = <&cpu0_opp_table>;
+                       cci-control-port = <&cci_control0>;
+                       enable-method = "allwinner,sun8i-a83t-smp";
                        reg = <0>;
                };
 
@@ -73,6 +75,8 @@ cpu@1 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        operating-points-v2 = <&cpu0_opp_table>;
+                       cci-control-port = <&cci_control0>;
+                       enable-method = "allwinner,sun8i-a83t-smp";
                        reg = <1>;
                };
 
@@ -80,6 +84,8 @@ cpu@2 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        operating-points-v2 = <&cpu0_opp_table>;
+                       cci-control-port = <&cci_control0>;
+                       enable-method = "allwinner,sun8i-a83t-smp";
                        reg = <2>;
                };
 
@@ -87,6 +93,8 @@ cpu@3 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        operating-points-v2 = <&cpu0_opp_table>;
+                       cci-control-port = <&cci_control0>;
+                       enable-method = "allwinner,sun8i-a83t-smp";
                        reg = <3>;
                };
 
@@ -96,6 +104,8 @@ cpu100: cpu@100 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        operating-points-v2 = <&cpu1_opp_table>;
+                       cci-control-port = <&cci_control1>;
+                       enable-method = "allwinner,sun8i-a83t-smp";
                        reg = <0x100>;
                };
 
@@ -103,6 +113,8 @@ cpu@101 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        operating-points-v2 = <&cpu1_opp_table>;
+                       cci-control-port = <&cci_control1>;
+                       enable-method = "allwinner,sun8i-a83t-smp";
                        reg = <0x101>;
                };
 
@@ -110,6 +122,8 @@ cpu@102 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        operating-points-v2 = <&cpu1_opp_table>;
+                       cci-control-port = <&cci_control1>;
+                       enable-method = "allwinner,sun8i-a83t-smp";
                        reg = <0x102>;
                };
 
@@ -117,6 +131,8 @@ cpu@103 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        operating-points-v2 = <&cpu1_opp_table>;
+                       cci-control-port = <&cci_control1>;
+                       enable-method = "allwinner,sun8i-a83t-smp";
                        reg = <0x103>;
                };
        };
@@ -349,6 +365,44 @@ mixer1_out_tcon1: endpoint {
                        };
                };
 
+               cpucfg@1700000 {
+                       compatible = "allwinner,sun8i-a83t-cpucfg";
+                       reg = <0x01700000 0x400>;
+               };
+
+               cci@1790000 {
+                       compatible = "arm,cci-400";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       reg = <0x01790000 0x10000>;
+                       ranges = <0x0 0x01790000 0x10000>;
+
+                       cci_control0: slave-if@4000 {
+                               compatible = "arm,cci-400-ctrl-if";
+                               interface-type = "ace";
+                               reg = <0x4000 0x1000>;
+                       };
+
+                       cci_control1: slave-if@5000 {
+                               compatible = "arm,cci-400-ctrl-if";
+                               interface-type = "ace";
+                               reg = <0x5000 0x1000>;
+                       };
+
+                       pmu@9000 {
+                               compatible = "arm,cci-400-pmu,r1";
+                               reg = <0x9000 0x5000>;
+                               interrupts = <GIC_SPI 132 IRQ_TYPE_LEVEL_HIGH>,
+                                            <GIC_SPI 133 IRQ_TYPE_LEVEL_HIGH>,
+                                            <GIC_SPI 134 IRQ_TYPE_LEVEL_HIGH>,
+                                            <GIC_SPI 135 IRQ_TYPE_LEVEL_HIGH>,
+                                            <GIC_SPI 151 IRQ_TYPE_LEVEL_HIGH>,
+                                            <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>,
+                                            <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>,
+                                            <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
+                       };
+               };
+
                syscon: syscon@1c00000 {
                        compatible = "allwinner,sun8i-a83t-system-controller",
                                "syscon";
@@ -492,6 +546,11 @@ mmc2: mmc@1c11000 {
                        #size-cells = <0>;
                };
 
+               sid: eeprom@1c14000 {
+                       compatible = "allwinner,sun8i-a83t-sid";
+                       reg = <0x1c14000 0x400>;
+               };
+
                usb_otg: usb@1c19000 {
                        compatible = "allwinner,sun8i-a83t-musb",
                                     "allwinner,sun8i-a33-musb";
@@ -928,6 +987,11 @@ r_ccu: clock@1f01400 {
                        #reset-cells = <1>;
                };
 
+               r_cpucfg@1f01c00 {
+                       compatible = "allwinner,sun8i-a83t-r-cpucfg";
+                       reg = <0x1f01c00 0x400>;
+               };
+
                r_pio: pinctrl@1f02c00 {
                        compatible = "allwinner,sun8i-a83t-r-pinctrl";
                        reg = <0x01f02c00 0x400>;
diff --git a/arch/arm/boot/dts/sun8i-h2-plus-libretech-all-h3-cc.dts b/arch/arm/boot/dts/sun8i-h2-plus-libretech-all-h3-cc.dts
new file mode 100644 (file)
index 0000000..4db0d4b
--- /dev/null
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 Chen-Yu Tsai <wens@csie.org>
+ */
+
+/dts-v1/;
+#include "sun8i-h3.dtsi"
+#include "sunxi-libretech-all-h3-cc.dtsi"
+
+/ {
+       model = "Libre Computer Board ALL-H3-CC H2+";
+       compatible = "libretech,all-h3-cc-h2-plus", "allwinner,sun8i-h2-plus";
+};
index 0bc031fe4c56b5a234f73bafd1919ef81d613f54..84cd9c06122752e226f55b532890fde654ecf4c9 100644 (file)
@@ -89,6 +89,23 @@ reg_vcc_wifi: reg_vcc_wifi {
                gpio = <&pio 0 20 GPIO_ACTIVE_HIGH>;
        };
 
+       reg_vdd_cpux: vdd-cpux-regulator {
+               compatible = "regulator-gpio";
+               regulator-name = "vdd-cpux";
+               regulator-type = "voltage";
+               regulator-boot-on;
+               regulator-always-on;
+               regulator-min-microvolt = <1100000>;
+               regulator-max-microvolt = <1300000>;
+               regulator-ramp-delay = <50>; /* 4ms */
+
+               gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
+               enable-active-high;
+               gpios-states = <1>;
+               states = <1100000 0
+                         1300000 1>;
+       };
+
        wifi_pwrseq: wifi_pwrseq {
                compatible = "mmc-pwrseq-simple";
                reset-gpios = <&r_pio 0 7 GPIO_ACTIVE_LOW>;
@@ -96,6 +113,10 @@ wifi_pwrseq: wifi_pwrseq {
        };
 };
 
+&cpu0 {
+       cpu-supply = <&reg_vdd_cpux>;
+};
+
 &ehci0 {
        status = "okay";
 };
index b20a710da7bc6bf9553051ff4d9c0942f4f732bc..a8b2f0f1c11d6407ef0f5251e6b9ea9d53085f66 100644 (file)
@@ -6,213 +6,9 @@
 
 /dts-v1/;
 #include "sun8i-h3.dtsi"
-
-#include <dt-bindings/gpio/gpio.h>
-#include <dt-bindings/input/input.h>
+#include "sunxi-libretech-all-h3-cc.dtsi"
 
 / {
        model = "Libre Computer Board ALL-H3-CC H3";
        compatible = "libretech,all-h3-cc-h3", "allwinner,sun8i-h3";
-
-       aliases {
-               ethernet0 = &emac;
-               serial0 = &uart0;
-       };
-
-       chosen {
-               stdout-path = "serial0:115200n8";
-       };
-
-       connector {
-               compatible = "hdmi-connector";
-               type = "a";
-
-               port {
-                       hdmi_con_in: endpoint {
-                               remote-endpoint = <&hdmi_out_con>;
-                       };
-               };
-       };
-
-       leds {
-               compatible = "gpio-leds";
-
-               pwr_led {
-                       label = "librecomputer:green:pwr";
-                       gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
-                       default-state = "on";
-               };
-
-               status_led {
-                       label = "librecomputer:blue:status";
-                       gpios = <&pio 0 7 GPIO_ACTIVE_HIGH>; /* PA7 */
-               };
-       };
-
-       gpio_keys {
-               compatible = "gpio-keys";
-
-               power {
-                       label = "power";
-                       linux,code = <KEY_POWER>;
-                       gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
-               };
-       };
-
-       reg_vcc1v2: vcc1v2 {
-               compatible = "regulator-fixed";
-               regulator-name = "vcc1v2";
-               regulator-min-microvolt = <3300000>;
-               regulator-max-microvolt = <3300000>;
-               regulator-always-on;
-               regulator-boot-on;
-               vin-supply = <&reg_vcc5v0>;
-               gpio = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */
-               enable-active-high;
-       };
-
-       reg_vcc3v3: vcc3v3 {
-               compatible = "regulator-fixed";
-               regulator-name = "vcc3v3";
-               regulator-min-microvolt = <3300000>;
-               regulator-max-microvolt = <3300000>;
-               vin-supply = <&reg_vcc5v0>;
-       };
-
-       /* This represents the board's 5V input */
-       reg_vcc5v0: vcc5v0 {
-               compatible = "regulator-fixed";
-               regulator-name = "vcc5v0";
-               regulator-min-microvolt = <5000000>;
-               regulator-max-microvolt = <5000000>;
-       };
-
-       reg_vcc_dram: vcc-dram {
-               compatible = "regulator-fixed";
-               regulator-name = "vcc-dram";
-               regulator-min-microvolt = <1500000>;
-               regulator-max-microvolt = <1500000>;
-               regulator-always-on;
-               regulator-boot-on;
-               vin-supply = <&reg_vcc5v0>;
-               gpio = <&r_pio 0 9 GPIO_ACTIVE_HIGH>; /* PL9 */
-               enable-active-high;
-       };
-
-       reg_vcc_io: vcc-io {
-               compatible = "regulator-fixed";
-               regulator-name = "vcc-io";
-               regulator-min-microvolt = <3300000>;
-               regulator-max-microvolt = <3300000>;
-               regulator-always-on;
-               regulator-boot-on;
-               vin-supply = <&reg_vcc3v3>;
-               gpio = <&r_pio 0 5 GPIO_ACTIVE_LOW>; /* PL5 */
-       };
-
-       reg_vdd_cpux: vdd-cpux {
-               compatible = "regulator-fixed";
-               regulator-name = "vdd-cpux";
-               regulator-min-microvolt = <3300000>;
-               regulator-max-microvolt = <3300000>;
-               regulator-always-on;
-               regulator-boot-on;
-               vin-supply = <&reg_vcc5v0>;
-               gpio = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */
-               enable-active-high;
-       };
-};
-
-&codec {
-       allwinner,audio-routing =
-               "Line Out", "LINEOUT",
-               "MIC1", "Mic",
-               "Mic",  "MBIAS";
-       status = "okay";
-};
-
-&de {
-       status = "okay";
-};
-
-&ehci0 {
-       status = "okay";
-};
-
-&ehci1 {
-       status = "okay";
-};
-
-&ehci2 {
-       status = "okay";
-};
-
-&ehci3 {
-       status = "okay";
-};
-
-&emac {
-       phy-handle = <&int_mii_phy>;
-       phy-mode = "mii";
-       allwinner,leds-active-low;
-       status = "okay";
-};
-
-&hdmi {
-       status = "okay";
-};
-
-&hdmi_out {
-       hdmi_out_con: endpoint {
-               remote-endpoint = <&hdmi_con_in>;
-       };
-};
-
-&ir {
-       pinctrl-names = "default";
-       pinctrl-0 = <&ir_pins_a>;
-       status = "okay";
-};
-
-&mmc0 {
-       vmmc-supply = <&reg_vcc_io>;
-       bus-width = <4>;
-       cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
-       status = "okay";
-};
-
-&ohci0 {
-       status = "okay";
-};
-
-&ohci1 {
-       status = "okay";
-};
-
-&ohci2 {
-       status = "okay";
-};
-
-&ohci3 {
-       status = "okay";
-};
-
-&uart0 {
-       pinctrl-names = "default";
-       pinctrl-0 = <&uart0_pins_a>;
-       status = "okay";
-};
-
-&usb_otg {
-       dr_mode = "host";
-       status = "okay";
-};
-
-&usbphy {
-       /* VBUS on USB ports are always on */
-       usb0_vbus-supply = <&reg_vcc5v0>;
-       usb1_vbus-supply = <&reg_vcc5v0>;
-       usb2_vbus-supply = <&reg_vcc5v0>;
-       usb3_vbus-supply = <&reg_vcc5v0>;
-       status = "okay";
 };
index 232f124ce62c0d241864e719aa17adf10f53f286..245fd658defbc698bf5f77fe96d8e946c37851b3 100644 (file)
@@ -99,6 +99,27 @@ sw4 {
                        gpios = <&r_pio 0 3 GPIO_ACTIVE_LOW>;
                };
        };
+
+       reg_vdd_cpux: vdd-cpux-regulator {
+               compatible = "regulator-gpio";
+               regulator-name = "vdd-cpux";
+               regulator-type = "voltage";
+               regulator-boot-on;
+               regulator-always-on;
+               regulator-min-microvolt = <1100000>;
+               regulator-max-microvolt = <1300000>;
+               regulator-ramp-delay = <50>; /* 4ms */
+
+               gpios = <&r_pio 0 6 GPIO_ACTIVE_HIGH>; /* PL6 */
+               enable-active-high;
+               gpios-states = <0x1>;
+               states = <1100000 0x0
+                         1300000 0x1>;
+       };
+};
+
+&cpu0 {
+       cpu-supply = <&reg_vdd_cpux>;
 };
 
 &de {
index cea4d647ecbf3464dcddce9952d6d844646cf613..46240334128f29bf24e79650d514ad8e1b27c1af 100644 (file)
@@ -113,6 +113,10 @@ &de {
        status = "okay";
 };
 
+&cpu0 {
+       cpu-supply = <&reg_vdd_cpux>;
+};
+
 &ehci0 {
        status = "okay";
 };
@@ -182,6 +186,30 @@ leds_opc: led_pins {
        };
 };
 
+&r_i2c {
+       status = "okay";
+
+       reg_vdd_cpux: regulator@65 {
+               compatible = "silergy,sy8106a";
+               reg = <0x65>;
+               regulator-name = "vdd-cpux";
+               silergy,fixed-microvolt = <1200000>;
+               /*
+                * The datasheet uses 1.1V as the minimum value of VDD-CPUX,
+                * however both the Armbian DVFS table and the official one
+                * have operating points with voltage under 1.1V, and both
+                * DVFS table are known to work properly at the lowest
+                * operating point.
+                *
+                * Use 1.0V as the minimum voltage instead.
+                */
+               regulator-min-microvolt = <1000000>;
+               regulator-max-microvolt = <1300000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+};
+
 &r_pio {
        leds_r_opc: led_pins {
                pins = "PL10";
index 10da8ed7db813df90ec3dbb6043d5724f8493f79..41d57c76f29052c4bb1724810bc0c5c9a50c09b1 100644 (file)
 #include "sunxi-h3-h5.dtsi"
 
 / {
+       cpu0_opp_table: opp_table0 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp@648000000 {
+                       opp-hz = /bits/ 64 <648000000>;
+                       opp-microvolt = <1040000 1040000 1300000>;
+                       clock-latency-ns = <244144>; /* 8 32k periods */
+               };
+
+               opp@816000000 {
+                       opp-hz = /bits/ 64 <816000000>;
+                       opp-microvolt = <1100000 1100000 1300000>;
+                       clock-latency-ns = <244144>; /* 8 32k periods */
+               };
+
+               opp@1008000000 {
+                       opp-hz = /bits/ 64 <1008000000>;
+                       opp-microvolt = <1200000 1200000 1300000>;
+                       clock-latency-ns = <244144>; /* 8 32k periods */
+               };
+       };
+
        cpus {
                #address-cells = <1>;
                #size-cells = <0>;
 
-               cpu@0 {
+               cpu0: cpu@0 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        reg = <0>;
+                       clocks = <&ccu CLK_CPUX>;
+                       clock-names = "cpu";
+                       operating-points-v2 = <&cpu0_opp_table>;
+                       #cooling-cells = <2>;
                };
 
                cpu@1 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        reg = <1>;
+                       operating-points-v2 = <&cpu0_opp_table>;
                };
 
                cpu@2 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        reg = <2>;
+                       operating-points-v2 = <&cpu0_opp_table>;
                };
 
                cpu@3 {
                        compatible = "arm,cortex-a7";
                        device_type = "cpu";
                        reg = <3>;
+                       operating-points-v2 = <&cpu0_opp_table>;
                };
        };
 
diff --git a/arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic.dts b/arch/arm/boot/dts/sun8i-r16-nintendo-nes-classic.dts
new file mode 100644 (file)
index 0000000..fc0658c
--- /dev/null
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0 OR X11
+/* Copyright (c) 2016 FUKAUMI Naoki <naobsd@gmail.com> */
+
+/dts-v1/;
+#include "sun8i-a33.dtsi"
+#include "sunxi-common-regulators.dtsi"
+
+/ {
+       model = "Nintendo NES Classic Edition";
+       compatible = "nintendo,nes-classic", "allwinner,sun8i-r16",
+                    "allwinner,sun8i-a33";
+
+       aliases {
+               serial0 = &uart0;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+};
+
+&uart0 {
+       /*
+        * UART0 is available on two ports: PB and PF, both are accessible.
+        * PF can also be used for the SD card so PB is preferred.
+        */
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart0_pins_a>;
+       status = "okay";
+};
+
+&nfc {
+       status = "okay";
+
+       /* 2Gb Macronix MX30LF2G18AC (3V) */
+       nand@0 {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               reg = <0>;
+               allwinner,rb = <0>;
+               nand-ecc-mode = "hw";
+               nand-ecc-strength = <16>;
+               nand-ecc-step-size = <1024>;
+       };
+};
+
+&usb_otg {
+       status = "okay";
+       dr_mode = "otg";
+};
+
+&usbphy {
+       /* VBUS is always on because it is wired to the power supply */
+       usb1_vbus-supply = <&reg_vcc5v0>;
+       status = "okay";
+};
diff --git a/arch/arm/boot/dts/sun8i-r16-nintendo-super-nes-classic.dts b/arch/arm/boot/dts/sun8i-r16-nintendo-super-nes-classic.dts
new file mode 100644 (file)
index 0000000..80761d7
--- /dev/null
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0 OR X11
+/* Copyright (c) 2018 Miquèl RAYNAL <miquel.raynal@bootlin.com> */
+
+/dts-v1/;
+#include "sun8i-r16-nintendo-nes-classic.dts"
+
+/ {
+       model = "Nintendo SuperNES Classic Edition";
+       compatible = "nintendo,super-nes-classic", "nintendo,nes-classic",
+                    "allwinner,sun8i-r16", "allwinner,sun8i-a33";
+};
index 27d9ccd0ef2f1c140edcaff08e5826cf662c14a3..25fb048c7df2389a5d9ded7f44886efafb36b5d0 100644 (file)
@@ -51,6 +51,7 @@ / {
        compatible = "sinovoip,bpi-m2-ultra", "allwinner,sun8i-r40";
 
        aliases {
+               ethernet0 = &gmac;
                serial0 = &uart0;
        };
 
@@ -101,6 +102,22 @@ &ehci2 {
        status = "okay";
 };
 
+&gmac {
+       pinctrl-names = "default";
+       pinctrl-0 = <&gmac_rgmii_pins>;
+       phy-handle = <&phy1>;
+       phy-mode = "rgmii";
+       phy-supply = <&reg_dc1sw>;
+       status = "okay";
+};
+
+&gmac_mdio {
+       phy1: ethernet-phy@1 {
+               compatible = "ethernet-phy-ieee802.3-c22";
+               reg = <1>;
+       };
+};
+
 &i2c0 {
        status = "okay";
 
@@ -114,6 +131,48 @@ axp22x: pmic@34 {
 
 #include "axp22x.dtsi"
 
+&mmc0 {
+       vmmc-supply = <&reg_dcdc1>;
+       bus-width = <4>;
+       cd-gpios = <&pio 7 13 GPIO_ACTIVE_HIGH>; /* PH13 */
+       cd-inverted;
+       status = "okay";
+};
+
+&mmc1 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&mmc1_pg_pins>;
+       vmmc-supply = <&reg_dldo2>;
+       vqmmc-supply = <&reg_dldo1>;
+       mmc-pwrseq = <&wifi_pwrseq>;
+       bus-width = <4>;
+       non-removable;
+       status = "okay";
+};
+
+&mmc2 {
+       vmmc-supply = <&reg_dcdc1>;
+       vqmmc-supply = <&reg_dcdc1>;
+       bus-width = <8>;
+       non-removable;
+       status = "okay";
+};
+
+&ohci1 {
+       status = "okay";
+};
+
+&ohci2 {
+       status = "okay";
+};
+
+&reg_aldo2 {
+       regulator-always-on;
+       regulator-min-microvolt = <2500000>;
+       regulator-max-microvolt = <2500000>;
+       regulator-name = "vcc-pa";
+};
+
 &reg_aldo3 {
        regulator-always-on;
        regulator-min-microvolt = <2700000>;
@@ -121,6 +180,12 @@ &reg_aldo3 {
        regulator-name = "avcc";
 };
 
+&reg_dc1sw {
+       regulator-min-microvolt = <3000000>;
+       regulator-max-microvolt = <3000000>;
+       regulator-name = "vcc-gmac-phy";
+};
+
 &reg_dcdc1 {
        regulator-always-on;
        regulator-min-microvolt = <3000000>;
@@ -161,40 +226,6 @@ &reg_dldo2 {
        regulator-name = "vcc-wifi";
 };
 
-&mmc0 {
-       vmmc-supply = <&reg_dcdc1>;
-       bus-width = <4>;
-       cd-gpios = <&pio 7 13 GPIO_ACTIVE_LOW>; /* PH13 */
-       status = "okay";
-};
-
-&mmc1 {
-       pinctrl-names = "default";
-       pinctrl-0 = <&mmc1_pg_pins>;
-       vmmc-supply = <&reg_dldo2>;
-       vqmmc-supply = <&reg_dldo1>;
-       mmc-pwrseq = <&wifi_pwrseq>;
-       bus-width = <4>;
-       non-removable;
-       status = "okay";
-};
-
-&mmc2 {
-       vmmc-supply = <&reg_dcdc1>;
-       vqmmc-supply = <&reg_dcdc1>;
-       bus-width = <8>;
-       non-removable;
-       status = "okay";
-};
-
-&ohci1 {
-       status = "okay";
-};
-
-&ohci2 {
-       status = "okay";
-};
-
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_pb_pins>;
index 173dcc1652d2be98db9a34b4c068c22f307c9d59..bd97ca3dc2fa0ca264144af345870cea784deac6 100644 (file)
@@ -265,6 +265,19 @@ pio: pinctrl@1c20800 {
                        #interrupt-cells = <3>;
                        #gpio-cells = <3>;
 
+                       gmac_rgmii_pins: gmac-rgmii-pins {
+                               pins = "PA0", "PA1", "PA2", "PA3",
+                                      "PA4", "PA5", "PA6", "PA7",
+                                      "PA8", "PA10", "PA11", "PA12",
+                                      "PA13", "PA15", "PA16";
+                               function = "gmac";
+                               /*
+                                * data lines in RGMII mode use DDR mode
+                                * and need a higher signal drive strength
+                                */
+                               drive-strength = <40>;
+                       };
+
                        i2c0_pins: i2c0-pins {
                                pins = "PB0", "PB1";
                                function = "i2c0";
@@ -451,6 +464,27 @@ i2c4: i2c@1c2c000 {
                        #size-cells = <0>;
                };
 
+               gmac: ethernet@1c50000 {
+                       compatible = "allwinner,sun8i-r40-gmac";
+                       syscon = <&ccu>;
+                       reg = <0x01c50000 0x10000>;
+                       interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "macirq";
+                       resets = <&ccu RST_BUS_GMAC>;
+                       reset-names = "stmmaceth";
+                       clocks = <&ccu CLK_BUS_GMAC>;
+                       clock-names = "stmmaceth";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+
+                       gmac_mdio: mdio {
+                               compatible = "snps,dwmac-mdio";
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                       };
+               };
+
                gic: interrupt-controller@1c81000 {
                        compatible = "arm,gic-400";
                        reg = <0x01c81000 0x1000>,
index a26d72c3f9b58e7fb635619a123f5894ad515002..35859d8f3267fd2a1d6fa7e716e97094895f3530 100644 (file)
@@ -87,6 +87,11 @@ wifi_pwrseq: wifi_pwrseq {
        };
 };
 
+&ehci1 {
+       /* Terminus Tech FE 1.1s 4-port USB 2.0 hub here */
+       status = "okay";
+};
+
 &i2c0 {
        status = "okay";
 
@@ -170,3 +175,8 @@ &uart0 {
        pinctrl-0 = <&uart0_pb_pins>;
        status = "okay";
 };
+
+&usbphy {
+       usb1_vbus-supply = <&reg_vcc5v0>;
+       status = "okay";
+};
index 1be1a02d6df26b5a963418a50b15a9bea4880004..c3bff1105e5da6169972888fb70327f2ff8e7c81 100644 (file)
@@ -822,6 +822,19 @@ ir: ir@1f02000 {
                        status = "disabled";
                };
 
+               r_i2c: i2c@1f02400 {
+                       compatible = "allwinner,sun6i-a31-i2c";
+                       reg = <0x01f02400 0x400>;
+                       interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>;
+                       pinctrl-names = "default";
+                       pinctrl-0 = <&r_i2c_pins>;
+                       clocks = <&r_ccu CLK_APB0_I2C>;
+                       resets = <&r_ccu RST_APB0_I2C>;
+                       status = "disabled";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+               };
+
                r_pio: pinctrl@1f02c00 {
                        compatible = "allwinner,sun8i-h3-r-pinctrl";
                        reg = <0x01f02c00 0x400>;
@@ -837,6 +850,11 @@ ir_pins_a: ir {
                                pins = "PL11";
                                function = "s_cir_rx";
                        };
+
+                       r_i2c_pins: r-i2c {
+                               pins = "PL0", "PL1";
+                               function = "s_i2c";
+                       };
                };
        };
 };
diff --git a/arch/arm/boot/dts/sunxi-libretech-all-h3-cc.dtsi b/arch/arm/boot/dts/sunxi-libretech-all-h3-cc.dtsi
new file mode 100644 (file)
index 0000000..f7ffdd6
--- /dev/null
@@ -0,0 +1,215 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2017 Chen-Yu Tsai <wens@csie.org>
+ */
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+/ {
+       aliases {
+               ethernet0 = &emac;
+               serial0 = &uart0;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       connector {
+               compatible = "hdmi-connector";
+               type = "a";
+
+               port {
+                       hdmi_con_in: endpoint {
+                               remote-endpoint = <&hdmi_out_con>;
+                       };
+               };
+       };
+
+       leds {
+               compatible = "gpio-leds";
+
+               pwr_led {
+                       label = "librecomputer:green:pwr";
+                       gpios = <&r_pio 0 10 GPIO_ACTIVE_HIGH>; /* PL10 */
+                       default-state = "on";
+               };
+
+               status_led {
+                       label = "librecomputer:blue:status";
+                       gpios = <&pio 0 7 GPIO_ACTIVE_HIGH>; /* PA7 */
+               };
+       };
+
+       gpio_keys {
+               compatible = "gpio-keys";
+
+               power {
+                       label = "power";
+                       linux,code = <KEY_POWER>;
+                       gpios = <&r_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 */
+               };
+       };
+
+       reg_vcc1v2: vcc1v2 {
+               compatible = "regulator-fixed";
+               regulator-name = "vcc1v2";
+               regulator-min-microvolt = <1200000>;
+               regulator-max-microvolt = <1200000>;
+               regulator-always-on;
+               regulator-boot-on;
+               vin-supply = <&reg_vcc5v0>;
+               gpio = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */
+               enable-active-high;
+       };
+
+       reg_vcc3v3: vcc3v3 {
+               compatible = "regulator-fixed";
+               regulator-name = "vcc3v3";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               vin-supply = <&reg_vcc5v0>;
+       };
+
+       /* This represents the board's 5V input */
+       reg_vcc5v0: vcc5v0 {
+               compatible = "regulator-fixed";
+               regulator-name = "vcc5v0";
+               regulator-min-microvolt = <5000000>;
+               regulator-max-microvolt = <5000000>;
+       };
+
+       reg_vcc_dram: vcc-dram {
+               compatible = "regulator-fixed";
+               regulator-name = "vcc-dram";
+               regulator-min-microvolt = <1500000>;
+               regulator-max-microvolt = <1500000>;
+               regulator-always-on;
+               regulator-boot-on;
+               vin-supply = <&reg_vcc5v0>;
+               gpio = <&r_pio 0 9 GPIO_ACTIVE_HIGH>; /* PL9 */
+               enable-active-high;
+       };
+
+       reg_vcc_io: vcc-io {
+               compatible = "regulator-fixed";
+               regulator-name = "vcc-io";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-always-on;
+               regulator-boot-on;
+               vin-supply = <&reg_vcc3v3>;
+               gpio = <&r_pio 0 5 GPIO_ACTIVE_LOW>; /* PL5 */
+       };
+
+       reg_vdd_cpux: vdd-cpux {
+               compatible = "regulator-fixed";
+               regulator-name = "vdd-cpux";
+               regulator-min-microvolt = <1200000>;
+               regulator-max-microvolt = <1200000>;
+               regulator-always-on;
+               regulator-boot-on;
+               vin-supply = <&reg_vcc5v0>;
+               gpio = <&r_pio 0 8 GPIO_ACTIVE_HIGH>; /* PL8 */
+               enable-active-high;
+       };
+};
+
+&codec {
+       allwinner,audio-routing =
+               "Line Out", "LINEOUT",
+               "MIC1", "Mic",
+               "Mic",  "MBIAS";
+       status = "okay";
+};
+
+&cpu0 {
+       cpu-supply = <&reg_vdd_cpux>;
+};
+
+&de {
+       status = "okay";
+};
+
+&ehci0 {
+       status = "okay";
+};
+
+&ehci1 {
+       status = "okay";
+};
+
+&ehci2 {
+       status = "okay";
+};
+
+&ehci3 {
+       status = "okay";
+};
+
+&emac {
+       phy-handle = <&int_mii_phy>;
+       phy-mode = "mii";
+       allwinner,leds-active-low;
+       status = "okay";
+};
+
+&hdmi {
+       status = "okay";
+};
+
+&hdmi_out {
+       hdmi_out_con: endpoint {
+               remote-endpoint = <&hdmi_con_in>;
+       };
+};
+
+&ir {
+       pinctrl-names = "default";
+       pinctrl-0 = <&ir_pins_a>;
+       status = "okay";
+};
+
+&mmc0 {
+       vmmc-supply = <&reg_vcc_io>;
+       bus-width = <4>;
+       cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
+       status = "okay";
+};
+
+&ohci0 {
+       status = "okay";
+};
+
+&ohci1 {
+       status = "okay";
+};
+
+&ohci2 {
+       status = "okay";
+};
+
+&ohci3 {
+       status = "okay";
+};
+
+&uart0 {
+       pinctrl-names = "default";
+       pinctrl-0 = <&uart0_pins_a>;
+       status = "okay";
+};
+
+&usb_otg {
+       dr_mode = "host";
+       status = "okay";
+};
+
+&usbphy {
+       /* VBUS on USB ports are always on */
+       usb0_vbus-supply = <&reg_vcc5v0>;
+       usb1_vbus-supply = <&reg_vcc5v0>;
+       usb2_vbus-supply = <&reg_vcc5v0>;
+       usb3_vbus-supply = <&reg_vcc5v0>;
+       status = "okay";
+};
index 0e4a13295d8aa73fe63b1cb600d1f7fc2acf01cd..84c4358dacac7e7cc71fbdae100f0d04e1af72b6 100644 (file)
@@ -19,6 +19,7 @@ host1x@50000000 {
                clocks = <&tegra_car TEGRA114_CLK_HOST1X>;
                resets = <&tegra_car 28>;
                reset-names = "host1x";
+               iommus = <&mc TEGRA_SWGROUP_HC>;
 
                #address-cells = <1>;
                #size-cells = <1>;
@@ -32,6 +33,8 @@ gr2d@54140000 {
                        clocks = <&tegra_car TEGRA114_CLK_GR2D>;
                        resets = <&tegra_car 21>;
                        reset-names = "2d";
+
+                       iommus = <&mc TEGRA_SWGROUP_G2>;
                };
 
                gr3d@54180000 {
@@ -40,6 +43,8 @@ gr3d@54180000 {
                        clocks = <&tegra_car TEGRA114_CLK_GR3D>;
                        resets = <&tegra_car 24>;
                        reset-names = "3d";
+
+                       iommus = <&mc TEGRA_SWGROUP_NV>;
                };
 
                dc@54200000 {
index bb67edb016c5890b32ad7e9a7690b1e32e008824..3455822350c5984fb483d7e7f5d66708436af3e6 100644 (file)
@@ -1536,15 +1536,15 @@ sdmmc3_clk_lb_out_pee4 { /* NC */
        };
 
        serial@70006040 {
-               compatible = "nvidia,tegra124-hsuart";
+               compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart";
        };
 
        serial@70006200 {
-               compatible = "nvidia,tegra124-hsuart";
+               compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart";
        };
 
        serial@70006300 {
-               compatible = "nvidia,tegra124-hsuart";
+               compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart";
        };
 
        hdmi_ddc: i2c@7000c700 {
index 65a2161b9b8eebb6e64ad11c6b4e88dd25f47fd4..9f960c84ba10ce0c0b2e0ec5e37e067b5cc7ef20 100644 (file)
@@ -1565,15 +1565,15 @@ sdmmc3_clk_lb_out_pee4 { /* NC */
        };
 
        serial@70006040 {
-               compatible = "nvidia,tegra124-hsuart";
+               compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart";
        };
 
        serial@70006200 {
-               compatible = "nvidia,tegra124-hsuart";
+               compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart";
        };
 
        serial@70006300 {
-               compatible = "nvidia,tegra124-hsuart";
+               compatible = "nvidia,tegra124-hsuart", "nvidia,tegra30-hsuart";
        };
 
        hdmi_ddc: i2c@7000c400 {
index a110cf84d85fb9505d9b279a44dac9b58aaeadf8..09087b9c5e26ce2b9989e26ee0f7bae011a5b77c 100644 (file)
@@ -112,6 +112,7 @@ host1x@50000000 {
                clocks = <&tegra_car TEGRA30_CLK_HOST1X>;
                resets = <&tegra_car 28>;
                reset-names = "host1x";
+               iommus = <&mc TEGRA_SWGROUP_HC>;
 
                #address-cells = <1>;
                #size-cells = <1>;
@@ -125,6 +126,8 @@ mpe@54040000 {
                        clocks = <&tegra_car TEGRA30_CLK_MPE>;
                        resets = <&tegra_car 60>;
                        reset-names = "mpe";
+
+                       iommus = <&mc TEGRA_SWGROUP_MPE>;
                };
 
                vi@54080000 {
@@ -134,6 +137,8 @@ vi@54080000 {
                        clocks = <&tegra_car TEGRA30_CLK_VI>;
                        resets = <&tegra_car 20>;
                        reset-names = "vi";
+
+                       iommus = <&mc TEGRA_SWGROUP_VI>;
                };
 
                epp@540c0000 {
@@ -143,6 +148,8 @@ epp@540c0000 {
                        clocks = <&tegra_car TEGRA30_CLK_EPP>;
                        resets = <&tegra_car 19>;
                        reset-names = "epp";
+
+                       iommus = <&mc TEGRA_SWGROUP_EPP>;
                };
 
                isp@54100000 {
@@ -152,6 +159,8 @@ isp@54100000 {
                        clocks = <&tegra_car TEGRA30_CLK_ISP>;
                        resets = <&tegra_car 23>;
                        reset-names = "isp";
+
+                       iommus = <&mc TEGRA_SWGROUP_ISP>;
                };
 
                gr2d@54140000 {
@@ -161,6 +170,8 @@ gr2d@54140000 {
                        clocks = <&tegra_car TEGRA30_CLK_GR2D>;
                        resets = <&tegra_car 21>;
                        reset-names = "2d";
+
+                       iommus = <&mc TEGRA_SWGROUP_G2>;
                };
 
                gr3d@54180000 {
@@ -172,6 +183,9 @@ gr3d@54180000 {
                        resets = <&tegra_car 24>,
                                 <&tegra_car 98>;
                        reset-names = "3d", "3d2";
+
+                       iommus = <&mc TEGRA_SWGROUP_NV>,
+                                <&mc TEGRA_SWGROUP_NV2>;
                };
 
                dc@54200000 {
index 844124bc9c9cfafa0de56aa7c80003ec0649ff24..49539f0352193cb4e1c768e7f13ee6ce5b5215c8 100644 (file)
@@ -286,7 +286,7 @@ usb3: usb@5a810100 {
                        has-transaction-translator;
                };
 
-               soc-glue@5f800000 {
+               soc_glue: soc-glue@5f800000 {
                        compatible = "socionext,uniphier-pro4-soc-glue",
                                     "simple-mfd", "syscon";
                        reg = <0x5f800000 0x2000>;
@@ -371,10 +371,14 @@ eth: ethernet@65000000 {
                        interrupts = <0 66 4>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_ether_rgmii>;
-                       clocks = <&sys_clk 6>;
-                       resets = <&sys_rst 6>;
+                       clock-names = "gio", "ether", "ether-gb", "ether-phy";
+                       clocks = <&sys_clk 12>, <&sys_clk 6>, <&sys_clk 7>,
+                                <&sys_clk 10>;
+                       reset-names = "gio", "ether";
+                       resets = <&sys_rst 12>, <&sys_rst 6>;
                        phy-mode = "rgmii";
                        local-mac-address = [00 00 00 00 00 00];
+                       socionext,syscon-phy-mode = <&soc_glue 0>;
 
                        mdio: mdio {
                                #address-cells = <1>;
index debcbd15c24bfc9db595803d74ee372c5e0cff85..641d96119d4f9e59dcdbe79ef6caf128f8e77735 100644 (file)
@@ -506,10 +506,13 @@ eth: ethernet@65000000 {
                        interrupts = <0 66 4>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_ether_rgmii>;
+                       clock-names = "ether";
                        clocks = <&sys_clk 6>;
+                       reset-names = "ether";
                        resets = <&sys_rst 6>;
                        phy-mode = "rgmii";
                        local-mac-address = [00 00 00 00 00 00];
+                       socionext,syscon-phy-mode = <&soc_glue 0>;
 
                        mdio: mdio {
                                #address-cells = <1>;
index 35714ff6f4677dfd6ee80af87c0db546dc360b85..4488c8fe213aabb750e9e185e9b87fa16b01d351 100644 (file)
  * CHANGES TO vexpress-v2m.dtsi!
  */
 
-       motherboard {
-               model = "V2M-P1";
-               arm,hbi = <0x190>;
-               arm,vexpress,site = <0>;
-               arm,v2m-memory-map = "rs1";
-               compatible = "arm,vexpress,v2m-p1", "simple-bus";
-               #address-cells = <2>; /* SMB chipselect number and offset */
-               #size-cells = <1>;
-               #interrupt-cells = <1>;
-               ranges;
-
-               flash@0,00000000 {
-                       compatible = "arm,vexpress-flash", "cfi-flash";
-                       reg = <0 0x00000000 0x04000000>,
-                             <4 0x00000000 0x04000000>;
-                       bank-width = <4>;
-               };
+/ {
+       smb@8000000 {
+               motherboard {
+                       model = "V2M-P1";
+                       arm,hbi = <0x190>;
+                       arm,vexpress,site = <0>;
+                       arm,v2m-memory-map = "rs1";
+                       compatible = "arm,vexpress,v2m-p1", "simple-bus";
+                       #address-cells = <2>; /* SMB chipselect number and offset */
+                       #size-cells = <1>;
+                       #interrupt-cells = <1>;
+                       ranges;
 
-               psram@1,00000000 {
-                       compatible = "arm,vexpress-psram", "mtd-ram";
-                       reg = <1 0x00000000 0x02000000>;
-                       bank-width = <4>;
-               };
+                       flash@0,00000000 {
+                               compatible = "arm,vexpress-flash", "cfi-flash";
+                               reg = <0 0x00000000 0x04000000>,
+                                     <4 0x00000000 0x04000000>;
+                               bank-width = <4>;
+                       };
 
-               v2m_video_ram: vram@2,00000000 {
-                       compatible = "arm,vexpress-vram";
-                       reg = <2 0x00000000 0x00800000>;
-               };
+                       psram@1,00000000 {
+                               compatible = "arm,vexpress-psram", "mtd-ram";
+                               reg = <1 0x00000000 0x02000000>;
+                               bank-width = <4>;
+                       };
 
-               ethernet@2,02000000 {
-                       compatible = "smsc,lan9118", "smsc,lan9115";
-                       reg = <2 0x02000000 0x10000>;
-                       interrupts = <15>;
-                       phy-mode = "mii";
-                       reg-io-width = <4>;
-                       smsc,irq-active-high;
-                       smsc,irq-push-pull;
-                       vdd33a-supply = <&v2m_fixed_3v3>;
-                       vddvario-supply = <&v2m_fixed_3v3>;
-               };
+                       v2m_video_ram: vram@2,00000000 {
+                               compatible = "arm,vexpress-vram";
+                               reg = <2 0x00000000 0x00800000>;
+                       };
 
-               usb@2,03000000 {
-                       compatible = "nxp,usb-isp1761";
-                       reg = <2 0x03000000 0x20000>;
-                       interrupts = <16>;
-                       port1-otg;
-               };
+                       ethernet@2,02000000 {
+                               compatible = "smsc,lan9118", "smsc,lan9115";
+                               reg = <2 0x02000000 0x10000>;
+                               interrupts = <15>;
+                               phy-mode = "mii";
+                               reg-io-width = <4>;
+                               smsc,irq-active-high;
+                               smsc,irq-push-pull;
+                               vdd33a-supply = <&v2m_fixed_3v3>;
+                               vddvario-supply = <&v2m_fixed_3v3>;
+                       };
 
-               iofpga@3,00000000 {
-                       compatible = "simple-bus";
-                       #address-cells = <1>;
-                       #size-cells = <1>;
-                       ranges = <0 3 0 0x200000>;
+                       usb@2,03000000 {
+                               compatible = "nxp,usb-isp1761";
+                               reg = <2 0x03000000 0x20000>;
+                               interrupts = <16>;
+                               port1-otg;
+                       };
 
-                       v2m_sysreg: sysreg@10000 {
-                               compatible = "arm,vexpress-sysreg";
-                               reg = <0x010000 0x1000>;
+                       iofpga@3,00000000 {
+                               compatible = "simple-bus";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+                               ranges = <0 3 0 0x200000>;
+
+                               v2m_sysreg: sysreg@10000 {
+                                       compatible = "arm,vexpress-sysreg";
+                                       reg = <0x010000 0x1000>;
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+                                       ranges = <0 0x10000 0x1000>;
+
+                                       v2m_led_gpios: gpio@8 {
+                                               compatible = "arm,vexpress-sysreg,sys_led";
+                                               reg = <0x008 4>;
+                                               gpio-controller;
+                                               #gpio-cells = <2>;
+                                       };
 
-                               v2m_led_gpios: sys_led {
-                                       compatible = "arm,vexpress-sysreg,sys_led";
-                                       gpio-controller;
-                                       #gpio-cells = <2>;
-                               };
+                                       v2m_mmc_gpios: gpio@48 {
+                                               compatible = "arm,vexpress-sysreg,sys_mci";
+                                               reg = <0x048 4>;
+                                               gpio-controller;
+                                               #gpio-cells = <2>;
+                                       };
 
-                               v2m_mmc_gpios: sys_mci {
-                                       compatible = "arm,vexpress-sysreg,sys_mci";
-                                       gpio-controller;
-                                       #gpio-cells = <2>;
+                                       v2m_flash_gpios: gpio@4c {
+                                               compatible = "arm,vexpress-sysreg,sys_flash";
+                                               reg = <0x04c 4>;
+                                               gpio-controller;
+                                               #gpio-cells = <2>;
+                                       };
                                };
 
-                               v2m_flash_gpios: sys_flash {
-                                       compatible = "arm,vexpress-sysreg,sys_flash";
-                                       gpio-controller;
-                                       #gpio-cells = <2>;
+                               v2m_sysctl: sysctl@20000 {
+                                       compatible = "arm,sp810", "arm,primecell";
+                                       reg = <0x020000 0x1000>;
+                                       clocks = <&v2m_refclk32khz>, <&v2m_refclk1mhz>, <&smbclk>;
+                                       clock-names = "refclk", "timclk", "apb_pclk";
+                                       #clock-cells = <1>;
+                                       clock-output-names = "timerclken0", "timerclken1", "timerclken2", "timerclken3";
+                                       assigned-clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&v2m_sysctl 3>, <&v2m_sysctl 3>;
+                                       assigned-clock-parents = <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>;
                                };
-                       };
 
-                       v2m_sysctl: sysctl@20000 {
-                               compatible = "arm,sp810", "arm,primecell";
-                               reg = <0x020000 0x1000>;
-                               clocks = <&v2m_refclk32khz>, <&v2m_refclk1mhz>, <&smbclk>;
-                               clock-names = "refclk", "timclk", "apb_pclk";
-                               #clock-cells = <1>;
-                               clock-output-names = "timerclken0", "timerclken1", "timerclken2", "timerclken3";
-                               assigned-clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&v2m_sysctl 3>, <&v2m_sysctl 3>;
-                               assigned-clock-parents = <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>;
-                       };
+                               /* PCI-E I2C bus */
+                               v2m_i2c_pcie: i2c@30000 {
+                                       compatible = "arm,versatile-i2c";
+                                       reg = <0x030000 0x1000>;
 
-                       /* PCI-E I2C bus */
-                       v2m_i2c_pcie: i2c@30000 {
-                               compatible = "arm,versatile-i2c";
-                               reg = <0x030000 0x1000>;
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
 
-                               #address-cells = <1>;
-                               #size-cells = <0>;
+                                       pcie-switch@60 {
+                                               compatible = "idt,89hpes32h8";
+                                               reg = <0x60>;
+                                       };
+                               };
 
-                               pcie-switch@60 {
-                                       compatible = "idt,89hpes32h8";
-                                       reg = <0x60>;
+                               aaci@40000 {
+                                       compatible = "arm,pl041", "arm,primecell";
+                                       reg = <0x040000 0x1000>;
+                                       interrupts = <11>;
+                                       clocks = <&smbclk>;
+                                       clock-names = "apb_pclk";
                                };
-                       };
 
-                       aaci@40000 {
-                               compatible = "arm,pl041", "arm,primecell";
-                               reg = <0x040000 0x1000>;
-                               interrupts = <11>;
-                               clocks = <&smbclk>;
-                               clock-names = "apb_pclk";
-                       };
+                               mmci@50000 {
+                                       compatible = "arm,pl180", "arm,primecell";
+                                       reg = <0x050000 0x1000>;
+                                       interrupts = <9 10>;
+                                       cd-gpios = <&v2m_mmc_gpios 0 0>;
+                                       wp-gpios = <&v2m_mmc_gpios 1 0>;
+                                       max-frequency = <12000000>;
+                                       vmmc-supply = <&v2m_fixed_3v3>;
+                                       clocks = <&v2m_clk24mhz>, <&smbclk>;
+                                       clock-names = "mclk", "apb_pclk";
+                               };
 
-                       mmci@50000 {
-                               compatible = "arm,pl180", "arm,primecell";
-                               reg = <0x050000 0x1000>;
-                               interrupts = <9 10>;
-                               cd-gpios = <&v2m_mmc_gpios 0 0>;
-                               wp-gpios = <&v2m_mmc_gpios 1 0>;
-                               max-frequency = <12000000>;
-                               vmmc-supply = <&v2m_fixed_3v3>;
-                               clocks = <&v2m_clk24mhz>, <&smbclk>;
-                               clock-names = "mclk", "apb_pclk";
-                       };
+                               kmi@60000 {
+                                       compatible = "arm,pl050", "arm,primecell";
+                                       reg = <0x060000 0x1000>;
+                                       interrupts = <12>;
+                                       clocks = <&v2m_clk24mhz>, <&smbclk>;
+                                       clock-names = "KMIREFCLK", "apb_pclk";
+                               };
 
-                       kmi@60000 {
-                               compatible = "arm,pl050", "arm,primecell";
-                               reg = <0x060000 0x1000>;
-                               interrupts = <12>;
-                               clocks = <&v2m_clk24mhz>, <&smbclk>;
-                               clock-names = "KMIREFCLK", "apb_pclk";
-                       };
+                               kmi@70000 {
+                                       compatible = "arm,pl050", "arm,primecell";
+                                       reg = <0x070000 0x1000>;
+                                       interrupts = <13>;
+                                       clocks = <&v2m_clk24mhz>, <&smbclk>;
+                                       clock-names = "KMIREFCLK", "apb_pclk";
+                               };
 
-                       kmi@70000 {
-                               compatible = "arm,pl050", "arm,primecell";
-                               reg = <0x070000 0x1000>;
-                               interrupts = <13>;
-                               clocks = <&v2m_clk24mhz>, <&smbclk>;
-                               clock-names = "KMIREFCLK", "apb_pclk";
-                       };
+                               v2m_serial0: uart@90000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x090000 0x1000>;
+                                       interrupts = <5>;
+                                       clocks = <&v2m_oscclk2>, <&smbclk>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       v2m_serial0: uart@90000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x090000 0x1000>;
-                               interrupts = <5>;
-                               clocks = <&v2m_oscclk2>, <&smbclk>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               v2m_serial1: uart@a0000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x0a0000 0x1000>;
+                                       interrupts = <6>;
+                                       clocks = <&v2m_oscclk2>, <&smbclk>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       v2m_serial1: uart@a0000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x0a0000 0x1000>;
-                               interrupts = <6>;
-                               clocks = <&v2m_oscclk2>, <&smbclk>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               v2m_serial2: uart@b0000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x0b0000 0x1000>;
+                                       interrupts = <7>;
+                                       clocks = <&v2m_oscclk2>, <&smbclk>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       v2m_serial2: uart@b0000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x0b0000 0x1000>;
-                               interrupts = <7>;
-                               clocks = <&v2m_oscclk2>, <&smbclk>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               v2m_serial3: uart@c0000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x0c0000 0x1000>;
+                                       interrupts = <8>;
+                                       clocks = <&v2m_oscclk2>, <&smbclk>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       v2m_serial3: uart@c0000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x0c0000 0x1000>;
-                               interrupts = <8>;
-                               clocks = <&v2m_oscclk2>, <&smbclk>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               wdt@f0000 {
+                                       compatible = "arm,sp805", "arm,primecell";
+                                       reg = <0x0f0000 0x1000>;
+                                       interrupts = <0>;
+                                       clocks = <&v2m_refclk32khz>, <&smbclk>;
+                                       clock-names = "wdogclk", "apb_pclk";
+                               };
 
-                       wdt@f0000 {
-                               compatible = "arm,sp805", "arm,primecell";
-                               reg = <0x0f0000 0x1000>;
-                               interrupts = <0>;
-                               clocks = <&v2m_refclk32khz>, <&smbclk>;
-                               clock-names = "wdogclk", "apb_pclk";
-                       };
+                               v2m_timer01: timer@110000 {
+                                       compatible = "arm,sp804", "arm,primecell";
+                                       reg = <0x110000 0x1000>;
+                                       interrupts = <2>;
+                                       clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
+                                       clock-names = "timclken1", "timclken2", "apb_pclk";
+                               };
 
-                       v2m_timer01: timer@110000 {
-                               compatible = "arm,sp804", "arm,primecell";
-                               reg = <0x110000 0x1000>;
-                               interrupts = <2>;
-                               clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
-                               clock-names = "timclken1", "timclken2", "apb_pclk";
-                       };
+                               v2m_timer23: timer@120000 {
+                                       compatible = "arm,sp804", "arm,primecell";
+                                       reg = <0x120000 0x1000>;
+                                       interrupts = <3>;
+                                       clocks = <&v2m_sysctl 2>, <&v2m_sysctl 3>, <&smbclk>;
+                                       clock-names = "timclken1", "timclken2", "apb_pclk";
+                               };
 
-                       v2m_timer23: timer@120000 {
-                               compatible = "arm,sp804", "arm,primecell";
-                               reg = <0x120000 0x1000>;
-                               interrupts = <3>;
-                               clocks = <&v2m_sysctl 2>, <&v2m_sysctl 3>, <&smbclk>;
-                               clock-names = "timclken1", "timclken2", "apb_pclk";
-                       };
+                               /* DVI I2C bus */
+                               v2m_i2c_dvi: i2c@160000 {
+                                       compatible = "arm,versatile-i2c";
+                                       reg = <0x160000 0x1000>;
 
-                       /* DVI I2C bus */
-                       v2m_i2c_dvi: i2c@160000 {
-                               compatible = "arm,versatile-i2c";
-                               reg = <0x160000 0x1000>;
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
 
-                               #address-cells = <1>;
-                               #size-cells = <0>;
+                                       dvi-transmitter@39 {
+                                               compatible = "sil,sii9022-tpi", "sil,sii9022";
+                                               reg = <0x39>;
+                                       };
 
-                               dvi-transmitter@39 {
-                                       compatible = "sil,sii9022-tpi", "sil,sii9022";
-                                       reg = <0x39>;
+                                       dvi-transmitter@60 {
+                                               compatible = "sil,sii9022-cpi", "sil,sii9022";
+                                               reg = <0x60>;
+                                       };
                                };
 
-                               dvi-transmitter@60 {
-                                       compatible = "sil,sii9022-cpi", "sil,sii9022";
-                                       reg = <0x60>;
+                               rtc@170000 {
+                                       compatible = "arm,pl031", "arm,primecell";
+                                       reg = <0x170000 0x1000>;
+                                       interrupts = <4>;
+                                       clocks = <&smbclk>;
+                                       clock-names = "apb_pclk";
                                };
-                       };
 
-                       rtc@170000 {
-                               compatible = "arm,pl031", "arm,primecell";
-                               reg = <0x170000 0x1000>;
-                               interrupts = <4>;
-                               clocks = <&smbclk>;
-                               clock-names = "apb_pclk";
-                       };
-
-                       compact-flash@1a0000 {
-                               compatible = "arm,vexpress-cf", "ata-generic";
-                               reg = <0x1a0000 0x100
-                                      0x1a0100 0xf00>;
-                               reg-shift = <2>;
-                       };
-
-                       clcd@1f0000 {
-                               compatible = "arm,pl111", "arm,primecell";
-                               reg = <0x1f0000 0x1000>;
-                               interrupt-names = "combined";
-                               interrupts = <14>;
-                               clocks = <&v2m_oscclk1>, <&smbclk>;
-                               clock-names = "clcdclk", "apb_pclk";
-                               memory-region = <&v2m_video_ram>;
-                               max-memory-bandwidth = <50350000>; /* 16bpp @ 25.175MHz */
-
-                               port {
-                                       v2m_clcd_pads: endpoint {
-                                               remote-endpoint = <&v2m_clcd_panel>;
-                                               arm,pl11x,tft-r0g0b0-pads = <0 8 16>;
-                                       };
+                               compact-flash@1a0000 {
+                                       compatible = "arm,vexpress-cf", "ata-generic";
+                                       reg = <0x1a0000 0x100
+                                              0x1a0100 0xf00>;
+                                       reg-shift = <2>;
                                };
 
-                               panel {
-                                       compatible = "panel-dpi";
+                               clcd@1f0000 {
+                                       compatible = "arm,pl111", "arm,primecell";
+                                       reg = <0x1f0000 0x1000>;
+                                       interrupt-names = "combined";
+                                       interrupts = <14>;
+                                       clocks = <&v2m_oscclk1>, <&smbclk>;
+                                       clock-names = "clcdclk", "apb_pclk";
+                                       memory-region = <&v2m_video_ram>;
+                                       max-memory-bandwidth = <50350000>; /* 16bpp @ 25.175MHz */
 
                                        port {
-                                               v2m_clcd_panel: endpoint {
-                                                       remote-endpoint = <&v2m_clcd_pads>;
+                                               v2m_clcd_pads: endpoint {
+                                                       remote-endpoint = <&v2m_clcd_panel>;
+                                                       arm,pl11x,tft-r0g0b0-pads = <0 8 16>;
                                                };
                                        };
 
-                                       panel-timing {
-                                               clock-frequency = <25175000>;
-                                               hactive = <640>;
-                                               hback-porch = <40>;
-                                               hfront-porch = <24>;
-                                               hsync-len = <96>;
-                                               vactive = <480>;
-                                               vback-porch = <32>;
-                                               vfront-porch = <11>;
-                                               vsync-len = <2>;
+                                       panel {
+                                               compatible = "panel-dpi";
+
+                                               port {
+                                                       v2m_clcd_panel: endpoint {
+                                                               remote-endpoint = <&v2m_clcd_pads>;
+                                                       };
+                                               };
+
+                                               panel-timing {
+                                                       clock-frequency = <25175000>;
+                                                       hactive = <640>;
+                                                       hback-porch = <40>;
+                                                       hfront-porch = <24>;
+                                                       hsync-len = <96>;
+                                                       vactive = <480>;
+                                                       vback-porch = <32>;
+                                                       vfront-porch = <11>;
+                                                       vsync-len = <2>;
+                                               };
                                        };
                                };
                        };
-               };
 
-               v2m_fixed_3v3: fixed-regulator-0 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "3V3";
-                       regulator-min-microvolt = <3300000>;
-                       regulator-max-microvolt = <3300000>;
-                       regulator-always-on;
-               };
+                       v2m_fixed_3v3: fixed-regulator-0 {
+                               compatible = "regulator-fixed";
+                               regulator-name = "3V3";
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
 
-               v2m_clk24mhz: clk24mhz {
-                       compatible = "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <24000000>;
-                       clock-output-names = "v2m:clk24mhz";
-               };
+                       v2m_clk24mhz: clk24mhz {
+                               compatible = "fixed-clock";
+                               #clock-cells = <0>;
+                               clock-frequency = <24000000>;
+                               clock-output-names = "v2m:clk24mhz";
+                       };
 
-               v2m_refclk1mhz: refclk1mhz {
-                       compatible = "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <1000000>;
-                       clock-output-names = "v2m:refclk1mhz";
-               };
+                       v2m_refclk1mhz: refclk1mhz {
+                               compatible = "fixed-clock";
+                               #clock-cells = <0>;
+                               clock-frequency = <1000000>;
+                               clock-output-names = "v2m:refclk1mhz";
+                       };
 
-               v2m_refclk32khz: refclk32khz {
-                       compatible = "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <32768>;
-                       clock-output-names = "v2m:refclk32khz";
-               };
+                       v2m_refclk32khz: refclk32khz {
+                               compatible = "fixed-clock";
+                               #clock-cells = <0>;
+                               clock-frequency = <32768>;
+                               clock-output-names = "v2m:refclk32khz";
+                       };
 
-               leds {
-                       compatible = "gpio-leds";
+                       leds {
+                               compatible = "gpio-leds";
 
-                       user1 {
-                               label = "v2m:green:user1";
-                               gpios = <&v2m_led_gpios 0 0>;
-                               linux,default-trigger = "heartbeat";
-                       };
+                               user1 {
+                                       label = "v2m:green:user1";
+                                       gpios = <&v2m_led_gpios 0 0>;
+                                       linux,default-trigger = "heartbeat";
+                               };
 
-                       user2 {
-                               label = "v2m:green:user2";
-                               gpios = <&v2m_led_gpios 1 0>;
-                               linux,default-trigger = "mmc0";
-                       };
+                               user2 {
+                                       label = "v2m:green:user2";
+                                       gpios = <&v2m_led_gpios 1 0>;
+                                       linux,default-trigger = "mmc0";
+                               };
 
-                       user3 {
-                               label = "v2m:green:user3";
-                               gpios = <&v2m_led_gpios 2 0>;
-                               linux,default-trigger = "cpu0";
-                       };
+                               user3 {
+                                       label = "v2m:green:user3";
+                                       gpios = <&v2m_led_gpios 2 0>;
+                                       linux,default-trigger = "cpu0";
+                               };
 
-                       user4 {
-                               label = "v2m:green:user4";
-                               gpios = <&v2m_led_gpios 3 0>;
-                               linux,default-trigger = "cpu1";
-                       };
+                               user4 {
+                                       label = "v2m:green:user4";
+                                       gpios = <&v2m_led_gpios 3 0>;
+                                       linux,default-trigger = "cpu1";
+                               };
 
-                       user5 {
-                               label = "v2m:green:user5";
-                               gpios = <&v2m_led_gpios 4 0>;
-                               linux,default-trigger = "cpu2";
-                       };
+                               user5 {
+                                       label = "v2m:green:user5";
+                                       gpios = <&v2m_led_gpios 4 0>;
+                                       linux,default-trigger = "cpu2";
+                               };
 
-                       user6 {
-                               label = "v2m:green:user6";
-                               gpios = <&v2m_led_gpios 5 0>;
-                               linux,default-trigger = "cpu3";
-                       };
+                               user6 {
+                                       label = "v2m:green:user6";
+                                       gpios = <&v2m_led_gpios 5 0>;
+                                       linux,default-trigger = "cpu3";
+                               };
 
-                       user7 {
-                               label = "v2m:green:user7";
-                               gpios = <&v2m_led_gpios 6 0>;
-                               linux,default-trigger = "cpu4";
-                       };
+                               user7 {
+                                       label = "v2m:green:user7";
+                                       gpios = <&v2m_led_gpios 6 0>;
+                                       linux,default-trigger = "cpu4";
+                               };
 
-                       user8 {
-                               label = "v2m:green:user8";
-                               gpios = <&v2m_led_gpios 7 0>;
-                               linux,default-trigger = "cpu5";
+                               user8 {
+                                       label = "v2m:green:user8";
+                                       gpios = <&v2m_led_gpios 7 0>;
+                                       linux,default-trigger = "cpu5";
+                               };
                        };
-               };
 
-               mcc {
-                       compatible = "arm,vexpress,config-bus";
-                       arm,vexpress,config-bridge = <&v2m_sysreg>;
+                       mcc {
+                               compatible = "arm,vexpress,config-bus";
+                               arm,vexpress,config-bridge = <&v2m_sysreg>;
 
-                       oscclk0 {
-                               /* MCC static memory clock */
-                               compatible = "arm,vexpress-osc";
-                               arm,vexpress-sysreg,func = <1 0>;
-                               freq-range = <25000000 60000000>;
-                               #clock-cells = <0>;
-                               clock-output-names = "v2m:oscclk0";
-                       };
+                               oscclk0 {
+                                       /* MCC static memory clock */
+                                       compatible = "arm,vexpress-osc";
+                                       arm,vexpress-sysreg,func = <1 0>;
+                                       freq-range = <25000000 60000000>;
+                                       #clock-cells = <0>;
+                                       clock-output-names = "v2m:oscclk0";
+                               };
 
-                       v2m_oscclk1: oscclk1 {
-                               /* CLCD clock */
-                               compatible = "arm,vexpress-osc";
-                               arm,vexpress-sysreg,func = <1 1>;
-                               freq-range = <23750000 65000000>;
-                               #clock-cells = <0>;
-                               clock-output-names = "v2m:oscclk1";
-                       };
+                               v2m_oscclk1: oscclk1 {
+                                       /* CLCD clock */
+                                       compatible = "arm,vexpress-osc";
+                                       arm,vexpress-sysreg,func = <1 1>;
+                                       freq-range = <23750000 65000000>;
+                                       #clock-cells = <0>;
+                                       clock-output-names = "v2m:oscclk1";
+                               };
 
-                       v2m_oscclk2: oscclk2 {
-                               /* IO FPGA peripheral clock */
-                               compatible = "arm,vexpress-osc";
-                               arm,vexpress-sysreg,func = <1 2>;
-                               freq-range = <24000000 24000000>;
-                               #clock-cells = <0>;
-                               clock-output-names = "v2m:oscclk2";
-                       };
+                               v2m_oscclk2: oscclk2 {
+                                       /* IO FPGA peripheral clock */
+                                       compatible = "arm,vexpress-osc";
+                                       arm,vexpress-sysreg,func = <1 2>;
+                                       freq-range = <24000000 24000000>;
+                                       #clock-cells = <0>;
+                                       clock-output-names = "v2m:oscclk2";
+                               };
 
-                       volt-vio {
-                               /* Logic level voltage */
-                               compatible = "arm,vexpress-volt";
-                               arm,vexpress-sysreg,func = <2 0>;
-                               regulator-name = "VIO";
-                               regulator-always-on;
-                               label = "VIO";
-                       };
+                               volt-vio {
+                                       /* Logic level voltage */
+                                       compatible = "arm,vexpress-volt";
+                                       arm,vexpress-sysreg,func = <2 0>;
+                                       regulator-name = "VIO";
+                                       regulator-always-on;
+                                       label = "VIO";
+                               };
 
-                       temp-mcc {
-                               /* MCC internal operating temperature */
-                               compatible = "arm,vexpress-temp";
-                               arm,vexpress-sysreg,func = <4 0>;
-                               label = "MCC";
-                       };
+                               temp-mcc {
+                                       /* MCC internal operating temperature */
+                                       compatible = "arm,vexpress-temp";
+                                       arm,vexpress-sysreg,func = <4 0>;
+                                       label = "MCC";
+                               };
 
-                       reset {
-                               compatible = "arm,vexpress-reset";
-                               arm,vexpress-sysreg,func = <5 0>;
-                       };
+                               reset {
+                                       compatible = "arm,vexpress-reset";
+                                       arm,vexpress-sysreg,func = <5 0>;
+                               };
 
-                       muxfpga {
-                               compatible = "arm,vexpress-muxfpga";
-                               arm,vexpress-sysreg,func = <7 0>;
-                       };
+                               muxfpga {
+                                       compatible = "arm,vexpress-muxfpga";
+                                       arm,vexpress-sysreg,func = <7 0>;
+                               };
 
-                       shutdown {
-                               compatible = "arm,vexpress-shutdown";
-                               arm,vexpress-sysreg,func = <8 0>;
-                       };
+                               shutdown {
+                                       compatible = "arm,vexpress-shutdown";
+                                       arm,vexpress-sysreg,func = <8 0>;
+                               };
 
-                       reboot {
-                               compatible = "arm,vexpress-reboot";
-                               arm,vexpress-sysreg,func = <9 0>;
-                       };
+                               reboot {
+                                       compatible = "arm,vexpress-reboot";
+                                       arm,vexpress-sysreg,func = <9 0>;
+                               };
 
-                       dvimode {
-                               compatible = "arm,vexpress-dvimode";
-                               arm,vexpress-sysreg,func = <11 0>;
+                               dvimode {
+                                       compatible = "arm,vexpress-dvimode";
+                                       arm,vexpress-sysreg,func = <11 0>;
+                               };
                        };
                };
        };
+};
index b0021a816028781a9615c8ec6073aebaaeac3b1e..4db42f6326a3175072f7fe617064ab983fbcf5e6 100644 (file)
  * CHANGES TO vexpress-v2m-rs1.dtsi!
  */
 
-       motherboard {
-               model = "V2M-P1";
-               arm,hbi = <0x190>;
-               arm,vexpress,site = <0>;
-               compatible = "arm,vexpress,v2m-p1", "simple-bus";
-               #address-cells = <2>; /* SMB chipselect number and offset */
-               #size-cells = <1>;
-               #interrupt-cells = <1>;
-               ranges;
-
-               flash@0,00000000 {
-                       compatible = "arm,vexpress-flash", "cfi-flash";
-                       reg = <0 0x00000000 0x04000000>,
-                             <1 0x00000000 0x04000000>;
-                       bank-width = <4>;
-               };
+/ {
+       smb@4000000 {
+               motherboard {
+                       model = "V2M-P1";
+                       arm,hbi = <0x190>;
+                       arm,vexpress,site = <0>;
+                       compatible = "arm,vexpress,v2m-p1", "simple-bus";
+                       #address-cells = <2>; /* SMB chipselect number and offset */
+                       #size-cells = <1>;
+                       #interrupt-cells = <1>;
+                       ranges;
 
-               psram@2,00000000 {
-                       compatible = "arm,vexpress-psram", "mtd-ram";
-                       reg = <2 0x00000000 0x02000000>;
-                       bank-width = <4>;
-               };
+                       flash@0,00000000 {
+                               compatible = "arm,vexpress-flash", "cfi-flash";
+                               reg = <0 0x00000000 0x04000000>,
+                                     <1 0x00000000 0x04000000>;
+                               bank-width = <4>;
+                       };
 
-               v2m_video_ram: vram@3,00000000 {
-                       compatible = "arm,vexpress-vram";
-                       reg = <3 0x00000000 0x00800000>;
-               };
+                       psram@2,00000000 {
+                               compatible = "arm,vexpress-psram", "mtd-ram";
+                               reg = <2 0x00000000 0x02000000>;
+                               bank-width = <4>;
+                       };
 
-               ethernet@3,02000000 {
-                       compatible = "smsc,lan9118", "smsc,lan9115";
-                       reg = <3 0x02000000 0x10000>;
-                       interrupts = <15>;
-                       phy-mode = "mii";
-                       reg-io-width = <4>;
-                       smsc,irq-active-high;
-                       smsc,irq-push-pull;
-                       vdd33a-supply = <&v2m_fixed_3v3>;
-                       vddvario-supply = <&v2m_fixed_3v3>;
-               };
+                       v2m_video_ram: vram@3,00000000 {
+                               compatible = "arm,vexpress-vram";
+                               reg = <3 0x00000000 0x00800000>;
+                       };
 
-               usb@3,03000000 {
-                       compatible = "nxp,usb-isp1761";
-                       reg = <3 0x03000000 0x20000>;
-                       interrupts = <16>;
-                       port1-otg;
-               };
+                       ethernet@3,02000000 {
+                               compatible = "smsc,lan9118", "smsc,lan9115";
+                               reg = <3 0x02000000 0x10000>;
+                               interrupts = <15>;
+                               phy-mode = "mii";
+                               reg-io-width = <4>;
+                               smsc,irq-active-high;
+                               smsc,irq-push-pull;
+                               vdd33a-supply = <&v2m_fixed_3v3>;
+                               vddvario-supply = <&v2m_fixed_3v3>;
+                       };
 
-               iofpga@7,00000000 {
-                       compatible = "simple-bus";
-                       #address-cells = <1>;
-                       #size-cells = <1>;
-                       ranges = <0 7 0 0x20000>;
+                       usb@3,03000000 {
+                               compatible = "nxp,usb-isp1761";
+                               reg = <3 0x03000000 0x20000>;
+                               interrupts = <16>;
+                               port1-otg;
+                       };
 
-                       v2m_sysreg: sysreg@0 {
-                               compatible = "arm,vexpress-sysreg";
-                               reg = <0x00000 0x1000>;
+                       iofpga@7,00000000 {
+                               compatible = "simple-bus";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+                               ranges = <0 7 0 0x20000>;
+
+                               v2m_sysreg: sysreg@0 {
+                                       compatible = "arm,vexpress-sysreg";
+                                       reg = <0x00000 0x1000>;
+                                       #address-cells = <1>;
+                                       #size-cells = <1>;
+                                       ranges = <0 0 0x1000>;
+
+                                       v2m_led_gpios: gpio@8 {
+                                               compatible = "arm,vexpress-sysreg,sys_led";
+                                               reg = <0x008 4>;
+                                               gpio-controller;
+                                               #gpio-cells = <2>;
+                                       };
 
-                               v2m_led_gpios: sys_led {
-                                       compatible = "arm,vexpress-sysreg,sys_led";
-                                       gpio-controller;
-                                       #gpio-cells = <2>;
-                               };
+                                       v2m_mmc_gpios: gpio@48 {
+                                               compatible = "arm,vexpress-sysreg,sys_mci";
+                                               reg = <0x048 4>;
+                                               gpio-controller;
+                                               #gpio-cells = <2>;
+                                       };
 
-                               v2m_mmc_gpios: sys_mci {
-                                       compatible = "arm,vexpress-sysreg,sys_mci";
-                                       gpio-controller;
-                                       #gpio-cells = <2>;
+                                       v2m_flash_gpios: gpio@4c {
+                                               compatible = "arm,vexpress-sysreg,sys_flash";
+                                               reg = <0x04c 4>;
+                                               gpio-controller;
+                                               #gpio-cells = <2>;
+                                       };
                                };
 
-                               v2m_flash_gpios: sys_flash {
-                                       compatible = "arm,vexpress-sysreg,sys_flash";
-                                       gpio-controller;
-                                       #gpio-cells = <2>;
+                               v2m_sysctl: sysctl@1000 {
+                                       compatible = "arm,sp810", "arm,primecell";
+                                       reg = <0x01000 0x1000>;
+                                       clocks = <&v2m_refclk32khz>, <&v2m_refclk1mhz>, <&smbclk>;
+                                       clock-names = "refclk", "timclk", "apb_pclk";
+                                       #clock-cells = <1>;
+                                       clock-output-names = "timerclken0", "timerclken1", "timerclken2", "timerclken3";
+                                       assigned-clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&v2m_sysctl 3>, <&v2m_sysctl 3>;
+                                       assigned-clock-parents = <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>;
                                };
-                       };
 
-                       v2m_sysctl: sysctl@1000 {
-                               compatible = "arm,sp810", "arm,primecell";
-                               reg = <0x01000 0x1000>;
-                               clocks = <&v2m_refclk32khz>, <&v2m_refclk1mhz>, <&smbclk>;
-                               clock-names = "refclk", "timclk", "apb_pclk";
-                               #clock-cells = <1>;
-                               clock-output-names = "timerclken0", "timerclken1", "timerclken2", "timerclken3";
-                               assigned-clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&v2m_sysctl 3>, <&v2m_sysctl 3>;
-                               assigned-clock-parents = <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>;
-                       };
+                               /* PCI-E I2C bus */
+                               v2m_i2c_pcie: i2c@2000 {
+                                       compatible = "arm,versatile-i2c";
+                                       reg = <0x02000 0x1000>;
 
-                       /* PCI-E I2C bus */
-                       v2m_i2c_pcie: i2c@2000 {
-                               compatible = "arm,versatile-i2c";
-                               reg = <0x02000 0x1000>;
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
 
-                               #address-cells = <1>;
-                               #size-cells = <0>;
+                                       pcie-switch@60 {
+                                               compatible = "idt,89hpes32h8";
+                                               reg = <0x60>;
+                                       };
+                               };
 
-                               pcie-switch@60 {
-                                       compatible = "idt,89hpes32h8";
-                                       reg = <0x60>;
+                               aaci@4000 {
+                                       compatible = "arm,pl041", "arm,primecell";
+                                       reg = <0x04000 0x1000>;
+                                       interrupts = <11>;
+                                       clocks = <&smbclk>;
+                                       clock-names = "apb_pclk";
                                };
-                       };
 
-                       aaci@4000 {
-                               compatible = "arm,pl041", "arm,primecell";
-                               reg = <0x04000 0x1000>;
-                               interrupts = <11>;
-                               clocks = <&smbclk>;
-                               clock-names = "apb_pclk";
-                       };
+                               mmci@5000 {
+                                       compatible = "arm,pl180", "arm,primecell";
+                                       reg = <0x05000 0x1000>;
+                                       interrupts = <9 10>;
+                                       cd-gpios = <&v2m_mmc_gpios 0 0>;
+                                       wp-gpios = <&v2m_mmc_gpios 1 0>;
+                                       max-frequency = <12000000>;
+                                       vmmc-supply = <&v2m_fixed_3v3>;
+                                       clocks = <&v2m_clk24mhz>, <&smbclk>;
+                                       clock-names = "mclk", "apb_pclk";
+                               };
 
-                       mmci@5000 {
-                               compatible = "arm,pl180", "arm,primecell";
-                               reg = <0x05000 0x1000>;
-                               interrupts = <9 10>;
-                               cd-gpios = <&v2m_mmc_gpios 0 0>;
-                               wp-gpios = <&v2m_mmc_gpios 1 0>;
-                               max-frequency = <12000000>;
-                               vmmc-supply = <&v2m_fixed_3v3>;
-                               clocks = <&v2m_clk24mhz>, <&smbclk>;
-                               clock-names = "mclk", "apb_pclk";
-                       };
+                               kmi@6000 {
+                                       compatible = "arm,pl050", "arm,primecell";
+                                       reg = <0x06000 0x1000>;
+                                       interrupts = <12>;
+                                       clocks = <&v2m_clk24mhz>, <&smbclk>;
+                                       clock-names = "KMIREFCLK", "apb_pclk";
+                               };
 
-                       kmi@6000 {
-                               compatible = "arm,pl050", "arm,primecell";
-                               reg = <0x06000 0x1000>;
-                               interrupts = <12>;
-                               clocks = <&v2m_clk24mhz>, <&smbclk>;
-                               clock-names = "KMIREFCLK", "apb_pclk";
-                       };
+                               kmi@7000 {
+                                       compatible = "arm,pl050", "arm,primecell";
+                                       reg = <0x07000 0x1000>;
+                                       interrupts = <13>;
+                                       clocks = <&v2m_clk24mhz>, <&smbclk>;
+                                       clock-names = "KMIREFCLK", "apb_pclk";
+                               };
 
-                       kmi@7000 {
-                               compatible = "arm,pl050", "arm,primecell";
-                               reg = <0x07000 0x1000>;
-                               interrupts = <13>;
-                               clocks = <&v2m_clk24mhz>, <&smbclk>;
-                               clock-names = "KMIREFCLK", "apb_pclk";
-                       };
+                               v2m_serial0: uart@9000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x09000 0x1000>;
+                                       interrupts = <5>;
+                                       clocks = <&v2m_oscclk2>, <&smbclk>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       v2m_serial0: uart@9000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x09000 0x1000>;
-                               interrupts = <5>;
-                               clocks = <&v2m_oscclk2>, <&smbclk>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               v2m_serial1: uart@a000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x0a000 0x1000>;
+                                       interrupts = <6>;
+                                       clocks = <&v2m_oscclk2>, <&smbclk>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       v2m_serial1: uart@a000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x0a000 0x1000>;
-                               interrupts = <6>;
-                               clocks = <&v2m_oscclk2>, <&smbclk>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               v2m_serial2: uart@b000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x0b000 0x1000>;
+                                       interrupts = <7>;
+                                       clocks = <&v2m_oscclk2>, <&smbclk>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       v2m_serial2: uart@b000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x0b000 0x1000>;
-                               interrupts = <7>;
-                               clocks = <&v2m_oscclk2>, <&smbclk>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               v2m_serial3: uart@c000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x0c000 0x1000>;
+                                       interrupts = <8>;
+                                       clocks = <&v2m_oscclk2>, <&smbclk>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       v2m_serial3: uart@c000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x0c000 0x1000>;
-                               interrupts = <8>;
-                               clocks = <&v2m_oscclk2>, <&smbclk>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               wdt@f000 {
+                                       compatible = "arm,sp805", "arm,primecell";
+                                       reg = <0x0f000 0x1000>;
+                                       interrupts = <0>;
+                                       clocks = <&v2m_refclk32khz>, <&smbclk>;
+                                       clock-names = "wdogclk", "apb_pclk";
+                               };
 
-                       wdt@f000 {
-                               compatible = "arm,sp805", "arm,primecell";
-                               reg = <0x0f000 0x1000>;
-                               interrupts = <0>;
-                               clocks = <&v2m_refclk32khz>, <&smbclk>;
-                               clock-names = "wdogclk", "apb_pclk";
-                       };
+                               v2m_timer01: timer@11000 {
+                                       compatible = "arm,sp804", "arm,primecell";
+                                       reg = <0x11000 0x1000>;
+                                       interrupts = <2>;
+                                       clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
+                                       clock-names = "timclken1", "timclken2", "apb_pclk";
+                               };
 
-                       v2m_timer01: timer@11000 {
-                               compatible = "arm,sp804", "arm,primecell";
-                               reg = <0x11000 0x1000>;
-                               interrupts = <2>;
-                               clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&smbclk>;
-                               clock-names = "timclken1", "timclken2", "apb_pclk";
-                       };
+                               v2m_timer23: timer@12000 {
+                                       compatible = "arm,sp804", "arm,primecell";
+                                       reg = <0x12000 0x1000>;
+                                       interrupts = <3>;
+                                       clocks = <&v2m_sysctl 2>, <&v2m_sysctl 3>, <&smbclk>;
+                                       clock-names = "timclken1", "timclken2", "apb_pclk";
+                               };
 
-                       v2m_timer23: timer@12000 {
-                               compatible = "arm,sp804", "arm,primecell";
-                               reg = <0x12000 0x1000>;
-                               interrupts = <3>;
-                               clocks = <&v2m_sysctl 2>, <&v2m_sysctl 3>, <&smbclk>;
-                               clock-names = "timclken1", "timclken2", "apb_pclk";
-                       };
+                               /* DVI I2C bus */
+                               v2m_i2c_dvi: i2c@16000 {
+                                       compatible = "arm,versatile-i2c";
+                                       reg = <0x16000 0x1000>;
 
-                       /* DVI I2C bus */
-                       v2m_i2c_dvi: i2c@16000 {
-                               compatible = "arm,versatile-i2c";
-                               reg = <0x16000 0x1000>;
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
 
-                               #address-cells = <1>;
-                               #size-cells = <0>;
+                                       dvi-transmitter@39 {
+                                               compatible = "sil,sii9022-tpi", "sil,sii9022";
+                                               reg = <0x39>;
+                                       };
 
-                               dvi-transmitter@39 {
-                                       compatible = "sil,sii9022-tpi", "sil,sii9022";
-                                       reg = <0x39>;
+                                       dvi-transmitter@60 {
+                                               compatible = "sil,sii9022-cpi", "sil,sii9022";
+                                               reg = <0x60>;
+                                       };
                                };
 
-                               dvi-transmitter@60 {
-                                       compatible = "sil,sii9022-cpi", "sil,sii9022";
-                                       reg = <0x60>;
+                               rtc@17000 {
+                                       compatible = "arm,pl031", "arm,primecell";
+                                       reg = <0x17000 0x1000>;
+                                       interrupts = <4>;
+                                       clocks = <&smbclk>;
+                                       clock-names = "apb_pclk";
                                };
-                       };
 
-                       rtc@17000 {
-                               compatible = "arm,pl031", "arm,primecell";
-                               reg = <0x17000 0x1000>;
-                               interrupts = <4>;
-                               clocks = <&smbclk>;
-                               clock-names = "apb_pclk";
-                       };
-
-                       compact-flash@1a000 {
-                               compatible = "arm,vexpress-cf", "ata-generic";
-                               reg = <0x1a000 0x100
-                                      0x1a100 0xf00>;
-                               reg-shift = <2>;
-                       };
-
-                       clcd@1f000 {
-                               compatible = "arm,pl111", "arm,primecell";
-                               reg = <0x1f000 0x1000>;
-                               interrupt-names = "combined";
-                               interrupts = <14>;
-                               clocks = <&v2m_oscclk1>, <&smbclk>;
-                               clock-names = "clcdclk", "apb_pclk";
-                               memory-region = <&v2m_video_ram>;
-                               max-memory-bandwidth = <50350000>; /* 16bpp @ 25.175MHz */
-
-                               port {
-                                       v2m_clcd_pads: endpoint {
-                                               remote-endpoint = <&v2m_clcd_panel>;
-                                               arm,pl11x,tft-r0g0b0-pads = <0 8 16>;
-                                       };
+                               compact-flash@1a000 {
+                                       compatible = "arm,vexpress-cf", "ata-generic";
+                                       reg = <0x1a000 0x100
+                                              0x1a100 0xf00>;
+                                       reg-shift = <2>;
                                };
 
-                               panel {
-                                       compatible = "panel-dpi";
+                               clcd@1f000 {
+                                       compatible = "arm,pl111", "arm,primecell";
+                                       reg = <0x1f000 0x1000>;
+                                       interrupt-names = "combined";
+                                       interrupts = <14>;
+                                       clocks = <&v2m_oscclk1>, <&smbclk>;
+                                       clock-names = "clcdclk", "apb_pclk";
+                                       memory-region = <&v2m_video_ram>;
+                                       max-memory-bandwidth = <50350000>; /* 16bpp @ 25.175MHz */
 
                                        port {
-                                               v2m_clcd_panel: endpoint {
-                                                       remote-endpoint = <&v2m_clcd_pads>;
+                                               v2m_clcd_pads: endpoint {
+                                                       remote-endpoint = <&v2m_clcd_panel>;
+                                                       arm,pl11x,tft-r0g0b0-pads = <0 8 16>;
                                                };
                                        };
 
-                                       panel-timing {
-                                               clock-frequency = <25175000>;
-                                               hactive = <640>;
-                                               hback-porch = <40>;
-                                               hfront-porch = <24>;
-                                               hsync-len = <96>;
-                                               vactive = <480>;
-                                               vback-porch = <32>;
-                                               vfront-porch = <11>;
-                                               vsync-len = <2>;
+                                       panel {
+                                               compatible = "panel-dpi";
+
+                                               port {
+                                                       v2m_clcd_panel: endpoint {
+                                                               remote-endpoint = <&v2m_clcd_pads>;
+                                                       };
+                                               };
+
+                                               panel-timing {
+                                                       clock-frequency = <25175000>;
+                                                       hactive = <640>;
+                                                       hback-porch = <40>;
+                                                       hfront-porch = <24>;
+                                                       hsync-len = <96>;
+                                                       vactive = <480>;
+                                                       vback-porch = <32>;
+                                                       vfront-porch = <11>;
+                                                       vsync-len = <2>;
+                                               };
                                        };
                                };
                        };
-               };
 
-               v2m_fixed_3v3: fixed-regulator-0 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "3V3";
-                       regulator-min-microvolt = <3300000>;
-                       regulator-max-microvolt = <3300000>;
-                       regulator-always-on;
-               };
+                       v2m_fixed_3v3: fixed-regulator-0 {
+                               compatible = "regulator-fixed";
+                               regulator-name = "3V3";
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
+                       };
 
-               v2m_clk24mhz: clk24mhz {
-                       compatible = "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <24000000>;
-                       clock-output-names = "v2m:clk24mhz";
-               };
+                       v2m_clk24mhz: clk24mhz {
+                               compatible = "fixed-clock";
+                               #clock-cells = <0>;
+                               clock-frequency = <24000000>;
+                               clock-output-names = "v2m:clk24mhz";
+                       };
 
-               v2m_refclk1mhz: refclk1mhz {
-                       compatible = "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <1000000>;
-                       clock-output-names = "v2m:refclk1mhz";
-               };
+                       v2m_refclk1mhz: refclk1mhz {
+                               compatible = "fixed-clock";
+                               #clock-cells = <0>;
+                               clock-frequency = <1000000>;
+                               clock-output-names = "v2m:refclk1mhz";
+                       };
 
-               v2m_refclk32khz: refclk32khz {
-                       compatible = "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <32768>;
-                       clock-output-names = "v2m:refclk32khz";
-               };
+                       v2m_refclk32khz: refclk32khz {
+                               compatible = "fixed-clock";
+                               #clock-cells = <0>;
+                               clock-frequency = <32768>;
+                               clock-output-names = "v2m:refclk32khz";
+                       };
 
-               leds {
-                       compatible = "gpio-leds";
+                       leds {
+                               compatible = "gpio-leds";
 
-                       user1 {
-                               label = "v2m:green:user1";
-                               gpios = <&v2m_led_gpios 0 0>;
-                               linux,default-trigger = "heartbeat";
-                       };
+                               user1 {
+                                       label = "v2m:green:user1";
+                                       gpios = <&v2m_led_gpios 0 0>;
+                                       linux,default-trigger = "heartbeat";
+                               };
 
-                       user2 {
-                               label = "v2m:green:user2";
-                               gpios = <&v2m_led_gpios 1 0>;
-                               linux,default-trigger = "mmc0";
-                       };
+                               user2 {
+                                       label = "v2m:green:user2";
+                                       gpios = <&v2m_led_gpios 1 0>;
+                                       linux,default-trigger = "mmc0";
+                               };
 
-                       user3 {
-                               label = "v2m:green:user3";
-                               gpios = <&v2m_led_gpios 2 0>;
-                               linux,default-trigger = "cpu0";
-                       };
+                               user3 {
+                                       label = "v2m:green:user3";
+                                       gpios = <&v2m_led_gpios 2 0>;
+                                       linux,default-trigger = "cpu0";
+                               };
 
-                       user4 {
-                               label = "v2m:green:user4";
-                               gpios = <&v2m_led_gpios 3 0>;
-                               linux,default-trigger = "cpu1";
-                       };
+                               user4 {
+                                       label = "v2m:green:user4";
+                                       gpios = <&v2m_led_gpios 3 0>;
+                                       linux,default-trigger = "cpu1";
+                               };
 
-                       user5 {
-                               label = "v2m:green:user5";
-                               gpios = <&v2m_led_gpios 4 0>;
-                               linux,default-trigger = "cpu2";
-                       };
+                               user5 {
+                                       label = "v2m:green:user5";
+                                       gpios = <&v2m_led_gpios 4 0>;
+                                       linux,default-trigger = "cpu2";
+                               };
 
-                       user6 {
-                               label = "v2m:green:user6";
-                               gpios = <&v2m_led_gpios 5 0>;
-                               linux,default-trigger = "cpu3";
-                       };
+                               user6 {
+                                       label = "v2m:green:user6";
+                                       gpios = <&v2m_led_gpios 5 0>;
+                                       linux,default-trigger = "cpu3";
+                               };
 
-                       user7 {
-                               label = "v2m:green:user7";
-                               gpios = <&v2m_led_gpios 6 0>;
-                               linux,default-trigger = "cpu4";
-                       };
+                               user7 {
+                                       label = "v2m:green:user7";
+                                       gpios = <&v2m_led_gpios 6 0>;
+                                       linux,default-trigger = "cpu4";
+                               };
 
-                       user8 {
-                               label = "v2m:green:user8";
-                               gpios = <&v2m_led_gpios 7 0>;
-                               linux,default-trigger = "cpu5";
+                               user8 {
+                                       label = "v2m:green:user8";
+                                       gpios = <&v2m_led_gpios 7 0>;
+                                       linux,default-trigger = "cpu5";
+                               };
                        };
-               };
 
-               mcc {
-                       compatible = "arm,vexpress,config-bus";
-                       arm,vexpress,config-bridge = <&v2m_sysreg>;
+                       mcc {
+                               compatible = "arm,vexpress,config-bus";
+                               arm,vexpress,config-bridge = <&v2m_sysreg>;
 
-                       oscclk0 {
-                               /* MCC static memory clock */
-                               compatible = "arm,vexpress-osc";
-                               arm,vexpress-sysreg,func = <1 0>;
-                               freq-range = <25000000 60000000>;
-                               #clock-cells = <0>;
-                               clock-output-names = "v2m:oscclk0";
-                       };
+                               oscclk0 {
+                                       /* MCC static memory clock */
+                                       compatible = "arm,vexpress-osc";
+                                       arm,vexpress-sysreg,func = <1 0>;
+                                       freq-range = <25000000 60000000>;
+                                       #clock-cells = <0>;
+                                       clock-output-names = "v2m:oscclk0";
+                               };
 
-                       v2m_oscclk1: oscclk1 {
-                               /* CLCD clock */
-                               compatible = "arm,vexpress-osc";
-                               arm,vexpress-sysreg,func = <1 1>;
-                               freq-range = <23750000 65000000>;
-                               #clock-cells = <0>;
-                               clock-output-names = "v2m:oscclk1";
-                       };
+                               v2m_oscclk1: oscclk1 {
+                                       /* CLCD clock */
+                                       compatible = "arm,vexpress-osc";
+                                       arm,vexpress-sysreg,func = <1 1>;
+                                       freq-range = <23750000 65000000>;
+                                       #clock-cells = <0>;
+                                       clock-output-names = "v2m:oscclk1";
+                               };
 
-                       v2m_oscclk2: oscclk2 {
-                               /* IO FPGA peripheral clock */
-                               compatible = "arm,vexpress-osc";
-                               arm,vexpress-sysreg,func = <1 2>;
-                               freq-range = <24000000 24000000>;
-                               #clock-cells = <0>;
-                               clock-output-names = "v2m:oscclk2";
-                       };
+                               v2m_oscclk2: oscclk2 {
+                                       /* IO FPGA peripheral clock */
+                                       compatible = "arm,vexpress-osc";
+                                       arm,vexpress-sysreg,func = <1 2>;
+                                       freq-range = <24000000 24000000>;
+                                       #clock-cells = <0>;
+                                       clock-output-names = "v2m:oscclk2";
+                               };
 
-                       volt-vio {
-                               /* Logic level voltage */
-                               compatible = "arm,vexpress-volt";
-                               arm,vexpress-sysreg,func = <2 0>;
-                               regulator-name = "VIO";
-                               regulator-always-on;
-                               label = "VIO";
-                       };
+                               volt-vio {
+                                       /* Logic level voltage */
+                                       compatible = "arm,vexpress-volt";
+                                       arm,vexpress-sysreg,func = <2 0>;
+                                       regulator-name = "VIO";
+                                       regulator-always-on;
+                                       label = "VIO";
+                               };
 
-                       temp-mcc {
-                               /* MCC internal operating temperature */
-                               compatible = "arm,vexpress-temp";
-                               arm,vexpress-sysreg,func = <4 0>;
-                               label = "MCC";
-                       };
+                               temp-mcc {
+                                       /* MCC internal operating temperature */
+                                       compatible = "arm,vexpress-temp";
+                                       arm,vexpress-sysreg,func = <4 0>;
+                                       label = "MCC";
+                               };
 
-                       reset {
-                               compatible = "arm,vexpress-reset";
-                               arm,vexpress-sysreg,func = <5 0>;
-                       };
+                               reset {
+                                       compatible = "arm,vexpress-reset";
+                                       arm,vexpress-sysreg,func = <5 0>;
+                               };
 
-                       muxfpga {
-                               compatible = "arm,vexpress-muxfpga";
-                               arm,vexpress-sysreg,func = <7 0>;
-                       };
+                               muxfpga {
+                                       compatible = "arm,vexpress-muxfpga";
+                                       arm,vexpress-sysreg,func = <7 0>;
+                               };
 
-                       shutdown {
-                               compatible = "arm,vexpress-shutdown";
-                               arm,vexpress-sysreg,func = <8 0>;
-                       };
+                               shutdown {
+                                       compatible = "arm,vexpress-shutdown";
+                                       arm,vexpress-sysreg,func = <8 0>;
+                               };
 
-                       reboot {
-                               compatible = "arm,vexpress-reboot";
-                               arm,vexpress-sysreg,func = <9 0>;
-                       };
+                               reboot {
+                                       compatible = "arm,vexpress-reboot";
+                                       arm,vexpress-sysreg,func = <9 0>;
+                               };
 
-                       dvimode {
-                               compatible = "arm,vexpress-dvimode";
-                               arm,vexpress-sysreg,func = <11 0>;
+                               dvimode {
+                                       compatible = "arm,vexpress-dvimode";
+                                       arm,vexpress-sysreg,func = <11 0>;
+                               };
                        };
                };
        };
+};
\ No newline at end of file
index a8ac4e2ed2907cfca6441a9f3e2ac09ce3a1bc99..3971427a105b5447e113427d565bd980096a4502 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 /dts-v1/;
+#include "vexpress-v2m-rs1.dtsi"
 
 / {
        model = "V2P-CA15";
@@ -278,8 +279,6 @@ smb@8000000 {
                                <0 0 40 &gic 0 40 4>,
                                <0 0 41 &gic 0 41 4>,
                                <0 0 42 &gic 0 42 4>;
-
-               /include/ "vexpress-v2m-rs1.dtsi"
        };
 
        site2: hsb@40000000 {
index a4c7713edfcd5c9807cf5c4827978303aa8e1c95..ac6b90e9d806042f153d6cc4260b1dba765904f2 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 /dts-v1/;
+#include "vexpress-v2m-rs1.dtsi"
 
 / {
        model = "V2P-CA15_CA7";
@@ -203,7 +204,7 @@ timer {
                             <1 10 0xf08>;
        };
 
-       pmu_a15 {
+       pmu-a15 {
                compatible = "arm,cortex-a15-pmu";
                interrupts = <0 68 4>,
                             <0 69 4>;
@@ -211,7 +212,7 @@ pmu_a15 {
                                     <&cpu1>;
        };
 
-       pmu_a7 {
+       pmu-a7 {
                compatible = "arm,cortex-a7-pmu";
                interrupts = <0 128 4>,
                             <0 129 4>,
@@ -584,7 +585,7 @@ etm2_out_port: endpoint {
                };
        };
 
-       smb@8000000 {
+       smb: smb@8000000 {
                compatible = "simple-bus";
 
                #address-cells = <2>;
@@ -641,8 +642,6 @@ smb@8000000 {
                                <0 0 40 &gic 0 40 4>,
                                <0 0 41 &gic 0 41 4>,
                                <0 0 42 &gic 0 42 4>;
-
-               /include/ "vexpress-v2m-rs1.dtsi"
        };
 
        site2: hsb@40000000 {
index 32f1906ffecfed690e4a7d7c35f6bbc633e273c4..e5b4a7570a010e0562eac1b3a6e05627c2c7b0e3 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 /dts-v1/;
+#include "vexpress-v2m-rs1.dtsi"
 
 / {
        model = "V2P-CA5s";
@@ -191,7 +192,7 @@ temp-dcc {
                };
        };
 
-       smb@8000000 {
+       smb: smb@8000000 {
                compatible = "simple-bus";
 
                #address-cells = <2>;
@@ -248,8 +249,6 @@ smb@8000000 {
                                <0 0 40 &gic 0 40 4>,
                                <0 0 41 &gic 0 41 4>,
                                <0 0 42 &gic 0 42 4>;
-
-               /include/ "vexpress-v2m-rs1.dtsi"
        };
 
        site2: hsb@40000000 {
index 5814460e0549469e13d2200bc55cc3b81d683a0c..fc43873cbdff5dbf7b7f14d1e699da5c8228a682 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 /dts-v1/;
+#include "vexpress-v2m.dtsi"
 
 / {
        model = "V2P-CA9";
@@ -301,7 +302,7 @@ power-vd10-s3 {
                };
        };
 
-       smb@4000000 {
+       smb: smb@4000000 {
                compatible = "simple-bus";
 
                #address-cells = <2>;
@@ -357,8 +358,6 @@ smb@4000000 {
                                <0 0 40 &gic 0 40 4>,
                                <0 0 41 &gic 0 41 4>,
                                <0 0 42 &gic 0 42 4>;
-
-               /include/ "vexpress-v2m.dtsi"
        };
 
        site2: hsb@e0000000 {
index d8b2972527ebfd0c7f0b286d28612fa669ef09e3..e2da122a63f4f3904f80d30f49a6edbdd144cca5 100644 (file)
@@ -117,7 +117,7 @@ mcp2515can: can@0 {
                clocks = <&clk16m>;
                spi-max-frequency = <10000000>;
                interrupt-parent = <&gpio1>;
-               interrupts = <11 GPIO_ACTIVE_LOW>;
+               interrupts = <11 IRQ_TYPE_EDGE_RISING>;
        };
 };
 
index 782b69a3acdfaef71b3e035a79c3da1e707c8c20..bd79e00bf6153a5a66c4e63025ed3ee73ec69dae 100644 (file)
@@ -70,8 +70,6 @@ switch0: switch@0 {
                                compatible = "marvell,mv88e6085";
                                pinctrl-0 = <&pinctrl_gpio_switch0>;
                                pinctrl-names = "default";
-                               #address-cells = <1>;
-                               #size-cells = <0>;
                                reg = <0>;
                                dsa,member = <0 0>;
                                interrupt-parent = <&gpio0>;
@@ -156,8 +154,6 @@ switch1: switch@0 {
                                compatible = "marvell,mv88e6085";
                                pinctrl-0 = <&pinctrl_gpio_switch1>;
                                pinctrl-names = "default";
-                               #address-cells = <1>;
-                               #size-cells = <0>;
                                reg = <0>;
                                dsa,member = <0 1>;
                                interrupt-parent = <&gpio0>;
@@ -243,8 +239,6 @@ mdio_mux_4: mdio@4 {
 
                        switch2: switch@0 {
                                compatible = "marvell,mv88e6085";
-                               #address-cells = <1>;
-                               #size-cells = <0>;
                                reg = <0>;
                                dsa,member = <0 2>;
 
index c6f134c78303fa0c733394cf46f6d62de7480a5d..0b1e94c6f25bd0867c9eee3c603cd2bf1da8ec7d 100644 (file)
@@ -69,8 +69,6 @@ switch0: switch@0 {
                                compatible = "marvell,mv88e6190";
                                pinctrl-0 = <&pinctrl_gpio_switch0>;
                                pinctrl-names = "default";
-                               #address-cells = <1>;
-                               #size-cells = <0>;
                                reg = <0>;
                                dsa,member = <0 0>;
                                eeprom-length = <65536>;
@@ -166,8 +164,6 @@ switch1: switch@0 {
                                compatible = "marvell,mv88e6190";
                                pinctrl-0 = <&pinctrl_gpio_switch1>;
                                pinctrl-names = "default";
-                               #address-cells = <1>;
-                               #size-cells = <0>;
                                reg = <0>;
                                dsa,member = <0 1>;
                                eeprom-length = <65536>;
index 4890b8a5aa4457437aa2adcccb9f33cf56dd8e3e..5ae5abfe1d55e50ffa066b26697e85416555bde6 100644 (file)
@@ -222,6 +222,10 @@ &usbphy1 {
        status = "okay";
 };
 
+&tempsensor {
+       io-channels = <&adc0 16>;
+};
+
 &iomuxc {
        pinctrl_adc0_ad5: adc0ad5grp {
                fsl,pins = <
index c3f09b7379240b1823e0fcc573597f29c0026284..d392794d9c139f139fecfa6938c3ac5cdb69bed5 100644 (file)
@@ -84,7 +84,7 @@ reboot: syscon-reboot {
                mask = <0x1000>;
        };
 
-       iio-hwmon {
+       tempsensor: iio-hwmon {
                compatible = "iio-hwmon";
                io-channels = <&adc0 16>, <&adc1 16>;
        };
index 70b4a14ed9937aad24ff77f5dd16dd0a52934538..1e9f7af8f70ff6ba23d9403f930f09dd6e0dda7e 100644 (file)
@@ -10,6 +10,7 @@ obj-$(CONFIG_DMABOUNCE)               += dmabounce.o
 obj-$(CONFIG_SHARP_LOCOMO)     += locomo.o
 obj-$(CONFIG_SHARP_PARAM)      += sharpsl_param.o
 obj-$(CONFIG_SHARP_SCOOP)      += scoop.o
+obj-$(CONFIG_SMP)              += secure_cntvoff.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
 obj-$(CONFIG_MCPM)             += mcpm_head.o mcpm_entry.o mcpm_platsmp.o vlock.o
 CFLAGS_REMOVE_mcpm_entry.o     = -pg
diff --git a/arch/arm/common/secure_cntvoff.S b/arch/arm/common/secure_cntvoff.S
new file mode 100644 (file)
index 0000000..53fc7bd
--- /dev/null
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2014 Renesas Electronics Corporation
+ *
+ * Initialization of CNTVOFF register from secure mode
+ *
+ */
+
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+
+ENTRY(secure_cntvoff_init)
+       .arch   armv7-a
+       /*
+        * CNTVOFF has to be initialized either from non-secure Hypervisor
+        * mode or secure Monitor mode with SCR.NS==1. If TrustZone is enabled
+        * then it should be handled by the secure code. The CPU must implement
+        * the virtualization extensions.
+        */
+       cps     #MON_MODE
+       mrc     p15, 0, r1, c1, c1, 0           /* Get Secure Config */
+       orr     r0, r1, #1
+       mcr     p15, 0, r0, c1, c1, 0           /* Set Non Secure bit */
+       isb
+       mov     r0, #0
+       mcrr    p15, 4, r0, r0, c14             /* CNTVOFF = 0 */
+       isb
+       mcr     p15, 0, r1, c1, c1, 0           /* Set Secure bit */
+       isb
+       cps     #SVC_MODE
+       ret     lr
+ENDPROC(secure_cntvoff_init)
index 8682b15336b915b9816eeaef4772016005b7778b..e4d188f0a4b498a8922f330c9e868d6e2bd66d3a 100644 (file)
@@ -64,6 +64,7 @@ CONFIG_BLK_DEV_SD=y
 CONFIG_SCSI_CONSTANTS=y
 CONFIG_SCSI_SCAN_ASYNC=y
 CONFIG_NETDEVICES=y
+CONFIG_USB_LAN78XX=y
 CONFIG_USB_USBNET=y
 CONFIG_USB_NET_SMSC95XX=y
 CONFIG_BRCMFMAC=m
@@ -127,6 +128,7 @@ CONFIG_LEDS_TRIGGER_CAMERA=y
 CONFIG_DMADEVICES=y
 CONFIG_DMA_BCM2835=y
 CONFIG_STAGING=y
+CONFIG_BCM2835_VCHIQ=m
 CONFIG_MAILBOX=y
 CONFIG_BCM2835_MBOX=y
 # CONFIG_IOMMU_SUPPORT is not set
index c302a04e8cbcba78a0abc3a7c0fb5621679c9d97..21b2d7791df444eec304e23381e77ab36a3a0214 100644 (file)
@@ -56,7 +56,7 @@ CONFIG_IP_PNP_DHCP=y
 CONFIG_NETFILTER=y
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
-# CONFIG_FW_LOADER is not set
+CONFIG_FW_LOADER=m
 CONFIG_DMA_CMA=y
 CONFIG_DA8XX_MSTPRI=y
 CONFIG_MTD=m
@@ -212,6 +212,8 @@ CONFIG_RTC_CLASS=y
 CONFIG_RTC_DRV_OMAP=m
 CONFIG_DMADEVICES=y
 CONFIG_TI_EDMA=y
+CONFIG_REMOTEPROC=m
+CONFIG_DA8XX_REMOTEPROC=m
 CONFIG_MEMORY=y
 CONFIG_TI_AEMIF=m
 CONFIG_DA8XX_DDRCTL=y
index 629189c62fd160b9bd85ac82c15ea62aeb291e12..85b2369d6b20def24de633021bb1ea9489a3765d 100644 (file)
@@ -208,6 +208,7 @@ CONFIG_DRM_EXYNOS_DSI=y
 CONFIG_DRM_EXYNOS_HDMI=y
 CONFIG_DRM_PANEL_SIMPLE=y
 CONFIG_DRM_PANEL_SAMSUNG_LD9040=y
+CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03=y
 CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0=y
 CONFIG_DRM_NXP_PTN3460=y
 CONFIG_DRM_PARADE_PS8622=y
index 3a308437b088bb23587ef5e2fb9da1d15b15f34e..f70507ab91eeb1b59a0857cb9e6f55ff2825fe9f 100644 (file)
@@ -38,6 +38,7 @@ CONFIG_SOC_IMX51=y
 CONFIG_SOC_IMX53=y
 CONFIG_SOC_IMX6Q=y
 CONFIG_SOC_IMX6SL=y
+CONFIG_SOC_IMX6SLL=y
 CONFIG_SOC_IMX6SX=y
 CONFIG_SOC_IMX6UL=y
 CONFIG_SOC_IMX7D=y
@@ -153,6 +154,9 @@ CONFIG_USB_RTL8152=m
 CONFIG_USB_USBNET=y
 CONFIG_USB_NET_CDC_EEM=m
 CONFIG_BRCMFMAC=m
+CONFIG_MWIFIEX=m
+CONFIG_MWIFIEX_SDIO=m
+CONFIG_MWIFIEX_PCIE=m
 CONFIG_WL12XX=m
 CONFIG_WL18XX=m
 CONFIG_WLCORE_SDIO=m
@@ -199,6 +203,7 @@ CONFIG_SPI_GPIO=y
 CONFIG_SPI_IMX=y
 CONFIG_SPI_FSL_DSPI=y
 CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_MAX732X=y
 CONFIG_GPIO_MC9S08DZ60=y
 CONFIG_GPIO_PCA953X=y
 CONFIG_GPIO_STMPE=y
@@ -214,11 +219,13 @@ CONFIG_CPU_THERMAL=y
 CONFIG_IMX_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_DA9062_WATCHDOG=y
+CONFIG_RN5T618_WATCHDOG=y
 CONFIG_IMX2_WDT=y
 CONFIG_MFD_DA9052_I2C=y
 CONFIG_MFD_DA9062=y
 CONFIG_MFD_MC13XXX_SPI=y
 CONFIG_MFD_MC13XXX_I2C=y
+CONFIG_MFD_RN5T618=y
 CONFIG_MFD_STMPE=y
 CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
@@ -229,6 +236,7 @@ CONFIG_REGULATOR_GPIO=y
 CONFIG_REGULATOR_MC13783=y
 CONFIG_REGULATOR_MC13892=y
 CONFIG_REGULATOR_PFUZE100=y
+CONFIG_REGULATOR_RN5T618=y
 CONFIG_RC_CORE=y
 CONFIG_RC_DEVICES=y
 CONFIG_IR_GPIO_CIR=y
@@ -374,6 +382,7 @@ CONFIG_PWM=y
 CONFIG_PWM_FSL_FTM=y
 CONFIG_PWM_IMX=y
 CONFIG_NVMEM_IMX_OCOTP=y
+CONFIG_NVMEM_VF610_OCOTP=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
 CONFIG_MUX_MMIO=y
index e6b3c96d4c0992b5458e72d2ddbf4811a6ca735d..7e1c543162c3ab16f11f6be6ccec5a16abae31d0 100644 (file)
@@ -90,6 +90,7 @@ CONFIG_ARCH_R8A73A4=y
 CONFIG_ARCH_R8A7740=y
 CONFIG_ARCH_R8A7743=y
 CONFIG_ARCH_R8A7745=y
+CONFIG_ARCH_R8A77470=y
 CONFIG_ARCH_R8A7778=y
 CONFIG_ARCH_R8A7779=y
 CONFIG_ARCH_R8A7790=y
@@ -187,6 +188,8 @@ CONFIG_B53_MMAP_DRIVER=m
 CONFIG_B53_SRAB_DRIVER=m
 CONFIG_CAN_SUN4I=y
 CONFIG_BT=m
+CONFIG_BT_HCIUART=m
+CONFIG_BT_HCIUART_BCM=y
 CONFIG_BT_MRVL=m
 CONFIG_BT_MRVL_SDIO=m
 CONFIG_CFG80211=m
@@ -280,6 +283,7 @@ CONFIG_FIXED_PHY=y
 CONFIG_ROCKCHIP_PHY=y
 CONFIG_USB_PEGASUS=y
 CONFIG_USB_RTL8152=m
+CONFIG_USB_LAN78XX=m
 CONFIG_USB_USBNET=y
 CONFIG_USB_NET_SMSC75XX=y
 CONFIG_USB_NET_SMSC95XX=y
@@ -360,10 +364,12 @@ CONFIG_SERIAL_ST_ASC=y
 CONFIG_SERIAL_ST_ASC_CONSOLE=y
 CONFIG_SERIAL_STM32=y
 CONFIG_SERIAL_STM32_CONSOLE=y
+CONFIG_SERIAL_DEV_BUS=y
 CONFIG_HVC_DRIVER=y
 CONFIG_VIRTIO_CONSOLE=y
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_DAVINCI=y
+CONFIG_I2C_MESON=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_ARB_GPIO_CHALLENGE=m
 CONFIG_I2C_MUX_PCA954x=y
@@ -385,6 +391,7 @@ CONFIG_I2C_S3C2410=y
 CONFIG_I2C_SH_MOBILE=y
 CONFIG_I2C_SIRF=y
 CONFIG_I2C_ST=y
+CONFIG_I2C_STM32F7=y
 CONFIG_I2C_SUN6I_P2WI=y
 CONFIG_I2C_TEGRA=y
 CONFIG_I2C_UNIPHIER=y
@@ -497,6 +504,7 @@ CONFIG_TEGRA_WATCHDOG=m
 CONFIG_MESON_WATCHDOG=y
 CONFIG_DW_WATCHDOG=y
 CONFIG_DIGICOLOR_WATCHDOG=y
+CONFIG_RENESAS_WDT=m
 CONFIG_BCM2835_WDT=y
 CONFIG_BCM47XX_WDT=y
 CONFIG_BCM7038_WDT=m
@@ -638,6 +646,7 @@ CONFIG_DRM_SUN4I=m
 CONFIG_DRM_FSL_DCU=m
 CONFIG_DRM_TEGRA=y
 CONFIG_DRM_PANEL_SAMSUNG_LD9040=m
+CONFIG_DRM_PANEL_SAMSUNG_S6E63J0X03=m
 CONFIG_DRM_PANEL_SAMSUNG_S6E8AA0=m
 CONFIG_DRM_PANEL_SIMPLE=y
 CONFIG_DRM_SII9234=m
@@ -650,7 +659,6 @@ CONFIG_FB_EFI=y
 CONFIG_FB_WM8505=y
 CONFIG_FB_SH_MOBILE_LCDC=y
 CONFIG_FB_SIMPLE=y
-CONFIG_FB_SH_MOBILE_MERAM=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 CONFIG_LCD_PLATFORM=m
@@ -947,6 +955,7 @@ CONFIG_PWM_ATMEL=m
 CONFIG_PWM_ATMEL_HLCDC_PWM=m
 CONFIG_PWM_ATMEL_TCB=m
 CONFIG_PWM_FSL_FTM=m
+CONFIG_PWM_MESON=m
 CONFIG_PWM_RCAR=m
 CONFIG_PWM_RENESAS_TPU=y
 CONFIG_PWM_ROCKCHIP=m
@@ -972,6 +981,7 @@ CONFIG_PHY_QCOM_APQ8064_SATA=m
 CONFIG_PHY_MIPHY28LP=y
 CONFIG_PHY_RCAR_GEN2=m
 CONFIG_PHY_STIH407_USB=y
+CONFIG_PHY_STM32_USBPHYC=y
 CONFIG_PHY_SUN4I_USB=y
 CONFIG_PHY_SUN9I_USB=y
 CONFIG_PHY_SAMSUNG_USB2=m
index a701601fbd7618f4b188296cf8210c652ccbad4d..b49887e86a3d82ead3f18aeed5bedd70494e0e0d 100644 (file)
@@ -14,6 +14,7 @@ CONFIG_ARCH_R8A73A4=y
 CONFIG_ARCH_R8A7740=y
 CONFIG_ARCH_R8A7743=y
 CONFIG_ARCH_R8A7745=y
+CONFIG_ARCH_R8A77470=y
 CONFIG_ARCH_R8A7778=y
 CONFIG_ARCH_R8A7779=y
 CONFIG_ARCH_R8A7790=y
@@ -127,6 +128,7 @@ CONFIG_CPU_THERMAL=y
 CONFIG_RCAR_THERMAL=y
 CONFIG_WATCHDOG=y
 CONFIG_DA9063_WATCHDOG=y
+CONFIG_RENESAS_WDT=y
 CONFIG_MFD_AS3711=y
 CONFIG_MFD_DA9063=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
@@ -156,7 +158,6 @@ CONFIG_DRM_DUMB_VGA_DAC=y
 CONFIG_DRM_I2C_ADV7511=y
 CONFIG_DRM_I2C_ADV7511_AUDIO=y
 CONFIG_FB_SH_MOBILE_LCDC=y
-CONFIG_FB_SH_MOBILE_MERAM=y
 # CONFIG_LCD_CLASS_DEVICE is not set
 # CONFIG_BACKLIGHT_GENERIC is not set
 CONFIG_BACKLIGHT_PWM=y
index 869080bedb89f031dd3295702cd1466c919a3113..ec1a5fd0d2948987cb1fbccf8b477cd82b16838e 100644 (file)
@@ -35,7 +35,7 @@
  *     Start addresses are inclusive and end addresses are exclusive;
  *     start addresses should be rounded down, end addresses up.
  *
- *     See Documentation/cachetlb.txt for more information.
+ *     See Documentation/core-api/cachetlb.rst for more information.
  *     Please note that the implementation of these, and the required
  *     effects are cache-type (VIVT/VIPT/PIPT) specific.
  *
index 26021980504db178d4efdfa8d8957b3a6c32ff82..0d289240b6ca110ab961a280ddd20fc1c567f2a4 100644 (file)
@@ -2,9 +2,6 @@
 #ifndef __ASM_ARM_CPUTYPE_H
 #define __ASM_ARM_CPUTYPE_H
 
-#include <linux/stringify.h>
-#include <linux/kernel.h>
-
 #define CPUID_ID       0
 #define CPUID_CACHETYPE        1
 #define CPUID_TCM      2
@@ -62,6 +59,7 @@
        ((mpidr >> (MPIDR_LEVEL_BITS * level)) & MPIDR_LEVEL_MASK)
 
 #define ARM_CPU_IMP_ARM                        0x41
+#define ARM_CPU_IMP_BRCM               0x42
 #define ARM_CPU_IMP_DEC                        0x44
 #define ARM_CPU_IMP_INTEL              0x69
 
@@ -84,8 +82,9 @@
 #define ARM_CPU_PART_CORTEX_A75                0x4100d0a0
 #define ARM_CPU_PART_MASK              0xff00fff0
 
-/* Broadcom cores */
+/* Broadcom implemented processors */
 #define ARM_CPU_PART_BRAHMA_B15                0x420000f0
+#define ARM_CPU_PART_BRAHMA_B53                0x42001000
 
 /* DEC implemented cores */
 #define ARM_CPU_PART_SA1100            0x4400a110
 /* Qualcomm implemented cores */
 #define ARM_CPU_PART_SCORPION          0x510002d0
 
+#ifndef __ASSEMBLY__
+
+#include <linux/stringify.h>
+#include <linux/kernel.h>
+
 extern unsigned int processor_id;
 
 #ifdef CONFIG_CPU_CP15
@@ -334,4 +338,6 @@ static inline int __attribute_const__ cpuid_feature_extract_field(u32 features,
 #define cpuid_feature_extract(reg, field) \
        cpuid_feature_extract_field(read_cpuid_ext(reg), field)
 
+#endif /* __ASSEMBLY__ */
+
 #endif
index 2d75e77bf7bb341d6e1d39a76351e0eee9390c39..1f1fe4109b026690ab80ca0d3e31355f77e78f04 100644 (file)
@@ -281,6 +281,7 @@ void kvm_mmu_wp_memory_region(struct kvm *kvm, int slot);
 
 struct kvm_vcpu *kvm_mpidr_to_vcpu(struct kvm *kvm, unsigned long mpidr);
 
+static inline bool kvm_arch_check_sve_has_vhe(void) { return true; }
 static inline void kvm_arch_hardware_unsetup(void) {}
 static inline void kvm_arch_sync_events(struct kvm *kvm) {}
 static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {}
@@ -304,8 +305,13 @@ int kvm_arm_vcpu_arch_get_attr(struct kvm_vcpu *vcpu,
 int kvm_arm_vcpu_arch_has_attr(struct kvm_vcpu *vcpu,
                               struct kvm_device_attr *attr);
 
-/* All host FP/SIMD state is restored on guest exit, so nothing to save: */
-static inline void kvm_fpsimd_flush_cpu_state(void) {}
+/*
+ * VFP/NEON switching is all done by the hyp switch code, so no need to
+ * coordinate with host context handling for this state:
+ */
+static inline void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu) {}
+static inline void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu) {}
+static inline void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu) {}
 
 static inline void kvm_arm_vhe_guest_enter(void) {}
 static inline void kvm_arm_vhe_guest_exit(void) {}
@@ -340,4 +346,8 @@ static inline int kvm_arm_have_ssbd(void)
 static inline void kvm_vcpu_load_sysregs(struct kvm_vcpu *vcpu) {}
 static inline void kvm_vcpu_put_sysregs(struct kvm_vcpu *vcpu) {}
 
+#define __KVM_HAVE_ARCH_VM_ALLOC
+struct kvm *kvm_arch_alloc_vm(void);
+void kvm_arch_free_vm(struct kvm *kvm);
+
 #endif /* __ARM_KVM_HOST_H__ */
diff --git a/arch/arm/include/asm/secure_cntvoff.h b/arch/arm/include/asm/secure_cntvoff.h
new file mode 100644 (file)
index 0000000..1f93aee
--- /dev/null
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ASMARM_ARCH_CNTVOFF_H
+#define __ASMARM_ARCH_CNTVOFF_H
+
+extern void secure_cntvoff_init(void);
+
+#endif
index c826f15d2f80382e160633bbc82f4d3a02f9b8fb..0f580caa81e51abcf51216577ee96ece658d3b7e 100644 (file)
  * GNU General Public License for more details.
  */
 #include <linux/serial_reg.h>
+#include <asm/cputype.h>
 
 /* Physical register offset and virtual register offset */
 #define REG_PHYS_BASE          0xf0000000
+#define REG_PHYS_BASE_V7       0x08000000
 #define REG_VIRT_BASE          0xfc000000
 #define REG_PHYS_ADDR(x)       ((x) + REG_PHYS_BASE)
+#define REG_PHYS_ADDR_V7(x)    ((x) + REG_PHYS_BASE_V7)
 
 /* Product id can be read from here */
 #define SUN_TOP_CTRL_BASE      REG_PHYS_ADDR(0x404000)
+#define SUN_TOP_CTRL_BASE_V7   REG_PHYS_ADDR_V7(0x404000)
 
 #define UARTA_3390             REG_PHYS_ADDR(0x40a900)
 #define UARTA_7250             REG_PHYS_ADDR(0x40b400)
 #define UARTA_7260             REG_PHYS_ADDR(0x40c000)
 #define UARTA_7268             UARTA_7260
 #define UARTA_7271             UARTA_7268
+#define UARTA_7278             REG_PHYS_ADDR_V7(0x40c000)
 #define UARTA_7364             REG_PHYS_ADDR(0x40b000)
 #define UARTA_7366             UARTA_7364
 #define UARTA_74371            REG_PHYS_ADDR(0x406b00)
                mov     \rv, #0                 @ yes; record init is done
                str     \rv, [\tmp]
 
+               /* Check for V7 memory map if B53 */
+               mrc     p15, 0, \rv, c0, c0, 0  @ get Main ID register
+               ldr     \rp, =ARM_CPU_PART_MASK
+               and     \rv, \rv, \rp
+               ldr     \rp, =ARM_CPU_PART_BRAHMA_B53   @ check for B53 CPU
+               cmp     \rv, \rp
+               bne     10f
+
+               /* if PERIPHBASE doesn't overlap REG_PHYS_BASE use V7 map */
+               mrc     p15, 1, \rv, c15, c3, 0 @ get PERIPHBASE from CBAR
+               ands    \rv, \rv, #REG_PHYS_BASE
+               ldreq   \rp, =SUN_TOP_CTRL_BASE_V7
+
                /* Check SUN_TOP_CTRL base */
-               ldr     \rp, =SUN_TOP_CTRL_BASE @ load SUN_TOP_CTRL PA
+10:            ldrne   \rp, =SUN_TOP_CTRL_BASE @ load SUN_TOP_CTRL PA
                ldr     \rv, [\rp, #0]          @ get register contents
 ARM_BE8(       rev     \rv, \rv )
                and     \rv, \rv, #0xffffff00   @ strip revision bits [7:0]
@@ -72,6 +90,7 @@ ARM_BE8(      rev     \rv, \rv )
 27:            checkuart(\rp, \rv, 0x07437100, 74371)
 28:            checkuart(\rp, \rv, 0x74390000, 7439)
 29:            checkuart(\rp, \rv, 0x74450000, 7445)
+30:            checkuart(\rp, \rv, 0x72780000, 7278)
 
                /* No valid UART found */
 90:            mov     \rp, #0
index caae4843cb7001fbee1fa9b222850df7006850fb..16e006f708ca0cbd44a63135bb996b8db7c3ba9e 100644 (file)
@@ -91,6 +91,7 @@ struct kvm_regs {
 #define KVM_VGIC_V3_ADDR_TYPE_DIST     2
 #define KVM_VGIC_V3_ADDR_TYPE_REDIST   3
 #define KVM_VGIC_ITS_ADDR_TYPE         4
+#define KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION    5
 
 #define KVM_VGIC_V3_DIST_SIZE          SZ_64K
 #define KVM_VGIC_V3_REDIST_SIZE                (2 * SZ_64K)
index 27c5381518d8878d664fd3e9575b3f0aaf963417..974d8d7d1bcdd2a68e101296a4fd9649cb4cebe9 100644 (file)
@@ -61,7 +61,7 @@
 int main(void)
 {
   DEFINE(TSK_ACTIVE_MM,                offsetof(struct task_struct, active_mm));
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
   DEFINE(TSK_STACK_CANARY,     offsetof(struct task_struct, stack_canary));
 #endif
   BLANK();
index 1752033b00700c780666352d6b256f5d36396d28..179a9f6bd1e31c63564fd3e67444d41916939617 100644 (file)
@@ -791,7 +791,7 @@ ENTRY(__switch_to)
        ldr     r6, [r2, #TI_CPU_DOMAIN]
 #endif
        switch_tls r1, r4, r5, r3, r7
-#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
+#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
        ldr     r7, [r2, #TI_TASK]
        ldr     r8, =__stack_chk_guard
        .if (TSK_STACK_CANARY > IMM12_MASK)
@@ -807,7 +807,7 @@ ENTRY(__switch_to)
        ldr     r0, =thread_notify_head
        mov     r1, #THREAD_NOTIFY_SWITCH
        bl      atomic_notifier_call_chain
-#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
+#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
        str     r7, [r8]
 #endif
  THUMB(        mov     ip, r4                     )
index 1523cb18b10994dd3ba186de0da5aff6dc5762be..225d1c58d2de98d5c4a92de4905052203f1e25b6 100644 (file)
@@ -39,7 +39,7 @@
 #include <asm/tls.h>
 #include <asm/vdso.h>
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 #include <linux/stackprotector.h>
 unsigned long __stack_chk_guard __read_mostly;
 EXPORT_SYMBOL(__stack_chk_guard);
index b9786f491873fae6a2f448e85b3fd76eb7511665..1df21a61e379e1a0fe66e784c7a1212814b100da 100644 (file)
@@ -286,7 +286,7 @@ asmlinkage long sys_oabi_epoll_wait(int epfd,
                return -EINVAL;
        if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents))
                return -EFAULT;
-       kbuf = kmalloc(sizeof(*kbuf) * maxevents, GFP_KERNEL);
+       kbuf = kmalloc_array(maxevents, sizeof(*kbuf), GFP_KERNEL);
        if (!kbuf)
                return -ENOMEM;
        fs = get_fs();
@@ -324,7 +324,7 @@ asmlinkage long sys_oabi_semtimedop(int semid,
                return -EINVAL;
        if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops))
                return -EFAULT;
-       sops = kmalloc(sizeof(*sops) * nsops, GFP_KERNEL);
+       sops = kmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
        if (!sops)
                return -ENOMEM;
        err = 0;
index 7fc0638f263ac975dc3a4bddd0c1ec00adc2348f..d2b5ec9c4b9293758626d35ce49b6ba226140b73 100644 (file)
@@ -23,3 +23,11 @@ obj-$(CONFIG_KVM_ARM_HOST) += hyp-entry.o
 obj-$(CONFIG_KVM_ARM_HOST) += switch.o
 CFLAGS_switch.o                   += $(CFLAGS_ARMV7VE)
 obj-$(CONFIG_KVM_ARM_HOST) += s2-setup.o
+
+# KVM code is run at a different exception code with a different map, so
+# compiler instrumentation that inserts callbacks or checks into the code may
+# cause crashes. Just disable it.
+GCOV_PROFILE   := n
+KASAN_SANITIZE := n
+UBSAN_SANITIZE := n
+KCOV_INSTRUMENT        := n
index 63ab1d36862518ccdc248e0170f568a54306a0d9..3d719cf645e3171729bd59e704d543401840b4bd 100644 (file)
@@ -23,8 +23,12 @@ config MACH_BERLIN_BG2
 
 config MACH_BERLIN_BG2CD
        bool "Marvell Armada 1500-mini (BG2CD)"
+       select ARM_ERRATA_754322
+       select ARM_ERRATA_775420
+       select ARM_GLOBAL_TIMER
        select CACHE_L2X0
-       select HAVE_ARM_TWD if SMP
+       select HAVE_ARM_SCU
+       select HAVE_ARM_TWD
        select PINCTRL_BERLIN_BG2CD
 
 config MACH_BERLIN_BG2Q
index ac181c6797ee5784c2f64d80ea1b1f4b2d0fc3b1..2424ad40190c257227d18511ff63c23c5debc446 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Device Tree support for Marvell Berlin SoCs.
  *
@@ -5,10 +6,6 @@
  *
  * based on GPL'ed 2.6 kernel sources
  *  (c) Marvell International Ltd.
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2.  This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
  */
 
 #include <linux/init.h>
index dc82a3486b05e6b208c37fe8f93707d9388b06db..3057885d97728f6896409f62ddb93cb64378962d 100644 (file)
@@ -1,11 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (C) 2014 Marvell Technology Group Ltd.
  *
  * Antoine Ténart <antoine.tenart@free-electrons.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
  */
 
 #include <linux/linkage.h>
index 7586b7aec272c0c5b3786d166d026c4f96af4afd..593fc4a69d8442527b222ded1ffedcd760dda670 100644 (file)
@@ -1,11 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2014 Marvell Technology Group Ltd.
  *
  * Antoine Ténart <antoine.tenart@free-electrons.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
  */
 
 #include <linux/io.h>
@@ -81,7 +78,6 @@ static void __init berlin_smp_prepare_cpus(unsigned int max_cpus)
                goto unmap_scu;
 
        scu_enable(scu_base);
-       flush_cache_all();
 
        /*
         * Write the first instruction the CPU will execute after being reset
index ff8b7e76b6e961f9493e8b070db8d249359d58fa..e4ab3f3a2a1f12123a553a96e2f7fc6c963cb787 100644 (file)
@@ -189,7 +189,7 @@ int davinci_aemif_setup(struct platform_device *pdev)
         * Setup Async configuration register in case we did not boot
         * from NAND and so bootloader did not bother to set it up.
         */
-       val = davinci_aemif_readl(base, A1CR_OFFSET + pdev->id * 4);
+       val = davinci_aemif_readl(base, A1CR_OFFSET + pdata->core_chipsel * 4);
        /*
         * Extended Wait is not valid and Select Strobe mode is not
         * used
@@ -198,13 +198,13 @@ int davinci_aemif_setup(struct platform_device *pdev)
        if (pdata->options & NAND_BUSWIDTH_16)
                val |= 0x1;
 
-       davinci_aemif_writel(base, A1CR_OFFSET + pdev->id * 4, val);
+       davinci_aemif_writel(base, A1CR_OFFSET + pdata->core_chipsel * 4, val);
 
        clkrate = clk_get_rate(clk);
 
        if (pdata->timing)
-               ret = davinci_aemif_setup_timing(pdata->timing, base, pdev->id,
-                                                clkrate);
+               ret = davinci_aemif_setup_timing(pdata->timing, base,
+                                                pdata->core_chipsel, clkrate);
 
        if (ret < 0)
                dev_dbg(&pdev->dev, "NAND timing values setup fail\n");
index d1e8ce7b4bd21245d41901709041c113f95f344d..14a6fc06174499ba031e4868add99aac34083d2f 100644 (file)
@@ -315,6 +315,7 @@ static struct davinci_aemif_timing da830_evm_nandflash_timing = {
 };
 
 static struct davinci_nand_pdata da830_evm_nand_pdata = {
+       .core_chipsel   = 1,
        .parts          = da830_evm_nand_partitions,
        .nr_parts       = ARRAY_SIZE(da830_evm_nand_partitions),
        .ecc_mode       = NAND_ECC_HW,
index 158ed9a1483fc87582d66de2746620590f800dd5..e22fb40e34bc55be6dd807de63fb9cd009107916 100644 (file)
@@ -244,6 +244,7 @@ static struct davinci_aemif_timing da850_evm_nandflash_timing = {
 };
 
 static struct davinci_nand_pdata da850_evm_nandflash_data = {
+       .core_chipsel   = 1,
        .parts          = da850_evm_nandflash_partition,
        .nr_parts       = ARRAY_SIZE(da850_evm_nandflash_partition),
        .ecc_mode       = NAND_ECC_HW,
index 23ab9e8bc04c0e3b37d7a940d23755d1e48a2c80..a3377f95944489ed9051279bccb5a0cc392bba73 100644 (file)
@@ -78,6 +78,7 @@ static struct mtd_partition davinci_nand_partitions[] = {
 };
 
 static struct davinci_nand_pdata davinci_nand_data = {
+       .core_chipsel           = 0,
        .mask_chipsel           = BIT(14),
        .parts                  = davinci_nand_partitions,
        .nr_parts               = ARRAY_SIZE(davinci_nand_partitions),
index 59743bd76793b2ded206afc18925675a7bf431ab..8249a0bf69f0426d9ceed1b65a29064b2378dcb2 100644 (file)
@@ -72,6 +72,7 @@ static struct mtd_partition davinci_nand_partitions[] = {
 };
 
 static struct davinci_nand_pdata davinci_nand_data = {
+       .core_chipsel           = 0,
        .mask_chipsel           = BIT(14),
        .parts                  = davinci_nand_partitions,
        .nr_parts               = ARRAY_SIZE(davinci_nand_partitions),
index 0ac085b58a2ba31a3dc24467eb40913bf6712765..435f7ec7d9afa92b4f35a39d7fd365a04b436624 100644 (file)
@@ -138,6 +138,7 @@ static struct mtd_partition davinci_nand_partitions[] = {
 };
 
 static struct davinci_nand_pdata davinci_nand_data = {
+       .core_chipsel           = 0,
        .mask_chipsel           = BIT(14),
        .parts                  = davinci_nand_partitions,
        .nr_parts               = ARRAY_SIZE(davinci_nand_partitions),
index 509e64ab1994ac3b0c5d94e1144772fd93d99465..48436f74fd7108bdc984a0c5af7c9be14e808369 100644 (file)
@@ -153,6 +153,7 @@ static struct davinci_aemif_timing davinci_evm_nandflash_timing = {
 };
 
 static struct davinci_nand_pdata davinci_evm_nandflash_data = {
+       .core_chipsel   = 0,
        .parts          = davinci_evm_nandflash_partition,
        .nr_parts       = ARRAY_SIZE(davinci_evm_nandflash_partition),
        .ecc_mode       = NAND_ECC_HW,
@@ -772,6 +773,8 @@ static __init void davinci_evm_init(void)
        struct clk *aemif_clk;
        struct davinci_soc_info *soc_info = &davinci_soc_info;
 
+       dm644x_init_devices();
+
        ret = dm644x_gpio_register();
        if (ret)
                pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
index a3c0d1e87647847605cfdaca2ac26f5c05aa8894..584064fdabf5bbb6466f7f19e7d686199258e542 100644 (file)
@@ -84,6 +84,7 @@ static struct davinci_aemif_timing dm6467tevm_nandflash_timing = {
 };
 
 static struct davinci_nand_pdata davinci_nand_data = {
+       .core_chipsel           = 0,
        .mask_cle               = 0x80000,
        .mask_ale               = 0x40000,
        .parts                  = davinci_nand_partitions,
index d1c85484c2e24d559bf37719ac436bf81c0f3b9a..37b3e48a21d1b6d37741857dfbe170af5e2be7b8 100644 (file)
@@ -400,6 +400,7 @@ static struct mtd_partition mityomapl138_nandflash_partition[] = {
 };
 
 static struct davinci_nand_pdata mityomapl138_nandflash_data = {
+       .core_chipsel   = 1,
        .parts          = mityomapl138_nandflash_partition,
        .nr_parts       = ARRAY_SIZE(mityomapl138_nandflash_partition),
        .ecc_mode       = NAND_ECC_HW,
index f2875770fbff64f5a9ec4dfcdaa9a27290a481b0..25ad9b0612bee50024f5c35fa1b62f15c134bf56 100644 (file)
@@ -87,6 +87,7 @@ static struct mtd_partition davinci_ntosd2_nandflash_partition[] = {
 };
 
 static struct davinci_nand_pdata davinci_ntosd2_nandflash_data = {
+       .core_chipsel   = 0,
        .parts          = davinci_ntosd2_nandflash_partition,
        .nr_parts       = ARRAY_SIZE(davinci_ntosd2_nandflash_partition),
        .ecc_mode       = NAND_ECC_HW,
@@ -174,6 +175,8 @@ static __init void davinci_ntosd2_init(void)
        struct clk *aemif_clk;
        struct davinci_soc_info *soc_info = &davinci_soc_info;
 
+       dm644x_init_devices();
+
        ret = dm644x_gpio_register();
        if (ret)
                pr_warn("%s: GPIO init failed: %d\n", __func__, ret);
index 2922da9d1684304cfb8b3d606f86b3420b174224..e7c1728b0833a0b791de802866a3ef7578955c67 100644 (file)
@@ -134,6 +134,8 @@ static __init void davinci_sffsdr_init(void)
 {
        struct davinci_soc_info *soc_info = &davinci_soc_info;
 
+       dm644x_init_devices();
+
        platform_add_devices(davinci_sffsdr_devices,
                             ARRAY_SIZE(davinci_sffsdr_devices));
        sffsdr_init_i2c();
index 270cef85750a76fcc5262211089faecdf48cc543..376cdd51ce9d7beb89a5551f4abbe0e501db52b3 100644 (file)
@@ -104,6 +104,7 @@ int dm365_gpio_register(void);
 
 /* DM644x function declarations */
 void dm644x_init(void);
+void dm644x_init_devices(void);
 void dm644x_init_time(void);
 void dm644x_init_asp(void);
 int dm644x_init_video(struct vpfe_config *, struct vpbe_config *);
index b409801649e1f2e4ea25788f1bdcb0ae3fa18fe8..a2e8586c8a6d57229d27665393fa74f26463145d 100644 (file)
@@ -961,19 +961,14 @@ int __init dm644x_init_video(struct vpfe_config *vpfe_cfg,
        return 0;
 }
 
-static int __init dm644x_init_devices(void)
+void __init dm644x_init_devices(void)
 {
        struct platform_device *edma_pdev;
-       int ret = 0;
-
-       if (!cpu_is_davinci_dm644x())
-               return 0;
+       int ret;
 
        edma_pdev = platform_device_register_full(&dm644x_edma_device);
-       if (IS_ERR(edma_pdev)) {
+       if (IS_ERR(edma_pdev))
                pr_warn("%s: Failed to register eDMA\n", __func__);
-               return PTR_ERR(edma_pdev);
-       }
 
        platform_device_register(&dm644x_mdio_device);
        platform_device_register(&dm644x_emac_device);
@@ -982,6 +977,4 @@ static int __init dm644x_init_devices(void)
        if (ret)
                pr_warn("%s: watchdog init failed: %d\n", __func__, ret);
 
-       return ret;
 }
-postcore_initcall(dm644x_init_devices);
index 2ca40581684685b76b424a8487b33954f7e61bb4..b40963cf91c77d211f5b25cddaf3565f2832e85d 100644 (file)
@@ -8,7 +8,6 @@
 menuconfig ARCH_EXYNOS
        bool "Samsung EXYNOS"
        depends on ARCH_MULTI_V7
-       select ARCH_HAS_BANDGAP
        select ARCH_HAS_HOLES_MEMORYMODEL
        select ARCH_SUPPORTS_BIG_ENDIAN
        select ARM_AMBA
@@ -108,17 +107,6 @@ config SOC_EXYNOS5420
        default y
        depends on ARCH_EXYNOS5
 
-config SOC_EXYNOS5440
-       bool "SAMSUNG EXYNOS5440"
-       default y
-       depends on ARCH_EXYNOS5
-       select HAVE_ARM_ARCH_TIMER
-       select AUTO_ZRELADDR
-       select PINCTRL_EXYNOS5440
-       select PM_OPP
-       help
-         Enable EXYNOS5440 SoC support
-
 config SOC_EXYNOS5800
        bool "SAMSUNG EXYNOS5800"
        default y
index 098f84a149a3cb2d7344fd277b725599c2759812..dcd21bb95e3b9cc7fc705ecbcc8d007d9fb9dd28 100644 (file)
@@ -21,7 +21,6 @@
 #define EXYNOS5250_SOC_ID      0x43520000
 #define EXYNOS5410_SOC_ID      0xE5410000
 #define EXYNOS5420_SOC_ID      0xE5420000
-#define EXYNOS5440_SOC_ID      0xE5440000
 #define EXYNOS5800_SOC_ID      0xE5422000
 #define EXYNOS5_SOC_MASK       0xFFFFF000
 
@@ -39,7 +38,6 @@ IS_SAMSUNG_CPU(exynos4412, EXYNOS4412_CPU_ID, EXYNOS4_CPU_MASK)
 IS_SAMSUNG_CPU(exynos5250, EXYNOS5250_SOC_ID, EXYNOS5_SOC_MASK)
 IS_SAMSUNG_CPU(exynos5410, EXYNOS5410_SOC_ID, EXYNOS5_SOC_MASK)
 IS_SAMSUNG_CPU(exynos5420, EXYNOS5420_SOC_ID, EXYNOS5_SOC_MASK)
-IS_SAMSUNG_CPU(exynos5440, EXYNOS5440_SOC_ID, EXYNOS5_SOC_MASK)
 IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK)
 
 #if defined(CONFIG_SOC_EXYNOS3250)
@@ -82,22 +80,12 @@ IS_SAMSUNG_CPU(exynos5800, EXYNOS5800_SOC_ID, EXYNOS5_SOC_MASK)
 # define soc_is_exynos5420()   0
 #endif
 
-#if defined(CONFIG_SOC_EXYNOS5440)
-# define soc_is_exynos5440()   is_samsung_exynos5440()
-#else
-# define soc_is_exynos5440()   0
-#endif
-
 #if defined(CONFIG_SOC_EXYNOS5800)
 # define soc_is_exynos5800()   is_samsung_exynos5800()
 #else
 # define soc_is_exynos5800()   0
 #endif
 
-#define soc_is_exynos4() (soc_is_exynos4210() || soc_is_exynos4412())
-#define soc_is_exynos5() (soc_is_exynos5250() || soc_is_exynos5410() || \
-                         soc_is_exynos5420() || soc_is_exynos5800())
-
 extern u32 cp15_save_diag;
 extern u32 cp15_save_power;
 
@@ -149,6 +137,11 @@ extern void exynos_cpu_restore_register(void);
 extern void exynos_pm_central_suspend(void);
 extern int exynos_pm_central_resume(void);
 extern void exynos_enter_aftr(void);
+#ifdef CONFIG_SMP
+extern void exynos_scu_enable(void);
+#else
+static inline void exynos_scu_enable(void) { }
+#endif
 
 extern struct cpuidle_exynos_data cpuidle_coupled_exynos_data;
 
index 8c4f5e342dc1af0cc26ed949a4c3c85c60b429c0..f4b6c93a7fd07fdc289d486e09c2f331ecfb5d21 100644 (file)
 
 #include "common.h"
 
-static struct map_desc exynos4_iodesc[] __initdata = {
-       {
-               .virtual        = (unsigned long)S5P_VA_COREPERI_BASE,
-               .pfn            = __phys_to_pfn(EXYNOS4_PA_COREPERI),
-               .length         = SZ_8K,
-               .type           = MT_DEVICE,
-       },
-};
-
 static struct platform_device exynos_cpuidle = {
        .name              = "exynos_cpuidle",
 #ifdef CONFIG_ARM_EXYNOS_CPUIDLE
@@ -63,15 +54,6 @@ void __init exynos_sysram_init(void)
        }
 }
 
-static void __init exynos_init_late(void)
-{
-       if (of_machine_is_compatible("samsung,exynos5440"))
-               /* to be supported later */
-               return;
-
-       exynos_pm_init();
-}
-
 static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname,
                                        int depth, void *data)
 {
@@ -79,8 +61,7 @@ static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname,
        const __be32 *reg;
        int len;
 
-       if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid") &&
-               !of_flat_dt_is_compatible(node, "samsung,exynos5440-clock"))
+       if (!of_flat_dt_is_compatible(node, "samsung,exynos4210-chipid"))
                return 0;
 
        reg = of_get_flat_dt_prop(node, "reg", &len);
@@ -95,17 +76,6 @@ static int __init exynos_fdt_map_chipid(unsigned long node, const char *uname,
        return 1;
 }
 
-/*
- * exynos_map_io
- *
- * register the standard cpu IO areas
- */
-static void __init exynos_map_io(void)
-{
-       if (soc_is_exynos4())
-               iotable_init(exynos4_iodesc, ARRAY_SIZE(exynos4_iodesc));
-}
-
 static void __init exynos_init_io(void)
 {
        debug_ll_io_init();
@@ -114,8 +84,6 @@ static void __init exynos_init_io(void)
 
        /* detect cpu id and rev. */
        s5p_init_cpu(S5P_VA_CHIPID);
-
-       exynos_map_io();
 }
 
 /*
@@ -209,7 +177,6 @@ static char const *const exynos_dt_compat[] __initconst = {
        "samsung,exynos5250",
        "samsung,exynos5260",
        "samsung,exynos5420",
-       "samsung,exynos5440",
        NULL
 };
 
@@ -232,7 +199,7 @@ DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)")
        .init_early     = exynos_firmware_init,
        .init_irq       = exynos_init_irq,
        .init_machine   = exynos_dt_machine_init,
-       .init_late      = exynos_init_late,
+       .init_late      = exynos_pm_init,
        .dt_compat      = exynos_dt_compat,
        .dt_fixup       = exynos_dt_fixup,
 MACHINE_END
index 37a5ea5e2602a3c7ac81fc18276bb5e6c2b48229..22ebe36546330c25a85112ce867e047ad28595cc 100644 (file)
@@ -15,6 +15,4 @@
 
 #define EXYNOS_PA_CHIPID               0x10000000
 
-#define EXYNOS4_PA_COREPERI            0x10500000
-
 #endif /* __ASM_ARCH_MAP_H */
index 5156fe70e030579cf2b707fd755f70133a63926d..6a1e682371b32c400041fb2aa0db1698a19a63d3 100644 (file)
@@ -163,6 +163,26 @@ int exynos_cluster_power_state(int cluster)
                S5P_CORE_LOCAL_PWR_EN);
 }
 
+/**
+ * exynos_scu_enable : enables SCU for Cortex-A9 based system
+ */
+void exynos_scu_enable(void)
+{
+       struct device_node *np;
+       static void __iomem *scu_base;
+
+       if (!scu_base) {
+               np = of_find_compatible_node(NULL, NULL, "arm,cortex-a9-scu");
+               if (np) {
+                       scu_base = of_iomap(np, 0);
+                       of_node_put(np);
+               } else {
+                       scu_base = ioremap(scu_a9_get_base(), SZ_4K);
+               }
+       }
+       scu_enable(scu_base);
+}
+
 static void __iomem *cpu_boot_reg_base(void)
 {
        if (soc_is_exynos4210() && samsung_rev() == EXYNOS4210_REV_1_1)
@@ -219,11 +239,6 @@ static void write_pen_release(int val)
        sync_cache_w(&pen_release);
 }
 
-static void __iomem *scu_base_addr(void)
-{
-       return (void __iomem *)(S5P_VA_SCU);
-}
-
 static DEFINE_SPINLOCK(boot_lock);
 
 static void exynos_secondary_init(unsigned int cpu)
@@ -389,7 +404,7 @@ static void __init exynos_smp_prepare_cpus(unsigned int max_cpus)
        exynos_set_delayed_reset_assertion(true);
 
        if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9)
-               scu_enable(scu_base_addr());
+               exynos_scu_enable();
 
        /*
         * Write the address of secondary startup into the
index a822c507371545bc19b0a7e78adc7b7d10c196cc..48e7fb38613ebcd079bfdea7d45e27bc2501b812 100644 (file)
@@ -22,8 +22,6 @@
 #include <asm/suspend.h>
 #include <asm/cacheflush.h>
 
-#include <mach/map.h>
-
 #include "common.h"
 
 static inline void __iomem *exynos_boot_vector_addr(void)
@@ -172,7 +170,7 @@ void exynos_enter_aftr(void)
        cpu_suspend(0, exynos_aftr_finisher);
 
        if (read_cpuid_part() == ARM_CPU_PART_CORTEX_A9) {
-               scu_enable(S5P_VA_SCU);
+               exynos_scu_enable();
                if (call_firmware_op(resume) == -ENOSYS)
                        exynos_cpu_restore_register();
        }
index c2ed997fedefacc2052e950664ffa272d71cf334..d3db306a5a709a82dad9852ace9b83deca2fb1e9 100644 (file)
@@ -30,8 +30,6 @@
 #include <asm/smp_scu.h>
 #include <asm/suspend.h>
 
-#include <mach/map.h>
-
 #include <plat/pm-common.h>
 
 #include "common.h"
@@ -401,7 +399,7 @@ static void exynos_pm_resume(void)
                goto early_wakeup;
 
        if (cpuid == ARM_CPU_PART_CORTEX_A9)
-               scu_enable(S5P_VA_SCU);
+               exynos_scu_enable();
 
        if (call_firmware_op(resume) == -ENOSYS
            && cpuid == ARM_CPU_PART_CORTEX_A9)
index e7b350f18f5f82b993f36e5f1f258c3e58836c16..16d71bac0061b34d0257f0d226dcdb1886fc49f8 100644 (file)
@@ -252,7 +252,7 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
        if (nr || !footbridge_cfn_mode())
                return 0;
 
-       res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+       res = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
        if (!res) {
                printk("out of memory for root bus resources");
                return 0;
index e47fa13f4b0cc9ce02797f6afa0955d71f15d21c..6f423238477477c2720d4cb042305016f0676fb9 100644 (file)
@@ -501,6 +501,7 @@ config SOC_IMX6SL
 
 config SOC_IMX6SLL
        bool "i.MX6 SoloLiteLite support"
+       select PINCTRL_IMX6SLL
        select SOC_IMX6
 
        help
index 68c3f0799d5bbab62ce2cb9b94788014e6998800..9d87f1dcf7bbc8cea73b30e571ec131793b41b9c 100644 (file)
@@ -374,26 +374,12 @@ static struct imx_ssi_platform_data mx31_3ds_ssi_pdata = {
 };
 
 /* SPI */
-static int spi0_internal_chipselect[] = {
-       MXC_SPI_CS(0),
-       MXC_SPI_CS(1),
-       MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master spi0_pdata __initconst = {
-       .chipselect     = spi0_internal_chipselect,
-       .num_chipselect = ARRAY_SIZE(spi0_internal_chipselect),
-};
-
-static int spi1_internal_chipselect[] = {
-       MXC_SPI_CS(0),
-       MXC_SPI_CS(1),
-       MXC_SPI_CS(2),
+       .num_chipselect = 3,
 };
 
 static const struct spi_imx_master spi1_pdata __initconst = {
-       .chipselect     = spi1_internal_chipselect,
-       .num_chipselect = ARRAY_SIZE(spi1_internal_chipselect),
+       .num_chipselect = 3,
 };
 
 static struct spi_board_info mx31_3ds_spi_devs[] __initdata = {
index 6fd463642954a404e60cfb9526e2041360008260..8bf52819d4d9885cdf842a4d1b0b4ab2f6526846 100644 (file)
@@ -226,20 +226,12 @@ static void __init lilly1131_usb_init(void)
 
 /* SPI */
 
-static int spi_internal_chipselect[] = {
-       MXC_SPI_CS(0),
-       MXC_SPI_CS(1),
-       MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master spi0_pdata __initconst = {
-       .chipselect = spi_internal_chipselect,
-       .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
+       .num_chipselect = 3,
 };
 
 static const struct spi_imx_master spi1_pdata __initconst = {
-       .chipselect = spi_internal_chipselect,
-       .num_chipselect = ARRAY_SIZE(spi_internal_chipselect),
+       .num_chipselect = 3,
 };
 
 static struct mc13xxx_platform_data mc13783_pdata __initdata = {
index a3250bc7f1148fc59c11f3c378051ad950dc253b..a3cbba6c955bd0168b9e18c8bf92987e5a053653 100644 (file)
@@ -83,15 +83,8 @@ static const struct imxuart_platform_data uart_pdata __initconst = {
 };
 
 /* SPI */
-static int spi0_internal_chipselect[] = {
-       MXC_SPI_CS(0),
-       MXC_SPI_CS(1),
-       MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master spi0_pdata __initconst = {
-       .chipselect     = spi0_internal_chipselect,
-       .num_chipselect = ARRAY_SIZE(spi0_internal_chipselect),
+       .num_chipselect = 3,
 };
 
 static const struct mxc_nand_platform_data
@@ -133,13 +126,8 @@ static struct platform_device smsc911x_device = {
  * The MC13783 is the only hard-wired SPI device on the module.
  */
 
-static int spi1_internal_chipselect[] = {
-       MXC_SPI_CS(0),
-};
-
 static const struct spi_imx_master spi1_pdata __initconst = {
-       .chipselect     = spi1_internal_chipselect,
-       .num_chipselect = ARRAY_SIZE(spi1_internal_chipselect),
+       .num_chipselect = 1,
 };
 
 static struct mc13xxx_platform_data mc13783_pdata __initdata = {
index 7716f83aecdda1d5f6a35677d40d9446b5d8a0cf..643a3d74970364985366e613ecc2ca9dc6773adc 100644 (file)
@@ -152,14 +152,8 @@ static const struct imxi2c_platform_data moboard_i2c1_data __initconst = {
        .bitrate = 100000,
 };
 
-static int moboard_spi1_cs[] = {
-       MXC_SPI_CS(0),
-       MXC_SPI_CS(2),
-};
-
 static const struct spi_imx_master moboard_spi1_pdata __initconst = {
-       .chipselect     = moboard_spi1_cs,
-       .num_chipselect = ARRAY_SIZE(moboard_spi1_cs),
+       .num_chipselect = 3,
 };
 
 static struct regulator_consumer_supply sdhc_consumers[] = {
@@ -296,19 +290,14 @@ static struct spi_board_info moboard_spi_board_info[] __initdata = {
                /* irq number is run-time assigned */
                .max_speed_hz = 300000,
                .bus_num = 1,
-               .chip_select = 1,
+               .chip_select = 0,
                .platform_data = &moboard_pmic,
                .mode = SPI_CS_HIGH,
        },
 };
 
-static int moboard_spi2_cs[] = {
-       MXC_SPI_CS(0), MXC_SPI_CS(1),
-};
-
 static const struct spi_imx_master moboard_spi2_pdata __initconst = {
-       .chipselect     = moboard_spi2_cs,
-       .num_chipselect = ARRAY_SIZE(moboard_spi2_cs),
+       .num_chipselect = 2,
 };
 
 #define SDHC1_CD IOMUX_TO_GPIO(MX31_PIN_ATA_CS0)
index ed675863655b7115df6ce911d40f6c7022918c37..5714e2f1b10621a0df1bd8294ce0ef374ec01726 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/platform_device.h>
 #include <linux/io.h>
 #include <linux/i2c.h>
-#include <linux/platform_data/at24.h>
+#include <linux/property.h>
 #include <linux/dma-mapping.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/eeprom.h>
@@ -168,16 +168,15 @@ static const struct imxi2c_platform_data pca100_i2c1_data __initconst = {
        .bitrate = 100000,
 };
 
-static struct at24_platform_data board_eeprom = {
-       .byte_len = 4096,
-       .page_size = 32,
-       .flags = AT24_FLAG_ADDR16,
+static const struct property_entry board_eeprom_properties[] = {
+       PROPERTY_ENTRY_U32("pagesize", 32),
+       { }
 };
 
 static struct i2c_board_info pca100_i2c_devices[] = {
        {
-               I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
-               .platform_data = &board_eeprom,
+               I2C_BOARD_INFO("24c32", 0x52), /* E0=0, E1=1, E2=0 */
+               .properties = board_eeprom_properties,
        }, {
                I2C_BOARD_INFO("pcf8563", 0x51),
        }, {
index b787ba6897e435ae53ca1ddabdc664a19d9a68d3..004737c40fdab306f890cf881c7ec2cb0b32e83f 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/smsc911x.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
-#include <linux/platform_data/at24.h>
+#include <linux/property.h>
 #include <linux/delay.h>
 #include <linux/spi/spi.h>
 #include <linux/irq.h>
@@ -263,16 +263,15 @@ static const struct imxi2c_platform_data pcm037_i2c2_data __initconst = {
        .bitrate = 20000,
 };
 
-static struct at24_platform_data board_eeprom = {
-       .byte_len = 4096,
-       .page_size = 32,
-       .flags = AT24_FLAG_ADDR16,
+static const struct property_entry board_eeprom_properties[] = {
+       PROPERTY_ENTRY_U32("pagesize", 32),
+       { }
 };
 
 static struct i2c_board_info pcm037_i2c_devices[] = {
        {
-               I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
-               .platform_data = &board_eeprom,
+               I2C_BOARD_INFO("24c32", 0x52), /* E0=0, E1=1, E2=0 */
+               .properties = board_eeprom_properties,
        }, {
                I2C_BOARD_INFO("pcf8563", 0x51),
        }
index 95bd97710494e4e0041ad36c82ef0e0eaa220003..15bc956d466b1ea43b16053d205f278f2d0387f7 100644 (file)
@@ -56,11 +56,8 @@ static struct spi_board_info pcm037_spi_dev[] = {
 };
 
 /* Platform Data for MXC CSPI */
-static int pcm037_spi1_cs[] = { MXC_SPI_CS(0), MXC_SPI_CS(1), };
-
 static const struct spi_imx_master pcm037_spi1_pdata __initconst = {
-       .chipselect = pcm037_spi1_cs,
-       .num_chipselect = ARRAY_SIZE(pcm037_spi1_cs),
+       .num_chipselect = 2,
 };
 
 /* GPIO-keys input device */
index 78e2bf8dcd965a236c3f82b7a53b738c13ad92a1..e595e5368676de1f5f219c74ed8ea37cc217266b 100644 (file)
@@ -24,7 +24,7 @@
 #include <linux/interrupt.h>
 #include <linux/delay.h>
 #include <linux/i2c.h>
-#include <linux/platform_data/at24.h>
+#include <linux/property.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/ulpi.h>
 
@@ -110,16 +110,15 @@ static const struct imxi2c_platform_data pcm043_i2c0_data __initconst = {
        .bitrate = 50000,
 };
 
-static struct at24_platform_data board_eeprom = {
-       .byte_len = 4096,
-       .page_size = 32,
-       .flags = AT24_FLAG_ADDR16,
+static const struct property_entry board_eeprom_properties[] = {
+       PROPERTY_ENTRY_U32("pagesize", 32),
+       { }
 };
 
 static struct i2c_board_info pcm043_i2c_devices[] = {
        {
-               I2C_BOARD_INFO("at24", 0x52), /* E0=0, E1=1, E2=0 */
-               .platform_data = &board_eeprom,
+               I2C_BOARD_INFO("24c32", 0x52), /* E0=0, E1=1, E2=0 */
+               .properties = board_eeprom_properties,
        }, {
                I2C_BOARD_INFO("pcf8563", 0x51),
        },
index 5ff154c9a08626fa179983d0361a2ec22a7aa6c7..da3336aaa4c53758f86a84501f1d3137fae76cdd 100644 (file)
@@ -29,7 +29,6 @@
 #include <asm/mach/time.h>
 
 #include <linux/i2c.h>
-#include <linux/platform_data/at24.h>
 #include <linux/mfd/mc13xxx.h>
 
 #include "common.h"
@@ -145,15 +144,9 @@ static const struct imxi2c_platform_data vpr200_i2c0_data __initconst = {
        .bitrate = 50000,
 };
 
-static struct at24_platform_data vpr200_eeprom = {
-       .byte_len = 2048 / 8,
-       .page_size = 1,
-};
-
 static struct i2c_board_info vpr200_i2c_devices[] = {
        {
-               I2C_BOARD_INFO("at24", 0x50), /* E0=0, E1=0, E2=0 */
-               .platform_data = &vpr200_eeprom,
+               I2C_BOARD_INFO("24c02", 0x50), /* E0=0, E1=0, E2=0 */
        }, {
                I2C_BOARD_INFO("mc13892", 0x08),
                .platform_data = &vpr200_pmic,
index bcf3df59f71b447aeb1880a9c9e7743bb9d92398..6835b17113e57f3e5c936c2150c6d33ce385fcd6 100644 (file)
@@ -421,7 +421,7 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
        if (nr >= 1)
                return 0;
 
-       res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
+       res = kcalloc(2, sizeof(*res), GFP_KERNEL);
        if (res == NULL) {
                /* 
                 * If we're out of memory this early, something is wrong,
index 937eb1d47e7bb793a774e06c015347e726abc513..ef835d82cdb95ecb7f43d36a80f1dc7c9870a5b6 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/gpio/machine.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
-#include <linux/i2c-gpio.h>
+#include <linux/platform_data/i2c-gpio.h>
 #include <linux/platform_data/pca953x.h>
 
 #include <linux/mtd/mtd.h>
index d90f61e6254f80ba8fde45ef1129581713ee693a..d51cfda953d4564d372dac3955aedc9b3cefef29 100644 (file)
@@ -19,14 +19,7 @@ config MACH_MESON6
        select MESON6_TIMER
 
 config MACH_MESON8
-       bool "Amlogic Meson8 SoCs support"
-       default ARCH_MESON
-       select MESON6_TIMER
-       select COMMON_CLK_MESON8B
-       select MESON_IRQ_GPIO
-
-config MACH_MESON8B
-       bool "Amlogic Meson8b SoCs support"
+       bool "Amlogic Meson8, Meson8b and Meson8m2 SoCs support"
        default ARCH_MESON
        select MESON6_TIMER
        select COMMON_CLK_MESON8B
index 4e235717862599a211857c7c62cf5387fe85ebc8..c8d99df32f9b775c081f44e76438f910e3a945c2 100644 (file)
@@ -20,6 +20,7 @@ static const char * const meson_common_board_compat[] = {
        "amlogic,meson6",
        "amlogic,meson8",
        "amlogic,meson8b",
+       "amlogic,meson8m2",
        NULL,
 };
 
index 52e8e53ca154a7146a9abe2b4bf95bf2b2c2be8a..80f54cb54276fe81b870d7dd9298f39b340e2417 100644 (file)
@@ -12,6 +12,7 @@
  * published by the Free Software Foundation.
  */
 #include <linux/gpio/driver.h>
+#include <linux/gpio/machine.h>
 #include <linux/gpio.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
@@ -202,7 +203,10 @@ static struct resource latch2_resources[] = {
        },
 };
 
+#define LATCH2_LABEL   "latch2"
+
 static struct bgpio_pdata latch2_pdata = {
+       .label  = LATCH2_LABEL,
        .base   = AMS_DELTA_LATCH2_GPIO_BASE,
        .ngpio  = AMS_DELTA_LATCH2_NGPIO,
 };
@@ -217,6 +221,23 @@ static struct platform_device latch2_gpio_device = {
        },
 };
 
+#define LATCH2_PIN_LCD_VBLEN           0
+#define LATCH2_PIN_LCD_NDISP           1
+#define LATCH2_PIN_NAND_NCE            2
+#define LATCH2_PIN_NAND_NRE            3
+#define LATCH2_PIN_NAND_NWP            4
+#define LATCH2_PIN_NAND_NWE            5
+#define LATCH2_PIN_NAND_ALE            6
+#define LATCH2_PIN_NAND_CLE            7
+#define LATCH2_PIN_KEYBRD_PWR          8
+#define LATCH2_PIN_KEYBRD_DATAOUT      9
+#define LATCH2_PIN_SCARD_RSTIN         10
+#define LATCH2_PIN_SCARD_CMDVCC                11
+#define LATCH2_PIN_MODEM_NRESET                12
+#define LATCH2_PIN_MODEM_CODEC         13
+#define LATCH2_PIN_HOOKFLASH1          14
+#define LATCH2_PIN_HOOKFLASH2          15
+
 static const struct gpio latch_gpios[] __initconst = {
        {
                .gpio   = LATCH1_GPIO_BASE + 6,
@@ -238,11 +259,6 @@ static const struct gpio latch_gpios[] __initconst = {
                .flags  = GPIOF_OUT_INIT_LOW,
                .label  = "scard_cmdvcc",
        },
-       {
-               .gpio   = AMS_DELTA_GPIO_PIN_MODEM_CODEC,
-               .flags  = GPIOF_OUT_INIT_LOW,
-               .label  = "modem_codec",
-       },
        {
                .gpio   = AMS_DELTA_LATCH2_GPIO_BASE + 14,
                .flags  = GPIOF_OUT_INIT_LOW,
@@ -323,6 +339,22 @@ static struct platform_device ams_delta_nand_device = {
        .resource       = ams_delta_nand_resources,
 };
 
+#define OMAP_GPIO_LABEL        "gpio-0-15"
+
+static struct gpiod_lookup_table ams_delta_nand_gpio_table = {
+       .table = {
+               GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_NAND_RB, "rdy",
+                           0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce", 0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre", 0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp", 0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe", 0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_ALE, "ale", 0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_CLE, "cle", 0),
+               { },
+       },
+};
+
 static struct resource ams_delta_kp_resources[] = {
        [0] = {
                .start  = INT_KEYBOARD,
@@ -358,6 +390,14 @@ static struct platform_device ams_delta_lcd_device = {
        .id     = -1,
 };
 
+static struct gpiod_lookup_table ams_delta_lcd_gpio_table = {
+       .table = {
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_VBLEN, "vblen", 0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_NDISP, "ndisp", 0),
+               { },
+       },
+};
+
 static const struct gpio_led gpio_leds[] __initconst = {
        {
                .name            = "camera",
@@ -449,11 +489,35 @@ static struct platform_device ams_delta_audio_device = {
        .id     = -1,
 };
 
+static struct gpiod_lookup_table ams_delta_audio_gpio_table = {
+       .table = {
+               GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_HOOK_SWITCH,
+                           "hook_switch", 0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_CODEC,
+                           "modem_codec", 0),
+               { },
+       },
+};
+
 static struct platform_device cx20442_codec_device = {
        .name   = "cx20442-codec",
        .id     = -1,
 };
 
+static struct gpiod_lookup_table ams_delta_serio_gpio_table = {
+       .table = {
+               GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_KEYBRD_DATA,
+                           "data", 0),
+               GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_KEYBRD_CLK,
+                           "clock", 0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_PWR,
+                           "power", 0),
+               GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_DATAOUT,
+                           "dataout", 0),
+               { },
+       },
+};
+
 static struct platform_device *ams_delta_devices[] __initdata = {
        &latch1_gpio_device,
        &latch2_gpio_device,
@@ -468,6 +532,16 @@ static struct platform_device *late_devices[] __initdata = {
        &cx20442_codec_device,
 };
 
+static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = {
+       &ams_delta_audio_gpio_table,
+       &ams_delta_serio_gpio_table,
+};
+
+static struct gpiod_lookup_table *late_gpio_tables[] __initdata = {
+       &ams_delta_lcd_gpio_table,
+       &ams_delta_nand_gpio_table,
+};
+
 static void __init ams_delta_init(void)
 {
        /* mux pins for uarts */
@@ -500,6 +574,20 @@ static void __init ams_delta_init(void)
        gpio_led_register_device(-1, &leds_pdata);
        platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
 
+       /*
+        * As soon as devices have been registered, assign their dev_names
+        * to respective GPIO lookup tables before they are added.
+        */
+       ams_delta_audio_gpio_table.dev_id =
+                       dev_name(&ams_delta_audio_device.dev);
+       /*
+        * No device name is assigned to GPIO lookup table for serio device
+        * as long as serio driver is not converted to platform device driver.
+        */
+
+       gpiod_add_lookup_tables(ams_delta_gpio_tables,
+                               ARRAY_SIZE(ams_delta_gpio_tables));
+
        ams_delta_init_fiq();
 
        omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1);
@@ -570,6 +658,15 @@ static int __init late_init(void)
 
        platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
 
+       /*
+        * As soon as devices have been registered, assign their dev_names
+        * to respective GPIO lookup tables before they are added.
+        */
+       ams_delta_lcd_gpio_table.dev_id = dev_name(&ams_delta_lcd_device.dev);
+       ams_delta_nand_gpio_table.dev_id = dev_name(&ams_delta_nand_device.dev);
+
+       gpiod_add_lookup_tables(late_gpio_tables, ARRAY_SIZE(late_gpio_tables));
+
        err = platform_device_register(&modem_nreset_device);
        if (err) {
                pr_err("Couldn't register the modem regulator device\n");
index 67d46690a56e470d98c7a22792e856b237809a23..da8f3fc3180f55c2366ed9f68afb2fe116cf7a75 100644 (file)
@@ -31,7 +31,7 @@
 #include <linux/gpio.h>
 #include <linux/gpio_keys.h>
 #include <linux/i2c.h>
-#include <linux/i2c-gpio.h>
+#include <linux/platform_data/i2c-gpio.h>
 #include <linux/htcpld.h>
 #include <linux/leds.h>
 #include <linux/spi/spi.h>
index c66372ed29e2229d543e17d9961da2f796bd42bb..9ffa8d755a599344825b53c6363ac22038d21197 100644 (file)
@@ -303,22 +303,22 @@ static const struct omap_lcd_config osk_lcd_config __initconst = {
 #ifdef CONFIG_OMAP_OSK_MISTRAL
 
 #include <linux/input.h>
-#include <linux/platform_data/at24.h>
+#include <linux/property.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/ads7846.h>
 
 #include <linux/platform_data/keypad-omap.h>
 
-static struct at24_platform_data at24c04 = {
-       .byte_len       = SZ_4K / 8,
-       .page_size      = 16,
+static const struct property_entry mistral_at24_properties[] = {
+       PROPERTY_ENTRY_U32("pagesize", 16),
+       { }
 };
 
 static struct i2c_board_info __initdata mistral_i2c_board_info[] = {
        {
                /* NOTE:  powered from LCD supply */
                I2C_BOARD_INFO("24c04", 0x50),
-               .platform_data  = &at24c04,
+               .properties = mistral_at24_properties,
        },
        /* TODO when driver support is ready:
         *  - optionally ov9640 camera sensor at 0x30
index d83ff257eaa8fb5decb1fca1388989243dac3f2c..c6537d2c28597ac1f8296322085d591198d508f4 100644 (file)
@@ -27,7 +27,7 @@
 #define __ARCH_ARM_MACH_OMAP1_COMMON_H
 
 #include <linux/mtd/mtd.h>
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 #include <linux/reboot.h>
 
 #include <asm/exception.h>
index 5bdf3c4190f97221e3db0d090e558476d5091579..9250f263ac5117a4b02a7f1672fcbf63547d34d8 100644 (file)
@@ -20,7 +20,7 @@
  */
 
 #include <linux/i2c.h>
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 #include <mach/mux.h>
 #include "soc.h"
 
index 8ed67f8d1762f3bc5937e46c0519b816d135cddf..27e22e702f96a9e09a87366cd6a695c7bbd46023 100644 (file)
@@ -389,7 +389,7 @@ static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
 {
        int i;
 
-       omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
+       omap_mcbsp_devices = kcalloc(size, sizeof(struct platform_device *),
                                     GFP_KERNEL);
        if (!omap_mcbsp_devices) {
                printk(KERN_ERR "Could not register McBSP devices\n");
index 0d9ce58bc464a87249f1551a0882c18d5009bc5d..01377c292db43f6e48e7d3f4098140c7bf5cea7f 100644 (file)
@@ -78,7 +78,6 @@ endif
 omap-4-5-pm-common                     = omap-mpuss-lowpower.o
 obj-$(CONFIG_ARCH_OMAP4)               += $(omap-4-5-pm-common)
 obj-$(CONFIG_SOC_OMAP5)                        += $(omap-4-5-pm-common)
-obj-$(CONFIG_OMAP_PM_NOOP)             += omap-pm-noop.o
 
 ifeq ($(CONFIG_PM),y)
 obj-$(CONFIG_ARCH_OMAP2)               += pm24xx.o
index 6c61ecc62905a37021979b0f1c3074b98bd532ca..6b4f4975cf7a6c20361e7a7f96b4a69a2e48c3d2 100644 (file)
@@ -31,8 +31,6 @@ static const struct of_device_id omap_dt_match_table[] __initconst = {
 static void __init __maybe_unused omap_generic_init(void)
 {
        pdata_quirks_init(omap_dt_match_table);
-
-       omapdss_init_of();
        omap_soc_device_init();
 }
 
index b79b1ca9aee9edbd96099495e0c6165089c0c01e..6d44fe05a3feb00f3ce11877f52b25ed43863926 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/limits.h>
 #include <linux/err.h>
 #include <linux/clk-provider.h>
+#include <linux/cpu_pm.h>
 
 #include <linux/io.h>
 
@@ -31,6 +32,7 @@
 #include "soc.h"
 #include "clock.h"
 #include "clockdomain.h"
+#include "pm.h"
 
 /* clkdm_list contains all registered struct clockdomains */
 static LIST_HEAD(clkdm_list);
@@ -39,6 +41,8 @@ static LIST_HEAD(clkdm_list);
 static struct clkdm_autodep *autodeps;
 
 static struct clkdm_ops *arch_clkdm;
+void clkdm_save_context(void);
+void clkdm_restore_context(void);
 
 /* Private functions */
 
@@ -449,6 +453,22 @@ int clkdm_register_autodeps(struct clkdm_autodep *ia)
        return 0;
 }
 
+static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
+{
+       switch (cmd) {
+       case CPU_CLUSTER_PM_ENTER:
+               if (enable_off_mode)
+                       clkdm_save_context();
+               break;
+       case CPU_CLUSTER_PM_EXIT:
+               if (enable_off_mode)
+                       clkdm_restore_context();
+               break;
+       }
+
+       return NOTIFY_OK;
+}
+
 /**
  * clkdm_complete_init - set up the clockdomain layer
  *
@@ -460,6 +480,7 @@ int clkdm_register_autodeps(struct clkdm_autodep *ia)
 int clkdm_complete_init(void)
 {
        struct clockdomain *clkdm;
+       static struct notifier_block nb;
 
        if (list_empty(&clkdm_list))
                return -EACCES;
@@ -474,6 +495,12 @@ int clkdm_complete_init(void)
                clkdm_clear_all_sleepdeps(clkdm);
        }
 
+       /* Only AM43XX can lose clkdm context during rtc-ddr suspend */
+       if (soc_is_am43xx()) {
+               nb.notifier_call = cpu_notifier;
+               cpu_pm_register_notifier(&nb);
+       }
+
        return 0;
 }
 
@@ -1307,3 +1334,49 @@ int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh)
        return 0;
 }
 
+/**
+ * _clkdm_save_context - save the context for the control of this clkdm
+ *
+ * Due to a suspend or hibernation operation, the state of the registers
+ * controlling this clkdm will be lost, save their context.
+ */
+static int _clkdm_save_context(struct clockdomain *clkdm, void *ununsed)
+{
+       if (!arch_clkdm || !arch_clkdm->clkdm_save_context)
+               return -EINVAL;
+
+       return arch_clkdm->clkdm_save_context(clkdm);
+}
+
+/**
+ * _clkdm_restore_context - restore context for control of this clkdm
+ *
+ * Restore the register values for this clockdomain.
+ */
+static int _clkdm_restore_context(struct clockdomain *clkdm, void *ununsed)
+{
+       if (!arch_clkdm || !arch_clkdm->clkdm_restore_context)
+               return -EINVAL;
+
+       return arch_clkdm->clkdm_restore_context(clkdm);
+}
+
+/**
+ * clkdm_save_context - Saves the context for each registered clkdm
+ *
+ * Save the context for each registered clockdomain.
+ */
+void clkdm_save_context(void)
+{
+       clkdm_for_each(_clkdm_save_context, NULL);
+}
+
+/**
+ * clkdm_restore_context - Restores the context for each registered clkdm
+ *
+ * Restore the context for each registered clockdomain.
+ */
+void clkdm_restore_context(void)
+{
+       clkdm_for_each(_clkdm_restore_context, NULL);
+}
index 24667a5a9dc0f487759b3635eff014517e8533c8..c7d0953e4aa2db25e43337b31d5e927e272ccde0 100644 (file)
@@ -141,6 +141,7 @@ struct clockdomain {
        int usecount;
        int forcewake_count;
        struct list_head node;
+       u32 context;
 };
 
 /**
@@ -159,6 +160,8 @@ struct clockdomain {
  * @clkdm_deny_idle: Disable hw supervised idle transitions for clock domain
  * @clkdm_clk_enable: Put the clkdm in right state for a clock enable
  * @clkdm_clk_disable: Put the clkdm in right state for a clock disable
+ * @clkdm_save_context: Save the current clkdm context
+ * @clkdm_restore_context: Restore the clkdm context
  */
 struct clkdm_ops {
        int     (*clkdm_add_wkdep)(struct clockdomain *clkdm1, struct clockdomain *clkdm2);
@@ -175,6 +178,8 @@ struct clkdm_ops {
        void    (*clkdm_deny_idle)(struct clockdomain *clkdm);
        int     (*clkdm_clk_enable)(struct clockdomain *clkdm);
        int     (*clkdm_clk_disable)(struct clockdomain *clkdm);
+       int     (*clkdm_save_context)(struct clockdomain *clkdm);
+       int     (*clkdm_restore_context)(struct clockdomain *clkdm);
 };
 
 int clkdm_register_platform_funcs(struct clkdm_ops *co);
@@ -214,6 +219,9 @@ int clkdm_clk_disable(struct clockdomain *clkdm, struct clk *clk);
 int clkdm_hwmod_enable(struct clockdomain *clkdm, struct omap_hwmod *oh);
 int clkdm_hwmod_disable(struct clockdomain *clkdm, struct omap_hwmod *oh);
 
+void clkdm_save_context(void);
+void clkdm_restore_context(void);
+
 extern void __init omap242x_clockdomains_init(void);
 extern void __init omap243x_clockdomains_init(void);
 extern void __init omap3xxx_clockdomains_init(void);
index 1cc0247a2cb5e81615f9f7b4286d6a804c587c48..084d454f607482622207e73979f6f28629a10b6e 100644 (file)
@@ -72,6 +72,17 @@ static inline u32 am33xx_cm_rmw_reg_bits(u32 mask, u32 bits, s16 inst, s16 idx)
        return v;
 }
 
+static inline u32 am33xx_cm_read_reg_bits(u16 inst, s16 idx, u32 mask)
+{
+       u32 v;
+
+       v = am33xx_cm_read_reg(inst, idx);
+       v &= mask;
+       v >>= __ffs(mask);
+
+       return v;
+}
+
 /**
  * _clkctrl_idlest - read a CM_*_CLKCTRL register; mask & shift IDLEST bitfield
  * @inst: CM instance register offset (*_INST macro)
@@ -338,6 +349,46 @@ static u32 am33xx_cm_xlate_clkctrl(u8 part, u16 inst, u16 offset)
        return cm_base.pa + inst + offset;
 }
 
+/**
+ * am33xx_clkdm_save_context - Save the clockdomain transition context
+ * @clkdm: The clockdomain pointer whose context needs to be saved
+ *
+ * Save the clockdomain transition context.
+ */
+static int am33xx_clkdm_save_context(struct clockdomain *clkdm)
+{
+       clkdm->context = am33xx_cm_read_reg_bits(clkdm->cm_inst,
+                                                clkdm->clkdm_offs,
+                                                AM33XX_CLKTRCTRL_MASK);
+
+       return 0;
+}
+
+/**
+ * am33xx_restore_save_context - Restore the clockdomain transition context
+ * @clkdm: The clockdomain pointer whose context needs to be restored
+ *
+ * Restore the clockdomain transition context.
+ */
+static int am33xx_clkdm_restore_context(struct clockdomain *clkdm)
+{
+       switch (clkdm->context) {
+       case OMAP34XX_CLKSTCTRL_DISABLE_AUTO:
+               am33xx_clkdm_deny_idle(clkdm);
+               break;
+       case OMAP34XX_CLKSTCTRL_FORCE_SLEEP:
+               am33xx_clkdm_sleep(clkdm);
+               break;
+       case OMAP34XX_CLKSTCTRL_FORCE_WAKEUP:
+               am33xx_clkdm_wakeup(clkdm);
+               break;
+       case OMAP34XX_CLKSTCTRL_ENABLE_AUTO:
+               am33xx_clkdm_allow_idle(clkdm);
+               break;
+       }
+       return 0;
+}
+
 struct clkdm_ops am33xx_clkdm_operations = {
        .clkdm_sleep            = am33xx_clkdm_sleep,
        .clkdm_wakeup           = am33xx_clkdm_wakeup,
@@ -345,6 +396,8 @@ struct clkdm_ops am33xx_clkdm_operations = {
        .clkdm_deny_idle        = am33xx_clkdm_deny_idle,
        .clkdm_clk_enable       = am33xx_clkdm_clk_enable,
        .clkdm_clk_disable      = am33xx_clkdm_clk_disable,
+       .clkdm_save_context     = am33xx_clkdm_save_context,
+       .clkdm_restore_context  = am33xx_clkdm_restore_context,
 };
 
 static const struct cm_ll_data am33xx_cm_ll_data = {
index 7deefee49fc3c7276cba9e4bc3aca5679f896611..c11ac492b626a5f7ceeb8e3638f772460d2044ad 100644 (file)
@@ -481,6 +481,47 @@ static u32 omap4_cminst_xlate_clkctrl(u8 part, u16 inst, u16 offset)
        return _cm_bases[part].pa + inst + offset;
 }
 
+/**
+ * omap4_clkdm_save_context - Save the clockdomain modulemode context
+ * @clkdm: The clockdomain pointer whose context needs to be saved
+ *
+ * Save the clockdomain modulemode context.
+ */
+static int omap4_clkdm_save_context(struct clockdomain *clkdm)
+{
+       clkdm->context = omap4_cminst_read_inst_reg(clkdm->prcm_partition,
+                                                   clkdm->cm_inst,
+                                                   clkdm->clkdm_offs +
+                                                   OMAP4_CM_CLKSTCTRL);
+       clkdm->context &= OMAP4430_MODULEMODE_MASK;
+       return 0;
+}
+
+/**
+ * omap4_clkdm_restore_context - Restore the clockdomain modulemode context
+ * @clkdm: The clockdomain pointer whose context needs to be restored
+ *
+ * Restore the clockdomain modulemode context.
+ */
+static int omap4_clkdm_restore_context(struct clockdomain *clkdm)
+{
+       switch (clkdm->context) {
+       case OMAP34XX_CLKSTCTRL_DISABLE_AUTO:
+               omap4_clkdm_deny_idle(clkdm);
+               break;
+       case OMAP34XX_CLKSTCTRL_FORCE_SLEEP:
+               omap4_clkdm_sleep(clkdm);
+               break;
+       case OMAP34XX_CLKSTCTRL_FORCE_WAKEUP:
+               omap4_clkdm_wakeup(clkdm);
+               break;
+       case OMAP34XX_CLKSTCTRL_ENABLE_AUTO:
+               omap4_clkdm_allow_idle(clkdm);
+               break;
+       }
+       return 0;
+}
+
 struct clkdm_ops omap4_clkdm_operations = {
        .clkdm_add_wkdep        = omap4_clkdm_add_wkup_sleep_dep,
        .clkdm_del_wkdep        = omap4_clkdm_del_wkup_sleep_dep,
@@ -496,6 +537,8 @@ struct clkdm_ops omap4_clkdm_operations = {
        .clkdm_deny_idle        = omap4_clkdm_deny_idle,
        .clkdm_clk_enable       = omap4_clkdm_clk_enable,
        .clkdm_clk_disable      = omap4_clkdm_clk_disable,
+       .clkdm_save_context     = omap4_clkdm_save_context,
+       .clkdm_restore_context  = omap4_clkdm_restore_context,
 };
 
 struct clkdm_ops am43xx_clkdm_operations = {
index fbe0b78bf489dbaadc0ab1ae9eb4459baa019ca3..129455e822e42564fbeefffabe2d3dbb5eed3102 100644 (file)
@@ -30,7 +30,7 @@
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/mfd/twl.h>
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 #include <linux/reboot.h>
 #include <linux/irqchip/irq-omap-intc.h>
 
@@ -44,6 +44,9 @@
 
 #define OMAP_INTC_START                NR_IRQS
 
+extern int (*omap_pm_soc_init)(void);
+int omap_pm_nop_init(void);
+
 #if defined(CONFIG_PM) && defined(CONFIG_ARCH_OMAP2)
 int omap2_pm_init(void);
 #else
@@ -79,9 +82,12 @@ static inline int omap4_pm_init_early(void)
 
 #if defined(CONFIG_PM) && (defined(CONFIG_SOC_AM33XX) || \
        defined(CONFIG_SOC_AM43XX))
-void amx3_common_pm_init(void);
+int amx3_common_pm_init(void);
 #else
-static inline void amx3_common_pm_init(void) { }
+static inline int amx3_common_pm_init(void)
+{
+       return 0;
+}
 #endif
 
 extern void omap2_init_common_infrastructure(void);
@@ -122,14 +128,10 @@ void am43xx_init_early(void);
 void am43xx_init_late(void);
 void omap4430_init_early(void);
 void omap5_init_early(void);
-void omap3_init_late(void);    /* Do not use this one */
+void omap3_init_late(void);
 void omap4430_init_late(void);
 void omap2420_init_late(void);
 void omap2430_init_late(void);
-void omap3430_init_late(void);
-void omap35xx_init_late(void);
-void omap3630_init_late(void);
-void am35xx_init_late(void);
 void ti81xx_init_late(void);
 void am33xx_init_late(void);
 void omap5_init_late(void);
@@ -350,7 +352,5 @@ extern int omap_dss_reset(struct omap_hwmod *);
 /* SoC specific clock initializer */
 int omap_clk_init(void);
 
-int __init omapdss_init_of(void);
-
 #endif /* __ASSEMBLER__ */
 #endif /* __ARCH_ARM_MACH_OMAP2PLUS_COMMON_H */
index 180da403639e141a40ee8b62b201b76748a09350..0bbfb20e193f4b6a735fcbe38b2d2e04c9834952 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/of_address.h>
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
+#include <linux/cpu_pm.h>
 
 #include "soc.h"
 #include "iomap.h"
@@ -621,6 +622,110 @@ void __init omap3_ctrl_init(void)
 }
 #endif /* CONFIG_ARCH_OMAP3 && CONFIG_PM */
 
+static unsigned long am43xx_control_reg_offsets[] = {
+       AM33XX_CONTROL_SYSCONFIG_OFFSET,
+       AM33XX_CONTROL_STATUS_OFFSET,
+       AM43XX_CONTROL_MPU_L2_CTRL_OFFSET,
+       AM33XX_CONTROL_CORE_SLDO_CTRL_OFFSET,
+       AM33XX_CONTROL_MPU_SLDO_CTRL_OFFSET,
+       AM33XX_CONTROL_CLK32KDIVRATIO_CTRL_OFFSET,
+       AM33XX_CONTROL_BANDGAP_CTRL_OFFSET,
+       AM33XX_CONTROL_BANDGAP_TRIM_OFFSET,
+       AM33XX_CONTROL_PLL_CLKINPULOW_CTRL_OFFSET,
+       AM33XX_CONTROL_MOSC_CTRL_OFFSET,
+       AM33XX_CONTROL_DEEPSLEEP_CTRL_OFFSET,
+       AM43XX_CONTROL_DISPLAY_PLL_SEL_OFFSET,
+       AM33XX_CONTROL_INIT_PRIORITY_0_OFFSET,
+       AM33XX_CONTROL_INIT_PRIORITY_1_OFFSET,
+       AM33XX_CONTROL_TPTC_CFG_OFFSET,
+       AM33XX_CONTROL_USB_CTRL0_OFFSET,
+       AM33XX_CONTROL_USB_CTRL1_OFFSET,
+       AM43XX_CONTROL_USB_CTRL2_OFFSET,
+       AM43XX_CONTROL_GMII_SEL_OFFSET,
+       AM43XX_CONTROL_MPUSS_CTRL_OFFSET,
+       AM43XX_CONTROL_TIMER_CASCADE_CTRL_OFFSET,
+       AM43XX_CONTROL_PWMSS_CTRL_OFFSET,
+       AM33XX_CONTROL_MREQPRIO_0_OFFSET,
+       AM33XX_CONTROL_MREQPRIO_1_OFFSET,
+       AM33XX_CONTROL_HW_EVENT_SEL_GRP1_OFFSET,
+       AM33XX_CONTROL_HW_EVENT_SEL_GRP2_OFFSET,
+       AM33XX_CONTROL_HW_EVENT_SEL_GRP3_OFFSET,
+       AM33XX_CONTROL_HW_EVENT_SEL_GRP4_OFFSET,
+       AM33XX_CONTROL_SMRT_CTRL_OFFSET,
+       AM33XX_CONTROL_MPUSS_HW_DEBUG_SEL_OFFSET,
+       AM43XX_CONTROL_CQDETECT_STS_OFFSET,
+       AM43XX_CONTROL_CQDETECT_STS2_OFFSET,
+       AM43XX_CONTROL_VTP_CTRL_OFFSET,
+       AM33XX_CONTROL_VREF_CTRL_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_0_3_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_4_7_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_8_11_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_12_15_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_16_19_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_20_23_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_24_27_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_28_31_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_32_35_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_36_39_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_40_43_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_44_47_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_48_51_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_52_55_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_56_59_OFFSET,
+       AM33XX_CONTROL_TPCC_EVT_MUX_60_63_OFFSET,
+       AM33XX_CONTROL_TIMER_EVT_CAPT_OFFSET,
+       AM33XX_CONTROL_ECAP_EVT_CAPT_OFFSET,
+       AM33XX_CONTROL_ADC_EVT_CAPT_OFFSET,
+       AM43XX_CONTROL_ADC1_EVT_CAPT_OFFSET,
+       AM33XX_CONTROL_RESET_ISO_OFFSET,
+};
+
+static u32 am33xx_control_vals[ARRAY_SIZE(am43xx_control_reg_offsets)];
+
+/**
+ * am43xx_control_save_context - Save the wakeup domain registers
+ *
+ * Save the wkup domain registers
+ */
+void am43xx_control_save_context(void)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(am43xx_control_reg_offsets); i++)
+               am33xx_control_vals[i] =
+                               omap_ctrl_readl(am43xx_control_reg_offsets[i]);
+}
+
+/**
+ * am43xx_control_restore_context - Restore the wakeup domain registers
+ *
+ * Restore the wkup domain registers
+ */
+void am43xx_control_restore_context(void)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(am43xx_control_reg_offsets); i++)
+               omap_ctrl_writel(am33xx_control_vals[i],
+                                am43xx_control_reg_offsets[i]);
+}
+
+static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
+{
+       switch (cmd) {
+       case CPU_CLUSTER_PM_ENTER:
+               if (enable_off_mode)
+                       am43xx_control_save_context();
+               break;
+       case CPU_CLUSTER_PM_EXIT:
+               if (enable_off_mode)
+                       am43xx_control_restore_context();
+               break;
+       }
+
+       return NOTIFY_OK;
+}
+
 struct control_init_data {
        int index;
        void __iomem *mem;
@@ -699,6 +804,7 @@ int __init omap_control_init(void)
        const struct omap_prcm_init_data *data;
        int ret;
        struct regmap *syscon;
+       static struct notifier_block nb;
 
        for_each_matching_node_and_match(np, omap_scrm_dt_match_table, &match) {
                data = match->data;
@@ -731,6 +837,12 @@ int __init omap_control_init(void)
                }
        }
 
+       /* Only AM43XX can lose ctrl registers context during rtc-ddr suspend */
+       if (soc_is_am43xx()) {
+               nb.notifier_call = cpu_notifier;
+               cpu_pm_register_notifier(&nb);
+       }
+
        return 0;
 }
 
index ec406bc2c6d4a4524b329415fcbe361c9ca88c0a..393b421105114843613ea5f63f0fce0c016348f9 100644 (file)
 #define AM33XX_DEV_FEATURE             0x604
 #define AM33XX_SGX_MASK                        BIT(29)
 
+/* Additional AM33XX/AM43XX CONTROL registers */
+#define AM33XX_CONTROL_SYSCONFIG_OFFSET                        0x0010
+#define AM33XX_CONTROL_STATUS_OFFSET                   0x0040
+#define AM43XX_CONTROL_MPU_L2_CTRL_OFFSET              0x01e0
+#define AM33XX_CONTROL_CORTEX_VBBLDO_CTRL_OFFSET       0x041c
+#define AM33XX_CONTROL_CORE_SLDO_CTRL_OFFSET           0x0428
+#define AM33XX_CONTROL_MPU_SLDO_CTRL_OFFSET            0x042c
+#define AM33XX_CONTROL_CLK32KDIVRATIO_CTRL_OFFSET      0x0444
+#define AM33XX_CONTROL_BANDGAP_CTRL_OFFSET             0x0448
+#define AM33XX_CONTROL_BANDGAP_TRIM_OFFSET             0x044c
+#define AM33XX_CONTROL_PLL_CLKINPULOW_CTRL_OFFSET      0x0458
+#define AM33XX_CONTROL_MOSC_CTRL_OFFSET                        0x0468
+#define AM33XX_CONTROL_RCOSC_CTRL_OFFSET               0x046c
+#define AM33XX_CONTROL_DEEPSLEEP_CTRL_OFFSET           0x0470
+#define AM43XX_CONTROL_DISPLAY_PLL_SEL_OFFSET          0x0534
+#define AM33XX_CONTROL_INIT_PRIORITY_0_OFFSET          0x0608
+#define AM33XX_CONTROL_INIT_PRIORITY_1_OFFSET          0x060c
+#define AM33XX_CONTROL_MMU_CFG_OFFSET                  0x0610
+#define AM33XX_CONTROL_TPTC_CFG_OFFSET                 0x0614
+#define AM33XX_CONTROL_USB_CTRL0_OFFSET                        0x0620
+#define AM33XX_CONTROL_USB_CTRL1_OFFSET                        0x0628
+#define AM33XX_CONTROL_USB_WKUP_CTRL_OFFSET            0x0648
+#define AM43XX_CONTROL_USB_CTRL2_OFFSET                        0x064c
+#define AM43XX_CONTROL_GMII_SEL_OFFSET                 0x0650
+#define AM43XX_CONTROL_MPUSS_CTRL_OFFSET               0x0654
+#define AM43XX_CONTROL_TIMER_CASCADE_CTRL_OFFSET       0x0658
+#define AM43XX_CONTROL_PWMSS_CTRL_OFFSET               0x0664
+#define AM33XX_CONTROL_MREQPRIO_0_OFFSET               0x0670
+#define AM33XX_CONTROL_MREQPRIO_1_OFFSET               0x0674
+#define AM33XX_CONTROL_HW_EVENT_SEL_GRP1_OFFSET                0x0690
+#define AM33XX_CONTROL_HW_EVENT_SEL_GRP2_OFFSET                0x0694
+#define AM33XX_CONTROL_HW_EVENT_SEL_GRP3_OFFSET                0x0698
+#define AM33XX_CONTROL_HW_EVENT_SEL_GRP4_OFFSET                0x069c
+#define AM33XX_CONTROL_SMRT_CTRL_OFFSET                        0x06a0
+#define AM33XX_CONTROL_MPUSS_HW_DEBUG_SEL_OFFSET       0x06a4
+#define AM43XX_CONTROL_CQDETECT_STS_OFFSET             0x0e00
+#define AM43XX_CONTROL_CQDETECT_STS2_OFFSET            0x0e08
+#define AM43XX_CONTROL_VTP_CTRL_OFFSET                 0x0e0c
+#define AM33XX_CONTROL_VREF_CTRL_OFFSET                        0x0e14
+#define AM33XX_CONTROL_TPCC_EVT_MUX_0_3_OFFSET         0x0f90
+#define AM33XX_CONTROL_TPCC_EVT_MUX_4_7_OFFSET         0x0f94
+#define AM33XX_CONTROL_TPCC_EVT_MUX_8_11_OFFSET                0x0f98
+#define AM33XX_CONTROL_TPCC_EVT_MUX_12_15_OFFSET       0x0f9c
+#define AM33XX_CONTROL_TPCC_EVT_MUX_16_19_OFFSET       0x0fa0
+#define AM33XX_CONTROL_TPCC_EVT_MUX_20_23_OFFSET       0x0fa4
+#define AM33XX_CONTROL_TPCC_EVT_MUX_24_27_OFFSET       0x0fa8
+#define AM33XX_CONTROL_TPCC_EVT_MUX_28_31_OFFSET       0x0fac
+#define AM33XX_CONTROL_TPCC_EVT_MUX_32_35_OFFSET       0x0fb0
+#define AM33XX_CONTROL_TPCC_EVT_MUX_36_39_OFFSET       0x0fb4
+#define AM33XX_CONTROL_TPCC_EVT_MUX_40_43_OFFSET       0x0fb8
+#define AM33XX_CONTROL_TPCC_EVT_MUX_44_47_OFFSET       0x0fbc
+#define AM33XX_CONTROL_TPCC_EVT_MUX_48_51_OFFSET       0x0fc0
+#define AM33XX_CONTROL_TPCC_EVT_MUX_52_55_OFFSET       0x0fc4
+#define AM33XX_CONTROL_TPCC_EVT_MUX_56_59_OFFSET       0x0fc8
+#define AM33XX_CONTROL_TPCC_EVT_MUX_60_63_OFFSET       0x0fcc
+#define AM33XX_CONTROL_TIMER_EVT_CAPT_OFFSET           0x0fd0
+#define AM33XX_CONTROL_ECAP_EVT_CAPT_OFFSET            0x0fd4
+#define AM33XX_CONTROL_ADC_EVT_CAPT_OFFSET             0x0fd8
+#define AM43XX_CONTROL_ADC1_EVT_CAPT_OFFSET            0x0fdc
+#define AM33XX_CONTROL_RESET_ISO_OFFSET                        0x1000
+
 /* CONTROL OMAP STATUS register to identify OMAP3 features */
 #define OMAP3_CONTROL_OMAP_STATUS      0x044c
 
index b3f6eb5d04a260226eaa46e17b476e11ecb6e274..9500b6e2738019a4fb53e50c8150a2972ca8c391 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/platform_data/omapdss.h>
 #include "omap_hwmod.h"
 #include "omap_device.h"
-#include "omap-pm.h"
 #include "common.h"
 
 #include "soc.h"
@@ -126,11 +125,6 @@ static void omap_dsi_disable_pads(int dsi_id, unsigned lane_mask)
                omap4_dsi_mux_pads(dsi_id, 0);
 }
 
-static int omap_dss_set_min_bus_tput(struct device *dev, unsigned long tput)
-{
-       return omap_pm_set_min_bus_tput(dev, OCP_INITIATOR_AGENT, tput);
-}
-
 static enum omapdss_version __init omap_display_get_version(void)
 {
        if (cpu_is_omap24xx())
@@ -169,7 +163,6 @@ static int __init omapdss_init_fbdev(void)
        static struct omap_dss_board_info board_data = {
                .dsi_enable_pads = omap_dsi_enable_pads,
                .dsi_disable_pads = omap_dsi_disable_pads,
-               .set_min_bus_tput = omap_dss_set_min_bus_tput,
        };
        struct device_node *node;
        int r;
@@ -392,7 +385,7 @@ static struct device_node * __init omapdss_find_dss_of_node(void)
        return NULL;
 }
 
-int __init omapdss_init_of(void)
+static int __init omapdss_init_of(void)
 {
        int r;
        struct device_node *node;
@@ -422,3 +415,4 @@ int __init omapdss_init_of(void)
 
        return omapdss_init_fbdev();
 }
+omap_device_initcall(omapdss_init_of);
index b064066d431c2b0e0cd664a5058acc7dca68e92e..af545193f6736f474d2c77b62c3abc46fc7c494f 100644 (file)
@@ -18,7 +18,6 @@
 
 #include "soc.h"
 #include "omap_device.h"
-#include "omap-pm.h"
 
 #include "hsmmc.h"
 #include "control.h"
@@ -35,7 +34,7 @@ static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
 {
        char *hc_name;
 
-       hc_name = kzalloc(sizeof(char) * (HSMMC_NAME_LEN + 1), GFP_KERNEL);
+       hc_name = kzalloc(HSMMC_NAME_LEN + 1, GFP_KERNEL);
        if (!hc_name) {
                kfree(hc_name);
                return -ENOMEM;
index 91a21c3923b2faf0ffbb7bebcc0ffab4330799c1..37ff25ee3d8966d93e79a692d9e17618477f2de5 100644 (file)
@@ -22,7 +22,6 @@
 #include "soc.h"
 #include "omap_hwmod.h"
 #include "omap_device.h"
-#include "omap-pm.h"
 
 #include "prm.h"
 #include "common.h"
index cf546dfe3b3288865ea4231237a939b41a24c2d9..bb8e0bb7ef5de71d713beeda76eff14d17981099 100644 (file)
@@ -37,7 +37,6 @@
 #include "clock.h"
 #include "clock2xxx.h"
 #include "clock3xxx.h"
-#include "omap-pm.h"
 #include "sdrc.h"
 #include "control.h"
 #include "serial.h"
@@ -421,13 +420,6 @@ static void __init __maybe_unused omap_hwmod_init_postsetup(void)
        postsetup_state = _HWMOD_STATE_ENABLED;
 #endif
        omap_hwmod_for_each(_set_hwmod_postsetup_state, &postsetup_state);
-
-       omap_pm_if_early_init();
-}
-
-static void __init __maybe_unused omap_common_late_init(void)
-{
-       omap2_common_pm_late_init();
 }
 
 #ifdef CONFIG_SOC_OMAP2420
@@ -450,9 +442,7 @@ void __init omap2420_init_early(void)
 
 void __init omap2420_init_late(void)
 {
-       omap_common_late_init();
-       omap2_pm_init();
-       omap2_clk_enable_autoidle_all();
+       omap_pm_soc_init = omap2_pm_init;
 }
 #endif
 
@@ -476,9 +466,7 @@ void __init omap2430_init_early(void)
 
 void __init omap2430_init_late(void)
 {
-       omap_common_late_init();
-       omap2_pm_init();
-       omap2_clk_enable_autoidle_all();
+       omap_pm_soc_init = omap2_pm_init;
 }
 #endif
 
@@ -529,43 +517,12 @@ void __init am35xx_init_early(void)
 
 void __init omap3_init_late(void)
 {
-       omap_common_late_init();
-       omap3_pm_init();
-       omap2_clk_enable_autoidle_all();
-}
-
-void __init omap3430_init_late(void)
-{
-       omap_common_late_init();
-       omap3_pm_init();
-       omap2_clk_enable_autoidle_all();
-}
-
-void __init omap35xx_init_late(void)
-{
-       omap_common_late_init();
-       omap3_pm_init();
-       omap2_clk_enable_autoidle_all();
-}
-
-void __init omap3630_init_late(void)
-{
-       omap_common_late_init();
-       omap3_pm_init();
-       omap2_clk_enable_autoidle_all();
-}
-
-void __init am35xx_init_late(void)
-{
-       omap_common_late_init();
-       omap3_pm_init();
-       omap2_clk_enable_autoidle_all();
+       omap_pm_soc_init = omap3_pm_init;
 }
 
 void __init ti81xx_init_late(void)
 {
-       omap_common_late_init();
-       omap2_clk_enable_autoidle_all();
+       omap_pm_soc_init = omap_pm_nop_init;
 }
 #endif
 
@@ -621,8 +578,7 @@ void __init am33xx_init_early(void)
 
 void __init am33xx_init_late(void)
 {
-       omap_common_late_init();
-       amx3_common_pm_init();
+       omap_pm_soc_init = amx3_common_pm_init;
 }
 #endif
 
@@ -645,9 +601,7 @@ void __init am43xx_init_early(void)
 
 void __init am43xx_init_late(void)
 {
-       omap_common_late_init();
-       omap2_clk_enable_autoidle_all();
-       amx3_common_pm_init();
+       omap_pm_soc_init = amx3_common_pm_init;
 }
 #endif
 
@@ -675,9 +629,7 @@ void __init omap4430_init_early(void)
 
 void __init omap4430_init_late(void)
 {
-       omap_common_late_init();
-       omap4_pm_init();
-       omap2_clk_enable_autoidle_all();
+       omap_pm_soc_init = omap4_pm_init;
 }
 #endif
 
@@ -703,9 +655,7 @@ void __init omap5_init_early(void)
 
 void __init omap5_init_late(void)
 {
-       omap_common_late_init();
-       omap4_pm_init();
-       omap2_clk_enable_autoidle_all();
+       omap_pm_soc_init = omap4_pm_init;
 }
 #endif
 
@@ -728,9 +678,7 @@ void __init dra7xx_init_early(void)
 
 void __init dra7xx_init_late(void)
 {
-       omap_common_late_init();
-       omap4_pm_init();
-       omap2_clk_enable_autoidle_all();
+       omap_pm_soc_init = omap4_pm_init;
 }
 #endif
 
diff --git a/arch/arm/mach-omap2/omap-pm-noop.c b/arch/arm/mach-omap2/omap-pm-noop.c
deleted file mode 100644 (file)
index 4ead077..0000000
+++ /dev/null
@@ -1,176 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * omap-pm-noop.c - OMAP power management interface - dummy version
- *
- * This code implements the OMAP power management interface to
- * drivers, CPUIdle, CPUFreq, and DSP Bridge.  It is strictly for
- * debug/demonstration use, as it does nothing but printk() whenever a
- * function is called (when DEBUG is defined, below)
- *
- * Copyright (C) 2008-2009 Texas Instruments, Inc.
- * Copyright (C) 2008-2009 Nokia Corporation
- * Paul Walmsley
- *
- * Interface developed by (in alphabetical order):
- * Karthik Dasu, Tony Lindgren, Rajendra Nayak, Sakari Poussa, Veeramanikandan
- * Raju, Anand Sawant, Igor Stoppa, Paul Walmsley, Richard Woodruff
- */
-
-#undef DEBUG
-
-#include <linux/init.h>
-#include <linux/cpufreq.h>
-#include <linux/device.h>
-#include <linux/platform_device.h>
-
-#include "omap_device.h"
-#include "omap-pm.h"
-
-static bool off_mode_enabled;
-static int dummy_context_loss_counter;
-
-/*
- * Device-driver-originated constraints (via board-*.c files)
- */
-
-int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t)
-{
-       if (!dev || t < -1) {
-               WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
-               return -EINVAL;
-       }
-
-       if (t == -1)
-               pr_debug("OMAP PM: remove max MPU wakeup latency constraint: dev %s\n",
-                        dev_name(dev));
-       else
-               pr_debug("OMAP PM: add max MPU wakeup latency constraint: dev %s, t = %ld usec\n",
-                        dev_name(dev), t);
-
-       /*
-        * For current Linux, this needs to map the MPU to a
-        * powerdomain, then go through the list of current max lat
-        * constraints on the MPU and find the smallest.  If
-        * the latency constraint has changed, the code should
-        * recompute the state to enter for the next powerdomain
-        * state.
-        *
-        * TI CDP code can call constraint_set here.
-        */
-
-       return 0;
-}
-
-int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r)
-{
-       if (!dev || (agent_id != OCP_INITIATOR_AGENT &&
-           agent_id != OCP_TARGET_AGENT)) {
-               WARN(1, "OMAP PM: %s: invalid parameter(s)", __func__);
-               return -EINVAL;
-       }
-
-       if (r == 0)
-               pr_debug("OMAP PM: remove min bus tput constraint: dev %s for agent_id %d\n",
-                        dev_name(dev), agent_id);
-       else
-               pr_debug("OMAP PM: add min bus tput constraint: dev %s for agent_id %d: rate %ld KiB\n",
-                        dev_name(dev), agent_id, r);
-
-       /*
-        * This code should model the interconnect and compute the
-        * required clock frequency, convert that to a VDD2 OPP ID, then
-        * set the VDD2 OPP appropriately.
-        *
-        * TI CDP code can call constraint_set here on the VDD2 OPP.
-        */
-
-       return 0;
-}
-
-/*
- * DSP Bridge-specific constraints
- */
-
-
-/**
- * omap_pm_enable_off_mode - notify OMAP PM that off-mode is enabled
- *
- * Intended for use only by OMAP PM core code to notify this layer
- * that off mode has been enabled.
- */
-void omap_pm_enable_off_mode(void)
-{
-       off_mode_enabled = true;
-}
-
-/**
- * omap_pm_disable_off_mode - notify OMAP PM that off-mode is disabled
- *
- * Intended for use only by OMAP PM core code to notify this layer
- * that off mode has been disabled.
- */
-void omap_pm_disable_off_mode(void)
-{
-       off_mode_enabled = false;
-}
-
-/*
- * Device context loss tracking
- */
-
-#ifdef CONFIG_ARCH_OMAP2PLUS
-
-int omap_pm_get_dev_context_loss_count(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       int count;
-
-       if (WARN_ON(!dev))
-               return -ENODEV;
-
-       if (dev->pm_domain == &omap_device_pm_domain) {
-               count = omap_device_get_context_loss_count(pdev);
-       } else {
-               WARN_ONCE(off_mode_enabled, "omap_pm: using dummy context loss counter; device %s should be converted to omap_device",
-                         dev_name(dev));
-
-               count = dummy_context_loss_counter;
-
-               if (off_mode_enabled) {
-                       count++;
-                       /*
-                        * Context loss count has to be a non-negative value.
-                        * Clear the sign bit to get a value range from 0 to
-                        * INT_MAX.
-                        */
-                       count &= INT_MAX;
-                       dummy_context_loss_counter = count;
-               }
-       }
-
-       pr_debug("OMAP PM: context loss count for dev %s = %d\n",
-                dev_name(dev), count);
-
-       return count;
-}
-
-#else
-
-int omap_pm_get_dev_context_loss_count(struct device *dev)
-{
-       return dummy_context_loss_counter;
-}
-
-#endif
-
-/* Should be called before clk framework init */
-int __init omap_pm_if_early_init(void)
-{
-       return 0;
-}
-
-/* Must be called after clock framework is initialized */
-int __init omap_pm_if_init(void)
-{
-       return 0;
-}
diff --git a/arch/arm/mach-omap2/omap-pm.h b/arch/arm/mach-omap2/omap-pm.h
deleted file mode 100644 (file)
index 5ba5df4..0000000
+++ /dev/null
@@ -1,161 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * omap-pm.h - OMAP power management interface
- *
- * Copyright (C) 2008-2010 Texas Instruments, Inc.
- * Copyright (C) 2008-2010 Nokia Corporation
- * Paul Walmsley
- *
- * Interface developed by (in alphabetical order): Karthik Dasu, Jouni
- * Högander, Tony Lindgren, Rajendra Nayak, Sakari Poussa,
- * Veeramanikandan Raju, Anand Sawant, Igor Stoppa, Paul Walmsley,
- * Richard Woodruff
- */
-
-#ifndef ASM_ARM_ARCH_OMAP_OMAP_PM_H
-#define ASM_ARM_ARCH_OMAP_OMAP_PM_H
-
-#include <linux/device.h>
-#include <linux/cpufreq.h>
-#include <linux/clk.h>
-#include <linux/pm_opp.h>
-
-/*
- * agent_id values for use with omap_pm_set_min_bus_tput():
- *
- * OCP_INITIATOR_AGENT is only valid for devices that can act as
- * initiators -- it represents the device's L3 interconnect
- * connection.  OCP_TARGET_AGENT represents the device's L4
- * interconnect connection.
- */
-#define OCP_TARGET_AGENT               1
-#define OCP_INITIATOR_AGENT            2
-
-/**
- * omap_pm_if_early_init - OMAP PM init code called before clock fw init
- * @mpu_opp_table: array ptr to struct omap_opp for MPU
- * @dsp_opp_table: array ptr to struct omap_opp for DSP
- * @l3_opp_table : array ptr to struct omap_opp for CORE
- *
- * Initialize anything that must be configured before the clock
- * framework starts.  The "_if_" is to avoid name collisions with the
- * PM idle-loop code.
- */
-int __init omap_pm_if_early_init(void);
-
-/**
- * omap_pm_if_init - OMAP PM init code called after clock fw init
- *
- * The main initialization code.  OPP tables are passed in here.  The
- * "_if_" is to avoid name collisions with the PM idle-loop code.
- */
-int __init omap_pm_if_init(void);
-
-/*
- * Device-driver-originated constraints (via board-*.c files, platform_data)
- */
-
-
-/**
- * omap_pm_set_max_mpu_wakeup_lat - set the maximum MPU wakeup latency
- * @dev: struct device * requesting the constraint
- * @t: maximum MPU wakeup latency in microseconds
- *
- * Request that the maximum interrupt latency for the MPU to be no
- * greater than @t microseconds. "Interrupt latency" in this case is
- * defined as the elapsed time from the occurrence of a hardware or
- * timer interrupt to the time when the device driver's interrupt
- * service routine has been entered by the MPU.
- *
- * It is intended that underlying PM code will use this information to
- * determine what power state to put the MPU powerdomain into, and
- * possibly the CORE powerdomain as well, since interrupt handling
- * code currently runs from SDRAM.  Advanced PM or board*.c code may
- * also configure interrupt controller priorities, OCP bus priorities,
- * CPU speed(s), etc.
- *
- * This function will not affect device wakeup latency, e.g., time
- * elapsed from when a device driver enables a hardware device with
- * clk_enable(), to when the device is ready for register access or
- * other use.  To control this device wakeup latency, use
- * omap_pm_set_max_dev_wakeup_lat()
- *
- * Multiple calls to omap_pm_set_max_mpu_wakeup_lat() will replace the
- * previous t value.  To remove the latency target for the MPU, call
- * with t = -1.
- *
- * XXX This constraint will be deprecated soon in favor of the more
- * general omap_pm_set_max_dev_wakeup_lat()
- *
- * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
- * is not satisfiable, or 0 upon success.
- */
-int omap_pm_set_max_mpu_wakeup_lat(struct device *dev, long t);
-
-
-/**
- * omap_pm_set_min_bus_tput - set minimum bus throughput needed by device
- * @dev: struct device * requesting the constraint
- * @tbus_id: interconnect to operate on (OCP_{INITIATOR,TARGET}_AGENT)
- * @r: minimum throughput (in KiB/s)
- *
- * Request that the minimum data throughput on the OCP interconnect
- * attached to device @dev interconnect agent @tbus_id be no less
- * than @r KiB/s.
- *
- * It is expected that the OMAP PM or bus code will use this
- * information to set the interconnect clock to run at the lowest
- * possible speed that satisfies all current system users.  The PM or
- * bus code will adjust the estimate based on its model of the bus, so
- * device driver authors should attempt to specify an accurate
- * quantity for their device use case, and let the PM or bus code
- * overestimate the numbers as necessary to handle request/response
- * latency, other competing users on the system, etc.  On OMAP2/3, if
- * a driver requests a minimum L4 interconnect speed constraint, the
- * code will also need to add an minimum L3 interconnect speed
- * constraint,
- *
- * Multiple calls to omap_pm_set_min_bus_tput() will replace the
- * previous rate value for this device.  To remove the interconnect
- * throughput restriction for this device, call with r = 0.
- *
- * Returns -EINVAL for an invalid argument, -ERANGE if the constraint
- * is not satisfiable, or 0 upon success.
- */
-int omap_pm_set_min_bus_tput(struct device *dev, u8 agent_id, unsigned long r);
-
-
-/*
- * CPUFreq-originated constraint
- *
- * In the future, this should be handled by custom OPP clocktype
- * functions.
- */
-
-
-/*
- * Device context loss tracking
- */
-
-/**
- * omap_pm_get_dev_context_loss_count - return count of times dev has lost ctx
- * @dev: struct device *
- *
- * This function returns the number of times that the device @dev has
- * lost its internal context.  This generally occurs on a powerdomain
- * transition to OFF.  Drivers use this as an optimization to avoid restoring
- * context if the device hasn't lost it.  To use, drivers should initially
- * call this in their context save functions and store the result.  Early in
- * the driver's context restore function, the driver should call this function
- * again, and compare the result to the stored counter.  If they differ, the
- * driver must restore device context.   If the number of context losses
- * exceeds the maximum positive integer, the function will wrap to 0 and
- * continue counting.  Returns the number of context losses for this device,
- * or negative value upon error.
- */
-int omap_pm_get_dev_context_loss_count(struct device *dev);
-
-void omap_pm_enable_off_mode(void);
-void omap_pm_disable_off_mode(void);
-
-#endif
index 3b829a50d1dbb6258f7e8a18bc6a042c0c2c6ea3..41c7b905980a9e7a37a512cf26c06a428b4e9ca6 100644 (file)
@@ -143,7 +143,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
        struct resource res;
        const char *oh_name;
        int oh_cnt, i, ret = 0;
-       bool device_active = false;
+       bool device_active = false, skip_pm_domain = false;
 
        oh_cnt = of_property_count_strings(node, "ti,hwmods");
        if (oh_cnt <= 0) {
@@ -151,11 +151,18 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
                return -ENODEV;
        }
 
+       /* SDMA still needs special handling for omap_device_build() */
+       ret = of_property_read_string_index(node, "ti,hwmods", 0, &oh_name);
+       if (!ret && (!strncmp("dma_system", oh_name, 10) ||
+                    !strncmp("dma", oh_name, 3)))
+               skip_pm_domain = true;
+
        /* Use ti-sysc driver instead of omap_device? */
-       if (!omap_hwmod_parse_module_range(NULL, node, &res))
+       if (!skip_pm_domain &&
+           !omap_hwmod_parse_module_range(NULL, node, &res))
                return -ENODEV;
 
-       hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
+       hwmods = kcalloc(oh_cnt, sizeof(struct omap_hwmod *), GFP_KERNEL);
        if (!hwmods) {
                ret = -ENOMEM;
                goto odbfd_exit;
@@ -191,11 +198,12 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
                        r->name = dev_name(&pdev->dev);
        }
 
-       dev_pm_domain_set(&pdev->dev, &omap_device_pm_domain);
-
-       if (device_active) {
-               omap_device_enable(pdev);
-               pm_runtime_set_active(&pdev->dev);
+       if (!skip_pm_domain) {
+               dev_pm_domain_set(&pdev->dev, &omap_device_pm_domain);
+               if (device_active) {
+                       omap_device_enable(pdev);
+                       pm_runtime_set_active(&pdev->dev);
+               }
        }
 
 odbfd_exit1:
@@ -405,7 +413,7 @@ omap_device_copy_resources(struct omap_hwmod *oh,
                goto error;
        }
 
-       res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
+       res = kcalloc(2, sizeof(*res), GFP_KERNEL);
        if (!res)
                return -ENOMEM;
 
index e7d23e200eccf87e9ff9e366ca25130278b12831..2ceffd85dd3d3fbcc4f80ae831713b37d23a83f3 100644 (file)
@@ -481,7 +481,7 @@ static int _wait_softreset_complete(struct omap_hwmod *oh)
 
        sysc = oh->class->sysc;
 
-       if (sysc->sysc_flags & SYSS_HAS_RESET_STATUS)
+       if (sysc->sysc_flags & SYSS_HAS_RESET_STATUS && sysc->syss_offs > 0)
                omap_test_timeout((omap_hwmod_read(oh, sysc->syss_offs)
                                   & SYSS_RESETDONE_MASK),
                                  MAX_MODULE_SOFTRESET_WAIT, c);
@@ -3171,19 +3171,19 @@ static int omap_hwmod_init_regbits(struct device *dev,
  */
 int omap_hwmod_init_reg_offs(struct device *dev,
                             const struct ti_sysc_module_data *data,
-                            u32 *rev_offs, u32 *sysc_offs, u32 *syss_offs)
+                            s32 *rev_offs, s32 *sysc_offs, s32 *syss_offs)
 {
-       *rev_offs = 0;
+       *rev_offs = -ENODEV;
        *sysc_offs = 0;
        *syss_offs = 0;
 
-       if (data->offsets[SYSC_REVISION] > 0)
+       if (data->offsets[SYSC_REVISION] >= 0)
                *rev_offs = data->offsets[SYSC_REVISION];
 
-       if (data->offsets[SYSC_SYSCONFIG] > 0)
+       if (data->offsets[SYSC_SYSCONFIG] >= 0)
                *sysc_offs = data->offsets[SYSC_SYSCONFIG];
 
-       if (data->offsets[SYSC_SYSSTATUS] > 0)
+       if (data->offsets[SYSC_SYSSTATUS] >= 0)
                *syss_offs = data->offsets[SYSC_SYSSTATUS];
 
        return 0;
@@ -3312,8 +3312,8 @@ static int omap_hwmod_check_module(struct device *dev,
                                   struct omap_hwmod *oh,
                                   const struct ti_sysc_module_data *data,
                                   struct sysc_regbits *sysc_fields,
-                                  u32 rev_offs, u32 sysc_offs,
-                                  u32 syss_offs, u32 sysc_flags,
+                                  s32 rev_offs, s32 sysc_offs,
+                                  s32 syss_offs, u32 sysc_flags,
                                   u32 idlemodes)
 {
        if (!oh->class->sysc)
@@ -3365,7 +3365,7 @@ static int omap_hwmod_check_module(struct device *dev,
 int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,
                               const struct ti_sysc_module_data *data,
                               struct sysc_regbits *sysc_fields,
-                              u32 rev_offs, u32 sysc_offs, u32 syss_offs,
+                              s32 rev_offs, s32 sysc_offs, s32 syss_offs,
                               u32 sysc_flags, u32 idlemodes)
 {
        struct omap_hwmod_class_sysconfig *sysc;
@@ -3425,7 +3425,8 @@ int omap_hwmod_init_module(struct device *dev,
 {
        struct omap_hwmod *oh;
        struct sysc_regbits *sysc_fields;
-       u32 rev_offs, sysc_offs, syss_offs, sysc_flags, idlemodes;
+       s32 rev_offs, sysc_offs, syss_offs;
+       u32 sysc_flags, idlemodes;
        int error;
 
        if (!dev || !data)
index c7122abbf9771831967eae9b7a6c44364fb2bbd2..b70cdc21f8a2b1ecfdffb7157c67c65a18d80db1 100644 (file)
@@ -317,9 +317,9 @@ struct omap_hwmod_ocp_if {
  * then this field has to be populated with the correct offset structure.
  */
 struct omap_hwmod_class_sysconfig {
-       u32 rev_offs;
-       u32 sysc_offs;
-       u32 syss_offs;
+       s32 rev_offs;
+       s32 sysc_offs;
+       s32 syss_offs;
        u16 sysc_flags;
        struct sysc_regbits *sysc_fields;
        u8 srst_udelay;
index fe66cf2478741c00a48f82addf68ef7782d8a7c6..d684fac8f592846ced792ac45a87f3c297b01baa 100644 (file)
@@ -13,7 +13,7 @@
  * XXX these should be marked initdata for multi-OMAP kernels
  */
 
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 #include <linux/omap-dma.h>
 
 #include "omap_hwmod.h"
index 74eefd30518c9dd59420ce9f3517987cac897df4..abef9f6f9bf57dd95452c73c22c41168aa7c5de2 100644 (file)
@@ -13,7 +13,7 @@
  * XXX these should be marked initdata for multi-OMAP kernels
  */
 
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 #include <linux/platform_data/hsmmc-omap.h>
 #include <linux/omap-dma.h>
 
index 5efe91c6e95befc207e17dd0904ff46aa810780b..9ded7bf972e714dba0fc12e7b261b512823fe2a7 100644 (file)
@@ -629,6 +629,7 @@ struct omap_hwmod am33xx_gpmc_hwmod = {
 
 /* 'i2c' class */
 static struct omap_hwmod_class_sysconfig am33xx_i2c_sysc = {
+       .rev_offs       = 0,
        .sysc_offs      = 0x0010,
        .syss_offs      = 0x0090,
        .sysc_flags     = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY |
index 53e1ac3724f287fb94c803a07d50a2eb3436f32f..c9483bc062280bf2174ee83730a7455d93591161 100644 (file)
@@ -14,7 +14,7 @@
  * GNU General Public License for more details.
  */
 
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 
 #include "omap_hwmod.h"
 #include "omap_hwmod_common_data.h"
index 23336b6c712541b2f7050233ab54722c191c4b63..23e6a41a18eb3c184f562215c0970a4d9d828268 100644 (file)
@@ -15,7 +15,7 @@
  * XXX these should be marked initdata for multi-OMAP kernels
  */
 
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 #include <linux/power/smartreflex.h>
 #include <linux/platform_data/hsmmc-omap.h>
 
@@ -885,6 +885,7 @@ static struct omap_hwmod omap3xxx_dma_system_hwmod = {
  */
 
 static struct omap_hwmod_class_sysconfig omap3xxx_mcbsp_sysc = {
+       .rev_offs       = -ENODEV,
        .sysc_offs      = 0x008c,
        .sysc_flags     = (SYSC_HAS_CLOCKACTIVITY | SYSC_HAS_ENAWAKEUP |
                           SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET),
@@ -990,6 +991,7 @@ static struct omap_hwmod omap3xxx_mcbsp5_hwmod = {
 
 /* 'mcbsp sidetone' class */
 static struct omap_hwmod_class_sysconfig omap3xxx_mcbsp_sidetone_sysc = {
+       .rev_offs       = -ENODEV,
        .sysc_offs      = 0x0010,
        .sysc_flags     = SYSC_HAS_AUTOIDLE,
        .sysc_fields    = &omap_hwmod_sysc_type1,
@@ -1018,6 +1020,7 @@ static struct omap_hwmod omap3xxx_mcbsp3_sidetone_hwmod = {
 
 /* SR common */
 static struct omap_hwmod_class_sysconfig omap34xx_sr_sysc = {
+       .rev_offs       = -ENODEV,
        .sysc_offs      = 0x24,
        .sysc_flags     = (SYSC_HAS_CLOCKACTIVITY | SYSC_NO_CACHE),
        .sysc_fields    = &omap34xx_sr_sysc_fields,
@@ -1030,6 +1033,7 @@ static struct omap_hwmod_class omap34xx_smartreflex_hwmod_class = {
 };
 
 static struct omap_hwmod_class_sysconfig omap36xx_sr_sysc = {
+       .rev_offs       = -ENODEV,
        .sysc_offs      = 0x38,
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
        .sysc_flags     = (SYSC_HAS_SIDLEMODE | SYSC_HAS_ENAWAKEUP |
index 5f73b730d4fc7c89f3819c2cd76da42c4093f22e..aa271ac5ebac51dbe909552b3b807a0f5575b2dc 100644 (file)
@@ -378,6 +378,7 @@ static struct omap_hwmod am43xx_usb_otg_ss1_hwmod = {
 };
 
 static struct omap_hwmod_class_sysconfig am43xx_qspi_sysc = {
+       .rev_offs       = 0,
        .sysc_offs      = 0x0010,
        .sysc_flags     = SYSC_HAS_SIDLEMODE,
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
index e4f8ae9cd63711295b39d9e3a46d0931980337c4..a95dbac57a814a92d23e660f2273549da6cce2cc 100644 (file)
@@ -23,7 +23,7 @@
 #include <linux/io.h>
 #include <linux/platform_data/hsmmc-omap.h>
 #include <linux/power/smartreflex.h>
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 
 #include <linux/omap-dma.h>
 
@@ -1360,6 +1360,7 @@ static struct omap_hwmod omap44xx_hsi_hwmod = {
  */
 
 static struct omap_hwmod_class_sysconfig omap44xx_i2c_sysc = {
+       .rev_offs       = 0,
        .sysc_offs      = 0x0010,
        .syss_offs      = 0x0090,
        .sysc_flags     = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY |
@@ -1634,6 +1635,7 @@ static struct omap_hwmod omap44xx_mailbox_hwmod = {
 
 /* The IP is not compliant to type1 / type2 scheme */
 static struct omap_hwmod_class_sysconfig omap44xx_mcasp_sysc = {
+       .rev_offs       = 0,
        .sysc_offs      = 0x0004,
        .sysc_flags     = SYSC_HAS_SIDLEMODE,
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
@@ -1667,6 +1669,7 @@ static struct omap_hwmod omap44xx_mcasp_hwmod = {
  */
 
 static struct omap_hwmod_class_sysconfig omap44xx_mcbsp_sysc = {
+       .rev_offs       = -ENODEV,
        .sysc_offs      = 0x008c,
        .sysc_flags     = (SYSC_HAS_CLOCKACTIVITY | SYSC_HAS_ENAWAKEUP |
                           SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET),
@@ -2353,6 +2356,7 @@ static struct omap_hwmod omap44xx_slimbus2_hwmod = {
 
 /* The IP is not compliant to type1 / type2 scheme */
 static struct omap_hwmod_class_sysconfig omap44xx_smartreflex_sysc = {
+       .rev_offs       = -ENODEV,
        .sysc_offs      = 0x0038,
        .sysc_flags     = (SYSC_HAS_ENAWAKEUP | SYSC_HAS_SIDLEMODE),
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
index c72cd84b07ece729775e2ef6002b664256c0ed02..115473d441cde08bdbf360572b35ca41ae500ebd 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/io.h>
 #include <linux/platform_data/hsmmc-omap.h>
 #include <linux/power/smartreflex.h>
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 
 #include <linux/omap-dma.h>
 
@@ -804,6 +804,7 @@ static struct omap_hwmod omap54xx_gpio8_hwmod = {
  */
 
 static struct omap_hwmod_class_sysconfig omap54xx_i2c_sysc = {
+       .rev_offs       = 0,
        .sysc_offs      = 0x0010,
        .syss_offs      = 0x0090,
        .sysc_flags     = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY |
@@ -974,6 +975,7 @@ static struct omap_hwmod omap54xx_mailbox_hwmod = {
  */
 
 static struct omap_hwmod_class_sysconfig omap54xx_mcbsp_sysc = {
+       .rev_offs       = -ENODEV,
        .sysc_offs      = 0x008c,
        .sysc_flags     = (SYSC_HAS_CLOCKACTIVITY | SYSC_HAS_ENAWAKEUP |
                           SYSC_HAS_SIDLEMODE | SYSC_HAS_SOFTRESET),
@@ -1997,6 +1999,7 @@ static struct omap_hwmod omap54xx_ocp2scp3_hwmod = {
  */
 
 static struct omap_hwmod_class_sysconfig omap54xx_sata_sysc = {
+       .rev_offs       = 0x00fc,
        .sysc_offs      = 0x0000,
        .sysc_flags     = (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE),
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
index 62352d1e63612b83707d5566450367c3e74a12bb..e6c7061a8e73679695f7816c0461ccccf66151c6 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/io.h>
 #include <linux/platform_data/hsmmc-omap.h>
 #include <linux/power/smartreflex.h>
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 
 #include <linux/omap-dma.h>
 
@@ -1070,6 +1070,7 @@ static struct omap_hwmod dra7xx_hdq1w_hwmod = {
  */
 
 static struct omap_hwmod_class_sysconfig dra7xx_i2c_sysc = {
+       .rev_offs       = 0,
        .sysc_offs      = 0x0010,
        .syss_offs      = 0x0090,
        .sysc_flags     = (SYSC_HAS_AUTOIDLE | SYSC_HAS_CLOCKACTIVITY |
@@ -1440,6 +1441,7 @@ static struct omap_hwmod dra7xx_mcspi4_hwmod = {
  *
  */
 static struct omap_hwmod_class_sysconfig dra7xx_mcasp_sysc = {
+       .rev_offs       = 0,
        .sysc_offs      = 0x0004,
        .sysc_flags     = SYSC_HAS_SIDLEMODE,
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART),
@@ -1898,6 +1900,7 @@ static struct omap_hwmod dra7xx_pciess2_hwmod = {
  */
 
 static struct omap_hwmod_class_sysconfig dra7xx_qspi_sysc = {
+       .rev_offs       = 0,
        .sysc_offs      = 0x0010,
        .sysc_flags     = SYSC_HAS_SIDLEMODE,
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
@@ -1930,6 +1933,7 @@ static struct omap_hwmod dra7xx_qspi_hwmod = {
  *
  */
 static struct omap_hwmod_class_sysconfig dra7xx_rtcss_sysc = {
+       .rev_offs       = 0x0074,
        .sysc_offs      = 0x0078,
        .sysc_flags     = SYSC_HAS_SIDLEMODE,
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
@@ -1965,6 +1969,7 @@ static struct omap_hwmod dra7xx_rtcss_hwmod = {
  */
 
 static struct omap_hwmod_class_sysconfig dra7xx_sata_sysc = {
+       .rev_offs       = 0x00fc,
        .sysc_offs      = 0x0000,
        .sysc_flags     = (SYSC_HAS_MIDLEMODE | SYSC_HAS_SIDLEMODE),
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
@@ -2003,6 +2008,7 @@ static struct omap_hwmod dra7xx_sata_hwmod = {
 
 /* The IP is not compliant to type1 / type2 scheme */
 static struct omap_hwmod_class_sysconfig dra7xx_smartreflex_sysc = {
+       .rev_offs       = -ENODEV,
        .sysc_offs      = 0x0038,
        .sysc_flags     = (SYSC_HAS_ENAWAKEUP | SYSC_HAS_SIDLEMODE),
        .idlemodes      = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART |
index 686655f884c15a562e9408a0ea7389cf44f2f8fb..8e44e2728620f52f3c51f8c7ebe143f6755720b7 100644 (file)
@@ -954,6 +954,7 @@ static struct omap_hwmod_ocp_if dm816x_l4_hs__emac1 = {
 };
 
 static struct omap_hwmod_class_sysconfig dm81xx_sata_sysc = {
+       .rev_offs       = 0x00fc,
        .sysc_offs      = 0x1100,
        .sysc_flags     = SYSC_HAS_SIDLEMODE,
        .idlemodes      = SIDLE_FORCE,
index 6459816c2879ff9536b93f38f2cb786e0b30b780..7f02743edbe4c7880bb12feccb4d6a1683ca276d 100644 (file)
 #include <linux/platform_data/iommu-omap.h>
 #include <linux/platform_data/ti-sysc.h>
 #include <linux/platform_data/wkup_m3.h>
-#include <linux/platform_data/media/ir-rx51.h>
 #include <linux/platform_data/asoc-ti-mcbsp.h>
 
 #include "common.h"
 #include "common-board-devices.h"
 #include "control.h"
 #include "omap_device.h"
-#include "omap-pm.h"
 #include "omap-secure.h"
 #include "soc.h"
 #include "hsmmc.h"
@@ -514,18 +512,6 @@ void omap_auxdata_legacy_init(struct device *dev)
        dev->platform_data = &twl_gpio_auxdata;
 }
 
-static struct ir_rx51_platform_data __maybe_unused rx51_ir_data = {
-       .set_max_mpu_wakeup_lat = omap_pm_set_max_mpu_wakeup_lat,
-};
-
-static struct platform_device __maybe_unused rx51_ir_device = {
-       .name           = "ir_rx51",
-       .id             = -1,
-       .dev            = {
-               .platform_data = &rx51_ir_data,
-       },
-};
-
 #if IS_ENABLED(CONFIG_SND_OMAP_SOC_MCBSP)
 static struct omap_mcbsp_platform_data mcbsp_pdata;
 static void __init omap3_mcbsp_init(void)
@@ -569,7 +555,6 @@ static struct of_dev_auxdata omap_auxdata_lookup[] = {
                       "480c9000.smartreflex", &omap_sr_pdata[OMAP_SR_MPU]),
        OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x4809c000, "4809c000.mmc", &mmc_pdata[0]),
        OF_DEV_AUXDATA("ti,omap3-hsmmc", 0x480b4000, "480b4000.mmc", &mmc_pdata[1]),
-       OF_DEV_AUXDATA("nokia,n900-ir", 0, "n900-ir", &rx51_ir_data),
        /* Only on am3517 */
        OF_DEV_AUXDATA("ti,davinci_mdio", 0x5c030000, "davinci_mdio.0", NULL),
        OF_DEV_AUXDATA("ti,am3517-emac", 0x5c000000, "davinci_emac.0",
index 5c46ea6756d7b1dcbe8e6a6afd9cddc556880e04..acb698d5780f84a74bc21a25129d2bdb41b77e61 100644 (file)
@@ -31,7 +31,6 @@
 #include "clock.h"
 #include "powerdomain.h"
 #include "clockdomain.h"
-#include "omap-pm.h"
 
 #include "soc.h"
 #include "cm2xxx_3xxx.h"
@@ -240,10 +239,6 @@ static int option_set(void *data, u64 val)
        *option = val;
 
        if (option == &enable_off_mode) {
-               if (val)
-                       omap_pm_enable_off_mode();
-               else
-                       omap_pm_disable_off_mode();
                if (cpu_is_omap34xx())
                        omap3_pm_off_mode_enable(val);
        }
index 6f68576e56956a635acae35af565d09bb2ff2d0f..ca03af8fe43ffc21a0252233e4cc2e1bb38cd771 100644 (file)
 #include <linux/pm_opp.h>
 #include <linux/export.h>
 #include <linux/suspend.h>
+#include <linux/clk.h>
 #include <linux/cpu.h>
 
 #include <asm/system_misc.h>
 
-#include "omap-pm.h"
 #include "omap_device.h"
 #include "common.h"
 
@@ -230,16 +230,20 @@ static void __init omap4_init_voltages(void)
        omap2_set_init_voltage("iva", "dpll_iva_m5x2_ck", "iva");
 }
 
-static int __init omap2_common_pm_init(void)
+int __maybe_unused omap_pm_nop_init(void)
 {
-       omap_pm_if_init();
-
        return 0;
 }
-omap_postcore_initcall(omap2_common_pm_init);
+
+int (*omap_pm_soc_init)(void);
 
 int __init omap2_common_pm_late_init(void)
 {
+       int error;
+
+       if (!omap_pm_soc_init)
+               return 0;
+
        /* Init the voltage layer */
        omap3_twl_init();
        omap4_twl_init();
@@ -252,5 +256,12 @@ int __init omap2_common_pm_late_init(void)
        /* Smartreflex device init */
        omap_devinit_smartreflex();
 
+       error = omap_pm_soc_init();
+       if (error)
+               pr_warn("%s: pm soc init failed: %i\n", __func__, error);
+
+       omap2_clk_enable_autoidle_all();
+
        return 0;
 }
+omap_late_initcall(omap2_common_pm_late_init);
index 93c0b5ba9f09c57acc62b0ac7d7a6cbffd45738b..9b3755a2e2ecdeceb5007f8bed14c1720a64e2da 100644 (file)
@@ -173,7 +173,7 @@ static struct am33xx_pm_platform_data *am33xx_pm_get_pdata(void)
                return NULL;
 }
 
-void __init amx3_common_pm_init(void)
+int __init amx3_common_pm_init(void)
 {
        struct am33xx_pm_platform_data *pdata;
        struct platform_device_info devinfo;
@@ -186,4 +186,6 @@ void __init amx3_common_pm_init(void)
        devinfo.size_data = sizeof(*pdata);
        devinfo.id = -1;
        platform_device_register_full(&devinfo);
+
+       return 0;
 }
index b3870220612e60df778593529d518253085baf2d..78e1ace7d17d64bbfe619cc35e6c4d771fda82b9 100644 (file)
@@ -131,6 +131,19 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
                return 0;
        }
 
+       /*
+        * Bootloader or kexec boot may have LOGICRETSTATE cleared
+        * for some domains. This is the case when kexec booting from
+        * Android kernels that support off mode for example.
+        * Make sure it's set at least for core and per, otherwise
+        * we currently will see lost GPIO interrupts for wlcore and
+        * smsc911x at least if per hits retention during idle.
+        */
+       if (!strncmp(pwrdm->name, "core", 4) ||
+           !strncmp(pwrdm->name, "l4per", 5) ||
+           !strncmp(pwrdm->name, "wkup", 4))
+               pwrdm_set_logic_retst(pwrdm, PWRDM_POWER_RET);
+
        pwrst = kmalloc(sizeof(struct power_state), GFP_ATOMIC);
        if (!pwrst)
                return -ENOMEM;
index 1e6a967cd2d5890342fb76bbe3b0c8c42ec6491d..1a0f69c0a37638ce10985aea2f027a11bb371ba8 100644 (file)
@@ -14,6 +14,7 @@
  */
 #undef DEBUG
 
+#include <linux/cpu_pm.h>
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/list.h>
@@ -39,6 +40,9 @@
 
 #define PWRDM_TRACE_STATES_FLAG        (1<<31)
 
+void pwrdms_save_context(void);
+void pwrdms_restore_context(void);
+
 enum {
        PWRDM_STATE_NOW = 0,
        PWRDM_STATE_PREV,
@@ -333,6 +337,22 @@ int pwrdm_register_pwrdms(struct powerdomain **ps)
        return 0;
 }
 
+static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
+{
+       switch (cmd) {
+       case CPU_CLUSTER_PM_ENTER:
+               if (enable_off_mode)
+                       pwrdms_save_context();
+               break;
+       case CPU_CLUSTER_PM_EXIT:
+               if (enable_off_mode)
+                       pwrdms_restore_context();
+               break;
+       }
+
+       return NOTIFY_OK;
+}
+
 /**
  * pwrdm_complete_init - set up the powerdomain layer
  *
@@ -347,6 +367,7 @@ int pwrdm_register_pwrdms(struct powerdomain **ps)
 int pwrdm_complete_init(void)
 {
        struct powerdomain *temp_p;
+       static struct notifier_block nb;
 
        if (list_empty(&pwrdm_list))
                return -EACCES;
@@ -354,6 +375,12 @@ int pwrdm_complete_init(void)
        list_for_each_entry(temp_p, &pwrdm_list, node)
                pwrdm_set_next_pwrst(temp_p, PWRDM_POWER_ON);
 
+       /* Only AM43XX can lose pwrdm context during rtc-ddr suspend */
+       if (soc_is_am43xx()) {
+               nb.notifier_call = cpu_notifier;
+               cpu_pm_register_notifier(&nb);
+       }
+
        return 0;
 }
 
@@ -1199,3 +1226,63 @@ bool pwrdm_can_ever_lose_context(struct powerdomain *pwrdm)
 
        return 0;
 }
+
+/**
+ * pwrdm_save_context - save powerdomain registers
+ *
+ * Register state is going to be lost due to a suspend or hibernate
+ * event. Save the powerdomain registers.
+ */
+static int pwrdm_save_context(struct powerdomain *pwrdm, void *unused)
+{
+       if (arch_pwrdm && arch_pwrdm->pwrdm_save_context)
+               arch_pwrdm->pwrdm_save_context(pwrdm);
+       return 0;
+}
+
+/**
+ * pwrdm_save_context - restore powerdomain registers
+ *
+ * Restore powerdomain control registers after a suspend or resume
+ * event.
+ */
+static int pwrdm_restore_context(struct powerdomain *pwrdm, void *unused)
+{
+       if (arch_pwrdm && arch_pwrdm->pwrdm_restore_context)
+               arch_pwrdm->pwrdm_restore_context(pwrdm);
+       return 0;
+}
+
+static int pwrdm_lost_power(struct powerdomain *pwrdm, void *unused)
+{
+       int state;
+
+       /*
+        * Power has been lost across all powerdomains, increment the
+        * counter.
+        */
+
+       state = pwrdm_read_pwrst(pwrdm);
+       if (state != PWRDM_POWER_OFF) {
+               pwrdm->state_counter[state]++;
+               pwrdm->state_counter[PWRDM_POWER_OFF]++;
+       }
+       pwrdm->state = state;
+
+       return 0;
+}
+
+void pwrdms_save_context(void)
+{
+       pwrdm_for_each(pwrdm_save_context, NULL);
+}
+
+void pwrdms_restore_context(void)
+{
+       pwrdm_for_each(pwrdm_restore_context, NULL);
+}
+
+void pwrdms_lost_power(void)
+{
+       pwrdm_for_each(pwrdm_lost_power, NULL);
+}
index 28a796ce07d7302aed19ce7e5ae25fcbbdb584df..9a907fb14044ea8f05a2ca412fc890b4f0707706 100644 (file)
@@ -144,6 +144,7 @@ struct powerdomain {
        s64 timer;
        s64 state_timer[PWRDM_MAX_PWRSTS];
 #endif
+       u32 context;
 };
 
 /**
@@ -198,6 +199,8 @@ struct pwrdm_ops {
        int     (*pwrdm_set_lowpwrstchange)(struct powerdomain *pwrdm);
        int     (*pwrdm_wait_transition)(struct powerdomain *pwrdm);
        int     (*pwrdm_has_voltdm)(void);
+       void    (*pwrdm_save_context)(struct powerdomain *pwrdm);
+       void    (*pwrdm_restore_context)(struct powerdomain *pwrdm);
 };
 
 int pwrdm_register_platform_funcs(struct pwrdm_ops *custom_funcs);
@@ -273,4 +276,8 @@ extern struct powerdomain gfx_omap2_pwrdm;
 extern void pwrdm_lock(struct powerdomain *pwrdm);
 extern void pwrdm_unlock(struct powerdomain *pwrdm);
 
+extern void pwrdms_save_context(void);
+extern void pwrdms_restore_context(void);
+
+extern void pwrdms_lost_power(void);
 #endif
index ebaf80d72a109fdaabb1fbeb21da6d401119ce8d..d5141669c28dd6cfff6e93713dee669038a80ac3 100644 (file)
@@ -342,6 +342,35 @@ static void am33xx_prm_global_warm_sw_reset(void)
                                  AM33XX_PRM_RSTCTRL_OFFSET);
 }
 
+static void am33xx_pwrdm_save_context(struct powerdomain *pwrdm)
+{
+       pwrdm->context = am33xx_prm_read_reg(pwrdm->prcm_offs,
+                                               pwrdm->pwrstctrl_offs);
+       /*
+        * Do not save LOWPOWERSTATECHANGE, writing a 1 indicates a request,
+        * reading back a 1 indicates a request in progress.
+        */
+       pwrdm->context &= ~AM33XX_LOWPOWERSTATECHANGE_MASK;
+}
+
+static void am33xx_pwrdm_restore_context(struct powerdomain *pwrdm)
+{
+       int st, ctrl;
+
+       st = am33xx_prm_read_reg(pwrdm->prcm_offs,
+                                pwrdm->pwrstst_offs);
+
+       am33xx_prm_write_reg(pwrdm->context, pwrdm->prcm_offs,
+                            pwrdm->pwrstctrl_offs);
+
+       /* Make sure we only wait for a transition if there is one */
+       st &= OMAP_POWERSTATEST_MASK;
+       ctrl = OMAP_POWERSTATEST_MASK & pwrdm->context;
+
+       if (st != ctrl)
+               am33xx_pwrdm_wait_transition(pwrdm);
+}
+
 struct pwrdm_ops am33xx_pwrdm_operations = {
        .pwrdm_set_next_pwrst           = am33xx_pwrdm_set_next_pwrst,
        .pwrdm_read_next_pwrst          = am33xx_pwrdm_read_next_pwrst,
@@ -357,6 +386,8 @@ struct pwrdm_ops am33xx_pwrdm_operations = {
        .pwrdm_set_mem_retst            = am33xx_pwrdm_set_mem_retst,
        .pwrdm_wait_transition          = am33xx_pwrdm_wait_transition,
        .pwrdm_has_voltdm               = am33xx_check_vcvp,
+       .pwrdm_save_context             = am33xx_pwrdm_save_context,
+       .pwrdm_restore_context          = am33xx_pwrdm_restore_context,
 };
 
 static struct prm_ll_data am33xx_prm_ll_data = {
index acb95936dfe74c350e9cea47e2b57dcfbb7e28f9..7b95729e83594d330e4f0d5e3205a05b4d0751e1 100644 (file)
@@ -12,6 +12,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/cpu_pm.h>
 #include <linux/kernel.h>
 #include <linux/delay.h>
 #include <linux/errno.h>
@@ -30,6 +31,7 @@
 #include "prcm44xx.h"
 #include "prminst44xx.h"
 #include "powerdomain.h"
+#include "pm.h"
 
 /* Static data */
 
@@ -57,6 +59,13 @@ static struct omap_prcm_irq_setup omap4_prcm_irq_setup = {
        .reconfigure_io_chain   = &omap44xx_prm_reconfigure_io_chain,
 };
 
+struct omap_prm_irq_context {
+       unsigned long irq_enable;
+       unsigned long pm_ctrl;
+};
+
+static struct omap_prm_irq_context omap_prm_context;
+
 /*
  * omap44xx_prm_reset_src_map - map from bits in the PRM_RSTST
  *   hardware register (which are specific to OMAP44xx SoCs) to reset
@@ -667,6 +676,54 @@ static int omap4_check_vcvp(void)
        return 0;
 }
 
+/**
+ * omap4_pwrdm_save_context - Saves the powerdomain state
+ * @pwrdm: pointer to individual powerdomain
+ *
+ * The function saves the powerdomain state control information.
+ * This is needed in rtc+ddr modes where we lose powerdomain context.
+ */
+static void omap4_pwrdm_save_context(struct powerdomain *pwrdm)
+{
+       pwrdm->context = omap4_prminst_read_inst_reg(pwrdm->prcm_partition,
+                                                    pwrdm->prcm_offs,
+                                                    pwrdm->pwrstctrl_offs);
+
+       /*
+        * Do not save LOWPOWERSTATECHANGE, writing a 1 indicates a request,
+        * reading back a 1 indicates a request in progress.
+        */
+       pwrdm->context &= ~OMAP4430_LOWPOWERSTATECHANGE_MASK;
+}
+
+/**
+ * omap4_pwrdm_restore_context - Restores the powerdomain state
+ * @pwrdm: pointer to individual powerdomain
+ *
+ * The function restores the powerdomain state control information.
+ * This is needed in rtc+ddr modes where we lose powerdomain context.
+ */
+static void omap4_pwrdm_restore_context(struct powerdomain *pwrdm)
+{
+       int st, ctrl;
+
+       st = omap4_prminst_read_inst_reg(pwrdm->prcm_partition,
+                                        pwrdm->prcm_offs,
+                                        pwrdm->pwrstctrl_offs);
+
+       omap4_prminst_write_inst_reg(pwrdm->context,
+                                    pwrdm->prcm_partition,
+                                    pwrdm->prcm_offs,
+                                    pwrdm->pwrstctrl_offs);
+
+       /* Make sure we only wait for a transition if there is one */
+       st &= OMAP_POWERSTATEST_MASK;
+       ctrl = OMAP_POWERSTATEST_MASK & pwrdm->context;
+
+       if (st != ctrl)
+               omap4_pwrdm_wait_transition(pwrdm);
+}
+
 struct pwrdm_ops omap4_pwrdm_operations = {
        .pwrdm_set_next_pwrst   = omap4_pwrdm_set_next_pwrst,
        .pwrdm_read_next_pwrst  = omap4_pwrdm_read_next_pwrst,
@@ -685,10 +742,50 @@ struct pwrdm_ops omap4_pwrdm_operations = {
        .pwrdm_set_mem_retst    = omap4_pwrdm_set_mem_retst,
        .pwrdm_wait_transition  = omap4_pwrdm_wait_transition,
        .pwrdm_has_voltdm       = omap4_check_vcvp,
+       .pwrdm_save_context     = omap4_pwrdm_save_context,
+       .pwrdm_restore_context  = omap4_pwrdm_restore_context,
 };
 
 static int omap44xx_prm_late_init(void);
 
+void prm_save_context(void)
+{
+       omap_prm_context.irq_enable =
+                       omap4_prm_read_inst_reg(AM43XX_PRM_OCP_SOCKET_INST,
+                                               omap4_prcm_irq_setup.mask);
+
+       omap_prm_context.pm_ctrl =
+                       omap4_prm_read_inst_reg(AM43XX_PRM_DEVICE_INST,
+                                               omap4_prcm_irq_setup.pm_ctrl);
+}
+
+void prm_restore_context(void)
+{
+       omap4_prm_write_inst_reg(omap_prm_context.irq_enable,
+                                OMAP4430_PRM_OCP_SOCKET_INST,
+                                omap4_prcm_irq_setup.mask);
+
+       omap4_prm_write_inst_reg(omap_prm_context.pm_ctrl,
+                                AM43XX_PRM_DEVICE_INST,
+                                omap4_prcm_irq_setup.pm_ctrl);
+}
+
+static int cpu_notifier(struct notifier_block *nb, unsigned long cmd, void *v)
+{
+       switch (cmd) {
+       case CPU_CLUSTER_PM_ENTER:
+               if (enable_off_mode)
+                       prm_save_context();
+               break;
+       case CPU_CLUSTER_PM_EXIT:
+               if (enable_off_mode)
+                       prm_restore_context();
+               break;
+       }
+
+       return NOTIFY_OK;
+}
+
 /*
  * XXX document
  */
@@ -709,6 +806,7 @@ static const struct omap_prcm_init_data *prm_init_data;
 
 int __init omap44xx_prm_init(const struct omap_prcm_init_data *data)
 {
+       static struct notifier_block nb;
        omap_prm_base_init();
 
        prm_init_data = data;
@@ -730,6 +828,12 @@ int __init omap44xx_prm_init(const struct omap_prcm_init_data *data)
                omap4_prcm_irq_setup.mask = AM43XX_PRM_IRQENABLE_MPU_OFFSET;
        }
 
+       /* Only AM43XX can lose prm context during rtc-ddr suspend */
+       if (soc_is_am43xx()) {
+               nb.notifier_call = cpu_notifier;
+               cpu_pm_register_notifier(&nb);
+       }
+
        return prm_register(&omap44xx_prm_ll_data);
 }
 
index 021b5a8b9c0a6200ca6b8632fdc130fc3735ce54..058a37e6d11c34955ab37f4df9833cdb0166fb6c 100644 (file)
@@ -285,10 +285,11 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
 
        prcm_irq_setup = irq_setup;
 
-       prcm_irq_chips = kzalloc(sizeof(void *) * nr_regs, GFP_KERNEL);
-       prcm_irq_setup->saved_mask = kzalloc(sizeof(u32) * nr_regs, GFP_KERNEL);
-       prcm_irq_setup->priority_mask = kzalloc(sizeof(u32) * nr_regs,
-               GFP_KERNEL);
+       prcm_irq_chips = kcalloc(nr_regs, sizeof(void *), GFP_KERNEL);
+       prcm_irq_setup->saved_mask = kcalloc(nr_regs, sizeof(u32),
+                                            GFP_KERNEL);
+       prcm_irq_setup->priority_mask = kcalloc(nr_regs, sizeof(u32),
+                                               GFP_KERNEL);
 
        if (!prcm_irq_chips || !prcm_irq_setup->saved_mask ||
            !prcm_irq_setup->priority_mask)
index 4fb4dc24e5e99318ed3e7d377594683773fa28ce..98ed5ac073bc1fcaac2a4394b6f01a677d461118 100644 (file)
@@ -50,7 +50,6 @@
 #include "omap_device.h"
 #include <plat/counter-32k.h>
 #include <clocksource/timer-ti-dm.h>
-#include "omap-pm.h"
 
 #include "soc.h"
 #include "common.h"
@@ -71,6 +70,9 @@ static struct clock_event_device clockevent_gpt;
 /* Clockevent hwmod for am335x and am437x suspend */
 static struct omap_hwmod *clockevent_gpt_hwmod;
 
+/* Clockesource hwmod for am437x suspend */
+static struct omap_hwmod *clocksource_gpt_hwmod;
+
 #ifdef CONFIG_SOC_HAS_REALTIME_COUNTER
 static unsigned long arch_timer_freq;
 
@@ -168,6 +170,43 @@ static const struct of_device_id omap_timer_match[] __initconst = {
        { }
 };
 
+static int omap_timer_add_disabled_property(struct device_node *np)
+{
+       struct property *prop;
+
+       prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+       if (!prop)
+               return -ENOMEM;
+
+       prop->name = "status";
+       prop->value = "disabled";
+       prop->length = strlen(prop->value);
+
+       return of_add_property(np, prop);
+}
+
+static int omap_timer_update_dt(struct device_node *np)
+{
+       int error = 0;
+
+       if (!of_device_is_compatible(np, "ti,omap-counter32k")) {
+               error = omap_timer_add_disabled_property(np);
+               if (error)
+                       return error;
+       }
+
+       /* No parent interconnect target module configured? */
+       if (of_get_property(np, "ti,hwmods", NULL))
+               return error;
+
+       /* Tag parent interconnect target module disabled */
+       error = omap_timer_add_disabled_property(np->parent);
+       if (error)
+               return error;
+
+       return 0;
+}
+
 /**
  * omap_get_timer_dt - get a timer using device-tree
  * @match      - device-tree match structure for matching a device type
@@ -183,6 +222,7 @@ static struct device_node * __init omap_get_timer_dt(const struct of_device_id *
                                                     const char *property)
 {
        struct device_node *np;
+       int error;
 
        for_each_matching_node(np, match) {
                if (!of_device_is_available(np))
@@ -197,17 +237,9 @@ static struct device_node * __init omap_get_timer_dt(const struct of_device_id *
                                  of_get_property(np, "ti,timer-secure", NULL)))
                        continue;
 
-               if (!of_device_is_compatible(np, "ti,omap-counter32k")) {
-                       struct property *prop;
+               error = omap_timer_update_dt(np);
+               WARN(error, "%s: Could not update dt: %i\n", __func__, error);
 
-                       prop = kzalloc(sizeof(*prop), GFP_KERNEL);
-                       if (!prop)
-                               return NULL;
-                       prop->name = "status";
-                       prop->value = "disabled";
-                       prop->length = strlen(prop->value);
-                       of_add_property(np, prop);
-               }
                return np;
        }
 
@@ -266,8 +298,12 @@ static int __init omap_dm_timer_init_one(struct omap_dm_timer *timer,
                return -ENODEV;
 
        of_property_read_string_index(np, "ti,hwmods", 0, &oh_name);
-       if (!oh_name)
-               return -ENODEV;
+       if (!oh_name) {
+               of_property_read_string_index(np->parent, "ti,hwmods", 0,
+                                             &oh_name);
+               if (!oh_name)
+                       return -ENODEV;
+       }
 
        timer->irq = irq_of_parse_and_map(np, 0);
        if (!timer->irq)
@@ -419,9 +455,12 @@ static int __init __maybe_unused omap2_sync32k_clocksource_init(void)
        if (!np)
                return -ENODEV;
 
-       of_property_read_string_index(np, "ti,hwmods", 0, &oh_name);
-       if (!oh_name)
-               return -ENODEV;
+       of_property_read_string_index(np->parent, "ti,hwmods", 0, &oh_name);
+       if (!oh_name) {
+               of_property_read_string_index(np, "ti,hwmods", 0, &oh_name);
+               if (!oh_name)
+                       return -ENODEV;
+       }
 
        /*
         * First check hwmod data is available for sync32k counter
@@ -442,6 +481,26 @@ static int __init __maybe_unused omap2_sync32k_clocksource_init(void)
        return ret;
 }
 
+static unsigned int omap2_gptimer_clksrc_load;
+
+static void omap2_gptimer_clksrc_suspend(struct clocksource *unused)
+{
+       omap2_gptimer_clksrc_load =
+               __omap_dm_timer_read_counter(&clksrc, OMAP_TIMER_NONPOSTED);
+
+       omap_hwmod_idle(clocksource_gpt_hwmod);
+}
+
+static void omap2_gptimer_clksrc_resume(struct clocksource *unused)
+{
+       omap_hwmod_enable(clocksource_gpt_hwmod);
+
+       __omap_dm_timer_load_start(&clksrc,
+                                  OMAP_TIMER_CTRL_ST | OMAP_TIMER_CTRL_AR,
+                                  omap2_gptimer_clksrc_load,
+                                  OMAP_TIMER_NONPOSTED);
+}
+
 static void __init omap2_gptimer_clocksource_init(int gptimer_id,
                                                  const char *fck_source,
                                                  const char *property)
@@ -454,6 +513,15 @@ static void __init omap2_gptimer_clocksource_init(int gptimer_id,
        res = omap_dm_timer_init_one(&clksrc, fck_source, property,
                                     &clocksource_gpt.name,
                                     OMAP_TIMER_NONPOSTED);
+
+       if (soc_is_am43xx()) {
+               clocksource_gpt.suspend = omap2_gptimer_clksrc_suspend;
+               clocksource_gpt.resume = omap2_gptimer_clksrc_resume;
+
+               clocksource_gpt_hwmod =
+                       omap_hwmod_lookup(clocksource_gpt.name);
+       }
+
        BUG_ON(res);
 
        __omap_dm_timer_load_start(&clksrc,
index 0adb1bd6208e27ab349c88ce2e912ad6a22109e2..4d475f6f4a777081d2e0c9c695ad7ceb26ab399f 100644 (file)
@@ -30,7 +30,7 @@
 #include <linux/wm97xx.h>
 #include <linux/power_supply.h>
 #include <linux/usb/gpio_vbus.h>
-#include <linux/i2c-gpio.h>
+#include <linux/platform_data/i2c-gpio.h>
 #include <linux/gpio/machine.h>
 
 #include <asm/mach-types.h>
index 4b8a0df8ea5785bcbe59d02ba3583c50faf0b137..8c64f93b669b9539dc691e325195740aac4d86d2 100644 (file)
@@ -446,6 +446,10 @@ static int __init pxa3xx_init(void)
 
                pxa3xx_init_pm();
 
+               enable_irq_wake(IRQ_WAKEUP0);
+               if (cpu_is_pxa320())
+                       enable_irq_wake(IRQ_WAKEUP1);
+
                register_syscore_ops(&pxa_irq_syscore_ops);
                register_syscore_ops(&pxa3xx_mfp_syscore_ops);
 
index df62bb23dbeead237320cc4cbf54093d1a25205d..bbea5fa9a140110fbb6970594b2985c604246c59 100644 (file)
 
 #include <linux/platform_data/i2c-pxa.h>
 #include <linux/platform_data/pcf857x.h>
-#include <linux/platform_data/at24.h>
 #include <linux/smc91x.h>
 #include <linux/gpio/machine.h>
 #include <linux/gpio.h>
 #include <linux/leds.h>
+#include <linux/property.h>
 
 #include <asm/types.h>
 #include <asm/setup.h>
@@ -795,9 +795,9 @@ static struct pcf857x_platform_data platform_data_pcf857x = {
        .context = NULL,
 };
 
-static struct at24_platform_data pca9500_eeprom_pdata = {
-       .byte_len = 256,
-       .page_size = 4,
+static const struct property_entry pca9500_eeprom_properties[] = {
+       PROPERTY_ENTRY_U32("pagesize", 4),
+       { }
 };
 
 /**
@@ -935,7 +935,7 @@ static struct i2c_board_info __initdata stargate2_i2c_board_info[] = {
        }, {
                .type = "24c02",
                .addr = 0x57,
-               .platform_data = &pca9500_eeprom_pdata,
+               .properties = pca9500_eeprom_properties,
        }, {
                .type = "max1238",
                .addr = 0x35,
index 207dcc2e94e70694376423a4a3c938d434368ff8..ab2f89266bbd44d1ebc8ff0e3018ae3a0dc09636 100644 (file)
@@ -35,7 +35,7 @@
 #include <linux/sched.h>
 #include <linux/gpio.h>
 #include <linux/jiffies.h>
-#include <linux/i2c-gpio.h>
+#include <linux/platform_data/i2c-gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/platform_data/i2c-pxa.h>
 #include <linux/serial_8250.h>
index 46ad20ea87d1e761c8b68ab0fb3c5fc42172ce30..186b5321658e87fc26e33aca9214dfd772d433bf 100644 (file)
@@ -1,4 +1,4 @@
-// SPDX-License-Identifier: GPL-1.0
+// SPDX-License-Identifier: GPL-1.0+
 //
 // Copyright (c) Arnaud Patard <arnaud.patard@rtp-net.org>
 //
index 95753e0bc0730708eb16eb30cdc6daf870e78464..f9fc1f8d2b2814dbf0de70b77d47b38e6d0ab665 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/serial_core.h>
 #include <linux/serial_s3c.h>
 #include <linux/dm9000.h>
-#include <linux/platform_data/at24.h>
+#include <linux/property.h>
 #include <linux/platform_device.h>
 #include <linux/gpio_keys.h>
 #include <linux/i2c.h>
@@ -481,15 +481,15 @@ static struct platform_device mini2440_audio = {
 /*
  * I2C devices
  */
-static struct at24_platform_data at24c08 = {
-       .byte_len       = SZ_8K / 8,
-       .page_size      = 16,
+static const struct property_entry mini2440_at24_properties[] = {
+       PROPERTY_ENTRY_U32("pagesize", 16),
+       { }
 };
 
 static struct i2c_board_info mini2440_i2c_devs[] __initdata = {
        {
                I2C_BOARD_INFO("24c08", 0x50),
-               .platform_data = &at24c08,
+               .properties = mini2440_at24_properties,
        },
 };
 
index f45aed2519ba21979ce107b492059e26857bbae3..406487e76a5cec4d6f0e7e60849f5ddc4e02c763 100644 (file)
@@ -37,7 +37,7 @@
 #include <linux/input.h>
 #include <linux/gpio_keys.h>
 #include <linux/leds.h>
-#include <linux/i2c-gpio.h>
+#include <linux/platform_data/i2c-gpio.h>
 
 #include "generic.h"
 
index fe60cd09a5ca6515a595d03d64ff805c42850b81..0b67254eabb2c4e823fb7f31aca437e1d45979f3 100644 (file)
@@ -74,6 +74,10 @@ config ARCH_R8A7745
        bool "RZ/G1E (R8A77450)"
        select ARCH_RCAR_GEN2
 
+config ARCH_R8A77470
+       bool "RZ/G1C (R8A77470)"
+       select ARCH_RCAR_GEN2
+
 config ARCH_R8A7778
        bool "R-Car M1A (R8A77781)"
        select ARCH_RCAR_GEN1
@@ -109,6 +113,15 @@ config ARCH_R8A7794
        bool "R-Car E2 (R8A77940)"
        select ARCH_RCAR_GEN2
 
+config ARCH_R9A06G032
+       bool "RZ/N1D (R9A06G032)"
+       select ARCH_RZN1
+
+config ARCH_RZN1
+       bool "RZ/N1 (R9A06G0xx) Family"
+       select ARM_AMBA
+       select CPU_V7
+
 config ARCH_SH73A0
        bool "SH-Mobile AG5 (R8A73A00)"
        select ARCH_RMOBILE
index 43c1ac696274175779b9ea20636a263ed54e22e2..2109f123bdfb2e19c3e24e77037b91eb87e4afd5 100644 (file)
@@ -2,7 +2,6 @@
 #ifndef __ARCH_MACH_COMMON_H
 #define __ARCH_MACH_COMMON_H
 
-extern void shmobile_init_cntvoff(void);
 extern void shmobile_init_delay(void);
 extern void shmobile_boot_vector(void);
 extern unsigned long shmobile_boot_fn;
index 5672b58494016c6ac06a78cb4b00d6ff20feabc4..d49ab194766a401fb5642f269f01db39929ef9a5 100644 (file)
 #include <linux/linkage.h>
 #include <asm/assembler.h>
 
-ENTRY(shmobile_init_cntvoff)
-       /*
-        * CNTVOFF has to be initialized either from non-secure Hypervisor
-        * mode or secure Monitor mode with SCR.NS==1. If TrustZone is enabled
-        * then it should be handled by the secure code
-        */
-       cps     #MON_MODE
-       mrc     p15, 0, r1, c1, c1, 0           /* Get Secure Config */
-       orr     r0, r1, #1
-       mcr     p15, 0, r0, c1, c1, 0           /* Set Non Secure bit */
-       instr_sync
-       mov     r0, #0
-       mcrr    p15, 4, r0, r0, c14             /* CNTVOFF = 0 */
-       instr_sync
-       mcr     p15, 0, r1, c1, c1, 0           /* Set Secure bit */
-       instr_sync
-       cps     #SVC_MODE
-       ret     lr
-ENDPROC(shmobile_init_cntvoff)
-
 #ifdef CONFIG_SMP
 ENTRY(shmobile_boot_apmu)
-       bl      shmobile_init_cntvoff
+       bl      secure_cntvoff_init
        b       secondary_startup
 ENDPROC(shmobile_boot_apmu)
 #endif
index 5561dbed7a332a58665688b23dbf5bff2c378c99..88fdc1801d90f9a1ecc7e96516f368bc9c9e898b 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/of_fdt.h>
 #include <linux/of_platform.h>
 #include <asm/mach/arch.h>
+#include <asm/secure_cntvoff.h>
 #include "common.h"
 #include "rcar-gen2.h"
 
@@ -70,9 +71,10 @@ void __init rcar_gen2_timer_init(void)
        void __iomem *base;
        u32 freq;
 
-       shmobile_init_cntvoff();
+       secure_cntvoff_init();
 
        if (of_machine_is_compatible("renesas,r8a7745") ||
+           of_machine_is_compatible("renesas,r8a77470") ||
            of_machine_is_compatible("renesas,r8a7792") ||
            of_machine_is_compatible("renesas,r8a7794")) {
                freq = 260000000 / 8;   /* ZS / 8 */
@@ -205,6 +207,7 @@ MACHINE_END
 static const char * const rz_g1_boards_compat_dt[] __initconst = {
        "renesas,r8a7743",
        "renesas,r8a7745",
+       "renesas,r8a77470",
        NULL,
 };
 
index ce53ceaf4cc53144996d99d30245da9397c3bca1..d9c8ecf88ec6635a1d3add0a6ac9c9cf77ff2e7f 100644 (file)
@@ -51,7 +51,7 @@ config MACH_SUN9I
 config ARCH_SUNXI_MC_SMP
        bool
        depends on SMP
-       default MACH_SUN9I
+       default MACH_SUN9I || MACH_SUN8I
        select ARM_CCI400_PORT_CTRL
        select ARM_CPU_SUSPEND
 
index 7de9cc286d53c2e2314d93dac30f8ba8190f5e2f..71429aa851436466cc88dfd436fd4b8f7f8c92f5 100644 (file)
@@ -1,5 +1,5 @@
 CFLAGS_mc_smp.o        += -march=armv7-a
 
 obj-$(CONFIG_ARCH_SUNXI) += sunxi.o
-obj-$(CONFIG_ARCH_SUNXI_MC_SMP) += mc_smp.o
+obj-$(CONFIG_ARCH_SUNXI_MC_SMP) += mc_smp.o headsmp.o
 obj-$(CONFIG_SMP) += platsmp.o
diff --git a/arch/arm/mach-sunxi/headsmp.S b/arch/arm/mach-sunxi/headsmp.S
new file mode 100644 (file)
index 0000000..32d76be
--- /dev/null
@@ -0,0 +1,81 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (c) 2018 Chen-Yu Tsai
+ * Copyright (c) 2018 Bootlin
+ *
+ * Chen-Yu Tsai <wens@csie.org>
+ * Mylène Josserand <mylene.josserand@bootlin.com>
+ *
+ * SMP support for sunxi based systems with Cortex A7/A15
+ *
+ */
+
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+#include <asm/cputype.h>
+
+ENTRY(sunxi_mc_smp_cluster_cache_enable)
+       .arch   armv7-a
+       /*
+        * Enable cluster-level coherency, in preparation for turning on the MMU.
+        *
+        * Also enable regional clock gating and L2 data latency settings for
+        * Cortex-A15. These settings are from the vendor kernel.
+        */
+       mrc     p15, 0, r1, c0, c0, 0
+       movw    r2, #(ARM_CPU_PART_MASK & 0xffff)
+       movt    r2, #(ARM_CPU_PART_MASK >> 16)
+       and     r1, r1, r2
+       movw    r2, #(ARM_CPU_PART_CORTEX_A15 & 0xffff)
+       movt    r2, #(ARM_CPU_PART_CORTEX_A15 >> 16)
+       cmp     r1, r2
+       bne     not_a15
+
+       /* The following is Cortex-A15 specific */
+
+       /* ACTLR2: Enable CPU regional clock gates */
+       mrc p15, 1, r1, c15, c0, 4
+       orr r1, r1, #(0x1 << 31)
+       mcr p15, 1, r1, c15, c0, 4
+
+       /* L2ACTLR */
+       mrc p15, 1, r1, c15, c0, 0
+       /* Enable L2, GIC, and Timer regional clock gates */
+       orr r1, r1, #(0x1 << 26)
+       /* Disable clean/evict from being pushed to external */
+       orr r1, r1, #(0x1<<3)
+       mcr p15, 1, r1, c15, c0, 0
+
+       /* L2CTRL: L2 data RAM latency */
+       mrc p15, 1, r1, c9, c0, 2
+       bic r1, r1, #(0x7 << 0)
+       orr r1, r1, #(0x3 << 0)
+       mcr p15, 1, r1, c9, c0, 2
+
+       /* End of Cortex-A15 specific setup */
+       not_a15:
+
+       /* Get value of sunxi_mc_smp_first_comer */
+       adr     r1, first
+       ldr     r0, [r1]
+       ldr     r0, [r1, r0]
+
+       /* Skip cci_enable_port_for_self if not first comer */
+       cmp     r0, #0
+       bxeq    lr
+       b       cci_enable_port_for_self
+
+       .align 2
+       first: .word sunxi_mc_smp_first_comer - .
+ENDPROC(sunxi_mc_smp_cluster_cache_enable)
+
+ENTRY(sunxi_mc_smp_secondary_startup)
+       bl      sunxi_mc_smp_cluster_cache_enable
+       bl      secure_cntvoff_init
+       b       secondary_startup
+ENDPROC(sunxi_mc_smp_secondary_startup)
+
+ENTRY(sunxi_mc_smp_resume)
+       bl      sunxi_mc_smp_cluster_cache_enable
+       b       cpu_resume
+ENDPROC(sunxi_mc_smp_resume)
index c0246ec54a0a3f32555c3eca08e9b7cf28a40faa..b4037b603897d62e15eeafb099c4ef1163328d29 100644 (file)
 #define CPUCFG_CX_RST_CTRL_L2_RST      BIT(8)
 #define CPUCFG_CX_RST_CTRL_CX_RST(n)   BIT(4 + (n))
 #define CPUCFG_CX_RST_CTRL_CORE_RST(n) BIT(n)
+#define CPUCFG_CX_RST_CTRL_CORE_RST_ALL        (0xf << 0)
 
 #define PRCM_CPU_PO_RST_CTRL(c)                (0x4 + 0x4 * (c))
 #define PRCM_CPU_PO_RST_CTRL_CORE(n)   BIT(n)
 #define PRCM_CPU_PO_RST_CTRL_CORE_ALL  0xf
 #define PRCM_PWROFF_GATING_REG(c)      (0x100 + 0x4 * (c))
-#define PRCM_PWROFF_GATING_REG_CLUSTER BIT(4)
+/* The power off register for clusters are different from a80 and a83t */
+#define PRCM_PWROFF_GATING_REG_CLUSTER_SUN8I   BIT(0)
+#define PRCM_PWROFF_GATING_REG_CLUSTER_SUN9I   BIT(4)
 #define PRCM_PWROFF_GATING_REG_CORE(n) BIT(n)
 #define PRCM_PWR_SWITCH_REG(c, cpu)    (0x140 + 0x10 * (c) + 0x4 * (cpu))
 #define PRCM_CPU_SOFT_ENTRY_REG                0x164
 
+/* R_CPUCFG registers, specific to sun8i-a83t */
+#define R_CPUCFG_CLUSTER_PO_RST_CTRL(c)        (0x30 + (c) * 0x4)
+#define R_CPUCFG_CLUSTER_PO_RST_CTRL_CORE(n)   BIT(n)
+#define R_CPUCFG_CPU_SOFT_ENTRY_REG            0x01a4
+
 #define CPU0_SUPPORT_HOTPLUG_MAGIC0    0xFA50392F
 #define CPU0_SUPPORT_HOTPLUG_MAGIC1    0x790DCA3A
 
 static void __iomem *cpucfg_base;
 static void __iomem *prcm_base;
 static void __iomem *sram_b_smp_base;
+static void __iomem *r_cpucfg_base;
+
+extern void sunxi_mc_smp_secondary_startup(void);
+extern void sunxi_mc_smp_resume(void);
+static bool is_a83t;
 
 static bool sunxi_core_is_cortex_a15(unsigned int core, unsigned int cluster)
 {
@@ -157,6 +170,16 @@ static int sunxi_cpu_powerup(unsigned int cpu, unsigned int cluster)
        reg &= ~PRCM_CPU_PO_RST_CTRL_CORE(cpu);
        writel(reg, prcm_base + PRCM_CPU_PO_RST_CTRL(cluster));
 
+       if (is_a83t) {
+               /* assert cpu power-on reset */
+               reg  = readl(r_cpucfg_base +
+                            R_CPUCFG_CLUSTER_PO_RST_CTRL(cluster));
+               reg &= ~(R_CPUCFG_CLUSTER_PO_RST_CTRL_CORE(cpu));
+               writel(reg, r_cpucfg_base +
+                      R_CPUCFG_CLUSTER_PO_RST_CTRL(cluster));
+               udelay(10);
+       }
+
        /* Cortex-A7: hold L1 reset disable signal low */
        if (!sunxi_core_is_cortex_a15(cpu, cluster)) {
                reg = readl(cpucfg_base + CPUCFG_CX_CTRL_REG0(cluster));
@@ -180,17 +203,38 @@ static int sunxi_cpu_powerup(unsigned int cpu, unsigned int cluster)
        /* open power switch */
        sunxi_cpu_power_switch_set(cpu, cluster, true);
 
+       /* Handle A83T bit swap */
+       if (is_a83t) {
+               if (cpu == 0)
+                       cpu = 4;
+       }
+
        /* clear processor power gate */
        reg = readl(prcm_base + PRCM_PWROFF_GATING_REG(cluster));
        reg &= ~PRCM_PWROFF_GATING_REG_CORE(cpu);
        writel(reg, prcm_base + PRCM_PWROFF_GATING_REG(cluster));
        udelay(20);
 
+       /* Handle A83T bit swap */
+       if (is_a83t) {
+               if (cpu == 4)
+                       cpu = 0;
+       }
+
        /* de-assert processor power-on reset */
        reg = readl(prcm_base + PRCM_CPU_PO_RST_CTRL(cluster));
        reg |= PRCM_CPU_PO_RST_CTRL_CORE(cpu);
        writel(reg, prcm_base + PRCM_CPU_PO_RST_CTRL(cluster));
 
+       if (is_a83t) {
+               reg  = readl(r_cpucfg_base +
+                            R_CPUCFG_CLUSTER_PO_RST_CTRL(cluster));
+               reg |= R_CPUCFG_CLUSTER_PO_RST_CTRL_CORE(cpu);
+               writel(reg, r_cpucfg_base +
+                      R_CPUCFG_CLUSTER_PO_RST_CTRL(cluster));
+               udelay(10);
+       }
+
        /* de-assert all processor resets */
        reg = readl(cpucfg_base + CPUCFG_CX_RST_CTRL(cluster));
        reg |= CPUCFG_CX_RST_CTRL_DBG_RST(cpu);
@@ -212,6 +256,14 @@ static int sunxi_cluster_powerup(unsigned int cluster)
        if (cluster >= SUNXI_NR_CLUSTERS)
                return -EINVAL;
 
+       /* For A83T, assert cluster cores resets */
+       if (is_a83t) {
+               reg = readl(cpucfg_base + CPUCFG_CX_RST_CTRL(cluster));
+               reg &= ~CPUCFG_CX_RST_CTRL_CORE_RST_ALL;   /* Core Reset    */
+               writel(reg, cpucfg_base + CPUCFG_CX_RST_CTRL(cluster));
+               udelay(10);
+       }
+
        /* assert ACINACTM */
        reg = readl(cpucfg_base + CPUCFG_CX_CTRL_REG1(cluster));
        reg |= CPUCFG_CX_CTRL_REG1_ACINACTM;
@@ -222,6 +274,16 @@ static int sunxi_cluster_powerup(unsigned int cluster)
        reg &= ~PRCM_CPU_PO_RST_CTRL_CORE_ALL;
        writel(reg, prcm_base + PRCM_CPU_PO_RST_CTRL(cluster));
 
+       /* assert cluster cores resets */
+       if (is_a83t) {
+               reg  = readl(r_cpucfg_base +
+                            R_CPUCFG_CLUSTER_PO_RST_CTRL(cluster));
+               reg &= ~CPUCFG_CX_RST_CTRL_CORE_RST_ALL;
+               writel(reg, r_cpucfg_base +
+                      R_CPUCFG_CLUSTER_PO_RST_CTRL(cluster));
+               udelay(10);
+       }
+
        /* assert cluster resets */
        reg = readl(cpucfg_base + CPUCFG_CX_RST_CTRL(cluster));
        reg &= ~CPUCFG_CX_RST_CTRL_DBG_SOC_RST;
@@ -252,7 +314,10 @@ static int sunxi_cluster_powerup(unsigned int cluster)
 
        /* clear cluster power gate */
        reg = readl(prcm_base + PRCM_PWROFF_GATING_REG(cluster));
-       reg &= ~PRCM_PWROFF_GATING_REG_CLUSTER;
+       if (is_a83t)
+               reg &= ~PRCM_PWROFF_GATING_REG_CLUSTER_SUN8I;
+       else
+               reg &= ~PRCM_PWROFF_GATING_REG_CLUSTER_SUN9I;
        writel(reg, prcm_base + PRCM_PWROFF_GATING_REG(cluster));
        udelay(20);
 
@@ -300,74 +365,7 @@ static void sunxi_cluster_cache_disable_without_axi(void)
 }
 
 static int sunxi_mc_smp_cpu_table[SUNXI_NR_CLUSTERS][SUNXI_CPUS_PER_CLUSTER];
-static int sunxi_mc_smp_first_comer;
-
-/*
- * Enable cluster-level coherency, in preparation for turning on the MMU.
- *
- * Also enable regional clock gating and L2 data latency settings for
- * Cortex-A15. These settings are from the vendor kernel.
- */
-static void __naked sunxi_mc_smp_cluster_cache_enable(void)
-{
-       asm volatile (
-               "mrc    p15, 0, r1, c0, c0, 0\n"
-               "movw   r2, #" __stringify(ARM_CPU_PART_MASK & 0xffff) "\n"
-               "movt   r2, #" __stringify(ARM_CPU_PART_MASK >> 16) "\n"
-               "and    r1, r1, r2\n"
-               "movw   r2, #" __stringify(ARM_CPU_PART_CORTEX_A15 & 0xffff) "\n"
-               "movt   r2, #" __stringify(ARM_CPU_PART_CORTEX_A15 >> 16) "\n"
-               "cmp    r1, r2\n"
-               "bne    not_a15\n"
-
-               /* The following is Cortex-A15 specific */
-
-               /* ACTLR2: Enable CPU regional clock gates */
-               "mrc p15, 1, r1, c15, c0, 4\n"
-               "orr r1, r1, #(0x1<<31)\n"
-               "mcr p15, 1, r1, c15, c0, 4\n"
-
-               /* L2ACTLR */
-               "mrc p15, 1, r1, c15, c0, 0\n"
-               /* Enable L2, GIC, and Timer regional clock gates */
-               "orr r1, r1, #(0x1<<26)\n"
-               /* Disable clean/evict from being pushed to external */
-               "orr r1, r1, #(0x1<<3)\n"
-               "mcr p15, 1, r1, c15, c0, 0\n"
-
-               /* L2CTRL: L2 data RAM latency */
-               "mrc p15, 1, r1, c9, c0, 2\n"
-               "bic r1, r1, #(0x7<<0)\n"
-               "orr r1, r1, #(0x3<<0)\n"
-               "mcr p15, 1, r1, c9, c0, 2\n"
-
-               /* End of Cortex-A15 specific setup */
-               "not_a15:\n"
-
-               /* Get value of sunxi_mc_smp_first_comer */
-               "adr    r1, first\n"
-               "ldr    r0, [r1]\n"
-               "ldr    r0, [r1, r0]\n"
-
-               /* Skip cci_enable_port_for_self if not first comer */
-               "cmp    r0, #0\n"
-               "bxeq   lr\n"
-               "b      cci_enable_port_for_self\n"
-
-               ".align 2\n"
-               "first: .word sunxi_mc_smp_first_comer - .\n"
-       );
-}
-
-static void __naked sunxi_mc_smp_secondary_startup(void)
-{
-       asm volatile(
-               "bl     sunxi_mc_smp_cluster_cache_enable\n"
-               "b      secondary_startup"
-               /* Let compiler know about sunxi_mc_smp_cluster_cache_enable */
-               :: "i" (sunxi_mc_smp_cluster_cache_enable)
-       );
-}
+int sunxi_mc_smp_first_comer;
 
 static DEFINE_SPINLOCK(boot_lock);
 
@@ -516,7 +514,10 @@ static int sunxi_cluster_powerdown(unsigned int cluster)
        /* gate cluster power */
        pr_debug("%s: gate cluster power\n", __func__);
        reg = readl(prcm_base + PRCM_PWROFF_GATING_REG(cluster));
-       reg |= PRCM_PWROFF_GATING_REG_CLUSTER;
+       if (is_a83t)
+               reg |= PRCM_PWROFF_GATING_REG_CLUSTER_SUN8I;
+       else
+               reg |= PRCM_PWROFF_GATING_REG_CLUSTER_SUN9I;
        writel(reg, prcm_base + PRCM_PWROFF_GATING_REG(cluster));
        udelay(20);
 
@@ -598,8 +599,12 @@ static int sunxi_mc_smp_cpu_kill(unsigned int l_cpu)
        return !ret;
 }
 
-static bool sunxi_mc_smp_cpu_can_disable(unsigned int __unused)
+static bool sunxi_mc_smp_cpu_can_disable(unsigned int cpu)
 {
+       /* CPU0 hotplug not handled for sun8i-a83t */
+       if (is_a83t)
+               if (cpu == 0)
+                       return false;
        return true;
 }
 #endif
@@ -637,16 +642,6 @@ static bool __init sunxi_mc_smp_cpu_table_init(void)
  */
 typedef typeof(cpu_reset) phys_reset_t;
 
-static void __init __naked sunxi_mc_smp_resume(void)
-{
-       asm volatile(
-               "bl     sunxi_mc_smp_cluster_cache_enable\n"
-               "b      cpu_resume"
-               /* Let compiler know about sunxi_mc_smp_cluster_cache_enable */
-               :: "i" (sunxi_mc_smp_cluster_cache_enable)
-       );
-}
-
 static int __init nocache_trampoline(unsigned long __unused)
 {
        phys_reset_t phys_reset;
@@ -692,12 +687,14 @@ struct sunxi_mc_smp_nodes {
        struct device_node *prcm_node;
        struct device_node *cpucfg_node;
        struct device_node *sram_node;
+       struct device_node *r_cpucfg_node;
 };
 
 /* This structure holds SoC-specific bits tied to an enable-method string. */
 struct sunxi_mc_smp_data {
        const char *enable_method;
        int (*get_smp_nodes)(struct sunxi_mc_smp_nodes *nodes);
+       bool is_a83t;
 };
 
 static void __init sunxi_mc_smp_put_nodes(struct sunxi_mc_smp_nodes *nodes)
@@ -705,6 +702,7 @@ static void __init sunxi_mc_smp_put_nodes(struct sunxi_mc_smp_nodes *nodes)
        of_node_put(nodes->prcm_node);
        of_node_put(nodes->cpucfg_node);
        of_node_put(nodes->sram_node);
+       of_node_put(nodes->r_cpucfg_node);
        memset(nodes, 0, sizeof(*nodes));
 }
 
@@ -734,11 +732,42 @@ static int __init sun9i_a80_get_smp_nodes(struct sunxi_mc_smp_nodes *nodes)
        return 0;
 }
 
+static int __init sun8i_a83t_get_smp_nodes(struct sunxi_mc_smp_nodes *nodes)
+{
+       nodes->prcm_node = of_find_compatible_node(NULL, NULL,
+                                                  "allwinner,sun8i-a83t-r-ccu");
+       if (!nodes->prcm_node) {
+               pr_err("%s: PRCM not available\n", __func__);
+               return -ENODEV;
+       }
+
+       nodes->cpucfg_node = of_find_compatible_node(NULL, NULL,
+                                                    "allwinner,sun8i-a83t-cpucfg");
+       if (!nodes->cpucfg_node) {
+               pr_err("%s: CPUCFG not available\n", __func__);
+               return -ENODEV;
+       }
+
+       nodes->r_cpucfg_node = of_find_compatible_node(NULL, NULL,
+                                                      "allwinner,sun8i-a83t-r-cpucfg");
+       if (!nodes->r_cpucfg_node) {
+               pr_err("%s: RCPUCFG not available\n", __func__);
+               return -ENODEV;
+       }
+
+       return 0;
+}
+
 static const struct sunxi_mc_smp_data sunxi_mc_smp_data[] __initconst = {
        {
                .enable_method  = "allwinner,sun9i-a80-smp",
                .get_smp_nodes  = sun9i_a80_get_smp_nodes,
        },
+       {
+               .enable_method  = "allwinner,sun8i-a83t-smp",
+               .get_smp_nodes  = sun8i_a83t_get_smp_nodes,
+               .is_a83t        = true,
+       },
 };
 
 static int __init sunxi_mc_smp_init(void)
@@ -746,6 +775,7 @@ static int __init sunxi_mc_smp_init(void)
        struct sunxi_mc_smp_nodes nodes = { 0 };
        struct device_node *node;
        struct resource res;
+       void __iomem *addr;
        int i, ret;
 
        /*
@@ -771,6 +801,8 @@ static int __init sunxi_mc_smp_init(void)
                        break;
        }
 
+       is_a83t = sunxi_mc_smp_data[i].is_a83t;
+
        of_node_put(node);
        if (ret)
                return -ENODEV;
@@ -808,12 +840,23 @@ static int __init sunxi_mc_smp_init(void)
                goto err_unmap_prcm;
        }
 
-       sram_b_smp_base = of_io_request_and_map(nodes.sram_node, 0,
-                                               "sunxi-mc-smp");
-       if (IS_ERR(sram_b_smp_base)) {
-               ret = PTR_ERR(sram_b_smp_base);
-               pr_err("%s: failed to map secure SRAM\n", __func__);
-               goto err_unmap_release_cpucfg;
+       if (is_a83t) {
+               r_cpucfg_base = of_io_request_and_map(nodes.r_cpucfg_node,
+                                                     0, "sunxi-mc-smp");
+               if (IS_ERR(r_cpucfg_base)) {
+                       ret = PTR_ERR(r_cpucfg_base);
+                       pr_err("%s: failed to map R-CPUCFG registers\n",
+                              __func__);
+                       goto err_unmap_release_cpucfg;
+               }
+       } else {
+               sram_b_smp_base = of_io_request_and_map(nodes.sram_node, 0,
+                                                       "sunxi-mc-smp");
+               if (IS_ERR(sram_b_smp_base)) {
+                       ret = PTR_ERR(sram_b_smp_base);
+                       pr_err("%s: failed to map secure SRAM\n", __func__);
+                       goto err_unmap_release_cpucfg;
+               }
        }
 
        /* Configure CCI-400 for boot cluster */
@@ -821,15 +864,18 @@ static int __init sunxi_mc_smp_init(void)
        if (ret) {
                pr_err("%s: failed to configure boot cluster: %d\n",
                       __func__, ret);
-               goto err_unmap_release_secure_sram;
+               goto err_unmap_release_sram_rcpucfg;
        }
 
        /* We don't need the device nodes anymore */
        sunxi_mc_smp_put_nodes(&nodes);
 
        /* Set the hardware entry point address */
-       writel(__pa_symbol(sunxi_mc_smp_secondary_startup),
-              prcm_base + PRCM_CPU_SOFT_ENTRY_REG);
+       if (is_a83t)
+               addr = r_cpucfg_base + R_CPUCFG_CPU_SOFT_ENTRY_REG;
+       else
+               addr = prcm_base + PRCM_CPU_SOFT_ENTRY_REG;
+       writel(__pa_symbol(sunxi_mc_smp_secondary_startup), addr);
 
        /* Actually enable multi cluster SMP */
        smp_set_ops(&sunxi_mc_smp_smp_ops);
@@ -838,9 +884,14 @@ static int __init sunxi_mc_smp_init(void)
 
        return 0;
 
-err_unmap_release_secure_sram:
-       iounmap(sram_b_smp_base);
-       of_address_to_resource(nodes.sram_node, 0, &res);
+err_unmap_release_sram_rcpucfg:
+       if (is_a83t) {
+               iounmap(r_cpucfg_base);
+               of_address_to_resource(nodes.r_cpucfg_node, 0, &res);
+       } else {
+               iounmap(sram_b_smp_base);
+               of_address_to_resource(nodes.sram_node, 0, &res);
+       }
        release_mem_region(res.start, resource_size(&res));
 err_unmap_release_cpucfg:
        iounmap(cpucfg_base);
index 5e9602ce1573bc7ee26f235cc4c2200b8d99905e..de4b0e932f22e27278b494ad1a4207e143f80f9e 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/platform_device.h>
 
 #include <asm/mach/arch.h>
+#include <asm/secure_cntvoff.h>
 
 static const char * const sunxi_board_dt_compat[] = {
        "allwinner,sun4i-a10",
@@ -62,7 +63,6 @@ MACHINE_END
 static const char * const sun8i_board_dt_compat[] = {
        "allwinner,sun8i-a23",
        "allwinner,sun8i-a33",
-       "allwinner,sun8i-a83t",
        "allwinner,sun8i-h2-plus",
        "allwinner,sun8i-h3",
        "allwinner,sun8i-r40",
@@ -75,6 +75,24 @@ DT_MACHINE_START(SUN8I_DT, "Allwinner sun8i Family")
        .dt_compat      = sun8i_board_dt_compat,
 MACHINE_END
 
+static void __init sun8i_a83t_cntvoff_init(void)
+{
+#ifdef CONFIG_SMP
+       secure_cntvoff_init();
+#endif
+}
+
+static const char * const sun8i_a83t_cntvoff_board_dt_compat[] = {
+       "allwinner,sun8i-a83t",
+       NULL,
+};
+
+DT_MACHINE_START(SUN8I_A83T_CNTVOFF_DT, "Allwinner A83t board")
+       .init_early     = sun8i_a83t_cntvoff_init,
+       .init_time      = sun6i_timer_init,
+       .dt_compat      = sun8i_a83t_cntvoff_board_dt_compat,
+MACHINE_END
+
 static const char * const sun9i_board_dt_compat[] = {
        "allwinner,sun9i-a80",
        NULL,
index 02e712d2ea300b2040efefbfab43cc8cd9cab2e0..f9587be482351fc463800f63253b767a55507a30 100644 (file)
@@ -97,6 +97,10 @@ static void __init tegra_dt_init_late(void)
        if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
            of_machine_is_compatible("compal,paz00"))
                tegra_paz00_wifikill_init();
+
+       if (IS_ENABLED(CONFIG_ARCH_TEGRA_2x_SOC) &&
+           of_machine_is_compatible("nvidia,tegra20"))
+               platform_device_register_simple("tegra20-cpufreq", -1, NULL, 0);
 }
 
 static const char * const tegra_dt_board_compat[] = {
index f98332ea2ef2e8c999f0b634270ec5b9b4fec95b..c1086ebe0050912774e0445a4fa87bd90ff65386 100644 (file)
@@ -9,64 +9,33 @@ menuconfig ARCH_U8500
        select ARM_ERRATA_764369 if SMP
        select ARM_GIC
        select CACHE_L2X0
+       select CLKSRC_DBX500_PRCMU
        select CLKSRC_NOMADIK_MTU
        select GPIOLIB
        select HAVE_ARM_SCU if SMP
        select HAVE_ARM_TWD if SMP
+       select I2C
+       select I2C_NOMADIK
+       select MFD_DB8500_PRCMU
        select PINCTRL
+       select PINCTRL_AB8500
+       select PINCTRL_AB8505
        select PINCTRL_ABX500
+       select PINCTRL_DB8500
        select PINCTRL_NOMADIK
        select PL310_ERRATA_753970 if CACHE_L2X0
-       help
-         Support for ST-Ericsson's Ux500 architecture
-
-if ARCH_U8500
-
-config UX500_SOC_DB8500
-       bool
-       select MFD_DB8500_PRCMU
-       select PINCTRL_DB8500
-       select PINCTRL_DB8540
-       select PINCTRL_AB8500
-       select PINCTRL_AB8505
-       select PINCTRL_AB9540
-       select PINCTRL_AB8540
-       select REGULATOR
-       select REGULATOR_DB8500_PRCMU
-       select CLKSRC_DBX500_PRCMU
        select PM_GENERIC_DOMAINS if PM
-
-config MACH_MOP500
-       bool "U8500 Development platform, MOP500 versions"
-       select I2C
-       select I2C_NOMADIK
        select REGULATOR
+       select REGULATOR_DB8500_PRCMU
        select REGULATOR_FIXED_VOLTAGE
        select SOC_BUS
-       select UX500_SOC_DB8500
        help
-         Include support for the MOP500 development platform.
-
-config MACH_HREFV60
-       bool "U8500 Development platform, HREFv60 version"
-       select MACH_MOP500
-       help
-         Include support for the HREFv60 new development platform.
-         Includes HREFv70, v71 etc.
+         Support for ST-Ericsson's Ux500 architecture
 
-config MACH_SNOWBALL
-       bool "U8500 Snowball platform"
-       select MACH_MOP500
-       help
-         Include support for the snowball development platform.
+if ARCH_U8500
 
-config UX500_AUTO_PLATFORM
+config UX500_SOC_DB8500
        def_bool y
-       select MACH_MOP500
-       help
-         At least one platform needs to be selected in order to build
-         a working kernel. If everything else is disabled, this
-         automatically enables MACH_MOP500.
 
 config UX500_DEBUG_UART
        int "Ux500 UART to use for low-level debug"
index 36cd23c8be9b0f147c87e952c101ef14b0b8db93..389ecf6faa00b383ce2d9ec13a11c223960ca89f 100644 (file)
@@ -111,11 +111,6 @@ static void ux500_restart(enum reboot_mode mode, const char *cmd)
        prcmu_system_reset(0);
 }
 
-static struct of_dev_auxdata u8540_auxdata_lookup[] __initdata = {
-       OF_DEV_AUXDATA("stericsson,db8500-prcmu", 0x80157000, "db8500-prcmu", NULL),
-       {},
-};
-
 static const struct of_device_id u8500_local_bus_nodes[] = {
        /* only create devices below soc node */
        { .compatible = "stericsson,db8500", },
@@ -129,20 +124,13 @@ static void __init u8500_init_machine(void)
        /* Initialize ux500 power domains */
        ux500_pm_domains_init();
 
-       /* automatically probe child nodes of dbx5x0 devices */
-       if (of_machine_is_compatible("st-ericsson,u8540"))
-               of_platform_populate(NULL, u8500_local_bus_nodes,
-                                    u8540_auxdata_lookup, NULL);
-       else
-               of_platform_populate(NULL, u8500_local_bus_nodes,
-                                    NULL, NULL);
+       of_platform_populate(NULL, u8500_local_bus_nodes,
+                            NULL, NULL);
 }
 
 static const char * stericsson_dt_platform_compat[] = {
        "st-ericsson,u8500",
-       "st-ericsson,u8540",
        "st-ericsson,u9500",
-       "st-ericsson,u9540",
        NULL,
 };
 
index 27399553c841aa9151fa97a019d52ef53f2c502b..3d6e1955119a132df3b4dfee738c2fc60052bfd2 100644 (file)
 /* ASIC ID is at 0xbf4 offset within this region */
 #define U8500_ASIC_ID_BASE     0x9001D000
 
-#define U9540_BOOT_ROM_BASE    0xFFFE0000
-/* ASIC ID is at 0xbf4 offset within this region */
-#define U9540_ASIC_ID_BASE     0xFFFFD000
-
 #define U8500_PER6_BASE                0xa03c0000
 #define U8500_PER7_BASE                0xa03d0000
 #define U8500_PER5_BASE                0xa03e0000
index 21c064267af5a4f95df0052a944b0ebf0490215d..0f5381d1349418c5de2723be59811be30a402f8e 100644 (file)
@@ -403,7 +403,7 @@ static int ve_spc_populate_opps(uint32_t cluster)
        uint32_t data = 0, off, ret, idx;
        struct ve_spc_opp *opps;
 
-       opps = kzalloc(sizeof(*opps) * MAX_OPPS, GFP_KERNEL);
+       opps = kcalloc(MAX_OPPS, sizeof(*opps), GFP_KERNEL);
        if (!opps)
                return -ENOMEM;
 
index d9586ba2e63c188489737cb59e7aba35b288911e..c6ed14840c3c76ea27cfdbbf6a1eea2fc5a1edfe 100644 (file)
@@ -33,7 +33,10 @@ extern void v7_flush_kern_cache_all(void);
 #define  RAC_CPU_SHIFT                 (8)
 #define  RACCFG_MASK                   (0xff)
 #define RAC_CONFIG1_REG                        (0x7c)
-#define RAC_FLUSH_REG                  (0x80)
+/* Brahma-B15 is a quad-core only design */
+#define B15_RAC_FLUSH_REG              (0x80)
+/* Brahma-B53 is an octo-core design */
+#define B53_RAC_FLUSH_REG              (0x84)
 #define  FLUSH_RAC                     (1 << 0)
 
 /* Bitmask to enable instruction and data prefetching with a 256-bytes stride */
@@ -52,6 +55,7 @@ static void __iomem *b15_rac_base;
 static DEFINE_SPINLOCK(rac_lock);
 
 static u32 rac_config0_reg;
+static u32 rac_flush_offset;
 
 /* Initialization flag to avoid checking for b15_rac_base, and to prevent
  * multi-platform kernels from crashing here as well.
@@ -70,14 +74,14 @@ static inline void __b15_rac_flush(void)
 {
        u32 reg;
 
-       __raw_writel(FLUSH_RAC, b15_rac_base + RAC_FLUSH_REG);
+       __raw_writel(FLUSH_RAC, b15_rac_base + rac_flush_offset);
        do {
                /* This dmb() is required to force the Bus Interface Unit
                 * to clean oustanding writes, and forces an idle cycle
                 * to be inserted.
                 */
                dmb();
-               reg = __raw_readl(b15_rac_base + RAC_FLUSH_REG);
+               reg = __raw_readl(b15_rac_base + rac_flush_offset);
        } while (reg & FLUSH_RAC);
 }
 
@@ -287,7 +291,7 @@ static struct syscore_ops b15_rac_syscore_ops = {
 
 static int __init b15_rac_init(void)
 {
-       struct device_node *dn;
+       struct device_node *dn, *cpu_dn;
        int ret = 0, cpu;
        u32 reg, en_mask = 0;
 
@@ -305,6 +309,24 @@ static int __init b15_rac_init(void)
                goto out;
        }
 
+       cpu_dn = of_get_cpu_node(0, NULL);
+       if (!cpu_dn) {
+               ret = -ENODEV;
+               goto out;
+       }
+
+       if (of_device_is_compatible(cpu_dn, "brcm,brahma-b15"))
+               rac_flush_offset = B15_RAC_FLUSH_REG;
+       else if (of_device_is_compatible(cpu_dn, "brcm,brahma-b53"))
+               rac_flush_offset = B53_RAC_FLUSH_REG;
+       else {
+               pr_err("Unsupported CPU\n");
+               of_node_put(cpu_dn);
+               ret = -EINVAL;
+               goto out;
+       }
+       of_node_put(cpu_dn);
+
        ret = register_reboot_notifier(&b15_rac_reboot_nb);
        if (ret) {
                pr_err("failed to register reboot notifier\n");
index af27f1c22d93b81c5017b01cf2d89af8c01ceefa..be0fa7e39c2621ea4a9a83744e513f4d62d246c4 100644 (file)
@@ -2162,8 +2162,8 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size)
                goto err;
 
        mapping->bitmap_size = bitmap_size;
-       mapping->bitmaps = kzalloc(extensions * sizeof(unsigned long *),
-                               GFP_KERNEL);
+       mapping->bitmaps = kcalloc(extensions, sizeof(unsigned long *),
+                                  GFP_KERNEL);
        if (!mapping->bitmaps)
                goto err2;
 
index 61e281cb29fb8280e00c88a3ebd0a575645a8c4e..a1606d9502515d5701899c934e9f81fc94c67d2d 100644 (file)
@@ -20,7 +20,7 @@
 #include "mm.h"
 
 #ifdef CONFIG_ARM_LPAE
-#define __pgd_alloc()  kmalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL)
+#define __pgd_alloc()  kmalloc_array(PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL)
 #define __pgd_free(pgd)        kfree(pgd)
 #else
 #define __pgd_alloc()  (pgd_t *)__get_free_pages(GFP_KERNEL, 2)
index afc1a1d4f7a5cdd2cda8486b717addb2cd1baf60..c0a242cae79afd3df963a292ae73d7e5914530b7 100644 (file)
@@ -115,16 +115,6 @@ config OMAP_SERIAL_WAKE
          to data on the serial RX line. This allows you to wake the
          system from serial console.
 
-choice
-       prompt "OMAP PM layer selection"
-       depends on ARCH_OMAP
-       default OMAP_PM_NOOP
-
-config OMAP_PM_NOOP
-       bool "No-op/debug PM layer"
-
-endchoice
-
 endmenu
 
 endif
index 42bac8d5ab5d9166fb3567f8574fd7bc7d2bb6bf..2da35735fa388fae33a5ed705ef5f5b1a9fdcaa8 100644 (file)
@@ -413,8 +413,7 @@ static int s3c_adc_remove(struct platform_device *pdev)
 #ifdef CONFIG_PM
 static int s3c_adc_suspend(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct adc_device *adc = platform_get_drvdata(pdev);
+       struct adc_device *adc = dev_get_drvdata(dev);
        unsigned long flags;
        u32 con;
 
index f5769e93544a95805e5f87bfc727c3407ed244c1..d69a0ca09fb5b84eda2fe27363319cbd53cd777d 100644 (file)
 
 #define S5P_VA_CHIPID          S3C_ADDR(0x02000000)
 
-#define S5P_VA_COREPERI_BASE   S3C_ADDR(0x02800000)
-#define S5P_VA_COREPERI(x)     (S5P_VA_COREPERI_BASE + (x))
-#define S5P_VA_SCU             S5P_VA_COREPERI(0x0)
-
 #define VA_VIC(x)              (S3C_VA_IRQ + ((x) * 0x10000))
 #define VA_VIC0                        VA_VIC(0)
 #define VA_VIC1                        VA_VIC(1)
index 9ed0129bed3ce3d2904740c9efa24256c3088e18..14db14152909c9942978c370b3d8230bc5ae4508 100644 (file)
@@ -766,8 +766,9 @@ static int coverage_start_fn(const struct decode_header *h, void *args)
 
 static int coverage_start(const union decode_item *table)
 {
-       coverage.base = kmalloc(MAX_COVERAGE_ENTRIES *
-                               sizeof(struct coverage_entry), GFP_KERNEL);
+       coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES,
+                                     sizeof(struct coverage_entry),
+                                     GFP_KERNEL);
        coverage.num_entries = 0;
        coverage.nesting = 0;
        return table_iter(table, coverage_start_fn, &coverage);
index bb4118213feee5ae9b33f85abb853ae20d51721b..f4efff9d3afbb68e6ae9d09f0b4cd3538bb66f63 100644 (file)
@@ -30,6 +30,9 @@ CFLAGS_vgettimeofday.o = -O2
 # Disable gcov profiling for VDSO code
 GCOV_PROFILE := n
 
+# Prevents link failures: __sanitizer_cov_trace_pc() is not linked in.
+KCOV_INSTRUMENT := n
+
 # Force dependency
 $(obj)/vdso.o : $(obj)/vdso.so
 
index 9795b59aa28a1ecc01979f819d68beaa21192311..42c090cf02927283ccb2dc597e30205a11050ecb 100644 (file)
@@ -46,6 +46,7 @@ config ARM64
        select ARCH_USE_QUEUED_RWLOCKS
        select ARCH_SUPPORTS_MEMORY_FAILURE
        select ARCH_SUPPORTS_ATOMIC_RMW
+       select ARCH_SUPPORTS_INT128 if GCC_VERSION >= 50000 || CC_IS_CLANG
        select ARCH_SUPPORTS_NUMA_BALANCING
        select ARCH_WANT_COMPAT_IPC_PARSE_VERSION
        select ARCH_WANT_FRAME_POINTERS
@@ -102,7 +103,6 @@ config ARM64
        select HAVE_ARM_SMCCC
        select HAVE_EBPF_JIT
        select HAVE_C_RECORDMCOUNT
-       select HAVE_CC_STACKPROTECTOR
        select HAVE_CMPXCHG_DOUBLE
        select HAVE_CMPXCHG_LOCAL
        select HAVE_CONTEXT_TRACKING
@@ -127,6 +127,7 @@ config ARM64
        select HAVE_PERF_USER_STACK_DUMP
        select HAVE_REGS_AND_STACK_ACCESS_API
        select HAVE_RCU_TABLE_FREE
+       select HAVE_STACKPROTECTOR
        select HAVE_SYSCALL_TRACEPOINTS
        select HAVE_KPROBES
        select HAVE_KRETPROBES
@@ -1128,6 +1129,7 @@ endmenu
 config ARM64_SVE
        bool "ARM Scalable Vector Extension support"
        default y
+       depends on !KVM || ARM64_VHE
        help
          The Scalable Vector Extension (SVE) is an extension to the AArch64
          execution state which complements and extends the SIMD functionality
@@ -1153,6 +1155,12 @@ config ARM64_SVE
          booting the kernel.  If unsure and you are not observing these
          symptoms, you should assume that it is safe to say Y.
 
+         CPUs that support SVE are architecturally required to support the
+         Virtualization Host Extensions (VHE), so the kernel makes no
+         provision for supporting SVE alongside KVM without VHE enabled.
+         Thus, you will need to enable CONFIG_ARM64_VHE if you want to support
+         KVM in the same kernel image.
+
 config ARM64_MODULE_PLTS
        bool
        select HAVE_MOD_ARCH_SPECIFIC
index 2b1535cdeb7ccfa4d3b9a15613e38e2d16b63f65..d5aeac351fc3a776ee840f09680f43a864b5307c 100644 (file)
@@ -208,6 +208,12 @@ config ARCH_R8A77980
        help
          This enables support for the Renesas R-Car V3H SoC.
 
+config ARCH_R8A77990
+       bool "Renesas R-Car E3 SoC Platform"
+       depends on ARCH_RENESAS
+       help
+         This enables support for the Renesas R-Car E3 SoC.
+
 config ARCH_R8A77995
        bool "Renesas R-Car D3 SoC Platform"
        depends on ARCH_RENESAS
index 3c353b4715dc462ef26bc3bb1ad00af684cd3bc5..45272266dafb64a1fda433e7f557bf11b89e908e 100644 (file)
@@ -56,12 +56,6 @@ KBUILD_AFLAGS        += $(lseinstr) $(brokengasinst)
 KBUILD_CFLAGS  += $(call cc-option,-mabi=lp64)
 KBUILD_AFLAGS  += $(call cc-option,-mabi=lp64)
 
-ifeq ($(cc-name),clang)
-KBUILD_CFLAGS  += -DCONFIG_ARCH_SUPPORTS_INT128
-else
-KBUILD_CFLAGS  += $(call cc-ifversion, -ge, 0500, -DCONFIG_ARCH_SUPPORTS_INT128)
-endif
-
 ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
 KBUILD_CPPFLAGS        += -mbig-endian
 CHECKFLAGS     += -D__AARCH64EB__
index 4aa50b9b26bca7b904ab3e2921dc844f0f46f9b9..3543bc32455339cf22d7ca70f2aef5a3de159cba 100644 (file)
@@ -22,5 +22,6 @@ subdir-y += renesas
 subdir-y += rockchip
 subdir-y += socionext
 subdir-y += sprd
+subdir-y += synaptics
 subdir-y += xilinx
 subdir-y += zte
index 8bebe7da5ed9a924080dec86dbb05cfd97eab7fb..c31f90a494810d2ac9ef89fdd2bb4413ccb7da5e 100644 (file)
@@ -6,10 +6,11 @@ dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-orangepi-win.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-pine64-plus.dtb sun50i-a64-pine64.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-sopine-baseboard.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-a64-teres-i.dtb
+dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-libretech-all-h3-cc.dtb
+dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-nanopi-neo2.dtb
+dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-nanopi-neo-plus2.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-orangepi-pc2.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-orangepi-prime.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-orangepi-zero-plus.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-orangepi-zero-plus2.dtb
-dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-nanopi-neo2.dtb
-dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h5-nanopi-neo-plus2.dtb
 dtb-$(CONFIG_ARCH_SUNXI) += sun50i-h6-pine-h64.dtb
index ff8af52743ff4c2e714e233d5fd21e38d4c2d9f9..e5eae8bafc422ca4a33f4d34c0109ef90c184563 100644 (file)
@@ -146,5 +146,10 @@ reg_rtc_ldo: rtc-ldo {
                        regulator-max-microvolt = <3000000>;
                        regulator-name = "rtc-ldo";
                };
+
+               reg_drivevbus: drivevbus {
+                       regulator-name = "drivevbus";
+                       status = "disabled";
+               };
        };
 };
index 2250dec9974c7f27e3abebc298e83861e015f3b8..0716b144118775df150f19010549a141c18e744f 100644 (file)
@@ -86,6 +86,10 @@ wifi_pwrseq: wifi_pwrseq {
        };
 };
 
+&ehci0 {
+       status = "okay";
+};
+
 &ehci1 {
        status = "okay";
 };
@@ -155,6 +159,10 @@ &mmc2 {
        status = "okay";
 };
 
+&ohci0 {
+       status = "okay";
+};
+
 &ohci1 {
        status = "okay";
 };
@@ -167,6 +175,7 @@ axp803: pmic@3a3 {
                reg = <0x3a3>;
                interrupt-parent = <&r_intc>;
                interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+               x-powers,drive-vbus-en; /* set N_VBUSEN as output pin */
        };
 };
 
@@ -254,6 +263,11 @@ &reg_dldo4 {
        regulator-name = "vcc-wifi-io";
 };
 
+&reg_drivevbus {
+       regulator-name = "usb0-vbus";
+       status = "okay";
+};
+
 &reg_eldo1 {
        regulator-min-microvolt = <1800000>;
        regulator-max-microvolt = <1800000>;
@@ -294,6 +308,13 @@ &uart1 {
        status = "okay";
 };
 
+&usb_otg {
+       dr_mode = "otg";
+       status = "okay";
+};
+
 &usbphy {
+       usb0_id_det-gpios = <&pio 7 9 GPIO_ACTIVE_HIGH>; /* PH9 */
+       usb0_vbus-supply = <&reg_drivevbus>;
        status = "okay";
 };
diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h5-libretech-all-h3-cc.dts b/arch/arm64/boot/dts/allwinner/sun50i-h5-libretech-all-h3-cc.dts
new file mode 100644 (file)
index 0000000..95e113c
--- /dev/null
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (C) 2018 BayLibre, SAS
+ * Author: Neil Armstrong <narmstrong@baylibre.com>
+ */
+
+/dts-v1/;
+#include "sun50i-h5.dtsi"
+#include <arm/sunxi-libretech-all-h3-cc.dtsi>
+
+/ {
+       model = "Libre Computer Board ALL-H3-CC H5";
+       compatible = "libretech,all-h3-cc-h5", "allwinner,sun50i-h5";
+};
index e237c05cfdb403040742528228f59c04ca89b4c8..62d646baac3c403bb1d1908278694f7404a954f6 100644 (file)
@@ -47,7 +47,7 @@ cpus {
                #address-cells = <1>;
                #size-cells = <0>;
 
-               cpu@0 {
+               cpu0: cpu@0 {
                        compatible = "arm,cortex-a53", "arm,armv8";
                        device_type = "cpu";
                        reg = <0>;
index d36de5eb81f3f224ab04de6f62a7a7a2793090c4..b6f2d6b2ecaea7afd40ba3da6d27b94ffc8b10fb 100644 (file)
@@ -22,6 +22,16 @@ chosen {
        };
 };
 
+&r_i2c {
+       status = "okay";
+
+       pcf8563: rtc@51 {
+               compatible = "nxp,pcf8563";
+               reg = <0x51>;
+               #clock-cells = <0>;
+       };
+};
+
 &uart0 {
        pinctrl-names = "default";
        pinctrl-0 = <&uart0_ph_pins>;
index 56563150d61a91eac2f77b272042a45d57adfb96..c72da8cd9ef5881eceedcf8390fbcda620c5cac9 100644 (file)
@@ -4,6 +4,8 @@
  */
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/clock/sun50i-h6-ccu.h>
+#include <dt-bindings/reset/sun50i-h6-ccu.h>
 
 / {
        interrupt-parent = <&gic>;
@@ -115,7 +117,7 @@ pio: pinctrl@300b000 {
                                     <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
                                     <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
                                     <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&ccu 26>, <&osc24M>, <&osc32k>;
+                       clocks = <&ccu CLK_APB1>, <&osc24M>, <&osc32k>;
                        clock-names = "apb", "hosc", "losc";
                        gpio-controller;
                        #gpio-cells = <3>;
@@ -134,8 +136,8 @@ uart0: serial@5000000 {
                        interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH>;
                        reg-shift = <2>;
                        reg-io-width = <4>;
-                       clocks = <&ccu 70>;
-                       resets = <&ccu 21>;
+                       clocks = <&ccu CLK_BUS_UART0>;
+                       resets = <&ccu RST_BUS_UART0>;
                        status = "disabled";
                };
 
@@ -145,8 +147,8 @@ uart1: serial@5000400 {
                        interrupts = <GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH>;
                        reg-shift = <2>;
                        reg-io-width = <4>;
-                       clocks = <&ccu 71>;
-                       resets = <&ccu 22>;
+                       clocks = <&ccu CLK_BUS_UART1>;
+                       resets = <&ccu RST_BUS_UART1>;
                        status = "disabled";
                };
 
@@ -156,8 +158,8 @@ uart2: serial@5000800 {
                        interrupts = <GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH>;
                        reg-shift = <2>;
                        reg-io-width = <4>;
-                       clocks = <&ccu 72>;
-                       resets = <&ccu 23>;
+                       clocks = <&ccu CLK_BUS_UART2>;
+                       resets = <&ccu RST_BUS_UART2>;
                        status = "disabled";
                };
 
@@ -167,9 +169,59 @@ uart3: serial@5000c00 {
                        interrupts = <GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH>;
                        reg-shift = <2>;
                        reg-io-width = <4>;
-                       clocks = <&ccu 73>;
-                       resets = <&ccu 24>;
+                       clocks = <&ccu CLK_BUS_UART3>;
+                       resets = <&ccu RST_BUS_UART3>;
                        status = "disabled";
                };
+
+               r_ccu: clock@7010000 {
+                       compatible = "allwinner,sun50i-h6-r-ccu";
+                       reg = <0x07010000 0x400>;
+                       clocks = <&osc24M>, <&osc32k>, <&iosc>,
+                                <&ccu CLK_PLL_PERIPH0>;
+                       clock-names = "hosc", "losc", "iosc", "pll-periph";
+                       #clock-cells = <1>;
+                       #reset-cells = <1>;
+               };
+
+               r_intc: interrupt-controller@7021000 {
+                       compatible = "allwinner,sun50i-h6-r-intc",
+                                    "allwinner,sun6i-a31-r-intc";
+                       interrupt-controller;
+                       #interrupt-cells = <2>;
+                       reg = <0x07021000 0x400>;
+                       interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
+               };
+
+               r_pio: pinctrl@7022000 {
+                       compatible = "allwinner,sun50i-h6-r-pinctrl";
+                       reg = <0x07022000 0x400>;
+                       interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 111 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&r_ccu 2>, <&osc24M>, <&osc32k>;
+                       clock-names = "apb", "hosc", "losc";
+                       gpio-controller;
+                       #gpio-cells = <3>;
+                       interrupt-controller;
+                       #interrupt-cells = <3>;
+
+                       r_i2c_pins: r-i2c {
+                               pins = "PL0", "PL1";
+                               function = "s_i2c";
+                       };
+               };
+
+               r_i2c: i2c@7081400 {
+                       compatible = "allwinner,sun6i-a31-i2c";
+                       reg = <0x07081400 0x400>;
+                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&r_ccu 8>;
+                       resets = <&r_ccu 4>;
+                       pinctrl-names = "default";
+                       pinctrl-0 = <&r_i2c_pins>;
+                       status = "disabled";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+               };
        };
 };
index 57eedced5a5168fbc72fc1224be13e7d12b80aa5..4b3331fbfe39d7b81d9466fb718975b6265c8e5e 100644 (file)
@@ -15,6 +15,53 @@ aliases {
                serial0 = &uart_AO;
                serial1 = &uart_A;
        };
+
+       vddio_boot: regulator-vddio_boot {
+               compatible = "regulator-fixed";
+               regulator-name = "VDDIO_BOOT";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+       };
+
+       vddao_3v3: regulator-vddao_3v3 {
+               compatible = "regulator-fixed";
+               regulator-name = "VDDAO_3V3";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+       };
+
+       vddio_ao18: regulator-vddio_ao18 {
+               compatible = "regulator-fixed";
+               regulator-name = "VDDIO_AO18";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+       };
+
+       vcc_3v3: regulator-vcc_3v3 {
+               compatible = "regulator-fixed";
+               regulator-name = "VCC_3V3";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+       };
+
+       emmc_pwrseq: emmc-pwrseq {
+               compatible = "mmc-pwrseq-emmc";
+               reset-gpios = <&gpio BOOT_9 GPIO_ACTIVE_LOW>;
+       };
+
+       sdio_pwrseq: sdio-pwrseq {
+               compatible = "mmc-pwrseq-simple";
+               reset-gpios = <&gpio GPIOX_7 GPIO_ACTIVE_LOW>;
+               clocks = <&wifi32k>;
+               clock-names = "ext_clock";
+       };
+
+       wifi32k: wifi32k {
+               compatible = "pwm-clock";
+               #clock-cells = <0>;
+               clock-frequency = <32768>;
+               pwms = <&pwm_ab 0 30518 0>; /* PWM_A at 32.768KHz */
+       };
 };
 
 &ethmac {
@@ -47,3 +94,62 @@ &i2c1 {
        pinctrl-0 = <&i2c1_z_pins>;
        pinctrl-names = "default";
 };
+
+&i2c_AO {
+       status = "okay";
+       pinctrl-0 = <&i2c_ao_sck_10_pins>, <&i2c_ao_sda_11_pins>;
+       pinctrl-names = "default";
+};
+
+&pwm_ab {
+       status = "okay";
+       pinctrl-0 = <&pwm_a_x20_pins>;
+       pinctrl-names = "default";
+};
+
+/* emmc storage */
+&sd_emmc_c {
+       status = "okay";
+       pinctrl-0 = <&emmc_pins>;
+       pinctrl-1 = <&emmc_clk_gate_pins>;
+       pinctrl-names = "default", "clk-gate";
+
+       bus-width = <8>;
+       cap-sd-highspeed;
+       cap-mmc-highspeed;
+       max-frequency = <180000000>;
+       non-removable;
+       disable-wp;
+       mmc-ddr-1_8v;
+       mmc-hs200-1_8v;
+
+       vmmc-supply = <&vcc_3v3>;
+       vqmmc-supply = <&vddio_boot>;
+};
+
+/* wifi module */
+&sd_emmc_b {
+       status = "okay";
+       #address-cells = <1>;
+       #size-cells = <0>;
+
+       pinctrl-0 = <&sdio_pins>;
+       pinctrl-1 = <&sdio_clk_gate_pins>;
+       pinctrl-names = "default", "clk-gate";
+
+       bus-width = <4>;
+       cap-sd-highspeed;
+       max-frequency = <100000000>;
+       non-removable;
+       disable-wp;
+
+       mmc-pwrseq = <&sdio_pwrseq>;
+
+       vmmc-supply = <&vddao_3v3>;
+       vqmmc-supply = <&vddio_boot>;
+
+       brcmf: wifi@1 {
+               reg = <1>;
+               compatible = "brcm,bcm4329-fmac";
+       };
+};
index b58808eb3cc84037ab9cc87edeb2d624a65a073b..fee87737a201f1121fe7a3ad3cd70c1d20415a0d 100644 (file)
@@ -7,6 +7,9 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/clock/axg-clkc.h>
+#include <dt-bindings/clock/axg-aoclkc.h>
+#include <dt-bindings/gpio/meson-axg-gpio.h>
+#include <dt-bindings/reset/amlogic,meson-axg-reset.h>
 
 / {
        compatible = "amlogic,meson-axg";
@@ -107,12 +110,51 @@ xtal: xtal-clk {
                #clock-cells = <0>;
        };
 
+       ao_alt_xtal: ao_alt_xtal-clk {
+               compatible = "fixed-clock";
+               clock-frequency = <32000000>;
+               clock-output-names = "ao_alt_xtal";
+               #clock-cells = <0>;
+       };
+
        soc {
                compatible = "simple-bus";
                #address-cells = <2>;
                #size-cells = <2>;
                ranges;
 
+               apb: apb@ffe00000 {
+                       compatible = "simple-bus";
+                       reg = <0x0 0xffe00000 0x0 0x200000>;
+                       #address-cells = <2>;
+                       #size-cells = <2>;
+                       ranges = <0x0 0x0 0x0 0xffe00000 0x0 0x200000>;
+
+                       sd_emmc_b: sd@5000 {
+                               compatible = "amlogic,meson-axg-mmc";
+                               reg = <0x0 0x5000 0x0 0x2000>;
+                               interrupts = <GIC_SPI 217 IRQ_TYPE_EDGE_RISING>;
+                               status = "disabled";
+                               clocks = <&clkc CLKID_SD_EMMC_B>,
+                                       <&clkc CLKID_SD_EMMC_B_CLK0>,
+                                       <&clkc CLKID_FCLK_DIV2>;
+                               clock-names = "core", "clkin0", "clkin1";
+                               resets = <&reset RESET_SD_EMMC_B>;
+                       };
+
+                       sd_emmc_c: mmc@7000 {
+                               compatible = "amlogic,meson-axg-mmc";
+                               reg = <0x0 0x7000 0x0 0x2000>;
+                               interrupts = <GIC_SPI 218 IRQ_TYPE_EDGE_RISING>;
+                               status = "disabled";
+                               clocks = <&clkc CLKID_SD_EMMC_C>,
+                                       <&clkc CLKID_SD_EMMC_C_CLK0>,
+                                       <&clkc CLKID_FCLK_DIV2>;
+                               clock-names = "core", "clkin0", "clkin1";
+                               resets = <&reset RESET_SD_EMMC_C>;
+                       };
+               };
+
                cbus: bus@ffd00000 {
                        compatible = "simple-bus";
                        reg = <0x0 0xffd00000 0x0 0x25000>;
@@ -120,6 +162,15 @@ cbus: bus@ffd00000 {
                        #size-cells = <2>;
                        ranges = <0x0 0x0 0x0 0xffd00000 0x0 0x25000>;
 
+                       gpio_intc: interrupt-controller@f080 {
+                               compatible = "amlogic,meson-gpio-intc";
+                               reg = <0x0 0xf080 0x0 0x10>;
+                               interrupt-controller;
+                               #interrupt-cells = <2>;
+                               amlogic,channel-interrupts = <64 65 66 67 68 69 70 71>;
+                               status = "disabled";
+                       };
+
                        pwm_ab: pwm@1b000 {
                                compatible = "amlogic,meson-axg-ee-pwm";
                                reg = <0x0 0x1b000 0x0 0x20>;
@@ -164,50 +215,42 @@ spicc1: spi@15000 {
 
                        i2c0: i2c@1f000 {
                                compatible = "amlogic,meson-axg-i2c";
-                               status = "disabled";
                                reg = <0x0 0x1f000 0x0 0x20>;
-                               interrupts = <GIC_SPI 21 IRQ_TYPE_EDGE_RISING>,
-                                       <GIC_SPI 47 IRQ_TYPE_EDGE_RISING>;
+                               interrupts = <GIC_SPI 21 IRQ_TYPE_EDGE_RISING>;
+                               clocks = <&clkc CLKID_I2C>;
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               clocks = <&clkc CLKID_I2C>;
-                               clock-names = "clk_i2c";
+                               status = "disabled";
                        };
 
                        i2c1: i2c@1e000 {
                                compatible = "amlogic,meson-axg-i2c";
+                               reg = <0x0 0x1e000 0x0 0x20>;
+                               interrupts = <GIC_SPI 214 IRQ_TYPE_EDGE_RISING>;
+                               clocks = <&clkc CLKID_I2C>;
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               reg = <0x0 0x1e000 0x0 0x20>;
                                status = "disabled";
-                               interrupts = <GIC_SPI 214 IRQ_TYPE_EDGE_RISING>,
-                                       <GIC_SPI 48 IRQ_TYPE_EDGE_RISING>;
-                               clocks = <&clkc CLKID_I2C>;
-                               clock-names = "clk_i2c";
                        };
 
                        i2c2: i2c@1d000 {
                                compatible = "amlogic,meson-axg-i2c";
-                               status = "disabled";
                                reg = <0x0 0x1d000 0x0 0x20>;
-                               interrupts = <GIC_SPI 215 IRQ_TYPE_EDGE_RISING>,
-                                       <GIC_SPI 49 IRQ_TYPE_EDGE_RISING>;
+                               interrupts = <GIC_SPI 215 IRQ_TYPE_EDGE_RISING>;
+                               clocks = <&clkc CLKID_I2C>;
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               clocks = <&clkc CLKID_I2C>;
-                               clock-names = "clk_i2c";
+                               status = "disabled";
                        };
 
                        i2c3: i2c@1c000 {
                                compatible = "amlogic,meson-axg-i2c";
-                               status = "disabled";
                                reg = <0x0 0x1c000 0x0 0x20>;
-                               interrupts = <GIC_SPI 39 IRQ_TYPE_EDGE_RISING>,
-                                       <GIC_SPI 50 IRQ_TYPE_EDGE_RISING>;
+                               interrupts = <GIC_SPI 39 IRQ_TYPE_EDGE_RISING>;
+                               clocks = <&clkc CLKID_I2C>;
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               clocks = <&clkc CLKID_I2C>;
-                               clock-names = "clk_i2c";
+                               status = "disabled";
                        };
 
                        uart_A: serial@24000 {
@@ -262,10 +305,14 @@ hiubus: bus@ff63c000 {
                        #size-cells = <2>;
                        ranges = <0x0 0x0 0x0 0xff63c000 0x0 0x1c00>;
 
-                       clkc: clock-controller@0 {
-                               compatible = "amlogic,axg-clkc";
-                               #clock-cells = <1>;
-                               reg = <0x0 0x0 0x0 0x320>;
+                       sysctrl: system-controller@0 {
+                               compatible = "amlogic,meson-axg-hhi-sysctrl", "syscon", "simple-mfd";
+                               reg = <0 0 0 0x400>;
+
+                               clkc: clock-controller {
+                                       compatible = "amlogic,axg-clkc";
+                                       #clock-cells = <1>;
+                               };
                        };
                };
 
@@ -309,6 +356,57 @@ gpio: bank@480 {
                                        gpio-ranges = <&pinctrl_periphs 0 0 86>;
                                };
 
+                               emmc_pins: emmc {
+                                       mux {
+                                               groups = "emmc_nand_d0",
+                                                       "emmc_nand_d1",
+                                                       "emmc_nand_d2",
+                                                       "emmc_nand_d3",
+                                                       "emmc_nand_d4",
+                                                       "emmc_nand_d5",
+                                                       "emmc_nand_d6",
+                                                       "emmc_nand_d7",
+                                                       "emmc_clk",
+                                                       "emmc_cmd",
+                                                       "emmc_ds";
+                                               function = "emmc";
+                                       };
+                               };
+
+                               emmc_clk_gate_pins: emmc_clk_gate {
+                                       mux {
+                                               groups = "BOOT_8";
+                                               function = "gpio_periphs";
+                                       };
+                                       cfg-pull-down {
+                                               pins = "BOOT_8";
+                                               bias-pull-down;
+                                       };
+                               };
+
+                               sdio_pins: sdio {
+                                       mux {
+                                               groups = "sdio_d0",
+                                                       "sdio_d1",
+                                                       "sdio_d2",
+                                                       "sdio_d3",
+                                                       "sdio_cmd",
+                                                       "sdio_clk";
+                                               function = "sdio";
+                                       };
+                               };
+
+                               sdio_clk_gate_pins: sdio_clk_gate {
+                                       mux {
+                                               groups = "GPIOX_4";
+                                               function = "gpio_periphs";
+                                       };
+                                       cfg-pull-down {
+                                               pins = "GPIOX_4";
+                                               bias-pull-down;
+                                       };
+                               };
+
                                eth_rmii_x_pins: eth-x-rmii {
                                        mux {
                                                groups = "eth_mdio_x",
@@ -660,6 +758,251 @@ mux {
                                                function = "uart_ao_b_z";
                                        };
                                };
+
+                               mclk_b_pins: mclk_b {
+                                       mux {
+                                               groups = "mclk_b";
+                                               function = "mclk_b";
+                                       };
+                               };
+
+                               mclk_c_pins: mclk_c {
+                                       mux {
+                                               groups = "mclk_c";
+                                               function = "mclk_c";
+                                       };
+                               };
+
+                               tdma_sclk_pins: tdma_sclk {
+                                       mux {
+                                               groups = "tdma_sclk";
+                                               function = "tdma";
+                                       };
+                               };
+
+                               tdma_sclk_slv_pins: tdma_sclk_slv {
+                                       mux {
+                                               groups = "tdma_sclk_slv";
+                                               function = "tdma";
+                                       };
+                               };
+
+                               tdma_fs_pins: tdma_fs {
+                                       mux {
+                                               groups = "tdma_fs";
+                                               function = "tdma";
+                                       };
+                               };
+
+                               tdma_fs_slv_pins: tdma_fs_slv {
+                                       mux {
+                                               groups = "tdma_fs_slv";
+                                               function = "tdma";
+                                       };
+                               };
+
+                               tdma_din0_pins: tdma_din0 {
+                                       mux {
+                                               groups = "tdma_din0";
+                                               function = "tdma";
+                                       };
+                               };
+
+                               tdma_dout0_x14_pins: tdma_dout0_x14 {
+                                       mux {
+                                               groups = "tdma_dout0_x14";
+                                               function = "tdma";
+                                       };
+                               };
+
+                               tdma_dout0_x15_pins: tdma_dout0_x15 {
+                                       mux {
+                                               groups = "tdma_dout0_x15";
+                                               function = "tdma";
+                                       };
+                               };
+
+                               tdma_dout1_pins: tdma_dout1 {
+                                       mux {
+                                               groups = "tdma_dout1";
+                                               function = "tdma";
+                                       };
+                               };
+
+                               tdma_din1_pins: tdma_din1 {
+                                       mux {
+                                               groups = "tdma_din1";
+                                               function = "tdma";
+                                       };
+                               };
+
+                               tdmb_sclk_pins: tdmb_sclk {
+                                       mux {
+                                               groups = "tdmb_sclk";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_sclk_slv_pins: tdmb_sclk_slv {
+                                       mux {
+                                               groups = "tdmb_sclk_slv";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_fs_pins: tdmb_fs {
+                                       mux {
+                                               groups = "tdmb_fs";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_fs_slv_pins: tdmb_fs_slv {
+                                       mux {
+                                               groups = "tdmb_fs_slv";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_din0_pins: tdmb_din0 {
+                                       mux {
+                                               groups = "tdmb_din0";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_dout0_pins: tdmb_dout0 {
+                                       mux {
+                                               groups = "tdmb_dout0";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_din1_pins: tdmb_din1 {
+                                       mux {
+                                               groups = "tdmb_din1";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_dout1_pins: tdmb_dout1 {
+                                       mux {
+                                               groups = "tdmb_dout1";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_din2_pins: tdmb_din2 {
+                                       mux {
+                                               groups = "tdmb_din2";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_dout2_pins: tdmb_dout2 {
+                                       mux {
+                                               groups = "tdmb_dout2";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_din3_pins: tdmb_din3 {
+                                       mux {
+                                               groups = "tdmb_din3";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmb_dout3_pins: tdmb_dout3 {
+                                       mux {
+                                               groups = "tdmb_dout3";
+                                               function = "tdmb";
+                                       };
+                               };
+
+                               tdmc_sclk_pins: tdmc_sclk {
+                                       mux {
+                                               groups = "tdmc_sclk";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_sclk_slv_pins: tdmc_sclk_slv {
+                                       mux {
+                                               groups = "tdmc_sclk_slv";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_fs_pins: tdmc_fs {
+                                       mux {
+                                               groups = "tdmc_fs";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_fs_slv_pins: tdmc_fs_slv {
+                                       mux {
+                                               groups = "tdmc_fs_slv";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_din0_pins: tdmc_din0 {
+                                       mux {
+                                               groups = "tdmc_din0";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_dout0_pins: tdmc_dout0 {
+                                       mux {
+                                               groups = "tdmc_dout0";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_din1_pins: tdmc_din1 {
+                                       mux {
+                                               groups = "tdmc_din1";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_dout1_pins: tdmc_dout1 {
+                                       mux {
+                                               groups = "tdmc_dout1";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_din2_pins: tdmc_din2 {
+                                       mux {
+                                               groups = "tdmc_din2";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_dout2_pins: tdmc_dout2 {
+                                       mux {
+                                               groups = "tdmc_dout2";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_din3_pins: tdmc_din3 {
+                                       mux {
+                                               groups = "tdmc_din3";
+                                               function = "tdmc";
+                                       };
+                               };
+
+                               tdmc_dout3_pins: tdmc_dout3 {
+                                       mux {
+                                               groups = "tdmc_dout3";
+                                               function = "tdmc";
+                                       };
+                               };
                        };
                };
 
@@ -688,6 +1031,17 @@ aobus: bus@ff800000 {
                        #size-cells = <2>;
                        ranges = <0x0 0x0 0x0 0xff800000 0x0 0x100000>;
 
+                       sysctrl_AO: sys-ctrl@0 {
+                               compatible = "amlogic,meson-axg-ao-sysctrl", "syscon", "simple-mfd";
+                               reg =  <0x0 0x0 0x0 0x100>;
+
+                               clkc_AO: clock-controller {
+                                       compatible = "amlogic,meson-axg-aoclkc";
+                                       #clock-cells = <1>;
+                                       #reset-cells = <1>;
+                               };
+                       };
+
                        pinctrl_aobus: pinctrl@14 {
                                compatible = "amlogic,meson-axg-aobus-pinctrl";
                                #address-cells = <2>;
@@ -704,6 +1058,48 @@ gpio_ao: bank@14 {
                                        gpio-ranges = <&pinctrl_aobus 0 0 15>;
                                };
 
+                               i2c_ao_sck_4_pins: i2c_ao_sck_4 {
+                                       mux {
+                                               groups = "i2c_ao_sck_4";
+                                               function = "i2c_ao";
+                                       };
+                               };
+
+                               i2c_ao_sck_8_pins: i2c_ao_sck_8 {
+                                       mux {
+                                               groups = "i2c_ao_sck_8";
+                                               function = "i2c_ao";
+                                       };
+                               };
+
+                               i2c_ao_sck_10_pins: i2c_ao_sck_10 {
+                                       mux {
+                                               groups = "i2c_ao_sck_10";
+                                               function = "i2c_ao";
+                                       };
+                               };
+
+                               i2c_ao_sda_5_pins: i2c_ao_sda_5 {
+                                       mux {
+                                               groups = "i2c_ao_sda_5";
+                                               function = "i2c_ao";
+                                       };
+                               };
+
+                               i2c_ao_sda_9_pins: i2c_ao_sda_9 {
+                                       mux {
+                                               groups = "i2c_ao_sda_9";
+                                               function = "i2c_ao";
+                                       };
+                               };
+
+                               i2c_ao_sda_11_pins: i2c_ao_sda_11 {
+                                       mux {
+                                               groups = "i2c_ao_sda_11";
+                                               function = "i2c_ao";
+                                       };
+                               };
+
                                remote_input_ao_pins: remote_input_ao {
                                        mux {
                                                groups = "remote_input_ao";
@@ -766,20 +1162,19 @@ pwm_AO_cd: pwm@2000 {
 
                        i2c_AO: i2c@5000 {
                                compatible = "amlogic,meson-axg-i2c";
-                               status = "disabled";
                                reg = <0x0 0x05000 0x0 0x20>;
                                interrupts = <GIC_SPI 195 IRQ_TYPE_EDGE_RISING>;
+                               clocks = <&clkc CLKID_AO_I2C>;
                                #address-cells = <1>;
                                #size-cells = <0>;
-                               clocks = <&clkc CLKID_I2C>;
-                               clock-names = "clk_i2c";
+                               status = "disabled";
                        };
 
                        uart_AO: serial@3000 {
                                compatible = "amlogic,meson-gx-uart", "amlogic,meson-ao-uart";
                                reg = <0x0 0x3000 0x0 0x18>;
                                interrupts = <GIC_SPI 193 IRQ_TYPE_EDGE_RISING>;
-                               clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+                               clocks = <&xtal>, <&clkc_AO CLKID_AO_UART1>, <&xtal>;
                                clock-names = "xtal", "pclk", "baud";
                                status = "disabled";
                        };
@@ -788,7 +1183,7 @@ uart_AO_B: serial@4000 {
                                compatible = "amlogic,meson-gx-uart", "amlogic,meson-ao-uart";
                                reg = <0x0 0x4000 0x0 0x18>;
                                interrupts = <GIC_SPI 197 IRQ_TYPE_EDGE_RISING>;
-                               clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+                               clocks = <&xtal>, <&clkc_AO CLKID_AO_UART2>, <&xtal>;
                                clock-names = "xtal", "pclk", "baud";
                                status = "disabled";
                        };
index 562c26a0ba333ed2989351f1d854b0a20fcab042..98cbba6809caa17e2fa4f6b630bf8b02e26f32ab 100644 (file)
@@ -307,11 +307,10 @@ &hdmi_tx {
        clock-names = "isfr", "iahb", "venci";
 };
 
-&hiubus {
-       clkc: clock-controller@0 {
+&sysctrl {
+       clkc: clock-controller {
                compatible = "amlogic,gxbb-clkc";
                #clock-cells = <1>;
-               reg = <0x0 0x0 0x0 0x3db>;
        };
 };
 
@@ -716,6 +715,7 @@ &sd_emmc_a {
                 <&clkc CLKID_SD_EMMC_A_CLK0>,
                 <&clkc CLKID_FCLK_DIV2>;
        clock-names = "core", "clkin0", "clkin1";
+       resets = <&reset RESET_SD_EMMC_A>;
 };
 
 &sd_emmc_b {
@@ -723,6 +723,7 @@ &sd_emmc_b {
                 <&clkc CLKID_SD_EMMC_B_CLK0>,
                 <&clkc CLKID_FCLK_DIV2>;
        clock-names = "core", "clkin0", "clkin1";
+       resets = <&reset RESET_SD_EMMC_B>;
 };
 
 &sd_emmc_c {
@@ -730,6 +731,7 @@ &sd_emmc_c {
                 <&clkc CLKID_SD_EMMC_C_CLK0>,
                 <&clkc CLKID_FCLK_DIV2>;
        clock-names = "core", "clkin0", "clkin1";
+       resets = <&reset RESET_SD_EMMC_C>;
 };
 
 &spicc {
@@ -749,12 +751,12 @@ &uart_A {
 };
 
 &uart_AO {
-       clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+       clocks = <&xtal>, <&clkc_AO CLKID_AO_UART1>, <&xtal>;
        clock-names = "xtal", "pclk", "baud";
 };
 
 &uart_AO_B {
-       clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+       clocks = <&xtal>, <&clkc_AO CLKID_AO_UART2>, <&xtal>;
        clock-names = "xtal", "pclk", "baud";
 };
 
index dba365ed4bd5f903e34f4c6fdf1b14d539db0d89..27538eea547b19a0fe8c14a97de4aa303ba63978 100644 (file)
@@ -267,11 +267,10 @@ &hdmi_tx {
        clock-names = "isfr", "iahb", "venci";
 };
 
-&hiubus {
-       clkc: clock-controller@0 {
-               compatible = "amlogic,gxl-clkc", "amlogic,gxbb-clkc";
+&sysctrl {
+       clkc: clock-controller {
+               compatible = "amlogic,gxl-clkc";
                #clock-cells = <1>;
-               reg = <0x0 0x0 0x0 0x3db>;
        };
 };
 
@@ -725,13 +724,15 @@ &sd_emmc_a {
                 <&clkc CLKID_SD_EMMC_A_CLK0>,
                 <&clkc CLKID_FCLK_DIV2>;
        clock-names = "core", "clkin0", "clkin1";
+       resets = <&reset RESET_SD_EMMC_A>;
 };
 
 &sd_emmc_b {
        clocks = <&clkc CLKID_SD_EMMC_B>,
                 <&clkc CLKID_SD_EMMC_B_CLK0>,
                 <&clkc CLKID_FCLK_DIV2>;
-       clock-names = "core", "clkin0", "clkin1";
+       clock-names = "core", "clkin0", "clkin1";
+       resets = <&reset RESET_SD_EMMC_B>;
 };
 
 &sd_emmc_c {
@@ -739,6 +740,7 @@ &sd_emmc_c {
                 <&clkc CLKID_SD_EMMC_C_CLK0>,
                 <&clkc CLKID_FCLK_DIV2>;
        clock-names = "core", "clkin0", "clkin1";
+       resets = <&reset RESET_SD_EMMC_C>;
 };
 
 &spicc {
@@ -758,12 +760,12 @@ &uart_A {
 };
 
 &uart_AO {
-       clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+       clocks = <&xtal>, <&clkc_AO CLKID_AO_UART1>, <&xtal>;
        clock-names = "xtal", "pclk", "baud";
 };
 
 &uart_AO_B {
-       clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+       clocks = <&xtal>, <&clkc_AO CLKID_AO_UART2>, <&xtal>;
        clock-names = "xtal", "pclk", "baud";
 };
 
index eb749c50a73636bdb4375ee6f14d4191957d1cc9..ce56a4acda4fa07bb7eedebfeeb55f05f29c0c8d 100644 (file)
@@ -1,5 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 #include "juno-clocks.dtsi"
+#include "juno-motherboard.dtsi"
 
 / {
        /*
@@ -572,14 +573,14 @@ soc {
                        thermal-sensors = <&scpi_sensors0 3>;
                };
 
-               big_cluster_thermal_zone: big_cluster {
+               big_cluster_thermal_zone: big-cluster {
                        polling-delay = <1000>;
                        polling-delay-passive = <100>;
                        thermal-sensors = <&scpi_sensors0 21>;
                        status = "disabled";
                };
 
-               little_cluster_thermal_zone: little_cluster {
+               little_cluster_thermal_zone: little-cluster {
                        polling-delay = <1000>;
                        polling-delay-passive = <100>;
                        thermal-sensors = <&scpi_sensors0 22>;
@@ -677,7 +678,7 @@ hdlcd@7ff50000 {
                clock-names = "pxlclk";
 
                port {
-                       hdlcd1_output: hdlcd1-endpoint {
+                       hdlcd1_output: endpoint {
                                remote-endpoint = <&tda998x_1_input>;
                        };
                };
@@ -692,7 +693,7 @@ hdlcd@7ff60000 {
                clock-names = "pxlclk";
 
                port {
-                       hdlcd0_output: hdlcd0-endpoint {
+                       hdlcd0_output: endpoint {
                                remote-endpoint = <&tda998x_0_input>;
                        };
                };
@@ -720,7 +721,7 @@ hdmi-transmitter@70 {
                        compatible = "nxp,tda998x";
                        reg = <0x70>;
                        port {
-                               tda998x_0_input: tda998x-0-endpoint {
+                               tda998x_0_input: endpoint {
                                        remote-endpoint = <&hdlcd0_output>;
                                };
                        };
@@ -730,7 +731,7 @@ hdmi-transmitter@71 {
                        compatible = "nxp,tda998x";
                        reg = <0x71>;
                        port {
-                               tda998x_1_input: tda998x-1-endpoint {
+                               tda998x_1_input: endpoint {
                                        remote-endpoint = <&hdlcd1_output>;
                                };
                        };
@@ -795,8 +796,6 @@ smb@8000000 {
                                <0 0 10 &gic 0 0 0 167 IRQ_TYPE_LEVEL_HIGH>,
                                <0 0 11 &gic 0 0 0 168 IRQ_TYPE_LEVEL_HIGH>,
                                <0 0 12 &gic 0 0 0 169 IRQ_TYPE_LEVEL_HIGH>;
-
-               /include/ "juno-motherboard.dtsi"
        };
 
        site2: tlx@60000000 {
index 69804c5f1197caac2815199edde847a547a0ae03..1792b074e9a3275a6702f681e02f8c0b2538738e 100644 (file)
@@ -7,6 +7,8 @@
  *
  */
 
+/ {
+       smb@8000000 {
                mb_clk24mhz: clk24mhz {
                        compatible = "fixed-clock";
                        #clock-cells = <0>;
@@ -54,46 +56,46 @@ mb_fixed_3v3: mcc-sb-3v3 {
                                regulator-always-on;
                        };
 
-                       gpio_keys {
+                       gpio-keys {
                                compatible = "gpio-keys";
 
                                power-button {
-                                       debounce_interval = <50>;
+                                       debounce-interval = <50>;
                                        wakeup-source;
                                        linux,code = <116>;
                                        label = "POWER";
                                        gpios = <&iofpga_gpio0 0 0x4>;
                                };
                                home-button {
-                                       debounce_interval = <50>;
+                                       debounce-interval = <50>;
                                        wakeup-source;
                                        linux,code = <102>;
                                        label = "HOME";
                                        gpios = <&iofpga_gpio0 1 0x4>;
                                };
                                rlock-button {
-                                       debounce_interval = <50>;
+                                       debounce-interval = <50>;
                                        wakeup-source;
                                        linux,code = <152>;
                                        label = "RLOCK";
                                        gpios = <&iofpga_gpio0 2 0x4>;
                                };
                                vol-up-button {
-                                       debounce_interval = <50>;
+                                       debounce-interval = <50>;
                                        wakeup-source;
                                        linux,code = <115>;
                                        label = "VOL+";
                                        gpios = <&iofpga_gpio0 3 0x4>;
                                };
                                vol-down-button {
-                                       debounce_interval = <50>;
+                                       debounce-interval = <50>;
                                        wakeup-source;
                                        linux,code = <114>;
                                        label = "VOL-";
                                        gpios = <&iofpga_gpio0 4 0x4>;
                                };
                                nmi-button {
-                                       debounce_interval = <50>;
+                                       debounce-interval = <50>;
                                        wakeup-source;
                                        linux,code = <99>;
                                        label = "NMI";
@@ -287,3 +289,5 @@ iofpga_gpio0: gpio@1d0000 {
                                };
                        };
                };
+       };
+};
index aed6389468c4a1d386189265e2d7a0abe68f6b06..2c5db03f226c60b595dad62e136e32ca4d769702 100644 (file)
@@ -201,7 +201,7 @@ A53_L2: l2-cache1 {
                };
        };
 
-       pmu_a57 {
+       pmu-a57 {
                compatible = "arm,cortex-a57-pmu";
                interrupts = <GIC_SPI 02 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 06 IRQ_TYPE_LEVEL_HIGH>;
@@ -209,7 +209,7 @@ pmu_a57 {
                                     <&A57_1>;
        };
 
-       pmu_a53 {
+       pmu-a53 {
                compatible = "arm,cortex-a53-pmu";
                interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>,
@@ -278,6 +278,10 @@ &replicator_in_port0 {
        remote-endpoint = <&csys2_funnel_out_port>;
 };
 
+&csys1_funnel_in_port0 {
+       remote-endpoint = <&stm_out_port>;
+};
+
 &stm_out_port {
        remote-endpoint = <&csys1_funnel_in_port0>;
 };
index b39b6d6ec5aa1be93c88e7a988bdbae3cfd40a9b..c51950f4a1b66b4088331a8741edf38bfd6eec22 100644 (file)
@@ -201,7 +201,7 @@ A53_L2: l2-cache1 {
                };
        };
 
-       pmu_a72 {
+       pmu-a72 {
                compatible = "arm,cortex-a72-pmu";
                interrupts = <GIC_SPI 02 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 06 IRQ_TYPE_LEVEL_HIGH>;
@@ -209,7 +209,7 @@ pmu_a72 {
                                     <&A72_1>;
        };
 
-       pmu_a53 {
+       pmu-a53 {
                compatible = "arm,cortex-a53-pmu";
                interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>,
@@ -278,6 +278,10 @@ &replicator_in_port0 {
        remote-endpoint = <&csys2_funnel_out_port>;
 };
 
+&csys1_funnel_in_port0 {
+       remote-endpoint = <&stm_out_port>;
+};
+
 &stm_out_port {
        remote-endpoint = <&csys1_funnel_in_port0>;
 };
index c9236c4b967d2f461b91730e0b8f3f941b32d307..2b2bf39c30ef68c1347f01457bb0818516fe2d43 100644 (file)
@@ -200,7 +200,7 @@ A53_L2: l2-cache1 {
                };
        };
 
-       pmu_a57 {
+       pmu-a57 {
                compatible = "arm,cortex-a57-pmu";
                interrupts = <GIC_SPI 02 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 06 IRQ_TYPE_LEVEL_HIGH>;
@@ -208,7 +208,7 @@ pmu_a57 {
                                     <&A57_1>;
        };
 
-       pmu_a53 {
+       pmu-a53 {
                compatible = "arm,cortex-a53-pmu";
                interrupts = <GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 22 IRQ_TYPE_LEVEL_HIGH>,
index 06c8117e812ae1b85041800d1ea91f8bd326fb3d..602f63f72c37e66a41108768fbbeadfc6fda4596 100644 (file)
@@ -12,6 +12,8 @@
 
 /memreserve/ 0x80000000 0x00010000;
 
+#include "rtsm_ve-motherboard.dtsi"
+
 / {
        model = "RTSM_VE_AEMv8A";
        compatible = "arm,rtsm_ve,aemv8a", "arm,vexpress";
@@ -162,7 +164,5 @@ smb@8000000 {
                                <0 0 40 &gic 0 40 4>,
                                <0 0 41 &gic 0 41 4>,
                                <0 0 42 &gic 0 42 4>;
-
-               /include/ "rtsm_ve-motherboard.dtsi"
        };
 };
index 1134e5d8df181a4ae126a1973521f9807eed7e67..d2dbc3f39263f96d9f8dd065fb34de6d045ea98e 100644 (file)
  *
  * VEMotherBoard.lisa
  */
-
-       motherboard {
-               arm,v2m-memory-map = "rs1";
-               compatible = "arm,vexpress,v2m-p1", "simple-bus";
-               #address-cells = <2>; /* SMB chipselect number and offset */
-               #size-cells = <1>;
-               #interrupt-cells = <1>;
-               ranges;
-
-               flash@0,00000000 {
-                       compatible = "arm,vexpress-flash", "cfi-flash";
-                       reg = <0 0x00000000 0x04000000>,
-                             <4 0x00000000 0x04000000>;
-                       bank-width = <4>;
-               };
-
-               v2m_video_ram: vram@2,00000000 {
-                       compatible = "arm,vexpress-vram";
-                       reg = <2 0x00000000 0x00800000>;
-               };
-
-               ethernet@2,02000000 {
-                       compatible = "smsc,lan91c111";
-                       reg = <2 0x02000000 0x10000>;
-                       interrupts = <15>;
-               };
-
-               v2m_clk24mhz: clk24mhz {
-                       compatible = "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <24000000>;
-                       clock-output-names = "v2m:clk24mhz";
-               };
-
-               v2m_refclk1mhz: refclk1mhz {
-                       compatible = "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <1000000>;
-                       clock-output-names = "v2m:refclk1mhz";
-               };
-
-               v2m_refclk32khz: refclk32khz {
-                       compatible = "fixed-clock";
-                       #clock-cells = <0>;
-                       clock-frequency = <32768>;
-                       clock-output-names = "v2m:refclk32khz";
-               };
-
-               iofpga@3,00000000 {
-                       compatible = "simple-bus";
-                       #address-cells = <1>;
+/ {
+       smb@8000000 {
+               motherboard {
+                       arm,v2m-memory-map = "rs1";
+                       compatible = "arm,vexpress,v2m-p1", "simple-bus";
+                       #address-cells = <2>; /* SMB chipselect number and offset */
                        #size-cells = <1>;
-                       ranges = <0 3 0 0x200000>;
-
-                       v2m_sysreg: sysreg@10000 {
-                               compatible = "arm,vexpress-sysreg";
-                               reg = <0x010000 0x1000>;
-                               gpio-controller;
-                               #gpio-cells = <2>;
+                       #interrupt-cells = <1>;
+                       ranges;
+
+                       flash@0,00000000 {
+                               compatible = "arm,vexpress-flash", "cfi-flash";
+                               reg = <0 0x00000000 0x04000000>,
+                                     <4 0x00000000 0x04000000>;
+                               bank-width = <4>;
                        };
 
-                       v2m_sysctl: sysctl@20000 {
-                               compatible = "arm,sp810", "arm,primecell";
-                               reg = <0x020000 0x1000>;
-                               clocks = <&v2m_refclk32khz>, <&v2m_refclk1mhz>, <&v2m_clk24mhz>;
-                               clock-names = "refclk", "timclk", "apb_pclk";
-                               #clock-cells = <1>;
-                               clock-output-names = "timerclken0", "timerclken1", "timerclken2", "timerclken3";
-                               assigned-clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&v2m_sysctl 3>, <&v2m_sysctl 3>;
-                               assigned-clock-parents = <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>;
+                       v2m_video_ram: vram@2,00000000 {
+                               compatible = "arm,vexpress-vram";
+                               reg = <2 0x00000000 0x00800000>;
                        };
 
-                       aaci@40000 {
-                               compatible = "arm,pl041", "arm,primecell";
-                               reg = <0x040000 0x1000>;
-                               interrupts = <11>;
-                               clocks = <&v2m_clk24mhz>;
-                               clock-names = "apb_pclk";
+                       ethernet@2,02000000 {
+                               compatible = "smsc,lan91c111";
+                               reg = <2 0x02000000 0x10000>;
+                               interrupts = <15>;
                        };
 
-                       mmci@50000 {
-                               compatible = "arm,pl180", "arm,primecell";
-                               reg = <0x050000 0x1000>;
-                               interrupts = <9 10>;
-                               cd-gpios = <&v2m_sysreg 0 0>;
-                               wp-gpios = <&v2m_sysreg 1 0>;
-                               max-frequency = <12000000>;
-                               vmmc-supply = <&v2m_fixed_3v3>;
-                               clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
-                               clock-names = "mclk", "apb_pclk";
+                       v2m_clk24mhz: clk24mhz {
+                               compatible = "fixed-clock";
+                               #clock-cells = <0>;
+                               clock-frequency = <24000000>;
+                               clock-output-names = "v2m:clk24mhz";
                        };
 
-                       kmi@60000 {
-                               compatible = "arm,pl050", "arm,primecell";
-                               reg = <0x060000 0x1000>;
-                               interrupts = <12>;
-                               clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
-                               clock-names = "KMIREFCLK", "apb_pclk";
+                       v2m_refclk1mhz: refclk1mhz {
+                               compatible = "fixed-clock";
+                               #clock-cells = <0>;
+                               clock-frequency = <1000000>;
+                               clock-output-names = "v2m:refclk1mhz";
                        };
 
-                       kmi@70000 {
-                               compatible = "arm,pl050", "arm,primecell";
-                               reg = <0x070000 0x1000>;
-                               interrupts = <13>;
-                               clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
-                               clock-names = "KMIREFCLK", "apb_pclk";
+                       v2m_refclk32khz: refclk32khz {
+                               compatible = "fixed-clock";
+                               #clock-cells = <0>;
+                               clock-frequency = <32768>;
+                               clock-output-names = "v2m:refclk32khz";
                        };
 
-                       v2m_serial0: uart@90000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x090000 0x1000>;
-                               interrupts = <5>;
-                               clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                       iofpga@3,00000000 {
+                               compatible = "simple-bus";
+                               #address-cells = <1>;
+                               #size-cells = <1>;
+                               ranges = <0 3 0 0x200000>;
+
+                               v2m_sysreg: sysreg@10000 {
+                                       compatible = "arm,vexpress-sysreg";
+                                       reg = <0x010000 0x1000>;
+                                       gpio-controller;
+                                       #gpio-cells = <2>;
+                               };
 
-                       v2m_serial1: uart@a0000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x0a0000 0x1000>;
-                               interrupts = <6>;
-                               clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               v2m_sysctl: sysctl@20000 {
+                                       compatible = "arm,sp810", "arm,primecell";
+                                       reg = <0x020000 0x1000>;
+                                       clocks = <&v2m_refclk32khz>, <&v2m_refclk1mhz>, <&v2m_clk24mhz>;
+                                       clock-names = "refclk", "timclk", "apb_pclk";
+                                       #clock-cells = <1>;
+                                       clock-output-names = "timerclken0", "timerclken1", "timerclken2", "timerclken3";
+                                       assigned-clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&v2m_sysctl 3>, <&v2m_sysctl 3>;
+                                       assigned-clock-parents = <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>, <&v2m_refclk1mhz>;
+                               };
 
-                       v2m_serial2: uart@b0000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x0b0000 0x1000>;
-                               interrupts = <7>;
-                               clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               aaci@40000 {
+                                       compatible = "arm,pl041", "arm,primecell";
+                                       reg = <0x040000 0x1000>;
+                                       interrupts = <11>;
+                                       clocks = <&v2m_clk24mhz>;
+                                       clock-names = "apb_pclk";
+                               };
 
-                       v2m_serial3: uart@c0000 {
-                               compatible = "arm,pl011", "arm,primecell";
-                               reg = <0x0c0000 0x1000>;
-                               interrupts = <8>;
-                               clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
-                               clock-names = "uartclk", "apb_pclk";
-                       };
+                               mmci@50000 {
+                                       compatible = "arm,pl180", "arm,primecell";
+                                       reg = <0x050000 0x1000>;
+                                       interrupts = <9 10>;
+                                       cd-gpios = <&v2m_sysreg 0 0>;
+                                       wp-gpios = <&v2m_sysreg 1 0>;
+                                       max-frequency = <12000000>;
+                                       vmmc-supply = <&v2m_fixed_3v3>;
+                                       clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
+                                       clock-names = "mclk", "apb_pclk";
+                               };
 
-                       wdt@f0000 {
-                               compatible = "arm,sp805", "arm,primecell";
-                               reg = <0x0f0000 0x1000>;
-                               interrupts = <0>;
-                               clocks = <&v2m_refclk32khz>, <&v2m_clk24mhz>;
-                               clock-names = "wdogclk", "apb_pclk";
-                       };
+                               kmi@60000 {
+                                       compatible = "arm,pl050", "arm,primecell";
+                                       reg = <0x060000 0x1000>;
+                                       interrupts = <12>;
+                                       clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
+                                       clock-names = "KMIREFCLK", "apb_pclk";
+                               };
 
-                       v2m_timer01: timer@110000 {
-                               compatible = "arm,sp804", "arm,primecell";
-                               reg = <0x110000 0x1000>;
-                               interrupts = <2>;
-                               clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&v2m_clk24mhz>;
-                               clock-names = "timclken1", "timclken2", "apb_pclk";
-                       };
+                               kmi@70000 {
+                                       compatible = "arm,pl050", "arm,primecell";
+                                       reg = <0x070000 0x1000>;
+                                       interrupts = <13>;
+                                       clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
+                                       clock-names = "KMIREFCLK", "apb_pclk";
+                               };
 
-                       v2m_timer23: timer@120000 {
-                               compatible = "arm,sp804", "arm,primecell";
-                               reg = <0x120000 0x1000>;
-                               interrupts = <3>;
-                               clocks = <&v2m_sysctl 2>, <&v2m_sysctl 3>, <&v2m_clk24mhz>;
-                               clock-names = "timclken1", "timclken2", "apb_pclk";
-                       };
+                               v2m_serial0: uart@90000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x090000 0x1000>;
+                                       interrupts = <5>;
+                                       clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       rtc@170000 {
-                               compatible = "arm,pl031", "arm,primecell";
-                               reg = <0x170000 0x1000>;
-                               interrupts = <4>;
-                               clocks = <&v2m_clk24mhz>;
-                               clock-names = "apb_pclk";
-                       };
+                               v2m_serial1: uart@a0000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x0a0000 0x1000>;
+                                       interrupts = <6>;
+                                       clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
 
-                       clcd@1f0000 {
-                               compatible = "arm,pl111", "arm,primecell";
-                               reg = <0x1f0000 0x1000>;
-                               interrupt-names = "combined";
-                               interrupts = <14>;
-                               clocks = <&v2m_oscclk1>, <&v2m_clk24mhz>;
-                               clock-names = "clcdclk", "apb_pclk";
-                               arm,pl11x,framebuffer = <0x18000000 0x00180000>;
-                               memory-region = <&v2m_video_ram>;
-                               max-memory-bandwidth = <130000000>; /* 16bpp @ 63.5MHz */
-
-                               port {
-                                       v2m_clcd_pads: endpoint {
-                                               remote-endpoint = <&v2m_clcd_panel>;
-                                               arm,pl11x,tft-r0g0b0-pads = <0 8 16>;
-                                       };
+                               v2m_serial2: uart@b0000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x0b0000 0x1000>;
+                                       interrupts = <7>;
+                                       clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
+                                       clock-names = "uartclk", "apb_pclk";
                                };
 
-                               panel {
-                                       compatible = "panel-dpi";
+                               v2m_serial3: uart@c0000 {
+                                       compatible = "arm,pl011", "arm,primecell";
+                                       reg = <0x0c0000 0x1000>;
+                                       interrupts = <8>;
+                                       clocks = <&v2m_clk24mhz>, <&v2m_clk24mhz>;
+                                       clock-names = "uartclk", "apb_pclk";
+                               };
+
+                               wdt@f0000 {
+                                       compatible = "arm,sp805", "arm,primecell";
+                                       reg = <0x0f0000 0x1000>;
+                                       interrupts = <0>;
+                                       clocks = <&v2m_refclk32khz>, <&v2m_clk24mhz>;
+                                       clock-names = "wdogclk", "apb_pclk";
+                               };
+
+                               v2m_timer01: timer@110000 {
+                                       compatible = "arm,sp804", "arm,primecell";
+                                       reg = <0x110000 0x1000>;
+                                       interrupts = <2>;
+                                       clocks = <&v2m_sysctl 0>, <&v2m_sysctl 1>, <&v2m_clk24mhz>;
+                                       clock-names = "timclken1", "timclken2", "apb_pclk";
+                               };
+
+                               v2m_timer23: timer@120000 {
+                                       compatible = "arm,sp804", "arm,primecell";
+                                       reg = <0x120000 0x1000>;
+                                       interrupts = <3>;
+                                       clocks = <&v2m_sysctl 2>, <&v2m_sysctl 3>, <&v2m_clk24mhz>;
+                                       clock-names = "timclken1", "timclken2", "apb_pclk";
+                               };
+
+                               rtc@170000 {
+                                       compatible = "arm,pl031", "arm,primecell";
+                                       reg = <0x170000 0x1000>;
+                                       interrupts = <4>;
+                                       clocks = <&v2m_clk24mhz>;
+                                       clock-names = "apb_pclk";
+                               };
+
+                               clcd@1f0000 {
+                                       compatible = "arm,pl111", "arm,primecell";
+                                       reg = <0x1f0000 0x1000>;
+                                       interrupt-names = "combined";
+                                       interrupts = <14>;
+                                       clocks = <&v2m_oscclk1>, <&v2m_clk24mhz>;
+                                       clock-names = "clcdclk", "apb_pclk";
+                                       arm,pl11x,framebuffer = <0x18000000 0x00180000>;
+                                       memory-region = <&v2m_video_ram>;
+                                       max-memory-bandwidth = <130000000>; /* 16bpp @ 63.5MHz */
 
                                        port {
-                                               v2m_clcd_panel: endpoint {
-                                                       remote-endpoint = <&v2m_clcd_pads>;
+                                               v2m_clcd_pads: endpoint {
+                                                       remote-endpoint = <&v2m_clcd_panel>;
+                                                       arm,pl11x,tft-r0g0b0-pads = <0 8 16>;
                                                };
                                        };
 
-                                       panel-timing {
-                                               clock-frequency = <63500127>;
-                                               hactive = <1024>;
-                                               hback-porch = <152>;
-                                               hfront-porch = <48>;
-                                               hsync-len = <104>;
-                                               vactive = <768>;
-                                               vback-porch = <23>;
-                                               vfront-porch = <3>;
-                                               vsync-len = <4>;
+                                       panel {
+                                               compatible = "panel-dpi";
+
+                                               port {
+                                                       v2m_clcd_panel: endpoint {
+                                                               remote-endpoint = <&v2m_clcd_pads>;
+                                                       };
+                                               };
+
+                                               panel-timing {
+                                                       clock-frequency = <63500127>;
+                                                       hactive = <1024>;
+                                                       hback-porch = <152>;
+                                                       hfront-porch = <48>;
+                                                       hsync-len = <104>;
+                                                       vactive = <768>;
+                                                       vback-porch = <23>;
+                                                       vfront-porch = <3>;
+                                                       vsync-len = <4>;
+                                               };
                                        };
                                };
-                       };
 
-                       virtio-block@130000 {
-                               compatible = "virtio,mmio";
-                               reg = <0x130000 0x200>;
-                               interrupts = <42>;
+                               virtio-block@130000 {
+                                       compatible = "virtio,mmio";
+                                       reg = <0x130000 0x200>;
+                                       interrupts = <42>;
+                               };
                        };
-               };
-
-               v2m_fixed_3v3: v2m-3v3 {
-                       compatible = "regulator-fixed";
-                       regulator-name = "3V3";
-                       regulator-min-microvolt = <3300000>;
-                       regulator-max-microvolt = <3300000>;
-                       regulator-always-on;
-               };
-
-               mcc {
-                       compatible = "arm,vexpress,config-bus";
-                       arm,vexpress,config-bridge = <&v2m_sysreg>;
 
-                       v2m_oscclk1: oscclk1 {
-                               /* CLCD clock */
-                               compatible = "arm,vexpress-osc";
-                               arm,vexpress-sysreg,func = <1 1>;
-                               freq-range = <23750000 63500000>;
-                               #clock-cells = <0>;
-                               clock-output-names = "v2m:oscclk1";
+                       v2m_fixed_3v3: v2m-3v3 {
+                               compatible = "regulator-fixed";
+                               regulator-name = "3V3";
+                               regulator-min-microvolt = <3300000>;
+                               regulator-max-microvolt = <3300000>;
+                               regulator-always-on;
                        };
 
-                       reset {
-                               compatible = "arm,vexpress-reset";
-                               arm,vexpress-sysreg,func = <5 0>;
-                       };
+                       mcc {
+                               compatible = "arm,vexpress,config-bus";
+                               arm,vexpress,config-bridge = <&v2m_sysreg>;
+
+                               v2m_oscclk1: oscclk1 {
+                                       /* CLCD clock */
+                                       compatible = "arm,vexpress-osc";
+                                       arm,vexpress-sysreg,func = <1 1>;
+                                       freq-range = <23750000 63500000>;
+                                       #clock-cells = <0>;
+                                       clock-output-names = "v2m:oscclk1";
+                               };
 
-                       muxfpga {
-                               compatible = "arm,vexpress-muxfpga";
-                               arm,vexpress-sysreg,func = <7 0>;
-                       };
+                               reset {
+                                       compatible = "arm,vexpress-reset";
+                                       arm,vexpress-sysreg,func = <5 0>;
+                               };
 
-                       shutdown {
-                               compatible = "arm,vexpress-shutdown";
-                               arm,vexpress-sysreg,func = <8 0>;
-                       };
+                               muxfpga {
+                                       compatible = "arm,vexpress-muxfpga";
+                                       arm,vexpress-sysreg,func = <7 0>;
+                               };
 
-                       reboot {
-                               compatible = "arm,vexpress-reboot";
-                               arm,vexpress-sysreg,func = <9 0>;
-                       };
+                               shutdown {
+                                       compatible = "arm,vexpress-shutdown";
+                                       arm,vexpress-sysreg,func = <8 0>;
+                               };
+
+                               reboot {
+                                       compatible = "arm,vexpress-reboot";
+                                       arm,vexpress-sysreg,func = <9 0>;
+                               };
 
-                       dvimode {
-                               compatible = "arm,vexpress-dvimode";
-                               arm,vexpress-sysreg,func = <11 0>;
+                               dvimode {
+                                       compatible = "arm,vexpress-dvimode";
+                                       arm,vexpress-sysreg,func = <11 0>;
+                               };
                        };
                };
        };
+};
index 1c9eadc2d71e460c35317eddc7ce891abe37b01e..38880380e0facf2067b9daf5587c21366edcdc45 100644 (file)
@@ -13,6 +13,7 @@
 /dts-v1/;
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include "vexpress-v2m-rs1.dtsi"
 
 / {
        model = "V2F-1XV7 Cortex-A53x2 SMM";
@@ -129,7 +130,7 @@ temp-fpga {
                };
        };
 
-       smb@8000000 {
+       smb: smb@8000000 {
                compatible = "simple-bus";
 
                #address-cells = <2>;
@@ -186,7 +187,5 @@ smb@8000000 {
                                <0 0 40 &gic GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
                                <0 0 41 &gic GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
                                <0 0 42 &gic GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>;
-
-               /include/ "vexpress-v2m-rs1.dtsi"
        };
 };
index 2a2591ef1feedb183573fb1753603293db9da622..1193a9e34bbb16aaea9cf0e684dc7601af45a10a 100644 (file)
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
-dtb-$(CONFIG_ARCH_BCM2835) += bcm2837-rpi-3-b.dtb
+dtb-$(CONFIG_ARCH_BCM2835) += bcm2837-rpi-3-b.dtb \
+                             bcm2837-rpi-3-b-plus.dtb
 
 subdir-y       += northstar2
 subdir-y       += stingray
diff --git a/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b-plus.dts b/arch/arm64/boot/dts/broadcom/bcm2837-rpi-3-b-plus.dts
new file mode 100644 (file)
index 0000000..46ad202
--- /dev/null
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0
+#include "arm/bcm2837-rpi-3-b-plus.dts"
index 1ad8677f6a0a622c66f842ef16478091ee22ee73..038c99792ccb33f94fa2191687102946e3ebe265 100644 (file)
@@ -18,8 +18,8 @@
 
 / {
        compatible = "samsung,exynos5433";
-       #address-cells = <2>;
-       #size-cells = <2>;
+       #address-cells = <1>;
+       #size-cells = <1>;
 
        interrupt-parent = <&gic>;
 
@@ -231,18 +231,11 @@ psci {
                cpu_on = <0xC4000003>;
        };
 
-       reboot: syscon-reboot {
-               compatible = "syscon-reboot";
-               regmap = <&pmu_system_controller>;
-               offset = <0x400>; /* SWRESET */
-               mask = <0x1>;
-       };
-
        soc: soc {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
-               ranges = <0x0 0x0 0x0 0x18000000>;
+               ranges;
 
                arm_a53_pmu {
                        compatible = "arm,cortex-a53-pmu", "arm,armv8-pmuv3";
@@ -799,6 +792,13 @@ pmu_system_controller: system-controller@105c0000 {
                        #clock-cells = <1>;
                        clock-names = "clkout16";
                        clocks = <&xxti>;
+
+                       reboot: syscon-reboot {
+                               compatible = "syscon-reboot";
+                               regmap = <&pmu_system_controller>;
+                               offset = <0x400>; /* SWRESET */
+                               mask = <0x1>;
+                       };
                };
 
                gic: interrupt-controller@11001000 {
@@ -829,11 +829,16 @@ decon: decon@13800000 {
                                <&cmu_disp CLK_ACLK_SMMU_DECON0X>,
                                <&cmu_disp CLK_ACLK_XIU_DECON0X>,
                                <&cmu_disp CLK_PCLK_SMMU_DECON0X>,
+                               <&cmu_disp CLK_ACLK_SMMU_DECON1X>,
+                               <&cmu_disp CLK_ACLK_XIU_DECON1X>,
+                               <&cmu_disp CLK_PCLK_SMMU_DECON1X>,
                                <&cmu_disp CLK_SCLK_DECON_VCLK>,
                                <&cmu_disp CLK_SCLK_DECON_ECLK>;
                        clock-names = "pclk", "aclk_decon", "aclk_smmu_decon0x",
                                "aclk_xiu_decon0x", "pclk_smmu_decon0x",
-                               "sclk_decon_vclk", "sclk_decon_eclk";
+                               "aclk_smmu_decon1x", "aclk_xiu_decon1x",
+                               "pclk_smmu_decon1x", "sclk_decon_vclk",
+                               "sclk_decon_eclk";
                        power-domains = <&pd_disp>;
                        interrupt-names = "fifo", "vsync", "lcd_sys";
                        interrupts = <GIC_SPI 201 IRQ_TYPE_LEVEL_HIGH>,
@@ -866,11 +871,16 @@ decon_tv: decon@13880000 {
                                 <&cmu_disp CLK_ACLK_SMMU_TV0X>,
                                 <&cmu_disp CLK_ACLK_XIU_TV0X>,
                                 <&cmu_disp CLK_PCLK_SMMU_TV0X>,
+                                <&cmu_disp CLK_ACLK_SMMU_TV1X>,
+                                <&cmu_disp CLK_ACLK_XIU_TV1X>,
+                                <&cmu_disp CLK_PCLK_SMMU_TV1X>,
                                 <&cmu_disp CLK_SCLK_DECON_TV_VCLK>,
                                 <&cmu_disp CLK_SCLK_DECON_TV_ECLK>;
                        clock-names = "pclk", "aclk_decon", "aclk_smmu_decon0x",
                                      "aclk_xiu_decon0x", "pclk_smmu_decon0x",
-                                     "sclk_decon_vclk", "sclk_decon_eclk";
+                                     "aclk_smmu_decon1x", "aclk_xiu_decon1x",
+                                     "pclk_smmu_decon1x", "sclk_decon_vclk",
+                                     "sclk_decon_eclk";
                        samsung,disp-sysreg = <&syscon_disp>;
                        power-domains = <&pd_disp>;
                        interrupt-names = "fifo", "vsync", "lcd_sys";
@@ -1034,6 +1044,30 @@ gsc_2: video-scaler@13c20000 {
                        power-domains = <&pd_gscl>;
                };
 
+               scaler_0: scaler@15000000 {
+                       compatible = "samsung,exynos5433-scaler";
+                       reg = <0x15000000 0x1294>;
+                       interrupts = <0 402 IRQ_TYPE_LEVEL_HIGH>;
+                       clock-names = "pclk", "aclk", "aclk_xiu";
+                       clocks = <&cmu_mscl CLK_PCLK_M2MSCALER0>,
+                                <&cmu_mscl CLK_ACLK_M2MSCALER0>,
+                                <&cmu_mscl CLK_ACLK_XIU_MSCLX>;
+                       iommus = <&sysmmu_scaler_0>;
+                       power-domains = <&pd_mscl>;
+               };
+
+               scaler_1: scaler@15010000 {
+                       compatible = "samsung,exynos5433-scaler";
+                       reg = <0x15010000 0x1294>;
+                       interrupts = <0 403 IRQ_TYPE_LEVEL_HIGH>;
+                       clock-names = "pclk", "aclk", "aclk_xiu";
+                       clocks = <&cmu_mscl CLK_PCLK_M2MSCALER1>,
+                                <&cmu_mscl CLK_ACLK_M2MSCALER1>,
+                                <&cmu_mscl CLK_ACLK_XIU_MSCLX>;
+                       iommus = <&sysmmu_scaler_1>;
+                       power-domains = <&pd_mscl>;
+               };
+
                jpeg: codec@15020000 {
                        compatible = "samsung,exynos5433-jpeg";
                        reg = <0x15020000 0x10000>;
@@ -1137,6 +1171,28 @@ sysmmu_gscl2: sysmmu@13ca0000 {
                        power-domains = <&pd_gscl>;
                };
 
+               sysmmu_scaler_0: sysmmu@0x15040000 {
+                       compatible = "samsung,exynos-sysmmu";
+                       reg = <0x15040000 0x1000>;
+                       interrupts = <GIC_SPI 404 IRQ_TYPE_LEVEL_HIGH>;
+                       clock-names = "pclk", "aclk";
+                       clocks = <&cmu_mscl CLK_PCLK_SMMU_M2MSCALER0>,
+                                <&cmu_mscl CLK_ACLK_SMMU_M2MSCALER0>;
+                       #iommu-cells = <0>;
+                       power-domains = <&pd_mscl>;
+               };
+
+               sysmmu_scaler_1: sysmmu@0x15050000 {
+                       compatible = "samsung,exynos-sysmmu";
+                       reg = <0x15050000 0x1000>;
+                       interrupts = <GIC_SPI 406 IRQ_TYPE_LEVEL_HIGH>;
+                       clock-names = "pclk", "aclk";
+                       clocks = <&cmu_mscl CLK_PCLK_SMMU_M2MSCALER1>,
+                                <&cmu_mscl CLK_ACLK_SMMU_M2MSCALER1>;
+                       #iommu-cells = <0>;
+                       power-domains = <&pd_mscl>;
+               };
+
                sysmmu_jpeg: sysmmu@15060000 {
                        compatible = "samsung,exynos-sysmmu";
                        reg = <0x15060000 0x1000>;
index ad9dce6894ce816799481c5abc30a517cd9cc4ef..93a84338938a65cc1a594f3de37fa3bcfe48b9e5 100644 (file)
@@ -12,8 +12,8 @@
 / {
        compatible = "samsung,exynos7";
        interrupt-parent = <&gic>;
-       #address-cells = <2>;
-       #size-cells = <2>;
+       #address-cells = <1>;
+       #size-cells = <1>;
 
        aliases {
                pinctrl0 = &pinctrl_alive;
@@ -70,7 +70,7 @@ soc: soc {
                compatible = "simple-bus";
                #address-cells = <1>;
                #size-cells = <1>;
-               ranges = <0 0 0 0x18000000>;
+               ranges;
 
                chipid@10000000 {
                        compatible = "samsung,exynos4210-chipid";
@@ -494,13 +494,13 @@ timer {
                pmu_system_controller: system-controller@105c0000 {
                        compatible = "samsung,exynos7-pmu", "syscon";
                        reg = <0x105c0000 0x5000>;
-               };
 
-               reboot: syscon-reboot {
-                       compatible = "syscon-reboot";
-                       regmap = <&pmu_system_controller>;
-                       offset = <0x0400>;
-                       mask = <0x1>;
+                       reboot: syscon-reboot {
+                               compatible = "syscon-reboot";
+                               regmap = <&pmu_system_controller>;
+                               offset = <0x0400>;
+                               mask = <0x1>;
+                       };
                };
 
                rtc: rtc@10590000 {
index bb788eddf9f4e8cc0493c62279745f6475ec6250..205f0f4c5df0a5b6b9fe1480d97be09930f38e00 100644 (file)
@@ -53,11 +53,11 @@ / {
 
        aliases {
                crypto = &crypto;
-               rtic_a = &rtic_a;
-               rtic_b = &rtic_b;
-               rtic_c = &rtic_c;
-               rtic_d = &rtic_d;
-               sec_mon = &sec_mon;
+               rtic-a = &rtic_a;
+               rtic-b = &rtic_b;
+               rtic-c = &rtic_c;
+               rtic-d = &rtic_d;
+               sec-mon = &sec_mon;
        };
 
        cpus {
index 5498c705ae6a476ed04d9b4fd2a71f4be9dff8aa..061647bd97b8a6246d94b41d0c64027769036a02 100644 (file)
@@ -134,7 +134,7 @@ &i2c3 {
 
 &dspi {
        status = "okay";
-       dflash0: n25q512a {
+       dflash0: n25q512a@0 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "st,m25p80";
index ec3eb8e33a3a528e1a78d2138762acf4aaec3cd2..8d477dcbfa5822c4b037cee7e187bd27ee045f04 100644 (file)
@@ -7,6 +7,7 @@
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/clock/hi3660-clock.h>
+#include <dt-bindings/thermal/thermal.h>
 
 / {
        compatible = "hisilicon,hi3660";
@@ -62,6 +63,10 @@ cpu0: cpu@0 {
                        next-level-cache = <&A53_L2>;
                        cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP_0>;
                        capacity-dmips-mhz = <592>;
+                       clocks = <&stub_clock HI3660_CLK_STUB_CLUSTER0>;
+                       operating-points-v2 = <&cluster0_opp>;
+                       #cooling-cells = <2>;
+                       dynamic-power-coefficient = <110>;
                };
 
                cpu1: cpu@1 {
@@ -72,6 +77,8 @@ cpu1: cpu@1 {
                        next-level-cache = <&A53_L2>;
                        cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP_0>;
                        capacity-dmips-mhz = <592>;
+                       clocks = <&stub_clock HI3660_CLK_STUB_CLUSTER0>;
+                       operating-points-v2 = <&cluster0_opp>;
                };
 
                cpu2: cpu@2 {
@@ -82,6 +89,8 @@ cpu2: cpu@2 {
                        next-level-cache = <&A53_L2>;
                        cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP_0>;
                        capacity-dmips-mhz = <592>;
+                       clocks = <&stub_clock HI3660_CLK_STUB_CLUSTER0>;
+                       operating-points-v2 = <&cluster0_opp>;
                };
 
                cpu3: cpu@3 {
@@ -92,6 +101,8 @@ cpu3: cpu@3 {
                        next-level-cache = <&A53_L2>;
                        cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP_0>;
                        capacity-dmips-mhz = <592>;
+                       clocks = <&stub_clock HI3660_CLK_STUB_CLUSTER0>;
+                       operating-points-v2 = <&cluster0_opp>;
                };
 
                cpu4: cpu@100 {
@@ -102,6 +113,10 @@ cpu4: cpu@100 {
                        next-level-cache = <&A73_L2>;
                        cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP_1>;
                        capacity-dmips-mhz = <1024>;
+                       clocks = <&stub_clock HI3660_CLK_STUB_CLUSTER1>;
+                       operating-points-v2 = <&cluster1_opp>;
+                       #cooling-cells = <2>;
+                       dynamic-power-coefficient = <550>;
                };
 
                cpu5: cpu@101 {
@@ -112,6 +127,8 @@ cpu5: cpu@101 {
                        next-level-cache = <&A73_L2>;
                        cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP_1>;
                        capacity-dmips-mhz = <1024>;
+                       clocks = <&stub_clock HI3660_CLK_STUB_CLUSTER1>;
+                       operating-points-v2 = <&cluster1_opp>;
                };
 
                cpu6: cpu@102 {
@@ -122,6 +139,8 @@ cpu6: cpu@102 {
                        next-level-cache = <&A73_L2>;
                        cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP_1>;
                        capacity-dmips-mhz = <1024>;
+                       clocks = <&stub_clock HI3660_CLK_STUB_CLUSTER1>;
+                       operating-points-v2 = <&cluster1_opp>;
                };
 
                cpu7: cpu@103 {
@@ -132,6 +151,8 @@ cpu7: cpu@103 {
                        next-level-cache = <&A73_L2>;
                        cpu-idle-states = <&CPU_SLEEP &CLUSTER_SLEEP_1>;
                        capacity-dmips-mhz = <1024>;
+                       clocks = <&stub_clock HI3660_CLK_STUB_CLUSTER1>;
+                       operating-points-v2 = <&cluster1_opp>;
                };
 
                idle-states {
@@ -174,6 +195,76 @@ A73_L2: l2-cache1 {
                };
        };
 
+       cluster0_opp: opp_table0 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp00 {
+                       opp-hz = /bits/ 64 <533000000>;
+                       opp-microvolt = <700000>;
+                       clock-latency-ns = <300000>;
+               };
+
+               opp01 {
+                       opp-hz = /bits/ 64 <999000000>;
+                       opp-microvolt = <800000>;
+                       clock-latency-ns = <300000>;
+               };
+
+               opp02 {
+                       opp-hz = /bits/ 64 <1402000000>;
+                       opp-microvolt = <900000>;
+                       clock-latency-ns = <300000>;
+               };
+
+               opp03 {
+                       opp-hz = /bits/ 64 <1709000000>;
+                       opp-microvolt = <1000000>;
+                       clock-latency-ns = <300000>;
+               };
+
+               opp04 {
+                       opp-hz = /bits/ 64 <1844000000>;
+                       opp-microvolt = <1100000>;
+                       clock-latency-ns = <300000>;
+               };
+       };
+
+       cluster1_opp: opp_table1 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp10 {
+                       opp-hz = /bits/ 64 <903000000>;
+                       opp-microvolt = <700000>;
+                       clock-latency-ns = <300000>;
+               };
+
+               opp11 {
+                       opp-hz = /bits/ 64 <1421000000>;
+                       opp-microvolt = <800000>;
+                       clock-latency-ns = <300000>;
+               };
+
+               opp12 {
+                       opp-hz = /bits/ 64 <1805000000>;
+                       opp-microvolt = <900000>;
+                       clock-latency-ns = <300000>;
+               };
+
+               opp13 {
+                       opp-hz = /bits/ 64 <2112000000>;
+                       opp-microvolt = <1000000>;
+                       clock-latency-ns = <300000>;
+               };
+
+               opp14 {
+                       opp-hz = /bits/ 64 <2362000000>;
+                       opp-microvolt = <1100000>;
+                       clock-latency-ns = <300000>;
+               };
+       };
+
        gic: interrupt-controller@e82b0000 {
                compatible = "arm,gic-400";
                reg = <0x0 0xe82b1000 0 0x1000>, /* GICD */
@@ -274,6 +365,21 @@ iomcu_rst: reset {
                        #reset-cells = <2>;
                };
 
+               mailbox: mailbox@e896b000 {
+                       compatible = "hisilicon,hi3660-mbox";
+                       reg = <0x0 0xe896b000 0x0 0x1000>;
+                       interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
+                       #mbox-cells = <3>;
+               };
+
+               stub_clock: stub_clock@e896b500 {
+                       compatible = "hisilicon,hi3660-stub-clk";
+                       reg = <0x0 0xe896b500 0x0 0x0100>;
+                       #clock-cells = <1>;
+                       mboxes = <&mailbox 13 3 0>;
+               };
+
                dual_timer0: timer@fff14000 {
                        compatible = "arm,sp804", "arm,primecell";
                        reg = <0x0 0xfff14000 0x0 0x1000>;
@@ -872,6 +978,8 @@ pcie@f4000000 {
                                  0x0 0x02000000>;
                        num-lanes = <1>;
                        #interrupt-cells = <1>;
+                       interrupts = <0 283 4>;
+                       interrupt-names = "msi";
                        interrupt-map-mask = <0xf800 0 0 7>;
                        interrupt-map = <0x0 0 0 1
                                         &gic GIC_SPI 282 IRQ_TYPE_LEVEL_HIGH>,
@@ -972,5 +1080,44 @@ tsensor: tsensor@fff30000 {
                        interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
                        #thermal-sensor-cells = <1>;
                };
+
+               thermal-zones {
+
+                       cls0: cls0 {
+                               polling-delay = <1000>;
+                               polling-delay-passive = <100>;
+                               sustainable-power = <4500>;
+
+                               /* sensor ID */
+                               thermal-sensors = <&tsensor 1>;
+
+                               trips {
+                                       threshold: trip-point@0 {
+                                               temperature = <65000>;
+                                               hysteresis = <1000>;
+                                               type = "passive";
+                                       };
+
+                                       target: trip-point@1 {
+                                               temperature = <75000>;
+                                               hysteresis = <1000>;
+                                               type = "passive";
+                                       };
+                               };
+
+                               cooling-maps {
+                                       map0 {
+                                               trip = <&target>;
+                                               contribution = <1024>;
+                                               cooling-device = <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+                                       };
+                                       map1 {
+                                               trip = <&target>;
+                                               contribution = <512>;
+                                               cooling-device = <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>;
+                                       };
+                               };
+                       };
+               };
        };
 };
index 4d5d644abb126a9c4bc7e602b04ae82d80c050c0..d30f6eb8a5ee2f67fd3708f072224607f87d32fa 100644 (file)
@@ -11,6 +11,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include "hi3798cv200.dtsi"
+#include "poplar-pinctrl.dtsi"
 
 / {
        model = "HiSilicon Poplar Development Board";
@@ -61,6 +62,33 @@ user-led3 {
                        default-state = "off";
                };
        };
+
+       reg_pcie: regulator-pcie {
+               compatible = "regulator-fixed";
+               regulator-name = "3V3_PCIE0";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               gpio = <&gpio6 7 0>;
+               enable-active-high;
+       };
+};
+
+&ehci {
+       status = "okay";
+};
+
+&emmc {
+       pinctrl-names = "default";
+       pinctrl-0 = <&emmc_pins_1 &emmc_pins_2
+                    &emmc_pins_3 &emmc_pins_4>;
+       fifo-depth = <256>;
+       clock-frequency = <200000000>;
+       cap-mmc-highspeed;
+       mmc-ddr-1_8v;
+       mmc-hs200-1_8v;
+       non-removable;
+       bus-width = <8>;
+       status = "okay";
 };
 
 &gmac1 {
@@ -146,6 +174,16 @@ &ir {
        status = "okay";
 };
 
+&ohci {
+       status = "okay";
+};
+
+&pcie {
+       reset-gpios = <&gpio4 4 GPIO_ACTIVE_HIGH>;
+       vpcie-supply = <&reg_pcie>;
+       status = "okay";
+};
+
 &sd0 {
        bus-width = <4>;
        cap-sd-highspeed;
index 962bd79139e4804ee9dc4ca18cabe5775926a7c6..7c0fddd7c8cfe97c1e8e26d77379ba8bdea8a0bc 100644 (file)
@@ -8,7 +8,9 @@
  */
 
 #include <dt-bindings/clock/histb-clock.h>
+#include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/phy/phy.h>
 #include <dt-bindings/reset/ti-syscon.h>
 
 / {
@@ -106,6 +108,113 @@ sysctrl: system-controller@8000000 {
                        #reset-cells = <2>;
                };
 
+               perictrl: peripheral-controller@8a20000 {
+                       compatible = "hisilicon,hi3798cv200-perictrl", "syscon",
+                                    "simple-mfd";
+                       reg = <0x8a20000 0x1000>;
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       ranges = <0x0 0x8a20000 0x1000>;
+
+                       usb2_phy1: usb2-phy@120 {
+                               compatible = "hisilicon,hi3798cv200-usb2-phy";
+                               reg = <0x120 0x4>;
+                               clocks = <&crg HISTB_USB2_PHY1_REF_CLK>;
+                               resets = <&crg 0xbc 4>;
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               usb2_phy1_port0: phy@0 {
+                                       reg = <0>;
+                                       #phy-cells = <0>;
+                                       resets = <&crg 0xbc 8>;
+                               };
+
+                               usb2_phy1_port1: phy@1 {
+                                       reg = <1>;
+                                       #phy-cells = <0>;
+                                       resets = <&crg 0xbc 9>;
+                               };
+                       };
+
+                       usb2_phy2: usb2-phy@124 {
+                               compatible = "hisilicon,hi3798cv200-usb2-phy";
+                               reg = <0x124 0x4>;
+                               clocks = <&crg HISTB_USB2_PHY2_REF_CLK>;
+                               resets = <&crg 0xbc 6>;
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               usb2_phy2_port0: phy@0 {
+                                       reg = <0>;
+                                       #phy-cells = <0>;
+                                       resets = <&crg 0xbc 10>;
+                               };
+                       };
+
+                       combphy0: phy@850 {
+                               compatible = "hisilicon,hi3798cv200-combphy";
+                               reg = <0x850 0x8>;
+                               #phy-cells = <1>;
+                               clocks = <&crg HISTB_COMBPHY0_CLK>;
+                               resets = <&crg 0x188 4>;
+                               assigned-clocks = <&crg HISTB_COMBPHY0_CLK>;
+                               assigned-clock-rates = <100000000>;
+                               hisilicon,fixed-mode = <PHY_TYPE_USB3>;
+                       };
+
+                       combphy1: phy@858 {
+                               compatible = "hisilicon,hi3798cv200-combphy";
+                               reg = <0x858 0x8>;
+                               #phy-cells = <1>;
+                               clocks = <&crg HISTB_COMBPHY1_CLK>;
+                               resets = <&crg 0x188 12>;
+                               assigned-clocks = <&crg HISTB_COMBPHY1_CLK>;
+                               assigned-clock-rates = <100000000>;
+                               hisilicon,mode-select-bits = <0x0008 11 (0x3 << 11)>;
+                       };
+               };
+
+               pmx0: pinconf@8a21000 {
+                       compatible = "pinconf-single";
+                       reg = <0x8a21000 0x180>;
+                       pinctrl-single,register-width = <32>;
+                       pinctrl-single,function-mask = <7>;
+                       pinctrl-single,gpio-range = <
+                               &range 0  8 2  /* GPIO 0 */
+                               &range 8  1 0  /* GPIO 1 */
+                               &range 9  4 2
+                               &range 13 1 0
+                               &range 14 1 1
+                               &range 15 1 0
+                               &range 16 5 0  /* GPIO 2 */
+                               &range 21 3 1
+                               &range 24 4 1  /* GPIO 3 */
+                               &range 28 2 2
+                               &range 86 1 1
+                               &range 87 1 0
+                               &range 30 4 2  /* GPIO 4 */
+                               &range 34 3 0
+                               &range 37 1 2
+                               &range 38 3 2  /* GPIO 6 */
+                               &range 41 5 0
+                               &range 46 8 1  /* GPIO 7 */
+                               &range 54 8 1  /* GPIO 8 */
+                               &range 64 7 1  /* GPIO 9 */
+                               &range 71 1 0
+                               &range 72 6 1  /* GPIO 10 */
+                               &range 78 1 0
+                               &range 79 1 1
+                               &range 80 6 1  /* GPIO 11 */
+                               &range 70 2 1
+                               &range 88 8 0  /* GPIO 12 */
+                       >;
+
+                       range: gpio-range {
+                               #pinctrl-single,gpio-range-cells = <3>;
+                       };
+               };
+
                uart0: serial@8b00000 {
                        compatible = "arm,pl011", "arm,primecell";
                        reg = <0x8b00000 0x1000>;
@@ -205,12 +314,17 @@ sd0: mmc@9820000 {
                };
 
                emmc: mmc@9830000 {
-                       compatible = "snps,dw-mshc";
+                       compatible = "hisilicon,hi3798cv200-dw-mshc";
                        reg = <0x9830000 0x10000>;
                        interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&crg HISTB_MMC_CIU_CLK>,
-                                <&crg HISTB_MMC_BIU_CLK>;
-                       clock-names = "ciu", "biu";
+                                <&crg HISTB_MMC_BIU_CLK>,
+                                <&crg HISTB_MMC_SAMPLE_CLK>,
+                                <&crg HISTB_MMC_DRV_CLK>;
+                       clock-names = "ciu", "biu", "ciu-sample", "ciu-drive";
+                       resets = <&crg 0xa0 4>;
+                       reset-names = "reset";
+                       status = "disabled";
                };
 
                gpio0: gpio@8b20000 {
@@ -221,6 +335,7 @@ gpio0: gpio@8b20000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 0 8>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -234,6 +349,13 @@ gpio1: gpio@8b21000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <
+                               &pmx0 0 8 1
+                               &pmx0 1 9 4
+                               &pmx0 5 13 1
+                               &pmx0 6 14 1
+                               &pmx0 7 15 1
+                       >;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -247,6 +369,7 @@ gpio2: gpio@8b22000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 16 5 &pmx0 5 21 3>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -260,6 +383,12 @@ gpio3: gpio@8b23000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <
+                               &pmx0 0 24 4
+                               &pmx0 4 28 2
+                               &pmx0 6 86 1
+                               &pmx0 7 87 1
+                       >;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -273,6 +402,7 @@ gpio4: gpio@8b24000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 30 4 &pmx0 4 34 3 &pmx0 7 37 1>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -299,6 +429,7 @@ gpio6: gpio@8b26000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 38 3 &pmx0 0 41 5>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -312,6 +443,7 @@ gpio7: gpio@8b27000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 46 8>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -325,6 +457,7 @@ gpio8: gpio@8b28000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 54 8>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -338,6 +471,7 @@ gpio9: gpio@8b29000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 64 7 &pmx0 71 1>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -351,6 +485,7 @@ gpio10: gpio@8b2a000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 72 6 &pmx0 6 78 1 &pmx0 7 79 1>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -364,6 +499,7 @@ gpio11: gpio@8b2b000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 80 6 &pmx0 6 70 2>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -377,6 +513,7 @@ gpio12: gpio@8b2c000 {
                        #gpio-cells = <2>;
                        interrupt-controller;
                        #interrupt-cells = <2>;
+                       gpio-ranges = <&pmx0 0 88 8>;
                        clocks = <&crg HISTB_APB_CLK>;
                        clock-names = "apb_pclk";
                        status = "disabled";
@@ -419,5 +556,67 @@ ir: ir@8001000 {
                        clocks = <&sysctrl HISTB_IR_CLK>;
                        status = "disabled";
                };
+
+               pcie: pcie@9860000 {
+                       compatible = "hisilicon,hi3798cv200-pcie";
+                       reg = <0x9860000 0x1000>,
+                             <0x0 0x2000>,
+                             <0x2000000 0x01000000>;
+                       reg-names = "control", "rc-dbi", "config";
+                       #address-cells = <3>;
+                       #size-cells = <2>;
+                       device_type = "pci";
+                       bus-range = <0 15>;
+                       num-lanes = <1>;
+                       ranges = <0x81000000 0x0 0x00000000 0x4f00000 0x0 0x100000
+                                 0x82000000 0x0 0x3000000 0x3000000 0x0 0x01f00000>;
+                       interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "msi";
+                       #interrupt-cells = <1>;
+                       interrupt-map-mask = <0 0 0 0>;
+                       interrupt-map = <0 0 0 0 &gic 0 131 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&crg HISTB_PCIE_AUX_CLK>,
+                                <&crg HISTB_PCIE_PIPE_CLK>,
+                                <&crg HISTB_PCIE_SYS_CLK>,
+                                <&crg HISTB_PCIE_BUS_CLK>;
+                       clock-names = "aux", "pipe", "sys", "bus";
+                       resets = <&crg 0x18c 6>, <&crg 0x18c 5>, <&crg 0x18c 4>;
+                       reset-names = "soft", "sys", "bus";
+                       phys = <&combphy1 PHY_TYPE_PCIE>;
+                       phy-names = "phy";
+                       status = "disabled";
+               };
+
+               ohci: ohci@9880000 {
+                       compatible = "generic-ohci";
+                       reg = <0x9880000 0x10000>;
+                       interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&crg HISTB_USB2_BUS_CLK>,
+                                <&crg HISTB_USB2_12M_CLK>,
+                                <&crg HISTB_USB2_48M_CLK>;
+                       clock-names = "bus", "clk12", "clk48";
+                       resets = <&crg 0xb8 12>;
+                       reset-names = "bus";
+                       phys = <&usb2_phy1_port0>;
+                       phy-names = "usb";
+                       status = "disabled";
+               };
+
+               ehci: ehci@9890000 {
+                       compatible = "generic-ehci";
+                       reg = <0x9890000 0x10000>;
+                       interrupts = <GIC_SPI 66 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&crg HISTB_USB2_BUS_CLK>,
+                                <&crg HISTB_USB2_PHY_CLK>,
+                                <&crg HISTB_USB2_UTMI_CLK>;
+                       clock-names = "bus", "phy", "utmi";
+                       resets = <&crg 0xb8 12>,
+                                <&crg 0xb8 16>,
+                                <&crg 0xb8 13>;
+                       reset-names = "bus", "phy", "utmi";
+                       phys = <&usb2_phy1_port0>;
+                       phy-names = "usb";
+                       status = "disabled";
+               };
        };
 };
index 9af633021a42a62460bed98a66ba63c244123177..a95c6f5619bfed8ded000442627bad2383fde3ed 100644 (file)
@@ -25,6 +25,14 @@ memory@0 {
        chosen { };
 };
 
+&ipmi0 {
+       status = "ok";
+};
+
+&uart0 {
+       status = "ok";
+};
+
 &eth0 {
        status = "ok";
 };
index 35202ebe62a744decfad6b40823620d31ee300f0..d78a6a755d03dfb1c2ac6ffacd1a990fec9fa7b8 100644 (file)
@@ -350,6 +350,27 @@ soc {
                #size-cells = <2>;
                ranges;
 
+               isa@a01b0000 {
+                       compatible = "hisilicon,hip06-lpc";
+                       #size-cells = <1>;
+                       #address-cells = <2>;
+                       reg = <0x0 0xa01b0000 0x0 0x1000>;
+
+                       ipmi0: bt@e4 {
+                               compatible = "ipmi-bt";
+                               device_type = "ipmi";
+                               reg = <0x01 0xe4 0x04>;
+                               status = "disabled";
+                       };
+
+                       uart0: lpc-uart@2f8 {
+                               compatible = "ns16550a";
+                               clock-frequency = <1843200>;
+                               reg = <0x01 0x2f8 0x08>;
+                               status = "disabled";
+                       };
+               };
+
                refclk: refclk {
                        compatible = "fixed-clock";
                        clock-frequency = <50000000>;
index fe7c16c3602593a9b572fef58bba730dbd1a9c73..21147e8e3f94410f3f5e1634302cd7b296f8ff3c 100644 (file)
@@ -57,6 +57,10 @@ &uart0 {
        status = "ok";
 };
 
+&ipmi0 {
+       status = "ok";
+};
+
 &usb_ohci {
        status = "ok";
 };
index 0600a6a84ab7d1a2c72b792ce1693e14daecf55a..9c10030a07f87e934afc86138cfa1bee0e0d8c82 100644 (file)
@@ -1114,6 +1114,20 @@ soc {
                #size-cells = <2>;
                ranges;
 
+               isa@a01b0000 {
+                       compatible = "hisilicon,hip07-lpc";
+                       #size-cells = <1>;
+                       #address-cells = <2>;
+                       reg = <0x0 0xa01b0000 0x0 0x1000>;
+
+                       ipmi0: bt@e4 {
+                               compatible = "ipmi-bt";
+                               device_type = "ipmi";
+                               reg = <0x01 0xe4 0x04>;
+                               status = "disabled";
+                       };
+               };
+
                uart0: uart@602b0000 {
                        compatible = "arm,sbsa-uart";
                        reg = <0x0 0x602b0000 0x0 0x1000>;
diff --git a/arch/arm64/boot/dts/hisilicon/poplar-pinctrl.dtsi b/arch/arm64/boot/dts/hisilicon/poplar-pinctrl.dtsi
new file mode 100644 (file)
index 0000000..7bb19e4
--- /dev/null
@@ -0,0 +1,98 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Pinctrl dts file for HiSilicon Poplar board
+ *
+ * Copyright (c) 2016-2018 HiSilicon Technologies Co., Ltd.
+ */
+
+#include <dt-bindings/pinctrl/hisi.h>
+
+/* value, enable bits, disable bits, mask */
+#define PINCTRL_PULLDOWN(value, enable, disable, mask) \
+       (value << 13) (enable << 13) (disable << 13) (mask << 13)
+#define PINCTRL_PULLUP(value, enable, disable, mask) \
+       (value << 12) (enable << 12) (disable << 12) (mask << 12)
+#define PINCTRL_SLEW_RATE(value, mask)   (value << 8) (mask << 8)
+#define PINCTRL_DRV_STRENGTH(value, mask) (value << 4) (mask << 4)
+
+&pmx0 {
+       emmc_pins_1: emmc-pins-1 {
+               pinctrl-single,pins = <
+                       0x000 MUX_M2
+                       0x004 MUX_M2
+                       0x008 MUX_M2
+                       0x00c MUX_M2
+                       0x010 MUX_M2
+                       0x014 MUX_M2
+                       0x018 MUX_M2
+                       0x01c MUX_M2
+                       0x024 MUX_M2
+               >;
+               pinctrl-single,bias-pulldown = <
+                       PINCTRL_PULLDOWN(0, 1, 0, 1)
+               >;
+               pinctrl-single,bias-pullup = <
+                       PINCTRL_PULLUP(0, 1, 0, 1)
+               >;
+               pinctrl-single,slew-rate = <
+                       PINCTRL_SLEW_RATE(1, 1)
+               >;
+               pinctrl-single,drive-strength = <
+                       PINCTRL_DRV_STRENGTH(0xb, 0xf)
+               >;
+       };
+
+       emmc_pins_2: emmc-pins-2 {
+               pinctrl-single,pins = <
+                       0x028 MUX_M2
+               >;
+               pinctrl-single,bias-pulldown = <
+                       PINCTRL_PULLDOWN(0, 1, 0, 1)
+               >;
+               pinctrl-single,bias-pullup = <
+                       PINCTRL_PULLUP(0, 1, 0, 1)
+               >;
+               pinctrl-single,slew-rate = <
+                       PINCTRL_SLEW_RATE(1, 1)
+               >;
+               pinctrl-single,drive-strength = <
+                       PINCTRL_DRV_STRENGTH(0x9, 0xf)
+               >;
+       };
+
+       emmc_pins_3: emmc-pins-3 {
+               pinctrl-single,pins = <
+                       0x02c MUX_M2
+               >;
+               pinctrl-single,bias-pulldown = <
+                       PINCTRL_PULLDOWN(0, 1, 0, 1)
+               >;
+               pinctrl-single,bias-pullup = <
+                       PINCTRL_PULLUP(0, 1, 0, 1)
+               >;
+               pinctrl-single,slew-rate = <
+                       PINCTRL_SLEW_RATE(1, 1)
+               >;
+               pinctrl-single,drive-strength = <
+                       PINCTRL_DRV_STRENGTH(3, 3)
+               >;
+       };
+
+       emmc_pins_4: emmc-pins-4 {
+               pinctrl-single,pins = <
+                       0x030 MUX_M2
+               >;
+               pinctrl-single,bias-pulldown = <
+                       PINCTRL_PULLDOWN(1, 1, 0, 1)
+               >;
+               pinctrl-single,bias-pullup = <
+                       PINCTRL_PULLUP(0, 1, 0, 1)
+               >;
+               pinctrl-single,slew-rate = <
+                       PINCTRL_SLEW_RATE(1, 1)
+               >;
+               pinctrl-single,drive-strength = <
+                       PINCTRL_DRV_STRENGTH(3, 3)
+               >;
+       };
+};
index cb454beede55230fc29a4acddc5bb8a281212591..ea9d49f2a911cc2ad7a4fc278443505e878e39bc 100644 (file)
@@ -1,8 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
-# Berlin SoC Family
-dtb-$(CONFIG_ARCH_BERLIN) += berlin4ct-dmp.dtb
-dtb-$(CONFIG_ARCH_BERLIN) += berlin4ct-stb.dtb
-
 # Mvebu SoC Family
 dtb-$(CONFIG_ARCH_MVEBU) += armada-3720-db.dtb
 dtb-$(CONFIG_ARCH_MVEBU) += armada-3720-espressobin.dtb
index ef7fd2ca251522bb1944639e85565b24a9eb4373..3ab25ad402b90c8166883b2fb0d2dbbb727be27a 100644 (file)
@@ -63,6 +63,33 @@ &sdhci1 {
        status = "okay";
 };
 
+&spi0 {
+       status = "okay";
+
+       flash@0 {
+               reg = <0>;
+               compatible = "winbond,w25q32dw", "jedec,spi-flash";
+               spi-max-frequency = <104000000>;
+               m25p,fast-read;
+
+               partitions {
+                       compatible = "fixed-partitions";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+
+                       partition@0 {
+                               label = "uboot";
+                               reg = <0 0x180000>;
+                       };
+
+                       partition@180000 {
+                               label = "ubootenv";
+                               reg = <0x180000 0x10000>;
+                       };
+               };
+       };
+};
+
 /* Exported on the micro USB connector J5 through an FTDI */
 &uart0 {
        pinctrl-names = "default";
index 97207a61bc790528b117cd3eb9ebb7bc71835f53..3353252d78a0a93bd65b693f0516b38abe86fc75 100644 (file)
@@ -148,10 +148,13 @@ pinctrl_nb: pinctrl@13800 {
                                compatible = "marvell,armada3710-nb-pinctrl",
                                             "syscon", "simple-mfd";
                                reg = <0x13800 0x100>, <0x13C00 0x20>;
+                               /* MPP1[19:0] */
                                gpionb: gpio {
                                        #gpio-cells = <2>;
                                        gpio-ranges = <&pinctrl_nb 0 0 36>;
                                        gpio-controller;
+                                       interrupt-controller;
+                                       #interrupt-cells = <2>;
                                        interrupts =
                                        <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
                                        <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
@@ -209,10 +212,13 @@ pinctrl_sb: pinctrl@18800 {
                                compatible = "marvell,armada3710-sb-pinctrl",
                                             "syscon", "simple-mfd";
                                reg = <0x18800 0x100>, <0x18C00 0x20>;
+                               /* MPP2[23:0] */
                                gpiosb: gpio {
                                        #gpio-cells = <2>;
                                        gpio-ranges = <&pinctrl_sb 0 0 30>;
                                        gpio-controller;
+                                       interrupt-controller;
+                                       #interrupt-cells = <2>;
                                        interrupts =
                                        <GIC_SPI 160 IRQ_TYPE_LEVEL_HIGH>,
                                        <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>,
index d6bec058a30a2c847115678e3721dfbf6cdb09d1..412efdb46e7cd6e524b0aa112e7d5f3687faecd3 100644 (file)
@@ -242,6 +242,11 @@ &cp0_eth0 {
        phy-mode = "10gbase-kr";
        /* Generic PHY, providing serdes lanes */
        phys = <&cp0_comphy2 0>;
+
+       fixed-link {
+               speed = <10000>;
+               full-duplex;
+       };
 };
 
 &cp0_eth1 {
index 5689fb23bbab7cc9e93a216dde6ce9f577b3bc42..1bac437369a1594d6b08018d96e5bea46174a8df 100644 (file)
@@ -177,6 +177,11 @@ &cp0_ethernet {
 &cp0_eth0 {
        status = "okay";
        phy-mode = "10gbase-kr";
+
+       fixed-link {
+               speed = <10000>;
+               full-duplex;
+       };
 };
 
 &cp0_eth2 {
@@ -303,6 +308,11 @@ &cp1_ethernet {
 &cp1_eth0 {
        status = "okay";
        phy-mode = "10gbase-kr";
+
+       fixed-link {
+               speed = <10000>;
+               full-duplex;
+       };
 };
 
 &cp1_eth1 {
index 81de03ef860d8bb21e411f40292ba2aacebd500e..a66958ff4de6e493e6c2a6eaf62c546389d99397 100644 (file)
@@ -27,6 +27,7 @@ aliases {
                ethernet0 = &cp0_eth0;
                ethernet1 = &cp1_eth0;
                ethernet2 = &cp1_eth1;
+               ethernet3 = &cp1_eth2;
        };
 
        /* Regulator labels correspond with schematics */
@@ -64,6 +65,42 @@ usb3h0_phy: usb3_phy0 {
                compatible = "usb-nop-xceiv";
                vcc-supply = <&v_5v0_usb3_hst_vbus>;
        };
+
+       sfp_eth0: sfp-eth0 {
+               /* CON15,16 - CPM lane 4 */
+               compatible = "sff,sfp";
+               i2c-bus = <&sfpp0_i2c>;
+               los-gpio = <&cp1_gpio1 28 GPIO_ACTIVE_HIGH>;
+               mod-def0-gpio = <&cp1_gpio1 27 GPIO_ACTIVE_LOW>;
+               tx-disable-gpio = <&cp1_gpio1 29 GPIO_ACTIVE_HIGH>;
+               tx-fault-gpio  = <&cp1_gpio1 26 GPIO_ACTIVE_HIGH>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&cp1_sfpp0_pins>;
+       };
+
+       sfp_eth1: sfp-eth1 {
+               /* CON17,18 - CPS lane 4 */
+               compatible = "sff,sfp";
+               i2c-bus = <&sfpp1_i2c>;
+               los-gpio = <&cp1_gpio1 8 GPIO_ACTIVE_HIGH>;
+               mod-def0-gpio = <&cp1_gpio1 11 GPIO_ACTIVE_LOW>;
+               tx-disable-gpio = <&cp1_gpio1 10 GPIO_ACTIVE_HIGH>;
+               tx-fault-gpio = <&cp0_gpio2 30 GPIO_ACTIVE_HIGH>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&cp1_sfpp1_pins &cp0_sfpp1_pins>;
+       };
+
+       sfp_eth3: sfp-eth3 {
+               /* CON3,4 - CPS lane 5 */
+               compatible = "sff,sfp";
+               i2c-bus = <&sfp_1g_i2c>;
+               los-gpio = <&cp0_gpio2 22 GPIO_ACTIVE_HIGH>;
+               mod-def0-gpio = <&cp0_gpio2 21 GPIO_ACTIVE_LOW>;
+               tx-disable-gpio = <&cp1_gpio1 24 GPIO_ACTIVE_HIGH>;
+               tx-fault-gpio = <&cp0_gpio2 19 GPIO_ACTIVE_HIGH>;
+               pinctrl-names = "default";
+               pinctrl-0 = <&cp0_sfp_1g_pins &cp1_sfp_1g_pins>;
+       };
 };
 
 &uart0 {
@@ -171,6 +208,10 @@ cp0_xhci_vbus_pins: xhci0-vbus-pins {
                marvell,pins = "mpp47";
                marvell,function = "gpio";
        };
+       cp0_sfp_1g_pins: sfp-1g-pins {
+               marvell,pins = "mpp51", "mpp53", "mpp54";
+               marvell,function = "gpio";
+       };
        cp0_pcie_pins: pcie-pins {
                marvell,pins = "mpp52";
                marvell,function = "gpio";
@@ -180,6 +221,10 @@ cp0_sdhci_pins: sdhci-pins {
                               "mpp60", "mpp61";
                marvell,function = "sdio";
        };
+       cp0_sfpp1_pins: sfpp1-pins {
+               marvell,pins = "mpp62";
+               marvell,function = "gpio";
+       };
 };
 
 &cp0_xmdio {
@@ -188,11 +233,13 @@ &cp0_xmdio {
        phy0: ethernet-phy@0 {
                compatible = "ethernet-phy-ieee802.3-c45";
                reg = <0>;
+               sfp = <&sfp_eth0>;
        };
 
        phy8: ethernet-phy@8 {
                compatible = "ethernet-phy-ieee802.3-c45";
                reg = <8>;
+               sfp = <&sfp_eth1>;
        };
 };
 
@@ -257,7 +304,22 @@ &cp1_eth1 {
        phys = <&cp1_comphy0 1>;
 };
 
+&cp1_eth2 {
+       /* CPS Lane 5 */
+       status = "okay";
+       /* Network PHY */
+       phy-mode = "2500base-x";
+       managed = "in-band-status";
+       /* Generic PHY, providing serdes lanes */
+       phys = <&cp1_comphy5 2>;
+       sfp = <&sfp_eth3>;
+};
+
 &cp1_pinctrl {
+       cp1_sfpp1_pins: sfpp1-pins {
+               marvell,pins = "mpp8", "mpp10", "mpp11";
+               marvell,function = "gpio";
+       };
        cp1_spi1_pins: spi1-pins {
                marvell,pins = "mpp12", "mpp13", "mpp14", "mpp15", "mpp16";
                marvell,function = "spi1";
@@ -266,6 +328,14 @@ cp1_uart0_pins: uart0-pins {
                marvell,pins = "mpp6", "mpp7";
                marvell,function = "uart0";
        };
+       cp1_sfp_1g_pins: sfp-1g-pins {
+               marvell,pins = "mpp24";
+               marvell,function = "gpio";
+       };
+       cp1_sfpp0_pins: sfpp0-pins {
+               marvell,pins = "mpp26", "mpp27", "mpp28", "mpp29";
+               marvell,function = "gpio";
+       };
 };
 
 /* J27 UART header */
index ed2f1237ea1e9a9c320e7b2da56145f07e147079..7dabe25f6774827fd08ec78b3f3793e5b5658177 100644 (file)
@@ -236,6 +236,7 @@ CP110_LABEL(sata0): sata@540000 {
                        compatible = "marvell,armada-8k-ahci",
                        "generic-ahci";
                        reg = <0x540000 0x30000>;
+                       dma-coherent;
                        interrupts = <ICU_GRP_NSR 107 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&CP110_LABEL(clk) 1 15>,
                                 <&CP110_LABEL(clk) 1 16>;
diff --git a/arch/arm64/boot/dts/marvell/berlin4ct-dmp.dts b/arch/arm64/boot/dts/marvell/berlin4ct-dmp.dts
deleted file mode 100644 (file)
index fae6c69..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2015 Marvell Technology Group Ltd.
- *
- * Author: Jisheng Zhang <jszhang@marvell.com>
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPLv2 or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This library 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 library is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- *
- * Or, alternatively,
- *
- *  b) 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.
- */
-
-/dts-v1/;
-
-#include "berlin4ct.dtsi"
-
-/ {
-       model = "Marvell BG4CT DMP board";
-       compatible = "marvell,berlin4ct-dmp", "marvell,berlin4ct", "marvell,berlin";
-
-       chosen {
-               stdout-path = "serial0:115200n8";
-       };
-
-       memory@1000000 {
-               device_type = "memory";
-               /* the first 16MB is for firmwares' usage */
-               reg = <0 0x01000000 0 0x7f000000>;
-       };
-};
-
-&uart0 {
-       status = "okay";
-};
diff --git a/arch/arm64/boot/dts/marvell/berlin4ct-stb.dts b/arch/arm64/boot/dts/marvell/berlin4ct-stb.dts
deleted file mode 100644 (file)
index d47edad..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2015 Marvell Technology Group Ltd.
- *
- * Author: Jisheng Zhang <jszhang@marvell.com>
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPLv2 or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This library 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 library is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- *
- * Or, alternatively,
- *
- *  b) 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.
- */
-
-/dts-v1/;
-
-#include "berlin4ct.dtsi"
-
-/ {
-       model = "Marvell BG4CT STB board";
-       compatible = "marvell,berlin4ct-stb", "marvell,berlin4ct", "marvell,berlin";
-
-       chosen {
-               stdout-path = "serial0:115200n8";
-       };
-
-       memory@1000000 {
-               device_type = "memory";
-               /* the first 16MB is for firmwares' usage */
-               reg = <0 0x01000000 0 0x7f000000>;
-       };
-};
-
-&uart0 {
-       status = "okay";
-};
diff --git a/arch/arm64/boot/dts/mediatek/mt2712-pinfunc.h b/arch/arm64/boot/dts/mediatek/mt2712-pinfunc.h
new file mode 100644 (file)
index 0000000..1b4cb0c
--- /dev/null
@@ -0,0 +1,1123 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 MediaTek Inc.
+ * Author: Zhiyong Tao <zhiyong.tao@mediatek.com>
+ *
+ */
+#ifndef __DTS_MT2712_PINFUNC_H
+#define __DTS_MT2712_PINFUNC_H
+
+#include <dt-bindings/pinctrl/mt65xx.h>
+
+#define MT2712_PIN_0_EINT0__FUNC_GPIO0 (MTK_PIN_NO(0) | 0)
+#define MT2712_PIN_0_EINT0__FUNC_EINT0 (MTK_PIN_NO(0) | 1)
+#define MT2712_PIN_0_EINT0__FUNC_MBIST_DIAG_SCANOUT (MTK_PIN_NO(0) | 2)
+#define MT2712_PIN_0_EINT0__FUNC_DSIA_TE (MTK_PIN_NO(0) | 3)
+#define MT2712_PIN_0_EINT0__FUNC_DSIC_TE (MTK_PIN_NO(0) | 4)
+#define MT2712_PIN_0_EINT0__FUNC_DIN_D3 (MTK_PIN_NO(0) | 5)
+#define MT2712_PIN_0_EINT0__FUNC_PURE_HW_PROTECT (MTK_PIN_NO(0) | 6)
+
+#define MT2712_PIN_1_EINT1__FUNC_GPIO1 (MTK_PIN_NO(1) | 0)
+#define MT2712_PIN_1_EINT1__FUNC_EINT1 (MTK_PIN_NO(1) | 1)
+#define MT2712_PIN_1_EINT1__FUNC_IR_IN (MTK_PIN_NO(1) | 2)
+#define MT2712_PIN_1_EINT1__FUNC_DSIB_TE (MTK_PIN_NO(1) | 3)
+#define MT2712_PIN_1_EINT1__FUNC_DSID_TE (MTK_PIN_NO(1) | 4)
+#define MT2712_PIN_1_EINT1__FUNC_DIN_D4 (MTK_PIN_NO(1) | 5)
+
+#define MT2712_PIN_2_EINT2__FUNC_GPIO2 (MTK_PIN_NO(2) | 0)
+#define MT2712_PIN_2_EINT2__FUNC_EINT2 (MTK_PIN_NO(2) | 1)
+#define MT2712_PIN_2_EINT2__FUNC_IR_IN (MTK_PIN_NO(2) | 2)
+#define MT2712_PIN_2_EINT2__FUNC_LCM_RST1 (MTK_PIN_NO(2) | 3)
+#define MT2712_PIN_2_EINT2__FUNC_DIN_D5 (MTK_PIN_NO(2) | 5)
+
+#define MT2712_PIN_3_EINT3__FUNC_GPIO3 (MTK_PIN_NO(3) | 0)
+#define MT2712_PIN_3_EINT3__FUNC_EINT3 (MTK_PIN_NO(3) | 1)
+#define MT2712_PIN_3_EINT3__FUNC_IR_IN (MTK_PIN_NO(3) | 2)
+#define MT2712_PIN_3_EINT3__FUNC_LCM_RST0 (MTK_PIN_NO(3) | 3)
+#define MT2712_PIN_3_EINT3__FUNC_DIN_D6 (MTK_PIN_NO(3) | 5)
+
+#define MT2712_PIN_4_PWM0__FUNC_GPIO4 (MTK_PIN_NO(4) | 0)
+#define MT2712_PIN_4_PWM0__FUNC_PWM0 (MTK_PIN_NO(4) | 1)
+#define MT2712_PIN_4_PWM0__FUNC_DISP0_PWM (MTK_PIN_NO(4) | 2)
+#define MT2712_PIN_4_PWM0__FUNC_DISP1_PWM (MTK_PIN_NO(4) | 3)
+#define MT2712_PIN_4_PWM0__FUNC_DIN_CLK (MTK_PIN_NO(4) | 5)
+
+#define MT2712_PIN_5_PWM1__FUNC_GPIO5 (MTK_PIN_NO(5) | 0)
+#define MT2712_PIN_5_PWM1__FUNC_PWM1 (MTK_PIN_NO(5) | 1)
+#define MT2712_PIN_5_PWM1__FUNC_DISP1_PWM (MTK_PIN_NO(5) | 2)
+#define MT2712_PIN_5_PWM1__FUNC_DISP0_PWM (MTK_PIN_NO(5) | 3)
+#define MT2712_PIN_5_PWM1__FUNC_DIN_VSYNC (MTK_PIN_NO(5) | 5)
+
+#define MT2712_PIN_6_PWM2__FUNC_GPIO6 (MTK_PIN_NO(6) | 0)
+#define MT2712_PIN_6_PWM2__FUNC_PWM2 (MTK_PIN_NO(6) | 1)
+#define MT2712_PIN_6_PWM2__FUNC_DISP0_PWM (MTK_PIN_NO(6) | 2)
+#define MT2712_PIN_6_PWM2__FUNC_DISP1_PWM (MTK_PIN_NO(6) | 3)
+#define MT2712_PIN_6_PWM2__FUNC_DISP2_PWM (MTK_PIN_NO(6) | 4)
+#define MT2712_PIN_6_PWM2__FUNC_DIN_HSYNC (MTK_PIN_NO(6) | 5)
+
+#define MT2712_PIN_7_PWM3__FUNC_GPIO7 (MTK_PIN_NO(7) | 0)
+#define MT2712_PIN_7_PWM3__FUNC_PWM3 (MTK_PIN_NO(7) | 1)
+#define MT2712_PIN_7_PWM3__FUNC_DISP1_PWM (MTK_PIN_NO(7) | 2)
+#define MT2712_PIN_7_PWM3__FUNC_DISP0_PWM (MTK_PIN_NO(7) | 3)
+#define MT2712_PIN_7_PWM3__FUNC_LCM_RST2 (MTK_PIN_NO(7) | 4)
+#define MT2712_PIN_7_PWM3__FUNC_DIN_D0 (MTK_PIN_NO(7) | 5)
+
+#define MT2712_PIN_8_PWM4__FUNC_GPIO8 (MTK_PIN_NO(8) | 0)
+#define MT2712_PIN_8_PWM4__FUNC_PWM4 (MTK_PIN_NO(8) | 1)
+#define MT2712_PIN_8_PWM4__FUNC_DISP0_PWM (MTK_PIN_NO(8) | 2)
+#define MT2712_PIN_8_PWM4__FUNC_DISP1_PWM (MTK_PIN_NO(8) | 3)
+#define MT2712_PIN_8_PWM4__FUNC_DSIA_TE (MTK_PIN_NO(8) | 4)
+#define MT2712_PIN_8_PWM4__FUNC_DIN_D1 (MTK_PIN_NO(8) | 5)
+
+#define MT2712_PIN_9_PWM5__FUNC_GPIO9 (MTK_PIN_NO(9) | 0)
+#define MT2712_PIN_9_PWM5__FUNC_PWM5 (MTK_PIN_NO(9) | 1)
+#define MT2712_PIN_9_PWM5__FUNC_DISP1_PWM (MTK_PIN_NO(9) | 2)
+#define MT2712_PIN_9_PWM5__FUNC_DISP0_PWM (MTK_PIN_NO(9) | 3)
+#define MT2712_PIN_9_PWM5__FUNC_DSIB_TE (MTK_PIN_NO(9) | 4)
+#define MT2712_PIN_9_PWM5__FUNC_DIN_D2 (MTK_PIN_NO(9) | 5)
+
+#define MT2712_PIN_10_PWM6__FUNC_GPIO10 (MTK_PIN_NO(10) | 0)
+#define MT2712_PIN_10_PWM6__FUNC_PWM6 (MTK_PIN_NO(10) | 1)
+#define MT2712_PIN_10_PWM6__FUNC_DISP0_PWM (MTK_PIN_NO(10) | 2)
+#define MT2712_PIN_10_PWM6__FUNC_DISP1_PWM (MTK_PIN_NO(10) | 3)
+#define MT2712_PIN_10_PWM6__FUNC_LCM_RST0 (MTK_PIN_NO(10) | 4)
+
+#define MT2712_PIN_11_PWM7__FUNC_GPIO11 (MTK_PIN_NO(11) | 0)
+#define MT2712_PIN_11_PWM7__FUNC_PWM7 (MTK_PIN_NO(11) | 1)
+#define MT2712_PIN_11_PWM7__FUNC_DISP1_PWM (MTK_PIN_NO(11) | 2)
+#define MT2712_PIN_11_PWM7__FUNC_DISP0_PWM (MTK_PIN_NO(11) | 3)
+#define MT2712_PIN_11_PWM7__FUNC_LCM_RST1 (MTK_PIN_NO(11) | 4)
+
+#define MT2712_PIN_12_IDDIG_P0__FUNC_GPIO12 (MTK_PIN_NO(12) | 0)
+#define MT2712_PIN_12_IDDIG_P0__FUNC_IDDIG_A (MTK_PIN_NO(12) | 1)
+#define MT2712_PIN_12_IDDIG_P0__FUNC_DIN_D7 (MTK_PIN_NO(12) | 5)
+
+#define MT2712_PIN_13_DRV_VBUS_P0__FUNC_GPIO13 (MTK_PIN_NO(13) | 0)
+#define MT2712_PIN_13_DRV_VBUS_P0__FUNC_DRV_VBUS_A (MTK_PIN_NO(13) | 1)
+
+#define MT2712_PIN_14_IDDIG_P1__FUNC_GPIO14 (MTK_PIN_NO(14) | 0)
+#define MT2712_PIN_14_IDDIG_P1__FUNC_IDDIG_B (MTK_PIN_NO(14) | 1)
+
+#define MT2712_PIN_15_DRV_VBUS_P1__FUNC_GPIO15 (MTK_PIN_NO(15) | 0)
+#define MT2712_PIN_15_DRV_VBUS_P1__FUNC_DRV_VBUS_B (MTK_PIN_NO(15) | 1)
+
+#define MT2712_PIN_16_DRV_VBUS_P2__FUNC_GPIO16 (MTK_PIN_NO(16) | 0)
+#define MT2712_PIN_16_DRV_VBUS_P2__FUNC_DRV_VBUS_C (MTK_PIN_NO(16) | 1)
+
+#define MT2712_PIN_17_DRV_VBUS_P3__FUNC_GPIO17 (MTK_PIN_NO(17) | 0)
+#define MT2712_PIN_17_DRV_VBUS_P3__FUNC_DRV_VBUS_D (MTK_PIN_NO(17) | 1)
+
+#define MT2712_PIN_18_KPROW0__FUNC_GPIO18 (MTK_PIN_NO(18) | 0)
+#define MT2712_PIN_18_KPROW0__FUNC_KROW0 (MTK_PIN_NO(18) | 1)
+
+#define MT2712_PIN_19_KPCOL0__FUNC_GPIO19 (MTK_PIN_NO(19) | 0)
+#define MT2712_PIN_19_KPCOL0__FUNC_KCOL0 (MTK_PIN_NO(19) | 1)
+
+#define MT2712_PIN_20_KPROW1__FUNC_GPIO20 (MTK_PIN_NO(20) | 0)
+#define MT2712_PIN_20_KPROW1__FUNC_KROW1 (MTK_PIN_NO(20) | 1)
+
+#define MT2712_PIN_21_KPCOL1__FUNC_GPIO21 (MTK_PIN_NO(21) | 0)
+#define MT2712_PIN_21_KPCOL1__FUNC_KCOL1 (MTK_PIN_NO(21) | 1)
+
+#define MT2712_PIN_22_KPROW2__FUNC_GPIO22 (MTK_PIN_NO(22) | 0)
+#define MT2712_PIN_22_KPROW2__FUNC_KROW2 (MTK_PIN_NO(22) | 1)
+#define MT2712_PIN_22_KPROW2__FUNC_DISP1_PWM (MTK_PIN_NO(22) | 2)
+
+#define MT2712_PIN_23_KPCOL2__FUNC_GPIO23 (MTK_PIN_NO(23) | 0)
+#define MT2712_PIN_23_KPCOL2__FUNC_KCOL2 (MTK_PIN_NO(23) | 1)
+#define MT2712_PIN_23_KPCOL2__FUNC_DISP0_PWM (MTK_PIN_NO(23) | 2)
+
+#define MT2712_PIN_24_CMMCLK__FUNC_GPIO24 (MTK_PIN_NO(24) | 0)
+#define MT2712_PIN_24_CMMCLK__FUNC_CMMCLK (MTK_PIN_NO(24) | 1)
+#define MT2712_PIN_24_CMMCLK__FUNC_DBG_MON_A_1_ (MTK_PIN_NO(24) | 7)
+
+#define MT2712_PIN_25_CM2MCLK__FUNC_GPIO25 (MTK_PIN_NO(25) | 0)
+#define MT2712_PIN_25_CM2MCLK__FUNC_CM2MCLK (MTK_PIN_NO(25) | 1)
+#define MT2712_PIN_25_CM2MCLK__FUNC_DBG_MON_A_2_ (MTK_PIN_NO(25) | 7)
+
+#define MT2712_PIN_26_PCM_TX__FUNC_GPIO26 (MTK_PIN_NO(26) | 0)
+#define MT2712_PIN_26_PCM_TX__FUNC_PCM1_DO (MTK_PIN_NO(26) | 1)
+#define MT2712_PIN_26_PCM_TX__FUNC_MRG_TX (MTK_PIN_NO(26) | 2)
+#define MT2712_PIN_26_PCM_TX__FUNC_DAI_TX (MTK_PIN_NO(26) | 3)
+#define MT2712_PIN_26_PCM_TX__FUNC_MRG_RX (MTK_PIN_NO(26) | 4)
+#define MT2712_PIN_26_PCM_TX__FUNC_DAI_RX (MTK_PIN_NO(26) | 5)
+#define MT2712_PIN_26_PCM_TX__FUNC_PCM1_DI (MTK_PIN_NO(26) | 6)
+#define MT2712_PIN_26_PCM_TX__FUNC_DBG_MON_A_3_ (MTK_PIN_NO(26) | 7)
+
+#define MT2712_PIN_27_PCM_CLK__FUNC_GPIO27 (MTK_PIN_NO(27) | 0)
+#define MT2712_PIN_27_PCM_CLK__FUNC_PCM1_CLK (MTK_PIN_NO(27) | 1)
+#define MT2712_PIN_27_PCM_CLK__FUNC_MRG_CLK (MTK_PIN_NO(27) | 2)
+#define MT2712_PIN_27_PCM_CLK__FUNC_DAI_CLK (MTK_PIN_NO(27) | 3)
+#define MT2712_PIN_27_PCM_CLK__FUNC_DBG_MON_A_4_ (MTK_PIN_NO(27) | 7)
+
+#define MT2712_PIN_28_PCM_RX__FUNC_GPIO28 (MTK_PIN_NO(28) | 0)
+#define MT2712_PIN_28_PCM_RX__FUNC_PCM1_DI (MTK_PIN_NO(28) | 1)
+#define MT2712_PIN_28_PCM_RX__FUNC_MRG_RX (MTK_PIN_NO(28) | 2)
+#define MT2712_PIN_28_PCM_RX__FUNC_DAI_RX (MTK_PIN_NO(28) | 3)
+#define MT2712_PIN_28_PCM_RX__FUNC_MRG_TX (MTK_PIN_NO(28) | 4)
+#define MT2712_PIN_28_PCM_RX__FUNC_DAI_TX (MTK_PIN_NO(28) | 5)
+#define MT2712_PIN_28_PCM_RX__FUNC_PCM1_DO (MTK_PIN_NO(28) | 6)
+#define MT2712_PIN_28_PCM_RX__FUNC_DBG_MON_A_5_ (MTK_PIN_NO(28) | 7)
+
+#define MT2712_PIN_29_PCM_SYNC__FUNC_GPIO29 (MTK_PIN_NO(29) | 0)
+#define MT2712_PIN_29_PCM_SYNC__FUNC_PCM1_SYNC (MTK_PIN_NO(29) | 1)
+#define MT2712_PIN_29_PCM_SYNC__FUNC_MRG_SYNC (MTK_PIN_NO(29) | 2)
+#define MT2712_PIN_29_PCM_SYNC__FUNC_DAI_SYNC (MTK_PIN_NO(29) | 3)
+#define MT2712_PIN_29_PCM_SYNC__FUNC_DBG_MON_A_6_ (MTK_PIN_NO(29) | 7)
+
+#define MT2712_PIN_30_NCEB0__FUNC_GPIO30 (MTK_PIN_NO(30) | 0)
+#define MT2712_PIN_30_NCEB0__FUNC_NCEB0 (MTK_PIN_NO(30) | 1)
+#define MT2712_PIN_30_NCEB0__FUNC_USB0_FT_SDA (MTK_PIN_NO(30) | 2)
+#define MT2712_PIN_30_NCEB0__FUNC_DBG_MON_A_7_ (MTK_PIN_NO(30) | 7)
+
+#define MT2712_PIN_31_NCEB1__FUNC_GPIO31 (MTK_PIN_NO(31) | 0)
+#define MT2712_PIN_31_NCEB1__FUNC_NCEB1 (MTK_PIN_NO(31) | 1)
+#define MT2712_PIN_31_NCEB1__FUNC_USB1_FT_SCL (MTK_PIN_NO(31) | 2)
+#define MT2712_PIN_31_NCEB1__FUNC_DBG_MON_A_8_ (MTK_PIN_NO(31) | 7)
+
+#define MT2712_PIN_32_NF_DQS__FUNC_GPIO32 (MTK_PIN_NO(32) | 0)
+#define MT2712_PIN_32_NF_DQS__FUNC_NF_DQS (MTK_PIN_NO(32) | 1)
+#define MT2712_PIN_32_NF_DQS__FUNC_USB1_FT_SDA (MTK_PIN_NO(32) | 2)
+#define MT2712_PIN_32_NF_DQS__FUNC_DBG_MON_A_9_ (MTK_PIN_NO(32) | 7)
+
+#define MT2712_PIN_33_NWEB__FUNC_GPIO33 (MTK_PIN_NO(33) | 0)
+#define MT2712_PIN_33_NWEB__FUNC_NWEB (MTK_PIN_NO(33) | 1)
+#define MT2712_PIN_33_NWEB__FUNC_USB2_FT_SCL (MTK_PIN_NO(33) | 2)
+#define MT2712_PIN_33_NWEB__FUNC_DBG_MON_A_10_ (MTK_PIN_NO(33) | 7)
+
+#define MT2712_PIN_34_NREB__FUNC_GPIO34 (MTK_PIN_NO(34) | 0)
+#define MT2712_PIN_34_NREB__FUNC_NREB (MTK_PIN_NO(34) | 1)
+#define MT2712_PIN_34_NREB__FUNC_USB2_FT_SDA (MTK_PIN_NO(34) | 2)
+#define MT2712_PIN_34_NREB__FUNC_DBG_MON_A_11_ (MTK_PIN_NO(34) | 7)
+
+#define MT2712_PIN_35_NCLE__FUNC_GPIO35 (MTK_PIN_NO(35) | 0)
+#define MT2712_PIN_35_NCLE__FUNC_NCLE (MTK_PIN_NO(35) | 1)
+#define MT2712_PIN_35_NCLE__FUNC_USB3_FT_SCL (MTK_PIN_NO(35) | 2)
+#define MT2712_PIN_35_NCLE__FUNC_DBG_MON_A_12_ (MTK_PIN_NO(35) | 7)
+
+#define MT2712_PIN_36_NALE__FUNC_GPIO36 (MTK_PIN_NO(36) | 0)
+#define MT2712_PIN_36_NALE__FUNC_NALE (MTK_PIN_NO(36) | 1)
+#define MT2712_PIN_36_NALE__FUNC_USB3_FT_SDA (MTK_PIN_NO(36) | 2)
+#define MT2712_PIN_36_NALE__FUNC_DBG_MON_A_13_ (MTK_PIN_NO(36) | 7)
+
+#define MT2712_PIN_37_MSDC0E_CLK__FUNC_GPIO37 (MTK_PIN_NO(37) | 0)
+#define MT2712_PIN_37_MSDC0E_CLK__FUNC_MSDC0_CLK (MTK_PIN_NO(37) | 1)
+#define MT2712_PIN_37_MSDC0E_CLK__FUNC_USB0_FT_SCL (MTK_PIN_NO(37) | 2)
+#define MT2712_PIN_37_MSDC0E_CLK__FUNC_DBG_MON_A_0_ (MTK_PIN_NO(37) | 7)
+
+#define MT2712_PIN_38_MSDC0E_DAT7__FUNC_GPIO38 (MTK_PIN_NO(38) | 0)
+#define MT2712_PIN_38_MSDC0E_DAT7__FUNC_MSDC0_DAT7 (MTK_PIN_NO(38) | 1)
+#define MT2712_PIN_38_MSDC0E_DAT7__FUNC_NAND_ND7 (MTK_PIN_NO(38) | 2)
+#define MT2712_PIN_38_MSDC0E_DAT7__FUNC_DBG_MON_A_14_ (MTK_PIN_NO(38) | 7)
+
+#define MT2712_PIN_39_MSDC0E_DAT6__FUNC_GPIO39 (MTK_PIN_NO(39) | 0)
+#define MT2712_PIN_39_MSDC0E_DAT6__FUNC_MSDC0_DAT6 (MTK_PIN_NO(39) | 1)
+#define MT2712_PIN_39_MSDC0E_DAT6__FUNC_NAND_ND6 (MTK_PIN_NO(39) | 2)
+#define MT2712_PIN_39_MSDC0E_DAT6__FUNC_DBG_MON_A_15_ (MTK_PIN_NO(39) | 7)
+
+#define MT2712_PIN_40_MSDC0E_DAT5__FUNC_GPIO40 (MTK_PIN_NO(40) | 0)
+#define MT2712_PIN_40_MSDC0E_DAT5__FUNC_MSDC0_DAT5 (MTK_PIN_NO(40) | 1)
+#define MT2712_PIN_40_MSDC0E_DAT5__FUNC_NAND_ND5 (MTK_PIN_NO(40) | 2)
+#define MT2712_PIN_40_MSDC0E_DAT5__FUNC_DBG_MON_A_16_ (MTK_PIN_NO(40) | 7)
+
+#define MT2712_PIN_41_MSDC0E_DAT4__FUNC_GPIO41 (MTK_PIN_NO(41) | 0)
+#define MT2712_PIN_41_MSDC0E_DAT4__FUNC_MSDC0_DAT4 (MTK_PIN_NO(41) | 1)
+#define MT2712_PIN_41_MSDC0E_DAT4__FUNC_NAND_ND4 (MTK_PIN_NO(41) | 2)
+#define MT2712_PIN_41_MSDC0E_DAT4__FUNC_DBG_MON_A_17_ (MTK_PIN_NO(41) | 7)
+
+#define MT2712_PIN_42_MSDC0E_DAT3__FUNC_GPIO42 (MTK_PIN_NO(42) | 0)
+#define MT2712_PIN_42_MSDC0E_DAT3__FUNC_MSDC0_DAT3 (MTK_PIN_NO(42) | 1)
+#define MT2712_PIN_42_MSDC0E_DAT3__FUNC_NAND_ND3 (MTK_PIN_NO(42) | 2)
+#define MT2712_PIN_42_MSDC0E_DAT3__FUNC_DBG_MON_A_18_ (MTK_PIN_NO(42) | 7)
+
+#define MT2712_PIN_43_MSDC0E_DAT2__FUNC_GPIO43 (MTK_PIN_NO(43) | 0)
+#define MT2712_PIN_43_MSDC0E_DAT2__FUNC_MSDC0_DAT2 (MTK_PIN_NO(43) | 1)
+#define MT2712_PIN_43_MSDC0E_DAT2__FUNC_NAND_ND2 (MTK_PIN_NO(43) | 2)
+#define MT2712_PIN_43_MSDC0E_DAT2__FUNC_DBG_MON_A_19_ (MTK_PIN_NO(43) | 7)
+
+#define MT2712_PIN_44_MSDC0E_DAT1__FUNC_GPIO44 (MTK_PIN_NO(44) | 0)
+#define MT2712_PIN_44_MSDC0E_DAT1__FUNC_MSDC0_DAT1 (MTK_PIN_NO(44) | 1)
+#define MT2712_PIN_44_MSDC0E_DAT1__FUNC_NAND_ND1 (MTK_PIN_NO(44) | 2)
+#define MT2712_PIN_44_MSDC0E_DAT1__FUNC_DBG_MON_A_20_ (MTK_PIN_NO(44) | 7)
+
+#define MT2712_PIN_45_MSDC0E_DAT0__FUNC_GPIO45 (MTK_PIN_NO(45) | 0)
+#define MT2712_PIN_45_MSDC0E_DAT0__FUNC_MSDC0_DAT0 (MTK_PIN_NO(45) | 1)
+#define MT2712_PIN_45_MSDC0E_DAT0__FUNC_NAND_ND0 (MTK_PIN_NO(45) | 2)
+#define MT2712_PIN_45_MSDC0E_DAT0__FUNC_DBG_MON_A_21_ (MTK_PIN_NO(45) | 7)
+
+#define MT2712_PIN_46_MSDC0E_CMD__FUNC_GPIO46 (MTK_PIN_NO(46) | 0)
+#define MT2712_PIN_46_MSDC0E_CMD__FUNC_MSDC0_CMD (MTK_PIN_NO(46) | 1)
+#define MT2712_PIN_46_MSDC0E_CMD__FUNC_NAND_NRNB (MTK_PIN_NO(46) | 2)
+#define MT2712_PIN_46_MSDC0E_CMD__FUNC_DBG_MON_A_22_ (MTK_PIN_NO(46) | 7)
+
+#define MT2712_PIN_47_MSDC0E_DSL__FUNC_GPIO47 (MTK_PIN_NO(47) | 0)
+#define MT2712_PIN_47_MSDC0E_DSL__FUNC_MSDC0_DSL (MTK_PIN_NO(47) | 1)
+#define MT2712_PIN_47_MSDC0E_DSL__FUNC_DBG_MON_A_23_ (MTK_PIN_NO(47) | 7)
+
+#define MT2712_PIN_48_MSDC0E_RSTB__FUNC_GPIO48 (MTK_PIN_NO(48) | 0)
+#define MT2712_PIN_48_MSDC0E_RSTB__FUNC_MSDC0_RSTB (MTK_PIN_NO(48) | 1)
+#define MT2712_PIN_48_MSDC0E_RSTB__FUNC_DBG_MON_A_24_ (MTK_PIN_NO(48) | 7)
+
+#define MT2712_PIN_49_MSDC3_DAT3__FUNC_GPIO49 (MTK_PIN_NO(49) | 0)
+#define MT2712_PIN_49_MSDC3_DAT3__FUNC_MSDC3_DAT3 (MTK_PIN_NO(49) | 1)
+#define MT2712_PIN_49_MSDC3_DAT3__FUNC_DBG_MON_A_25_ (MTK_PIN_NO(49) | 7)
+
+#define MT2712_PIN_50_MSDC3_DAT2__FUNC_GPIO50 (MTK_PIN_NO(50) | 0)
+#define MT2712_PIN_50_MSDC3_DAT2__FUNC_MSDC3_DAT2 (MTK_PIN_NO(50) | 1)
+#define MT2712_PIN_50_MSDC3_DAT2__FUNC_DBG_MON_A_26_ (MTK_PIN_NO(50) | 7)
+
+#define MT2712_PIN_51_MSDC3_DAT1__FUNC_GPIO51 (MTK_PIN_NO(51) | 0)
+#define MT2712_PIN_51_MSDC3_DAT1__FUNC_MSDC3_DAT1 (MTK_PIN_NO(51) | 1)
+#define MT2712_PIN_51_MSDC3_DAT1__FUNC_DBG_MON_A_27_ (MTK_PIN_NO(51) | 7)
+
+#define MT2712_PIN_52_MSDC3_DAT0__FUNC_GPIO52 (MTK_PIN_NO(52) | 0)
+#define MT2712_PIN_52_MSDC3_DAT0__FUNC_MSDC3_DAT0 (MTK_PIN_NO(52) | 1)
+#define MT2712_PIN_52_MSDC3_DAT0__FUNC_DBG_MON_A_28_ (MTK_PIN_NO(52) | 7)
+
+#define MT2712_PIN_53_MSDC3_CMD__FUNC_GPIO53 (MTK_PIN_NO(53) | 0)
+#define MT2712_PIN_53_MSDC3_CMD__FUNC_MSDC3_CMD (MTK_PIN_NO(53) | 1)
+#define MT2712_PIN_53_MSDC3_CMD__FUNC_DBG_MON_A_29_ (MTK_PIN_NO(53) | 7)
+
+#define MT2712_PIN_54_MSDC3_INS__FUNC_GPIO54 (MTK_PIN_NO(54) | 0)
+#define MT2712_PIN_54_MSDC3_INS__FUNC_MSDC3_INS (MTK_PIN_NO(54) | 1)
+#define MT2712_PIN_54_MSDC3_INS__FUNC_DBG_MON_A_30_ (MTK_PIN_NO(54) | 7)
+
+#define MT2712_PIN_55_MSDC3_DSL__FUNC_GPIO55 (MTK_PIN_NO(55) | 0)
+#define MT2712_PIN_55_MSDC3_DSL__FUNC_MSDC3_DSL (MTK_PIN_NO(55) | 1)
+#define MT2712_PIN_55_MSDC3_DSL__FUNC_DBG_MON_A_31_ (MTK_PIN_NO(55) | 7)
+
+#define MT2712_PIN_56_MSDC3_CLK__FUNC_GPIO56 (MTK_PIN_NO(56) | 0)
+#define MT2712_PIN_56_MSDC3_CLK__FUNC_MSDC3_CLK (MTK_PIN_NO(56) | 1)
+#define MT2712_PIN_56_MSDC3_CLK__FUNC_DBG_MON_A_32_ (MTK_PIN_NO(56) | 7)
+
+#define MT2712_PIN_57_NOR_CS__FUNC_GPIO57 (MTK_PIN_NO(57) | 0)
+#define MT2712_PIN_57_NOR_CS__FUNC_NOR_CS (MTK_PIN_NO(57) | 1)
+
+#define MT2712_PIN_58_NOR_CK__FUNC_GPIO58 (MTK_PIN_NO(58) | 0)
+#define MT2712_PIN_58_NOR_CK__FUNC_NOR_CK (MTK_PIN_NO(58) | 1)
+
+#define MT2712_PIN_59_NOR_IO0__FUNC_GPIO59 (MTK_PIN_NO(59) | 0)
+#define MT2712_PIN_59_NOR_IO0__FUNC_NOR_IO0 (MTK_PIN_NO(59) | 1)
+
+#define MT2712_PIN_60_NOR_IO1__FUNC_GPIO60 (MTK_PIN_NO(60) | 0)
+#define MT2712_PIN_60_NOR_IO1__FUNC_NOR_IO1 (MTK_PIN_NO(60) | 1)
+
+#define MT2712_PIN_61_NOR_IO2__FUNC_GPIO61 (MTK_PIN_NO(61) | 0)
+#define MT2712_PIN_61_NOR_IO2__FUNC_NOR_IO2 (MTK_PIN_NO(61) | 1)
+
+#define MT2712_PIN_62_NOR_IO3__FUNC_GPIO62 (MTK_PIN_NO(62) | 0)
+#define MT2712_PIN_62_NOR_IO3__FUNC_NOR_IO3 (MTK_PIN_NO(62) | 1)
+
+#define MT2712_PIN_63_MSDC1_CLK__FUNC_GPIO63 (MTK_PIN_NO(63) | 0)
+#define MT2712_PIN_63_MSDC1_CLK__FUNC_MSDC1_CLK (MTK_PIN_NO(63) | 1)
+#define MT2712_PIN_63_MSDC1_CLK__FUNC_UDI_TCK (MTK_PIN_NO(63) | 2)
+
+#define MT2712_PIN_64_MSDC1_DAT3__FUNC_GPIO64 (MTK_PIN_NO(64) | 0)
+#define MT2712_PIN_64_MSDC1_DAT3__FUNC_MSDC1_DAT3 (MTK_PIN_NO(64) | 1)
+#define MT2712_PIN_64_MSDC1_DAT3__FUNC_UDI_TDI (MTK_PIN_NO(64) | 2)
+
+#define MT2712_PIN_65_MSDC1_DAT1__FUNC_GPIO65 (MTK_PIN_NO(65) | 0)
+#define MT2712_PIN_65_MSDC1_DAT1__FUNC_MSDC1_DAT1 (MTK_PIN_NO(65) | 1)
+#define MT2712_PIN_65_MSDC1_DAT1__FUNC_UDI_TMS (MTK_PIN_NO(65) | 2)
+
+#define MT2712_PIN_66_MSDC1_DAT2__FUNC_GPIO66 (MTK_PIN_NO(66) | 0)
+#define MT2712_PIN_66_MSDC1_DAT2__FUNC_MSDC1_DAT2 (MTK_PIN_NO(66) | 1)
+#define MT2712_PIN_66_MSDC1_DAT2__FUNC_UDI_TDO (MTK_PIN_NO(66) | 2)
+
+#define MT2712_PIN_67_MSDC1_PSW__FUNC_GPIO67 (MTK_PIN_NO(67) | 0)
+#define MT2712_PIN_67_MSDC1_PSW__FUNC_UDI_NTRST (MTK_PIN_NO(67) | 2)
+
+#define MT2712_PIN_68_MSDC1_DAT0__FUNC_GPIO68 (MTK_PIN_NO(68) | 0)
+#define MT2712_PIN_68_MSDC1_DAT0__FUNC_MSDC1_DAT0 (MTK_PIN_NO(68) | 1)
+
+#define MT2712_PIN_69_MSDC1_CMD__FUNC_GPIO69 (MTK_PIN_NO(69) | 0)
+#define MT2712_PIN_69_MSDC1_CMD__FUNC_MSDC1_CMD (MTK_PIN_NO(69) | 1)
+
+#define MT2712_PIN_70_MSDC1_INS__FUNC_GPIO70 (MTK_PIN_NO(70) | 0)
+
+#define MT2712_PIN_71_GBE_TXD3__FUNC_GPIO71 (MTK_PIN_NO(71) | 0)
+#define MT2712_PIN_71_GBE_TXD3__FUNC_GBE_TXD3 (MTK_PIN_NO(71) | 1)
+#define MT2712_PIN_71_GBE_TXD3__FUNC_DBG_MON_B_0_ (MTK_PIN_NO(71) | 7)
+
+#define MT2712_PIN_72_GBE_TXD2__FUNC_GPIO72 (MTK_PIN_NO(72) | 0)
+#define MT2712_PIN_72_GBE_TXD2__FUNC_GBE_TXD2 (MTK_PIN_NO(72) | 1)
+#define MT2712_PIN_72_GBE_TXD2__FUNC_DBG_MON_B_1_ (MTK_PIN_NO(72) | 7)
+
+#define MT2712_PIN_73_GBE_TXD1__FUNC_GPIO73 (MTK_PIN_NO(73) | 0)
+#define MT2712_PIN_73_GBE_TXD1__FUNC_GBE_TXD1 (MTK_PIN_NO(73) | 1)
+#define MT2712_PIN_73_GBE_TXD1__FUNC_DBG_MON_B_2_ (MTK_PIN_NO(73) | 7)
+
+#define MT2712_PIN_74_GBE_TXD0__FUNC_GPIO74 (MTK_PIN_NO(74) | 0)
+#define MT2712_PIN_74_GBE_TXD0__FUNC_GBE_TXD0 (MTK_PIN_NO(74) | 1)
+#define MT2712_PIN_74_GBE_TXD0__FUNC_DBG_MON_B_3_ (MTK_PIN_NO(74) | 7)
+
+#define MT2712_PIN_75_GBE_TXC__FUNC_GPIO75 (MTK_PIN_NO(75) | 0)
+#define MT2712_PIN_75_GBE_TXC__FUNC_GBE_TXC (MTK_PIN_NO(75) | 1)
+#define MT2712_PIN_75_GBE_TXC__FUNC_DBG_MON_B_4_ (MTK_PIN_NO(75) | 7)
+
+#define MT2712_PIN_76_GBE_TXEN__FUNC_GPIO76 (MTK_PIN_NO(76) | 0)
+#define MT2712_PIN_76_GBE_TXEN__FUNC_GBE_TXEN (MTK_PIN_NO(76) | 1)
+#define MT2712_PIN_76_GBE_TXEN__FUNC_DBG_MON_B_5_ (MTK_PIN_NO(76) | 7)
+
+#define MT2712_PIN_77_GBE_TXER__FUNC_GPIO77 (MTK_PIN_NO(77) | 0)
+#define MT2712_PIN_77_GBE_TXER__FUNC_GBE_TXER (MTK_PIN_NO(77) | 1)
+#define MT2712_PIN_77_GBE_TXER__FUNC_DBG_MON_B_6_ (MTK_PIN_NO(77) | 7)
+
+#define MT2712_PIN_78_GBE_RXD3__FUNC_GPIO78 (MTK_PIN_NO(78) | 0)
+#define MT2712_PIN_78_GBE_RXD3__FUNC_GBE_RXD3 (MTK_PIN_NO(78) | 1)
+#define MT2712_PIN_78_GBE_RXD3__FUNC_DBG_MON_B_7_ (MTK_PIN_NO(78) | 7)
+
+#define MT2712_PIN_79_GBE_RXD2__FUNC_GPIO79 (MTK_PIN_NO(79) | 0)
+#define MT2712_PIN_79_GBE_RXD2__FUNC_GBE_RXD2 (MTK_PIN_NO(79) | 1)
+#define MT2712_PIN_79_GBE_RXD2__FUNC_DBG_MON_B_8_ (MTK_PIN_NO(79) | 7)
+
+#define MT2712_PIN_80_GBE_RXD1__FUNC_GPIO80 (MTK_PIN_NO(80) | 0)
+#define MT2712_PIN_80_GBE_RXD1__FUNC_GBE_RXD1 (MTK_PIN_NO(80) | 1)
+#define MT2712_PIN_80_GBE_RXD1__FUNC_DBG_MON_B_9_ (MTK_PIN_NO(80) | 7)
+
+#define MT2712_PIN_81_GBE_RXD0__FUNC_GPIO81 (MTK_PIN_NO(81) | 0)
+#define MT2712_PIN_81_GBE_RXD0__FUNC_GBE_RXD0 (MTK_PIN_NO(81) | 1)
+#define MT2712_PIN_81_GBE_RXD0__FUNC_DBG_MON_B_10_ (MTK_PIN_NO(81) | 7)
+
+#define MT2712_PIN_82_GBE_RXDV__FUNC_GPIO82 (MTK_PIN_NO(82) | 0)
+#define MT2712_PIN_82_GBE_RXDV__FUNC_GBE_RXDV (MTK_PIN_NO(82) | 1)
+#define MT2712_PIN_82_GBE_RXDV__FUNC_DBG_MON_B_11_ (MTK_PIN_NO(82) | 7)
+
+#define MT2712_PIN_83_GBE_RXER__FUNC_GPIO83 (MTK_PIN_NO(83) | 0)
+#define MT2712_PIN_83_GBE_RXER__FUNC_GBE_RXER (MTK_PIN_NO(83) | 1)
+#define MT2712_PIN_83_GBE_RXER__FUNC_DBG_MON_B_12_ (MTK_PIN_NO(83) | 7)
+
+#define MT2712_PIN_84_GBE_RXC__FUNC_GPIO84 (MTK_PIN_NO(84) | 0)
+#define MT2712_PIN_84_GBE_RXC__FUNC_GBE_RXC (MTK_PIN_NO(84) | 1)
+#define MT2712_PIN_84_GBE_RXC__FUNC_DBG_MON_B_13_ (MTK_PIN_NO(84) | 7)
+
+#define MT2712_PIN_85_GBE_MDC__FUNC_GPIO85 (MTK_PIN_NO(85) | 0)
+#define MT2712_PIN_85_GBE_MDC__FUNC_GBE_MDC (MTK_PIN_NO(85) | 1)
+#define MT2712_PIN_85_GBE_MDC__FUNC_DBG_MON_B_14_ (MTK_PIN_NO(85) | 7)
+
+#define MT2712_PIN_86_GBE_MDIO__FUNC_GPIO86 (MTK_PIN_NO(86) | 0)
+#define MT2712_PIN_86_GBE_MDIO__FUNC_GBE_MDIO (MTK_PIN_NO(86) | 1)
+#define MT2712_PIN_86_GBE_MDIO__FUNC_DBG_MON_B_15_ (MTK_PIN_NO(86) | 7)
+
+#define MT2712_PIN_87_GBE_COL__FUNC_GPIO87 (MTK_PIN_NO(87) | 0)
+#define MT2712_PIN_87_GBE_COL__FUNC_GBE_COL (MTK_PIN_NO(87) | 1)
+#define MT2712_PIN_87_GBE_COL__FUNC_DBG_MON_B_16_ (MTK_PIN_NO(87) | 7)
+
+#define MT2712_PIN_88_GBE_INTR__FUNC_GPIO88 (MTK_PIN_NO(88) | 0)
+#define MT2712_PIN_88_GBE_INTR__FUNC_GBE_INTR (MTK_PIN_NO(88) | 1)
+#define MT2712_PIN_88_GBE_INTR__FUNC_GBE_CRS (MTK_PIN_NO(88) | 2)
+#define MT2712_PIN_88_GBE_INTR__FUNC_DBG_MON_B_17_ (MTK_PIN_NO(88) | 7)
+
+#define MT2712_PIN_89_MSDC2_CLK__FUNC_GPIO89 (MTK_PIN_NO(89) | 0)
+#define MT2712_PIN_89_MSDC2_CLK__FUNC_MSDC2_CLK (MTK_PIN_NO(89) | 1)
+#define MT2712_PIN_89_MSDC2_CLK__FUNC_DBG_MON_B_18_ (MTK_PIN_NO(89) | 7)
+
+#define MT2712_PIN_90_MSDC2_DAT3__FUNC_GPIO90 (MTK_PIN_NO(90) | 0)
+#define MT2712_PIN_90_MSDC2_DAT3__FUNC_MSDC2_DAT3 (MTK_PIN_NO(90) | 1)
+#define MT2712_PIN_90_MSDC2_DAT3__FUNC_DBG_MON_B_19_ (MTK_PIN_NO(90) | 7)
+
+#define MT2712_PIN_91_MSDC2_DAT2__FUNC_GPIO91 (MTK_PIN_NO(91) | 0)
+#define MT2712_PIN_91_MSDC2_DAT2__FUNC_MSDC2_DAT2 (MTK_PIN_NO(91) | 1)
+#define MT2712_PIN_91_MSDC2_DAT2__FUNC_DBG_MON_B_20_ (MTK_PIN_NO(91) | 7)
+
+#define MT2712_PIN_92_MSDC2_DAT1__FUNC_GPIO92 (MTK_PIN_NO(92) | 0)
+#define MT2712_PIN_92_MSDC2_DAT1__FUNC_MSDC2_DAT1 (MTK_PIN_NO(92) | 1)
+#define MT2712_PIN_92_MSDC2_DAT1__FUNC_DBG_MON_B_21_ (MTK_PIN_NO(92) | 7)
+
+#define MT2712_PIN_93_MSDC2_DAT0__FUNC_GPIO93 (MTK_PIN_NO(93) | 0)
+#define MT2712_PIN_93_MSDC2_DAT0__FUNC_MSDC2_DAT0 (MTK_PIN_NO(93) | 1)
+#define MT2712_PIN_93_MSDC2_DAT0__FUNC_DBG_MON_B_22_ (MTK_PIN_NO(93) | 7)
+
+#define MT2712_PIN_94_MSDC2_INS__FUNC_GPIO94 (MTK_PIN_NO(94) | 0)
+#define MT2712_PIN_94_MSDC2_INS__FUNC_DBG_MON_B_23_ (MTK_PIN_NO(94) | 7)
+
+#define MT2712_PIN_95_MSDC2_CMD__FUNC_GPIO95 (MTK_PIN_NO(95) | 0)
+#define MT2712_PIN_95_MSDC2_CMD__FUNC_MSDC2_CMD (MTK_PIN_NO(95) | 1)
+#define MT2712_PIN_95_MSDC2_CMD__FUNC_DBG_MON_B_24_ (MTK_PIN_NO(95) | 7)
+
+#define MT2712_PIN_96_MSDC2_PSW__FUNC_GPIO96 (MTK_PIN_NO(96) | 0)
+#define MT2712_PIN_96_MSDC2_PSW__FUNC_DBG_MON_B_25_ (MTK_PIN_NO(96) | 7)
+
+#define MT2712_PIN_97_URXD4__FUNC_GPIO97 (MTK_PIN_NO(97) | 0)
+#define MT2712_PIN_97_URXD4__FUNC_URXD4 (MTK_PIN_NO(97) | 1)
+#define MT2712_PIN_97_URXD4__FUNC_UTXD4 (MTK_PIN_NO(97) | 2)
+#define MT2712_PIN_97_URXD4__FUNC_MRG_CLK (MTK_PIN_NO(97) | 3)
+#define MT2712_PIN_97_URXD4__FUNC_PCM1_CLK (MTK_PIN_NO(97) | 4)
+#define MT2712_PIN_97_URXD4__FUNC_I2S_IQ2_SDQB (MTK_PIN_NO(97) | 5)
+#define MT2712_PIN_97_URXD4__FUNC_I2SO1_WS (MTK_PIN_NO(97) | 6)
+#define MT2712_PIN_97_URXD4__FUNC_DBG_MON_B_26_ (MTK_PIN_NO(97) | 7)
+
+#define MT2712_PIN_98_URTS4__FUNC_GPIO98 (MTK_PIN_NO(98) | 0)
+#define MT2712_PIN_98_URTS4__FUNC_URTS4 (MTK_PIN_NO(98) | 1)
+#define MT2712_PIN_98_URTS4__FUNC_UCTS4 (MTK_PIN_NO(98) | 2)
+#define MT2712_PIN_98_URTS4__FUNC_MRG_RX (MTK_PIN_NO(98) | 3)
+#define MT2712_PIN_98_URTS4__FUNC_PCM1_DI (MTK_PIN_NO(98) | 4)
+#define MT2712_PIN_98_URTS4__FUNC_I2S_IQ1_SDIB (MTK_PIN_NO(98) | 5)
+#define MT2712_PIN_98_URTS4__FUNC_I2SO1_MCK (MTK_PIN_NO(98) | 6)
+#define MT2712_PIN_98_URTS4__FUNC_DBG_MON_B_27_ (MTK_PIN_NO(98) | 7)
+
+#define MT2712_PIN_99_UTXD4__FUNC_GPIO99 (MTK_PIN_NO(99) | 0)
+#define MT2712_PIN_99_UTXD4__FUNC_UTXD4 (MTK_PIN_NO(99) | 1)
+#define MT2712_PIN_99_UTXD4__FUNC_URXD4 (MTK_PIN_NO(99) | 2)
+#define MT2712_PIN_99_UTXD4__FUNC_MRG_SYNC (MTK_PIN_NO(99) | 3)
+#define MT2712_PIN_99_UTXD4__FUNC_PCM1_SYNC (MTK_PIN_NO(99) | 4)
+#define MT2712_PIN_99_UTXD4__FUNC_I2S_IQ0_SDQB (MTK_PIN_NO(99) | 5)
+#define MT2712_PIN_99_UTXD4__FUNC_I2SO1_BCK (MTK_PIN_NO(99) | 6)
+#define MT2712_PIN_99_UTXD4__FUNC_DBG_MON_B_28_ (MTK_PIN_NO(99) | 7)
+
+#define MT2712_PIN_100_UCTS4__FUNC_GPIO100 (MTK_PIN_NO(100) | 0)
+#define MT2712_PIN_100_UCTS4__FUNC_UCTS4 (MTK_PIN_NO(100) | 1)
+#define MT2712_PIN_100_UCTS4__FUNC_URTS4 (MTK_PIN_NO(100) | 2)
+#define MT2712_PIN_100_UCTS4__FUNC_MRG_TX (MTK_PIN_NO(100) | 3)
+#define MT2712_PIN_100_UCTS4__FUNC_PCM1_DO (MTK_PIN_NO(100) | 4)
+#define MT2712_PIN_100_UCTS4__FUNC_I2S_IQ0_SDIB (MTK_PIN_NO(100) | 5)
+#define MT2712_PIN_100_UCTS4__FUNC_I2SO1_DO (MTK_PIN_NO(100) | 6)
+#define MT2712_PIN_100_UCTS4__FUNC_DBG_MON_B_29_ (MTK_PIN_NO(100) | 7)
+
+#define MT2712_PIN_101_URXD5__FUNC_GPIO101 (MTK_PIN_NO(101) | 0)
+#define MT2712_PIN_101_URXD5__FUNC_URXD5 (MTK_PIN_NO(101) | 1)
+#define MT2712_PIN_101_URXD5__FUNC_UTXD5 (MTK_PIN_NO(101) | 2)
+#define MT2712_PIN_101_URXD5__FUNC_I2SO3_WS (MTK_PIN_NO(101) | 3)
+#define MT2712_PIN_101_URXD5__FUNC_TDMIN_LRCK (MTK_PIN_NO(101) | 4)
+#define MT2712_PIN_101_URXD5__FUNC_I2SO0_WS (MTK_PIN_NO(101) | 6)
+#define MT2712_PIN_101_URXD5__FUNC_DBG_MON_B_30_ (MTK_PIN_NO(101) | 7)
+
+#define MT2712_PIN_102_URTS5__FUNC_GPIO102 (MTK_PIN_NO(102) | 0)
+#define MT2712_PIN_102_URTS5__FUNC_URTS5 (MTK_PIN_NO(102) | 1)
+#define MT2712_PIN_102_URTS5__FUNC_UCTS5 (MTK_PIN_NO(102) | 2)
+#define MT2712_PIN_102_URTS5__FUNC_I2SO3_MCK (MTK_PIN_NO(102) | 3)
+#define MT2712_PIN_102_URTS5__FUNC_TDMIN_MCLK (MTK_PIN_NO(102) | 4)
+#define MT2712_PIN_102_URTS5__FUNC_IR_IN (MTK_PIN_NO(102) | 5)
+#define MT2712_PIN_102_URTS5__FUNC_I2SO0_MCK (MTK_PIN_NO(102) | 6)
+#define MT2712_PIN_102_URTS5__FUNC_DBG_MON_B_31_ (MTK_PIN_NO(102) | 7)
+
+#define MT2712_PIN_103_UTXD5__FUNC_GPIO103 (MTK_PIN_NO(103) | 0)
+#define MT2712_PIN_103_UTXD5__FUNC_UTXD5 (MTK_PIN_NO(103) | 1)
+#define MT2712_PIN_103_UTXD5__FUNC_URXD5 (MTK_PIN_NO(103) | 2)
+#define MT2712_PIN_103_UTXD5__FUNC_I2SO3_BCK (MTK_PIN_NO(103) | 3)
+#define MT2712_PIN_103_UTXD5__FUNC_TDMIN_BCK (MTK_PIN_NO(103) | 4)
+#define MT2712_PIN_103_UTXD5__FUNC_I2SO0_BCK (MTK_PIN_NO(103) | 6)
+#define MT2712_PIN_103_UTXD5__FUNC_DBG_MON_B_32_ (MTK_PIN_NO(103) | 7)
+
+#define MT2712_PIN_104_UCTS5__FUNC_GPIO104 (MTK_PIN_NO(104) | 0)
+#define MT2712_PIN_104_UCTS5__FUNC_UCTS5 (MTK_PIN_NO(104) | 1)
+#define MT2712_PIN_104_UCTS5__FUNC_URTS5 (MTK_PIN_NO(104) | 2)
+#define MT2712_PIN_104_UCTS5__FUNC_I2SO0_DO1 (MTK_PIN_NO(104) | 3)
+#define MT2712_PIN_104_UCTS5__FUNC_TDMIN_DI (MTK_PIN_NO(104) | 4)
+#define MT2712_PIN_104_UCTS5__FUNC_IR_IN (MTK_PIN_NO(104) | 5)
+#define MT2712_PIN_104_UCTS5__FUNC_I2SO0_DO0 (MTK_PIN_NO(104) | 6)
+
+#define MT2712_PIN_105_I2C_SDA0__FUNC_GPIO105 (MTK_PIN_NO(105) | 0)
+#define MT2712_PIN_105_I2C_SDA0__FUNC_SDA0 (MTK_PIN_NO(105) | 1)
+
+#define MT2712_PIN_106_I2C_SDA1__FUNC_GPIO106 (MTK_PIN_NO(106) | 0)
+#define MT2712_PIN_106_I2C_SDA1__FUNC_SDA1 (MTK_PIN_NO(106) | 1)
+
+#define MT2712_PIN_107_I2C_SDA2__FUNC_GPIO107 (MTK_PIN_NO(107) | 0)
+#define MT2712_PIN_107_I2C_SDA2__FUNC_SDA2 (MTK_PIN_NO(107) | 1)
+
+#define MT2712_PIN_108_I2C_SDA3__FUNC_GPIO108 (MTK_PIN_NO(108) | 0)
+#define MT2712_PIN_108_I2C_SDA3__FUNC_SDA3 (MTK_PIN_NO(108) | 1)
+
+#define MT2712_PIN_109_I2C_SDA4__FUNC_GPIO109 (MTK_PIN_NO(109) | 0)
+#define MT2712_PIN_109_I2C_SDA4__FUNC_SDA4 (MTK_PIN_NO(109) | 1)
+
+#define MT2712_PIN_110_I2C_SDA5__FUNC_GPIO110 (MTK_PIN_NO(110) | 0)
+#define MT2712_PIN_110_I2C_SDA5__FUNC_SDA5 (MTK_PIN_NO(110) | 1)
+
+#define MT2712_PIN_111_I2C_SCL0__FUNC_GPIO111 (MTK_PIN_NO(111) | 0)
+#define MT2712_PIN_111_I2C_SCL0__FUNC_SCL0 (MTK_PIN_NO(111) | 1)
+
+#define MT2712_PIN_112_I2C_SCL1__FUNC_GPIO112 (MTK_PIN_NO(112) | 0)
+#define MT2712_PIN_112_I2C_SCL1__FUNC_SCL1 (MTK_PIN_NO(112) | 1)
+
+#define MT2712_PIN_113_I2C_SCL2__FUNC_GPIO113 (MTK_PIN_NO(113) | 0)
+#define MT2712_PIN_113_I2C_SCL2__FUNC_SCL2 (MTK_PIN_NO(113) | 1)
+
+#define MT2712_PIN_114_I2C_SCL3__FUNC_GPIO114 (MTK_PIN_NO(114) | 0)
+#define MT2712_PIN_114_I2C_SCL3__FUNC_SCL3 (MTK_PIN_NO(114) | 1)
+
+#define MT2712_PIN_115_I2C_SCL4__FUNC_GPIO115 (MTK_PIN_NO(115) | 0)
+#define MT2712_PIN_115_I2C_SCL4__FUNC_SCL4 (MTK_PIN_NO(115) | 1)
+
+#define MT2712_PIN_116_I2C_SCL5__FUNC_GPIO116 (MTK_PIN_NO(116) | 0)
+#define MT2712_PIN_116_I2C_SCL5__FUNC_SCL5 (MTK_PIN_NO(116) | 1)
+
+#define MT2712_PIN_117_URXD0__FUNC_GPIO117 (MTK_PIN_NO(117) | 0)
+#define MT2712_PIN_117_URXD0__FUNC_URXD0 (MTK_PIN_NO(117) | 1)
+#define MT2712_PIN_117_URXD0__FUNC_UTXD0 (MTK_PIN_NO(117) | 2)
+
+#define MT2712_PIN_118_URXD1__FUNC_GPIO118 (MTK_PIN_NO(118) | 0)
+#define MT2712_PIN_118_URXD1__FUNC_URXD1 (MTK_PIN_NO(118) | 1)
+#define MT2712_PIN_118_URXD1__FUNC_UTXD1 (MTK_PIN_NO(118) | 2)
+
+#define MT2712_PIN_119_URXD2__FUNC_GPIO119 (MTK_PIN_NO(119) | 0)
+#define MT2712_PIN_119_URXD2__FUNC_URXD2 (MTK_PIN_NO(119) | 1)
+#define MT2712_PIN_119_URXD2__FUNC_UTXD2 (MTK_PIN_NO(119) | 2)
+
+#define MT2712_PIN_120_UTXD0__FUNC_GPIO120 (MTK_PIN_NO(120) | 0)
+#define MT2712_PIN_120_UTXD0__FUNC_UTXD0 (MTK_PIN_NO(120) | 1)
+#define MT2712_PIN_120_UTXD0__FUNC_URXD0 (MTK_PIN_NO(120) | 2)
+
+#define MT2712_PIN_121_UTXD1__FUNC_GPIO121 (MTK_PIN_NO(121) | 0)
+#define MT2712_PIN_121_UTXD1__FUNC_UTXD1 (MTK_PIN_NO(121) | 1)
+#define MT2712_PIN_121_UTXD1__FUNC_URXD1 (MTK_PIN_NO(121) | 2)
+
+#define MT2712_PIN_122_UTXD2__FUNC_GPIO122 (MTK_PIN_NO(122) | 0)
+#define MT2712_PIN_122_UTXD2__FUNC_UTXD2 (MTK_PIN_NO(122) | 1)
+#define MT2712_PIN_122_UTXD2__FUNC_URXD2 (MTK_PIN_NO(122) | 2)
+
+#define MT2712_PIN_123_URXD3__FUNC_GPIO123 (MTK_PIN_NO(123) | 0)
+#define MT2712_PIN_123_URXD3__FUNC_URXD3 (MTK_PIN_NO(123) | 1)
+#define MT2712_PIN_123_URXD3__FUNC_UTXD3 (MTK_PIN_NO(123) | 2)
+#define MT2712_PIN_123_URXD3__FUNC_PURE_HW_PROTECT (MTK_PIN_NO(123) | 3)
+
+#define MT2712_PIN_124_UTXD3__FUNC_GPIO124 (MTK_PIN_NO(124) | 0)
+#define MT2712_PIN_124_UTXD3__FUNC_UTXD3 (MTK_PIN_NO(124) | 1)
+#define MT2712_PIN_124_UTXD3__FUNC_URXD3 (MTK_PIN_NO(124) | 2)
+#define MT2712_PIN_124_UTXD3__FUNC_PURE_HW_PROTECT (MTK_PIN_NO(124) | 3)
+
+#define MT2712_PIN_125_URTS3__FUNC_GPIO125 (MTK_PIN_NO(125) | 0)
+#define MT2712_PIN_125_URTS3__FUNC_URTS3 (MTK_PIN_NO(125) | 1)
+#define MT2712_PIN_125_URTS3__FUNC_UCTS3 (MTK_PIN_NO(125) | 2)
+#define MT2712_PIN_125_URTS3__FUNC_WATCH_DOG (MTK_PIN_NO(125) | 3)
+
+#define MT2712_PIN_126_UCTS3__FUNC_GPIO126 (MTK_PIN_NO(126) | 0)
+#define MT2712_PIN_126_UCTS3__FUNC_UCTS3 (MTK_PIN_NO(126) | 1)
+#define MT2712_PIN_126_UCTS3__FUNC_URTS3 (MTK_PIN_NO(126) | 2)
+#define MT2712_PIN_126_UCTS3__FUNC_SRCLKENA0 (MTK_PIN_NO(126) | 3)
+
+#define MT2712_PIN_127_SPI2_CSN__FUNC_GPIO127 (MTK_PIN_NO(127) | 0)
+#define MT2712_PIN_127_SPI2_CSN__FUNC_SPI_CS_2_ (MTK_PIN_NO(127) | 1)
+#define MT2712_PIN_127_SPI2_CSN__FUNC_SPI_CS_1_ (MTK_PIN_NO(127) | 2)
+
+#define MT2712_PIN_128_SPI2_MO__FUNC_GPIO128 (MTK_PIN_NO(128) | 0)
+#define MT2712_PIN_128_SPI2_MO__FUNC_SPI_MO_2_ (MTK_PIN_NO(128) | 1)
+#define MT2712_PIN_128_SPI2_MO__FUNC_SPI_SO_1_ (MTK_PIN_NO(128) | 2)
+
+#define MT2712_PIN_129_SPI2_MI__FUNC_GPIO129 (MTK_PIN_NO(129) | 0)
+#define MT2712_PIN_129_SPI2_MI__FUNC_SPI_MI_2_ (MTK_PIN_NO(129) | 1)
+#define MT2712_PIN_129_SPI2_MI__FUNC_SPI_SI_1_ (MTK_PIN_NO(129) | 2)
+
+#define MT2712_PIN_130_SPI2_CK__FUNC_GPIO130 (MTK_PIN_NO(130) | 0)
+#define MT2712_PIN_130_SPI2_CK__FUNC_SPI_CK_2_ (MTK_PIN_NO(130) | 1)
+#define MT2712_PIN_130_SPI2_CK__FUNC_SPI_CK_1_ (MTK_PIN_NO(130) | 2)
+
+#define MT2712_PIN_131_SPI3_CSN__FUNC_GPIO131 (MTK_PIN_NO(131) | 0)
+#define MT2712_PIN_131_SPI3_CSN__FUNC_SPI_CS_3_ (MTK_PIN_NO(131) | 1)
+
+#define MT2712_PIN_132_SPI3_MO__FUNC_GPIO132 (MTK_PIN_NO(132) | 0)
+#define MT2712_PIN_132_SPI3_MO__FUNC_SPI_MO_3_ (MTK_PIN_NO(132) | 1)
+
+#define MT2712_PIN_133_SPI3_MI__FUNC_GPIO133 (MTK_PIN_NO(133) | 0)
+#define MT2712_PIN_133_SPI3_MI__FUNC_SPI_MI_3_ (MTK_PIN_NO(133) | 1)
+
+#define MT2712_PIN_134_SPI3_CK__FUNC_GPIO134 (MTK_PIN_NO(134) | 0)
+#define MT2712_PIN_134_SPI3_CK__FUNC_SPI_CK_3_ (MTK_PIN_NO(134) | 1)
+
+#define MT2712_PIN_135_KPROW3__FUNC_GPIO135 (MTK_PIN_NO(135) | 0)
+#define MT2712_PIN_135_KPROW3__FUNC_KROW3 (MTK_PIN_NO(135) | 1)
+#define MT2712_PIN_135_KPROW3__FUNC_DSIC_TE (MTK_PIN_NO(135) | 2)
+
+#define MT2712_PIN_136_KPROW4__FUNC_GPIO136 (MTK_PIN_NO(136) | 0)
+#define MT2712_PIN_136_KPROW4__FUNC_KROW4 (MTK_PIN_NO(136) | 1)
+#define MT2712_PIN_136_KPROW4__FUNC_DSID_TE (MTK_PIN_NO(136) | 2)
+
+#define MT2712_PIN_137_KPCOL3__FUNC_GPIO137 (MTK_PIN_NO(137) | 0)
+#define MT2712_PIN_137_KPCOL3__FUNC_KCOL3 (MTK_PIN_NO(137) | 1)
+#define MT2712_PIN_137_KPCOL3__FUNC_DISP2_PWM (MTK_PIN_NO(137) | 2)
+
+#define MT2712_PIN_138_KPCOL4__FUNC_GPIO138 (MTK_PIN_NO(138) | 0)
+#define MT2712_PIN_138_KPCOL4__FUNC_KCOL4 (MTK_PIN_NO(138) | 1)
+#define MT2712_PIN_138_KPCOL4__FUNC_LCM_RST2 (MTK_PIN_NO(138) | 2)
+
+#define MT2712_PIN_139_KPCOL5__FUNC_GPIO139 (MTK_PIN_NO(139) | 0)
+#define MT2712_PIN_139_KPCOL5__FUNC_KCOL5 (MTK_PIN_NO(139) | 1)
+#define MT2712_PIN_139_KPCOL5__FUNC_DSIA_TE (MTK_PIN_NO(139) | 3)
+#define MT2712_PIN_139_KPCOL5__FUNC_PURE_HW_PROTECT (MTK_PIN_NO(139) | 4)
+
+#define MT2712_PIN_140_KPCOL6__FUNC_GPIO140 (MTK_PIN_NO(140) | 0)
+#define MT2712_PIN_140_KPCOL6__FUNC_KCOL6 (MTK_PIN_NO(140) | 1)
+#define MT2712_PIN_140_KPCOL6__FUNC_WATCH_DOG (MTK_PIN_NO(140) | 2)
+#define MT2712_PIN_140_KPCOL6__FUNC_LCM_RST1 (MTK_PIN_NO(140) | 3)
+
+#define MT2712_PIN_141_KPROW5__FUNC_GPIO141 (MTK_PIN_NO(141) | 0)
+#define MT2712_PIN_141_KPROW5__FUNC_KROW5 (MTK_PIN_NO(141) | 1)
+#define MT2712_PIN_141_KPROW5__FUNC_LCM_RST0 (MTK_PIN_NO(141) | 3)
+#define MT2712_PIN_141_KPROW5__FUNC_PURE_HW_PROTECT (MTK_PIN_NO(141) | 4)
+
+#define MT2712_PIN_142_KPROW6__FUNC_GPIO142 (MTK_PIN_NO(142) | 0)
+#define MT2712_PIN_142_KPROW6__FUNC_KROW6 (MTK_PIN_NO(142) | 1)
+#define MT2712_PIN_142_KPROW6__FUNC_SRCLKENA0 (MTK_PIN_NO(142) | 2)
+#define MT2712_PIN_142_KPROW6__FUNC_DSIB_TE (MTK_PIN_NO(142) | 3)
+
+#define MT2712_PIN_143_JTDO_ICE__FUNC_GPIO143 (MTK_PIN_NO(143) | 0)
+#define MT2712_PIN_143_JTDO_ICE__FUNC_JTDO_ICE (MTK_PIN_NO(143) | 1)
+#define MT2712_PIN_143_JTDO_ICE__FUNC_DFD_TDO (MTK_PIN_NO(143) | 3)
+
+#define MT2712_PIN_144_JTCK_ICE__FUNC_GPIO144 (MTK_PIN_NO(144) | 0)
+#define MT2712_PIN_144_JTCK_ICE__FUNC_JTCK_ICE (MTK_PIN_NO(144) | 1)
+#define MT2712_PIN_144_JTCK_ICE__FUNC_DFD_TCK (MTK_PIN_NO(144) | 3)
+
+#define MT2712_PIN_145_JTDI_ICE__FUNC_GPIO145 (MTK_PIN_NO(145) | 0)
+#define MT2712_PIN_145_JTDI_ICE__FUNC_JTDI_ICE (MTK_PIN_NO(145) | 1)
+#define MT2712_PIN_145_JTDI_ICE__FUNC_DFD_TDI (MTK_PIN_NO(145) | 3)
+
+#define MT2712_PIN_146_JTMS_ICE__FUNC_GPIO146 (MTK_PIN_NO(146) | 0)
+#define MT2712_PIN_146_JTMS_ICE__FUNC_JTMS_ICE (MTK_PIN_NO(146) | 1)
+#define MT2712_PIN_146_JTMS_ICE__FUNC_DFD_TMS (MTK_PIN_NO(146) | 3)
+
+#define MT2712_PIN_147_JTRSTB_ICE__FUNC_GPIO147 (MTK_PIN_NO(147) | 0)
+#define MT2712_PIN_147_JTRSTB_ICE__FUNC_JTRST_B_ICE (MTK_PIN_NO(147) | 1)
+#define MT2712_PIN_147_JTRSTB_ICE__FUNC_DFD_NTRST (MTK_PIN_NO(147) | 3)
+
+#define MT2712_PIN_148_GPIO148__FUNC_GPIO148 (MTK_PIN_NO(148) | 0)
+#define MT2712_PIN_148_GPIO148__FUNC_JTRSTB_CM4 (MTK_PIN_NO(148) | 1)
+#define MT2712_PIN_148_GPIO148__FUNC_DFD_NTRST (MTK_PIN_NO(148) | 3)
+
+#define MT2712_PIN_149_GPIO149__FUNC_GPIO149 (MTK_PIN_NO(149) | 0)
+#define MT2712_PIN_149_GPIO149__FUNC_JTCK_CM4 (MTK_PIN_NO(149) | 1)
+#define MT2712_PIN_149_GPIO149__FUNC_DFD_TCK (MTK_PIN_NO(149) | 3)
+
+#define MT2712_PIN_150_GPIO150__FUNC_GPIO150 (MTK_PIN_NO(150) | 0)
+#define MT2712_PIN_150_GPIO150__FUNC_JTMS_CM4 (MTK_PIN_NO(150) | 1)
+#define MT2712_PIN_150_GPIO150__FUNC_DFD_TMS (MTK_PIN_NO(150) | 3)
+
+#define MT2712_PIN_151_GPIO151__FUNC_GPIO151 (MTK_PIN_NO(151) | 0)
+#define MT2712_PIN_151_GPIO151__FUNC_JTDI_CM4 (MTK_PIN_NO(151) | 1)
+#define MT2712_PIN_151_GPIO151__FUNC_DFD_TDI (MTK_PIN_NO(151) | 3)
+
+#define MT2712_PIN_152_GPIO152__FUNC_GPIO152 (MTK_PIN_NO(152) | 0)
+#define MT2712_PIN_152_GPIO152__FUNC_JTDO_CM4 (MTK_PIN_NO(152) | 1)
+#define MT2712_PIN_152_GPIO152__FUNC_DFD_TDO (MTK_PIN_NO(152) | 3)
+
+#define MT2712_PIN_153_SPI0_CSN__FUNC_GPIO153 (MTK_PIN_NO(153) | 0)
+#define MT2712_PIN_153_SPI0_CSN__FUNC_SPI_CS_0_ (MTK_PIN_NO(153) | 1)
+#define MT2712_PIN_153_SPI0_CSN__FUNC_SRCLKENA0 (MTK_PIN_NO(153) | 2)
+#define MT2712_PIN_153_SPI0_CSN__FUNC_UTXD0 (MTK_PIN_NO(153) | 3)
+#define MT2712_PIN_153_SPI0_CSN__FUNC_I2SO0_DO1 (MTK_PIN_NO(153) | 4)
+#define MT2712_PIN_153_SPI0_CSN__FUNC_TDMO0_DATA1 (MTK_PIN_NO(153) | 6)
+#define MT2712_PIN_153_SPI0_CSN__FUNC_I2S_IQ2_SDQB (MTK_PIN_NO(153) | 7)
+
+#define MT2712_PIN_154_SPI0_MI__FUNC_GPIO154 (MTK_PIN_NO(154) | 0)
+#define MT2712_PIN_154_SPI0_MI__FUNC_SPI_MI_0_ (MTK_PIN_NO(154) | 1)
+#define MT2712_PIN_154_SPI0_MI__FUNC_SRCLKENA0 (MTK_PIN_NO(154) | 2)
+#define MT2712_PIN_154_SPI0_MI__FUNC_URXD0 (MTK_PIN_NO(154) | 3)
+#define MT2712_PIN_154_SPI0_MI__FUNC_I2SO0_DO0 (MTK_PIN_NO(154) | 4)
+#define MT2712_PIN_154_SPI0_MI__FUNC_I2SO1_DO (MTK_PIN_NO(154) | 5)
+#define MT2712_PIN_154_SPI0_MI__FUNC_TDMO0_DATA (MTK_PIN_NO(154) | 6)
+#define MT2712_PIN_154_SPI0_MI__FUNC_I2S_IQ1_SDIB (MTK_PIN_NO(154) | 7)
+
+#define MT2712_PIN_155_SPI0_CK__FUNC_GPIO155 (MTK_PIN_NO(155) | 0)
+#define MT2712_PIN_155_SPI0_CK__FUNC_SPI_CK_0_ (MTK_PIN_NO(155) | 1)
+#define MT2712_PIN_155_SPI0_CK__FUNC_SC_APBIAS_OFF (MTK_PIN_NO(155) | 2)
+#define MT2712_PIN_155_SPI0_CK__FUNC_UTXD1 (MTK_PIN_NO(155) | 3)
+#define MT2712_PIN_155_SPI0_CK__FUNC_I2SO0_BCK (MTK_PIN_NO(155) | 4)
+#define MT2712_PIN_155_SPI0_CK__FUNC_I2SO1_BCK (MTK_PIN_NO(155) | 5)
+#define MT2712_PIN_155_SPI0_CK__FUNC_TDMO0_BCK (MTK_PIN_NO(155) | 6)
+#define MT2712_PIN_155_SPI0_CK__FUNC_I2S_IQ0_SDQB (MTK_PIN_NO(155) | 7)
+
+#define MT2712_PIN_156_SPI0_MO__FUNC_GPIO156 (MTK_PIN_NO(156) | 0)
+#define MT2712_PIN_156_SPI0_MO__FUNC_SPI_MO_0_ (MTK_PIN_NO(156) | 1)
+#define MT2712_PIN_156_SPI0_MO__FUNC_SC_APBIAS_OFF (MTK_PIN_NO(156) | 2)
+#define MT2712_PIN_156_SPI0_MO__FUNC_URXD1 (MTK_PIN_NO(156) | 3)
+#define MT2712_PIN_156_SPI0_MO__FUNC_I2SO0_WS (MTK_PIN_NO(156) | 4)
+#define MT2712_PIN_156_SPI0_MO__FUNC_I2SO1_WS (MTK_PIN_NO(156) | 5)
+#define MT2712_PIN_156_SPI0_MO__FUNC_TDMO0_LRCK (MTK_PIN_NO(156) | 6)
+#define MT2712_PIN_156_SPI0_MO__FUNC_I2S_IQ0_SDIB (MTK_PIN_NO(156) | 7)
+
+#define MT2712_PIN_157_SPI5_CSN__FUNC_GPIO157 (MTK_PIN_NO(157) | 0)
+#define MT2712_PIN_157_SPI5_CSN__FUNC_SPI_CS_5_ (MTK_PIN_NO(157) | 1)
+#define MT2712_PIN_157_SPI5_CSN__FUNC_LCM_RST0 (MTK_PIN_NO(157) | 2)
+#define MT2712_PIN_157_SPI5_CSN__FUNC_UTXD2 (MTK_PIN_NO(157) | 3)
+#define MT2712_PIN_157_SPI5_CSN__FUNC_I2SO0_MCK (MTK_PIN_NO(157) | 4)
+#define MT2712_PIN_157_SPI5_CSN__FUNC_I2SO1_MCK (MTK_PIN_NO(157) | 5)
+#define MT2712_PIN_157_SPI5_CSN__FUNC_TDMO0_MCLK (MTK_PIN_NO(157) | 6)
+
+#define MT2712_PIN_158_SPI5_MI__FUNC_GPIO158 (MTK_PIN_NO(158) | 0)
+#define MT2712_PIN_158_SPI5_MI__FUNC_SPI_MI_5_ (MTK_PIN_NO(158) | 1)
+#define MT2712_PIN_158_SPI5_MI__FUNC_DSIA_TE (MTK_PIN_NO(158) | 2)
+#define MT2712_PIN_158_SPI5_MI__FUNC_URXD2 (MTK_PIN_NO(158) | 3)
+
+#define MT2712_PIN_159_SPI5_MO__FUNC_GPIO159 (MTK_PIN_NO(159) | 0)
+#define MT2712_PIN_159_SPI5_MO__FUNC_SPI_MO_5_ (MTK_PIN_NO(159) | 1)
+#define MT2712_PIN_159_SPI5_MO__FUNC_DSIB_TE (MTK_PIN_NO(159) | 2)
+#define MT2712_PIN_159_SPI5_MO__FUNC_UTXD3 (MTK_PIN_NO(159) | 3)
+
+#define MT2712_PIN_160_SPI5_CK__FUNC_GPIO160 (MTK_PIN_NO(160) | 0)
+#define MT2712_PIN_160_SPI5_CK__FUNC_SPI_CK_5_ (MTK_PIN_NO(160) | 1)
+#define MT2712_PIN_160_SPI5_CK__FUNC_LCM_RST1 (MTK_PIN_NO(160) | 2)
+#define MT2712_PIN_160_SPI5_CK__FUNC_URXD3 (MTK_PIN_NO(160) | 3)
+
+#define MT2712_PIN_161_SPI1_CSN__FUNC_GPIO161 (MTK_PIN_NO(161) | 0)
+#define MT2712_PIN_161_SPI1_CSN__FUNC_SPI_CS_1_ (MTK_PIN_NO(161) | 1)
+#define MT2712_PIN_161_SPI1_CSN__FUNC_SPI_CS_4_ (MTK_PIN_NO(161) | 2)
+#define MT2712_PIN_161_SPI1_CSN__FUNC_I2S_IQ2_SDQB (MTK_PIN_NO(161) | 4)
+#define MT2712_PIN_161_SPI1_CSN__FUNC_I2SO2_DO (MTK_PIN_NO(161) | 5)
+#define MT2712_PIN_161_SPI1_CSN__FUNC_TDMO0_DATA1 (MTK_PIN_NO(161) | 6)
+#define MT2712_PIN_161_SPI1_CSN__FUNC_I2SO0_DO1 (MTK_PIN_NO(161) | 7)
+
+#define MT2712_PIN_162_SPI1_SI__FUNC_GPIO162 (MTK_PIN_NO(162) | 0)
+#define MT2712_PIN_162_SPI1_SI__FUNC_SPI_SI_1_ (MTK_PIN_NO(162) | 1)
+#define MT2712_PIN_162_SPI1_SI__FUNC_SPI_MI_4_ (MTK_PIN_NO(162) | 2)
+#define MT2712_PIN_162_SPI1_SI__FUNC_I2S_IQ1_SDIB (MTK_PIN_NO(162) | 4)
+#define MT2712_PIN_162_SPI1_SI__FUNC_I2SO2_BCK (MTK_PIN_NO(162) | 5)
+#define MT2712_PIN_162_SPI1_SI__FUNC_TDMO0_DATA (MTK_PIN_NO(162) | 6)
+#define MT2712_PIN_162_SPI1_SI__FUNC_I2SO0_DO0 (MTK_PIN_NO(162) | 7)
+
+#define MT2712_PIN_163_SPI1_CK__FUNC_GPIO163 (MTK_PIN_NO(163) | 0)
+#define MT2712_PIN_163_SPI1_CK__FUNC_SPI_CK_1_ (MTK_PIN_NO(163) | 1)
+#define MT2712_PIN_163_SPI1_CK__FUNC_SPI_CK_4_ (MTK_PIN_NO(163) | 2)
+#define MT2712_PIN_163_SPI1_CK__FUNC_I2S_IQ0_SDQB (MTK_PIN_NO(163) | 4)
+#define MT2712_PIN_163_SPI1_CK__FUNC_I2SO2_WS (MTK_PIN_NO(163) | 5)
+#define MT2712_PIN_163_SPI1_CK__FUNC_TDMO0_BCK (MTK_PIN_NO(163) | 6)
+#define MT2712_PIN_163_SPI1_CK__FUNC_I2SO0_BCK (MTK_PIN_NO(163) | 7)
+
+#define MT2712_PIN_164_SPI1_SO__FUNC_GPIO164 (MTK_PIN_NO(164) | 0)
+#define MT2712_PIN_164_SPI1_SO__FUNC_SPI_SO_1_ (MTK_PIN_NO(164) | 1)
+#define MT2712_PIN_164_SPI1_SO__FUNC_SPI_MO_4_ (MTK_PIN_NO(164) | 2)
+#define MT2712_PIN_164_SPI1_SO__FUNC_I2S_IQ0_SDIB (MTK_PIN_NO(164) | 4)
+#define MT2712_PIN_164_SPI1_SO__FUNC_I2SO2_MCK (MTK_PIN_NO(164) | 5)
+#define MT2712_PIN_164_SPI1_SO__FUNC_TDMO0_LRCK (MTK_PIN_NO(164) | 6)
+#define MT2712_PIN_164_SPI1_SO__FUNC_I2SO0_WS (MTK_PIN_NO(164) | 7)
+
+#define MT2712_PIN_165_SPI4_CSN__FUNC_GPIO165 (MTK_PIN_NO(165) | 0)
+#define MT2712_PIN_165_SPI4_CSN__FUNC_SPI_CS_4_ (MTK_PIN_NO(165) | 1)
+#define MT2712_PIN_165_SPI4_CSN__FUNC_LCM_RST0 (MTK_PIN_NO(165) | 2)
+#define MT2712_PIN_165_SPI4_CSN__FUNC_SPI_CS_1_ (MTK_PIN_NO(165) | 3)
+#define MT2712_PIN_165_SPI4_CSN__FUNC_UTXD4 (MTK_PIN_NO(165) | 4)
+#define MT2712_PIN_165_SPI4_CSN__FUNC_I2SO1_DO (MTK_PIN_NO(165) | 5)
+#define MT2712_PIN_165_SPI4_CSN__FUNC_TDMO0_MCLK (MTK_PIN_NO(165) | 6)
+#define MT2712_PIN_165_SPI4_CSN__FUNC_I2SO0_MCK (MTK_PIN_NO(165) | 7)
+
+#define MT2712_PIN_166_SPI4_MI__FUNC_GPIO166 (MTK_PIN_NO(166) | 0)
+#define MT2712_PIN_166_SPI4_MI__FUNC_SPI_MI_4_ (MTK_PIN_NO(166) | 1)
+#define MT2712_PIN_166_SPI4_MI__FUNC_DSIA_TE (MTK_PIN_NO(166) | 2)
+#define MT2712_PIN_166_SPI4_MI__FUNC_SPI_SI_1_ (MTK_PIN_NO(166) | 3)
+#define MT2712_PIN_166_SPI4_MI__FUNC_URXD4 (MTK_PIN_NO(166) | 4)
+#define MT2712_PIN_166_SPI4_MI__FUNC_I2SO1_BCK (MTK_PIN_NO(166) | 5)
+
+#define MT2712_PIN_167_SPI4_MO__FUNC_GPIO167 (MTK_PIN_NO(167) | 0)
+#define MT2712_PIN_167_SPI4_MO__FUNC_SPI_MO_4_ (MTK_PIN_NO(167) | 1)
+#define MT2712_PIN_167_SPI4_MO__FUNC_DSIB_TE (MTK_PIN_NO(167) | 2)
+#define MT2712_PIN_167_SPI4_MO__FUNC_SPI_SO_1_ (MTK_PIN_NO(167) | 3)
+#define MT2712_PIN_167_SPI4_MO__FUNC_UTXD5 (MTK_PIN_NO(167) | 4)
+#define MT2712_PIN_167_SPI4_MO__FUNC_I2SO1_WS (MTK_PIN_NO(167) | 5)
+
+#define MT2712_PIN_168_SPI4_CK__FUNC_GPIO168 (MTK_PIN_NO(168) | 0)
+#define MT2712_PIN_168_SPI4_CK__FUNC_SPI_CK_4_ (MTK_PIN_NO(168) | 1)
+#define MT2712_PIN_168_SPI4_CK__FUNC_LCM_RST1 (MTK_PIN_NO(168) | 2)
+#define MT2712_PIN_168_SPI4_CK__FUNC_SPI_CK_1_ (MTK_PIN_NO(168) | 3)
+#define MT2712_PIN_168_SPI4_CK__FUNC_URXD5 (MTK_PIN_NO(168) | 4)
+#define MT2712_PIN_168_SPI4_CK__FUNC_I2SO1_MCK (MTK_PIN_NO(168) | 5)
+
+#define MT2712_PIN_169_I2SI0_DATA__FUNC_GPIO169 (MTK_PIN_NO(169) | 0)
+#define MT2712_PIN_169_I2SI0_DATA__FUNC_I2SI0_DI (MTK_PIN_NO(169) | 1)
+#define MT2712_PIN_169_I2SI0_DATA__FUNC_I2SI1_DI (MTK_PIN_NO(169) | 2)
+#define MT2712_PIN_169_I2SI0_DATA__FUNC_I2SI2_DI (MTK_PIN_NO(169) | 3)
+#define MT2712_PIN_169_I2SI0_DATA__FUNC_TDMIN_DI (MTK_PIN_NO(169) | 4)
+
+#define MT2712_PIN_170_I2SI0_LRCK__FUNC_GPIO170 (MTK_PIN_NO(170) | 0)
+#define MT2712_PIN_170_I2SI0_LRCK__FUNC_I2SI0_WS (MTK_PIN_NO(170) | 1)
+#define MT2712_PIN_170_I2SI0_LRCK__FUNC_I2SI1_WS (MTK_PIN_NO(170) | 2)
+#define MT2712_PIN_170_I2SI0_LRCK__FUNC_I2SI2_WS (MTK_PIN_NO(170) | 3)
+#define MT2712_PIN_170_I2SI0_LRCK__FUNC_TDMIN_LRCK (MTK_PIN_NO(170) | 4)
+#define MT2712_PIN_170_I2SI0_LRCK__FUNC_TDMO0_DATA3 (MTK_PIN_NO(170) | 5)
+#define MT2712_PIN_170_I2SI0_LRCK__FUNC_TDMO1_DATA3 (MTK_PIN_NO(170) | 6)
+
+#define MT2712_PIN_171_I2SI0_MCLK__FUNC_GPIO171 (MTK_PIN_NO(171) | 0)
+#define MT2712_PIN_171_I2SI0_MCLK__FUNC_I2SI0_MCK (MTK_PIN_NO(171) | 1)
+#define MT2712_PIN_171_I2SI0_MCLK__FUNC_I2SI1_MCK (MTK_PIN_NO(171) | 2)
+#define MT2712_PIN_171_I2SI0_MCLK__FUNC_I2SI2_MCK (MTK_PIN_NO(171) | 3)
+#define MT2712_PIN_171_I2SI0_MCLK__FUNC_TDMIN_MCLK (MTK_PIN_NO(171) | 4)
+#define MT2712_PIN_171_I2SI0_MCLK__FUNC_TDMO0_DATA2 (MTK_PIN_NO(171) | 5)
+#define MT2712_PIN_171_I2SI0_MCLK__FUNC_TDMO1_DATA2 (MTK_PIN_NO(171) | 6)
+
+#define MT2712_PIN_172_I2SI0_BCK__FUNC_GPIO172 (MTK_PIN_NO(172) | 0)
+#define MT2712_PIN_172_I2SI0_BCK__FUNC_I2SI0_BCK (MTK_PIN_NO(172) | 1)
+#define MT2712_PIN_172_I2SI0_BCK__FUNC_I2SI1_BCK (MTK_PIN_NO(172) | 2)
+#define MT2712_PIN_172_I2SI0_BCK__FUNC_I2SI2_BCK (MTK_PIN_NO(172) | 3)
+#define MT2712_PIN_172_I2SI0_BCK__FUNC_TDMIN_BCK (MTK_PIN_NO(172) | 4)
+#define MT2712_PIN_172_I2SI0_BCK__FUNC_TDMO0_DATA1 (MTK_PIN_NO(172) | 5)
+#define MT2712_PIN_172_I2SI0_BCK__FUNC_TDMO1_DATA1 (MTK_PIN_NO(172) | 6)
+
+#define MT2712_PIN_173_I2SI2_DATA__FUNC_GPIO173 (MTK_PIN_NO(173) | 0)
+#define MT2712_PIN_173_I2SI2_DATA__FUNC_I2SI2_DI (MTK_PIN_NO(173) | 1)
+#define MT2712_PIN_173_I2SI2_DATA__FUNC_I2SI0_DI (MTK_PIN_NO(173) | 2)
+#define MT2712_PIN_173_I2SI2_DATA__FUNC_I2SI1_DI (MTK_PIN_NO(173) | 3)
+#define MT2712_PIN_173_I2SI2_DATA__FUNC_PCM1_DI (MTK_PIN_NO(173) | 4)
+#define MT2712_PIN_173_I2SI2_DATA__FUNC_TDMIN_DI (MTK_PIN_NO(173) | 5)
+#define MT2712_PIN_173_I2SI2_DATA__FUNC_PCM1_DO (MTK_PIN_NO(173) | 6)
+
+#define MT2712_PIN_174_I2SI2_MCLK__FUNC_GPIO174 (MTK_PIN_NO(174) | 0)
+#define MT2712_PIN_174_I2SI2_MCLK__FUNC_I2SI2_MCK (MTK_PIN_NO(174) | 1)
+#define MT2712_PIN_174_I2SI2_MCLK__FUNC_I2SI0_MCK (MTK_PIN_NO(174) | 2)
+#define MT2712_PIN_174_I2SI2_MCLK__FUNC_I2SI1_MCK (MTK_PIN_NO(174) | 3)
+#define MT2712_PIN_174_I2SI2_MCLK__FUNC_PCM1_DO (MTK_PIN_NO(174) | 4)
+#define MT2712_PIN_174_I2SI2_MCLK__FUNC_TDMIN_MCLK (MTK_PIN_NO(174) | 5)
+#define MT2712_PIN_174_I2SI2_MCLK__FUNC_PCM1_DI (MTK_PIN_NO(174) | 6)
+#define MT2712_PIN_174_I2SI2_MCLK__FUNC_I2S_IQ2_SDQB (MTK_PIN_NO(174) | 7)
+
+#define MT2712_PIN_175_I2SI2_BCK__FUNC_GPIO175 (MTK_PIN_NO(175) | 0)
+#define MT2712_PIN_175_I2SI2_BCK__FUNC_I2SI2_BCK (MTK_PIN_NO(175) | 1)
+#define MT2712_PIN_175_I2SI2_BCK__FUNC_I2SI0_BCK (MTK_PIN_NO(175) | 2)
+#define MT2712_PIN_175_I2SI2_BCK__FUNC_I2SI1_BCK (MTK_PIN_NO(175) | 3)
+#define MT2712_PIN_175_I2SI2_BCK__FUNC_PCM1_CLK (MTK_PIN_NO(175) | 4)
+#define MT2712_PIN_175_I2SI2_BCK__FUNC_TDMIN_BCK (MTK_PIN_NO(175) | 5)
+
+#define MT2712_PIN_176_I2SI2_LRCK__FUNC_GPIO176 (MTK_PIN_NO(176) | 0)
+#define MT2712_PIN_176_I2SI2_LRCK__FUNC_I2SI2_WS (MTK_PIN_NO(176) | 1)
+#define MT2712_PIN_176_I2SI2_LRCK__FUNC_I2SI0_WS (MTK_PIN_NO(176) | 2)
+#define MT2712_PIN_176_I2SI2_LRCK__FUNC_I2SI1_WS (MTK_PIN_NO(176) | 3)
+#define MT2712_PIN_176_I2SI2_LRCK__FUNC_PCM1_SYNC (MTK_PIN_NO(176) | 4)
+#define MT2712_PIN_176_I2SI2_LRCK__FUNC_TDMIN_LRCK (MTK_PIN_NO(176) | 5)
+
+#define MT2712_PIN_177_I2SI1_DATA__FUNC_GPIO177 (MTK_PIN_NO(177) | 0)
+#define MT2712_PIN_177_I2SI1_DATA__FUNC_I2SI1_DI (MTK_PIN_NO(177) | 1)
+#define MT2712_PIN_177_I2SI1_DATA__FUNC_I2SI0_DI (MTK_PIN_NO(177) | 2)
+#define MT2712_PIN_177_I2SI1_DATA__FUNC_I2SI2_DI (MTK_PIN_NO(177) | 3)
+#define MT2712_PIN_177_I2SI1_DATA__FUNC_TDMIN_DI (MTK_PIN_NO(177) | 4)
+
+#define MT2712_PIN_178_I2SI1_BCK__FUNC_GPIO178 (MTK_PIN_NO(178) | 0)
+#define MT2712_PIN_178_I2SI1_BCK__FUNC_I2SI1_BCK (MTK_PIN_NO(178) | 1)
+#define MT2712_PIN_178_I2SI1_BCK__FUNC_I2SI0_BCK (MTK_PIN_NO(178) | 2)
+#define MT2712_PIN_178_I2SI1_BCK__FUNC_I2SI2_BCK (MTK_PIN_NO(178) | 3)
+#define MT2712_PIN_178_I2SI1_BCK__FUNC_TDMIN_BCK (MTK_PIN_NO(178) | 4)
+#define MT2712_PIN_178_I2SI1_BCK__FUNC_TDMO0_DATA3 (MTK_PIN_NO(178) | 5)
+#define MT2712_PIN_178_I2SI1_BCK__FUNC_TDMO1_DATA3 (MTK_PIN_NO(178) | 6)
+
+#define MT2712_PIN_179_I2SI1_LRCK__FUNC_GPIO179 (MTK_PIN_NO(179) | 0)
+#define MT2712_PIN_179_I2SI1_LRCK__FUNC_I2SI1_WS (MTK_PIN_NO(179) | 1)
+#define MT2712_PIN_179_I2SI1_LRCK__FUNC_I2SI0_WS (MTK_PIN_NO(179) | 2)
+#define MT2712_PIN_179_I2SI1_LRCK__FUNC_I2SI2_WS (MTK_PIN_NO(179) | 3)
+#define MT2712_PIN_179_I2SI1_LRCK__FUNC_TDMIN_LRCK (MTK_PIN_NO(179) | 4)
+#define MT2712_PIN_179_I2SI1_LRCK__FUNC_TDMO0_DATA2 (MTK_PIN_NO(179) | 5)
+#define MT2712_PIN_179_I2SI1_LRCK__FUNC_TDMO1_DATA2 (MTK_PIN_NO(179) | 6)
+
+#define MT2712_PIN_180_I2SI1_MCLK__FUNC_GPIO180 (MTK_PIN_NO(180) | 0)
+#define MT2712_PIN_180_I2SI1_MCLK__FUNC_I2SI1_MCK (MTK_PIN_NO(180) | 1)
+#define MT2712_PIN_180_I2SI1_MCLK__FUNC_I2SI0_MCK (MTK_PIN_NO(180) | 2)
+#define MT2712_PIN_180_I2SI1_MCLK__FUNC_I2SI2_MCK (MTK_PIN_NO(180) | 3)
+#define MT2712_PIN_180_I2SI1_MCLK__FUNC_TDMIN_MCLK (MTK_PIN_NO(180) | 4)
+#define MT2712_PIN_180_I2SI1_MCLK__FUNC_TDMO0_DATA1 (MTK_PIN_NO(180) | 5)
+#define MT2712_PIN_180_I2SI1_MCLK__FUNC_TDMO1_DATA1 (MTK_PIN_NO(180) | 6)
+#define MT2712_PIN_180_I2SI1_MCLK__FUNC_I2S_IQ2_SDIB (MTK_PIN_NO(180) | 7)
+
+#define MT2712_PIN_181_I2SO1_DATA0__FUNC_GPIO181 (MTK_PIN_NO(181) | 0)
+#define MT2712_PIN_181_I2SO1_DATA0__FUNC_I2SO1_DO (MTK_PIN_NO(181) | 1)
+#define MT2712_PIN_181_I2SO1_DATA0__FUNC_I2SO0_DO0 (MTK_PIN_NO(181) | 2)
+#define MT2712_PIN_181_I2SO1_DATA0__FUNC_I2SO2_DO (MTK_PIN_NO(181) | 3)
+#define MT2712_PIN_181_I2SO1_DATA0__FUNC_DAI_TX (MTK_PIN_NO(181) | 4)
+#define MT2712_PIN_181_I2SO1_DATA0__FUNC_TDMIN_MCLK (MTK_PIN_NO(181) | 5)
+#define MT2712_PIN_181_I2SO1_DATA0__FUNC_I2S_IQ2_SDIA (MTK_PIN_NO(181) | 7)
+
+#define MT2712_PIN_182_I2SO1_BCK__FUNC_GPIO182 (MTK_PIN_NO(182) | 0)
+#define MT2712_PIN_182_I2SO1_BCK__FUNC_I2SO1_BCK (MTK_PIN_NO(182) | 1)
+#define MT2712_PIN_182_I2SO1_BCK__FUNC_I2SO0_BCK (MTK_PIN_NO(182) | 2)
+#define MT2712_PIN_182_I2SO1_BCK__FUNC_I2SO2_BCK (MTK_PIN_NO(182) | 3)
+#define MT2712_PIN_182_I2SO1_BCK__FUNC_DAI_SYNC (MTK_PIN_NO(182) | 4)
+#define MT2712_PIN_182_I2SO1_BCK__FUNC_TDMIN_BCK (MTK_PIN_NO(182) | 5)
+#define MT2712_PIN_182_I2SO1_BCK__FUNC_TDMO0_DATA3 (MTK_PIN_NO(182) | 6)
+#define MT2712_PIN_182_I2SO1_BCK__FUNC_I2S_IQ2_BCK (MTK_PIN_NO(182) | 7)
+
+#define MT2712_PIN_183_I2SO1_LRCK__FUNC_GPIO183 (MTK_PIN_NO(183) | 0)
+#define MT2712_PIN_183_I2SO1_LRCK__FUNC_I2SO1_WS (MTK_PIN_NO(183) | 1)
+#define MT2712_PIN_183_I2SO1_LRCK__FUNC_I2SO0_WS (MTK_PIN_NO(183) | 2)
+#define MT2712_PIN_183_I2SO1_LRCK__FUNC_I2SO2_WS (MTK_PIN_NO(183) | 3)
+#define MT2712_PIN_183_I2SO1_LRCK__FUNC_DAI_CLK (MTK_PIN_NO(183) | 4)
+#define MT2712_PIN_183_I2SO1_LRCK__FUNC_TDMIN_DI (MTK_PIN_NO(183) | 5)
+#define MT2712_PIN_183_I2SO1_LRCK__FUNC_TDMO0_DATA2 (MTK_PIN_NO(183) | 6)
+#define MT2712_PIN_183_I2SO1_LRCK__FUNC_I2S_IQ2_WS (MTK_PIN_NO(183) | 7)
+
+#define MT2712_PIN_184_I2SO1_MCLK__FUNC_GPIO184 (MTK_PIN_NO(184) | 0)
+#define MT2712_PIN_184_I2SO1_MCLK__FUNC_I2SO1_MCK (MTK_PIN_NO(184) | 1)
+#define MT2712_PIN_184_I2SO1_MCLK__FUNC_I2SO0_MCK (MTK_PIN_NO(184) | 2)
+#define MT2712_PIN_184_I2SO1_MCLK__FUNC_I2SO2_MCK (MTK_PIN_NO(184) | 3)
+#define MT2712_PIN_184_I2SO1_MCLK__FUNC_DAI_RX (MTK_PIN_NO(184) | 4)
+#define MT2712_PIN_184_I2SO1_MCLK__FUNC_TDMIN_LRCK (MTK_PIN_NO(184) | 5)
+#define MT2712_PIN_184_I2SO1_MCLK__FUNC_TDMO0_DATA1 (MTK_PIN_NO(184) | 6)
+#define MT2712_PIN_184_I2SO1_MCLK__FUNC_I2S_IQ2_SDQA (MTK_PIN_NO(184) | 7)
+
+#define MT2712_PIN_185_AUD_EXT_CK2__FUNC_GPIO185 (MTK_PIN_NO(185) | 0)
+#define MT2712_PIN_185_AUD_EXT_CK2__FUNC_AUD_EXT_CK2 (MTK_PIN_NO(185) | 1)
+#define MT2712_PIN_185_AUD_EXT_CK2__FUNC_AUD_EXT_CK1 (MTK_PIN_NO(185) | 2)
+#define MT2712_PIN_185_AUD_EXT_CK2__FUNC_I2SO1_DO (MTK_PIN_NO(185) | 3)
+#define MT2712_PIN_185_AUD_EXT_CK2__FUNC_I2SI2_DI (MTK_PIN_NO(185) | 4)
+#define MT2712_PIN_185_AUD_EXT_CK2__FUNC_MRG_RX (MTK_PIN_NO(185) | 5)
+#define MT2712_PIN_185_AUD_EXT_CK2__FUNC_PCM1_DI (MTK_PIN_NO(185) | 6)
+#define MT2712_PIN_185_AUD_EXT_CK2__FUNC_I2S_IQ0_SDQB (MTK_PIN_NO(185) | 7)
+
+#define MT2712_PIN_186_AUD_EXT_CK1__FUNC_GPIO186 (MTK_PIN_NO(186) | 0)
+#define MT2712_PIN_186_AUD_EXT_CK1__FUNC_AUD_EXT_CK1 (MTK_PIN_NO(186) | 1)
+#define MT2712_PIN_186_AUD_EXT_CK1__FUNC_AUD_EXT_CK2 (MTK_PIN_NO(186) | 2)
+#define MT2712_PIN_186_AUD_EXT_CK1__FUNC_I2SO0_DO1 (MTK_PIN_NO(186) | 3)
+#define MT2712_PIN_186_AUD_EXT_CK1__FUNC_I2SI1_DI (MTK_PIN_NO(186) | 4)
+#define MT2712_PIN_186_AUD_EXT_CK1__FUNC_MRG_TX (MTK_PIN_NO(186) | 5)
+#define MT2712_PIN_186_AUD_EXT_CK1__FUNC_PCM1_DO (MTK_PIN_NO(186) | 6)
+#define MT2712_PIN_186_AUD_EXT_CK1__FUNC_I2S_IQ0_SDIB (MTK_PIN_NO(186) | 7)
+
+#define MT2712_PIN_187_I2SO2_BCK__FUNC_GPIO187 (MTK_PIN_NO(187) | 0)
+#define MT2712_PIN_187_I2SO2_BCK__FUNC_I2SO2_BCK (MTK_PIN_NO(187) | 1)
+#define MT2712_PIN_187_I2SO2_BCK__FUNC_I2SO0_BCK (MTK_PIN_NO(187) | 2)
+#define MT2712_PIN_187_I2SO2_BCK__FUNC_I2SO1_BCK (MTK_PIN_NO(187) | 3)
+#define MT2712_PIN_187_I2SO2_BCK__FUNC_PCM1_CLK (MTK_PIN_NO(187) | 4)
+#define MT2712_PIN_187_I2SO2_BCK__FUNC_MRG_SYNC (MTK_PIN_NO(187) | 5)
+#define MT2712_PIN_187_I2SO2_BCK__FUNC_TDMO1_DATA3 (MTK_PIN_NO(187) | 6)
+#define MT2712_PIN_187_I2SO2_BCK__FUNC_I2S_IQ0_BCK (MTK_PIN_NO(187) | 7)
+
+#define MT2712_PIN_188_I2SO2_LRCK__FUNC_GPIO188 (MTK_PIN_NO(188) | 0)
+#define MT2712_PIN_188_I2SO2_LRCK__FUNC_I2SO2_WS (MTK_PIN_NO(188) | 1)
+#define MT2712_PIN_188_I2SO2_LRCK__FUNC_I2SO0_WS (MTK_PIN_NO(188) | 2)
+#define MT2712_PIN_188_I2SO2_LRCK__FUNC_I2SO1_WS (MTK_PIN_NO(188) | 3)
+#define MT2712_PIN_188_I2SO2_LRCK__FUNC_PCM1_SYNC (MTK_PIN_NO(188) | 4)
+#define MT2712_PIN_188_I2SO2_LRCK__FUNC_MRG_CLK (MTK_PIN_NO(188) | 5)
+#define MT2712_PIN_188_I2SO2_LRCK__FUNC_TDMO1_DATA2 (MTK_PIN_NO(188) | 6)
+#define MT2712_PIN_188_I2SO2_LRCK__FUNC_I2S_IQ0_WS (MTK_PIN_NO(188) | 7)
+
+#define MT2712_PIN_189_I2SO2_MCLK__FUNC_GPIO189 (MTK_PIN_NO(189) | 0)
+#define MT2712_PIN_189_I2SO2_MCLK__FUNC_I2SO2_MCK (MTK_PIN_NO(189) | 1)
+#define MT2712_PIN_189_I2SO2_MCLK__FUNC_I2SO0_MCK (MTK_PIN_NO(189) | 2)
+#define MT2712_PIN_189_I2SO2_MCLK__FUNC_I2SO1_MCK (MTK_PIN_NO(189) | 3)
+#define MT2712_PIN_189_I2SO2_MCLK__FUNC_PCM1_DO (MTK_PIN_NO(189) | 4)
+#define MT2712_PIN_189_I2SO2_MCLK__FUNC_MRG_RX (MTK_PIN_NO(189) | 5)
+#define MT2712_PIN_189_I2SO2_MCLK__FUNC_TDMO1_DATA1 (MTK_PIN_NO(189) | 6)
+#define MT2712_PIN_189_I2SO2_MCLK__FUNC_I2S_IQ0_SDQA (MTK_PIN_NO(189) | 7)
+
+#define MT2712_PIN_190_I2SO2_DATA0__FUNC_GPIO190 (MTK_PIN_NO(190) | 0)
+#define MT2712_PIN_190_I2SO2_DATA0__FUNC_I2SO2_DO (MTK_PIN_NO(190) | 1)
+#define MT2712_PIN_190_I2SO2_DATA0__FUNC_I2SO0_DO0 (MTK_PIN_NO(190) | 2)
+#define MT2712_PIN_190_I2SO2_DATA0__FUNC_I2SO1_DO (MTK_PIN_NO(190) | 3)
+#define MT2712_PIN_190_I2SO2_DATA0__FUNC_PCM1_DI (MTK_PIN_NO(190) | 4)
+#define MT2712_PIN_190_I2SO2_DATA0__FUNC_MRG_TX (MTK_PIN_NO(190) | 5)
+#define MT2712_PIN_190_I2SO2_DATA0__FUNC_PCM1_DO (MTK_PIN_NO(190) | 6)
+#define MT2712_PIN_190_I2SO2_DATA0__FUNC_I2S_IQ0_SDIA (MTK_PIN_NO(190) | 7)
+
+#define MT2712_PIN_191_I2SO0_DATA1__FUNC_GPIO191 (MTK_PIN_NO(191) | 0)
+#define MT2712_PIN_191_I2SO0_DATA1__FUNC_I2SO0_DO1 (MTK_PIN_NO(191) | 1)
+#define MT2712_PIN_191_I2SO0_DATA1__FUNC_I2SI0_DI (MTK_PIN_NO(191) | 2)
+#define MT2712_PIN_191_I2SO0_DATA1__FUNC_I2SI1_DI (MTK_PIN_NO(191) | 3)
+#define MT2712_PIN_191_I2SO0_DATA1__FUNC_I2SI2_DI (MTK_PIN_NO(191) | 4)
+#define MT2712_PIN_191_I2SO0_DATA1__FUNC_DAI_TX (MTK_PIN_NO(191) | 5)
+#define MT2712_PIN_191_I2SO0_DATA1__FUNC_I2S_IQ0_SDQB (MTK_PIN_NO(191) | 6)
+#define MT2712_PIN_191_I2SO0_DATA1__FUNC_I2S_IQ1_SDQB (MTK_PIN_NO(191) | 7)
+
+#define MT2712_PIN_192_I2SO0_MCLK__FUNC_GPIO192 (MTK_PIN_NO(192) | 0)
+#define MT2712_PIN_192_I2SO0_MCLK__FUNC_I2SO0_MCK (MTK_PIN_NO(192) | 1)
+#define MT2712_PIN_192_I2SO0_MCLK__FUNC_I2SO1_MCK (MTK_PIN_NO(192) | 2)
+#define MT2712_PIN_192_I2SO0_MCLK__FUNC_I2SO2_MCK (MTK_PIN_NO(192) | 3)
+#define MT2712_PIN_192_I2SO0_MCLK__FUNC_USB4_FT_SCL (MTK_PIN_NO(192) | 4)
+#define MT2712_PIN_192_I2SO0_MCLK__FUNC_TDMO1_DATA3 (MTK_PIN_NO(192) | 5)
+#define MT2712_PIN_192_I2SO0_MCLK__FUNC_I2S_IQ0_SDIB (MTK_PIN_NO(192) | 6)
+#define MT2712_PIN_192_I2SO0_MCLK__FUNC_I2S_IQ1_SDQA (MTK_PIN_NO(192) | 7)
+
+#define MT2712_PIN_193_I2SO0_DATA0__FUNC_GPIO193 (MTK_PIN_NO(193) | 0)
+#define MT2712_PIN_193_I2SO0_DATA0__FUNC_I2SO0_DO0 (MTK_PIN_NO(193) | 1)
+#define MT2712_PIN_193_I2SO0_DATA0__FUNC_I2SO1_DO (MTK_PIN_NO(193) | 2)
+#define MT2712_PIN_193_I2SO0_DATA0__FUNC_I2SO2_DO (MTK_PIN_NO(193) | 3)
+#define MT2712_PIN_193_I2SO0_DATA0__FUNC_USB4_FT_SDA (MTK_PIN_NO(193) | 4)
+#define MT2712_PIN_193_I2SO0_DATA0__FUNC_I2S_IQ1_SDIA (MTK_PIN_NO(193) | 7)
+
+#define MT2712_PIN_194_I2SO0_LRCK__FUNC_GPIO194 (MTK_PIN_NO(194) | 0)
+#define MT2712_PIN_194_I2SO0_LRCK__FUNC_I2SO0_WS (MTK_PIN_NO(194) | 1)
+#define MT2712_PIN_194_I2SO0_LRCK__FUNC_I2SO1_WS (MTK_PIN_NO(194) | 2)
+#define MT2712_PIN_194_I2SO0_LRCK__FUNC_I2SO2_WS (MTK_PIN_NO(194) | 3)
+#define MT2712_PIN_194_I2SO0_LRCK__FUNC_USB5_FT_SCL (MTK_PIN_NO(194) | 4)
+#define MT2712_PIN_194_I2SO0_LRCK__FUNC_TDMO1_DATA2 (MTK_PIN_NO(194) | 5)
+#define MT2712_PIN_194_I2SO0_LRCK__FUNC_I2S_IQ1_WS (MTK_PIN_NO(194) | 7)
+
+#define MT2712_PIN_195_I2SO0_BCK__FUNC_GPIO195 (MTK_PIN_NO(195) | 0)
+#define MT2712_PIN_195_I2SO0_BCK__FUNC_I2SO0_BCK (MTK_PIN_NO(195) | 1)
+#define MT2712_PIN_195_I2SO0_BCK__FUNC_I2SO1_BCK (MTK_PIN_NO(195) | 2)
+#define MT2712_PIN_195_I2SO0_BCK__FUNC_I2SO2_BCK (MTK_PIN_NO(195) | 3)
+#define MT2712_PIN_195_I2SO0_BCK__FUNC_USB5_FT_SDA (MTK_PIN_NO(195) | 4)
+#define MT2712_PIN_195_I2SO0_BCK__FUNC_TDMO1_DATA1 (MTK_PIN_NO(195) | 5)
+#define MT2712_PIN_195_I2SO0_BCK__FUNC_I2S_IQ1_BCK (MTK_PIN_NO(195) | 7)
+
+#define MT2712_PIN_196_TDMO1_MCLK__FUNC_GPIO196 (MTK_PIN_NO(196) | 0)
+#define MT2712_PIN_196_TDMO1_MCLK__FUNC_TDMO1_MCLK (MTK_PIN_NO(196) | 1)
+#define MT2712_PIN_196_TDMO1_MCLK__FUNC_TDMO0_MCLK (MTK_PIN_NO(196) | 2)
+#define MT2712_PIN_196_TDMO1_MCLK__FUNC_TDMIN_MCLK (MTK_PIN_NO(196) | 3)
+#define MT2712_PIN_196_TDMO1_MCLK__FUNC_I2SO0_DO1 (MTK_PIN_NO(196) | 6)
+#define MT2712_PIN_196_TDMO1_MCLK__FUNC_I2S_IQ1_SDIB (MTK_PIN_NO(196) | 7)
+
+#define MT2712_PIN_197_TDMO1_LRCK__FUNC_GPIO197 (MTK_PIN_NO(197) | 0)
+#define MT2712_PIN_197_TDMO1_LRCK__FUNC_TDMO1_LRCK (MTK_PIN_NO(197) | 1)
+#define MT2712_PIN_197_TDMO1_LRCK__FUNC_TDMO0_LRCK (MTK_PIN_NO(197) | 2)
+#define MT2712_PIN_197_TDMO1_LRCK__FUNC_TDMIN_LRCK (MTK_PIN_NO(197) | 3)
+#define MT2712_PIN_197_TDMO1_LRCK__FUNC_TDMO0_DATA3 (MTK_PIN_NO(197) | 4)
+#define MT2712_PIN_197_TDMO1_LRCK__FUNC_TDMO1_DATA3 (MTK_PIN_NO(197) | 5)
+#define MT2712_PIN_197_TDMO1_LRCK__FUNC_I2SO3_MCK (MTK_PIN_NO(197) | 6)
+#define MT2712_PIN_197_TDMO1_LRCK__FUNC_TDMO1_DATA2 (MTK_PIN_NO(197) | 7)
+
+#define MT2712_PIN_198_TDMO1_BCK__FUNC_GPIO198 (MTK_PIN_NO(198) | 0)
+#define MT2712_PIN_198_TDMO1_BCK__FUNC_TDMO1_BCK (MTK_PIN_NO(198) | 1)
+#define MT2712_PIN_198_TDMO1_BCK__FUNC_TDMO0_BCK (MTK_PIN_NO(198) | 2)
+#define MT2712_PIN_198_TDMO1_BCK__FUNC_TDMIN_BCK (MTK_PIN_NO(198) | 3)
+#define MT2712_PIN_198_TDMO1_BCK__FUNC_TDMO0_DATA2 (MTK_PIN_NO(198) | 4)
+#define MT2712_PIN_198_TDMO1_BCK__FUNC_TDMO1_DATA2 (MTK_PIN_NO(198) | 5)
+#define MT2712_PIN_198_TDMO1_BCK__FUNC_I2SO3_BCK (MTK_PIN_NO(198) | 6)
+#define MT2712_PIN_198_TDMO1_BCK__FUNC_TDMO1_DATA1 (MTK_PIN_NO(198) | 7)
+
+#define MT2712_PIN_199_TDMO1_DATA__FUNC_GPIO199 (MTK_PIN_NO(199) | 0)
+#define MT2712_PIN_199_TDMO1_DATA__FUNC_TDMO1_DATA (MTK_PIN_NO(199) | 1)
+#define MT2712_PIN_199_TDMO1_DATA__FUNC_TDMO0_DATA (MTK_PIN_NO(199) | 2)
+#define MT2712_PIN_199_TDMO1_DATA__FUNC_TDMIN_DI (MTK_PIN_NO(199) | 3)
+#define MT2712_PIN_199_TDMO1_DATA__FUNC_TDMO0_DATA1 (MTK_PIN_NO(199) | 4)
+#define MT2712_PIN_199_TDMO1_DATA__FUNC_TDMO1_DATA1 (MTK_PIN_NO(199) | 5)
+#define MT2712_PIN_199_TDMO1_DATA__FUNC_I2SO3_WS (MTK_PIN_NO(199) | 6)
+
+#define MT2712_PIN_200_TDMO0_MCLK__FUNC_GPIO200 (MTK_PIN_NO(200) | 0)
+#define MT2712_PIN_200_TDMO0_MCLK__FUNC_TDMO0_MCLK0 (MTK_PIN_NO(200) | 1)
+#define MT2712_PIN_200_TDMO0_MCLK__FUNC_TDMO1_MCLK0 (MTK_PIN_NO(200) | 2)
+#define MT2712_PIN_200_TDMO0_MCLK__FUNC_PCM1_DI (MTK_PIN_NO(200) | 3)
+#define MT2712_PIN_200_TDMO0_MCLK__FUNC_TDMO0_MCLK1 (MTK_PIN_NO(200) | 4)
+#define MT2712_PIN_200_TDMO0_MCLK__FUNC_TDMO1_MCLK1 (MTK_PIN_NO(200) | 5)
+#define MT2712_PIN_200_TDMO0_MCLK__FUNC_MRG_TX (MTK_PIN_NO(200) | 6)
+#define MT2712_PIN_200_TDMO0_MCLK__FUNC_I2SO2_MCK (MTK_PIN_NO(200) | 7)
+
+#define MT2712_PIN_201_TDMO0_LRCK__FUNC_GPIO201 (MTK_PIN_NO(201) | 0)
+#define MT2712_PIN_201_TDMO0_LRCK__FUNC_TDMO0_LRCK0 (MTK_PIN_NO(201) | 1)
+#define MT2712_PIN_201_TDMO0_LRCK__FUNC_TDMO1_LRCK0 (MTK_PIN_NO(201) | 2)
+#define MT2712_PIN_201_TDMO0_LRCK__FUNC_PCM1_SYNC (MTK_PIN_NO(201) | 3)
+#define MT2712_PIN_201_TDMO0_LRCK__FUNC_TDMO0_LRCK1 (MTK_PIN_NO(201) | 4)
+#define MT2712_PIN_201_TDMO0_LRCK__FUNC_TDMO1_LRCK1 (MTK_PIN_NO(201) | 5)
+#define MT2712_PIN_201_TDMO0_LRCK__FUNC_MRG_RX (MTK_PIN_NO(201) | 6)
+#define MT2712_PIN_201_TDMO0_LRCK__FUNC_I2SO2_WS (MTK_PIN_NO(201) | 7)
+
+#define MT2712_PIN_202_TDMO0_BCK__FUNC_GPIO202 (MTK_PIN_NO(202) | 0)
+#define MT2712_PIN_202_TDMO0_BCK__FUNC_TDMO0_BCK0 (MTK_PIN_NO(202) | 1)
+#define MT2712_PIN_202_TDMO0_BCK__FUNC_TDMO1_BCK0 (MTK_PIN_NO(202) | 2)
+#define MT2712_PIN_202_TDMO0_BCK__FUNC_PCM1_CLK (MTK_PIN_NO(202) | 3)
+#define MT2712_PIN_202_TDMO0_BCK__FUNC_TDMO0_BCK1 (MTK_PIN_NO(202) | 4)
+#define MT2712_PIN_202_TDMO0_BCK__FUNC_TDMO1_BCK1 (MTK_PIN_NO(202) | 5)
+#define MT2712_PIN_202_TDMO0_BCK__FUNC_MRG_SYNC (MTK_PIN_NO(202) | 6)
+#define MT2712_PIN_202_TDMO0_BCK__FUNC_I2SO2_BCK (MTK_PIN_NO(202) | 7)
+
+#define MT2712_PIN_203_TDMO0_DATA__FUNC_GPIO203 (MTK_PIN_NO(203) | 0)
+#define MT2712_PIN_203_TDMO0_DATA__FUNC_TDMO0_DATA0 (MTK_PIN_NO(203) | 1)
+#define MT2712_PIN_203_TDMO0_DATA__FUNC_TDMO1_DATA0 (MTK_PIN_NO(203) | 2)
+#define MT2712_PIN_203_TDMO0_DATA__FUNC_PCM1_DO (MTK_PIN_NO(203) | 3)
+#define MT2712_PIN_203_TDMO0_DATA__FUNC_TDMO0_DATA1 (MTK_PIN_NO(203) | 4)
+#define MT2712_PIN_203_TDMO0_DATA__FUNC_TDMO1_DATA1 (MTK_PIN_NO(203) | 5)
+#define MT2712_PIN_203_TDMO0_DATA__FUNC_MRG_CLK (MTK_PIN_NO(203) | 6)
+#define MT2712_PIN_203_TDMO0_DATA__FUNC_I2SO2_DO (MTK_PIN_NO(203) | 7)
+
+#define MT2712_PIN_204_PERSTB_P0__FUNC_GPIO204 (MTK_PIN_NO(204) | 0)
+#define MT2712_PIN_204_PERSTB_P0__FUNC_PERST_B_P0 (MTK_PIN_NO(204) | 1)
+
+#define MT2712_PIN_205_CLKREQN_P0__FUNC_GPIO205 (MTK_PIN_NO(205) | 0)
+#define MT2712_PIN_205_CLKREQN_P0__FUNC_CLKREQ_N_P0 (MTK_PIN_NO(205) | 1)
+
+#define MT2712_PIN_206_WAKEEN_P0__FUNC_GPIO206 (MTK_PIN_NO(206) | 0)
+#define MT2712_PIN_206_WAKEEN_P0__FUNC_WAKE_EN_P0 (MTK_PIN_NO(206) | 1)
+
+#define MT2712_PIN_207_PERSTB_P1__FUNC_GPIO207 (MTK_PIN_NO(207) | 0)
+#define MT2712_PIN_207_PERSTB_P1__FUNC_PERST_B_P1 (MTK_PIN_NO(207) | 1)
+
+#define MT2712_PIN_208_CLKREQN_P1__FUNC_GPIO208 (MTK_PIN_NO(208) | 0)
+#define MT2712_PIN_208_CLKREQN_P1__FUNC_CLKREQ_N_P1 (MTK_PIN_NO(208) | 1)
+
+#define MT2712_PIN_209_WAKEEN_P1__FUNC_GPIO209 (MTK_PIN_NO(209) | 0)
+#define MT2712_PIN_209_WAKEEN_P1__FUNC_WAKE_EN_P1 (MTK_PIN_NO(209) | 1)
+
+#endif /* __DTS_MT2712_PINFUNC_H */
index 9d88f41aefa0a658b34c4bee983f75f811801be9..6d8532af834688d96e1bdb7394c3d2821da393e4 100644 (file)
@@ -9,6 +9,7 @@
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/power/mt2712-power.h>
+#include "mt2712-pinfunc.h"
 
 / {
        compatible = "mediatek,mt2712";
@@ -199,6 +200,34 @@ clkaud_ext_i_2: oscillator@5 {
                clock-output-names = "clkaud_ext_i_2";
        };
 
+       clki2si0_mck_i: oscillator@6 {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <30000000>;
+               clock-output-names = "clki2si0_mck_i";
+       };
+
+       clki2si1_mck_i: oscillator@7 {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <30000000>;
+               clock-output-names = "clki2si1_mck_i";
+       };
+
+       clki2si2_mck_i: oscillator@8 {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <30000000>;
+               clock-output-names = "clki2si2_mck_i";
+       };
+
+       clktdmin_mclk_i: oscillator@9 {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <30000000>;
+               clock-output-names = "clktdmin_mclk_i";
+       };
+
        timer {
                compatible = "arm,armv8-timer";
                interrupt-parent = <&gic>;
@@ -230,6 +259,23 @@ pericfg: syscon@10003000 {
                #clock-cells = <1>;
        };
 
+       syscfg_pctl_a: syscfg_pctl_a@10005000 {
+               compatible = "mediatek,mt2712-pctl-a-syscfg", "syscon";
+               reg = <0 0x10005000 0 0x1000>;
+       };
+
+       pio: pinctrl@10005000 {
+               compatible = "mediatek,mt2712-pinctrl";
+               reg = <0 0x1000b000 0 0x1000>;
+               mediatek,pctl-regmap = <&syscfg_pctl_a>;
+               pins-are-numbered;
+               gpio-controller;
+               #gpio-cells = <2>;
+               interrupt-controller;
+               #interrupt-cells = <2>;
+               interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
+       };
+
        scpsys: scpsys@10006000 {
                compatible = "mediatek,mt2712-scpsys", "syscon";
                #power-domain-cells = <1>;
index 45d8655ee423149a1cb648a3ccd12c2d381d76da..b7837642c33a8b6aae187b8c6df2dc71c9994edb 100644 (file)
@@ -18,7 +18,7 @@ / {
        compatible = "mediatek,mt7622-rfb1", "mediatek,mt7622";
 
        chosen {
-               bootargs = "console=ttyS0,115200n1";
+               bootargs = "console=ttyS0,115200n1 swiotlb=512";
        };
 
        cpus {
@@ -163,10 +163,17 @@ mux {
        i2s1_pins: i2s1-pins {
                mux {
                        function = "i2s";
-                       groups =  "i2s_out_bclk_ws_mclk",
+                       groups =  "i2s_out_mclk_bclk_ws",
                                  "i2s1_in_data",
                                  "i2s1_out_data";
                };
+
+               conf {
+                       pins = "I2S1_IN", "I2S1_OUT", "I2S_BCLK",
+                              "I2S_WS", "I2S_MCLK";
+                       drive-strength = <12>;
+                       bias-pull-down;
+               };
        };
 
        irrx_pins: irrx-pins {
index e9d5130df8d11cf9c3055ffd0e9e8774c393fe74..9213c966c2242ee6c8a14d270ffeb4712533f54f 100644 (file)
@@ -527,6 +527,95 @@ uart4: serial@11019000 {
                status = "disabled";
        };
 
+       audsys: clock-controller@11220000 {
+               compatible = "mediatek,mt7622-audsys", "syscon";
+               reg = <0 0x11220000 0 0x2000>;
+               #clock-cells = <1>;
+
+               afe: audio-controller {
+                       compatible = "mediatek,mt7622-audio";
+                       interrupts =  <GIC_SPI 144 IRQ_TYPE_LEVEL_LOW>,
+                                     <GIC_SPI 145 IRQ_TYPE_LEVEL_LOW>;
+                       interrupt-names = "afe", "asys";
+
+                       clocks = <&infracfg CLK_INFRA_AUDIO_PD>,
+                                <&topckgen CLK_TOP_AUD1_SEL>,
+                                <&topckgen CLK_TOP_AUD2_SEL>,
+                                <&topckgen CLK_TOP_A1SYS_HP_DIV_PD>,
+                                <&topckgen CLK_TOP_A2SYS_HP_DIV_PD>,
+                                <&topckgen CLK_TOP_I2S0_MCK_SEL>,
+                                <&topckgen CLK_TOP_I2S1_MCK_SEL>,
+                                <&topckgen CLK_TOP_I2S2_MCK_SEL>,
+                                <&topckgen CLK_TOP_I2S3_MCK_SEL>,
+                                <&topckgen CLK_TOP_I2S0_MCK_DIV>,
+                                <&topckgen CLK_TOP_I2S1_MCK_DIV>,
+                                <&topckgen CLK_TOP_I2S2_MCK_DIV>,
+                                <&topckgen CLK_TOP_I2S3_MCK_DIV>,
+                                <&topckgen CLK_TOP_I2S0_MCK_DIV_PD>,
+                                <&topckgen CLK_TOP_I2S1_MCK_DIV_PD>,
+                                <&topckgen CLK_TOP_I2S2_MCK_DIV_PD>,
+                                <&topckgen CLK_TOP_I2S3_MCK_DIV_PD>,
+                                <&audsys CLK_AUDIO_I2SO1>,
+                                <&audsys CLK_AUDIO_I2SO2>,
+                                <&audsys CLK_AUDIO_I2SO3>,
+                                <&audsys CLK_AUDIO_I2SO4>,
+                                <&audsys CLK_AUDIO_I2SIN1>,
+                                <&audsys CLK_AUDIO_I2SIN2>,
+                                <&audsys CLK_AUDIO_I2SIN3>,
+                                <&audsys CLK_AUDIO_I2SIN4>,
+                                <&audsys CLK_AUDIO_ASRCO1>,
+                                <&audsys CLK_AUDIO_ASRCO2>,
+                                <&audsys CLK_AUDIO_ASRCO3>,
+                                <&audsys CLK_AUDIO_ASRCO4>,
+                                <&audsys CLK_AUDIO_AFE>,
+                                <&audsys CLK_AUDIO_AFE_CONN>,
+                                <&audsys CLK_AUDIO_A1SYS>,
+                                <&audsys CLK_AUDIO_A2SYS>;
+
+                       clock-names = "infra_sys_audio_clk",
+                                     "top_audio_mux1_sel",
+                                     "top_audio_mux2_sel",
+                                     "top_audio_a1sys_hp",
+                                     "top_audio_a2sys_hp",
+                                     "i2s0_src_sel",
+                                     "i2s1_src_sel",
+                                     "i2s2_src_sel",
+                                     "i2s3_src_sel",
+                                     "i2s0_src_div",
+                                     "i2s1_src_div",
+                                     "i2s2_src_div",
+                                     "i2s3_src_div",
+                                     "i2s0_mclk_en",
+                                     "i2s1_mclk_en",
+                                     "i2s2_mclk_en",
+                                     "i2s3_mclk_en",
+                                     "i2so0_hop_ck",
+                                     "i2so1_hop_ck",
+                                     "i2so2_hop_ck",
+                                     "i2so3_hop_ck",
+                                     "i2si0_hop_ck",
+                                     "i2si1_hop_ck",
+                                     "i2si2_hop_ck",
+                                     "i2si3_hop_ck",
+                                     "asrc0_out_ck",
+                                     "asrc1_out_ck",
+                                     "asrc2_out_ck",
+                                     "asrc3_out_ck",
+                                     "audio_afe_pd",
+                                     "audio_afe_conn_pd",
+                                     "audio_a1sys_pd",
+                                     "audio_a2sys_pd";
+
+                       assigned-clocks = <&topckgen CLK_TOP_A1SYS_HP_SEL>,
+                                         <&topckgen CLK_TOP_A2SYS_HP_SEL>,
+                                         <&topckgen CLK_TOP_A1SYS_HP_DIV>,
+                                         <&topckgen CLK_TOP_A2SYS_HP_DIV>;
+                       assigned-clock-parents = <&topckgen CLK_TOP_AUD1PLL>,
+                                                <&topckgen CLK_TOP_AUD2PLL>;
+                       assigned-clock-rates = <0>, <0>, <49152000>, <45158400>;
+               };
+       };
+
        mmc0: mmc@11230000 {
                compatible = "mediatek,mt7622-mmc";
                reg = <0 0x11230000 0 0x1000>;
@@ -735,6 +824,16 @@ ethsys: syscon@1b000000 {
                #reset-cells = <1>;
        };
 
+       hsdma: dma-controller@1b007000 {
+               compatible = "mediatek,mt7622-hsdma";
+               reg = <0 0x1b007000 0 0x1000>;
+               interrupts = <GIC_SPI 219 IRQ_TYPE_LEVEL_LOW>;
+               clocks = <&ethsys CLK_ETH_HSDMA_EN>;
+               clock-names = "hsdma";
+               power-domains = <&scpsys MT7622_POWER_DOMAIN_ETHSYS>;
+               #dma-cells = <1>;
+       };
+
        eth: ethernet@1b100000 {
                compatible = "mediatek,mt7622-eth",
                             "mediatek,mt2701-eth",
index 55ec5ee7f7e846c2fcf773ab326099d10561d81b..9319e74b890687b0485f437dcea2d1cd8a1f4441 100644 (file)
@@ -6,3 +6,4 @@ dtb-$(CONFIG_ARCH_QCOM) += msm8916-mtp.dtb
 dtb-$(CONFIG_ARCH_QCOM)        += msm8992-bullhead-rev-101.dtb
 dtb-$(CONFIG_ARCH_QCOM)        += msm8994-angler-rev-101.dtb
 dtb-$(CONFIG_ARCH_QCOM)        += msm8996-mtp.dtb
+dtb-$(CONFIG_ARCH_QCOM)        += sdm845-mtp.dtb
index 6167af9556599ad3f019bd2696905bc9e64f3b76..a6ad3d7fe655bb3dbd976b1e7ddcc2541535b597 100644 (file)
@@ -4,7 +4,7 @@
 &pm8994_gpios {
 
        pinctrl-names = "default";
-       pinctrl-0 = <&ls_exp_gpio_f>;
+       pinctrl-0 = <&ls_exp_gpio_f &bt_en_gpios>;
 
        ls_exp_gpio_f: pm8994_gpio5 {
                pinconf {
index 4b8bb026346edb17ed2bc3c9b35790f5f99ec059..0f829db33efe2dfa2735a7cdf570de77c49a6356 100644 (file)
@@ -117,6 +117,16 @@ sdhci@74a4900 {
                        pinctrl-0 = <&sdc2_clk_on &sdc2_cmd_on &sdc2_data_on &sdc2_cd_on>;
                        pinctrl-1 = <&sdc2_clk_off &sdc2_cmd_off &sdc2_data_off &sdc2_cd_off>;
                        cd-gpios = <&msmgpio 38 0x1>;
+                       vmmc-supply = <&pm8994_l21>;
+                       vqmmc-supply = <&pm8994_l13>;
+                       status = "okay";
+               };
+
+               phy@627000 {
+                       status = "okay";
+               };
+
+               ufshc@624000 {
                        status = "okay";
                };
 
@@ -169,19 +179,6 @@ usb2_id: usb2-id {
                        pinctrl-0 = <&usb2_vbus_det_gpio>;
                };
 
-               bt_en: bt-en-1-8v {
-                       pinctrl-names = "default";
-                       pinctrl-0 = <&bt_en_gpios>;
-                       compatible = "regulator-fixed";
-                       regulator-name = "bt-en-regulator";
-                       regulator-min-microvolt = <1800000>;
-                       regulator-max-microvolt = <1800000>;
-
-                       /* WLAN card specific delay */
-                       startup-delay-us = <70000>;
-                       enable-active-high;
-               };
-
                wlan_en: wlan-en-1-8v {
                        pinctrl-names = "default";
                        pinctrl-0 = <&wlan_en_gpios>;
@@ -198,19 +195,18 @@ wlan_en: wlan-en-1-8v {
                };
 
                agnoc@0 {
-                       qcom,pcie@600000 {
+                       pcie@600000 {
                                status = "okay";
                                perst-gpio = <&msmgpio 35 GPIO_ACTIVE_LOW>;
-                               vddpe-supply = <&wlan_en>;
-                               vddpe1-supply = <&bt_en>;
+                               vddpe-3v3-supply = <&wlan_en>;
                        };
 
-                       qcom,pcie@608000 {
+                       pcie@608000 {
                                status = "okay";
                                perst-gpio = <&msmgpio 130 GPIO_ACTIVE_LOW>;
                        };
 
-                       qcom,pcie@610000 {
+                       pcie@610000 {
                                status = "okay";
                                perst-gpio = <&msmgpio 114 GPIO_ACTIVE_LOW>;
                        };
index 6a838b5d321e31c408674f642698fb7168b9ca93..c13ddee8262b97905e118cd6ab783feea048d1b1 100644 (file)
@@ -21,6 +21,7 @@ / {
 
        aliases {
                serial0 = &blsp1_uart5;
+               serial1 = &blsp1_uart3;
        };
 
        chosen {
@@ -33,20 +34,61 @@ memory {
        };
 
        soc {
-               pinctrl@1000000 {
-                       serial_4_pins: serial4_pinmux {
-                               mux {
-                                       pins = "gpio23", "gpio24";
-                                       function = "blsp4_uart1";
-                                       bias-disable;
-                               };
+               serial@78b3000 {
+                       status = "ok";
+               };
+
+               spi@78b5000 {
+                       status = "ok";
+
+                       m25p80@0 {
+                                 #address-cells = <1>;
+                                 #size-cells = <1>;
+                                 compatible = "jedec,spi-nor";
+                                 reg = <0>;
+                                 spi-max-frequency = <50000000>;
                        };
                };
 
-               serial@78b3000 {
-                       pinctrl-0 = <&serial_4_pins>;
-                       pinctrl-names = "default";
+               serial@78b1000 {
+                        status = "ok";
+               };
+
+               i2c@78b6000 {
+                        status = "ok";
+               };
+
+               dma@7984000 {
+                        status = "ok";
+               };
+
+               nand@79b0000 {
+                       status = "ok";
+
+                       nand@0 {
+                               reg = <0>;
+                               nand-ecc-strength = <4>;
+                               nand-ecc-step-size = <512>;
+                               nand-bus-width = <8>;
+                       };
+               };
+
+               phy@86000 {
+                       status = "ok";
+               };
+
+               phy@8e000 {
+                       status = "ok";
+               };
+
+               pci@20000000 {
+                       status = "ok";
+                       perst-gpio = <&tlmm 58 0x1>;
+               };
+
+               pci@10000000 {
                        status = "ok";
+                       perst-gpio = <&tlmm 61 0x1>;
                };
        };
 };
index 2bc5dec5614dec40962e987e0646321a888d4549..18226980f7c32fde64577a8e09074b664e5f805b 100644 (file)
@@ -24,7 +24,7 @@ soc: soc {
                ranges = <0 0 0 0xffffffff>;
                compatible = "simple-bus";
 
-               pinctrl@1000000 {
+               tlmm: pinctrl@1000000 {
                        compatible = "qcom,ipq8074-pinctrl";
                        reg = <0x1000000 0x300000>;
                        interrupts = <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>;
@@ -32,6 +32,45 @@ pinctrl@1000000 {
                        #gpio-cells = <0x2>;
                        interrupt-controller;
                        #interrupt-cells = <0x2>;
+
+                       serial_4_pins: serial4-pinmux {
+                               pins = "gpio23", "gpio24";
+                               function = "blsp4_uart1";
+                               drive-strength = <8>;
+                               bias-disable;
+                       };
+
+                       i2c_0_pins: i2c-0-pinmux {
+                               pins = "gpio42", "gpio43";
+                               function = "blsp1_i2c";
+                               drive-strength = <8>;
+                               bias-disable;
+                       };
+
+                       spi_0_pins: spi-0-pins {
+                               pins = "gpio38", "gpio39", "gpio40", "gpio41";
+                               function = "blsp0_spi";
+                               drive-strength = <8>;
+                               bias-disable;
+                       };
+
+                       hsuart_pins: hsuart-pins {
+                               pins = "gpio46", "gpio47", "gpio48", "gpio49";
+                               function = "blsp2_uart";
+                               drive-strength = <8>;
+                               bias-disable;
+                       };
+
+                       qpic_pins: qpic-pins {
+                               pins = "gpio1", "gpio3", "gpio4",
+                                      "gpio5", "gpio6", "gpio7",
+                                      "gpio8", "gpio10", "gpio11",
+                                      "gpio12", "gpio13", "gpio14",
+                                      "gpio15", "gpio16", "gpio17";
+                               function = "qpic";
+                               drive-strength = <8>;
+                               bias-disable;
+                       };
                };
 
                intc: interrupt-controller@b000000 {
@@ -122,6 +161,276 @@ blsp1_uart5: serial@78b3000 {
                        clocks = <&gcc GCC_BLSP1_UART5_APPS_CLK>,
                                 <&gcc GCC_BLSP1_AHB_CLK>;
                        clock-names = "core", "iface";
+                       pinctrl-0 = <&serial_4_pins>;
+                       pinctrl-names = "default";
+                       status = "disabled";
+               };
+
+               blsp_dma: dma@7884000 {
+                       compatible = "qcom,bam-v1.7.0";
+                       reg = <0x7884000 0x2b000>;
+                       interrupts = <GIC_SPI 238 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&gcc GCC_BLSP1_AHB_CLK>;
+                       clock-names = "bam_clk";
+                       #dma-cells = <1>;
+                       qcom,ee = <0>;
+               };
+
+               blsp1_uart1: serial@78af000 {
+                       compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
+                       reg = <0x78af000 0x200>;
+                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&gcc GCC_BLSP1_UART1_APPS_CLK>,
+                                <&gcc GCC_BLSP1_AHB_CLK>;
+                       clock-names = "core", "iface";
+                       status = "disabled";
+               };
+
+               blsp1_uart3: serial@78b1000 {
+                       compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm";
+                       reg = <0x78b1000 0x200>;
+                       interrupts = <GIC_SPI 306 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&gcc GCC_BLSP1_UART3_APPS_CLK>,
+                               <&gcc GCC_BLSP1_AHB_CLK>;
+                       clock-names = "core", "iface";
+                       dmas = <&blsp_dma 4>,
+                               <&blsp_dma 5>;
+                       dma-names = "tx", "rx";
+                       pinctrl-0 = <&hsuart_pins>;
+                       pinctrl-names = "default";
+                       status = "disabled";
+               };
+
+               blsp1_spi1: spi@78b5000 {
+                       compatible = "qcom,spi-qup-v2.2.1";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x78b5000 0x600>;
+                       interrupts = <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>;
+                       spi-max-frequency = <50000000>;
+                       clocks = <&gcc GCC_BLSP1_QUP1_SPI_APPS_CLK>,
+                               <&gcc GCC_BLSP1_AHB_CLK>;
+                       clock-names = "core", "iface";
+                       dmas = <&blsp_dma 12>, <&blsp_dma 13>;
+                       dma-names = "tx", "rx";
+                       pinctrl-0 = <&spi_0_pins>;
+                       pinctrl-names = "default";
+                       status = "disabled";
+               };
+
+               blsp1_i2c2: i2c@78b6000 {
+                       compatible = "qcom,i2c-qup-v2.2.1";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x78b6000 0x600>;
+                       interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&gcc GCC_BLSP1_AHB_CLK>,
+                               <&gcc GCC_BLSP1_QUP2_I2C_APPS_CLK>;
+                       clock-names = "iface", "core";
+                       clock-frequency = <400000>;
+                       dmas = <&blsp_dma 15>, <&blsp_dma 14>;
+                       dma-names = "rx", "tx";
+                       pinctrl-0 = <&i2c_0_pins>;
+                       pinctrl-names = "default";
+                       status = "disabled";
+               };
+
+               blsp1_i2c3: i2c@78b7000 {
+                       compatible = "qcom,i2c-qup-v2.2.1";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       reg = <0x78b7000 0x600>;
+                       interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&gcc GCC_BLSP1_AHB_CLK>,
+                               <&gcc GCC_BLSP1_QUP3_I2C_APPS_CLK>;
+                       clock-names = "iface", "core";
+                       clock-frequency = <100000>;
+                       dmas = <&blsp_dma 17>, <&blsp_dma 16>;
+                       dma-names = "rx", "tx";
+                       status = "disabled";
+               };
+
+               qpic_bam: dma@7984000 {
+                       compatible = "qcom,bam-v1.7.0";
+                       reg = <0x7984000 0x1a000>;
+                       interrupts = <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&gcc GCC_QPIC_AHB_CLK>;
+                       clock-names = "bam_clk";
+                       #dma-cells = <1>;
+                       qcom,ee = <0>;
+                       status = "disabled";
+               };
+
+               qpic_nand: nand@79b0000 {
+                       compatible = "qcom,ipq8074-nand";
+                       reg = <0x79b0000 0x10000>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       clocks = <&gcc GCC_QPIC_CLK>,
+                                <&gcc GCC_QPIC_AHB_CLK>;
+                       clock-names = "core", "aon";
+
+                       dmas = <&qpic_bam 0>,
+                              <&qpic_bam 1>,
+                              <&qpic_bam 2>;
+                       dma-names = "tx", "rx", "cmd";
+                       pinctrl-0 = <&qpic_pins>;
+                       pinctrl-names = "default";
+                       status = "disabled";
+               };
+
+               pcie_phy0: phy@86000 {
+                       compatible = "qcom,ipq8074-qmp-pcie-phy";
+                       reg = <0x86000 0x1000>;
+                       #phy-cells = <0>;
+                       clocks = <&gcc GCC_PCIE0_PIPE_CLK>;
+                       clock-names = "pipe_clk";
+                       clock-output-names = "pcie20_phy0_pipe_clk";
+
+                       resets = <&gcc GCC_PCIE0_PHY_BCR>,
+                               <&gcc GCC_PCIE0PHY_PHY_BCR>;
+                       reset-names = "phy",
+                                     "common";
+                       status = "disabled";
+               };
+
+               pcie0: pci@20000000 {
+                       compatible = "qcom,pcie-ipq8074";
+                       reg =  <0x20000000 0xf1d
+                               0x20000f20 0xa8
+                               0x80000 0x2000
+                               0x20100000 0x1000>;
+                       reg-names = "dbi", "elbi", "parf", "config";
+                       device_type = "pci";
+                       linux,pci-domain = <0>;
+                       bus-range = <0x00 0xff>;
+                       num-lanes = <1>;
+                       #address-cells = <3>;
+                       #size-cells = <2>;
+
+                       phys = <&pcie_phy0>;
+                       phy-names = "pciephy";
+
+                       ranges = <0x81000000 0 0x20200000 0x20200000
+                                 0 0x100000   /* downstream I/O */
+                                 0x82000000 0 0x20300000 0x20300000
+                                 0 0xd00000>; /* non-prefetchable memory */
+
+                       interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "msi";
+                       #interrupt-cells = <1>;
+                       interrupt-map-mask = <0 0 0 0x7>;
+                       interrupt-map = <0 0 0 1 &intc 0 75
+                                        IRQ_TYPE_LEVEL_HIGH>, /* int_a */
+                                       <0 0 0 2 &intc 0 78
+                                        IRQ_TYPE_LEVEL_HIGH>, /* int_b */
+                                       <0 0 0 3 &intc 0 79
+                                        IRQ_TYPE_LEVEL_HIGH>, /* int_c */
+                                       <0 0 0 4 &intc 0 83
+                                        IRQ_TYPE_LEVEL_HIGH>; /* int_d */
+
+                       clocks = <&gcc GCC_SYS_NOC_PCIE0_AXI_CLK>,
+                                <&gcc GCC_PCIE0_AXI_M_CLK>,
+                                <&gcc GCC_PCIE0_AXI_S_CLK>,
+                                <&gcc GCC_PCIE0_AHB_CLK>,
+                                <&gcc GCC_PCIE0_AUX_CLK>;
+
+                       clock-names = "iface",
+                                     "axi_m",
+                                     "axi_s",
+                                     "ahb",
+                                     "aux";
+                       resets = <&gcc GCC_PCIE0_PIPE_ARES>,
+                                <&gcc GCC_PCIE0_SLEEP_ARES>,
+                                <&gcc GCC_PCIE0_CORE_STICKY_ARES>,
+                                <&gcc GCC_PCIE0_AXI_MASTER_ARES>,
+                                <&gcc GCC_PCIE0_AXI_SLAVE_ARES>,
+                                <&gcc GCC_PCIE0_AHB_ARES>,
+                                <&gcc GCC_PCIE0_AXI_MASTER_STICKY_ARES>;
+                       reset-names = "pipe",
+                                     "sleep",
+                                     "sticky",
+                                     "axi_m",
+                                     "axi_s",
+                                     "ahb",
+                                     "axi_m_sticky";
+                       status = "disabled";
+               };
+
+               pcie_phy1: phy@8e000 {
+                       compatible = "qcom,ipq8074-qmp-pcie-phy";
+                       reg = <0x8e000 0x1000>;
+                       #phy-cells = <0>;
+                       clocks = <&gcc GCC_PCIE1_PIPE_CLK>;
+                       clock-names = "pipe_clk";
+                       clock-output-names = "pcie20_phy1_pipe_clk";
+
+                       resets = <&gcc GCC_PCIE1_PHY_BCR>,
+                               <&gcc GCC_PCIE1PHY_PHY_BCR>;
+                       reset-names = "phy",
+                                     "common";
+                       status = "disabled";
+               };
+
+               pcie1: pci@10000000 {
+                       compatible = "qcom,pcie-ipq8074";
+                       reg =  <0x10000000 0xf1d
+                               0x10000f20 0xa8
+                               0x88000 0x2000
+                               0x10100000 0x1000>;
+                       reg-names = "dbi", "elbi", "parf", "config";
+                       device_type = "pci";
+                       linux,pci-domain = <1>;
+                       bus-range = <0x00 0xff>;
+                       num-lanes = <1>;
+                       #address-cells = <3>;
+                       #size-cells = <2>;
+
+                       phys = <&pcie_phy1>;
+                       phy-names = "pciephy";
+
+                       ranges = <0x81000000 0 0x10200000 0x10200000
+                                 0 0x100000   /* downstream I/O */
+                                 0x82000000 0 0x10300000 0x10300000
+                                 0 0xd00000>; /* non-prefetchable memory */
+
+                       interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "msi";
+                       #interrupt-cells = <1>;
+                       interrupt-map-mask = <0 0 0 0x7>;
+                       interrupt-map = <0 0 0 1 &intc 0 142
+                                        IRQ_TYPE_LEVEL_HIGH>, /* int_a */
+                                       <0 0 0 2 &intc 0 143
+                                        IRQ_TYPE_LEVEL_HIGH>, /* int_b */
+                                       <0 0 0 3 &intc 0 144
+                                        IRQ_TYPE_LEVEL_HIGH>, /* int_c */
+                                       <0 0 0 4 &intc 0 145
+                                        IRQ_TYPE_LEVEL_HIGH>; /* int_d */
+
+                       clocks = <&gcc GCC_SYS_NOC_PCIE1_AXI_CLK>,
+                                <&gcc GCC_PCIE1_AXI_M_CLK>,
+                                <&gcc GCC_PCIE1_AXI_S_CLK>,
+                                <&gcc GCC_PCIE1_AHB_CLK>,
+                                <&gcc GCC_PCIE1_AUX_CLK>;
+                       clock-names = "iface",
+                                     "axi_m",
+                                     "axi_s",
+                                     "ahb",
+                                     "aux";
+                       resets = <&gcc GCC_PCIE1_PIPE_ARES>,
+                                <&gcc GCC_PCIE1_SLEEP_ARES>,
+                                <&gcc GCC_PCIE1_CORE_STICKY_ARES>,
+                                <&gcc GCC_PCIE1_AXI_MASTER_ARES>,
+                                <&gcc GCC_PCIE1_AXI_SLAVE_ARES>,
+                                <&gcc GCC_PCIE1_AHB_ARES>,
+                                <&gcc GCC_PCIE1_AXI_MASTER_STICKY_ARES>;
+                       reset-names = "pipe",
+                                     "sleep",
+                                     "sticky",
+                                     "axi_m",
+                                     "axi_s",
+                                     "ahb",
+                                     "axi_m_sticky";
                        status = "disabled";
                };
        };
@@ -175,7 +484,7 @@ psci {
 
        pmu {
                compatible = "arm,armv8-pmuv3";
-               interrupts = <GIC_PPI 7 GIC_CPU_MASK_SIMPLE(4)>;
+               interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4) | IRQ_TYPE_LEVEL_HIGH)>;
        };
 
        clocks {
index 66b318e1de8009e08722a308405cef508d42e362..650f356f69ca748f0fbef0c52f4026e43f511e46 100644 (file)
@@ -179,7 +179,7 @@ psci {
 
        pmu {
                compatible = "arm,cortex-a53-pmu";
-               interrupts = <GIC_PPI 7 GIC_CPU_MASK_SIMPLE(4)>;
+               interrupts = <GIC_PPI 7 (GIC_CPU_MASK_SIMPLE(4)| IRQ_TYPE_LEVEL_HIGH)>;
        };
 
        thermal-zones {
@@ -512,7 +512,7 @@ blsp_spi6: spi@78ba000 {
                blsp_i2c2: i2c@78b6000 {
                        compatible = "qcom,i2c-qup-v2.2.1";
                        reg = <0x078b6000 0x500>;
-                       interrupts = <GIC_SPI 96 0>;
+                       interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc GCC_BLSP1_AHB_CLK>,
                                 <&gcc GCC_BLSP1_QUP2_I2C_APPS_CLK>;
                        clock-names = "iface", "core";
@@ -527,7 +527,7 @@ blsp_i2c2: i2c@78b6000 {
                blsp_i2c4: i2c@78b8000 {
                        compatible = "qcom,i2c-qup-v2.2.1";
                        reg = <0x078b8000 0x500>;
-                       interrupts = <GIC_SPI 98 0>;
+                       interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc GCC_BLSP1_AHB_CLK>,
                                 <&gcc GCC_BLSP1_QUP4_I2C_APPS_CLK>;
                        clock-names = "iface", "core";
@@ -542,7 +542,7 @@ blsp_i2c4: i2c@78b8000 {
                blsp_i2c6: i2c@78ba000 {
                        compatible = "qcom,i2c-qup-v2.2.1";
                        reg = <0x078ba000 0x500>;
-                       interrupts = <GIC_SPI 100 0>;
+                       interrupts = <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc GCC_BLSP1_AHB_CLK>,
                                 <&gcc GCC_BLSP1_QUP6_I2C_APPS_CLK>;
                        clock-names = "iface", "core";
@@ -574,7 +574,7 @@ lpass: lpass@7708000 {
                                        "mi2s-bit-clk3";
                        #sound-dai-cells = <1>;
 
-                       interrupts = <0 160 0>;
+                       interrupts = <0 160 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "lpass-irq-lpaif";
                        reg = <0x07708000 0x10000>;
                        reg-names = "lpass-lpaif";
@@ -594,7 +594,7 @@ sdhc_1: sdhci@7824000 {
                        reg = <0x07824900 0x11c>, <0x07824000 0x800>;
                        reg-names = "hc_mem", "core_mem";
 
-                       interrupts = <0 123 0>, <0 138 0>;
+                       interrupts = <0 123 IRQ_TYPE_LEVEL_HIGH>, <0 138 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "hc_irq", "pwr_irq";
                        clocks = <&gcc GCC_SDCC1_APPS_CLK>,
                                 <&gcc GCC_SDCC1_AHB_CLK>,
@@ -611,7 +611,7 @@ sdhc_2: sdhci@7864000 {
                        reg = <0x07864900 0x11c>, <0x07864000 0x800>;
                        reg-names = "hc_mem", "core_mem";
 
-                       interrupts = <0 125 0>, <0 221 0>;
+                       interrupts = <0 125 IRQ_TYPE_LEVEL_HIGH>, <0 221 IRQ_TYPE_LEVEL_HIGH>;
                        interrupt-names = "hc_irq", "pwr_irq";
                        clocks = <&gcc GCC_SDCC2_APPS_CLK>,
                                 <&gcc GCC_SDCC2_AHB_CLK>,
@@ -818,7 +818,7 @@ iommu-ctx@1000 {
                        iommu-ctx@2000 {
                                compatible = "qcom,msm-iommu-v1-ns";
                                reg = <0x2000 0x1000>;
-                               interrupts = <GIC_SPI 242 0>;
+                               interrupts = <GIC_SPI 242 IRQ_TYPE_LEVEL_HIGH>;
                        };
                };
 
@@ -862,7 +862,7 @@ mdss: mdss@1a00000 {
                                      "bus_clk",
                                      "vsync_clk";
 
-                       interrupts = <0 72 0>;
+                       interrupts = <0 72 IRQ_TYPE_LEVEL_HIGH>;
 
                        interrupt-controller;
                        #interrupt-cells = <1>;
index 4542133916711bf25f83d3251d0c8403b859fc7b..8c69516f97ed01dbb9ef438c629c43a4e7436628 100644 (file)
@@ -38,4 +38,21 @@ serial@f991e000 {
                        pinctrl-1 = <&blsp1_uart2_sleep>;
                };
        };
+
+       reserved-memory {
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;
+
+               ramoops@1ff00000 {
+                       compatible = "ramoops";
+                       reg = <0x0 0x1ff00000 0x0 0x40000>;
+                       console-size = <0x10000>;
+                       record-size = <0x10000>;
+                       ftrace-size = <0x10000>;
+                       pmsg-size = <0x20000>;
+               };
+       };
 };
+
+#include "msm8994-smd-rpm.dtsi"
index d2a26f0f8d7389e73eb9d37f7e0d08c47e04b28a..31bc9d98e31f67e8847e817808eb26627bf5c5f9 100644 (file)
@@ -35,4 +35,64 @@ pinconf {
                        bias-pull-down;
                };
        };
+
+       /* 0-3 for sdc1 4-6 for sdc2 */
+       /* Order of pins */
+       /* SDC1: CLK -> 0, CMD -> 1, DATA -> 2, RCLK -> 3 */
+       /* SDC2: CLK -> 4, CMD -> 5, DATA -> 6 */
+       sdc1_clk_on: clk-on {
+               pinconf {
+                       pins = "sdc1_clk";
+                       bias-disable = <0>; /* No pull */
+                       drive-strength = <16>; /* 16mA */
+               };
+       };
+
+       sdc1_clk_off: clk-off {
+               pinconf {
+                       pins = "sdc1_clk";
+                       bias-disable = <0>; /* No pull */
+                       drive-strength = <2>; /* 2mA */
+               };
+       };
+
+       sdc1_cmd_on: cmd-on {
+               pinconf {
+                       pins = "sdc1_cmd";
+                       bias-pull-up;
+                       drive-strength = <8>;
+               };
+       };
+
+       sdc1_cmd_off: cmd-off {
+               pinconf {
+                       pins = "sdc1_cmd";
+                       bias-pull-up = <0x3>; /* same as 3.10 ?? */
+                       drive-strength = <2>; /* 2mA */
+               };
+       };
+
+       sdc1_data_on: data-on {
+               pinconf {
+                       pins = "sdc1_data";
+                       bias-pull-up;
+                       drive-strength = <8>; /* 8mA */
+               };
+       };
+
+       sdc1_data_off: data-off {
+               pinconf {
+                       pins = "sdc1_data";
+                       bias-pull-up;
+                       drive-strength = <2>;
+               };
+       };
+
+       sdc1_rclk_on: rclk-on {
+               bias-pull-down; /* pull down */
+       };
+
+       sdc1_rclk_off: rclk-off {
+               bias-pull-down; /* pull down */
+       };
 };
index 171578747ed083873d19e5c2152bea18d319f1e7..cf5cacdd624d8e05fa548ea2752cd5bc34ed7d5d 100644 (file)
@@ -202,6 +202,31 @@ clock_gcc: clock-controller@fc400000 {
                        reg = <0xfc400000 0x2000>;
                };
 
+               sdhci1: mmc@f9824900 {
+                       compatible = "qcom,sdhci-msm-v4";
+                       reg = <0xf9824900 0x1a0>, <0xf9824000 0x800>;
+                       reg-names = "hc_mem", "core_mem";
+
+                       interrupts = <GIC_SPI 123 IRQ_TYPE_NONE>,
+                                       <GIC_SPI 138 IRQ_TYPE_NONE>;
+                       interrupt-names = "hc_irq", "pwr_irq";
+
+                       clocks = <&clock_gcc GCC_SDCC1_APPS_CLK>,
+                               <&clock_gcc GCC_SDCC1_AHB_CLK>;
+                       clock-names = "core", "iface";
+
+                       pinctrl-names = "default", "sleep";
+                       pinctrl-0 = <&sdc1_clk_on &sdc1_cmd_on &sdc1_data_on
+                                       &sdc1_rclk_on>;
+                       pinctrl-1 = <&sdc1_clk_off &sdc1_cmd_off &sdc1_data_off
+                                       &sdc1_rclk_off>;
+
+                       regulator-always-on;
+                       bus-width = <8>;
+                       mmc-hs400-1_8v;
+                       status = "okay";
+               };
+
                rpm_msg_ram: memory@fc428000 {
                        compatible = "qcom,rpm-msg-ram";
                        reg = <0xfc428000 0x4000>;
@@ -231,7 +256,67 @@ smem_region: smem@6a00000 {
                };
        };
 
+       smd_rpm: smd {
+               compatible = "qcom,smd";
+               rpm {
+                       interrupts = <GIC_SPI 168 IRQ_TYPE_EDGE_RISING>;
+                       qcom,ipc = <&apcs 8 0>;
+                       qcom,smd-edge = <15>;
+                       qcom,local-pid = <0>;
+                       qcom,remote-pid = <6>;
+
+                       rpm-requests {
+                               compatible = "qcom,rpm-msm8994";
+                               qcom,smd-channels = "rpm_requests";
+
+                               pm8994-regulators {
+                                       compatible = "qcom,rpm-pm8994-regulators";
+
+                                       pm8994_s1: s1 {};
+                                       pm8994_s2: s2 {};
+                                       pm8994_s3: s3 {};
+                                       pm8994_s4: s4 {};
+                                       pm8994_s5: s5 {};
+                                       pm8994_s6: s6 {};
+                                       pm8994_s7: s7 {};
+
+                                       pm8994_l1: l1 {};
+                                       pm8994_l2: l2 {};
+                                       pm8994_l3: l3 {};
+                                       pm8994_l4: l4 {};
+                                       pm8994_l6: l6 {};
+                                       pm8994_l8: l8 {};
+                                       pm8994_l9: l9 {};
+                                       pm8994_l10: l10 {};
+                                       pm8994_l11: l11 {};
+                                       pm8994_l12: l12 {};
+                                       pm8994_l13: l13 {};
+                                       pm8994_l14: l14 {};
+                                       pm8994_l15: l15 {};
+                                       pm8994_l16: l16 {};
+                                       pm8994_l17: l17 {};
+                                       pm8994_l18: l18 {};
+                                       pm8994_l19: l19 {};
+                                       pm8994_l20: l20 {};
+                                       pm8994_l21: l21 {};
+                                       pm8994_l22: l22 {};
+                                       pm8994_l23: l23 {};
+                                       pm8994_l24: l24 {};
+                                       pm8994_l25: l25 {};
+                                       pm8994_l26: l26 {};
+                                       pm8994_l27: l27 {};
+                                       pm8994_l28: l28 {};
+                                       pm8994_l29: l29 {};
+                                       pm8994_l30: l30 {};
+                                       pm8994_l31: l31 {};
+                                       pm8994_l32: l32 {};
+
+                                       pm8994_lvs1: lvs1 {};
+                                       pm8994_lvs2: lvs2 {};
+                               };
+                       };
+               };
+       };
 };
 
-
 #include "msm8992-pins.dtsi"
diff --git a/arch/arm64/boot/dts/qcom/msm8994-smd-rpm.dtsi b/arch/arm64/boot/dts/qcom/msm8994-smd-rpm.dtsi
new file mode 100644 (file)
index 0000000..47ebd16
--- /dev/null
@@ -0,0 +1,276 @@
+/* Copyright (c) 2015, LGE Inc. All rights reserved.
+ * 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.
+ */
+
+&smd_rpm {
+       rpm {
+               rpm_requests {
+                       pm8994-regulators {
+
+                               vdd_l1-supply = <&pm8994_s1>;
+                               vdd_l2_26_28-supply = <&pm8994_s3>;
+                               vdd_l3_11-supply = <&pm8994_s3>;
+                               vdd_l4_27_31-supply = <&pm8994_s3>;
+                               vdd_l5_7-supply = <&pm8994_s3>;
+                               vdd_l6_12_32-supply = <&pm8994_s5>;
+                               vdd_l8_16_30-supply = <&vreg_vph_pwr>;
+                               vdd_l9_10_18_22-supply = <&vreg_vph_pwr>;
+                               vdd_l13_19_23_24-supply = <&vreg_vph_pwr>;
+                               vdd_l14_15-supply = <&pm8994_s5>;
+                               vdd_l17_29-supply = <&vreg_vph_pwr>;
+                               vdd_l20_21-supply = <&vreg_vph_pwr>;
+                               vdd_l25-supply = <&pm8994_s5>;
+                               vdd_lvs1_2 = <&pm8994_s4>;
+
+                               s1 {
+                                       regulator-min-microvolt = <800000>;
+                                       regulator-max-microvolt = <800000>;
+                               };
+
+                               s2 {
+                                       /* TODO */
+                               };
+
+                               s3 {
+                                       regulator-min-microvolt = <1300000>;
+                                       regulator-max-microvolt = <1300000>;
+                               };
+
+                               s4 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       regulator-allow-set-load;
+                                       regulator-system-load = <325000>;
+                               };
+
+                               s5 {
+                                       regulator-min-microvolt = <2150000>;
+                                       regulator-max-microvolt = <2150000>;
+                               };
+
+                               s7 {
+                                       regulator-min-microvolt = <1000000>;
+                                       regulator-max-microvolt = <1000000>;
+                               };
+
+                               l1 {
+                                       regulator-min-microvolt = <1000000>;
+                                       regulator-max-microvolt = <1000000>;
+                               };
+
+                               l2 {
+                                       regulator-min-microvolt = <1250000>;
+                                       regulator-max-microvolt = <1250000>;
+                               };
+
+                               l3 {
+                                       regulator-min-microvolt = <1200000>;
+                                       regulator-max-microvolt = <1200000>;
+                               };
+
+                               l4 {
+                                       regulator-min-microvolt = <1225000>;
+                                       regulator-max-microvolt = <1225000>;
+                               };
+
+                               l5 {
+                                       /* TODO */
+                               };
+
+                               l6 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                               };
+
+                               l7 {
+                                       /* TODO */
+                               };
+
+                               l8 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                               };
+
+                               l9 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                               };
+
+                               l10 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       qcom,init-voltage = <1800000>;
+                               };
+
+                               l11 {
+                                       regulator-min-microvolt = <1200000>;
+                                       regulator-max-microvolt = <1200000>;
+                                       qcom,init-voltage = <1200000>;
+                               };
+
+                               l12 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       qcom,init-voltage = <1800000>;
+                                       proxy-supply = <&pm8994_l12>;
+                                       qcom,proxy-consumer-enable;
+                                       qcom,proxy-consumer-current = <10000>;
+                                       status = "okay";
+                               };
+
+                               l13 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <2950000>;
+                                       qcom,init-voltage = <2950000>;
+                                       status = "okay";
+                               };
+
+                               l14 {
+                                       regulator-min-microvolt = <1200000>;
+                                       regulator-max-microvolt = <1200000>;
+                                       qcom,init-voltage = <1200000>;
+                                       proxy-supply = <&pm8994_l14>;
+                                       qcom,proxy-consumer-enable;
+                                       qcom,proxy-consumer-current = <10000>;
+                                       status = "okay";
+                               };
+
+                               l15 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       qcom,init-voltage = <1800000>;
+                                       status = "okay";
+                               };
+
+                               l16 {
+                                       regulator-min-microvolt = <2700000>;
+                                       regulator-max-microvolt = <2700000>;
+                                       qcom,init-voltage = <2700000>;
+                                       status = "okay";
+                               };
+
+                               l17 {
+                                       regulator-min-microvolt = <2700000>;
+                                       regulator-max-microvolt = <2700000>;
+                                       qcom,init-voltage = <2700000>;
+                                       status = "okay";
+                               };
+
+                               l18 {
+                                       regulator-min-microvolt = <3000000>;
+                                       regulator-max-microvolt = <3000000>;
+                                       regulator-always-on;
+                                       qcom,init-voltage = <3000000>;
+                                       qcom,init-ldo-mode = <1>;
+                               };
+
+                               l19 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       qcom,init-voltage = <1800000>;
+                                       status = "okay";
+                               };
+
+                               l20 {
+                                       regulator-min-microvolt = <2950000>;
+                                       regulator-max-microvolt = <2950000>;
+                                       regulator-always-on;
+                                       regulator-boot-on;
+                                       regulator-allow-set-load;
+                                       regulator-system-load = <570000>;
+                               };
+
+                               l21 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       regulator-always-on;
+                                       qcom,init-voltage = <1800000>;
+                               };
+
+                               l22 {
+                                       regulator-min-microvolt = <3100000>;
+                                       regulator-max-microvolt = <3100000>;
+                                       qcom,init-voltage = <3100000>;
+                               };
+
+                               l23 {
+                                       regulator-min-microvolt = <2800000>;
+                                       regulator-max-microvolt = <2800000>;
+                                       qcom,init-voltage = <2800000>;
+                               };
+
+                               l24 {
+                                       regulator-min-microvolt = <3075000>;
+                                       regulator-max-microvolt = <3150000>;
+                                       qcom,init-voltage = <3075000>;
+                               };
+
+                               l25 {
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       qcom,init-voltage = <1800000>;
+                               };
+
+                               l26 {
+                                       /* TODO: value from downstream
+                                       regulator-min-microvolt = <987500>;
+                                       fails to apply */
+                               };
+
+                               l27 {
+                                       regulator-min-microvolt = <1050000>;
+                                       regulator-max-microvolt = <1050000>;
+                                       qcom,init-voltage = <1050000>;
+                               };
+
+                               l28 {
+                                       regulator-min-microvolt = <1000000>;
+                                       regulator-max-microvolt = <1000000>;
+                                       qcom,init-voltage = <1000000>;
+                                       proxy-supply = <&pm8994_l28>;
+                                       qcom,proxy-consumer-enable;
+                                       qcom,proxy-consumer-current = <10000>;
+                               };
+
+                               l29 {
+                                       /* TODO: Unsupported voltage range.
+                                       regulator-min-microvolt = <2800000>;
+                                       regulator-max-microvolt = <2800000>;
+                                       qcom,init-voltage = <2800000>;
+                                       */
+                               };
+
+                               l30 {
+                                       /* TODO: get this verified
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       qcom,init-voltage = <1800000>;
+                                       */
+                               };
+
+                               l31 {
+                                       regulator-min-microvolt = <1262500>;
+                                       regulator-max-microvolt = <1262500>;
+                                       qcom,init-voltage = <1262500>;
+                               };
+
+                               l32 {
+                                       /* TODO: get this verified
+                                       regulator-min-microvolt = <1800000>;
+                                       regulator-max-microvolt = <1800000>;
+                                       qcom,init-voltage = <1800000>;
+                                       */
+                               };
+                       };
+               };
+       };
+};
index f8e49d0b468123f75251d7f975a42d65547bd373..8c7f9ca25b5340f51be48abca6e435f5a6293f7e 100644 (file)
@@ -447,7 +447,7 @@ blsp1_spi0: spi@7575000 {
                blsp2_i2c0: i2c@75b5000 {
                        compatible = "qcom,i2c-qup-v2.2.1";
                        reg = <0x075b5000 0x1000>;
-                       interrupts = <GIC_SPI 101 0>;
+                       interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc GCC_BLSP2_AHB_CLK>,
                                <&gcc GCC_BLSP2_QUP1_I2C_APPS_CLK>;
                        clock-names = "iface", "core";
@@ -478,7 +478,7 @@ blsp2_uart1: serial@75b0000 {
                blsp2_i2c1: i2c@75b6000 {
                        compatible = "qcom,i2c-qup-v2.2.1";
                        reg = <0x075b6000 0x1000>;
-                       interrupts = <GIC_SPI 102 0>;
+                       interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc GCC_BLSP2_AHB_CLK>,
                                <&gcc GCC_BLSP2_QUP2_I2C_APPS_CLK>;
                        clock-names = "iface", "core";
@@ -503,7 +503,7 @@ blsp2_uart2: serial@75b1000 {
                blsp1_i2c2: i2c@7577000 {
                        compatible = "qcom,i2c-qup-v2.2.1";
                        reg = <0x07577000 0x1000>;
-                       interrupts = <GIC_SPI 97 0>;
+                       interrupts = <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&gcc GCC_BLSP1_AHB_CLK>,
                                <&gcc GCC_BLSP1_QUP3_I2C_APPS_CLK>;
                        clock-names = "iface", "core";
@@ -536,7 +536,8 @@ sdhc2: sdhci@74a4900 {
                         reg = <0x74a4900 0x314>, <0x74a4000 0x800>;
                         reg-names = "hc_mem", "core_mem";
 
-                        interrupts = <0 125 0>, <0 221 0>;
+                        interrupts = <0 125 IRQ_TYPE_LEVEL_HIGH>,
+                                     <0 221 IRQ_TYPE_LEVEL_HIGH>;
                         interrupt-names = "hc_irq", "pwr_irq";
 
                         clock-names = "iface", "core", "xo";
@@ -633,6 +634,91 @@ spmi_bus: qcom,spmi@400f000 {
                        #interrupt-cells = <4>;
                };
 
+               ufsphy: phy@627000 {
+                       compatible = "qcom,msm8996-ufs-phy-qmp-14nm";
+                       reg = <0x627000 0xda8>;
+                       reg-names = "phy_mem";
+                       #phy-cells = <0>;
+
+                       vdda-phy-supply = <&pm8994_l28>;
+                       vdda-pll-supply = <&pm8994_l12>;
+
+                       vdda-phy-max-microamp = <18380>;
+                       vdda-pll-max-microamp = <9440>;
+
+                       vddp-ref-clk-supply = <&pm8994_l25>;
+                       vddp-ref-clk-max-microamp = <100>;
+                       vddp-ref-clk-always-on;
+
+                       clock-names = "ref_clk_src", "ref_clk";
+                       clocks = <&rpmcc RPM_SMD_LN_BB_CLK>,
+                                <&gcc GCC_UFS_CLKREF_CLK>;
+                       status = "disabled";
+               };
+
+               ufshc@624000 {
+                       compatible = "qcom,ufshc";
+                       reg = <0x624000 0x2500>;
+                       interrupts = <GIC_SPI 265 IRQ_TYPE_LEVEL_HIGH>;
+
+                       phys = <&ufsphy>;
+                       phy-names = "ufsphy";
+
+                       vcc-supply = <&pm8994_l20>;
+                       vccq-supply = <&pm8994_l25>;
+                       vccq2-supply = <&pm8994_s4>;
+
+                       vcc-max-microamp = <600000>;
+                       vccq-max-microamp = <450000>;
+                       vccq2-max-microamp = <450000>;
+
+                       power-domains = <&gcc UFS_GDSC>;
+
+                       clock-names =
+                               "core_clk_src",
+                               "core_clk",
+                               "bus_clk",
+                               "bus_aggr_clk",
+                               "iface_clk",
+                               "core_clk_unipro_src",
+                               "core_clk_unipro",
+                               "core_clk_ice",
+                               "ref_clk",
+                               "tx_lane0_sync_clk",
+                               "rx_lane0_sync_clk";
+                       clocks =
+                               <&gcc UFS_AXI_CLK_SRC>,
+                               <&gcc GCC_UFS_AXI_CLK>,
+                               <&gcc GCC_SYS_NOC_UFS_AXI_CLK>,
+                               <&gcc GCC_AGGRE2_UFS_AXI_CLK>,
+                               <&gcc GCC_UFS_AHB_CLK>,
+                               <&gcc UFS_ICE_CORE_CLK_SRC>,
+                               <&gcc GCC_UFS_UNIPRO_CORE_CLK>,
+                               <&gcc GCC_UFS_ICE_CORE_CLK>,
+                               <&rpmcc RPM_SMD_LN_BB_CLK>,
+                               <&gcc GCC_UFS_TX_SYMBOL_0_CLK>,
+                               <&gcc GCC_UFS_RX_SYMBOL_0_CLK>;
+                       freq-table-hz =
+                               <100000000 200000000>,
+                               <0 0>,
+                               <0 0>,
+                               <0 0>,
+                               <0 0>,
+                               <150000000 300000000>,
+                               <0 0>,
+                               <0 0>,
+                               <0 0>,
+                               <0 0>,
+                               <0 0>;
+
+                       lanes-per-direction = <1>;
+                       status = "disabled";
+
+                       ufs_variant {
+                               compatible = "qcom,ufs_variant";
+                       };
+               };
+
                mmcc: clock-controller@8c0000 {
                        compatible = "qcom,mmcc-msm8996";
                        #clock-cells = <1>;
@@ -819,7 +905,7 @@ usb2: usb@7600000 {
                        dwc3@7600000 {
                                compatible = "snps,dwc3";
                                reg = <0x7600000 0xcc00>;
-                               interrupts = <0 138 0>;
+                               interrupts = <0 138 IRQ_TYPE_LEVEL_HIGH>;
                                phys = <&hsusb_phy2>;
                                phy-names = "usb2-phy";
                        };
@@ -848,7 +934,7 @@ usb3: usb@6a00000 {
                        dwc3@6a00000 {
                                compatible = "snps,dwc3";
                                reg = <0x6a00000 0xcc00>;
-                               interrupts = <0 131 0>;
+                               interrupts = <0 131 IRQ_TYPE_LEVEL_HIGH>;
                                phys = <&hsusb_phy1>, <&ssusb_phy_0>;
                                phy-names = "usb2-phy", "usb3-phy";
                        };
@@ -861,7 +947,7 @@ agnoc@0 {
                        #size-cells = <1>;
                        ranges;
 
-                       pcie0: qcom,pcie@600000 {
+                       pcie0: pcie@600000 {
                                compatible = "qcom,pcie-msm8996", "snps,dw-pcie";
                                status = "disabled";
                                power-domains = <&gcc PCIE0_GDSC>;
@@ -882,7 +968,7 @@ pcie0: qcom,pcie@600000 {
                                ranges = <0x01000000 0x0 0x0c200000 0x0c200000 0x0 0x100000>,
                                        <0x02000000 0x0 0x0c300000 0x0c300000 0x0 0xd00000>;
 
-                               interrupts = <GIC_SPI 405 IRQ_TYPE_NONE>;
+                               interrupts = <GIC_SPI 405 IRQ_TYPE_LEVEL_HIGH>;
                                interrupt-names = "msi";
                                #interrupt-cells = <1>;
                                interrupt-map-mask = <0 0 0 0x7>;
@@ -914,7 +1000,7 @@ pcie0: qcom,pcie@600000 {
 
                        };
 
-                       pcie1: qcom,pcie@608000 {
+                       pcie1: pcie@608000 {
                                compatible = "qcom,pcie-msm8996", "snps,dw-pcie";
                                power-domains = <&gcc PCIE1_GDSC>;
                                bus-range = <0x00 0xff>;
@@ -937,7 +1023,7 @@ pcie1: qcom,pcie@608000 {
                                ranges = <0x01000000 0x0 0x0d200000 0x0d200000 0x0 0x100000>,
                                        <0x02000000 0x0 0x0d300000 0x0d300000 0x0 0xd00000>;
 
-                               interrupts = <GIC_SPI 413 IRQ_TYPE_NONE>;
+                               interrupts = <GIC_SPI 413 IRQ_TYPE_LEVEL_HIGH>;
                                interrupt-names = "msi";
                                #interrupt-cells = <1>;
                                interrupt-map-mask = <0 0 0 0x7>;
@@ -967,7 +1053,7 @@ pcie1: qcom,pcie@608000 {
                                                "bus_slave";
                        };
 
-                       pcie2: qcom,pcie@610000 {
+                       pcie2: pcie@610000 {
                                compatible = "qcom,pcie-msm8996", "snps,dw-pcie";
                                power-domains = <&gcc PCIE2_GDSC>;
                                bus-range = <0x00 0xff>;
@@ -990,7 +1076,7 @@ pcie2: qcom,pcie@610000 {
 
                                device_type = "pci";
 
-                               interrupts = <GIC_SPI 421 IRQ_TYPE_NONE>;
+                               interrupts = <GIC_SPI 421 IRQ_TYPE_LEVEL_HIGH>;
                                interrupt-names = "msi";
                                #interrupt-cells = <1>;
                                interrupt-map-mask = <0 0 0 0x7>;
diff --git a/arch/arm64/boot/dts/qcom/sdm845-mtp.dts b/arch/arm64/boot/dts/qcom/sdm845-mtp.dts
new file mode 100644 (file)
index 0000000..979ab49
--- /dev/null
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * SDM845 MTP board device tree source
+ *
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+/dts-v1/;
+
+#include "sdm845.dtsi"
+
+/ {
+       model = "Qualcomm Technologies, Inc. SDM845 MTP";
+       compatible = "qcom,sdm845-mtp";
+};
diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
new file mode 100644 (file)
index 0000000..cdaabeb
--- /dev/null
@@ -0,0 +1,327 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * SDM845 SoC device tree source
+ *
+ * Copyright (c) 2018, The Linux Foundation. All rights reserved.
+ */
+
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+/ {
+       interrupt-parent = <&intc>;
+
+       #address-cells = <2>;
+       #size-cells = <2>;
+
+       chosen { };
+
+       memory@80000000 {
+               device_type = "memory";
+               /* We expect the bootloader to fill in the size */
+               reg = <0 0x80000000 0 0>;
+       };
+
+       reserved-memory {
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;
+
+               memory@85fc0000 {
+                       reg = <0 0x85fc0000 0 0x20000>;
+                       no-map;
+               };
+
+               memory@85fe0000 {
+                       compatible = "qcom,cmd-db";
+                       reg = <0x0 0x85fe0000 0x0 0x20000>;
+                       no-map;
+               };
+
+               smem_mem: memory@86000000 {
+                       reg = <0x0 0x86000000 0x0 0x200000>;
+                       no-map;
+               };
+
+               memory@86200000 {
+                       reg = <0 0x86200000 0 0x2d00000>;
+                       no-map;
+               };
+       };
+
+       cpus {
+               #address-cells = <2>;
+               #size-cells = <0>;
+
+               CPU0: cpu@0 {
+                       device_type = "cpu";
+                       compatible = "qcom,kryo385";
+                       reg = <0x0 0x0>;
+                       enable-method = "psci";
+                       next-level-cache = <&L2_0>;
+                       L2_0: l2-cache {
+                               compatible = "cache";
+                               next-level-cache = <&L3_0>;
+                               L3_0: l3-cache {
+                                     compatible = "cache";
+                               };
+                       };
+               };
+
+               CPU1: cpu@100 {
+                       device_type = "cpu";
+                       compatible = "qcom,kryo385";
+                       reg = <0x0 0x100>;
+                       enable-method = "psci";
+                       next-level-cache = <&L2_100>;
+                       L2_100: l2-cache {
+                               compatible = "cache";
+                               next-level-cache = <&L3_0>;
+                       };
+               };
+
+               CPU2: cpu@200 {
+                       device_type = "cpu";
+                       compatible = "qcom,kryo385";
+                       reg = <0x0 0x200>;
+                       enable-method = "psci";
+                       next-level-cache = <&L2_200>;
+                       L2_200: l2-cache {
+                               compatible = "cache";
+                               next-level-cache = <&L3_0>;
+                       };
+               };
+
+               CPU3: cpu@300 {
+                       device_type = "cpu";
+                       compatible = "qcom,kryo385";
+                       reg = <0x0 0x300>;
+                       enable-method = "psci";
+                       next-level-cache = <&L2_300>;
+                       L2_300: l2-cache {
+                               compatible = "cache";
+                               next-level-cache = <&L3_0>;
+                       };
+               };
+
+               CPU4: cpu@400 {
+                       device_type = "cpu";
+                       compatible = "qcom,kryo385";
+                       reg = <0x0 0x400>;
+                       enable-method = "psci";
+                       next-level-cache = <&L2_400>;
+                       L2_400: l2-cache {
+                               compatible = "cache";
+                               next-level-cache = <&L3_0>;
+                       };
+               };
+
+               CPU5: cpu@500 {
+                       device_type = "cpu";
+                       compatible = "qcom,kryo385";
+                       reg = <0x0 0x500>;
+                       enable-method = "psci";
+                       next-level-cache = <&L2_500>;
+                       L2_500: l2-cache {
+                               compatible = "cache";
+                               next-level-cache = <&L3_0>;
+                       };
+               };
+
+               CPU6: cpu@600 {
+                       device_type = "cpu";
+                       compatible = "qcom,kryo385";
+                       reg = <0x0 0x600>;
+                       enable-method = "psci";
+                       next-level-cache = <&L2_600>;
+                       L2_600: l2-cache {
+                               compatible = "cache";
+                               next-level-cache = <&L3_0>;
+                       };
+               };
+
+               CPU7: cpu@700 {
+                       device_type = "cpu";
+                       compatible = "qcom,kryo385";
+                       reg = <0x0 0x700>;
+                       enable-method = "psci";
+                       next-level-cache = <&L2_700>;
+                       L2_700: l2-cache {
+                               compatible = "cache";
+                               next-level-cache = <&L3_0>;
+                       };
+               };
+       };
+
+       timer {
+               compatible = "arm,armv8-timer";
+               interrupts = <GIC_PPI 1 IRQ_TYPE_LEVEL_LOW>,
+                            <GIC_PPI 2 IRQ_TYPE_LEVEL_LOW>,
+                            <GIC_PPI 3 IRQ_TYPE_LEVEL_LOW>,
+                            <GIC_PPI 0 IRQ_TYPE_LEVEL_LOW>;
+       };
+
+       clocks {
+               xo_board: xo-board {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <38400000>;
+                       clock-output-names = "xo_board";
+               };
+
+               sleep_clk: sleep-clk {
+                       compatible = "fixed-clock";
+                       #clock-cells = <0>;
+                       clock-frequency = <32764>;
+               };
+       };
+
+       tcsr_mutex: hwlock {
+               compatible = "qcom,tcsr-mutex";
+               syscon = <&tcsr_mutex_regs 0 0x1000>;
+               #hwlock-cells = <1>;
+       };
+
+       smem {
+               compatible = "qcom,smem";
+               memory-region = <&smem_mem>;
+               hwlocks = <&tcsr_mutex 3>;
+       };
+
+       psci {
+               compatible = "arm,psci-1.0";
+               method = "smc";
+       };
+
+       soc: soc {
+               #address-cells = <1>;
+               #size-cells = <1>;
+               ranges = <0 0 0 0xffffffff>;
+               compatible = "simple-bus";
+
+               gcc: clock-controller@100000 {
+                       compatible = "qcom,gcc-sdm845";
+                       reg = <0x100000 0x1f0000>;
+                       #clock-cells = <1>;
+                       #reset-cells = <1>;
+                       #power-domain-cells = <1>;
+               };
+
+               tcsr_mutex_regs: syscon@1f40000 {
+                       compatible = "syscon";
+                       reg = <0x1f40000 0x40000>;
+               };
+
+               tlmm: pinctrl@3400000 {
+                       compatible = "qcom,sdm845-pinctrl";
+                       reg = <0x03400000 0xc00000>;
+                       interrupts = <GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH>;
+                       gpio-controller;
+                       #gpio-cells = <2>;
+                       interrupt-controller;
+                       #interrupt-cells = <2>;
+               };
+
+               spmi_bus: spmi@c440000 {
+                       compatible = "qcom,spmi-pmic-arb";
+                       reg = <0xc440000 0x1100>,
+                             <0xc600000 0x2000000>,
+                             <0xe600000 0x100000>,
+                             <0xe700000 0xa0000>,
+                             <0xc40a000 0x26000>;
+                       reg-names = "core", "chnls", "obsrvr", "intr", "cnfg";
+                       interrupt-names = "periph_irq";
+                       interrupts = <GIC_SPI 481 IRQ_TYPE_LEVEL_HIGH>;
+                       qcom,ee = <0>;
+                       qcom,channel = <0>;
+                       #address-cells = <2>;
+                       #size-cells = <0>;
+                       interrupt-controller;
+                       #interrupt-cells = <4>;
+                       cell-index = <0>;
+               };
+
+               apss_shared: mailbox@17990000 {
+                       compatible = "qcom,sdm845-apss-shared";
+                       reg = <0x17990000 0x1000>;
+                       #mbox-cells = <1>;
+               };
+
+               intc: interrupt-controller@17a00000 {
+                       compatible = "arm,gic-v3";
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       ranges;
+                       #interrupt-cells = <3>;
+                       interrupt-controller;
+                       reg = <0x17a00000 0x10000>,     /* GICD */
+                             <0x17a60000 0x100000>;    /* GICR * 8 */
+                       interrupts = <GIC_PPI 9 IRQ_TYPE_LEVEL_HIGH>;
+
+                       gic-its@17a40000 {
+                               compatible = "arm,gic-v3-its";
+                               msi-controller;
+                               #msi-cells = <1>;
+                               reg = <0x17a40000 0x20000>;
+                               status = "disabled";
+                       };
+               };
+
+               timer@17c90000 {
+                       #address-cells = <1>;
+                       #size-cells = <1>;
+                       ranges;
+                       compatible = "arm,armv7-timer-mem";
+                       reg = <0x17c90000 0x1000>;
+
+                       frame@17ca0000 {
+                               frame-number = <0>;
+                               interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>,
+                                            <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
+                               reg = <0x17ca0000 0x1000>,
+                                     <0x17cb0000 0x1000>;
+                       };
+
+                       frame@17cc0000 {
+                               frame-number = <1>;
+                               interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
+                               reg = <0x17cc0000 0x1000>;
+                               status = "disabled";
+                       };
+
+                       frame@17cd0000 {
+                               frame-number = <2>;
+                               interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
+                               reg = <0x17cd0000 0x1000>;
+                               status = "disabled";
+                       };
+
+                       frame@17ce0000 {
+                               frame-number = <3>;
+                               interrupts = <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>;
+                               reg = <0x17ce0000 0x1000>;
+                               status = "disabled";
+                       };
+
+                       frame@17cf0000 {
+                               frame-number = <4>;
+                               interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>;
+                               reg = <0x17cf0000 0x1000>;
+                               status = "disabled";
+                       };
+
+                       frame@17d00000 {
+                               frame-number = <5>;
+                               interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
+                               reg = <0x17d00000 0x1000>;
+                               status = "disabled";
+                       };
+
+                       frame@17d10000 {
+                               frame-number = <6>;
+                               interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
+                               reg = <0x17d10000 0x1000>;
+                               status = "disabled";
+                       };
+               };
+       };
+};
index 5ede06000ea46877a9828ebbe6fb4f42a4405225..9e2394bc3c6271ef264db5d8209045af119dbcf2 100644 (file)
@@ -9,5 +9,6 @@ dtb-$(CONFIG_ARCH_R8A7796) += r8a7796-m3ulcb-kf.dtb
 dtb-$(CONFIG_ARCH_R8A7796) += r8a7796-salvator-xs.dtb
 dtb-$(CONFIG_ARCH_R8A77965) += r8a77965-salvator-x.dtb r8a77965-salvator-xs.dtb
 dtb-$(CONFIG_ARCH_R8A77970) += r8a77970-eagle.dtb r8a77970-v3msk.dtb
-dtb-$(CONFIG_ARCH_R8A77980) += r8a77980-condor.dtb
+dtb-$(CONFIG_ARCH_R8A77980) += r8a77980-condor.dtb r8a77980-v3hsk.dtb
+dtb-$(CONFIG_ARCH_R8A77990) += r8a77990-ebisu.dtb
 dtb-$(CONFIG_ARCH_R8A77995) += r8a77995-draak.dtb
index 7f2a3d923f21ace85ef17e96cdef393f2e6429ba..3f46345a46447fce1ae323b1f632330a4af4a5a3 100644 (file)
@@ -56,6 +56,12 @@ &ehci2 {
        status = "okay";
 };
 
+&sound_card {
+       dais = <&rsnd_port0     /* ak4613 */
+               &rsnd_port1     /* HDMI0  */
+               &rsnd_port2>;   /* HDMI1  */
+};
+
 &hdmi0 {
        status = "okay";
 
@@ -66,6 +72,12 @@ rcar_dw_hdmi0_out: endpoint {
                                remote-endpoint = <&hdmi0_con>;
                        };
                };
+               port@2 {
+                       reg = <2>;
+                       dw_hdmi0_snd_in: endpoint {
+                               remote-endpoint = <&rsnd_endpoint1>;
+                       };
+               };
        };
 };
 
@@ -83,6 +95,12 @@ rcar_dw_hdmi1_out: endpoint {
                                remote-endpoint = <&hdmi1_con>;
                        };
                };
+               port@2 {
+                       reg = <2>;
+                       dw_hdmi1_snd_in: endpoint {
+                               remote-endpoint = <&rsnd_endpoint2>;
+                       };
+               };
        };
 };
 
@@ -94,6 +112,34 @@ &ohci2 {
        status = "okay";
 };
 
+&rcar_sound {
+       ports {
+               /* rsnd_port0 is on salvator-common */
+               rsnd_port1: port@1 {
+                       rsnd_endpoint1: endpoint {
+                               remote-endpoint = <&dw_hdmi0_snd_in>;
+
+                               dai-format = "i2s";
+                               bitclock-master = <&rsnd_endpoint1>;
+                               frame-master = <&rsnd_endpoint1>;
+
+                               playback = <&ssi2>;
+                       };
+               };
+               rsnd_port2: port@2 {
+                       rsnd_endpoint2: endpoint {
+                               remote-endpoint = <&dw_hdmi1_snd_in>;
+
+                               dai-format = "i2s";
+                               bitclock-master = <&rsnd_endpoint2>;
+                               frame-master = <&rsnd_endpoint2>;
+
+                               playback = <&ssi3>;
+                       };
+               };
+       };
+};
+
 &pfc {
        usb2_pins: usb2 {
                groups = "usb2";
index f9acd125d68750d571be091969ca49baa9f8d86c..e19dcd6cb76793d77bfbb91b01560b84fd6c283d 100644 (file)
@@ -39,7 +39,6 @@ ipmmu_sy: mmu@e7730000 {
                reg = <0 0xe7730000 0 0x1000>;
                renesas,ipmmu-main = <&ipmmu_mm 8>;
                #iommu-cells = <1>;
-               status = "disabled";
        };
 
        /delete-node/ usb-phy@ee0e0200;
@@ -108,6 +107,61 @@ fdp1@fe948000 {
                resets = <&cpg 117>;
                renesas,fcp = <&fcpf2>;
        };
+
+       csi21: csi2@fea90000 {
+               compatible = "renesas,r8a7795-csi2";
+               reg = <0 0xfea90000 0 0x10000>;
+               interrupts = <GIC_SPI 185 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&cpg CPG_MOD 713>;
+               power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+               resets = <&cpg 713>;
+               status = "disabled";
+
+               ports {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       port@1 {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               reg = <1>;
+
+                               csi21vin0: endpoint@0 {
+                                       reg = <0>;
+                                       remote-endpoint = <&vin0csi21>;
+                               };
+                               csi21vin1: endpoint@1 {
+                                       reg = <1>;
+                                       remote-endpoint = <&vin1csi21>;
+                               };
+                               csi21vin2: endpoint@2 {
+                                       reg = <2>;
+                                       remote-endpoint = <&vin2csi21>;
+                               };
+                               csi21vin3: endpoint@3 {
+                                       reg = <3>;
+                                       remote-endpoint = <&vin3csi21>;
+                               };
+                               csi21vin4: endpoint@4 {
+                                       reg = <4>;
+                                       remote-endpoint = <&vin4csi21>;
+                               };
+                               csi21vin5: endpoint@5 {
+                                       reg = <5>;
+                                       remote-endpoint = <&vin5csi21>;
+                               };
+                               csi21vin6: endpoint@6 {
+                                       reg = <6>;
+                                       remote-endpoint = <&vin6csi21>;
+                               };
+                               csi21vin7: endpoint@7 {
+                                       reg = <7>;
+                                       remote-endpoint = <&vin7csi21>;
+                               };
+                       };
+               };
+       };
 };
 
 &gpio1 {
@@ -175,3 +229,91 @@ &fcpvd2 {
 &du {
        vsps = <&vspd0 &vspd1 &vspd2 &vspd3>;
 };
+
+&vin0 {
+       ports {
+               port@1 {
+                       vin0csi21: endpoint@1 {
+                               reg = <1>;
+                               remote-endpoint= <&csi21vin0>;
+                       };
+               };
+       };
+};
+
+&vin1 {
+       ports {
+               port@1 {
+                       vin1csi21: endpoint@1 {
+                               reg = <1>;
+                               remote-endpoint= <&csi21vin1>;
+                       };
+               };
+       };
+};
+
+&vin2 {
+       ports {
+               port@1 {
+                       vin2csi21: endpoint@1 {
+                               reg = <1>;
+                               remote-endpoint= <&csi21vin2>;
+                       };
+               };
+       };
+};
+
+&vin3 {
+       ports {
+               port@1 {
+                       vin3csi21: endpoint@1 {
+                               reg = <1>;
+                               remote-endpoint= <&csi21vin3>;
+                       };
+               };
+       };
+};
+
+&vin4 {
+       ports {
+               port@1 {
+                       vin4csi21: endpoint@1 {
+                               reg = <1>;
+                               remote-endpoint= <&csi21vin4>;
+                       };
+               };
+       };
+};
+
+&vin5 {
+       ports {
+               port@1 {
+                       vin5csi21: endpoint@1 {
+                               reg = <1>;
+                               remote-endpoint= <&csi21vin5>;
+                       };
+               };
+       };
+};
+
+&vin6 {
+       ports {
+               port@1 {
+                       vin6csi21: endpoint@1 {
+                               reg = <1>;
+                               remote-endpoint= <&csi21vin6>;
+                       };
+               };
+       };
+};
+
+&vin7 {
+       ports {
+               port@1 {
+                       vin7csi21: endpoint@1 {
+                               reg = <1>;
+                               remote-endpoint= <&csi21vin7>;
+                       };
+               };
+       };
+};
index af467419266a9ea5a3b5161207ee849a72dc29c9..0efbef5ea9b7871d3b67065f92e83464f9bf4bc0 100644 (file)
@@ -56,6 +56,12 @@ &ehci2 {
        status = "okay";
 };
 
+&sound_card {
+       dais = <&rsnd_port0     /* ak4613 */
+               &rsnd_port1     /* HDMI0  */
+               &rsnd_port2>;   /* HDMI1  */
+};
+
 &hdmi0 {
        status = "okay";
 
@@ -66,6 +72,12 @@ rcar_dw_hdmi0_out: endpoint {
                                remote-endpoint = <&hdmi0_con>;
                        };
                };
+               port@2 {
+                       reg = <2>;
+                       dw_hdmi0_snd_in: endpoint {
+                               remote-endpoint = <&rsnd_endpoint1>;
+                       };
+               };
        };
 };
 
@@ -83,6 +95,12 @@ rcar_dw_hdmi1_out: endpoint {
                                remote-endpoint = <&hdmi1_con>;
                        };
                };
+               port@2 {
+                       reg = <2>;
+                       dw_hdmi1_snd_in: endpoint {
+                               remote-endpoint = <&rsnd_endpoint2>;
+                       };
+               };
        };
 };
 
@@ -94,6 +112,34 @@ &ohci2 {
        status = "okay";
 };
 
+&rcar_sound {
+       ports {
+               /* rsnd_port0 is on salvator-common */
+               rsnd_port1: port@1 {
+                       rsnd_endpoint1: endpoint {
+                               remote-endpoint = <&dw_hdmi0_snd_in>;
+
+                               dai-format = "i2s";
+                               bitclock-master = <&rsnd_endpoint1>;
+                               frame-master = <&rsnd_endpoint1>;
+
+                               playback = <&ssi2>;
+                       };
+               };
+               rsnd_port2: port@2 {
+                       rsnd_endpoint2: endpoint {
+                               remote-endpoint = <&dw_hdmi1_snd_in>;
+
+                               dai-format = "i2s";
+                               bitclock-master = <&rsnd_endpoint2>;
+                               frame-master = <&rsnd_endpoint2>;
+
+                               playback = <&ssi3>;
+                       };
+               };
+       };
+};
+
 &pfc {
        usb2_pins: usb2 {
                groups = "usb2";
index 8b50ceb746e814f73438a8594a48203ebf203174..e231b5a7cbabe48a5921354dac31349a1b359e55 100644 (file)
@@ -56,6 +56,22 @@ &ehci2 {
        status = "okay";
 };
 
+&ehci3 {
+       dr_mode = "otg";
+       status = "okay";
+};
+
+&hsusb3 {
+       dr_mode = "otg";
+       status = "okay";
+};
+
+&sound_card {
+       dais = <&rsnd_port0     /* ak4613 */
+               &rsnd_port1     /* HDMI0  */
+               &rsnd_port2>;   /* HDMI1  */
+};
+
 &hdmi0 {
        status = "okay";
 
@@ -66,6 +82,12 @@ rcar_dw_hdmi0_out: endpoint {
                                remote-endpoint = <&hdmi0_con>;
                        };
                };
+               port@2 {
+                       reg = <2>;
+                       dw_hdmi0_snd_in: endpoint {
+                               remote-endpoint = <&rsnd_endpoint1>;
+                       };
+               };
        };
 };
 
@@ -83,6 +105,12 @@ rcar_dw_hdmi1_out: endpoint {
                                remote-endpoint = <&hdmi1_con>;
                        };
                };
+               port@2 {
+                       reg = <2>;
+                       dw_hdmi1_snd_in: endpoint {
+                               remote-endpoint = <&rsnd_endpoint2>;
+                       };
+               };
        };
 };
 
@@ -94,11 +122,61 @@ &ohci2 {
        status = "okay";
 };
 
+&ohci3 {
+       dr_mode = "otg";
+       status = "okay";
+};
+
+&rcar_sound {
+       ports {
+               /* rsnd_port0 is on salvator-common */
+               rsnd_port1: port@1 {
+                       rsnd_endpoint1: endpoint {
+                               remote-endpoint = <&dw_hdmi0_snd_in>;
+
+                               dai-format = "i2s";
+                               bitclock-master = <&rsnd_endpoint1>;
+                               frame-master = <&rsnd_endpoint1>;
+
+                               playback = <&ssi2>;
+                       };
+               };
+               rsnd_port2: port@2 {
+                       rsnd_endpoint2: endpoint {
+                               remote-endpoint = <&dw_hdmi1_snd_in>;
+
+                               dai-format = "i2s";
+                               bitclock-master = <&rsnd_endpoint2>;
+                               frame-master = <&rsnd_endpoint2>;
+
+                               playback = <&ssi3>;
+                       };
+               };
+       };
+};
+
 &pfc {
        usb2_pins: usb2 {
                groups = "usb2";
                function = "usb2";
        };
+
+       /*
+        * - On Salvator-X[S], GP6_3[01] are connected to ADV7482 as irq pins
+        *   (when SW31 is the default setting on Salvator-XS).
+        * - If SW31 is the default setting, you cannot use USB2.0 ch3 on
+        *   r8a7795 with Salvator-XS.
+        *   Hence the SW31 setting must be changed like 2) below.
+        *   1) Default setting of SW31: ON-ON-OFF-OFF-OFF-OFF:
+        *      - Connect GP6_3[01] to ADV7842.
+        *   2) Changed setting of SW31: OFF-OFF-ON-ON-ON-ON:
+        *      - Connect GP6_3[01] to BD082065 (USB2.0 ch3's host power).
+        *      - Connect GP6_{04,21} to ADV7842.
+        */
+       usb2_ch3_pins: usb2_ch3 {
+               groups = "usb2_ch3";
+               function = "usb2_ch3";
+       };
 };
 
 &usb2_phy2 {
@@ -107,3 +185,10 @@ &usb2_phy2 {
 
        status = "okay";
 };
+
+&usb2_phy3 {
+       pinctrl-0 = <&usb2_ch3_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
index 1d5e3ac0231ca6ab31a55c1ab7bbdccd7dff002e..d842940b2f439d3500a79b1a7d924ee9e13f02da 100644 (file)
@@ -30,6 +30,91 @@ aliases {
                i2c7 = &i2c_dvfs;
        };
 
+       /*
+        * The external audio clocks are configured as 0 Hz fixed frequency
+        * clocks by default.
+        * Boards that provide audio clocks should override them.
+        */
+       audio_clk_a: audio_clk_a {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
+
+       audio_clk_b: audio_clk_b {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
+
+       audio_clk_c: audio_clk_c {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
+
+       /* External CAN clock - to be overridden by boards that provide it */
+       can_clk: can {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
+
+       cluster0_opp: opp_table0 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp-500000000 {
+                       opp-hz = /bits/ 64 <500000000>;
+                       opp-microvolt = <830000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1000000000 {
+                       opp-hz = /bits/ 64 <1000000000>;
+                       opp-microvolt = <830000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1500000000 {
+                       opp-hz = /bits/ 64 <1500000000>;
+                       opp-microvolt = <830000>;
+                       clock-latency-ns = <300000>;
+                       opp-suspend;
+               };
+               opp-1600000000 {
+                       opp-hz = /bits/ 64 <1600000000>;
+                       opp-microvolt = <900000>;
+                       clock-latency-ns = <300000>;
+                       turbo-mode;
+               };
+               opp-1700000000 {
+                       opp-hz = /bits/ 64 <1700000000>;
+                       opp-microvolt = <960000>;
+                       clock-latency-ns = <300000>;
+                       turbo-mode;
+               };
+       };
+
+       cluster1_opp: opp_table1 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp-800000000 {
+                       opp-hz = /bits/ 64 <800000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1000000000 {
+                       opp-hz = /bits/ 64 <1000000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1200000000 {
+                       opp-hz = /bits/ 64 <1200000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+               };
+       };
+
        cpus {
                #address-cells = <1>;
                #size-cells = <0>;
@@ -47,7 +132,7 @@ a57_0: cpu@0 {
                };
 
                a57_1: cpu@1 {
-                       compatible = "arm,cortex-a57","arm,armv8";
+                       compatible = "arm,cortex-a57", "arm,armv8";
                        reg = <0x1>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7795_PD_CA57_CPU1>;
@@ -59,7 +144,7 @@ a57_1: cpu@1 {
                };
 
                a57_2: cpu@2 {
-                       compatible = "arm,cortex-a57","arm,armv8";
+                       compatible = "arm,cortex-a57", "arm,armv8";
                        reg = <0x2>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7795_PD_CA57_CPU2>;
@@ -71,7 +156,7 @@ a57_2: cpu@2 {
                };
 
                a57_3: cpu@3 {
-                       compatible = "arm,cortex-a57","arm,armv8";
+                       compatible = "arm,cortex-a57", "arm,armv8";
                        reg = <0x3>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7795_PD_CA57_CPU3>;
@@ -94,7 +179,7 @@ a53_0: cpu@100 {
                };
 
                a53_1: cpu@101 {
-                       compatible = "arm,cortex-a53","arm,armv8";
+                       compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x101>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7795_PD_CA53_CPU1>;
@@ -105,7 +190,7 @@ a53_1: cpu@101 {
                };
 
                a53_2: cpu@102 {
-                       compatible = "arm,cortex-a53","arm,armv8";
+                       compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x102>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7795_PD_CA53_CPU2>;
@@ -116,7 +201,7 @@ a53_2: cpu@102 {
                };
 
                a53_3: cpu@103 {
-                       compatible = "arm,cortex-a53","arm,armv8";
+                       compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x103>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7795_PD_CA53_CPU3>;
@@ -155,91 +240,6 @@ extalr_clk: extalr {
                clock-frequency = <0>;
        };
 
-       /*
-        * The external audio clocks are configured as 0 Hz fixed frequency
-        * clocks by default.
-        * Boards that provide audio clocks should override them.
-        */
-       audio_clk_a: audio_clk_a {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
-       };
-
-       audio_clk_b: audio_clk_b {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
-       };
-
-       audio_clk_c: audio_clk_c {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
-       };
-
-       /* External CAN clock - to be overridden by boards that provide it */
-       can_clk: can {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
-       };
-
-       cluster0_opp: opp_table0 {
-               compatible = "operating-points-v2";
-               opp-shared;
-
-               opp-500000000 {
-                       opp-hz = /bits/ 64 <500000000>;
-                       opp-microvolt = <830000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1000000000 {
-                       opp-hz = /bits/ 64 <1000000000>;
-                       opp-microvolt = <830000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1500000000 {
-                       opp-hz = /bits/ 64 <1500000000>;
-                       opp-microvolt = <830000>;
-                       clock-latency-ns = <300000>;
-                       opp-suspend;
-               };
-               opp-1600000000 {
-                       opp-hz = /bits/ 64 <1600000000>;
-                       opp-microvolt = <900000>;
-                       clock-latency-ns = <300000>;
-                       turbo-mode;
-               };
-               opp-1700000000 {
-                       opp-hz = /bits/ 64 <1700000000>;
-                       opp-microvolt = <960000>;
-                       clock-latency-ns = <300000>;
-                       turbo-mode;
-               };
-       };
-
-       cluster1_opp: opp_table1 {
-               compatible = "operating-points-v2";
-               opp-shared;
-
-               opp-800000000 {
-                       opp-hz = /bits/ 64 <800000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1000000000 {
-                       opp-hz = /bits/ 64 <1000000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1200000000 {
-                       opp-hz = /bits/ 64 <1200000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-               };
-       };
-
        /* External PCIe clock - can be overridden by the board */
        pcie_bus_clk: pcie_bus {
                compatible = "fixed-clock";
@@ -247,18 +247,6 @@ pcie_bus_clk: pcie_bus {
                clock-frequency = <0>;
        };
 
-       pmu_a57 {
-               compatible = "arm,cortex-a57-pmu";
-               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
-                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>,
-                                     <&gic GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>,
-                                     <&gic GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-affinity = <&a57_0>,
-                                    <&a57_1>,
-                                    <&a57_2>,
-                                    <&a57_3>;
-       };
-
        pmu_a53 {
                compatible = "arm,cortex-a53-pmu";
                interrupts-extended = <&gic GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>,
@@ -271,6 +259,18 @@ pmu_a53 {
                                     <&a53_3>;
        };
 
+       pmu_a57 {
+               compatible = "arm,cortex-a57-pmu";
+               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&a57_0>,
+                                    <&a57_1>,
+                                    <&a57_2>,
+                                    <&a57_3>;
+       };
+
        psci {
                compatible = "arm,psci-1.0", "arm,psci-0.2";
                method = "smc";
@@ -291,23 +291,6 @@ soc: soc {
                #size-cells = <2>;
                ranges;
 
-               gic: interrupt-controller@f1010000 {
-                       compatible = "arm,gic-400";
-                       #interrupt-cells = <3>;
-                       #address-cells = <0>;
-                       interrupt-controller;
-                       reg = <0x0 0xf1010000 0 0x1000>,
-                             <0x0 0xf1020000 0 0x20000>,
-                             <0x0 0xf1040000 0 0x20000>,
-                             <0x0 0xf1060000 0 0x20000>;
-                       interrupts = <GIC_PPI 9
-                                       (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>;
-                       clocks = <&cpg CPG_MOD 408>;
-                       clock-names = "clk";
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 408>;
-               };
-
                wdt0: watchdog@e6020000 {
                        compatible = "renesas,r8a7795-wdt", "renesas,rcar-gen3-wdt";
                        reg = <0 0xe6020000 0 0x0c>;
@@ -437,6 +420,11 @@ gpio7: gpio@e6055800 {
                        resets = <&cpg 905>;
                };
 
+               pfc: pin-controller@e6060000 {
+                       compatible = "renesas,pfc-r8a7795";
+                       reg = <0 0xe6060000 0 0x50c>;
+               };
+
                cpg: clock-controller@e6150000 {
                        compatible = "renesas,r8a7795-cpg-mssr";
                        reg = <0 0xe6150000 0 0x1000>;
@@ -452,20 +440,25 @@ rst: reset-controller@e6160000 {
                        reg = <0 0xe6160000 0 0x0200>;
                };
 
-               prr: chipid@fff00044 {
-                       compatible = "renesas,prr";
-                       reg = <0 0xfff00044 0 4>;
-               };
-
                sysc: system-controller@e6180000 {
                        compatible = "renesas,r8a7795-sysc";
                        reg = <0 0xe6180000 0 0x0400>;
                        #power-domain-cells = <1>;
                };
 
-               pfc: pin-controller@e6060000 {
-                       compatible = "renesas,pfc-r8a7795";
-                       reg = <0 0xe6060000 0 0x50c>;
+               tsc: thermal@e6198000 {
+                       compatible = "renesas,r8a7795-thermal";
+                       reg = <0 0xe6198000 0 0x100>,
+                             <0 0xe61a0000 0 0x100>,
+                             <0 0xe61a8000 0 0x100>;
+                       interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 522>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 522>;
+                       #thermal-sensor-cells = <1>;
+                       status = "okay";
                };
 
                intc_ex: interrupt-controller@e61c0000 {
@@ -484,153 +477,326 @@ GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH
                        resets = <&cpg 407>;
                };
 
-               ipmmu_vi0: mmu@febd0000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfebd0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 14>;
+               i2c0: i2c@e6500000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a7795",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6500000 0 0x40>;
+                       interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 931>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-               };
-
-               ipmmu_vi1: mmu@febe0000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfebe0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 15>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 931>;
+                       dmas = <&dmac1 0x91>, <&dmac1 0x90>,
+                              <&dmac2 0x91>, <&dmac2 0x90>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <110>;
                        status = "disabled";
                };
 
-               ipmmu_vp0: mmu@fe990000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfe990000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 16>;
-                       power-domains = <&sysc R8A7795_PD_A3VP>;
-                       #iommu-cells = <1>;
+               i2c1: i2c@e6508000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a7795",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6508000 0 0x40>;
+                       interrupts = <GIC_SPI 288 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 930>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 930>;
+                       dmas = <&dmac1 0x93>, <&dmac1 0x92>,
+                              <&dmac2 0x93>, <&dmac2 0x92>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
                        status = "disabled";
                };
 
-               ipmmu_vp1: mmu@fe980000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfe980000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 17>;
-                       power-domains = <&sysc R8A7795_PD_A3VP>;
-                       #iommu-cells = <1>;
+               i2c2: i2c@e6510000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a7795",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6510000 0 0x40>;
+                       interrupts = <GIC_SPI 286 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 929>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 929>;
+                       dmas = <&dmac1 0x95>, <&dmac1 0x94>,
+                              <&dmac2 0x95>, <&dmac2 0x94>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
+                       status = "disabled";
                };
 
-               ipmmu_vc0: mmu@fe6b0000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfe6b0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 12>;
-                       power-domains = <&sysc R8A7795_PD_A3VC>;
-                       #iommu-cells = <1>;
+               i2c3: i2c@e66d0000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a7795",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe66d0000 0 0x40>;
+                       interrupts = <GIC_SPI 290 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 928>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 928>;
+                       dmas = <&dmac0 0x97>, <&dmac0 0x96>;
+                       dma-names = "tx", "rx";
+                       i2c-scl-internal-delay-ns = <110>;
                        status = "disabled";
                };
 
-               ipmmu_vc1: mmu@fe6f0000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfe6f0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 13>;
-                       power-domains = <&sysc R8A7795_PD_A3VC>;
-                       #iommu-cells = <1>;
+               i2c4: i2c@e66d8000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a7795",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe66d8000 0 0x40>;
+                       interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 927>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 927>;
+                       dmas = <&dmac0 0x99>, <&dmac0 0x98>;
+                       dma-names = "tx", "rx";
+                       i2c-scl-internal-delay-ns = <110>;
                        status = "disabled";
                };
 
-               ipmmu_pv0: mmu@fd800000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfd800000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 6>;
+               i2c5: i2c@e66e0000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a7795",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe66e0000 0 0x40>;
+                       interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 919>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 919>;
+                       dmas = <&dmac0 0x9b>, <&dmac0 0x9a>;
+                       dma-names = "tx", "rx";
+                       i2c-scl-internal-delay-ns = <110>;
                        status = "disabled";
                };
 
-               ipmmu_pv1: mmu@fd950000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfd950000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 7>;
+               i2c6: i2c@e66e8000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a7795",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe66e8000 0 0x40>;
+                       interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 918>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 918>;
+                       dmas = <&dmac0 0x9d>, <&dmac0 0x9c>;
+                       dma-names = "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
                        status = "disabled";
                };
 
-               ipmmu_pv2: mmu@fd960000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfd960000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 8>;
+               i2c_dvfs: i2c@e60b0000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,iic-r8a7795",
+                                    "renesas,rcar-gen3-iic",
+                                    "renesas,rmobile-iic";
+                       reg = <0 0xe60b0000 0 0x425>;
+                       interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 926>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 926>;
+                       dmas = <&dmac0 0x11>, <&dmac0 0x10>;
+                       dma-names = "tx", "rx";
                        status = "disabled";
                };
 
-               ipmmu_pv3: mmu@fd970000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xfd970000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 9>;
+               hscif0: serial@e6540000 {
+                       compatible = "renesas,hscif-r8a7795",
+                                    "renesas,rcar-gen3-hscif",
+                                    "renesas,hscif";
+                       reg = <0 0xe6540000 0 96>;
+                       interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 520>,
+                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac1 0x31>, <&dmac1 0x30>,
+                              <&dmac2 0x31>, <&dmac2 0x30>;
+                       dma-names = "tx", "rx", "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 520>;
                        status = "disabled";
                };
 
-               ipmmu_ir: mmu@ff8b0000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xff8b0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 3>;
-                       power-domains = <&sysc R8A7795_PD_A3IR>;
-                       #iommu-cells = <1>;
+               hscif1: serial@e6550000 {
+                       compatible = "renesas,hscif-r8a7795",
+                                    "renesas,rcar-gen3-hscif",
+                                    "renesas,hscif";
+                       reg = <0 0xe6550000 0 96>;
+                       interrupts = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 519>,
+                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac1 0x33>, <&dmac1 0x32>,
+                              <&dmac2 0x33>, <&dmac2 0x32>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 519>;
                        status = "disabled";
                };
 
-               ipmmu_hc: mmu@e6570000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xe6570000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 2>;
+               hscif2: serial@e6560000 {
+                       compatible = "renesas,hscif-r8a7795",
+                                    "renesas,rcar-gen3-hscif",
+                                    "renesas,hscif";
+                       reg = <0 0xe6560000 0 96>;
+                       interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 518>,
+                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac1 0x35>, <&dmac1 0x34>,
+                              <&dmac2 0x35>, <&dmac2 0x34>;
+                       dma-names = "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 518>;
                        status = "disabled";
                };
 
-               ipmmu_rt: mmu@ffc80000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xffc80000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 10>;
+               hscif3: serial@e66a0000 {
+                       compatible = "renesas,hscif-r8a7795",
+                                    "renesas,rcar-gen3-hscif",
+                                    "renesas,hscif";
+                       reg = <0 0xe66a0000 0 96>;
+                       interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 517>,
+                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0x37>, <&dmac0 0x36>;
+                       dma-names = "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 517>;
                        status = "disabled";
                };
 
-               ipmmu_mp0: mmu@ec670000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xec670000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 4>;
+               hscif4: serial@e66b0000 {
+                       compatible = "renesas,hscif-r8a7795",
+                                    "renesas,rcar-gen3-hscif",
+                                    "renesas,hscif";
+                       reg = <0 0xe66b0000 0 96>;
+                       interrupts = <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 516>,
+                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0x39>, <&dmac0 0x38>;
+                       dma-names = "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 516>;
                        status = "disabled";
                };
 
-               ipmmu_ds0: mmu@e6740000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xe6740000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 0>;
+               hsusb: usb@e6590000 {
+                       compatible = "renesas,usbhs-r8a7795",
+                                    "renesas,rcar-gen3-usbhs";
+                       reg = <0 0xe6590000 0 0x100>;
+                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 704>;
+                       dmas = <&usb_dmac0 0>, <&usb_dmac0 1>,
+                              <&usb_dmac1 0>, <&usb_dmac1 1>;
+                       dma-names = "ch0", "ch1", "ch2", "ch3";
+                       renesas,buswait = <11>;
+                       phys = <&usb2_phy0>;
+                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 704>;
+                       status = "disabled";
                };
 
-               ipmmu_ds1: mmu@e7740000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xe7740000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 1>;
+               hsusb3: usb@e659c000 {
+                       compatible = "renesas,usbhs-r8a7795",
+                                    "renesas,rcar-gen3-usbhs";
+                       reg = <0 0xe659c000 0 0x100>;
+                       interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 705>;
+                       dmas = <&usb_dmac2 0>, <&usb_dmac2 1>,
+                              <&usb_dmac3 0>, <&usb_dmac3 1>;
+                       dma-names = "ch0", "ch1", "ch2", "ch3";
+                       renesas,buswait = <11>;
+                       phys = <&usb2_phy3>;
+                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 705>;
+                       status = "disabled";
                };
 
-               ipmmu_mm: mmu@e67b0000 {
-                       compatible = "renesas,ipmmu-r8a7795";
-                       reg = <0 0xe67b0000 0 0x1000>;
-                       interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
+               usb_dmac0: dma-controller@e65a0000 {
+                       compatible = "renesas,r8a7795-usb-dmac",
+                                    "renesas,usb-dmac";
+                       reg = <0 0xe65a0000 0 0x100>;
+                       interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1";
+                       clocks = <&cpg CPG_MOD 330>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 330>;
+                       #dma-cells = <1>;
+                       dma-channels = <2>;
+               };
+
+               usb_dmac1: dma-controller@e65b0000 {
+                       compatible = "renesas,r8a7795-usb-dmac",
+                                    "renesas,usb-dmac";
+                       reg = <0 0xe65b0000 0 0x100>;
+                       interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1";
+                       clocks = <&cpg CPG_MOD 331>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 331>;
+                       #dma-cells = <1>;
+                       dma-channels = <2>;
+               };
+
+               usb_dmac2: dma-controller@e6460000 {
+                       compatible = "renesas,r8a7795-usb-dmac",
+                                    "renesas,usb-dmac";
+                       reg = <0 0xe6460000 0 0x100>;
+                       interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1";
+                       clocks = <&cpg CPG_MOD 326>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 326>;
+                       #dma-cells = <1>;
+                       dma-channels = <2>;
+               };
+
+               usb_dmac3: dma-controller@e6470000 {
+                       compatible = "renesas,r8a7795-usb-dmac",
+                                    "renesas,usb-dmac";
+                       reg = <0 0xe6470000 0 0x100>;
+                       interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1";
+                       clocks = <&cpg CPG_MOD 329>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 329>;
+                       #dma-cells = <1>;
+                       dma-channels = <2>;
+               };
+
+               usb3_phy0: usb-phy@e65ee000 {
+                       compatible = "renesas,r8a7795-usb3-phy",
+                                    "renesas,rcar-gen3-usb3-phy";
+                       reg = <0 0xe65ee000 0 0x90>;
+                       clocks = <&cpg CPG_MOD 328>, <&usb3s0_clk>,
+                                <&usb_extal_clk>;
+                       clock-names = "usb3-if", "usb3s_clk", "usb_extal";
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 328>;
+                       #phy-cells = <0>;
+                       status = "disabled";
                };
 
                dmac0: dma-controller@e6700000 {
@@ -759,155 +925,208 @@ GIC_SPI 431 IRQ_TYPE_LEVEL_HIGH
                               <&ipmmu_ds1 30>, <&ipmmu_ds1 31>;
                };
 
-               audma0: dma-controller@ec700000 {
-                       compatible = "renesas,dmac-r8a7795",
-                                    "renesas,rcar-dmac";
-                       reg = <0 0xec700000 0 0x10000>;
-                       interrupts = <GIC_SPI 350 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 320 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 321 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 322 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 323 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 324 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 325 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 326 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 327 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 328 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 329 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 330 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 331 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 332 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 333 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 334 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 335 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "error",
-                                       "ch0", "ch1", "ch2", "ch3",
-                                       "ch4", "ch5", "ch6", "ch7",
-                                       "ch8", "ch9", "ch10", "ch11",
-                                       "ch12", "ch13", "ch14", "ch15";
-                       clocks = <&cpg CPG_MOD 502>;
-                       clock-names = "fck";
+               ipmmu_ds0: mmu@e6740000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xe6740000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 0>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 502>;
-                       #dma-cells = <1>;
-                       dma-channels = <16>;
-                       iommus = <&ipmmu_mp0 0>, <&ipmmu_mp0 1>,
-                              <&ipmmu_mp0 2>, <&ipmmu_mp0 3>,
-                              <&ipmmu_mp0 4>, <&ipmmu_mp0 5>,
-                              <&ipmmu_mp0 6>, <&ipmmu_mp0 7>,
-                              <&ipmmu_mp0 8>, <&ipmmu_mp0 9>,
-                              <&ipmmu_mp0 10>, <&ipmmu_mp0 11>,
-                              <&ipmmu_mp0 12>, <&ipmmu_mp0 13>,
-                              <&ipmmu_mp0 14>, <&ipmmu_mp0 15>;
+                       #iommu-cells = <1>;
                };
 
-               audma1: dma-controller@ec720000 {
-                       compatible = "renesas,dmac-r8a7795",
-                                    "renesas,rcar-dmac";
-                       reg = <0 0xec720000 0 0x10000>;
-                       interrupts = <GIC_SPI 351 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 336 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 337 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 338 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 339 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 340 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 341 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 342 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 343 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 344 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 345 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 346 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 347 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 348 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 349 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 382 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 383 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "error",
-                                       "ch0", "ch1", "ch2", "ch3",
-                                       "ch4", "ch5", "ch6", "ch7",
-                                       "ch8", "ch9", "ch10", "ch11",
-                                       "ch12", "ch13", "ch14", "ch15";
-                       clocks = <&cpg CPG_MOD 501>;
-                       clock-names = "fck";
+               ipmmu_ds1: mmu@e7740000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xe7740000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 1>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 501>;
-                       #dma-cells = <1>;
-                       dma-channels = <16>;
-                       iommus = <&ipmmu_mp0 16>, <&ipmmu_mp0 17>,
-                              <&ipmmu_mp0 18>, <&ipmmu_mp0 19>,
-                              <&ipmmu_mp0 20>, <&ipmmu_mp0 21>,
-                              <&ipmmu_mp0 22>, <&ipmmu_mp0 23>,
-                              <&ipmmu_mp0 24>, <&ipmmu_mp0 25>,
-                              <&ipmmu_mp0 26>, <&ipmmu_mp0 27>,
-                              <&ipmmu_mp0 28>, <&ipmmu_mp0 29>,
-                              <&ipmmu_mp0 30>, <&ipmmu_mp0 31>;
+                       #iommu-cells = <1>;
                };
 
-               avb: ethernet@e6800000 {
-                       compatible = "renesas,etheravb-r8a7795",
-                                    "renesas,etheravb-rcar-gen3";
-                       reg = <0 0xe6800000 0 0x800>, <0 0xe6a00000 0 0x10000>;
-                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1", "ch2", "ch3",
-                                         "ch4", "ch5", "ch6", "ch7",
-                                         "ch8", "ch9", "ch10", "ch11",
-                                         "ch12", "ch13", "ch14", "ch15",
-                                         "ch16", "ch17", "ch18", "ch19",
-                                         "ch20", "ch21", "ch22", "ch23",
-                                         "ch24";
-                       clocks = <&cpg CPG_MOD 812>;
+               ipmmu_hc: mmu@e6570000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xe6570000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 2>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 812>;
-                       phy-mode = "rgmii";
-                       iommus = <&ipmmu_ds0 16>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       status = "disabled";
+                       #iommu-cells = <1>;
                };
 
-               can0: can@e6c30000 {
-                       compatible = "renesas,can-r8a7795",
-                                    "renesas,rcar-gen3-can";
-                       reg = <0 0xe6c30000 0 0x1000>;
-                       interrupts = <GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 916>,
-                              <&cpg CPG_CORE R8A7795_CLK_CANFD>,
-                              <&can_clk>;
-                       clock-names = "clkp1", "clkp2", "can_clk";
-                       assigned-clocks = <&cpg CPG_CORE R8A7795_CLK_CANFD>;
-                       assigned-clock-rates = <40000000>;
+               ipmmu_ir: mmu@ff8b0000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xff8b0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 3>;
+                       power-domains = <&sysc R8A7795_PD_A3IR>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_mm: mmu@e67b0000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xe67b0000 0 0x1000>;
+                       interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 916>;
-                       status = "disabled";
+                       #iommu-cells = <1>;
                };
 
-               can1: can@e6c38000 {
-                       compatible = "renesas,can-r8a7795",
-                                    "renesas,rcar-gen3-can";
+               ipmmu_mp0: mmu@ec670000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xec670000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 4>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_pv0: mmu@fd800000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfd800000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 6>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_pv1: mmu@fd950000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfd950000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 7>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_pv2: mmu@fd960000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfd960000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 8>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_pv3: mmu@fd970000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfd970000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 9>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_rt: mmu@ffc80000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xffc80000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 10>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vc0: mmu@fe6b0000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfe6b0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 12>;
+                       power-domains = <&sysc R8A7795_PD_A3VC>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vc1: mmu@fe6f0000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfe6f0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 13>;
+                       power-domains = <&sysc R8A7795_PD_A3VC>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vi0: mmu@febd0000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfebd0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 14>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vi1: mmu@febe0000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfebe0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 15>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vp0: mmu@fe990000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfe990000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 16>;
+                       power-domains = <&sysc R8A7795_PD_A3VP>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vp1: mmu@fe980000 {
+                       compatible = "renesas,ipmmu-r8a7795";
+                       reg = <0 0xfe980000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 17>;
+                       power-domains = <&sysc R8A7795_PD_A3VP>;
+                       #iommu-cells = <1>;
+               };
+
+               avb: ethernet@e6800000 {
+                       compatible = "renesas,etheravb-r8a7795",
+                                    "renesas,etheravb-rcar-gen3";
+                       reg = <0 0xe6800000 0 0x800>, <0 0xe6a00000 0 0x10000>;
+                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1", "ch2", "ch3",
+                                         "ch4", "ch5", "ch6", "ch7",
+                                         "ch8", "ch9", "ch10", "ch11",
+                                         "ch12", "ch13", "ch14", "ch15",
+                                         "ch16", "ch17", "ch18", "ch19",
+                                         "ch20", "ch21", "ch22", "ch23",
+                                         "ch24";
+                       clocks = <&cpg CPG_MOD 812>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 812>;
+                       phy-mode = "rgmii";
+                       iommus = <&ipmmu_ds0 16>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               can0: can@e6c30000 {
+                       compatible = "renesas,can-r8a7795",
+                                    "renesas,rcar-gen3-can";
+                       reg = <0 0xe6c30000 0 0x1000>;
+                       interrupts = <GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 916>,
+                              <&cpg CPG_CORE R8A7795_CLK_CANFD>,
+                              <&can_clk>;
+                       clock-names = "clkp1", "clkp2", "can_clk";
+                       assigned-clocks = <&cpg CPG_CORE R8A7795_CLK_CANFD>;
+                       assigned-clock-rates = <40000000>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 916>;
+                       status = "disabled";
+               };
+
+               can1: can@e6c38000 {
+                       compatible = "renesas,can-r8a7795",
+                                    "renesas,rcar-gen3-can";
                        reg = <0 0xe6c38000 0 0x1000>;
                        interrupts = <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 915>,
@@ -946,211 +1165,173 @@ channel1 {
                        };
                };
 
-               drif00: rif@e6f40000 {
-                       compatible = "renesas,r8a7795-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f40000 0 0x64>;
-                       interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 515>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x20>, <&dmac2 0x20>;
-                       dma-names = "rx", "rx";
+               pwm0: pwm@e6e30000 {
+                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
+                       reg = <0 0xe6e30000 0 0x8>;
+                       clocks = <&cpg CPG_MOD 523>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 515>;
-                       renesas,bonding = <&drif01>;
+                       resets = <&cpg 523>;
+                       #pwm-cells = <2>;
                        status = "disabled";
                };
 
-               drif01: rif@e6f50000 {
-                       compatible = "renesas,r8a7795-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f50000 0 0x64>;
-                       interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 514>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x22>, <&dmac2 0x22>;
-                       dma-names = "rx", "rx";
+               pwm1: pwm@e6e31000 {
+                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
+                       reg = <0 0xe6e31000 0 0x8>;
+                       clocks = <&cpg CPG_MOD 523>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 514>;
-                       renesas,bonding = <&drif00>;
+                       resets = <&cpg 523>;
+                       #pwm-cells = <2>;
                        status = "disabled";
                };
 
-               drif10: rif@e6f60000 {
-                       compatible = "renesas,r8a7795-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f60000 0 0x64>;
-                       interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 513>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x24>, <&dmac2 0x24>;
-                       dma-names = "rx", "rx";
+               pwm2: pwm@e6e32000 {
+                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
+                       reg = <0 0xe6e32000 0 0x8>;
+                       clocks = <&cpg CPG_MOD 523>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 513>;
-                       renesas,bonding = <&drif11>;
+                       resets = <&cpg 523>;
+                       #pwm-cells = <2>;
                        status = "disabled";
                };
 
-               drif11: rif@e6f70000 {
-                       compatible = "renesas,r8a7795-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f70000 0 0x64>;
-                       interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 512>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x26>, <&dmac2 0x26>;
-                       dma-names = "rx", "rx";
+               pwm3: pwm@e6e33000 {
+                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
+                       reg = <0 0xe6e33000 0 0x8>;
+                       clocks = <&cpg CPG_MOD 523>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 512>;
-                       renesas,bonding = <&drif10>;
+                       resets = <&cpg 523>;
+                       #pwm-cells = <2>;
                        status = "disabled";
                };
 
-               drif20: rif@e6f80000 {
-                       compatible = "renesas,r8a7795-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f80000 0 0x64>;
-                       interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 511>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x28>, <&dmac2 0x28>;
-                       dma-names = "rx", "rx";
+               pwm4: pwm@e6e34000 {
+                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
+                       reg = <0 0xe6e34000 0 0x8>;
+                       clocks = <&cpg CPG_MOD 523>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 511>;
-                       renesas,bonding = <&drif21>;
+                       resets = <&cpg 523>;
+                       #pwm-cells = <2>;
                        status = "disabled";
                };
 
-               drif21: rif@e6f90000 {
-                       compatible = "renesas,r8a7795-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f90000 0 0x64>;
-                       interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 510>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x2a>, <&dmac2 0x2a>;
-                       dma-names = "rx", "rx";
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 510>;
-                       renesas,bonding = <&drif20>;
+               pwm5: pwm@e6e35000 {
+                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
+                       reg = <0 0xe6e35000 0 0x8>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 523>;
+                       #pwm-cells = <2>;
                        status = "disabled";
                };
 
-               drif30: rif@e6fa0000 {
-                       compatible = "renesas,r8a7795-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6fa0000 0 0x64>;
-                       interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 509>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x2c>, <&dmac2 0x2c>;
-                       dma-names = "rx", "rx";
+               pwm6: pwm@e6e36000 {
+                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
+                       reg = <0 0xe6e36000 0 0x8>;
+                       clocks = <&cpg CPG_MOD 523>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 509>;
-                       renesas,bonding = <&drif31>;
+                       resets = <&cpg 523>;
+                       #pwm-cells = <2>;
                        status = "disabled";
                };
 
-               drif31: rif@e6fb0000 {
-                       compatible = "renesas,r8a7795-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6fb0000 0 0x64>;
-                       interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 508>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x2e>, <&dmac2 0x2e>;
-                       dma-names = "rx", "rx";
+               scif0: serial@e6e60000 {
+                       compatible = "renesas,scif-r8a7795",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6e60000 0 64>;
+                       interrupts = <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 207>,
+                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac1 0x51>, <&dmac1 0x50>,
+                              <&dmac2 0x51>, <&dmac2 0x50>;
+                       dma-names = "tx", "rx", "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 508>;
-                       renesas,bonding = <&drif30>;
+                       resets = <&cpg 207>;
                        status = "disabled";
                };
 
-               hscif0: serial@e6540000 {
-                       compatible = "renesas,hscif-r8a7795",
-                                    "renesas,rcar-gen3-hscif",
-                                    "renesas,hscif";
-                       reg = <0 0xe6540000 0 96>;
-                       interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 520>,
+               scif1: serial@e6e68000 {
+                       compatible = "renesas,scif-r8a7795",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6e68000 0 64>;
+                       interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 206>,
                                 <&cpg CPG_CORE R8A7795_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x31>, <&dmac1 0x30>,
-                              <&dmac2 0x31>, <&dmac2 0x30>;
+                       dmas = <&dmac1 0x53>, <&dmac1 0x52>,
+                              <&dmac2 0x53>, <&dmac2 0x52>;
                        dma-names = "tx", "rx", "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 520>;
+                       resets = <&cpg 206>;
                        status = "disabled";
                };
 
-               hscif1: serial@e6550000 {
-                       compatible = "renesas,hscif-r8a7795",
-                                    "renesas,rcar-gen3-hscif",
-                                    "renesas,hscif";
-                       reg = <0 0xe6550000 0 96>;
-                       interrupts = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 519>,
+               scif2: serial@e6e88000 {
+                       compatible = "renesas,scif-r8a7795",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6e88000 0 64>;
+                       interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 310>,
                                 <&cpg CPG_CORE R8A7795_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x33>, <&dmac1 0x32>,
-                              <&dmac2 0x33>, <&dmac2 0x32>;
+                       dmas = <&dmac1 0x13>, <&dmac1 0x12>,
+                              <&dmac2 0x13>, <&dmac2 0x12>;
                        dma-names = "tx", "rx", "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 519>;
+                       resets = <&cpg 310>;
                        status = "disabled";
                };
 
-               hscif2: serial@e6560000 {
-                       compatible = "renesas,hscif-r8a7795",
-                                    "renesas,rcar-gen3-hscif",
-                                    "renesas,hscif";
-                       reg = <0 0xe6560000 0 96>;
-                       interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 518>,
+               scif3: serial@e6c50000 {
+                       compatible = "renesas,scif-r8a7795",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6c50000 0 64>;
+                       interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 204>,
                                 <&cpg CPG_CORE R8A7795_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x35>, <&dmac1 0x34>,
-                              <&dmac2 0x35>, <&dmac2 0x34>;
-                       dma-names = "tx", "rx", "tx", "rx";
+                       dmas = <&dmac0 0x57>, <&dmac0 0x56>;
+                       dma-names = "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 518>;
+                       resets = <&cpg 204>;
                        status = "disabled";
                };
 
-               hscif3: serial@e66a0000 {
-                       compatible = "renesas,hscif-r8a7795",
-                                    "renesas,rcar-gen3-hscif",
-                                    "renesas,hscif";
-                       reg = <0 0xe66a0000 0 96>;
-                       interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 517>,
+               scif4: serial@e6c40000 {
+                       compatible = "renesas,scif-r8a7795",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6c40000 0 64>;
+                       interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 203>,
                                 <&cpg CPG_CORE R8A7795_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac0 0x37>, <&dmac0 0x36>;
+                       dmas = <&dmac0 0x59>, <&dmac0 0x58>;
                        dma-names = "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 517>;
+                       resets = <&cpg 203>;
                        status = "disabled";
                };
 
-               hscif4: serial@e66b0000 {
-                       compatible = "renesas,hscif-r8a7795",
-                                    "renesas,rcar-gen3-hscif",
-                                    "renesas,hscif";
-                       reg = <0 0xe66b0000 0 96>;
-                       interrupts = <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 516>,
+               scif5: serial@e6f30000 {
+                       compatible = "renesas,scif-r8a7795",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6f30000 0 64>;
+                       interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 202>,
                                 <&cpg CPG_CORE R8A7795_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac0 0x39>, <&dmac0 0x38>;
-                       dma-names = "tx", "rx";
+                       dmas = <&dmac1 0x5b>, <&dmac1 0x5a>,
+                              <&dmac2 0x5b>, <&dmac2 0x5a>;
+                       dma-names = "tx", "rx", "tx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 516>;
+                       resets = <&cpg 202>;
                        status = "disabled";
                };
 
@@ -1216,304 +1397,379 @@ msiof3: spi@e6c10000 {
                        status = "disabled";
                };
 
-               scif0: serial@e6e60000 {
-                       compatible = "renesas,scif-r8a7795",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6e60000 0 64>;
-                       interrupts = <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 207>,
-                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x51>, <&dmac1 0x50>,
-                              <&dmac2 0x51>, <&dmac2 0x50>;
-                       dma-names = "tx", "rx", "tx", "rx";
+               vin0: video@e6ef0000 {
+                       compatible = "renesas,vin-r8a7795";
+                       reg = <0 0xe6ef0000 0 0x1000>;
+                       interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 811>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 207>;
+                       resets = <&cpg 811>;
+                       renesas,id = <0>;
                        status = "disabled";
-               };
 
-               scif1: serial@e6e68000 {
-                       compatible = "renesas,scif-r8a7795",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6e68000 0 64>;
-                       interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 206>,
-                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x53>, <&dmac1 0x52>,
-                              <&dmac2 0x53>, <&dmac2 0x52>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 206>;
-                       status = "disabled";
-               };
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
 
-               scif2: serial@e6e88000 {
-                       compatible = "renesas,scif-r8a7795",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6e88000 0 64>;
-                       interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 310>,
-                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x13>, <&dmac1 0x12>,
-                              <&dmac2 0x13>, <&dmac2 0x12>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 310>;
-                       status = "disabled";
-               };
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
 
-               scif3: serial@e6c50000 {
-                       compatible = "renesas,scif-r8a7795",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6c50000 0 64>;
-                       interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 204>,
-                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac0 0x57>, <&dmac0 0x56>;
-                       dma-names = "tx", "rx";
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 204>;
-                       status = "disabled";
-               };
+                                       reg = <1>;
 
-               scif4: serial@e6c40000 {
-                       compatible = "renesas,scif-r8a7795",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6c40000 0 64>;
-                       interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 203>,
-                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac0 0x59>, <&dmac0 0x58>;
-                       dma-names = "tx", "rx";
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 203>;
-                       status = "disabled";
+                                       vin0csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin0>;
+                                       };
+                                       vin0csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin0>;
+                                       };
+                               };
+                       };
                };
 
-               scif5: serial@e6f30000 {
-                       compatible = "renesas,scif-r8a7795",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6f30000 0 64>;
-                       interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 202>,
-                                <&cpg CPG_CORE R8A7795_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x5b>, <&dmac1 0x5a>,
-                              <&dmac2 0x5b>, <&dmac2 0x5a>;
-                       dma-names = "tx", "rx", "tx", "rx";
+               vin1: video@e6ef1000 {
+                       compatible = "renesas,vin-r8a7795";
+                       reg = <0 0xe6ef1000 0 0x1000>;
+                       interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 810>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 202>;
+                       resets = <&cpg 810>;
+                       renesas,id = <1>;
                        status = "disabled";
-               };
 
-               i2c_dvfs: i2c@e60b0000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,iic-r8a7795",
-                                    "renesas,rcar-gen3-iic",
-                                    "renesas,rmobile-iic";
-                       reg = <0 0xe60b0000 0 0x425>;
-                       interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 926>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 926>;
-                       dmas = <&dmac0 0x11>, <&dmac0 0x10>;
-                       dma-names = "tx", "rx";
-                       status = "disabled";
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin1csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin1>;
+                                       };
+                                       vin1csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin1>;
+                                       };
+                               };
+                       };
                };
 
-               i2c0: i2c@e6500000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a7795",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe6500000 0 0x40>;
-                       interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 931>;
+               vin2: video@e6ef2000 {
+                       compatible = "renesas,vin-r8a7795";
+                       reg = <0 0xe6ef2000 0 0x1000>;
+                       interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 809>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 931>;
-                       dmas = <&dmac1 0x91>, <&dmac1 0x90>,
-                              <&dmac2 0x91>, <&dmac2 0x90>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       i2c-scl-internal-delay-ns = <110>;
+                       resets = <&cpg 809>;
+                       renesas,id = <2>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin2csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin2>;
+                                       };
+                                       vin2csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin2>;
+                                       };
+                               };
+                       };
                };
 
-               i2c1: i2c@e6508000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a7795",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe6508000 0 0x40>;
-                       interrupts = <GIC_SPI 288 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 930>;
+               vin3: video@e6ef3000 {
+                       compatible = "renesas,vin-r8a7795";
+                       reg = <0 0xe6ef3000 0 0x1000>;
+                       interrupts = <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 808>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 930>;
-                       dmas = <&dmac1 0x93>, <&dmac1 0x92>,
-                              <&dmac2 0x93>, <&dmac2 0x92>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       i2c-scl-internal-delay-ns = <6>;
+                       resets = <&cpg 808>;
+                       renesas,id = <3>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin3csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin3>;
+                                       };
+                                       vin3csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin3>;
+                                       };
+                               };
+                       };
                };
 
-               i2c2: i2c@e6510000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a7795",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe6510000 0 0x40>;
-                       interrupts = <GIC_SPI 286 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 929>;
+               vin4: video@e6ef4000 {
+                       compatible = "renesas,vin-r8a7795";
+                       reg = <0 0xe6ef4000 0 0x1000>;
+                       interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 807>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 929>;
-                       dmas = <&dmac1 0x95>, <&dmac1 0x94>,
-                              <&dmac2 0x95>, <&dmac2 0x94>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       i2c-scl-internal-delay-ns = <6>;
+                       resets = <&cpg 807>;
+                       renesas,id = <4>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin4csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin4>;
+                                       };
+                                       vin4csi41: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint= <&csi41vin4>;
+                                       };
+                               };
+                       };
                };
 
-               i2c3: i2c@e66d0000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a7795",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe66d0000 0 0x40>;
-                       interrupts = <GIC_SPI 290 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 928>;
+               vin5: video@e6ef5000 {
+                       compatible = "renesas,vin-r8a7795";
+                       reg = <0 0xe6ef5000 0 0x1000>;
+                       interrupts = <GIC_SPI 175 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 806>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 928>;
-                       dmas = <&dmac0 0x97>, <&dmac0 0x96>;
-                       dma-names = "tx", "rx";
-                       i2c-scl-internal-delay-ns = <110>;
+                       resets = <&cpg 806>;
+                       renesas,id = <5>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin5csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin5>;
+                                       };
+                                       vin5csi41: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint= <&csi41vin5>;
+                                       };
+                               };
+                       };
                };
 
-               i2c4: i2c@e66d8000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a7795",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe66d8000 0 0x40>;
-                       interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 927>;
+               vin6: video@e6ef6000 {
+                       compatible = "renesas,vin-r8a7795";
+                       reg = <0 0xe6ef6000 0 0x1000>;
+                       interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 805>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 927>;
-                       dmas = <&dmac0 0x99>, <&dmac0 0x98>;
-                       dma-names = "tx", "rx";
-                       i2c-scl-internal-delay-ns = <110>;
+                       resets = <&cpg 805>;
+                       renesas,id = <6>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin6csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin6>;
+                                       };
+                                       vin6csi41: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint= <&csi41vin6>;
+                                       };
+                               };
+                       };
                };
 
-               i2c5: i2c@e66e0000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a7795",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe66e0000 0 0x40>;
-                       interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 919>;
+               vin7: video@e6ef7000 {
+                       compatible = "renesas,vin-r8a7795";
+                       reg = <0 0xe6ef7000 0 0x1000>;
+                       interrupts = <GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 804>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 919>;
-                       dmas = <&dmac0 0x9b>, <&dmac0 0x9a>;
-                       dma-names = "tx", "rx";
-                       i2c-scl-internal-delay-ns = <110>;
+                       resets = <&cpg 804>;
+                       renesas,id = <7>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin7csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin7>;
+                                       };
+                                       vin7csi41: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint= <&csi41vin7>;
+                                       };
+                               };
+                       };
                };
 
-               i2c6: i2c@e66e8000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a7795",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe66e8000 0 0x40>;
-                       interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 918>;
+               drif00: rif@e6f40000 {
+                       compatible = "renesas,r8a7795-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f40000 0 0x64>;
+                       interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 515>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x20>, <&dmac2 0x20>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 918>;
-                       dmas = <&dmac0 0x9d>, <&dmac0 0x9c>;
-                       dma-names = "tx", "rx";
-                       i2c-scl-internal-delay-ns = <6>;
+                       resets = <&cpg 515>;
+                       renesas,bonding = <&drif01>;
                        status = "disabled";
                };
 
-               pwm0: pwm@e6e30000 {
-                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
-                       reg = <0 0xe6e30000 0 0x8>;
-                       clocks = <&cpg CPG_MOD 523>;
+               drif01: rif@e6f50000 {
+                       compatible = "renesas,r8a7795-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f50000 0 0x64>;
+                       interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 514>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x22>, <&dmac2 0x22>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 523>;
-                       #pwm-cells = <2>;
+                       resets = <&cpg 514>;
+                       renesas,bonding = <&drif00>;
                        status = "disabled";
                };
 
-               pwm1: pwm@e6e31000 {
-                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
-                       reg = <0 0xe6e31000 0 0x8>;
-                       clocks = <&cpg CPG_MOD 523>;
+               drif10: rif@e6f60000 {
+                       compatible = "renesas,r8a7795-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f60000 0 0x64>;
+                       interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 513>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x24>, <&dmac2 0x24>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 523>;
-                       #pwm-cells = <2>;
+                       resets = <&cpg 513>;
+                       renesas,bonding = <&drif11>;
                        status = "disabled";
                };
 
-               pwm2: pwm@e6e32000 {
-                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
-                       reg = <0 0xe6e32000 0 0x8>;
-                       clocks = <&cpg CPG_MOD 523>;
+               drif11: rif@e6f70000 {
+                       compatible = "renesas,r8a7795-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f70000 0 0x64>;
+                       interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 512>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x26>, <&dmac2 0x26>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 523>;
-                       #pwm-cells = <2>;
+                       resets = <&cpg 512>;
+                       renesas,bonding = <&drif10>;
                        status = "disabled";
                };
 
-               pwm3: pwm@e6e33000 {
-                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
-                       reg = <0 0xe6e33000 0 0x8>;
-                       clocks = <&cpg CPG_MOD 523>;
+               drif20: rif@e6f80000 {
+                       compatible = "renesas,r8a7795-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f80000 0 0x64>;
+                       interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 511>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x28>, <&dmac2 0x28>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 523>;
-                       #pwm-cells = <2>;
+                       resets = <&cpg 511>;
+                       renesas,bonding = <&drif21>;
                        status = "disabled";
                };
 
-               pwm4: pwm@e6e34000 {
-                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
-                       reg = <0 0xe6e34000 0 0x8>;
-                       clocks = <&cpg CPG_MOD 523>;
+               drif21: rif@e6f90000 {
+                       compatible = "renesas,r8a7795-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f90000 0 0x64>;
+                       interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 510>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x2a>, <&dmac2 0x2a>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 523>;
-                       #pwm-cells = <2>;
+                       resets = <&cpg 510>;
+                       renesas,bonding = <&drif20>;
                        status = "disabled";
                };
 
-               pwm5: pwm@e6e35000 {
-                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
-                       reg = <0 0xe6e35000 0 0x8>;
-                       clocks = <&cpg CPG_MOD 523>;
+               drif30: rif@e6fa0000 {
+                       compatible = "renesas,r8a7795-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6fa0000 0 0x64>;
+                       interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 509>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x2c>, <&dmac2 0x2c>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 523>;
-                       #pwm-cells = <2>;
+                       resets = <&cpg 509>;
+                       renesas,bonding = <&drif31>;
                        status = "disabled";
                };
 
-               pwm6: pwm@e6e36000 {
-                       compatible = "renesas,pwm-r8a7795", "renesas,pwm-rcar";
-                       reg = <0 0xe6e36000 0 0x8>;
-                       clocks = <&cpg CPG_MOD 523>;
+               drif31: rif@e6fb0000 {
+                       compatible = "renesas,r8a7795-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6fb0000 0 0x64>;
+                       interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 508>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x2e>, <&dmac2 0x2e>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 523>;
-                       #pwm-cells = <2>;
+                       resets = <&cpg 508>;
+                       renesas,bonding = <&drif30>;
                        status = "disabled";
                };
 
@@ -1711,201 +1967,172 @@ ssi9: ssi-9 {
                                        dma-names = "rx", "tx", "rxu", "txu";
                                };
                        };
-               };
-
-               sata: sata@ee300000 {
-                       compatible = "renesas,sata-r8a7795",
-                                    "renesas,rcar-gen3-sata";
-                       reg = <0 0xee300000 0 0x200000>;
-                       interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 815>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 815>;
-                       status = "disabled";
-                       iommus = <&ipmmu_hc 2>;
-               };
-
-               usb3_phy0: usb-phy@e65ee000 {
-                       compatible = "renesas,r8a7795-usb3-phy",
-                                    "renesas,rcar-gen3-usb3-phy";
-                       reg = <0 0xe65ee000 0 0x90>;
-                       clocks = <&cpg CPG_MOD 328>, <&usb3s0_clk>,
-                                <&usb_extal_clk>;
-                       clock-names = "usb3-if", "usb3s_clk", "usb_extal";
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 328>;
-                       #phy-cells = <0>;
-                       status = "disabled";
-               };
-
-               xhci0: usb@ee000000 {
-                       compatible = "renesas,xhci-r8a7795", "renesas,rcar-gen3-xhci";
-                       reg = <0 0xee000000 0 0xc00>;
-                       interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 328>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 328>;
-                       status = "disabled";
-               };
-
-               usb3_peri0: usb@ee020000 {
-                       compatible = "renesas,r8a7795-usb3-peri",
-                                    "renesas,rcar-gen3-usb3-peri";
-                       reg = <0 0xee020000 0 0x400>;
-                       interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 328>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 328>;
-                       status = "disabled";
-               };
-
-               usb_dmac0: dma-controller@e65a0000 {
-                       compatible = "renesas,r8a7795-usb-dmac",
-                                    "renesas,usb-dmac";
-                       reg = <0 0xe65a0000 0 0x100>;
-                       interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1";
-                       clocks = <&cpg CPG_MOD 330>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 330>;
-                       #dma-cells = <1>;
-                       dma-channels = <2>;
-               };
 
-               usb_dmac1: dma-controller@e65b0000 {
-                       compatible = "renesas,r8a7795-usb-dmac",
-                                    "renesas,usb-dmac";
-                       reg = <0 0xe65b0000 0 0x100>;
-                       interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1";
-                       clocks = <&cpg CPG_MOD 331>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 331>;
-                       #dma-cells = <1>;
-                       dma-channels = <2>;
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               port@0 {
+                                       reg = <0>;
+                               };
+                               port@1 {
+                                       reg = <1>;
+                               };
+                               port@2 {
+                                       reg = <2>;
+                               };
+                       };
                };
 
-               usb_dmac2: dma-controller@e6460000 {
-                       compatible = "renesas,r8a7795-usb-dmac",
-                                    "renesas,usb-dmac";
-                       reg = <0 0xe6460000 0 0x100>;
-                       interrupts = <GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 34 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1";
-                       clocks = <&cpg CPG_MOD 326>;
+               audma0: dma-controller@ec700000 {
+                       compatible = "renesas,dmac-r8a7795",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xec700000 0 0x10000>;
+                       interrupts = <GIC_SPI 350 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 320 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 321 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 322 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 323 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 324 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 325 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 326 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 327 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 328 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 329 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 330 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 331 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 332 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 333 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 334 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 335 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                       "ch0", "ch1", "ch2", "ch3",
+                                       "ch4", "ch5", "ch6", "ch7",
+                                       "ch8", "ch9", "ch10", "ch11",
+                                       "ch12", "ch13", "ch14", "ch15";
+                       clocks = <&cpg CPG_MOD 502>;
+                       clock-names = "fck";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 326>;
+                       resets = <&cpg 502>;
                        #dma-cells = <1>;
-                       dma-channels = <2>;
+                       dma-channels = <16>;
+                       iommus = <&ipmmu_mp0 0>, <&ipmmu_mp0 1>,
+                              <&ipmmu_mp0 2>, <&ipmmu_mp0 3>,
+                              <&ipmmu_mp0 4>, <&ipmmu_mp0 5>,
+                              <&ipmmu_mp0 6>, <&ipmmu_mp0 7>,
+                              <&ipmmu_mp0 8>, <&ipmmu_mp0 9>,
+                              <&ipmmu_mp0 10>, <&ipmmu_mp0 11>,
+                              <&ipmmu_mp0 12>, <&ipmmu_mp0 13>,
+                              <&ipmmu_mp0 14>, <&ipmmu_mp0 15>;
                };
 
-               usb_dmac3: dma-controller@e6470000 {
-                       compatible = "renesas,r8a7795-usb-dmac",
-                                    "renesas,usb-dmac";
-                       reg = <0 0xe6470000 0 0x100>;
-                       interrupts = <GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 35 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1";
-                       clocks = <&cpg CPG_MOD 329>;
+               audma1: dma-controller@ec720000 {
+                       compatible = "renesas,dmac-r8a7795",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xec720000 0 0x10000>;
+                       interrupts = <GIC_SPI 351 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 336 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 337 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 338 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 339 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 340 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 341 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 342 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 343 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 344 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 345 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 346 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 347 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 348 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 349 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 382 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 383 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                       "ch0", "ch1", "ch2", "ch3",
+                                       "ch4", "ch5", "ch6", "ch7",
+                                       "ch8", "ch9", "ch10", "ch11",
+                                       "ch12", "ch13", "ch14", "ch15";
+                       clocks = <&cpg CPG_MOD 501>;
+                       clock-names = "fck";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 329>;
+                       resets = <&cpg 501>;
                        #dma-cells = <1>;
-                       dma-channels = <2>;
-               };
-
-               sdhi0: sd@ee100000 {
-                       compatible = "renesas,sdhi-r8a7795",
-                                    "renesas,rcar-gen3-sdhi";
-                       reg = <0 0xee100000 0 0x2000>;
-                       interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 314>;
-                       max-frequency = <200000000>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 314>;
-                       status = "disabled";
-               };
-
-               sdhi1: sd@ee120000 {
-                       compatible = "renesas,sdhi-r8a7795",
-                                    "renesas,rcar-gen3-sdhi";
-                       reg = <0 0xee120000 0 0x2000>;
-                       interrupts = <GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 313>;
-                       max-frequency = <200000000>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 313>;
-                       status = "disabled";
+                       dma-channels = <16>;
+                       iommus = <&ipmmu_mp0 16>, <&ipmmu_mp0 17>,
+                              <&ipmmu_mp0 18>, <&ipmmu_mp0 19>,
+                              <&ipmmu_mp0 20>, <&ipmmu_mp0 21>,
+                              <&ipmmu_mp0 22>, <&ipmmu_mp0 23>,
+                              <&ipmmu_mp0 24>, <&ipmmu_mp0 25>,
+                              <&ipmmu_mp0 26>, <&ipmmu_mp0 27>,
+                              <&ipmmu_mp0 28>, <&ipmmu_mp0 29>,
+                              <&ipmmu_mp0 30>, <&ipmmu_mp0 31>;
                };
 
-               sdhi2: sd@ee140000 {
-                       compatible = "renesas,sdhi-r8a7795",
-                                    "renesas,rcar-gen3-sdhi";
-                       reg = <0 0xee140000 0 0x2000>;
-                       interrupts = <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 312>;
-                       max-frequency = <200000000>;
+               xhci0: usb@ee000000 {
+                       compatible = "renesas,xhci-r8a7795", "renesas,rcar-gen3-xhci";
+                       reg = <0 0xee000000 0 0xc00>;
+                       interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 328>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 312>;
+                       resets = <&cpg 328>;
                        status = "disabled";
                };
 
-               sdhi3: sd@ee160000 {
-                       compatible = "renesas,sdhi-r8a7795",
-                                    "renesas,rcar-gen3-sdhi";
-                       reg = <0 0xee160000 0 0x2000>;
-                       interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 311>;
-                       max-frequency = <200000000>;
+               usb3_peri0: usb@ee020000 {
+                       compatible = "renesas,r8a7795-usb3-peri",
+                                    "renesas,rcar-gen3-usb3-peri";
+                       reg = <0 0xee020000 0 0x400>;
+                       interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 328>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 311>;
+                       resets = <&cpg 328>;
                        status = "disabled";
                };
 
-               usb2_phy0: usb-phy@ee080200 {
-                       compatible = "renesas,usb2-phy-r8a7795",
-                                    "renesas,rcar-gen3-usb2-phy";
-                       reg = <0 0xee080200 0 0x700>;
+               ohci0: usb@ee080000 {
+                       compatible = "generic-ohci";
+                       reg = <0 0xee080000 0 0x100>;
                        interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 703>;
+                       phys = <&usb2_phy0>;
+                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
                        resets = <&cpg 703>;
-                       #phy-cells = <0>;
                        status = "disabled";
                };
 
-               usb2_phy1: usb-phy@ee0a0200 {
-                       compatible = "renesas,usb2-phy-r8a7795",
-                                    "renesas,rcar-gen3-usb2-phy";
-                       reg = <0 0xee0a0200 0 0x700>;
+               ohci1: usb@ee0a0000 {
+                       compatible = "generic-ohci";
+                       reg = <0 0xee0a0000 0 0x100>;
+                       interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 702>;
+                       phys = <&usb2_phy1>;
+                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
                        resets = <&cpg 702>;
-                       #phy-cells = <0>;
                        status = "disabled";
                };
 
-               usb2_phy2: usb-phy@ee0c0200 {
-                       compatible = "renesas,usb2-phy-r8a7795",
-                                    "renesas,rcar-gen3-usb2-phy";
-                       reg = <0 0xee0c0200 0 0x700>;
+               ohci2: usb@ee0c0000 {
+                       compatible = "generic-ohci";
+                       reg = <0 0xee0c0000 0 0x100>;
+                       interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 701>;
+                       phys = <&usb2_phy2>;
+                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
                        resets = <&cpg 701>;
-                       #phy-cells = <0>;
                        status = "disabled";
                };
 
-               usb2_phy3: usb-phy@ee0e0200 {
-                       compatible = "renesas,usb2-phy-r8a7795",
-                                    "renesas,rcar-gen3-usb2-phy";
-                       reg = <0 0xee0e0200 0 0x700>;
+               ohci3: usb@ee0e0000 {
+                       compatible = "generic-ohci";
+                       reg = <0 0xee0e0000 0 0x100>;
                        interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 700>;
+                       phys = <&usb2_phy3>;
+                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
                        resets = <&cpg 700>;
-                       #phy-cells = <0>;
                        status = "disabled";
                };
 
@@ -1961,88 +2188,129 @@ ehci3: usb@ee0e0100 {
                        status = "disabled";
                };
 
-               ohci0: usb@ee080000 {
-                       compatible = "generic-ohci";
-                       reg = <0 0xee080000 0 0x100>;
+               usb2_phy0: usb-phy@ee080200 {
+                       compatible = "renesas,usb2-phy-r8a7795",
+                                    "renesas,rcar-gen3-usb2-phy";
+                       reg = <0 0xee080200 0 0x700>;
                        interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 703>;
-                       phys = <&usb2_phy0>;
-                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
                        resets = <&cpg 703>;
+                       #phy-cells = <0>;
                        status = "disabled";
                };
 
-               ohci1: usb@ee0a0000 {
-                       compatible = "generic-ohci";
-                       reg = <0 0xee0a0000 0 0x100>;
-                       interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
+               usb2_phy1: usb-phy@ee0a0200 {
+                       compatible = "renesas,usb2-phy-r8a7795",
+                                    "renesas,rcar-gen3-usb2-phy";
+                       reg = <0 0xee0a0200 0 0x700>;
                        clocks = <&cpg CPG_MOD 702>;
-                       phys = <&usb2_phy1>;
-                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
                        resets = <&cpg 702>;
+                       #phy-cells = <0>;
                        status = "disabled";
                };
 
-               ohci2: usb@ee0c0000 {
-                       compatible = "generic-ohci";
-                       reg = <0 0xee0c0000 0 0x100>;
-                       interrupts = <GIC_SPI 113 IRQ_TYPE_LEVEL_HIGH>;
+               usb2_phy2: usb-phy@ee0c0200 {
+                       compatible = "renesas,usb2-phy-r8a7795",
+                                    "renesas,rcar-gen3-usb2-phy";
+                       reg = <0 0xee0c0200 0 0x700>;
                        clocks = <&cpg CPG_MOD 701>;
-                       phys = <&usb2_phy2>;
-                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
                        resets = <&cpg 701>;
+                       #phy-cells = <0>;
                        status = "disabled";
                };
 
-               ohci3: usb@ee0e0000 {
-                       compatible = "generic-ohci";
-                       reg = <0 0xee0e0000 0 0x100>;
+               usb2_phy3: usb-phy@ee0e0200 {
+                       compatible = "renesas,usb2-phy-r8a7795",
+                                    "renesas,rcar-gen3-usb2-phy";
+                       reg = <0 0xee0e0200 0 0x700>;
                        interrupts = <GIC_SPI 36 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 700>;
-                       phys = <&usb2_phy3>;
-                       phy-names = "usb";
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
                        resets = <&cpg 700>;
+                       #phy-cells = <0>;
                        status = "disabled";
                };
 
-               hsusb: usb@e6590000 {
-                       compatible = "renesas,usbhs-r8a7795",
-                                    "renesas,rcar-gen3-usbhs";
-                       reg = <0 0xe6590000 0 0x100>;
-                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 704>;
-                       dmas = <&usb_dmac0 0>, <&usb_dmac0 1>,
-                              <&usb_dmac1 0>, <&usb_dmac1 1>;
-                       dma-names = "ch0", "ch1", "ch2", "ch3";
-                       renesas,buswait = <11>;
-                       phys = <&usb2_phy0>;
-                       phy-names = "usb";
+               sdhi0: sd@ee100000 {
+                       compatible = "renesas,sdhi-r8a7795",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee100000 0 0x2000>;
+                       interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 314>;
+                       max-frequency = <200000000>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 704>;
+                       resets = <&cpg 314>;
                        status = "disabled";
                };
 
-               hsusb3: usb@e659c000 {
-                       compatible = "renesas,usbhs-r8a7795",
-                                    "renesas,rcar-gen3-usbhs";
-                       reg = <0 0xe659c000 0 0x100>;
-                       interrupts = <GIC_SPI 37 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 705>;
-                       dmas = <&usb_dmac2 0>, <&usb_dmac2 1>,
-                              <&usb_dmac3 0>, <&usb_dmac3 1>;
-                       dma-names = "ch0", "ch1", "ch2", "ch3";
-                       renesas,buswait = <11>;
-                       phys = <&usb2_phy3>;
-                       phy-names = "usb";
+               sdhi1: sd@ee120000 {
+                       compatible = "renesas,sdhi-r8a7795",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee120000 0 0x2000>;
+                       interrupts = <GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 313>;
+                       max-frequency = <200000000>;
                        power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 705>;
+                       resets = <&cpg 313>;
                        status = "disabled";
                };
 
+               sdhi2: sd@ee140000 {
+                       compatible = "renesas,sdhi-r8a7795",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee140000 0 0x2000>;
+                       interrupts = <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 312>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 312>;
+                       status = "disabled";
+               };
+
+               sdhi3: sd@ee160000 {
+                       compatible = "renesas,sdhi-r8a7795",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee160000 0 0x2000>;
+                       interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 311>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 311>;
+                       status = "disabled";
+               };
+
+               sata: sata@ee300000 {
+                       compatible = "renesas,sata-r8a7795",
+                                    "renesas,rcar-gen3-sata";
+                       reg = <0 0xee300000 0 0x200000>;
+                       interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 815>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 815>;
+                       status = "disabled";
+                       iommus = <&ipmmu_hc 2>;
+               };
+
+               gic: interrupt-controller@f1010000 {
+                       compatible = "arm,gic-400";
+                       #interrupt-cells = <3>;
+                       #address-cells = <0>;
+                       interrupt-controller;
+                       reg = <0x0 0xf1010000 0 0x1000>,
+                             <0x0 0xf1020000 0 0x20000>,
+                             <0x0 0xf1040000 0 0x20000>,
+                             <0x0 0xf1060000 0 0x20000>;
+                       interrupts = <GIC_PPI 9
+                                       (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_HIGH)>;
+                       clocks = <&cpg CPG_MOD 408>;
+                       clock-names = "clk";
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 408>;
+               };
+
                pciec0: pcie@fe000000 {
                        compatible = "renesas,pcie-r8a7795",
                                     "renesas,pcie-rcar-gen3";
@@ -2133,28 +2401,28 @@ imr-lx4@fe890000 {
                        reg = <0 0xfe890000 0 0x2000>;
                        interrupts = <GIC_SPI 195 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 820>;
-                       power-domains = <&sysc R8A7795_PD_A3VC>;
-                       resets = <&cpg 820>;
-               };
-
-               vspbc: vsp@fe920000 {
-                       compatible = "renesas,vsp2";
-                       reg = <0 0xfe920000 0 0x8000>;
-                       interrupts = <GIC_SPI 465 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 624>;
-                       power-domains = <&sysc R8A7795_PD_A3VP>;
-                       resets = <&cpg 624>;
+                       power-domains = <&sysc R8A7795_PD_A3VC>;
+                       resets = <&cpg 820>;
+               };
 
-                       renesas,fcp = <&fcpvb1>;
+               fdp1@fe940000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe940000 0 0x2400>;
+                       interrupts = <GIC_SPI 262 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 119>;
+                       power-domains = <&sysc R8A7795_PD_A3VP>;
+                       resets = <&cpg 119>;
+                       renesas,fcp = <&fcpf0>;
                };
 
-               fcpvb1: fcp@fe92f000 {
-                       compatible = "renesas,fcpv";
-                       reg = <0 0xfe92f000 0 0x200>;
-                       clocks = <&cpg CPG_MOD 606>;
+               fdp1@fe944000 {
+                       compatible = "renesas,fdp1";
+                       reg = <0 0xfe944000 0 0x2400>;
+                       interrupts = <GIC_SPI 263 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 118>;
                        power-domains = <&sysc R8A7795_PD_A3VP>;
-                       resets = <&cpg 606>;
-                       iommus = <&ipmmu_vp1 7>;
+                       resets = <&cpg 118>;
+                       renesas,fcp = <&fcpf1>;
                };
 
                fcpf0: fcp@fe950000 {
@@ -2175,17 +2443,6 @@ fcpf1: fcp@fe951000 {
                        iommus = <&ipmmu_vp1 1>;
                };
 
-               vspbd: vsp@fe960000 {
-                       compatible = "renesas,vsp2";
-                       reg = <0 0xfe960000 0 0x8000>;
-                       interrupts = <GIC_SPI 266 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 626>;
-                       power-domains = <&sysc R8A7795_PD_A3VP>;
-                       resets = <&cpg 626>;
-
-                       renesas,fcp = <&fcpvb0>;
-               };
-
                fcpvb0: fcp@fe96f000 {
                        compatible = "renesas,fcpv";
                        reg = <0 0xfe96f000 0 0x200>;
@@ -2195,15 +2452,13 @@ fcpvb0: fcp@fe96f000 {
                        iommus = <&ipmmu_vp0 5>;
                };
 
-               vspi0: vsp@fe9a0000 {
-                       compatible = "renesas,vsp2";
-                       reg = <0 0xfe9a0000 0 0x8000>;
-                       interrupts = <GIC_SPI 444 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 631>;
+               fcpvb1: fcp@fe92f000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfe92f000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 606>;
                        power-domains = <&sysc R8A7795_PD_A3VP>;
-                       resets = <&cpg 631>;
-
-                       renesas,fcp = <&fcpvi0>;
+                       resets = <&cpg 606>;
+                       iommus = <&ipmmu_vp1 7>;
                };
 
                fcpvi0: fcp@fe9af000 {
@@ -2215,17 +2470,6 @@ fcpvi0: fcp@fe9af000 {
                        iommus = <&ipmmu_vp0 8>;
                };
 
-               vspi1: vsp@fe9b0000 {
-                       compatible = "renesas,vsp2";
-                       reg = <0 0xfe9b0000 0 0x8000>;
-                       interrupts = <GIC_SPI 445 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 630>;
-                       power-domains = <&sysc R8A7795_PD_A3VP>;
-                       resets = <&cpg 630>;
-
-                       renesas,fcp = <&fcpvi1>;
-               };
-
                fcpvi1: fcp@fe9bf000 {
                        compatible = "renesas,fcpv";
                        reg = <0 0xfe9bf000 0 0x200>;
@@ -2235,6 +2479,55 @@ fcpvi1: fcp@fe9bf000 {
                        iommus = <&ipmmu_vp1 9>;
                };
 
+               fcpvd0: fcp@fea27000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea27000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 603>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 603>;
+                       iommus = <&ipmmu_vi0 8>;
+               };
+
+               fcpvd1: fcp@fea2f000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea2f000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 602>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 602>;
+                       iommus = <&ipmmu_vi0 9>;
+               };
+
+               fcpvd2: fcp@fea37000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea37000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 601>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 601>;
+                       iommus = <&ipmmu_vi1 10>;
+               };
+
+               vspbd: vsp@fe960000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfe960000 0 0x8000>;
+                       interrupts = <GIC_SPI 266 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 626>;
+                       power-domains = <&sysc R8A7795_PD_A3VP>;
+                       resets = <&cpg 626>;
+
+                       renesas,fcp = <&fcpvb0>;
+               };
+
+               vspbc: vsp@fe920000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfe920000 0 0x8000>;
+                       interrupts = <GIC_SPI 465 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 624>;
+                       power-domains = <&sysc R8A7795_PD_A3VP>;
+                       resets = <&cpg 624>;
+
+                       renesas,fcp = <&fcpvb1>;
+               };
+
                vspd0: vsp@fea20000 {
                        compatible = "renesas,vsp2";
                        reg = <0 0xfea20000 0 0x8000>;
@@ -2246,15 +2539,6 @@ vspd0: vsp@fea20000 {
                        renesas,fcp = <&fcpvd0>;
                };
 
-               fcpvd0: fcp@fea27000 {
-                       compatible = "renesas,fcpv";
-                       reg = <0 0xfea27000 0 0x200>;
-                       clocks = <&cpg CPG_MOD 603>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 603>;
-                       iommus = <&ipmmu_vi0 8>;
-               };
-
                vspd1: vsp@fea28000 {
                        compatible = "renesas,vsp2";
                        reg = <0 0xfea28000 0 0x8000>;
@@ -2266,15 +2550,6 @@ vspd1: vsp@fea28000 {
                        renesas,fcp = <&fcpvd1>;
                };
 
-               fcpvd1: fcp@fea2f000 {
-                       compatible = "renesas,fcpv";
-                       reg = <0 0xfea2f000 0 0x200>;
-                       clocks = <&cpg CPG_MOD 602>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 602>;
-                       iommus = <&ipmmu_vi0 9>;
-               };
-
                vspd2: vsp@fea30000 {
                        compatible = "renesas,vsp2";
                        reg = <0 0xfea30000 0 0x8000>;
@@ -2286,33 +2561,159 @@ vspd2: vsp@fea30000 {
                        renesas,fcp = <&fcpvd2>;
                };
 
-               fcpvd2: fcp@fea37000 {
-                       compatible = "renesas,fcpv";
-                       reg = <0 0xfea37000 0 0x200>;
-                       clocks = <&cpg CPG_MOD 601>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 601>;
-                       iommus = <&ipmmu_vi1 10>;
+               vspi0: vsp@fe9a0000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfe9a0000 0 0x8000>;
+                       interrupts = <GIC_SPI 444 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 631>;
+                       power-domains = <&sysc R8A7795_PD_A3VP>;
+                       resets = <&cpg 631>;
+
+                       renesas,fcp = <&fcpvi0>;
                };
 
-               fdp1@fe940000 {
-                       compatible = "renesas,fdp1";
-                       reg = <0 0xfe940000 0 0x2400>;
-                       interrupts = <GIC_SPI 262 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 119>;
+               vspi1: vsp@fe9b0000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfe9b0000 0 0x8000>;
+                       interrupts = <GIC_SPI 445 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 630>;
                        power-domains = <&sysc R8A7795_PD_A3VP>;
-                       resets = <&cpg 119>;
-                       renesas,fcp = <&fcpf0>;
+                       resets = <&cpg 630>;
+
+                       renesas,fcp = <&fcpvi1>;
                };
 
-               fdp1@fe944000 {
-                       compatible = "renesas,fdp1";
-                       reg = <0 0xfe944000 0 0x2400>;
-                       interrupts = <GIC_SPI 263 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 118>;
-                       power-domains = <&sysc R8A7795_PD_A3VP>;
-                       resets = <&cpg 118>;
-                       renesas,fcp = <&fcpf1>;
+               csi20: csi2@fea80000 {
+                       compatible = "renesas,r8a7795-csi2";
+                       reg = <0 0xfea80000 0 0x10000>;
+                       interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 714>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 714>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       csi20vin0: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint = <&vin0csi20>;
+                                       };
+                                       csi20vin1: endpoint@1 {
+                                               reg = <1>;
+                                               remote-endpoint = <&vin1csi20>;
+                                       };
+                                       csi20vin2: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint = <&vin2csi20>;
+                                       };
+                                       csi20vin3: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint = <&vin3csi20>;
+                                       };
+                                       csi20vin4: endpoint@4 {
+                                               reg = <4>;
+                                               remote-endpoint = <&vin4csi20>;
+                                       };
+                                       csi20vin5: endpoint@5 {
+                                               reg = <5>;
+                                               remote-endpoint = <&vin5csi20>;
+                                       };
+                                       csi20vin6: endpoint@6 {
+                                               reg = <6>;
+                                               remote-endpoint = <&vin6csi20>;
+                                       };
+                                       csi20vin7: endpoint@7 {
+                                               reg = <7>;
+                                               remote-endpoint = <&vin7csi20>;
+                                       };
+                               };
+                       };
+               };
+
+               csi40: csi2@feaa0000 {
+                       compatible = "renesas,r8a7795-csi2";
+                       reg = <0 0xfeaa0000 0 0x10000>;
+                       interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 716>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 716>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       csi40vin0: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint = <&vin0csi40>;
+                                       };
+                                       csi40vin1: endpoint@1 {
+                                               reg = <1>;
+                                               remote-endpoint = <&vin1csi40>;
+                                       };
+                                       csi40vin2: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint = <&vin2csi40>;
+                                       };
+                                       csi40vin3: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint = <&vin3csi40>;
+                                       };
+                               };
+                       };
+               };
+
+               csi41: csi2@feab0000 {
+                       compatible = "renesas,r8a7795-csi2";
+                       reg = <0 0xfeab0000 0 0x10000>;
+                       interrupts = <GIC_SPI 247 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 715>;
+                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
+                       resets = <&cpg 715>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       csi41vin4: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint = <&vin4csi41>;
+                                       };
+                                       csi41vin5: endpoint@1 {
+                                               reg = <1>;
+                                               remote-endpoint = <&vin5csi41>;
+                                       };
+                                       csi41vin6: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint = <&vin6csi41>;
+                                       };
+                                       csi41vin7: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint = <&vin7csi41>;
+                                       };
+                               };
+                       };
                };
 
                hdmi0: hdmi@fead0000 {
@@ -2337,6 +2738,10 @@ dw_hdmi0_in: endpoint {
                                port@1 {
                                        reg = <1>;
                                };
+                               port@2 {
+                                       /* HDMI sound */
+                                       reg = <2>;
+                               };
                        };
                };
 
@@ -2362,6 +2767,10 @@ dw_hdmi1_in: endpoint {
                                port@1 {
                                        reg = <1>;
                                };
+                               port@2 {
+                                       /* HDMI sound */
+                                       reg = <2>;
+                               };
                        };
                };
 
@@ -2412,38 +2821,12 @@ du_out_lvds0: endpoint {
                        };
                };
 
-               tsc: thermal@e6198000 {
-                       compatible = "renesas,r8a7795-thermal";
-                       reg = <0 0xe6198000 0 0x100>,
-                             <0 0xe61a0000 0 0x100>,
-                             <0 0xe61a8000 0 0x100>;
-                       interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 522>;
-                       power-domains = <&sysc R8A7795_PD_ALWAYS_ON>;
-                       resets = <&cpg 522>;
-                       #thermal-sensor-cells = <1>;
-                       status = "okay";
+               prr: chipid@fff00044 {
+                       compatible = "renesas,prr";
+                       reg = <0 0xfff00044 0 4>;
                };
        };
 
-       timer {
-               compatible = "arm,armv8-timer";
-               interrupts-extended = <&gic GIC_PPI 13
-                                      (GIC_CPU_MASK_SIMPLE(8) |
-                                      IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 14
-                                      (GIC_CPU_MASK_SIMPLE(8) |
-                                      IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 11
-                                      (GIC_CPU_MASK_SIMPLE(8) |
-                                      IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 10
-                                      (GIC_CPU_MASK_SIMPLE(8) |
-                                      IRQ_TYPE_LEVEL_LOW)>;
-       };
-
        thermal-zones {
                sensor_thermal1: sensor-thermal1 {
                        polling-delay-passive = <250>;
@@ -2453,12 +2836,12 @@ sensor_thermal1: sensor-thermal1 {
                        trips {
                                sensor1_passive: sensor1-passive {
                                        temperature = <95000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "passive";
                                };
                                sensor1_crit: sensor1-crit {
                                        temperature = <120000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "critical";
                                };
                        };
@@ -2479,12 +2862,12 @@ sensor_thermal2: sensor-thermal2 {
                        trips {
                                sensor2_passive: sensor2-passive {
                                        temperature = <95000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "passive";
                                };
                                sensor2_crit: sensor2-crit {
                                        temperature = <120000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "critical";
                                };
                        };
@@ -2505,12 +2888,12 @@ sensor_thermal3: sensor-thermal3 {
                        trips {
                                sensor3_passive: sensor3-passive {
                                        temperature = <95000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "passive";
                                };
                                sensor3_crit: sensor3-crit {
                                        temperature = <120000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "critical";
                                };
                        };
@@ -2524,6 +2907,14 @@ map0 {
                };
        };
 
+       timer {
+               compatible = "arm,armv8-timer";
+               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(8) | IRQ_TYPE_LEVEL_LOW)>;
+       };
+
        /* External USB clocks - can be overridden by the board */
        usb3s0_clk: usb3s0 {
                compatible = "fixed-clock";
index 498c9e807dc47e8b50fa2206a6e027229f8b57a3..90cca09b9a5e9cee8350bb95adb8a5b910652ffc 100644 (file)
@@ -40,6 +40,11 @@ &du {
                      "dclkin.0", "dclkin.1", "dclkin.2";
 };
 
+&sound_card {
+       dais = <&rsnd_port0     /* ak4613 */
+               &rsnd_port1>;   /* HDMI0  */
+};
+
 &hdmi0 {
        status = "okay";
 
@@ -50,9 +55,32 @@ rcar_dw_hdmi0_out: endpoint {
                                remote-endpoint = <&hdmi0_con>;
                        };
                };
+               port@2 {
+                       reg = <2>;
+                       dw_hdmi0_snd_in: endpoint {
+                               remote-endpoint = <&rsnd_endpoint1>;
+                       };
+               };
        };
 };
 
 &hdmi0_con {
        remote-endpoint = <&rcar_dw_hdmi0_out>;
 };
+
+&rcar_sound {
+       ports {
+               /* rsnd_port0 is on salvator-common */
+               rsnd_port1: port@1 {
+                       rsnd_endpoint1: endpoint {
+                               remote-endpoint = <&dw_hdmi0_snd_in>;
+
+                               dai-format = "i2s";
+                               bitclock-master = <&rsnd_endpoint1>;
+                               frame-master = <&rsnd_endpoint1>;
+
+                               playback = <&ssi2>;
+                       };
+               };
+       };
+};
index 2c37055efa94d3c32d12efaa57f885789afe113c..ddf35d4cd5e56f9d26ccbc0a1477421d6987dda7 100644 (file)
@@ -40,6 +40,11 @@ &du {
                      "dclkin.0", "dclkin.1", "dclkin.2";
 };
 
+&sound_card {
+       dais = <&rsnd_port0     /* ak4613 */
+               &rsnd_port1>;   /* HDMI0  */
+};
+
 &hdmi0 {
        status = "okay";
 
@@ -50,9 +55,32 @@ rcar_dw_hdmi0_out: endpoint {
                                remote-endpoint = <&hdmi0_con>;
                        };
                };
+               port@2 {
+                       reg = <2>;
+                       dw_hdmi0_snd_in: endpoint {
+                               remote-endpoint = <&rsnd_endpoint1>;
+                       };
+               };
        };
 };
 
 &hdmi0_con {
        remote-endpoint = <&rcar_dw_hdmi0_out>;
 };
+
+&rcar_sound {
+       ports {
+               /* rsnd_port0 is on salvator-common */
+               rsnd_port1: port@1 {
+                       rsnd_endpoint1: endpoint {
+                               remote-endpoint = <&dw_hdmi0_snd_in>;
+
+                               dai-format = "i2s";
+                               bitclock-master = <&rsnd_endpoint1>;
+                               frame-master = <&rsnd_endpoint1>;
+
+                               playback = <&ssi2>;
+                       };
+               };
+       };
+};
index 556eb8e45499daeefa56266d1a132633415e9be0..7c25be6b5af3eea8cd6978b43e69409c8c5c078e 100644 (file)
@@ -60,6 +60,72 @@ can_clk: can {
                clock-frequency = <0>;
        };
 
+       cluster0_opp: opp_table0 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp-500000000 {
+                       opp-hz = /bits/ 64 <500000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1000000000 {
+                       opp-hz = /bits/ 64 <1000000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1500000000 {
+                       opp-hz = /bits/ 64 <1500000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1600000000 {
+                       opp-hz = /bits/ 64 <1600000000>;
+                       opp-microvolt = <900000>;
+                       clock-latency-ns = <300000>;
+                       turbo-mode;
+               };
+               opp-1700000000 {
+                       opp-hz = /bits/ 64 <1700000000>;
+                       opp-microvolt = <900000>;
+                       clock-latency-ns = <300000>;
+                       turbo-mode;
+               };
+               opp-1800000000 {
+                       opp-hz = /bits/ 64 <1800000000>;
+                       opp-microvolt = <960000>;
+                       clock-latency-ns = <300000>;
+                       turbo-mode;
+               };
+       };
+
+       cluster1_opp: opp_table1 {
+               compatible = "operating-points-v2";
+               opp-shared;
+
+               opp-800000000 {
+                       opp-hz = /bits/ 64 <800000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1000000000 {
+                       opp-hz = /bits/ 64 <1000000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1200000000 {
+                       opp-hz = /bits/ 64 <1200000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+               };
+               opp-1300000000 {
+                       opp-hz = /bits/ 64 <1300000000>;
+                       opp-microvolt = <820000>;
+                       clock-latency-ns = <300000>;
+                       turbo-mode;
+               };
+       };
+
        cpus {
                #address-cells = <1>;
                #size-cells = <0>;
@@ -77,7 +143,7 @@ a57_0: cpu@0 {
                };
 
                a57_1: cpu@1 {
-                       compatible = "arm,cortex-a57","arm,armv8";
+                       compatible = "arm,cortex-a57", "arm,armv8";
                        reg = <0x1>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7796_PD_CA57_CPU1>;
@@ -100,7 +166,7 @@ a53_0: cpu@100 {
                };
 
                a53_1: cpu@101 {
-                       compatible = "arm,cortex-a53","arm,armv8";
+                       compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x101>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7796_PD_CA53_CPU1>;
@@ -111,7 +177,7 @@ a53_1: cpu@101 {
                };
 
                a53_2: cpu@102 {
-                       compatible = "arm,cortex-a53","arm,armv8";
+                       compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x102>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7796_PD_CA53_CPU2>;
@@ -122,7 +188,7 @@ a53_2: cpu@102 {
                };
 
                a53_3: cpu@103 {
-                       compatible = "arm,cortex-a53","arm,armv8";
+                       compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0x103>;
                        device_type = "cpu";
                        power-domains = <&sysc R8A7796_PD_CA53_CPU3>;
@@ -161,72 +227,6 @@ extalr_clk: extalr {
                clock-frequency = <0>;
        };
 
-       cluster0_opp: opp_table0 {
-               compatible = "operating-points-v2";
-               opp-shared;
-
-               opp-500000000 {
-                       opp-hz = /bits/ 64 <500000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1000000000 {
-                       opp-hz = /bits/ 64 <1000000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1500000000 {
-                       opp-hz = /bits/ 64 <1500000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1600000000 {
-                       opp-hz = /bits/ 64 <1600000000>;
-                       opp-microvolt = <900000>;
-                       clock-latency-ns = <300000>;
-                       turbo-mode;
-               };
-               opp-1700000000 {
-                       opp-hz = /bits/ 64 <1700000000>;
-                       opp-microvolt = <900000>;
-                       clock-latency-ns = <300000>;
-                       turbo-mode;
-               };
-               opp-1800000000 {
-                       opp-hz = /bits/ 64 <1800000000>;
-                       opp-microvolt = <960000>;
-                       clock-latency-ns = <300000>;
-                       turbo-mode;
-               };
-       };
-
-       cluster1_opp: opp_table1 {
-               compatible = "operating-points-v2";
-               opp-shared;
-
-               opp-800000000 {
-                       opp-hz = /bits/ 64 <800000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1000000000 {
-                       opp-hz = /bits/ 64 <1000000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1200000000 {
-                       opp-hz = /bits/ 64 <1200000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-               };
-               opp-1300000000 {
-                       opp-hz = /bits/ 64 <1300000000>;
-                       opp-microvolt = <820000>;
-                       clock-latency-ns = <300000>;
-                       turbo-mode;
-               };
-       };
-
        /* External PCIe clock - can be overridden by the board */
        pcie_bus_clk: pcie_bus {
                compatible = "fixed-clock";
@@ -234,13 +234,6 @@ pcie_bus_clk: pcie_bus {
                clock-frequency = <0>;
        };
 
-       pmu_a57 {
-               compatible = "arm,cortex-a57-pmu";
-               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
-                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-affinity = <&a57_0>, <&a57_1>;
-       };
-
        pmu_a53 {
                compatible = "arm,cortex-a53-pmu";
                interrupts-extended = <&gic GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>,
@@ -250,6 +243,13 @@ pmu_a53 {
                interrupt-affinity = <&a53_0>, <&a53_1>, <&a53_2>, <&a53_3>;
        };
 
+       pmu_a57 {
+               compatible = "arm,cortex-a57-pmu";
+               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&a57_0>, <&a57_1>;
+       };
+
        psci {
                compatible = "arm,psci-1.0", "arm,psci-0.2";
                method = "smc";
@@ -269,23 +269,6 @@ soc {
                #size-cells = <2>;
                ranges;
 
-               gic: interrupt-controller@f1010000 {
-                       compatible = "arm,gic-400";
-                       #interrupt-cells = <3>;
-                       #address-cells = <0>;
-                       interrupt-controller;
-                       reg = <0x0 0xf1010000 0 0x1000>,
-                             <0x0 0xf1020000 0 0x20000>,
-                             <0x0 0xf1040000 0 0x20000>,
-                             <0x0 0xf1060000 0 0x20000>;
-                       interrupts = <GIC_PPI 9
-                                       (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_HIGH)>;
-                       clocks = <&cpg CPG_MOD 408>;
-                       clock-names = "clk";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 408>;
-               };
-
                wdt0: watchdog@e6020000 {
                        compatible = "renesas,r8a7796-wdt",
                                     "renesas,rcar-gen3-wdt";
@@ -421,242 +404,72 @@ pfc: pin-controller@e6060000 {
                        reg = <0 0xe6060000 0 0x50c>;
                };
 
-               ipmmu_vi0: mmu@febd0000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xfebd0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 9>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+               cpg: clock-controller@e6150000 {
+                       compatible = "renesas,r8a7796-cpg-mssr";
+                       reg = <0 0xe6150000 0 0x1000>;
+                       clocks = <&extal_clk>, <&extalr_clk>;
+                       clock-names = "extal", "extalr";
+                       #clock-cells = <2>;
+                       #power-domain-cells = <0>;
+                       #reset-cells = <1>;
                };
 
-               ipmmu_vc0: mmu@fe6b0000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xfe6b0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 8>;
-                       power-domains = <&sysc R8A7796_PD_A3VC>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+               rst: reset-controller@e6160000 {
+                       compatible = "renesas,r8a7796-rst";
+                       reg = <0 0xe6160000 0 0x0200>;
                };
 
-               ipmmu_pv0: mmu@fd800000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xfd800000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 5>;
+               sysc: system-controller@e6180000 {
+                       compatible = "renesas,r8a7796-sysc";
+                       reg = <0 0xe6180000 0 0x0400>;
+                       #power-domain-cells = <1>;
+               };
+
+               tsc: thermal@e6198000 {
+                       compatible = "renesas,r8a7796-thermal";
+                       reg = <0 0xe6198000 0 0x100>,
+                             <0 0xe61a0000 0 0x100>,
+                             <0 0xe61a8000 0 0x100>;
+                       interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 522>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
+                       resets = <&cpg 522>;
+                       #thermal-sensor-cells = <1>;
+                       status = "okay";
                };
 
-               ipmmu_pv1: mmu@fd950000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xfd950000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 6>;
+               intc_ex: interrupt-controller@e61c0000 {
+                       compatible = "renesas,intc-ex-r8a7796", "renesas,irqc";
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       reg = <0 0xe61c0000 0 0x200>;
+                       interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 407>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+                       resets = <&cpg 407>;
                };
 
-               ipmmu_ir: mmu@ff8b0000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xff8b0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 3>;
-                       power-domains = <&sysc R8A7796_PD_A3IR>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
-               };
-
-               ipmmu_hc: mmu@e6570000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xe6570000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 2>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
-               };
-
-               ipmmu_rt: mmu@ffc80000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xffc80000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 7>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
-               };
-
-               ipmmu_mp: mmu@ec670000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xec670000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 4>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-               };
-
-               ipmmu_ds0: mmu@e6740000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xe6740000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 0>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-               };
-
-               ipmmu_ds1: mmu@e7740000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xe7740000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 1>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-               };
-
-               ipmmu_mm: mmu@e67b0000 {
-                       compatible = "renesas,ipmmu-r8a7796";
-                       reg = <0 0xe67b0000 0 0x1000>;
-                       interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-               };
-
-               cpg: clock-controller@e6150000 {
-                       compatible = "renesas,r8a7796-cpg-mssr";
-                       reg = <0 0xe6150000 0 0x1000>;
-                       clocks = <&extal_clk>, <&extalr_clk>;
-                       clock-names = "extal", "extalr";
-                       #clock-cells = <2>;
-                       #power-domain-cells = <0>;
-                       #reset-cells = <1>;
-               };
-
-               rst: reset-controller@e6160000 {
-                       compatible = "renesas,r8a7796-rst";
-                       reg = <0 0xe6160000 0 0x0200>;
-               };
-
-               prr: chipid@fff00044 {
-                       compatible = "renesas,prr";
-                       reg = <0 0xfff00044 0 4>;
-               };
-
-               sysc: system-controller@e6180000 {
-                       compatible = "renesas,r8a7796-sysc";
-                       reg = <0 0xe6180000 0 0x0400>;
-                       #power-domain-cells = <1>;
-               };
-
-               intc_ex: interrupt-controller@e61c0000 {
-                       compatible = "renesas,intc-ex-r8a7796", "renesas,irqc";
-                       #interrupt-cells = <2>;
-                       interrupt-controller;
-                       reg = <0 0xe61c0000 0 0x200>;
-                       interrupts = <GIC_SPI 0 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 1 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 2 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 407>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 407>;
-               };
-
-               i2c_dvfs: i2c@e60b0000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,iic-r8a7796",
-                                    "renesas,rcar-gen3-iic",
-                                    "renesas,rmobile-iic";
-                       reg = <0 0xe60b0000 0 0x425>;
-                       interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 926>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 926>;
-                       dmas = <&dmac0 0x11>, <&dmac0 0x10>;
-                       dma-names = "tx", "rx";
-                       status = "disabled";
-               };
-
-               pwm0: pwm@e6e30000 {
-                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
-                       reg = <0 0xe6e30000 0 8>;
-                       #pwm-cells = <2>;
-                       clocks = <&cpg CPG_MOD 523>;
-                       resets = <&cpg 523>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       status = "disabled";
-               };
-
-               pwm1: pwm@e6e31000 {
-                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
-                       reg = <0 0xe6e31000 0 8>;
-                       #pwm-cells = <2>;
-                       clocks = <&cpg CPG_MOD 523>;
-                       resets = <&cpg 523>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       status = "disabled";
-               };
-
-               pwm2: pwm@e6e32000 {
-                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
-                       reg = <0 0xe6e32000 0 8>;
-                       #pwm-cells = <2>;
-                       clocks = <&cpg CPG_MOD 523>;
-                       resets = <&cpg 523>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       status = "disabled";
-               };
-
-               pwm3: pwm@e6e33000 {
-                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
-                       reg = <0 0xe6e33000 0 8>;
-                       #pwm-cells = <2>;
-                       clocks = <&cpg CPG_MOD 523>;
-                       resets = <&cpg 523>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       status = "disabled";
-               };
-
-               pwm4: pwm@e6e34000 {
-                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
-                       reg = <0 0xe6e34000 0 8>;
-                       #pwm-cells = <2>;
-                       clocks = <&cpg CPG_MOD 523>;
-                       resets = <&cpg 523>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       status = "disabled";
-               };
-
-               pwm5: pwm@e6e35000 {
-                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
-                       reg = <0 0xe6e35000 0 8>;
-                       #pwm-cells = <2>;
-                       clocks = <&cpg CPG_MOD 523>;
-                       resets = <&cpg 523>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       status = "disabled";
-               };
-
-               pwm6: pwm@e6e36000 {
-                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
-                       reg = <0 0xe6e36000 0 8>;
-                       #pwm-cells = <2>;
-                       clocks = <&cpg CPG_MOD 523>;
-                       resets = <&cpg 523>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       status = "disabled";
-               };
-
-               i2c0: i2c@e6500000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a7796",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe6500000 0 0x40>;
-                       interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 931>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 931>;
-                       dmas = <&dmac1 0x91>, <&dmac1 0x90>,
-                              <&dmac2 0x91>, <&dmac2 0x90>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       i2c-scl-internal-delay-ns = <110>;
+               i2c0: i2c@e6500000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a7796",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6500000 0 0x40>;
+                       interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 931>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 931>;
+                       dmas = <&dmac1 0x91>, <&dmac1 0x90>,
+                              <&dmac2 0x91>, <&dmac2 0x90>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <110>;
                        status = "disabled";
                };
 
@@ -758,244 +571,37 @@ i2c6: i2c@e66e8000 {
                        status = "disabled";
                };
 
-               can0: can@e6c30000 {
-                       compatible = "renesas,can-r8a7796",
-                                    "renesas,rcar-gen3-can";
-                       reg = <0 0xe6c30000 0 0x1000>;
-                       interrupts = <GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 916>,
-                              <&cpg CPG_CORE R8A7796_CLK_CANFD>,
-                              <&can_clk>;
-                       clock-names = "clkp1", "clkp2", "can_clk";
-                       assigned-clocks = <&cpg CPG_CORE R8A7796_CLK_CANFD>;
-                       assigned-clock-rates = <40000000>;
+               i2c_dvfs: i2c@e60b0000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,iic-r8a7796",
+                                    "renesas,rcar-gen3-iic",
+                                    "renesas,rmobile-iic";
+                       reg = <0 0xe60b0000 0 0x425>;
+                       interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 926>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 916>;
+                       resets = <&cpg 926>;
+                       dmas = <&dmac0 0x11>, <&dmac0 0x10>;
+                       dma-names = "tx", "rx";
                        status = "disabled";
                };
 
-               can1: can@e6c38000 {
-                       compatible = "renesas,can-r8a7796",
-                                    "renesas,rcar-gen3-can";
-                       reg = <0 0xe6c38000 0 0x1000>;
-                       interrupts = <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 915>,
-                              <&cpg CPG_CORE R8A7796_CLK_CANFD>,
-                              <&can_clk>;
-                       clock-names = "clkp1", "clkp2", "can_clk";
-                       assigned-clocks = <&cpg CPG_CORE R8A7796_CLK_CANFD>;
-                       assigned-clock-rates = <40000000>;
+               hscif0: serial@e6540000 {
+                       compatible = "renesas,hscif-r8a7796",
+                                    "renesas,rcar-gen3-hscif",
+                                    "renesas,hscif";
+                       reg = <0 0xe6540000 0 0x60>;
+                       interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 520>,
+                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac1 0x31>, <&dmac1 0x30>,
+                              <&dmac2 0x31>, <&dmac2 0x30>;
+                       dma-names = "tx", "rx", "tx", "rx";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 915>;
-                       status = "disabled";
-               };
-
-               canfd: can@e66c0000 {
-                       compatible = "renesas,r8a7796-canfd",
-                                    "renesas,rcar-gen3-canfd";
-                       reg = <0 0xe66c0000 0 0x8000>;
-                       interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>,
-                                  <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 914>,
-                              <&cpg CPG_CORE R8A7796_CLK_CANFD>,
-                              <&can_clk>;
-                       clock-names = "fck", "canfd", "can_clk";
-                       assigned-clocks = <&cpg CPG_CORE R8A7796_CLK_CANFD>;
-                       assigned-clock-rates = <40000000>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 914>;
-                       status = "disabled";
-
-                       channel0 {
-                               status = "disabled";
-                       };
-
-                       channel1 {
-                               status = "disabled";
-                       };
-               };
-
-               drif00: rif@e6f40000 {
-                       compatible = "renesas,r8a7796-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f40000 0 0x64>;
-                       interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 515>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x20>, <&dmac2 0x20>;
-                       dma-names = "rx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 515>;
-                       renesas,bonding = <&drif01>;
-                       status = "disabled";
-               };
-
-               drif01: rif@e6f50000 {
-                       compatible = "renesas,r8a7796-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f50000 0 0x64>;
-                       interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 514>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x22>, <&dmac2 0x22>;
-                       dma-names = "rx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 514>;
-                       renesas,bonding = <&drif00>;
-                       status = "disabled";
-               };
-
-               drif10: rif@e6f60000 {
-                       compatible = "renesas,r8a7796-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f60000 0 0x64>;
-                       interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 513>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x24>, <&dmac2 0x24>;
-                       dma-names = "rx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 513>;
-                       renesas,bonding = <&drif11>;
-                       status = "disabled";
-               };
-
-               drif11: rif@e6f70000 {
-                       compatible = "renesas,r8a7796-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f70000 0 0x64>;
-                       interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 512>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x26>, <&dmac2 0x26>;
-                       dma-names = "rx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 512>;
-                       renesas,bonding = <&drif10>;
-                       status = "disabled";
-               };
-
-               drif20: rif@e6f80000 {
-                       compatible = "renesas,r8a7796-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f80000 0 0x64>;
-                       interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 511>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x28>, <&dmac2 0x28>;
-                       dma-names = "rx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 511>;
-                       renesas,bonding = <&drif21>;
-                       status = "disabled";
-               };
-
-               drif21: rif@e6f90000 {
-                       compatible = "renesas,r8a7796-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6f90000 0 0x64>;
-                       interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 510>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x2a>, <&dmac2 0x2a>;
-                       dma-names = "rx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 510>;
-                       renesas,bonding = <&drif20>;
-                       status = "disabled";
-               };
-
-               drif30: rif@e6fa0000 {
-                       compatible = "renesas,r8a7796-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6fa0000 0 0x64>;
-                       interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 509>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x2c>, <&dmac2 0x2c>;
-                       dma-names = "rx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 509>;
-                       renesas,bonding = <&drif31>;
-                       status = "disabled";
-               };
-
-               drif31: rif@e6fb0000 {
-                       compatible = "renesas,r8a7796-drif",
-                                    "renesas,rcar-gen3-drif";
-                       reg = <0 0xe6fb0000 0 0x64>;
-                       interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 508>;
-                       clock-names = "fck";
-                       dmas = <&dmac1 0x2e>, <&dmac2 0x2e>;
-                       dma-names = "rx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 508>;
-                       renesas,bonding = <&drif30>;
-                       status = "disabled";
-               };
-
-               avb: ethernet@e6800000 {
-                       compatible = "renesas,etheravb-r8a7796",
-                                    "renesas,etheravb-rcar-gen3";
-                       reg = <0 0xe6800000 0 0x800>, <0 0xe6a00000 0 0x10000>;
-                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1", "ch2", "ch3",
-                                         "ch4", "ch5", "ch6", "ch7",
-                                         "ch8", "ch9", "ch10", "ch11",
-                                         "ch12", "ch13", "ch14", "ch15",
-                                         "ch16", "ch17", "ch18", "ch19",
-                                         "ch20", "ch21", "ch22", "ch23",
-                                         "ch24";
-                       clocks = <&cpg CPG_MOD 812>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 812>;
-                       phy-mode = "rgmii";
-                       iommus = <&ipmmu_ds0 16>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       status = "disabled";
-               };
-
-               hscif0: serial@e6540000 {
-                       compatible = "renesas,hscif-r8a7796",
-                                    "renesas,rcar-gen3-hscif",
-                                    "renesas,hscif";
-                       reg = <0 0xe6540000 0 0x60>;
-                       interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 520>,
-                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x31>, <&dmac1 0x30>,
-                              <&dmac2 0x31>, <&dmac2 0x30>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 520>;
+                       resets = <&cpg 520>;
                        status = "disabled";
                };
 
@@ -1069,162 +675,61 @@ hscif4: serial@e66b0000 {
                        status = "disabled";
                };
 
-               scif0: serial@e6e60000 {
-                       compatible = "renesas,scif-r8a7796",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6e60000 0 64>;
-                       interrupts = <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 207>,
-                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x51>, <&dmac1 0x50>,
-                              <&dmac2 0x51>, <&dmac2 0x50>;
-                       dma-names = "tx", "rx", "tx", "rx";
+               hsusb: usb@e6590000 {
+                       compatible = "renesas,usbhs-r8a7796",
+                                    "renesas,rcar-gen3-usbhs";
+                       reg = <0 0xe6590000 0 0x100>;
+                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 704>;
+                       dmas = <&usb_dmac0 0>, <&usb_dmac0 1>,
+                              <&usb_dmac1 0>, <&usb_dmac1 1>;
+                       dma-names = "ch0", "ch1", "ch2", "ch3";
+                       renesas,buswait = <11>;
+                       phys = <&usb2_phy0>;
+                       phy-names = "usb";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 207>;
+                       resets = <&cpg 704>;
                        status = "disabled";
                };
 
-               scif1: serial@e6e68000 {
-                       compatible = "renesas,scif-r8a7796",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6e68000 0 64>;
-                       interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 206>,
-                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x53>, <&dmac1 0x52>,
-                              <&dmac2 0x53>, <&dmac2 0x52>;
-                       dma-names = "tx", "rx", "tx", "rx";
+               usb_dmac0: dma-controller@e65a0000 {
+                       compatible = "renesas,r8a7796-usb-dmac",
+                                    "renesas,usb-dmac";
+                       reg = <0 0xe65a0000 0 0x100>;
+                       interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1";
+                       clocks = <&cpg CPG_MOD 330>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 206>;
-                       status = "disabled";
+                       resets = <&cpg 330>;
+                       #dma-cells = <1>;
+                       dma-channels = <2>;
                };
 
-               scif2: serial@e6e88000 {
-                       compatible = "renesas,scif-r8a7796",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6e88000 0 64>;
-                       interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 310>,
-                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 310>;
-                       status = "disabled";
-               };
-
-               scif3: serial@e6c50000 {
-                       compatible = "renesas,scif-r8a7796",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6c50000 0 64>;
-                       interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 204>,
-                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac0 0x57>, <&dmac0 0x56>;
-                       dma-names = "tx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 204>;
-                       status = "disabled";
-               };
-
-               scif4: serial@e6c40000 {
-                       compatible = "renesas,scif-r8a7796",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6c40000 0 64>;
-                       interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 203>,
-                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac0 0x59>, <&dmac0 0x58>;
-                       dma-names = "tx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 203>;
-                       status = "disabled";
-               };
-
-               scif5: serial@e6f30000 {
-                       compatible = "renesas,scif-r8a7796",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6f30000 0 64>;
-                       interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 202>,
-                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x5b>, <&dmac1 0x5a>,
-                              <&dmac2 0x5b>, <&dmac2 0x5a>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 202>;
-                       status = "disabled";
-               };
-
-               msiof0: spi@e6e90000 {
-                       compatible = "renesas,msiof-r8a7796",
-                                    "renesas,rcar-gen3-msiof";
-                       reg = <0 0xe6e90000 0 0x0064>;
-                       interrupts = <GIC_SPI 156 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 211>;
-                       dmas = <&dmac1 0x41>, <&dmac1 0x40>,
-                              <&dmac2 0x41>, <&dmac2 0x40>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 211>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       status = "disabled";
-               };
-
-               msiof1: spi@e6ea0000 {
-                       compatible = "renesas,msiof-r8a7796",
-                                    "renesas,rcar-gen3-msiof";
-                       reg = <0 0xe6ea0000 0 0x0064>;
-                       interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 210>;
-                       dmas = <&dmac1 0x43>, <&dmac1 0x42>,
-                              <&dmac2 0x43>, <&dmac2 0x42>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 210>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       status = "disabled";
-               };
-
-               msiof2: spi@e6c00000 {
-                       compatible = "renesas,msiof-r8a7796",
-                                    "renesas,rcar-gen3-msiof";
-                       reg = <0 0xe6c00000 0 0x0064>;
-                       interrupts = <GIC_SPI 158 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 209>;
-                       dmas = <&dmac0 0x45>, <&dmac0 0x44>;
-                       dma-names = "tx", "rx";
+               usb_dmac1: dma-controller@e65b0000 {
+                       compatible = "renesas,r8a7796-usb-dmac",
+                                    "renesas,usb-dmac";
+                       reg = <0 0xe65b0000 0 0x100>;
+                       interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1";
+                       clocks = <&cpg CPG_MOD 331>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 209>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       status = "disabled";
+                       resets = <&cpg 331>;
+                       #dma-cells = <1>;
+                       dma-channels = <2>;
                };
 
-               msiof3: spi@e6c10000 {
-                       compatible = "renesas,msiof-r8a7796",
-                                    "renesas,rcar-gen3-msiof";
-                       reg = <0 0xe6c10000 0 0x0064>;
-                       interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 208>;
-                       dmas = <&dmac0 0x47>, <&dmac0 0x46>;
-                       dma-names = "tx", "rx";
+               usb3_phy0: usb-phy@e65ee000 {
+                       compatible = "renesas,r8a7796-usb3-phy",
+                                    "renesas,rcar-gen3-usb3-phy";
+                       reg = <0 0xe65ee000 0 0x90>;
+                       clocks = <&cpg CPG_MOD 328>, <&usb3s0_clk>,
+                                <&usb_extal_clk>;
+                       clock-names = "usb3-if", "usb3s_clk", "usb_extal";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 208>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
+                       resets = <&cpg 328>;
+                       #phy-cells = <0>;
                        status = "disabled";
                };
 
@@ -1354,306 +859,803 @@ GIC_SPI 431 IRQ_TYPE_LEVEL_HIGH
                               <&ipmmu_ds1 30>, <&ipmmu_ds1 31>;
                };
 
-               audma0: dma-controller@ec700000 {
-                       compatible = "renesas,dmac-r8a7796",
-                                    "renesas,rcar-dmac";
-                       reg = <0 0xec700000 0 0x10000>;
-                       interrupts = <GIC_SPI 350 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 320 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 321 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 322 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 323 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 324 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 325 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 326 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 327 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 328 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 329 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 330 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 331 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 332 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 333 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 334 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 335 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "error",
-                                       "ch0", "ch1", "ch2", "ch3",
-                                       "ch4", "ch5", "ch6", "ch7",
-                                       "ch8", "ch9", "ch10", "ch11",
-                                       "ch12", "ch13", "ch14", "ch15";
-                       clocks = <&cpg CPG_MOD 502>;
-                       clock-names = "fck";
+               ipmmu_ds0: mmu@e6740000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xe6740000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 0>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 502>;
-                       #dma-cells = <1>;
-                       dma-channels = <16>;
-                       iommus = <&ipmmu_mp 0>, <&ipmmu_mp 1>,
-                              <&ipmmu_mp 2>, <&ipmmu_mp 3>,
-                              <&ipmmu_mp 4>, <&ipmmu_mp 5>,
-                              <&ipmmu_mp 6>, <&ipmmu_mp 7>,
-                              <&ipmmu_mp 8>, <&ipmmu_mp 9>,
-                              <&ipmmu_mp 10>, <&ipmmu_mp 11>,
-                              <&ipmmu_mp 12>, <&ipmmu_mp 13>,
-                              <&ipmmu_mp 14>, <&ipmmu_mp 15>;
+                       #iommu-cells = <1>;
                };
 
-               audma1: dma-controller@ec720000 {
-                       compatible = "renesas,dmac-r8a7796",
-                                    "renesas,rcar-dmac";
-                       reg = <0 0xec720000 0 0x10000>;
-                       interrupts = <GIC_SPI 351 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 336 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 337 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 338 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 339 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 340 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 341 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 342 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 343 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 344 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 345 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 346 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 347 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 348 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 349 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 382 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 383 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "error",
-                                       "ch0", "ch1", "ch2", "ch3",
-                                       "ch4", "ch5", "ch6", "ch7",
-                                       "ch8", "ch9", "ch10", "ch11",
-                                       "ch12", "ch13", "ch14", "ch15";
-                       clocks = <&cpg CPG_MOD 501>;
-                       clock-names = "fck";
+               ipmmu_ds1: mmu@e7740000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xe7740000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 1>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 501>;
-                       #dma-cells = <1>;
-                       dma-channels = <16>;
-                       iommus = <&ipmmu_mp 16>, <&ipmmu_mp 17>,
-                              <&ipmmu_mp 18>, <&ipmmu_mp 19>,
-                              <&ipmmu_mp 20>, <&ipmmu_mp 21>,
-                              <&ipmmu_mp 22>, <&ipmmu_mp 23>,
-                              <&ipmmu_mp 24>, <&ipmmu_mp 25>,
-                              <&ipmmu_mp 26>, <&ipmmu_mp 27>,
-                              <&ipmmu_mp 28>, <&ipmmu_mp 29>,
-                              <&ipmmu_mp 30>, <&ipmmu_mp 31>;
+                       #iommu-cells = <1>;
                };
 
-               usb_dmac0: dma-controller@e65a0000 {
-                       compatible = "renesas,r8a7796-usb-dmac",
-                                    "renesas,usb-dmac";
-                       reg = <0 0xe65a0000 0 0x100>;
-                       interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1";
-                       clocks = <&cpg CPG_MOD 330>;
+               ipmmu_hc: mmu@e6570000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xe6570000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 2>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 330>;
-                       #dma-cells = <1>;
-                       dma-channels = <2>;
+                       #iommu-cells = <1>;
                };
 
-               usb_dmac1: dma-controller@e65b0000 {
-                       compatible = "renesas,r8a7796-usb-dmac",
-                                    "renesas,usb-dmac";
-                       reg = <0 0xe65b0000 0 0x100>;
-                       interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1";
-                       clocks = <&cpg CPG_MOD 331>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 331>;
-                       #dma-cells = <1>;
-                       dma-channels = <2>;
+               ipmmu_ir: mmu@ff8b0000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xff8b0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 3>;
+                       power-domains = <&sysc R8A7796_PD_A3IR>;
+                       #iommu-cells = <1>;
                };
 
-               hsusb: usb@e6590000 {
-                       compatible = "renesas,usbhs-r8a7796",
-                                    "renesas,rcar-gen3-usbhs";
-                       reg = <0 0xe6590000 0 0x100>;
-                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 704>;
-                       dmas = <&usb_dmac0 0>, <&usb_dmac0 1>,
-                              <&usb_dmac1 0>, <&usb_dmac1 1>;
-                       dma-names = "ch0", "ch1", "ch2", "ch3";
-                       renesas,buswait = <11>;
-                       phys = <&usb2_phy0>;
-                       phy-names = "usb";
+               ipmmu_mm: mmu@e67b0000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xe67b0000 0 0x1000>;
+                       interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_mp: mmu@ec670000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xec670000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 4>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_pv0: mmu@fd800000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xfd800000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 5>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_pv1: mmu@fd950000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xfd950000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 6>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_rt: mmu@ffc80000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xffc80000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 7>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vc0: mmu@fe6b0000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xfe6b0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 8>;
+                       power-domains = <&sysc R8A7796_PD_A3VC>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vi0: mmu@febd0000 {
+                       compatible = "renesas,ipmmu-r8a7796";
+                       reg = <0 0xfebd0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 9>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               avb: ethernet@e6800000 {
+                       compatible = "renesas,etheravb-r8a7796",
+                                    "renesas,etheravb-rcar-gen3";
+                       reg = <0 0xe6800000 0 0x800>, <0 0xe6a00000 0 0x10000>;
+                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1", "ch2", "ch3",
+                                         "ch4", "ch5", "ch6", "ch7",
+                                         "ch8", "ch9", "ch10", "ch11",
+                                         "ch12", "ch13", "ch14", "ch15",
+                                         "ch16", "ch17", "ch18", "ch19",
+                                         "ch20", "ch21", "ch22", "ch23",
+                                         "ch24";
+                       clocks = <&cpg CPG_MOD 812>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 812>;
+                       phy-mode = "rgmii";
+                       iommus = <&ipmmu_ds0 16>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               can0: can@e6c30000 {
+                       compatible = "renesas,can-r8a7796",
+                                    "renesas,rcar-gen3-can";
+                       reg = <0 0xe6c30000 0 0x1000>;
+                       interrupts = <GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 916>,
+                              <&cpg CPG_CORE R8A7796_CLK_CANFD>,
+                              <&can_clk>;
+                       clock-names = "clkp1", "clkp2", "can_clk";
+                       assigned-clocks = <&cpg CPG_CORE R8A7796_CLK_CANFD>;
+                       assigned-clock-rates = <40000000>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 916>;
+                       status = "disabled";
+               };
+
+               can1: can@e6c38000 {
+                       compatible = "renesas,can-r8a7796",
+                                    "renesas,rcar-gen3-can";
+                       reg = <0 0xe6c38000 0 0x1000>;
+                       interrupts = <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 915>,
+                              <&cpg CPG_CORE R8A7796_CLK_CANFD>,
+                              <&can_clk>;
+                       clock-names = "clkp1", "clkp2", "can_clk";
+                       assigned-clocks = <&cpg CPG_CORE R8A7796_CLK_CANFD>;
+                       assigned-clock-rates = <40000000>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 915>;
+                       status = "disabled";
+               };
+
+               canfd: can@e66c0000 {
+                       compatible = "renesas,r8a7796-canfd",
+                                    "renesas,rcar-gen3-canfd";
+                       reg = <0 0xe66c0000 0 0x8000>;
+                       interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>,
+                                  <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 914>,
+                              <&cpg CPG_CORE R8A7796_CLK_CANFD>,
+                              <&can_clk>;
+                       clock-names = "fck", "canfd", "can_clk";
+                       assigned-clocks = <&cpg CPG_CORE R8A7796_CLK_CANFD>;
+                       assigned-clock-rates = <40000000>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 914>;
+                       status = "disabled";
+
+                       channel0 {
+                               status = "disabled";
+                       };
+
+                       channel1 {
+                               status = "disabled";
+                       };
+               };
+
+               pwm0: pwm@e6e30000 {
+                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
+                       reg = <0 0xe6e30000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm1: pwm@e6e31000 {
+                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
+                       reg = <0 0xe6e31000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm2: pwm@e6e32000 {
+                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
+                       reg = <0 0xe6e32000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm3: pwm@e6e33000 {
+                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
+                       reg = <0 0xe6e33000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm4: pwm@e6e34000 {
+                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
+                       reg = <0 0xe6e34000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm5: pwm@e6e35000 {
+                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
+                       reg = <0 0xe6e35000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm6: pwm@e6e36000 {
+                       compatible = "renesas,pwm-r8a7796", "renesas,pwm-rcar";
+                       reg = <0 0xe6e36000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               scif0: serial@e6e60000 {
+                       compatible = "renesas,scif-r8a7796",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6e60000 0 64>;
+                       interrupts = <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 207>,
+                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac1 0x51>, <&dmac1 0x50>,
+                              <&dmac2 0x51>, <&dmac2 0x50>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 207>;
+                       status = "disabled";
+               };
+
+               scif1: serial@e6e68000 {
+                       compatible = "renesas,scif-r8a7796",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6e68000 0 64>;
+                       interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 206>,
+                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac1 0x53>, <&dmac1 0x52>,
+                              <&dmac2 0x53>, <&dmac2 0x52>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 206>;
+                       status = "disabled";
+               };
+
+               scif2: serial@e6e88000 {
+                       compatible = "renesas,scif-r8a7796",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6e88000 0 64>;
+                       interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 310>,
+                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 310>;
+                       status = "disabled";
+               };
+
+               scif3: serial@e6c50000 {
+                       compatible = "renesas,scif-r8a7796",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6c50000 0 64>;
+                       interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 204>,
+                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0x57>, <&dmac0 0x56>;
+                       dma-names = "tx", "rx";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 204>;
+                       status = "disabled";
+               };
+
+               scif4: serial@e6c40000 {
+                       compatible = "renesas,scif-r8a7796",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6c40000 0 64>;
+                       interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 203>,
+                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac0 0x59>, <&dmac0 0x58>;
+                       dma-names = "tx", "rx";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 203>;
+                       status = "disabled";
+               };
+
+               scif5: serial@e6f30000 {
+                       compatible = "renesas,scif-r8a7796",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6f30000 0 64>;
+                       interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 202>,
+                                <&cpg CPG_CORE R8A7796_CLK_S3D1>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac1 0x5b>, <&dmac1 0x5a>,
+                              <&dmac2 0x5b>, <&dmac2 0x5a>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 202>;
+                       status = "disabled";
+               };
+
+               msiof0: spi@e6e90000 {
+                       compatible = "renesas,msiof-r8a7796",
+                                    "renesas,rcar-gen3-msiof";
+                       reg = <0 0xe6e90000 0 0x0064>;
+                       interrupts = <GIC_SPI 156 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 211>;
+                       dmas = <&dmac1 0x41>, <&dmac1 0x40>,
+                              <&dmac2 0x41>, <&dmac2 0x40>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 211>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               msiof1: spi@e6ea0000 {
+                       compatible = "renesas,msiof-r8a7796",
+                                    "renesas,rcar-gen3-msiof";
+                       reg = <0 0xe6ea0000 0 0x0064>;
+                       interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 210>;
+                       dmas = <&dmac1 0x43>, <&dmac1 0x42>,
+                              <&dmac2 0x43>, <&dmac2 0x42>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 210>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               msiof2: spi@e6c00000 {
+                       compatible = "renesas,msiof-r8a7796",
+                                    "renesas,rcar-gen3-msiof";
+                       reg = <0 0xe6c00000 0 0x0064>;
+                       interrupts = <GIC_SPI 158 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 209>;
+                       dmas = <&dmac0 0x45>, <&dmac0 0x44>;
+                       dma-names = "tx", "rx";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 209>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               msiof3: spi@e6c10000 {
+                       compatible = "renesas,msiof-r8a7796",
+                                    "renesas,rcar-gen3-msiof";
+                       reg = <0 0xe6c10000 0 0x0064>;
+                       interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 208>;
+                       dmas = <&dmac0 0x47>, <&dmac0 0x46>;
+                       dma-names = "tx", "rx";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 208>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               vin0: video@e6ef0000 {
+                       compatible = "renesas,vin-r8a7796";
+                       reg = <0 0xe6ef0000 0 0x1000>;
+                       interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 811>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 811>;
+                       renesas,id = <0>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin0csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin0>;
+                                       };
+                                       vin0csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin0>;
+                                       };
+                               };
+                       };
+               };
+
+               vin1: video@e6ef1000 {
+                       compatible = "renesas,vin-r8a7796";
+                       reg = <0 0xe6ef1000 0 0x1000>;
+                       interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 810>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 704>;
+                       resets = <&cpg 810>;
+                       renesas,id = <1>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin1csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin1>;
+                                       };
+                                       vin1csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin1>;
+                                       };
+                               };
+                       };
                };
 
-               usb3_phy0: usb-phy@e65ee000 {
-                       compatible = "renesas,r8a7796-usb3-phy",
-                                    "renesas,rcar-gen3-usb3-phy";
-                       reg = <0 0xe65ee000 0 0x90>;
-                       clocks = <&cpg CPG_MOD 328>, <&usb3s0_clk>,
-                                <&usb_extal_clk>;
-                       clock-names = "usb3-if", "usb3s_clk", "usb_extal";
+               vin2: video@e6ef2000 {
+                       compatible = "renesas,vin-r8a7796";
+                       reg = <0 0xe6ef2000 0 0x1000>;
+                       interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 809>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 328>;
-                       #phy-cells = <0>;
+                       resets = <&cpg 809>;
+                       renesas,id = <2>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin2csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin2>;
+                                       };
+                                       vin2csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin2>;
+                                       };
+                               };
+                       };
                };
 
-               xhci0: usb@ee000000 {
-                       compatible = "renesas,xhci-r8a7796",
-                                    "renesas,rcar-gen3-xhci";
-                       reg = <0 0xee000000 0 0xc00>;
-                       interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 328>;
+               vin3: video@e6ef3000 {
+                       compatible = "renesas,vin-r8a7796";
+                       reg = <0 0xe6ef3000 0 0x1000>;
+                       interrupts = <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 808>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 328>;
+                       resets = <&cpg 808>;
+                       renesas,id = <3>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin3csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin3>;
+                                       };
+                                       vin3csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin3>;
+                                       };
+                               };
+                       };
                };
 
-               usb3_peri0: usb@ee020000 {
-                       compatible = "renesas,r8a7796-usb3-peri",
-                                    "renesas,rcar-gen3-usb3-peri";
-                       reg = <0 0xee020000 0 0x400>;
-                       interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 328>;
+               vin4: video@e6ef4000 {
+                       compatible = "renesas,vin-r8a7796";
+                       reg = <0 0xe6ef4000 0 0x1000>;
+                       interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 807>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 328>;
+                       resets = <&cpg 807>;
+                       renesas,id = <4>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin4csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin4>;
+                                       };
+                                       vin4csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin4>;
+                                       };
+                               };
+                       };
                };
 
-               ohci0: usb@ee080000 {
-                       compatible = "generic-ohci";
-                       reg = <0 0xee080000 0 0x100>;
-                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 703>;
-                       phys = <&usb2_phy0>;
-                       phy-names = "usb";
+               vin5: video@e6ef5000 {
+                       compatible = "renesas,vin-r8a7796";
+                       reg = <0 0xe6ef5000 0 0x1000>;
+                       interrupts = <GIC_SPI 175 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 806>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 703>;
+                       resets = <&cpg 806>;
+                       renesas,id = <5>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin5csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin5>;
+                                       };
+                                       vin5csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin5>;
+                                       };
+                               };
+                       };
                };
 
-               ehci0: usb@ee080100 {
-                       compatible = "generic-ehci";
-                       reg = <0 0xee080100 0 0x100>;
-                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 703>;
-                       phys = <&usb2_phy0>;
-                       phy-names = "usb";
-                       companion= <&ohci0>;
+               vin6: video@e6ef6000 {
+                       compatible = "renesas,vin-r8a7796";
+                       reg = <0 0xe6ef6000 0 0x1000>;
+                       interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 805>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 703>;
+                       resets = <&cpg 805>;
+                       renesas,id = <6>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin6csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin6>;
+                                       };
+                                       vin6csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin6>;
+                                       };
+                               };
+                       };
+               };
+
+               vin7: video@e6ef7000 {
+                       compatible = "renesas,vin-r8a7796";
+                       reg = <0 0xe6ef7000 0 0x1000>;
+                       interrupts = <GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 804>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 804>;
+                       renesas,id = <7>;
                        status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin7csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin7>;
+                                       };
+                                       vin7csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin7>;
+                                       };
+                               };
+                       };
                };
 
-               usb2_phy0: usb-phy@ee080200 {
-                       compatible = "renesas,usb2-phy-r8a7796",
-                                    "renesas,rcar-gen3-usb2-phy";
-                       reg = <0 0xee080200 0 0x700>;
-                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 703>;
+               drif00: rif@e6f40000 {
+                       compatible = "renesas,r8a7796-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f40000 0 0x64>;
+                       interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 515>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x20>, <&dmac2 0x20>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 703>;
-                       #phy-cells = <0>;
+                       resets = <&cpg 515>;
+                       renesas,bonding = <&drif01>;
                        status = "disabled";
                };
 
-               ohci1: usb@ee0a0000 {
-                       compatible = "generic-ohci";
-                       reg = <0 0xee0a0000 0 0x100>;
-                       interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 702>;
-                       phys = <&usb2_phy1>;
-                       phy-names = "usb";
+               drif01: rif@e6f50000 {
+                       compatible = "renesas,r8a7796-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f50000 0 0x64>;
+                       interrupts = <GIC_SPI 13 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 514>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x22>, <&dmac2 0x22>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 702>;
+                       resets = <&cpg 514>;
+                       renesas,bonding = <&drif00>;
                        status = "disabled";
                };
 
-               ehci1: usb@ee0a0100 {
-                       compatible = "generic-ehci";
-                       reg = <0 0xee0a0100 0 0x100>;
-                       interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 702>;
-                       phys = <&usb2_phy1>;
-                       phy-names = "usb";
-                       companion= <&ohci1>;
+               drif10: rif@e6f60000 {
+                       compatible = "renesas,r8a7796-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f60000 0 0x64>;
+                       interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 513>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x24>, <&dmac2 0x24>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 702>;
+                       resets = <&cpg 513>;
+                       renesas,bonding = <&drif11>;
                        status = "disabled";
                };
 
-               usb2_phy1: usb-phy@ee0a0200 {
-                       compatible = "renesas,usb2-phy-r8a7796",
-                                    "renesas,rcar-gen3-usb2-phy";
-                       reg = <0 0xee0a0200 0 0x700>;
-                       clocks = <&cpg CPG_MOD 702>;
+               drif11: rif@e6f70000 {
+                       compatible = "renesas,r8a7796-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f70000 0 0x64>;
+                       interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 512>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x26>, <&dmac2 0x26>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 702>;
-                       #phy-cells = <0>;
+                       resets = <&cpg 512>;
+                       renesas,bonding = <&drif10>;
                        status = "disabled";
                };
 
-               sdhi0: sd@ee100000 {
-                       compatible = "renesas,sdhi-r8a7796",
-                                    "renesas,rcar-gen3-sdhi";
-                       reg = <0 0xee100000 0 0x2000>;
-                       interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 314>;
-                       max-frequency = <200000000>;
+               drif20: rif@e6f80000 {
+                       compatible = "renesas,r8a7796-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f80000 0 0x64>;
+                       interrupts = <GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 511>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x28>, <&dmac2 0x28>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 314>;
+                       resets = <&cpg 511>;
+                       renesas,bonding = <&drif21>;
                        status = "disabled";
                };
 
-               sdhi1: sd@ee120000 {
-                       compatible = "renesas,sdhi-r8a7796",
-                                    "renesas,rcar-gen3-sdhi";
-                       reg = <0 0xee120000 0 0x2000>;
-                       interrupts = <GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 313>;
-                       max-frequency = <200000000>;
+               drif21: rif@e6f90000 {
+                       compatible = "renesas,r8a7796-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6f90000 0 0x64>;
+                       interrupts = <GIC_SPI 25 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 510>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x2a>, <&dmac2 0x2a>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 313>;
+                       resets = <&cpg 510>;
+                       renesas,bonding = <&drif20>;
                        status = "disabled";
                };
 
-               sdhi2: sd@ee140000 {
-                       compatible = "renesas,sdhi-r8a7796",
-                                    "renesas,rcar-gen3-sdhi";
-                       reg = <0 0xee140000 0 0x2000>;
-                       interrupts = <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 312>;
-                       max-frequency = <200000000>;
+               drif30: rif@e6fa0000 {
+                       compatible = "renesas,r8a7796-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6fa0000 0 0x64>;
+                       interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 509>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x2c>, <&dmac2 0x2c>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 312>;
+                       resets = <&cpg 509>;
+                       renesas,bonding = <&drif31>;
                        status = "disabled";
                };
 
-               sdhi3: sd@ee160000 {
-                       compatible = "renesas,sdhi-r8a7796",
-                                    "renesas,rcar-gen3-sdhi";
-                       reg = <0 0xee160000 0 0x2000>;
-                       interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 311>;
-                       max-frequency = <200000000>;
+               drif31: rif@e6fb0000 {
+                       compatible = "renesas,r8a7796-drif",
+                                    "renesas,rcar-gen3-drif";
+                       reg = <0 0xe6fb0000 0 0x64>;
+                       interrupts = <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 508>;
+                       clock-names = "fck";
+                       dmas = <&dmac1 0x2e>, <&dmac2 0x2e>;
+                       dma-names = "rx", "rx";
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 311>;
+                       resets = <&cpg 508>;
+                       renesas,bonding = <&drif30>;
                        status = "disabled";
                };
 
-               tsc: thermal@e6198000 {
-                       compatible = "renesas,r8a7796-thermal";
-                       reg = <0 0xe6198000 0 0x100>,
-                             <0 0xe61a0000 0 0x100>,
-                             <0 0xe61a8000 0 0x100>;
-                       interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 522>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 522>;
-                       #thermal-sensor-cells = <1>;
-                       status = "okay";
-               };
-
                rcar_sound: sound@ec500000 {
                        /*
                         * #sound-dai-cells is required
@@ -1848,6 +1850,261 @@ ssi9: ssi-9 {
                                        dma-names = "rx", "tx", "rxu", "txu";
                                };
                        };
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               port@0 {
+                                       reg = <0>;
+                               };
+                               port@1 {
+                                       reg = <1>;
+                               };
+                       };
+               };
+
+               audma0: dma-controller@ec700000 {
+                       compatible = "renesas,dmac-r8a7796",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xec700000 0 0x10000>;
+                       interrupts = <GIC_SPI 350 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 320 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 321 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 322 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 323 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 324 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 325 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 326 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 327 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 328 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 329 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 330 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 331 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 332 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 333 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 334 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 335 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                       "ch0", "ch1", "ch2", "ch3",
+                                       "ch4", "ch5", "ch6", "ch7",
+                                       "ch8", "ch9", "ch10", "ch11",
+                                       "ch12", "ch13", "ch14", "ch15";
+                       clocks = <&cpg CPG_MOD 502>;
+                       clock-names = "fck";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 502>;
+                       #dma-cells = <1>;
+                       dma-channels = <16>;
+                       iommus = <&ipmmu_mp 0>, <&ipmmu_mp 1>,
+                              <&ipmmu_mp 2>, <&ipmmu_mp 3>,
+                              <&ipmmu_mp 4>, <&ipmmu_mp 5>,
+                              <&ipmmu_mp 6>, <&ipmmu_mp 7>,
+                              <&ipmmu_mp 8>, <&ipmmu_mp 9>,
+                              <&ipmmu_mp 10>, <&ipmmu_mp 11>,
+                              <&ipmmu_mp 12>, <&ipmmu_mp 13>,
+                              <&ipmmu_mp 14>, <&ipmmu_mp 15>;
+               };
+
+               audma1: dma-controller@ec720000 {
+                       compatible = "renesas,dmac-r8a7796",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xec720000 0 0x10000>;
+                       interrupts = <GIC_SPI 351 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 336 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 337 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 338 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 339 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 340 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 341 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 342 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 343 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 344 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 345 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 346 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 347 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 348 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 349 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 382 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 383 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                       "ch0", "ch1", "ch2", "ch3",
+                                       "ch4", "ch5", "ch6", "ch7",
+                                       "ch8", "ch9", "ch10", "ch11",
+                                       "ch12", "ch13", "ch14", "ch15";
+                       clocks = <&cpg CPG_MOD 501>;
+                       clock-names = "fck";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 501>;
+                       #dma-cells = <1>;
+                       dma-channels = <16>;
+                       iommus = <&ipmmu_mp 16>, <&ipmmu_mp 17>,
+                              <&ipmmu_mp 18>, <&ipmmu_mp 19>,
+                              <&ipmmu_mp 20>, <&ipmmu_mp 21>,
+                              <&ipmmu_mp 22>, <&ipmmu_mp 23>,
+                              <&ipmmu_mp 24>, <&ipmmu_mp 25>,
+                              <&ipmmu_mp 26>, <&ipmmu_mp 27>,
+                              <&ipmmu_mp 28>, <&ipmmu_mp 29>,
+                              <&ipmmu_mp 30>, <&ipmmu_mp 31>;
+               };
+
+               xhci0: usb@ee000000 {
+                       compatible = "renesas,xhci-r8a7796",
+                                    "renesas,rcar-gen3-xhci";
+                       reg = <0 0xee000000 0 0xc00>;
+                       interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 328>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 328>;
+                       status = "disabled";
+               };
+
+               usb3_peri0: usb@ee020000 {
+                       compatible = "renesas,r8a7796-usb3-peri",
+                                    "renesas,rcar-gen3-usb3-peri";
+                       reg = <0 0xee020000 0 0x400>;
+                       interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 328>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 328>;
+                       status = "disabled";
+               };
+
+               ohci0: usb@ee080000 {
+                       compatible = "generic-ohci";
+                       reg = <0 0xee080000 0 0x100>;
+                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 703>;
+                       phys = <&usb2_phy0>;
+                       phy-names = "usb";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 703>;
+                       status = "disabled";
+               };
+
+               ohci1: usb@ee0a0000 {
+                       compatible = "generic-ohci";
+                       reg = <0 0xee0a0000 0 0x100>;
+                       interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 702>;
+                       phys = <&usb2_phy1>;
+                       phy-names = "usb";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 702>;
+                       status = "disabled";
+               };
+
+               ehci0: usb@ee080100 {
+                       compatible = "generic-ehci";
+                       reg = <0 0xee080100 0 0x100>;
+                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 703>;
+                       phys = <&usb2_phy0>;
+                       phy-names = "usb";
+                       companion= <&ohci0>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 703>;
+                       status = "disabled";
+               };
+
+               ehci1: usb@ee0a0100 {
+                       compatible = "generic-ehci";
+                       reg = <0 0xee0a0100 0 0x100>;
+                       interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 702>;
+                       phys = <&usb2_phy1>;
+                       phy-names = "usb";
+                       companion= <&ohci1>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 702>;
+                       status = "disabled";
+               };
+
+               usb2_phy0: usb-phy@ee080200 {
+                       compatible = "renesas,usb2-phy-r8a7796",
+                                    "renesas,rcar-gen3-usb2-phy";
+                       reg = <0 0xee080200 0 0x700>;
+                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 703>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 703>;
+                       #phy-cells = <0>;
+                       status = "disabled";
+               };
+
+               usb2_phy1: usb-phy@ee0a0200 {
+                       compatible = "renesas,usb2-phy-r8a7796",
+                                    "renesas,rcar-gen3-usb2-phy";
+                       reg = <0 0xee0a0200 0 0x700>;
+                       clocks = <&cpg CPG_MOD 702>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 702>;
+                       #phy-cells = <0>;
+                       status = "disabled";
+               };
+
+               sdhi0: sd@ee100000 {
+                       compatible = "renesas,sdhi-r8a7796",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee100000 0 0x2000>;
+                       interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 314>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 314>;
+                       status = "disabled";
+               };
+
+               sdhi1: sd@ee120000 {
+                       compatible = "renesas,sdhi-r8a7796",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee120000 0 0x2000>;
+                       interrupts = <GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 313>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 313>;
+                       status = "disabled";
+               };
+
+               sdhi2: sd@ee140000 {
+                       compatible = "renesas,sdhi-r8a7796",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee140000 0 0x2000>;
+                       interrupts = <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 312>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 312>;
+                       status = "disabled";
+               };
+
+               sdhi3: sd@ee160000 {
+                       compatible = "renesas,sdhi-r8a7796",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee160000 0 0x2000>;
+                       interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 311>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 311>;
+                       status = "disabled";
+               };
+
+               gic: interrupt-controller@f1010000 {
+                       compatible = "arm,gic-400";
+                       #interrupt-cells = <3>;
+                       #address-cells = <0>;
+                       interrupt-controller;
+                       reg = <0x0 0xf1010000 0 0x1000>,
+                             <0x0 0xf1020000 0 0x20000>,
+                             <0x0 0xf1040000 0 0x20000>,
+                             <0x0 0xf1060000 0 0x20000>;
+                       interrupts = <GIC_PPI 9
+                                       (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_HIGH)>;
+                       clocks = <&cpg CPG_MOD 408>;
+                       clock-names = "clk";
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 408>;
                };
 
                pciec0: pcie@fe000000 {
@@ -1860,6 +2117,26 @@ pciec1: pcie@ee800000 {
                        /* placeholder */
                };
 
+               imr-lx4@fe860000 {
+                       compatible = "renesas,r8a7796-imr-lx4",
+                                    "renesas,imr-lx4";
+                       reg = <0 0xfe860000 0 0x2000>;
+                       interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 823>;
+                       power-domains = <&sysc R8A7796_PD_A3VC>;
+                       resets = <&cpg 823>;
+               };
+
+               imr-lx4@fe870000 {
+                       compatible = "renesas,r8a7796-imr-lx4",
+                                    "renesas,imr-lx4";
+                       reg = <0 0xfe870000 0 0x2000>;
+                       interrupts = <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 822>;
+                       power-domains = <&sysc R8A7796_PD_A3VC>;
+                       resets = <&cpg 822>;
+               };
+
                fdp1@fe940000 {
                        compatible = "renesas,fdp1";
                        reg = <0 0xfe940000 0 0x2400>;
@@ -1878,17 +2155,6 @@ fcpf0: fcp@fe950000 {
                        resets = <&cpg 615>;
                };
 
-               vspb: vsp@fe960000 {
-                       compatible = "renesas,vsp2";
-                       reg = <0 0xfe960000 0 0x8000>;
-                       interrupts = <GIC_SPI 266 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 626>;
-                       power-domains = <&sysc R8A7796_PD_A3VC>;
-                       resets = <&cpg 626>;
-
-                       renesas,fcp = <&fcpvb0>;
-               };
-
                fcpvb0: fcp@fe96f000 {
                        compatible = "renesas,fcpv";
                        reg = <0 0xfe96f000 0 0x200>;
@@ -1897,17 +2163,6 @@ fcpvb0: fcp@fe96f000 {
                        resets = <&cpg 607>;
                };
 
-               vspi0: vsp@fe9a0000 {
-                       compatible = "renesas,vsp2";
-                       reg = <0 0xfe9a0000 0 0x8000>;
-                       interrupts = <GIC_SPI 444 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 631>;
-                       power-domains = <&sysc R8A7796_PD_A3VC>;
-                       resets = <&cpg 631>;
-
-                       renesas,fcp = <&fcpvi0>;
-               };
-
                fcpvi0: fcp@fe9af000 {
                        compatible = "renesas,fcpv";
                        reg = <0 0xfe9af000 0 0x200>;
@@ -1917,6 +2172,44 @@ fcpvi0: fcp@fe9af000 {
                        iommus = <&ipmmu_vc0 19>;
                };
 
+               fcpvd0: fcp@fea27000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea27000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 603>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 603>;
+                       iommus = <&ipmmu_vi0 8>;
+               };
+
+               fcpvd1: fcp@fea2f000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea2f000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 602>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 602>;
+                       iommus = <&ipmmu_vi0 9>;
+               };
+
+               fcpvd2: fcp@fea37000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea37000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 601>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 601>;
+                       iommus = <&ipmmu_vi0 10>;
+               };
+
+               vspb: vsp@fe960000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfe960000 0 0x8000>;
+                       interrupts = <GIC_SPI 266 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 626>;
+                       power-domains = <&sysc R8A7796_PD_A3VC>;
+                       resets = <&cpg 626>;
+
+                       renesas,fcp = <&fcpvb0>;
+               };
+
                vspd0: vsp@fea20000 {
                        compatible = "renesas,vsp2";
                        reg = <0 0xfea20000 0 0x8000>;
@@ -1928,15 +2221,6 @@ vspd0: vsp@fea20000 {
                        renesas,fcp = <&fcpvd0>;
                };
 
-               fcpvd0: fcp@fea27000 {
-                       compatible = "renesas,fcpv";
-                       reg = <0 0xfea27000 0 0x200>;
-                       clocks = <&cpg CPG_MOD 603>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 603>;
-                       iommus = <&ipmmu_vi0 8>;
-               };
-
                vspd1: vsp@fea28000 {
                        compatible = "renesas,vsp2";
                        reg = <0 0xfea28000 0 0x8000>;
@@ -1948,15 +2232,6 @@ vspd1: vsp@fea28000 {
                        renesas,fcp = <&fcpvd1>;
                };
 
-               fcpvd1: fcp@fea2f000 {
-                       compatible = "renesas,fcpv";
-                       reg = <0 0xfea2f000 0 0x200>;
-                       clocks = <&cpg CPG_MOD 602>;
-                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 602>;
-                       iommus = <&ipmmu_vi0 9>;
-               };
-
                vspd2: vsp@fea30000 {
                        compatible = "renesas,vsp2";
                        reg = <0 0xfea30000 0 0x8000>;
@@ -1968,13 +2243,126 @@ vspd2: vsp@fea30000 {
                        renesas,fcp = <&fcpvd2>;
                };
 
-               fcpvd2: fcp@fea37000 {
-                       compatible = "renesas,fcpv";
-                       reg = <0 0xfea37000 0 0x200>;
-                       clocks = <&cpg CPG_MOD 601>;
+               vspi0: vsp@fe9a0000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfe9a0000 0 0x8000>;
+                       interrupts = <GIC_SPI 444 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 631>;
+                       power-domains = <&sysc R8A7796_PD_A3VC>;
+                       resets = <&cpg 631>;
+
+                       renesas,fcp = <&fcpvi0>;
+               };
+
+               csi20: csi2@fea80000 {
+                       compatible = "renesas,r8a7796-csi2";
+                       reg = <0 0xfea80000 0 0x10000>;
+                       interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 714>;
                        power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
-                       resets = <&cpg 601>;
-                       iommus = <&ipmmu_vi0 10>;
+                       resets = <&cpg 714>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       csi20vin0: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint = <&vin0csi20>;
+                                       };
+                                       csi20vin1: endpoint@1 {
+                                               reg = <1>;
+                                               remote-endpoint = <&vin1csi20>;
+                                       };
+                                       csi20vin2: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint = <&vin2csi20>;
+                                       };
+                                       csi20vin3: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint = <&vin3csi20>;
+                                       };
+                                       csi20vin4: endpoint@4 {
+                                               reg = <4>;
+                                               remote-endpoint = <&vin4csi20>;
+                                       };
+                                       csi20vin5: endpoint@5 {
+                                               reg = <5>;
+                                               remote-endpoint = <&vin5csi20>;
+                                       };
+                                       csi20vin6: endpoint@6 {
+                                               reg = <6>;
+                                               remote-endpoint = <&vin6csi20>;
+                                       };
+                                       csi20vin7: endpoint@7 {
+                                               reg = <7>;
+                                               remote-endpoint = <&vin7csi20>;
+                                       };
+                               };
+                       };
+               };
+
+               csi40: csi2@feaa0000 {
+                       compatible = "renesas,r8a7796-csi2";
+                       reg = <0 0xfeaa0000 0 0x10000>;
+                       interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 716>;
+                       power-domains = <&sysc R8A7796_PD_ALWAYS_ON>;
+                       resets = <&cpg 716>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       csi40vin0: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint = <&vin0csi40>;
+                                       };
+                                       csi40vin1: endpoint@1 {
+                                               reg = <1>;
+                                               remote-endpoint = <&vin1csi40>;
+                                       };
+                                       csi40vin2: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint = <&vin2csi40>;
+                                       };
+                                       csi40vin3: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint = <&vin3csi40>;
+                                       };
+                                       csi40vin4: endpoint@4 {
+                                               reg = <4>;
+                                               remote-endpoint = <&vin4csi40>;
+                                       };
+                                       csi40vin5: endpoint@5 {
+                                               reg = <5>;
+                                               remote-endpoint = <&vin5csi40>;
+                                       };
+                                       csi40vin6: endpoint@6 {
+                                               reg = <6>;
+                                               remote-endpoint = <&vin6csi40>;
+                                       };
+                                       csi40vin7: endpoint@7 {
+                                               reg = <7>;
+                                               remote-endpoint = <&vin7csi40>;
+                                       };
+                               };
+
+                       };
                };
 
                hdmi0: hdmi@fead0000 {
@@ -1999,6 +2387,10 @@ dw_hdmi0_in: endpoint {
                                port@1 {
                                        reg = <1>;
                                };
+                               port@2 {
+                                       /* HDMI sound */
+                                       reg = <2>;
+                               };
                        };
                };
 
@@ -2042,35 +2434,12 @@ du_out_lvds0: endpoint {
                        };
                };
 
-               imr-lx4@fe860000 {
-                       compatible = "renesas,r8a7796-imr-lx4",
-                                    "renesas,imr-lx4";
-                       reg = <0 0xfe860000 0 0x2000>;
-                       interrupts = <GIC_SPI 192 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 823>;
-                       power-domains = <&sysc R8A7796_PD_A3VC>;
-                       resets = <&cpg 823>;
-               };
-
-               imr-lx4@fe870000 {
-                       compatible = "renesas,r8a7796-imr-lx4",
-                                    "renesas,imr-lx4";
-                       reg = <0 0xfe870000 0 0x2000>;
-                       interrupts = <GIC_SPI 193 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 822>;
-                       power-domains = <&sysc R8A7796_PD_A3VC>;
-                       resets = <&cpg 822>;
+               prr: chipid@fff00044 {
+                       compatible = "renesas,prr";
+                       reg = <0 0xfff00044 0 4>;
                };
        };
 
-       timer {
-               compatible = "arm,armv8-timer";
-               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>;
-       };
-
        thermal-zones {
                sensor_thermal1: sensor-thermal1 {
                        polling-delay-passive = <250>;
@@ -2080,12 +2449,12 @@ sensor_thermal1: sensor-thermal1 {
                        trips {
                                sensor1_passive: sensor1-passive {
                                        temperature = <95000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "passive";
                                };
                                sensor1_crit: sensor1-crit {
                                        temperature = <120000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "critical";
                                };
                        };
@@ -2106,12 +2475,12 @@ sensor_thermal2: sensor-thermal2 {
                        trips {
                                sensor2_passive: sensor2-passive {
                                        temperature = <95000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "passive";
                                };
                                sensor2_crit: sensor2-crit {
                                        temperature = <120000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "critical";
                                };
                        };
@@ -2132,12 +2501,12 @@ sensor_thermal3: sensor-thermal3 {
                        trips {
                                sensor3_passive: sensor3-passive {
                                        temperature = <95000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "passive";
                                };
                                sensor3_crit: sensor3-crit {
                                        temperature = <120000>;
-                                       hysteresis = <2000>;
+                                       hysteresis = <1000>;
                                        type = "critical";
                                };
                        };
@@ -2151,6 +2520,14 @@ map0 {
                };
        };
 
+       timer {
+               compatible = "arm,armv8-timer";
+               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(6) | IRQ_TYPE_LEVEL_LOW)>;
+       };
+
        /* External USB clocks - can be overridden by the board */
        usb3s0_clk: usb3s0 {
                compatible = "fixed-clock";
index 75d890d91df932f6e45fe8f8923491727808ccfa..340a3c72b65aad6c11638768b931718ad19c02c9 100644 (file)
@@ -19,3 +19,31 @@ memory@48000000 {
                reg = <0x0 0x48000000 0x0 0x78000000>;
        };
 };
+
+&du {
+       clocks = <&cpg CPG_MOD 724>,
+                <&cpg CPG_MOD 723>,
+                <&cpg CPG_MOD 721>,
+                <&versaclock5 1>,
+                <&x21_clk>,
+                <&versaclock5 2>;
+       clock-names = "du.0", "du.1", "du.3",
+                     "dclkin.0", "dclkin.1", "dclkin.3";
+};
+
+&hdmi0 {
+       status = "okay";
+
+       ports {
+               port@1 {
+                       reg = <1>;
+                       rcar_dw_hdmi0_out: endpoint {
+                               remote-endpoint = <&hdmi0_con>;
+                       };
+               };
+       };
+};
+
+&hdmi0_con {
+       remote-endpoint = <&rcar_dw_hdmi0_out>;
+};
index a83a00deed9efc421f4582eef00aca1799386a8d..9de4e3db1621bd26d566f7a18696e4b77599b240 100644 (file)
@@ -19,3 +19,31 @@ memory@48000000 {
                reg = <0x0 0x48000000 0x0 0x78000000>;
        };
 };
+
+&du {
+       clocks = <&cpg CPG_MOD 724>,
+                <&cpg CPG_MOD 723>,
+                <&cpg CPG_MOD 721>,
+                <&versaclock6 1>,
+                <&x21_clk>,
+                <&versaclock6 2>;
+       clock-names = "du.0", "du.1", "du.3",
+                     "dclkin.0", "dclkin.1", "dclkin.3";
+};
+
+&hdmi0 {
+       status = "okay";
+
+       ports {
+               port@1 {
+                       reg = <1>;
+                       rcar_dw_hdmi0_out: endpoint {
+                               remote-endpoint = <&hdmi0_con>;
+                       };
+               };
+       };
+};
+
+&hdmi0_con {
+       remote-endpoint = <&rcar_dw_hdmi0_out>;
+};
index f0871fcdd98450c2e2fddbc77f00b5b604bf4762..486aecacb22abcf237e4739b988c7a31f6257d62 100644 (file)
@@ -8,8 +8,9 @@
  * Copyright (C) 2016 Renesas Electronics Corp.
  */
 
-#include <dt-bindings/clock/renesas-cpg-mssr.h>
+#include <dt-bindings/clock/r8a77965-cpg-mssr.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/power/r8a77965-sysc.h>
 
 #define CPG_AUDIO_CLK_I                10
 
@@ -19,12 +20,44 @@ / {
        #size-cells = <2>;
 
        aliases {
+               i2c0 = &i2c0;
+               i2c1 = &i2c1;
+               i2c2 = &i2c2;
+               i2c3 = &i2c3;
+               i2c4 = &i2c4;
+               i2c5 = &i2c5;
+               i2c6 = &i2c6;
                i2c7 = &i2c_dvfs;
        };
 
-       psci {
-               compatible = "arm,psci-1.0", "arm,psci-0.2";
-               method = "smc";
+       /*
+        * The external audio clocks are configured as 0 Hz fixed frequency
+        * clocks by default.
+        * Boards that provide audio clocks should override them.
+        */
+       audio_clk_a: audio_clk_a {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
+
+       audio_clk_b: audio_clk_b {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
+
+       audio_clk_c: audio_clk_c {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
+
+       /* External CAN clock - to be overridden by boards that provide it */
+       can_clk: can {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
        };
 
        cpus {
@@ -35,23 +68,23 @@ a57_0: cpu@0 {
                        compatible = "arm,cortex-a57", "arm,armv8";
                        reg = <0x0>;
                        device_type = "cpu";
-                       power-domains = <&sysc 0>;
+                       power-domains = <&sysc R8A77965_PD_CA57_CPU0>;
                        next-level-cache = <&L2_CA57>;
                        enable-method = "psci";
                };
 
                a57_1: cpu@1 {
-                       compatible = "arm,cortex-a57","arm,armv8";
+                       compatible = "arm,cortex-a57", "arm,armv8";
                        reg = <0x1>;
                        device_type = "cpu";
-                       power-domains = <&sysc 1>;
+                       power-domains = <&sysc R8A77965_PD_CA57_CPU1>;
                        next-level-cache = <&L2_CA57>;
                        enable-method = "psci";
                };
 
                L2_CA57: cache-controller-0 {
                        compatible = "cache";
-                       power-domains = <&sysc 12>;
+                       power-domains = <&sysc R8A77965_PD_CA57_SCU>;
                        cache-unified;
                        cache-level = <2>;
                };
@@ -71,34 +104,24 @@ extalr_clk: extalr {
                clock-frequency = <0>;
        };
 
-       /*
-        * The external audio clocks are configured as 0 Hz fixed frequency
-        * clocks by default.
-        * Boards that provide audio clocks should override them.
-        */
-       audio_clk_a: audio_clk_a {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
-       };
-
-       audio_clk_b: audio_clk_b {
+       /* External PCIe clock - can be overridden by the board */
+       pcie_bus_clk: pcie_bus {
                compatible = "fixed-clock";
                #clock-cells = <0>;
                clock-frequency = <0>;
        };
 
-       audio_clk_c: audio_clk_c {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
+       pmu_a57 {
+               compatible = "arm,cortex-a57-pmu";
+               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&a57_0>,
+                                    <&a57_1>;
        };
 
-       /* External CAN clock - to be overridden by boards that provide it */
-       can_clk: can {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
+       psci {
+               compatible = "arm,psci-1.0", "arm,psci-0.2";
+               method = "smc";
        };
 
        /* External SCIF clock - to be overridden by boards that provide it */
@@ -108,42 +131,6 @@ scif_clk: scif {
                clock-frequency = <0>;
        };
 
-       /* External PCIe clock - can be overridden by the board */
-       pcie_bus_clk: pcie_bus {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
-       };
-
-       /* External USB clocks - can be overridden by the board */
-       usb3s0_clk: usb3s0 {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
-       };
-
-       usb_extal_clk: usb_extal {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
-       };
-
-       timer {
-               compatible = "arm,armv8-timer";
-               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
-       };
-
-       pmu_a57 {
-               compatible = "arm,cortex-a57-pmu";
-               interrupts-extended = <&gic GIC_SPI 72 IRQ_TYPE_LEVEL_HIGH>,
-                                     <&gic GIC_SPI 73 IRQ_TYPE_LEVEL_HIGH>;
-               interrupt-affinity = <&a57_0>,
-                                    <&a57_1>;
-       };
-
        soc {
                compatible = "simple-bus";
                interrupt-parent = <&gic>;
@@ -151,52 +138,9 @@ soc {
                #size-cells = <2>;
                ranges;
 
-               gic: interrupt-controller@f1010000 {
-                       compatible = "arm,gic-400";
-                       #interrupt-cells = <3>;
-                       #address-cells = <0>;
-                       interrupt-controller;
-                       reg = <0x0 0xf1010000 0 0x1000>,
-                             <0x0 0xf1020000 0 0x20000>,
-                             <0x0 0xf1040000 0 0x20000>,
-                             <0x0 0xf1060000 0 0x20000>;
-                       interrupts = <GIC_PPI 9
-                                       (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_HIGH)>;
-                       clocks = <&cpg CPG_MOD 408>;
-                       clock-names = "clk";
-                       power-domains = <&sysc 32>;
-                       resets = <&cpg 408>;
-               };
-
-               pfc: pin-controller@e6060000 {
-                       compatible = "renesas,pfc-r8a77965";
-                       reg = <0 0xe6060000 0 0x50c>;
-               };
-
-               cpg: clock-controller@e6150000 {
-                       compatible = "renesas,r8a77965-cpg-mssr";
-                       reg = <0 0xe6150000 0 0x1000>;
-                       clocks = <&extal_clk>, <&extalr_clk>;
-                       clock-names = "extal", "extalr";
-                       #clock-cells = <2>;
-                       #power-domain-cells = <0>;
-                       #reset-cells = <1>;
-               };
-
-               rst: reset-controller@e6160000 {
-                       compatible = "renesas,r8a77965-rst";
-                       reg = <0 0xe6160000 0 0x0200>;
-               };
-
-               prr: chipid@fff00044 {
-                       compatible = "renesas,prr";
-                       reg = <0 0xfff00044 0 4>;
-               };
-
-               sysc: system-controller@e6180000 {
-                       compatible = "renesas,r8a77965-sysc";
-                       reg = <0 0xe6180000 0 0x0400>;
-                       #power-domain-cells = <1>;
+               wdt0: watchdog@e6020000 {
+                       reg = <0 0xe6020000 0 0x0c>;
+                       /* placeholder */
                };
 
                gpio0: gpio@e6050000 {
@@ -210,7 +154,7 @@ gpio0: gpio@e6050000 {
                        #interrupt-cells = <2>;
                        interrupt-controller;
                        clocks = <&cpg CPG_MOD 912>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 912>;
                };
 
@@ -225,7 +169,7 @@ gpio1: gpio@e6051000 {
                        #interrupt-cells = <2>;
                        interrupt-controller;
                        clocks = <&cpg CPG_MOD 911>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 911>;
                };
 
@@ -240,7 +184,7 @@ gpio2: gpio@e6052000 {
                        #interrupt-cells = <2>;
                        interrupt-controller;
                        clocks = <&cpg CPG_MOD 910>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 910>;
                };
 
@@ -255,7 +199,7 @@ gpio3: gpio@e6053000 {
                        #interrupt-cells = <2>;
                        interrupt-controller;
                        clocks = <&cpg CPG_MOD 909>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 909>;
                };
 
@@ -270,7 +214,7 @@ gpio4: gpio@e6054000 {
                        #interrupt-cells = <2>;
                        interrupt-controller;
                        clocks = <&cpg CPG_MOD 908>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 908>;
                };
 
@@ -285,7 +229,7 @@ gpio5: gpio@e6055000 {
                        #interrupt-cells = <2>;
                        interrupt-controller;
                        clocks = <&cpg CPG_MOD 907>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 907>;
                };
 
@@ -300,7 +244,7 @@ gpio6: gpio@e6055400 {
                        #interrupt-cells = <2>;
                        interrupt-controller;
                        clocks = <&cpg CPG_MOD 906>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 906>;
                };
 
@@ -315,10 +259,51 @@ gpio7: gpio@e6055800 {
                        #interrupt-cells = <2>;
                        interrupt-controller;
                        clocks = <&cpg CPG_MOD 905>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 905>;
                };
 
+               pfc: pin-controller@e6060000 {
+                       compatible = "renesas,pfc-r8a77965";
+                       reg = <0 0xe6060000 0 0x50c>;
+               };
+
+               cpg: clock-controller@e6150000 {
+                       compatible = "renesas,r8a77965-cpg-mssr";
+                       reg = <0 0xe6150000 0 0x1000>;
+                       clocks = <&extal_clk>, <&extalr_clk>;
+                       clock-names = "extal", "extalr";
+                       #clock-cells = <2>;
+                       #power-domain-cells = <0>;
+                       #reset-cells = <1>;
+               };
+
+               rst: reset-controller@e6160000 {
+                       compatible = "renesas,r8a77965-rst";
+                       reg = <0 0xe6160000 0 0x0200>;
+               };
+
+               sysc: system-controller@e6180000 {
+                       compatible = "renesas,r8a77965-sysc";
+                       reg = <0 0xe6180000 0 0x0400>;
+                       #power-domain-cells = <1>;
+               };
+
+               tsc: thermal@e6198000 {
+                       compatible = "renesas,r8a77965-thermal";
+                       reg = <0 0xe6198000 0 0x100>,
+                             <0 0xe61a0000 0 0x100>,
+                             <0 0xe61a8000 0 0x100>;
+                       interrupts = <GIC_SPI 67 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 68 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 69 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 522>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 522>;
+                       #thermal-sensor-cells = <1>;
+                       status = "okay";
+               };
+
                intc_ex: interrupt-controller@e61c0000 {
                        compatible = "renesas,intc-ex-r8a77965", "renesas,irqc";
                        #interrupt-cells = <2>;
@@ -331,84 +316,273 @@ GIC_SPI 3 IRQ_TYPE_LEVEL_HIGH
                                      GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH
                                      GIC_SPI 161 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 407>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 407>;
                };
 
-               dmac0: dma-controller@e6700000 {
-                       compatible = "renesas,dmac-r8a77965",
-                                    "renesas,rcar-dmac";
-                       reg = <0 0xe6700000 0 0x10000>;
-                       interrupts = <GIC_SPI 199 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 200 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 201 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 202 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 203 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 204 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 206 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 207 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 211 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 213 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 214 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "error",
-                                       "ch0", "ch1", "ch2", "ch3",
-                                       "ch4", "ch5", "ch6", "ch7",
-                                       "ch8", "ch9", "ch10", "ch11",
-                                       "ch12", "ch13", "ch14", "ch15";
-                       clocks = <&cpg CPG_MOD 219>;
-                       clock-names = "fck";
-                       power-domains = <&sysc 32>;
-                       resets = <&cpg 219>;
-                       #dma-cells = <1>;
-                       dma-channels = <16>;
+               i2c0: i2c@e6500000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77965",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6500000 0 0x40>;
+                       interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 931>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 931>;
+                       dmas = <&dmac1 0x91>, <&dmac1 0x90>,
+                              <&dmac2 0x91>, <&dmac2 0x90>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <110>;
+                       status = "disabled";
                };
 
-               dmac1: dma-controller@e7300000 {
-                       compatible = "renesas,dmac-r8a77965",
-                                    "renesas,rcar-dmac";
-                       reg = <0 0xe7300000 0 0x10000>;
-                       interrupts = <GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 216 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 218 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 313 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 314 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 315 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 316 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 317 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 318 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 319 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "error",
-                                       "ch0", "ch1", "ch2", "ch3",
-                                       "ch4", "ch5", "ch6", "ch7",
-                                       "ch8", "ch9", "ch10", "ch11",
-                                       "ch12", "ch13", "ch14", "ch15";
-                       clocks = <&cpg CPG_MOD 218>;
-                       clock-names = "fck";
-                       power-domains = <&sysc 32>;
-                       resets = <&cpg 218>;
-                       #dma-cells = <1>;
-                       dma-channels = <16>;
+               i2c1: i2c@e6508000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77965",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6508000 0 0x40>;
+                       interrupts = <GIC_SPI 288 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 930>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 930>;
+                       dmas = <&dmac1 0x93>, <&dmac1 0x92>,
+                              <&dmac2 0x93>, <&dmac2 0x92>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
+                       status = "disabled";
                };
 
-               dmac2: dma-controller@e7310000 {
-                       compatible = "renesas,dmac-r8a77965",
-                                    "renesas,rcar-dmac";
-                       reg = <0 0xe7310000 0 0x10000>;
-                       interrupts = <GIC_SPI 416 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 417 IRQ_TYPE_LEVEL_HIGH
+               i2c2: i2c@e6510000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77965",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6510000 0 0x40>;
+                       interrupts = <GIC_SPI 286 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 929>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 929>;
+                       dmas = <&dmac1 0x95>, <&dmac1 0x94>,
+                              <&dmac2 0x95>, <&dmac2 0x94>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
+                       status = "disabled";
+               };
+
+               i2c3: i2c@e66d0000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77965",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe66d0000 0 0x40>;
+                       interrupts = <GIC_SPI 290 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 928>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 928>;
+                       dmas = <&dmac0 0x97>, <&dmac0 0x96>;
+                       dma-names = "tx", "rx";
+                       i2c-scl-internal-delay-ns = <110>;
+                       status = "disabled";
+               };
+
+               i2c4: i2c@e66d8000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77965",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe66d8000 0 0x40>;
+                       interrupts = <GIC_SPI 19 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 927>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 927>;
+                       dmas = <&dmac0 0x99>, <&dmac0 0x98>;
+                       dma-names = "tx", "rx";
+                       i2c-scl-internal-delay-ns = <110>;
+                       status = "disabled";
+               };
+
+               i2c5: i2c@e66e0000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77965",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe66e0000 0 0x40>;
+                       interrupts = <GIC_SPI 20 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 919>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 919>;
+                       dmas = <&dmac0 0x9b>, <&dmac0 0x9a>;
+                       dma-names = "tx", "rx";
+                       i2c-scl-internal-delay-ns = <110>;
+                       status = "disabled";
+               };
+
+               i2c6: i2c@e66e8000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77965",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe66e8000 0 0x40>;
+                       interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 918>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 918>;
+                       dmas = <&dmac0 0x9d>, <&dmac0 0x9c>;
+                       dma-names = "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
+                       status = "disabled";
+               };
+
+               i2c_dvfs: i2c@e60b0000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,iic-r8a77965",
+                                    "renesas,rcar-gen3-iic",
+                                    "renesas,rmobile-iic";
+                       reg = <0 0xe60b0000 0 0x425>;
+                       interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 926>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 926>;
+                       dmas = <&dmac0 0x11>, <&dmac0 0x10>;
+                       dma-names = "tx", "rx";
+                       status = "disabled";
+               };
+
+               hsusb: usb@e6590000 {
+                       compatible = "renesas,usbhs-r8a7796",
+                                    "renesas,rcar-gen3-usbhs";
+                       reg = <0 0xe6590000 0 0x100>;
+                       interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 704>;
+                       dmas = <&usb_dmac0 0>, <&usb_dmac0 1>,
+                              <&usb_dmac1 0>, <&usb_dmac1 1>;
+                       dma-names = "ch0", "ch1", "ch2", "ch3";
+                       renesas,buswait = <11>;
+                       phys = <&usb2_phy0>;
+                       phy-names = "usb";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 704>;
+                       status = "disabled";
+               };
+
+               usb_dmac0: dma-controller@e65a0000 {
+                       compatible = "renesas,r8a77965-usb-dmac",
+                                    "renesas,usb-dmac";
+                       reg = <0 0xe65a0000 0 0x100>;
+                       interrupts = <GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 109 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1";
+                       clocks = <&cpg CPG_MOD 330>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 330>;
+                       #dma-cells = <1>;
+                       dma-channels = <2>;
+               };
+
+               usb_dmac1: dma-controller@e65b0000 {
+                       compatible = "renesas,r8a77965-usb-dmac",
+                                    "renesas,usb-dmac";
+                       reg = <0 0xe65b0000 0 0x100>;
+                       interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1";
+                       clocks = <&cpg CPG_MOD 331>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 331>;
+                       #dma-cells = <1>;
+                       dma-channels = <2>;
+               };
+
+               usb3_phy0: usb-phy@e65ee000 {
+                       compatible = "renesas,r8a77965-usb3-phy",
+                                    "renesas,rcar-gen3-usb3-phy";
+                       reg = <0 0xe65ee000 0 0x90>;
+                       clocks = <&cpg CPG_MOD 328>, <&usb3s0_clk>,
+                                <&usb_extal_clk>;
+                       clock-names = "usb3-if", "usb3s_clk", "usb_extal";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 328>;
+                       #phy-cells = <0>;
+                       status = "disabled";
+               };
+
+               dmac0: dma-controller@e6700000 {
+                       compatible = "renesas,dmac-r8a77965",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xe6700000 0 0x10000>;
+                       interrupts = <GIC_SPI 199 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 200 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 201 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 202 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 203 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 204 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 205 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 206 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 207 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 208 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 210 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 211 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 212 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 213 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 214 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 215 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                       "ch0", "ch1", "ch2", "ch3",
+                                       "ch4", "ch5", "ch6", "ch7",
+                                       "ch8", "ch9", "ch10", "ch11",
+                                       "ch12", "ch13", "ch14", "ch15";
+                       clocks = <&cpg CPG_MOD 219>;
+                       clock-names = "fck";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 219>;
+                       #dma-cells = <1>;
+                       dma-channels = <16>;
+               };
+
+               dmac1: dma-controller@e7300000 {
+                       compatible = "renesas,dmac-r8a77965",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xe7300000 0 0x10000>;
+                       interrupts = <GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 216 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 218 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 313 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 314 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 315 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 316 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 317 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 318 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 319 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                       "ch0", "ch1", "ch2", "ch3",
+                                       "ch4", "ch5", "ch6", "ch7",
+                                       "ch8", "ch9", "ch10", "ch11",
+                                       "ch12", "ch13", "ch14", "ch15";
+                       clocks = <&cpg CPG_MOD 218>;
+                       clock-names = "fck";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 218>;
+                       #dma-cells = <1>;
+                       dma-channels = <16>;
+               };
+
+               dmac2: dma-controller@e7310000 {
+                       compatible = "renesas,dmac-r8a77965",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xe7310000 0 0x10000>;
+                       interrupts = <GIC_SPI 416 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 417 IRQ_TYPE_LEVEL_HIGH
                                      GIC_SPI 418 IRQ_TYPE_LEVEL_HIGH
                                      GIC_SPI 419 IRQ_TYPE_LEVEL_HIGH
                                      GIC_SPI 420 IRQ_TYPE_LEVEL_HIGH
@@ -431,12 +605,127 @@ GIC_SPI 431 IRQ_TYPE_LEVEL_HIGH
                                        "ch12", "ch13", "ch14", "ch15";
                        clocks = <&cpg CPG_MOD 217>;
                        clock-names = "fck";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 217>;
                        #dma-cells = <1>;
                        dma-channels = <16>;
                };
 
+               avb: ethernet@e6800000 {
+                       compatible = "renesas,etheravb-r8a77965",
+                                    "renesas,etheravb-rcar-gen3";
+                       reg = <0 0xe6800000 0 0x800>, <0 0xe6a00000 0 0x10000>;
+                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1", "ch2", "ch3",
+                                         "ch4", "ch5", "ch6", "ch7",
+                                         "ch8", "ch9", "ch10", "ch11",
+                                         "ch12", "ch13", "ch14", "ch15",
+                                         "ch16", "ch17", "ch18", "ch19",
+                                         "ch20", "ch21", "ch22", "ch23",
+                                         "ch24";
+                       clocks = <&cpg CPG_MOD 812>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 812>;
+                       phy-mode = "rgmii";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               pwm0: pwm@e6e30000 {
+                       compatible = "renesas,pwm-r8a77965", "renesas,pwm-rcar";
+                       reg = <0 0xe6e30000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm1: pwm@e6e31000 {
+                       compatible = "renesas,pwm-r8a77965", "renesas,pwm-rcar";
+                       reg = <0 0xe6e31000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm2: pwm@e6e32000 {
+                       compatible = "renesas,pwm-r8a77965", "renesas,pwm-rcar";
+                       reg = <0 0xe6e32000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm3: pwm@e6e33000 {
+                       compatible = "renesas,pwm-r8a77965", "renesas,pwm-rcar";
+                       reg = <0 0xe6e33000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm4: pwm@e6e34000 {
+                       compatible = "renesas,pwm-r8a77965", "renesas,pwm-rcar";
+                       reg = <0 0xe6e34000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm5: pwm@e6e35000 {
+                       compatible = "renesas,pwm-r8a77965", "renesas,pwm-rcar";
+                       reg = <0 0xe6e35000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
+               pwm6: pwm@e6e36000 {
+                       compatible = "renesas,pwm-r8a77965", "renesas,pwm-rcar";
+                       reg = <0 0xe6e36000 0 8>;
+                       #pwm-cells = <2>;
+                       clocks = <&cpg CPG_MOD 523>;
+                       resets = <&cpg 523>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       status = "disabled";
+               };
+
                scif0: serial@e6e60000 {
                        compatible = "renesas,scif-r8a77965",
                                     "renesas,rcar-gen3-scif", "renesas,scif";
@@ -449,7 +738,7 @@ scif0: serial@e6e60000 {
                        dmas = <&dmac1 0x51>, <&dmac1 0x50>,
                               <&dmac2 0x51>, <&dmac2 0x50>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 207>;
                        status = "disabled";
                };
@@ -466,7 +755,7 @@ scif1: serial@e6e68000 {
                        dmas = <&dmac1 0x53>, <&dmac1 0x52>,
                               <&dmac2 0x53>, <&dmac2 0x52>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 206>;
                        status = "disabled";
                };
@@ -480,7 +769,7 @@ scif2: serial@e6e88000 {
                                 <&cpg CPG_CORE 20>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 310>;
                        status = "disabled";
                };
@@ -496,7 +785,7 @@ scif3: serial@e6c50000 {
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac0 0x57>, <&dmac0 0x56>;
                        dma-names = "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 204>;
                        status = "disabled";
                };
@@ -512,7 +801,7 @@ scif4: serial@e6c40000 {
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac0 0x59>, <&dmac0 0x58>;
                        dma-names = "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 203>;
                        status = "disabled";
                };
@@ -529,243 +818,772 @@ scif5: serial@e6f30000 {
                        dmas = <&dmac1 0x5b>, <&dmac1 0x5a>,
                               <&dmac2 0x5b>, <&dmac2 0x5a>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
                        resets = <&cpg 202>;
                        status = "disabled";
                };
 
-               avb: ethernet@e6800000 {
-                       compatible = "renesas,etheravb-r8a77965",
-                                    "renesas,etheravb-rcar-gen3";
-                       reg = <0 0xe6800000 0 0x800>, <0 0xe6a00000 0 0x10000>;
-                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1", "ch2", "ch3",
-                                         "ch4", "ch5", "ch6", "ch7",
-                                         "ch8", "ch9", "ch10", "ch11",
-                                         "ch12", "ch13", "ch14", "ch15",
-                                         "ch16", "ch17", "ch18", "ch19",
-                                         "ch20", "ch21", "ch22", "ch23",
-                                         "ch24";
-                       clocks = <&cpg CPG_MOD 812>;
-                       power-domains = <&sysc 32>;
-                       resets = <&cpg 812>;
-                       phy-mode = "rgmii";
+               msiof0: spi@e6e90000 {
+                       compatible = "renesas,msiof-r8a77965",
+                                    "renesas,rcar-gen3-msiof";
+                       reg = <0 0xe6e90000 0 0x0064>;
+                       interrupts = <GIC_SPI 156 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 211>;
+                       dmas = <&dmac1 0x41>, <&dmac1 0x40>,
+                              <&dmac2 0x41>, <&dmac2 0x40>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 211>;
                        #address-cells = <1>;
                        #size-cells = <0>;
                        status = "disabled";
                };
 
-               csi20: csi2@fea80000 {
-                       reg = <0 0xfea80000 0 0x10000>;
-                       /* placeholder */
+               msiof1: spi@e6ea0000 {
+                       compatible = "renesas,msiof-r8a77965",
+                                    "renesas,rcar-gen3-msiof";
+                       reg = <0 0xe6ea0000 0 0x0064>;
+                       interrupts = <GIC_SPI 157 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 210>;
+                       dmas = <&dmac1 0x43>, <&dmac1 0x42>,
+                              <&dmac2 0x43>, <&dmac2 0x42>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 210>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               msiof2: spi@e6c00000 {
+                       compatible = "renesas,msiof-r8a77965",
+                                    "renesas,rcar-gen3-msiof";
+                       reg = <0 0xe6c00000 0 0x0064>;
+                       interrupts = <GIC_SPI 158 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 209>;
+                       dmas = <&dmac0 0x45>, <&dmac0 0x44>;
+                       dma-names = "tx", "rx";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 209>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               msiof3: spi@e6c10000 {
+                       compatible = "renesas,msiof-r8a77965",
+                                    "renesas,rcar-gen3-msiof";
+                       reg = <0 0xe6c10000 0 0x0064>;
+                       interrupts = <GIC_SPI 159 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 208>;
+                       dmas = <&dmac0 0x47>, <&dmac0 0x46>;
+                       dma-names = "tx", "rx";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 208>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               vin0: video@e6ef0000 {
+                       compatible = "renesas,vin-r8a77965";
+                       reg = <0 0xe6ef0000 0 0x1000>;
+                       interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 811>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 811>;
+                       renesas,id = <0>;
+                       status = "disabled";
 
                        ports {
                                #address-cells = <1>;
                                #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin0csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin0>;
+                                       };
+                                       vin0csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin0>;
+                                       };
+                               };
                        };
                };
 
-               csi40: csi2@feaa0000 {
-                       reg = <0 0xfeaa0000 0 0x10000>;
-                       /* placeholder */
+               vin1: video@e6ef1000 {
+                       compatible = "renesas,vin-r8a77965";
+                       reg = <0 0xe6ef1000 0 0x1000>;
+                       interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 810>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 810>;
+                       renesas,id = <1>;
+                       status = "disabled";
 
                        ports {
                                #address-cells = <1>;
                                #size-cells = <0>;
-                       };
-               };
 
-               vin0: video@e6ef0000 {
-                       reg = <0 0xe6ef0000 0 0x1000>;
-                       /* placeholder */
-               };
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
 
-               vin1: video@e6ef1000 {
-                       reg = <0 0xe6ef1000 0 0x1000>;
-                       /* placeholder */
+                                       reg = <1>;
+
+                                       vin1csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin1>;
+                                       };
+                                       vin1csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin1>;
+                                       };
+                               };
+                       };
                };
 
                vin2: video@e6ef2000 {
+                       compatible = "renesas,vin-r8a77965";
                        reg = <0 0xe6ef2000 0 0x1000>;
-                       /* placeholder */
+                       interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 809>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 809>;
+                       renesas,id = <2>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin2csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin2>;
+                                       };
+                                       vin2csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin2>;
+                                       };
+                               };
+                       };
                };
 
                vin3: video@e6ef3000 {
+                       compatible = "renesas,vin-r8a77965";
                        reg = <0 0xe6ef3000 0 0x1000>;
-                       /* placeholder */
+                       interrupts = <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 808>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 808>;
+                       renesas,id = <3>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin3csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin3>;
+                                       };
+                                       vin3csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin3>;
+                                       };
+                               };
+                       };
                };
 
                vin4: video@e6ef4000 {
+                       compatible = "renesas,vin-r8a77965";
                        reg = <0 0xe6ef4000 0 0x1000>;
-                       /* placeholder */
+                       interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 807>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 807>;
+                       renesas,id = <4>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin4csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin4>;
+                                       };
+                                       vin4csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin4>;
+                                       };
+                               };
+                       };
                };
 
                vin5: video@e6ef5000 {
+                       compatible = "renesas,vin-r8a77965";
                        reg = <0 0xe6ef5000 0 0x1000>;
-                       /* placeholder */
+                       interrupts = <GIC_SPI 175 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 806>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 806>;
+                       renesas,id = <5>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin5csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin5>;
+                                       };
+                                       vin5csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin5>;
+                                       };
+                               };
+                       };
                };
 
                vin6: video@e6ef6000 {
+                       compatible = "renesas,vin-r8a77965";
                        reg = <0 0xe6ef6000 0 0x1000>;
-                       /* placeholder */
+                       interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 805>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 805>;
+                       renesas,id = <6>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin6csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin6>;
+                                       };
+                                       vin6csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin6>;
+                                       };
+                               };
+                       };
                };
 
                vin7: video@e6ef7000 {
+                       compatible = "renesas,vin-r8a77965";
                        reg = <0 0xe6ef7000 0 0x1000>;
+                       interrupts = <GIC_SPI 171 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 804>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 804>;
+                       renesas,id = <7>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin7csi20: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint= <&csi20vin7>;
+                                       };
+                                       vin7csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin7>;
+                                       };
+                               };
+                       };
+               };
+
+               rcar_sound: sound@ec500000 {
+                       reg =   <0 0xec500000 0 0x1000>, /* SCU */
+                               <0 0xec5a0000 0 0x100>,  /* ADG */
+                               <0 0xec540000 0 0x1000>, /* SSIU */
+                               <0 0xec541000 0 0x280>,  /* SSI */
+                               <0 0xec740000 0 0x200>;  /* Audio DMAC peri peri*/
                        /* placeholder */
+
+                       rcar_sound,dvc {
+                               dvc0: dvc-0 {
+                               };
+                               dvc1: dvc-1 {
+                               };
+                       };
+
+                       rcar_sound,src {
+                               src0: src-0 {
+                               };
+                               src1: src-1 {
+                               };
+                       };
+
+                       rcar_sound,ssi {
+                               ssi0: ssi-0 {
+                               };
+                               ssi1: ssi-1 {
+                               };
+                       };
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               port@0 {
+                                       reg = <0>;
+                               };
+                       };
+               };
+
+               xhci0: usb@ee000000 {
+                       compatible = "renesas,xhci-r8a77965",
+                                    "renesas,rcar-gen3-xhci";
+                       reg = <0 0xee000000 0 0xc00>;
+                       interrupts = <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 328>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 328>;
+                       status = "disabled";
+               };
+
+               usb3_peri0: usb@ee020000 {
+                       compatible = "renesas,r8a77965-usb3-peri",
+                                    "renesas,rcar-gen3-usb3-peri";
+                       reg = <0 0xee020000 0 0x400>;
+                       interrupts = <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 328>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 328>;
+                       status = "disabled";
                };
 
                ohci0: usb@ee080000 {
+                       compatible = "generic-ohci";
                        reg = <0 0xee080000 0 0x100>;
-                       /* placeholder */
+                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 703>;
+                       phys = <&usb2_phy0>;
+                       phy-names = "usb";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 703>;
+                       status = "disabled";
+               };
+
+               ohci1: usb@ee0a0000 {
+                       compatible = "generic-ohci";
+                       reg = <0 0xee0a0000 0 0x100>;
+                       interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 702>;
+                       phys = <&usb2_phy1>;
+                       phy-names = "usb";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 702>;
+                       status = "disabled";
                };
 
                ehci0: usb@ee080100 {
+                       compatible = "generic-ehci";
                        reg = <0 0xee080100 0 0x100>;
-                       /* placeholder */
+                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 703>;
+                       phys = <&usb2_phy0>;
+                       phy-names = "usb";
+                       companion = <&ohci0>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 703>;
+                       status = "disabled";
+               };
+
+               ehci1: usb@ee0a0100 {
+                       compatible = "generic-ehci";
+                       reg = <0 0xee0a0100 0 0x100>;
+                       interrupts = <GIC_SPI 112 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 702>;
+                       phys = <&usb2_phy1>;
+                       phy-names = "usb";
+                       companion = <&ohci1>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 702>;
+                       status = "disabled";
                };
 
                usb2_phy0: usb-phy@ee080200 {
+                       compatible = "renesas,usb2-phy-r8a77965",
+                                    "renesas,rcar-gen3-usb2-phy";
                        reg = <0 0xee080200 0 0x700>;
-                       /* placeholder */
+                       interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 703>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 703>;
+                       #phy-cells = <0>;
+                       status = "disabled";
                };
 
                usb2_phy1: usb-phy@ee0a0200 {
+                       compatible = "renesas,usb2-phy-r8a77965",
+                                    "renesas,rcar-gen3-usb2-phy";
                        reg = <0 0xee0a0200 0 0x700>;
-                       /* placeholder */
+                       clocks = <&cpg CPG_MOD 703>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 703>;
+                       #phy-cells = <0>;
+                       status = "disabled";
                };
 
-               ohci1: usb@ee0a0000 {
-                       reg = <0 0xee0a0000 0 0x100>;
-                       /* placeholder */
+               sdhi0: sd@ee100000 {
+                       compatible = "renesas,sdhi-r8a77965",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee100000 0 0x2000>;
+                       interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 314>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 314>;
+                       status = "disabled";
                };
 
-               ehci1: usb@ee0a0100 {
-                       reg = <0 0xee0a0100 0 0x100>;
-                       /* placeholder */
+               sdhi1: sd@ee120000 {
+                       compatible = "renesas,sdhi-r8a77965",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee120000 0 0x2000>;
+                       interrupts = <GIC_SPI 166 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 313>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 313>;
+                       status = "disabled";
                };
 
-               i2c0: i2c@e6500000 {
-                       reg = <0 0xe6500000 0 0x40>;
-                       /* placeholder */
+               sdhi2: sd@ee140000 {
+                       compatible = "renesas,sdhi-r8a77965",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee140000 0 0x2000>;
+                       interrupts = <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 312>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 312>;
+                       status = "disabled";
                };
 
-               i2c1: i2c@e6508000 {
-                       reg = <0 0xe6508000 0 0x40>;
-                       /* placeholder */
+               sdhi3: sd@ee160000 {
+                       compatible = "renesas,sdhi-r8a77965",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee160000 0 0x2000>;
+                       interrupts = <GIC_SPI 168 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 311>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 311>;
+                       status = "disabled";
                };
 
-               i2c2: i2c@e6510000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
+               gic: interrupt-controller@f1010000 {
+                       compatible = "arm,gic-400";
+                       #interrupt-cells = <3>;
+                       #address-cells = <0>;
+                       interrupt-controller;
+                       reg = <0x0 0xf1010000 0 0x1000>,
+                             <0x0 0xf1020000 0 0x20000>,
+                             <0x0 0xf1040000 0 0x20000>,
+                             <0x0 0xf1060000 0 0x20000>;
+                       interrupts = <GIC_PPI 9
+                                       (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_HIGH)>;
+                       clocks = <&cpg CPG_MOD 408>;
+                       clock-names = "clk";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 408>;
+               };
 
-                       reg = <0 0xe6510000 0 0x40>;
+               pciec0: pcie@fe000000 {
+                       reg = <0 0xfe000000 0 0x80000>;
                        /* placeholder */
                };
 
-               i2c3: i2c@e66d0000 {
-                       reg = <0 0xe66d0000 0 0x40>;
+               pciec1: pcie@ee800000 {
+                       reg = <0 0xee800000 0 0x80000>;
                        /* placeholder */
                };
 
-               i2c4: i2c@e66d8000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
+               fcpf0: fcp@fe950000 {
+                       compatible = "renesas,fcpf";
+                       reg = <0 0xfe950000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 615>;
+                       power-domains = <&sysc R8A77965_PD_A3VP>;
+                       resets = <&cpg 615>;
+               };
 
-                       reg = <0 0xe66d8000 0 0x40>;
-                       /* placeholder */
+               vspb: vsp@fe960000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfe960000 0 0x8000>;
+                       interrupts = <GIC_SPI 266 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 626>;
+                       power-domains = <&sysc R8A77965_PD_A3VP>;
+                       resets = <&cpg 626>;
+
+                       renesas,fcp = <&fcpvb0>;
                };
 
-               i2c5: i2c@e66e0000 {
-                       reg = <0 0xe66e0000 0 0x40>;
-                       /* placeholder */
+               fcpvb0: fcp@fe96f000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfe96f000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 607>;
+                       power-domains = <&sysc R8A77965_PD_A3VP>;
+                       resets = <&cpg 607>;
                };
 
-               i2c6: i2c@e66e8000 {
-                       reg = <0 0xe66e8000 0 0x40>;
-                       /* placeholder */
+               vspi0: vsp@fe9a0000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfe9a0000 0 0x8000>;
+                       interrupts = <GIC_SPI 444 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 631>;
+                       power-domains = <&sysc R8A77965_PD_A3VP>;
+                       resets = <&cpg 631>;
+
+                       renesas,fcp = <&fcpvi0>;
                };
 
-               i2c_dvfs: i2c@e60b0000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,iic-r8a77965",
-                                    "renesas,rcar-gen3-iic",
-                                    "renesas,rmobile-iic";
-                       reg = <0 0xe60b0000 0 0x425>;
-                       interrupts = <GIC_SPI 173 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 926>;
-                       power-domains = <&sysc 32>;
-                       resets = <&cpg 926>;
-                       dmas = <&dmac0 0x11>, <&dmac0 0x10>;
-                       dma-names = "tx", "rx";
-                       status = "disabled";
+               fcpvi0: fcp@fe9af000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfe9af000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 611>;
+                       power-domains = <&sysc R8A77965_PD_A3VP>;
+                       resets = <&cpg 611>;
                };
 
-               pwm0: pwm@e6e30000 {
-                       reg = <0 0xe6e30000 0 8>;
-                       /* placeholder */
+               vspd0: vsp@fea20000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfea20000 0 0x8000>;
+                       interrupts = <GIC_SPI 466 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 623>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 623>;
+
+                       renesas,fcp = <&fcpvd0>;
                };
 
-               pwm1: pwm@e6e31000 {
-                       reg = <0 0xe6e31000 0 8>;
-                       #pwm-cells = <2>;
-                       /* placeholder */
+               fcpvd0: fcp@fea27000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea27000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 603>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 603>;
                };
 
-               pwm2: pwm@e6e32000 {
-                       reg = <0 0xe6e32000 0 8>;
-                       /* placeholder */
+               vspd1: vsp@fea28000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfea28000 0 0x8000>;
+                       interrupts = <GIC_SPI 467 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 622>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 622>;
+
+                       renesas,fcp = <&fcpvd1>;
                };
 
-               pwm3: pwm@e6e33000 {
-                       reg = <0 0xe6e33000 0 8>;
-                       /* placeholder */
+               fcpvd1: fcp@fea2f000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea2f000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 602>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 602>;
                };
 
-               pwm4: pwm@e6e34000 {
-                       reg = <0 0xe6e34000 0 8>;
-                       /* placeholder */
+               csi20: csi2@fea80000 {
+                       compatible = "renesas,r8a77965-csi2";
+                       reg = <0 0xfea80000 0 0x10000>;
+                       interrupts = <GIC_SPI 184 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 714>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 714>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       csi20vin0: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint = <&vin0csi20>;
+                                       };
+                                       csi20vin1: endpoint@1 {
+                                               reg = <1>;
+                                               remote-endpoint = <&vin1csi20>;
+                                       };
+                                       csi20vin2: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint = <&vin2csi20>;
+                                       };
+                                       csi20vin3: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint = <&vin3csi20>;
+                                       };
+                                       csi20vin4: endpoint@4 {
+                                               reg = <4>;
+                                               remote-endpoint = <&vin4csi20>;
+                                       };
+                                       csi20vin5: endpoint@5 {
+                                               reg = <5>;
+                                               remote-endpoint = <&vin5csi20>;
+                                       };
+                                       csi20vin6: endpoint@6 {
+                                               reg = <6>;
+                                               remote-endpoint = <&vin6csi20>;
+                                       };
+                                       csi20vin7: endpoint@7 {
+                                               reg = <7>;
+                                               remote-endpoint = <&vin7csi20>;
+                                       };
+                               };
+                       };
                };
 
-               pwm5: pwm@e6e35000 {
-                       reg = <0 0xe6e35000 0 8>;
-                       /* placeholder */
+               csi40: csi2@feaa0000 {
+                       compatible = "renesas,r8a77965-csi2";
+                       reg = <0 0xfeaa0000 0 0x10000>;
+                       interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 716>;
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 716>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       csi40vin0: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint = <&vin0csi40>;
+                                       };
+                                       csi40vin1: endpoint@1 {
+                                               reg = <1>;
+                                               remote-endpoint = <&vin1csi40>;
+                                       };
+                                       csi40vin2: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint = <&vin2csi40>;
+                                       };
+                                       csi40vin3: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint = <&vin3csi40>;
+                                       };
+                                       csi40vin4: endpoint@4 {
+                                               reg = <4>;
+                                               remote-endpoint = <&vin4csi40>;
+                                       };
+                                       csi40vin5: endpoint@5 {
+                                               reg = <5>;
+                                               remote-endpoint = <&vin5csi40>;
+                                       };
+                                       csi40vin6: endpoint@6 {
+                                               reg = <6>;
+                                               remote-endpoint = <&vin6csi40>;
+                                       };
+                                       csi40vin7: endpoint@7 {
+                                               reg = <7>;
+                                               remote-endpoint = <&vin7csi40>;
+                                       };
+                               };
+                       };
                };
 
-               pwm6: pwm@e6e36000 {
-                       reg = <0 0xe6e36000 0 8>;
-                       /* placeholder */
+               hdmi0: hdmi@fead0000 {
+                       compatible = "renesas,r8a77965-hdmi",
+                                    "renesas,rcar-gen3-hdmi";
+                       reg = <0 0xfead0000 0 0x10000>;
+                       interrupts = <GIC_SPI 389 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 729>,
+                                <&cpg CPG_CORE R8A77965_CLK_HDMI>;
+                       clock-names = "iahb", "isfr";
+                       power-domains = <&sysc R8A77965_PD_ALWAYS_ON>;
+                       resets = <&cpg 729>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+                               port@0 {
+                                       reg = <0>;
+                                       dw_hdmi0_in: endpoint {
+                                               remote-endpoint = <&du_out_hdmi0>;
+                                       };
+                               };
+                               port@1 {
+                                       reg = <1>;
+                               };
+                       };
                };
 
                du: display@feb00000 {
-                       reg = <0 0xfeb00000 0 0x80000>,
-                             <0 0xfeb90000 0 0x14>;
-                       /* placeholder */
+                       compatible = "renesas,du-r8a77965";
+                       reg = <0 0xfeb00000 0 0x80000>;
+                       reg-names = "du";
+                       interrupts = <GIC_SPI 256 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 268 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 270 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 724>,
+                                <&cpg CPG_MOD 723>,
+                                <&cpg CPG_MOD 721>;
+                       clock-names = "du.0", "du.1", "du.3";
+                       status = "disabled";
+
+                       vsps = <&vspd0 0 &vspd1 0 &vspd0 1>;
 
                        ports {
                                #address-cells = <1>;
@@ -779,6 +1597,7 @@ du_out_rgb: endpoint {
                                port@1 {
                                        reg = <1>;
                                        du_out_hdmi0: endpoint {
+                                               remote-endpoint = <&dw_hdmi0_in>;
                                        };
                                };
                                port@2 {
@@ -789,90 +1608,74 @@ du_out_lvds0: endpoint {
                        };
                };
 
-               hsusb: usb@e6590000 {
-                       reg = <0 0xe6590000 0 0x100>;
-                       /* placeholder */
-               };
-
-               pciec0: pcie@fe000000 {
-                       reg = <0 0xfe000000 0 0x80000>;
-                       /* placeholder */
-               };
-
-               pciec1: pcie@ee800000 {
-                       reg = <0 0xee800000 0 0x80000>;
-                       /* placeholder */
+               prr: chipid@fff00044 {
+                       compatible = "renesas,prr";
+                       reg = <0 0xfff00044 0 4>;
                };
+       };
 
-               rcar_sound: sound@ec500000 {
-                       reg =   <0 0xec500000 0 0x1000>, /* SCU */
-                               <0 0xec5a0000 0 0x100>,  /* ADG */
-                               <0 0xec540000 0 0x1000>, /* SSIU */
-                               <0 0xec541000 0 0x280>,  /* SSI */
-                               <0 0xec740000 0 0x200>;  /* Audio DMAC peri peri*/
-                       /* placeholder */
+       timer {
+               compatible = "arm,armv8-timer";
+               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
+       };
 
-                       rcar_sound,dvc {
-                               dvc0: dvc-0 {
-                               };
-                               dvc1: dvc-1 {
+       thermal-zones {
+               sensor_thermal1: sensor-thermal1 {
+                       polling-delay-passive = <250>;
+                       polling-delay = <1000>;
+                       thermal-sensors = <&tsc 0>;
+
+                       trips {
+                               sensor1_crit: sensor1-crit {
+                                       temperature = <120000>;
+                                       hysteresis = <1000>;
+                                       type = "critical";
                                };
                        };
+               };
 
-                       rcar_sound,src {
-                               src0: src-0 {
-                               };
-                               src1: src-1 {
-                               };
-                       };
+               sensor_thermal2: sensor-thermal2 {
+                       polling-delay-passive = <250>;
+                       polling-delay = <1000>;
+                       thermal-sensors = <&tsc 1>;
 
-                       rcar_sound,ssi {
-                               ssi0: ssi-0 {
-                               };
-                               ssi1: ssi-1 {
+                       trips {
+                               sensor2_crit: sensor2-crit {
+                                       temperature = <120000>;
+                                       hysteresis = <1000>;
+                                       type = "critical";
                                };
                        };
                };
 
-               sdhi0: sd@ee100000 {
-                       reg = <0 0xee100000 0 0x2000>;
-                       /* placeholder */
-               };
-
-               sdhi1: sd@ee120000 {
-                       reg = <0 0xee120000 0 0x2000>;
-                       /* placeholder */
-               };
+               sensor_thermal3: sensor-thermal3 {
+                       polling-delay-passive = <250>;
+                       polling-delay = <1000>;
+                       thermal-sensors = <&tsc 2>;
 
-               sdhi2: sd@ee140000 {
-                       reg = <0 0xee140000 0 0x2000>;
-                       /* placeholder */
-               };
-
-               sdhi3: sd@ee160000 {
-                       reg = <0 0xee160000 0 0x2000>;
-                       /* placeholder */
-               };
-
-               usb3_phy0: usb-phy@e65ee000 {
-                       reg = <0 0xe65ee000 0 0x90>;
-                       #phy-cells = <0>;
-                       /* placeholder */
-               };
-
-               usb3_peri0: usb@ee020000 {
-                       reg = <0 0xee020000 0 0x400>;
-                       /* placeholder */
+                       trips {
+                               sensor3_crit: sensor3-crit {
+                                       temperature = <120000>;
+                                       hysteresis = <1000>;
+                                       type = "critical";
+                               };
+                       };
                };
+       };
 
-               xhci0: usb@ee000000 {
-                       reg = <0 0xee000000 0 0xc00>;
-                       /* placeholder */
-               };
+       /* External USB clocks - can be overridden by the board */
+       usb3s0_clk: usb3s0 {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
 
-               wdt0: watchdog@e6020000 {
-                       reg = <0 0xe6020000 0 0x0c>;
-                       /* placeholder */
-               };
+       usb_extal_clk: usb_extal {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
        };
 };
index 3c5f598c9766303c43a0aeccc4ced795b6e19e1f..21f9cf5c6e84ea7072a07b8a4dbd015656e0c154 100644 (file)
@@ -31,9 +31,57 @@ memory@48000000 {
                /* first 128MB is reserved for secure area. */
                reg = <0x0 0x48000000 0x0 0x38000000>;
        };
+
+       hdmi-out {
+               compatible = "hdmi-connector";
+               type = "a";
+
+               port {
+                       hdmi_con_out: endpoint {
+                               remote-endpoint = <&adv7511_out>;
+                       };
+               };
+       };
+
+       d3p3: regulator-fixed {
+               compatible = "regulator-fixed";
+               regulator-name = "fixed-3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       lvds-decoder {
+               compatible = "thine,thc63lvd1024";
+
+               vcc-supply = <&d3p3>;
+
+               ports {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       port@0 {
+                               reg = <0>;
+                               thc63lvd1024_in: endpoint {
+                                       remote-endpoint = <&lvds0_out>;
+                               };
+                       };
+
+                       port@2 {
+                               reg = <2>;
+                               thc63lvd1024_out: endpoint {
+                                       remote-endpoint = <&adv7511_in>;
+                               };
+                       };
+               };
+       };
 };
 
 &avb {
+       pinctrl-0 = <&avb_pins>;
+       pinctrl-names = "default";
+
        renesas,no-ether-link;
        phy-handle = <&phy0>;
        phy-mode = "rgmii-id";
@@ -47,6 +95,16 @@ phy0: ethernet-phy@0 {
        };
 };
 
+&canfd {
+       pinctrl-0 = <&canfd0_pins>;
+       pinctrl-names = "default";
+       status = "okay";
+
+       channel0 {
+               status = "okay";
+       };
+};
+
 &extal_clk {
        clock-frequency = <16666666>;
 };
@@ -68,9 +126,51 @@ io_expander: gpio@20 {
                gpio-controller;
                #gpio-cells = <2>;
        };
+
+       hdmi@39 {
+               compatible = "adi,adv7511w";
+               reg = <0x39>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <20 IRQ_TYPE_LEVEL_LOW>;
+
+               adi,input-depth = <8>;
+               adi,input-colorspace = "rgb";
+               adi,input-clock = "1x";
+               adi,input-style = <1>;
+               adi,input-justification = "evenly";
+
+               ports {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       port@0 {
+                               reg = <0>;
+                               adv7511_in: endpoint {
+                                       remote-endpoint = <&thc63lvd1024_out>;
+                               };
+                       };
+
+                       port@1 {
+                               reg = <1>;
+                               adv7511_out: endpoint {
+                                       remote-endpoint = <&hdmi_con_out>;
+                               };
+                       };
+               };
+       };
 };
 
 &pfc {
+       avb_pins: avb0 {
+               groups = "avb0_mdio", "avb0_rgmii", "avb0_txcrefclk";
+               function = "avb0";
+       };
+
+       canfd0_pins: canfd0 {
+               groups = "canfd0_data_a";
+               function = "canfd0";
+       };
+
        i2c0_pins: i2c0 {
                groups = "i2c0";
                function = "i2c0";
@@ -93,3 +193,19 @@ &scif0 {
 
        status = "okay";
 };
+
+&du {
+       status = "okay";
+};
+
+&lvds0 {
+       status = "okay";
+
+       ports {
+               port@1 {
+                       lvds0_out: endpoint {
+                               remote-endpoint = <&thc63lvd1024_in>;
+                       };
+               };
+       };
+};
index a8ceeac77992de8c27744bdf118620ceee902cc4..9fce031a596f4060ab8d2408938f6f3859ec2409 100644 (file)
@@ -29,9 +29,71 @@ memory@48000000 {
                /* first 128MB is reserved for secure area. */
                reg = <0x0 0x48000000 0x0 0x38000000>;
        };
+
+       osc5_clk: osc5-clock {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <148500000>;
+       };
+
+       vcc_d1_8v: regulator-0 {
+               compatible = "regulator-fixed";
+               regulator-name = "VCC_D1.8V";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       vcc_d3_3v: regulator-1 {
+               compatible = "regulator-fixed";
+               regulator-name = "VCC_D3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       lvds-decoder {
+               compatible = "thine,thc63lvd1024";
+               vcc-supply = <&vcc_d3_3v>;
+
+               ports {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       port@0 {
+                               reg = <0>;
+                               thc63lvd1024_in: endpoint {
+                                       remote-endpoint = <&lvds0_out>;
+                               };
+                       };
+
+                       port@2 {
+                               reg = <2>;
+                               thc63lvd1024_out: endpoint {
+                                       remote-endpoint = <&adv7511_in>;
+                               };
+                       };
+               };
+       };
+
+       hdmi-out {
+               compatible = "hdmi-connector";
+               type = "a";
+
+               port {
+                       hdmi_con: endpoint {
+                               remote-endpoint = <&adv7511_out>;
+                       };
+               };
+       };
 };
 
 &avb {
+       pinctrl-0 = <&avb_pins>;
+       pinctrl-names = "default";
+
        renesas,no-ether-link;
        phy-handle = <&phy0>;
        phy-mode = "rgmii-id";
@@ -43,6 +105,13 @@ phy0: ethernet-phy@0 {
        };
 };
 
+&du {
+       clocks = <&cpg CPG_MOD 724>,
+                <&osc5_clk>;
+       clock-names = "du.0", "dclkin.0";
+       status = "okay";
+};
+
 &extal_clk {
        clock-frequency = <16666666>;
 };
@@ -52,12 +121,80 @@ &extalr_clk {
 };
 
 &pfc {
+       avb_pins: avb0 {
+               groups = "avb0_mdio", "avb0_rgmii", "avb0_txcrefclk";
+               function = "avb0";
+       };
+
+       i2c0_pins: i2c0 {
+               groups = "i2c0";
+               function = "i2c0";
+       };
+
        scif0_pins: scif0 {
                groups = "scif0_data";
                function = "scif0";
        };
 };
 
+&i2c0 {
+       pinctrl-0 = <&i2c0_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+       clock-frequency = <400000>;
+
+       hdmi@39{
+               compatible = "adi,adv7511w";
+               #sound-dai-cells = <0>;
+               reg = <0x39>;
+               interrupt-parent = <&gpio1>;
+               interrupts = <20 IRQ_TYPE_LEVEL_LOW>;
+               avdd-supply = <&vcc_d1_8v>;
+               dvdd-supply = <&vcc_d1_8v>;
+               pvdd-supply = <&vcc_d1_8v>;
+               bgvdd-supply = <&vcc_d1_8v>;
+               dvdd-3v-supply = <&vcc_d3_3v>;
+
+               adi,input-depth = <8>;
+               adi,input-colorspace = "rgb";
+               adi,input-clock = "1x";
+               adi,input-style = <1>;
+               adi,input-justification = "evenly";
+
+               ports {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+
+                       port@0 {
+                               reg = <0>;
+                               adv7511_in: endpoint {
+                                       remote-endpoint = <&thc63lvd1024_out>;
+                               };
+                       };
+
+                       port@1 {
+                               reg = <1>;
+                               adv7511_out: endpoint {
+                                       remote-endpoint = <&hdmi_con>;
+                               };
+                       };
+               };
+       };
+};
+
+&lvds0 {
+       status = "okay";
+
+       ports {
+               port@1 {
+                       lvds0_out: endpoint {
+                               remote-endpoint = <&thc63lvd1024_in>;
+                       };
+               };
+       };
+};
+
 &scif0 {
        pinctrl-0 = <&scif0_pins>;
        pinctrl-names = "default";
index c6db8ea4390624c4f2fce952738995f00dccc76b..98a2317a16c470bb46aff506f0bb7ee9a7d47f4c 100644 (file)
@@ -41,6 +41,16 @@ a53_0: cpu@0 {
                        enable-method = "psci";
                };
 
+               a53_1: cpu@1 {
+                       device_type = "cpu";
+                       compatible = "arm,cortex-a53", "arm,armv8";
+                       reg = <1>;
+                       clocks = <&cpg CPG_CORE R8A77970_CLK_Z2>;
+                       power-domains = <&sysc R8A77970_PD_CA53_CPU1>;
+                       next-level-cache = <&L2_CA53>;
+                       enable-method = "psci";
+               };
+
                L2_CA53: cache-controller {
                        compatible = "cache";
                        power-domains = <&sysc R8A77970_PD_CA53_SCU>;
@@ -63,11 +73,25 @@ extalr_clk: extalr {
                clock-frequency = <0>;
        };
 
+       pmu_a53 {
+               compatible = "arm,cortex-a53-pmu";
+               interrupts-extended = <&gic GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>,
+                                     <&gic GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&a53_0>, <&a53_1>;
+       };
+
        psci {
                compatible = "arm,psci-1.0", "arm,psci-0.2";
                method = "smc";
        };
 
+       /* External CAN clock - to be overridden by boards that provide it */
+       can_clk: can {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
+
        /* External SCIF clock - to be overridden by boards that provide it */
        scif_clk: scif {
                compatible = "fixed-clock";
@@ -83,23 +107,6 @@ soc {
                #size-cells = <2>;
                ranges;
 
-               gic: interrupt-controller@f1010000 {
-                       compatible = "arm,gic-400";
-                       #interrupt-cells = <3>;
-                       #address-cells = <0>;
-                       interrupt-controller;
-                       reg = <0 0xf1010000 0 0x1000>,
-                             <0 0xf1020000 0 0x20000>,
-                             <0 0xf1040000 0 0x20000>,
-                             <0 0xf1060000 0 0x20000>;
-                       interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(1) |
-                                     IRQ_TYPE_LEVEL_HIGH)>;
-                       clocks = <&cpg CPG_MOD 408>;
-                       clock-names = "clk";
-                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
-                       resets = <&cpg 408>;
-               };
-
                rwdt: watchdog@e6020000 {
                        compatible = "renesas,r8a77970-wdt",
                                     "renesas,rcar-gen3-wdt";
@@ -110,75 +117,6 @@ rwdt: watchdog@e6020000 {
                        status = "disabled";
                };
 
-               cpg: clock-controller@e6150000 {
-                       compatible = "renesas,r8a77970-cpg-mssr";
-                       reg = <0 0xe6150000 0 0x1000>;
-                       clocks = <&extal_clk>, <&extalr_clk>;
-                       clock-names = "extal", "extalr";
-                       #clock-cells = <2>;
-                       #power-domain-cells = <0>;
-                       #reset-cells = <1>;
-               };
-
-               rst: reset-controller@e6160000 {
-                       compatible = "renesas,r8a77970-rst";
-                       reg = <0 0xe6160000 0 0x200>;
-               };
-
-               sysc: system-controller@e6180000 {
-                       compatible = "renesas,r8a77970-sysc";
-                       reg = <0 0xe6180000 0 0x440>;
-                       #power-domain-cells = <1>;
-               };
-
-               ipmmu_vi0: mmu@febd0000 {
-                       compatible = "renesas,ipmmu-r8a77970";
-                       reg = <0 0xfebd0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 9>;
-                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
-               };
-
-               ipmmu_ir: mmu@ff8b0000 {
-                       compatible = "renesas,ipmmu-r8a77970";
-                       reg = <0 0xff8b0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 3>;
-                       power-domains = <&sysc R8A77970_PD_A3IR>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
-               };
-
-               ipmmu_rt: mmu@ffc80000 {
-                       compatible = "renesas,ipmmu-r8a77970";
-                       reg = <0 0xffc80000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 7>;
-                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-               };
-
-               ipmmu_ds1: mmu@e7740000 {
-                       compatible = "renesas,ipmmu-r8a77970";
-                       reg = <0 0xe7740000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 1>;
-                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-               };
-
-               ipmmu_mm: mmu@e67b0000 {
-                       compatible = "renesas,ipmmu-r8a77970";
-                       reg = <0 0xe67b0000 0 0x1000>;
-                       interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
-                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
-                       #iommu-cells = <1>;
-               };
-
-               pfc: pin-controller@e6060000 {
-                       compatible = "renesas,pfc-r8a77970";
-                       reg = <0 0xe6060000 0 0x504>;
-               };
-
                gpio0: gpio@e6050000 {
                        compatible = "renesas,gpio-r8a77970",
                                     "renesas,rcar-gen3-gpio";
@@ -269,6 +207,32 @@ gpio5: gpio@e6055000 {
                        resets = <&cpg 907>;
                };
 
+               pfc: pin-controller@e6060000 {
+                       compatible = "renesas,pfc-r8a77970";
+                       reg = <0 0xe6060000 0 0x504>;
+               };
+
+               cpg: clock-controller@e6150000 {
+                       compatible = "renesas,r8a77970-cpg-mssr";
+                       reg = <0 0xe6150000 0 0x1000>;
+                       clocks = <&extal_clk>, <&extalr_clk>;
+                       clock-names = "extal", "extalr";
+                       #clock-cells = <2>;
+                       #power-domain-cells = <0>;
+                       #reset-cells = <1>;
+               };
+
+               rst: reset-controller@e6160000 {
+                       compatible = "renesas,r8a77970-rst";
+                       reg = <0 0xe6160000 0 0x200>;
+               };
+
+               sysc: system-controller@e6180000 {
+                       compatible = "renesas,r8a77970-sysc";
+                       reg = <0 0xe6180000 0 0x440>;
+                       #power-domain-cells = <1>;
+               };
+
                intc_ex: interrupt-controller@e61c0000 {
                        compatible = "renesas,intc-ex-r8a77970", "renesas,irqc";
                        #interrupt-cells = <2>;
@@ -285,67 +249,6 @@ GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH
                        resets = <&cpg 407>;
                };
 
-               prr: chipid@fff00044 {
-                       compatible = "renesas,prr";
-                       reg = <0 0xfff00044 0 4>;
-               };
-
-               dmac1: dma-controller@e7300000 {
-                       compatible = "renesas,dmac-r8a77970",
-                                    "renesas,rcar-dmac";
-                       reg = <0 0xe7300000 0 0x10000>;
-                       interrupts = <GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 216 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 218 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "error",
-                                         "ch0", "ch1", "ch2", "ch3",
-                                         "ch4", "ch5", "ch6", "ch7";
-                       clocks = <&cpg CPG_MOD 218>;
-                       clock-names = "fck";
-                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
-                       resets = <&cpg 218>;
-                       #dma-cells = <1>;
-                       dma-channels = <8>;
-                       iommus = <&ipmmu_ds1 0>, <&ipmmu_ds1 1>,
-                              <&ipmmu_ds1 2>, <&ipmmu_ds1 3>,
-                              <&ipmmu_ds1 4>, <&ipmmu_ds1 5>,
-                              <&ipmmu_ds1 6>, <&ipmmu_ds1 7>;
-               };
-
-               dmac2: dma-controller@e7310000 {
-                       compatible = "renesas,dmac-r8a77970",
-                                    "renesas,rcar-dmac";
-                       reg = <0 0xe7310000 0 0x10000>;
-                       interrupts = <GIC_SPI 307 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 313 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 314 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 315 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 316 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 317 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 318 IRQ_TYPE_LEVEL_HIGH
-                                     GIC_SPI 319 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "error",
-                                         "ch0", "ch1", "ch2", "ch3",
-                                         "ch4", "ch5", "ch6", "ch7";
-                       clocks = <&cpg CPG_MOD 217>;
-                       clock-names = "fck";
-                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
-                       resets = <&cpg 217>;
-                       #dma-cells = <1>;
-                       dma-channels = <8>;
-                       iommus = <&ipmmu_ds1 16>, <&ipmmu_ds1 17>,
-                              <&ipmmu_ds1 18>, <&ipmmu_ds1 19>,
-                              <&ipmmu_ds1 20>, <&ipmmu_ds1 21>,
-                              <&ipmmu_ds1 22>, <&ipmmu_ds1 23>;
-               };
-
                i2c0: i2c@e6500000 {
                        compatible = "renesas,i2c-r8a77970",
                                     "renesas,rcar-gen3-i2c";
@@ -502,6 +405,77 @@ hscif3: serial@e66a0000 {
                        status = "disabled";
                };
 
+               canfd: can@e66c0000 {
+                       compatible = "renesas,r8a77970-canfd",
+                                    "renesas,rcar-gen3-canfd";
+                       reg = <0 0xe66c0000 0 0x8000>;
+                       interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 914>,
+                                <&cpg CPG_CORE R8A77970_CLK_CANFD>,
+                                <&can_clk>;
+                       clock-names = "fck", "canfd", "can_clk";
+                       assigned-clocks = <&cpg CPG_CORE R8A77970_CLK_CANFD>;
+                       assigned-clock-rates = <40000000>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 914>;
+                       status = "disabled";
+
+                       channel0 {
+                               status = "disabled";
+                       };
+
+                       channel1 {
+                               status = "disabled";
+                       };
+               };
+
+               avb: ethernet@e6800000 {
+                       compatible = "renesas,etheravb-r8a77970",
+                                    "renesas,etheravb-rcar-gen3";
+                       reg = <0 0xe6800000 0 0x800>;
+                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1", "ch2", "ch3",
+                                         "ch4", "ch5", "ch6", "ch7",
+                                         "ch8", "ch9", "ch10", "ch11",
+                                         "ch12", "ch13", "ch14", "ch15",
+                                         "ch16", "ch17", "ch18", "ch19",
+                                         "ch20", "ch21", "ch22", "ch23",
+                                         "ch24";
+                       clocks = <&cpg CPG_MOD 812>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 812>;
+                       phy-mode = "rgmii";
+                       iommus = <&ipmmu_rt 3>;
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
                scif0: serial@e6e60000 {
                        compatible = "renesas,scif-r8a77970",
                                     "renesas,rcar-gen3-scif",
@@ -573,57 +547,358 @@ scif4: serial@e6c40000 {
                        status = "disabled";
                };
 
-               avb: ethernet@e6800000 {
-                       compatible = "renesas,etheravb-r8a77970",
-                                    "renesas,etheravb-rcar-gen3";
-                       reg = <0 0xe6800000 0 0x800>;
-                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
-                       interrupt-names = "ch0", "ch1", "ch2", "ch3",
-                                         "ch4", "ch5", "ch6", "ch7",
-                                         "ch8", "ch9", "ch10", "ch11",
-                                         "ch12", "ch13", "ch14", "ch15",
-                                         "ch16", "ch17", "ch18", "ch19",
-                                         "ch20", "ch21", "ch22", "ch23",
-                                         "ch24";
-                       clocks = <&cpg CPG_MOD 812>;
+
+               vin0: video@e6ef0000 {
+                       compatible = "renesas,vin-r8a77970";
+                       reg = <0 0xe6ef0000 0 0x1000>;
+                       interrupts = <GIC_SPI 188 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 811>;
                        power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
-                       resets = <&cpg 812>;
-                       phy-mode = "rgmii";
-                       iommus = <&ipmmu_rt 3>;
-                       #address-cells = <1>;
-                       #size-cells = <0>;
+                       resets = <&cpg 811>;
+                       renesas,id = <0>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin0csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin0>;
+                                       };
+                               };
+                       };
+               };
+
+               vin1: video@e6ef1000 {
+                       compatible = "renesas,vin-r8a77970";
+                       reg = <0 0xe6ef1000 0 0x1000>;
+                       interrupts = <GIC_SPI 189 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 810>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 810>;
+                       renesas,id = <1>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin1csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin1>;
+                                       };
+                               };
+                       };
+               };
+
+               vin2: video@e6ef2000 {
+                       compatible = "renesas,vin-r8a77970";
+                       reg = <0 0xe6ef2000 0 0x1000>;
+                       interrupts = <GIC_SPI 190 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 809>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 809>;
+                       renesas,id = <2>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin2csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin2>;
+                                       };
+                               };
+                       };
+               };
+
+               vin3: video@e6ef3000 {
+                       compatible = "renesas,vin-r8a77970";
+                       reg = <0 0xe6ef3000 0 0x1000>;
+                       interrupts = <GIC_SPI 191 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 808>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 808>;
+                       renesas,id = <3>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       vin3csi40: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint= <&csi40vin3>;
+                                       };
+                               };
+                       };
+               };
+
+               dmac1: dma-controller@e7300000 {
+                       compatible = "renesas,dmac-r8a77970",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xe7300000 0 0x10000>;
+                       interrupts = <GIC_SPI 220 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 216 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 218 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 219 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 308 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 309 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 310 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 311 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                         "ch0", "ch1", "ch2", "ch3",
+                                         "ch4", "ch5", "ch6", "ch7";
+                       clocks = <&cpg CPG_MOD 218>;
+                       clock-names = "fck";
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 218>;
+                       #dma-cells = <1>;
+                       dma-channels = <8>;
+                       iommus = <&ipmmu_ds1 0>, <&ipmmu_ds1 1>,
+                              <&ipmmu_ds1 2>, <&ipmmu_ds1 3>,
+                              <&ipmmu_ds1 4>, <&ipmmu_ds1 5>,
+                              <&ipmmu_ds1 6>, <&ipmmu_ds1 7>;
+               };
+
+               dmac2: dma-controller@e7310000 {
+                       compatible = "renesas,dmac-r8a77970",
+                                    "renesas,rcar-dmac";
+                       reg = <0 0xe7310000 0 0x10000>;
+                       interrupts = <GIC_SPI 307 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 312 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 313 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 314 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 315 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 316 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 317 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 318 IRQ_TYPE_LEVEL_HIGH
+                                     GIC_SPI 319 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "error",
+                                         "ch0", "ch1", "ch2", "ch3",
+                                         "ch4", "ch5", "ch6", "ch7";
+                       clocks = <&cpg CPG_MOD 217>;
+                       clock-names = "fck";
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 217>;
+                       #dma-cells = <1>;
+                       dma-channels = <8>;
+                       iommus = <&ipmmu_ds1 16>, <&ipmmu_ds1 17>,
+                              <&ipmmu_ds1 18>, <&ipmmu_ds1 19>,
+                              <&ipmmu_ds1 20>, <&ipmmu_ds1 21>,
+                              <&ipmmu_ds1 22>, <&ipmmu_ds1 23>;
+               };
+
+               ipmmu_ds1: mmu@e7740000 {
+                       compatible = "renesas,ipmmu-r8a77970";
+                       reg = <0 0xe7740000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 0>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_ir: mmu@ff8b0000 {
+                       compatible = "renesas,ipmmu-r8a77970";
+                       reg = <0 0xff8b0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 3>;
+                       power-domains = <&sysc R8A77970_PD_A3IR>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_mm: mmu@e67b0000 {
+                       compatible = "renesas,ipmmu-r8a77970";
+                       reg = <0 0xe67b0000 0 0x1000>;
+                       interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_rt: mmu@ffc80000 {
+                       compatible = "renesas,ipmmu-r8a77970";
+                       reg = <0 0xffc80000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 7>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vi0: mmu@febd0000 {
+                       compatible = "renesas,ipmmu-r8a77970";
+                       reg = <0 0xfebd0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 9>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       #iommu-cells = <1>;
+               };
+
+               gic: interrupt-controller@f1010000 {
+                       compatible = "arm,gic-400";
+                       #interrupt-cells = <3>;
+                       #address-cells = <0>;
+                       interrupt-controller;
+                       reg = <0 0xf1010000 0 0x1000>,
+                             <0 0xf1020000 0 0x20000>,
+                             <0 0xf1040000 0 0x20000>,
+                             <0 0xf1060000 0 0x20000>;
+                       interrupts = <GIC_PPI 9 (GIC_CPU_MASK_SIMPLE(2) |
+                                     IRQ_TYPE_LEVEL_HIGH)>;
+                       clocks = <&cpg CPG_MOD 408>;
+                       clock-names = "clk";
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 408>;
+               };
+
+               vspd0: vsp@fea20000 {
+                       compatible = "renesas,vsp2";
+                       reg = <0 0xfea20000 0 0x8000>;
+                       interrupts = <GIC_SPI 169 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 623>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 623>;
+                       renesas,fcp = <&fcpvd0>;
+               };
+
+               fcpvd0: fcp@fea27000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea27000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 603>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 603>;
+               };
+
+               csi40: csi2@feaa0000 {
+                       compatible = "renesas,r8a77970-csi2";
+                       reg = <0 0xfeaa0000 0 0x10000>;
+                       interrupts = <GIC_SPI 246 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 716>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 716>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@1 {
+                                       #address-cells = <1>;
+                                       #size-cells = <0>;
+
+                                       reg = <1>;
+
+                                       csi40vin0: endpoint@0 {
+                                               reg = <0>;
+                                               remote-endpoint = <&vin0csi40>;
+                                       };
+                                       csi40vin1: endpoint@1 {
+                                               reg = <1>;
+                                               remote-endpoint = <&vin1csi40>;
+                                       };
+                                       csi40vin2: endpoint@2 {
+                                               reg = <2>;
+                                               remote-endpoint = <&vin2csi40>;
+                                       };
+                                       csi40vin3: endpoint@3 {
+                                               reg = <3>;
+                                               remote-endpoint = <&vin3csi40>;
+                                       };
+                               };
+                       };
+               };
+
+               du: display@feb00000 {
+                       compatible = "renesas,du-r8a77970";
+                       reg = <0 0xfeb00000 0 0x80000>;
+                       interrupts = <GIC_SPI 256 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 724>;
+                       clock-names = "du.0";
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 724>;
+                       vsps = <&vspd0>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@0 {
+                                       reg = <0>;
+                                       du_out_rgb: endpoint {
+                                       };
+                               };
+
+                               port@1 {
+                                       reg = <1>;
+                                       du_out_lvds0: endpoint {
+                                               remote-endpoint = <&lvds0_in>;
+                                       };
+                               };
+                       };
+               };
+
+               lvds0: lvds-encoder@feb90000 {
+                       compatible = "renesas,r8a77970-lvds";
+                       reg = <0 0xfeb90000 0 0x14>;
+                       clocks = <&cpg CPG_MOD 727>;
+                       power-domains = <&sysc R8A77970_PD_ALWAYS_ON>;
+                       resets = <&cpg 727>;
+                       status = "disabled";
+
+                       ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port@0 {
+                                       reg = <0>;
+                                       lvds0_in: endpoint {
+                                               remote-endpoint =
+                                                       <&du_out_lvds0>;
+                                       };
+                               };
+                               port@1 {
+                                       reg = <1>;
+                                       lvds0_out: endpoint {
+                                       };
+                               };
+                       };
+               };
+
+               prr: chipid@fff00044 {
+                       compatible = "renesas,prr";
+                       reg = <0 0xfff00044 0 4>;
                };
        };
 
        timer {
                compatible = "arm,armv8-timer";
-               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
-                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>;
+               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(2) | IRQ_TYPE_LEVEL_LOW)>;
        };
 };
index 06cf6845765ad75590e6e85a8eeb360bb631cbb2..0b93a7d765859a1feb539350d7790cc7d5a0b918 100644 (file)
@@ -27,9 +27,30 @@ memory@48000000 {
                /* first 128MB is reserved for secure area. */
                reg = <0 0x48000000 0 0x78000000>;
        };
+
+       d3_3v: regulator-0 {
+               compatible = "regulator-fixed";
+               regulator-name = "D3.3V";
+               regulator-min-microvolt = <3300000>;
+               regulator-max-microvolt = <3300000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
+
+       vddq_vin01: regulator-1 {
+               compatible = "regulator-fixed";
+               regulator-name = "VDDQ_VIN01";
+               regulator-min-microvolt = <1800000>;
+               regulator-max-microvolt = <1800000>;
+               regulator-boot-on;
+               regulator-always-on;
+       };
 };
 
 &avb {
+       pinctrl-0 = <&avb_pins>;
+       pinctrl-names = "default";
+
        phy-mode = "rgmii-id";
        phy-handle = <&phy0>;
        renesas,no-ether-link;
@@ -41,6 +62,16 @@ phy0: ethernet-phy@0 {
        };
 };
 
+&canfd {
+       pinctrl-0 = <&canfd0_pins>;
+       pinctrl-names = "default";
+       status = "okay";
+
+       channel0 {
+               status = "okay";
+       };
+};
+
 &extal_clk {
        clock-frequency = <16666666>;
 };
@@ -49,7 +80,57 @@ &extalr_clk {
        clock-frequency = <32768>;
 };
 
+&mmc0 {
+       pinctrl-0 = <&mmc_pins>;
+       pinctrl-1 = <&mmc_pins_uhs>;
+       pinctrl-names = "default", "state_uhs";
+
+       vmmc-supply = <&d3_3v>;
+       vqmmc-supply = <&vddq_vin01>;
+       mmc-hs200-1_8v;
+       bus-width = <8>;
+       non-removable;
+       status = "okay";
+};
+
+&pfc {
+       avb_pins: avb {
+               groups = "avb_mdio", "avb_rgmii";
+               function = "avb";
+       };
+
+       canfd0_pins: canfd0 {
+               groups = "canfd0_data_a";
+               function = "canfd0";
+       };
+
+       mmc_pins: mmc {
+               groups = "mmc_data8", "mmc_ctrl", "mmc_ds";
+               function = "mmc";
+               power-source = <3300>;
+       };
+
+       mmc_pins_uhs: mmc_uhs {
+               groups = "mmc_data8", "mmc_ctrl", "mmc_ds";
+               function = "mmc";
+               power-source = <1800>;
+       };
+
+       scif0_pins: scif0 {
+               groups = "scif0_data";
+               function = "scif0";
+       };
+
+       scif_clk_pins: scif_clk {
+               groups = "scif_clk_b";
+               function = "scif_clk";
+       };
+};
+
 &scif0 {
+       pinctrl-0 = <&scif0_pins>, <&scif_clk_pins>;
+       pinctrl-names = "default";
+
        status = "okay";
 };
 
diff --git a/arch/arm64/boot/dts/renesas/r8a77980-v3hsk.dts b/arch/arm64/boot/dts/renesas/r8a77980-v3hsk.dts
new file mode 100644 (file)
index 0000000..c968099
--- /dev/null
@@ -0,0 +1,60 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Device Tree Source for the V3H Starter Kit board
+ *
+ * Copyright (C) 2018 Renesas Electronics Corp.
+ * Copyright (C) 2018 Cogent Embedded, Inc.
+ */
+
+/dts-v1/;
+#include "r8a77980.dtsi"
+
+/ {
+       model = "Renesas V3H Starter Kit board";
+       compatible = "renesas,v3hsk", "renesas,r8a77980";
+
+       aliases {
+               serial0 = &scif0;
+       };
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       memory@48000000 {
+               device_type = "memory";
+               /* first 128MB is reserved for secure area. */
+               reg = <0 0x48000000 0 0x78000000>;
+       };
+};
+
+&extal_clk {
+       clock-frequency = <16666666>;
+};
+
+&extalr_clk {
+       clock-frequency = <32768>;
+};
+
+&pfc {
+       scif0_pins: scif0 {
+               groups = "scif0_data";
+               function = "scif0";
+       };
+
+       scif_clk_pins: scif_clk {
+               groups = "scif_clk_b";
+               function = "scif_clk";
+       };
+};
+
+&scif0 {
+       pinctrl-0 = <&scif0_pins>, <&scif_clk_pins>;
+       pinctrl-names = "default";
+
+       status = "okay";
+};
+
+&scif_clk {
+       clock-frequency = <14745600>;
+};
index 03845fd74996d479a22e5394c1f92282de6f633e..4c40f9f0ebc9ea7f93981a60b491b8144c63ce4f 100644 (file)
@@ -6,9 +6,10 @@
  * Copyright (C) 2018 Cogent Embedded, Inc.
  */
 
+#include <dt-bindings/clock/r8a77980-cpg-mssr.h>
 #include <dt-bindings/interrupt-controller/irq.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
-#include <dt-bindings/clock/renesas-cpg-mssr.h>
+#include <dt-bindings/power/r8a77980-sysc.h>
 
 / {
        compatible = "renesas,r8a77980";
@@ -23,20 +24,27 @@ a53_0: cpu@0 {
                        device_type = "cpu";
                        compatible = "arm,cortex-a53", "arm,armv8";
                        reg = <0>;
-                       clocks = <&cpg CPG_CORE 0>;
-                       power-domains = <&sysc 5>;
+                       clocks = <&cpg CPG_CORE R8A77980_CLK_Z2>;
+                       power-domains = <&sysc R8A77980_PD_CA53_CPU0>;
                        next-level-cache = <&L2_CA53>;
                        enable-method = "psci";
                };
 
                L2_CA53: cache-controller {
                        compatible = "cache";
-                       power-domains = <&sysc 21>;
+                       power-domains = <&sysc R8A77980_PD_CA53_SCU>;
                        cache-unified;
                        cache-level = <2>;
                };
        };
 
+       /* External CAN clock - to be overridden by boards that provide it */
+       can_clk: can {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
+       };
+
        extal_clk: extal {
                compatible = "fixed-clock";
                #clock-cells = <0>;
@@ -71,6 +79,11 @@ soc {
                #size-cells = <2>;
                ranges;
 
+               pfc: pin-controller@e6060000 {
+                       compatible = "renesas,pfc-r8a77980";
+                       reg = <0 0xe6060000 0 0x50c>;
+               };
+
                cpg: clock-controller@e6150000 {
                        compatible = "renesas,r8a77980-cpg-mssr";
                        reg = <0 0xe6150000 0 0x1000>;
@@ -99,13 +112,13 @@ hscif0: serial@e6540000 {
                        reg = <0 0xe6540000 0 0x60>;
                        interrupts = <GIC_SPI 154 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 520>,
-                                <&cpg CPG_CORE 19>,
+                                <&cpg CPG_CORE R8A77980_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac1 0x31>, <&dmac1 0x30>,
                               <&dmac2 0x31>, <&dmac2 0x30>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 520>;
                        status = "disabled";
                };
@@ -117,13 +130,13 @@ hscif1: serial@e6550000 {
                        reg = <0 0xe6550000 0 0x60>;
                        interrupts = <GIC_SPI 155 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 519>,
-                                <&cpg CPG_CORE 19>,
+                                <&cpg CPG_CORE R8A77980_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac1 0x33>, <&dmac1 0x32>,
                               <&dmac2 0x33>, <&dmac2 0x32>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 519>;
                        status = "disabled";
                };
@@ -135,13 +148,13 @@ hscif2: serial@e6560000 {
                        reg = <0 0xe6560000 0 0x60>;
                        interrupts = <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 518>,
-                                <&cpg CPG_CORE 19>,
+                                <&cpg CPG_CORE R8A77980_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac1 0x35>, <&dmac1 0x34>,
                               <&dmac2 0x35>, <&dmac2 0x34>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 518>;
                        status = "disabled";
                };
@@ -153,17 +166,42 @@ hscif3: serial@e66a0000 {
                        reg = <0 0xe66a0000 0 0x60>;
                        interrupts = <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 517>,
-                                <&cpg CPG_CORE 19>,
+                                <&cpg CPG_CORE R8A77980_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac1 0x37>, <&dmac1 0x36>,
                               <&dmac2 0x37>, <&dmac2 0x36>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 517>;
                        status = "disabled";
                };
 
+               canfd: can@e66c0000 {
+                       compatible = "renesas,r8a77980-canfd",
+                                    "renesas,rcar-gen3-canfd";
+                       reg = <0 0xe66c0000 0 0x8000>;
+                       interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 914>,
+                                <&cpg CPG_CORE R8A77980_CLK_CANFD>,
+                                <&can_clk>;
+                       clock-names = "fck", "canfd", "can_clk";
+                       assigned-clocks = <&cpg CPG_CORE R8A77980_CLK_CANFD>;
+                       assigned-clock-rates = <40000000>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
+                       resets = <&cpg 914>;
+                       status = "disabled";
+
+                       channel0 {
+                               status = "disabled";
+                       };
+
+                       channel1 {
+                               status = "disabled";
+                       };
+               };
+
                avb: ethernet@e6800000 {
                        compatible = "renesas,etheravb-r8a77980",
                                     "renesas,etheravb-rcar-gen3";
@@ -201,11 +239,12 @@ avb: ethernet@e6800000 {
                                          "ch20", "ch21", "ch22", "ch23",
                                          "ch24";
                        clocks = <&cpg CPG_MOD 812>;
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 812>;
                        phy-mode = "rgmii";
                        #address-cells = <1>;
                        #size-cells = <0>;
+                       status = "disabled";
                };
 
                scif0: serial@e6e60000 {
@@ -215,13 +254,13 @@ scif0: serial@e6e60000 {
                        reg = <0 0xe6e60000 0 0x40>;
                        interrupts = <GIC_SPI 152 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 207>,
-                                <&cpg CPG_CORE 19>,
+                                <&cpg CPG_CORE R8A77980_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac1 0x51>, <&dmac1 0x50>,
                               <&dmac2 0x51>, <&dmac2 0x50>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 207>;
                        status = "disabled";
                };
@@ -233,13 +272,13 @@ scif1: serial@e6e68000 {
                        reg = <0 0xe6e68000 0 0x40>;
                        interrupts = <GIC_SPI 153 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 206>,
-                                <&cpg CPG_CORE 19>,
+                                <&cpg CPG_CORE R8A77980_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac1 0x53>, <&dmac1 0x52>,
                               <&dmac2 0x53>, <&dmac2 0x52>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 206>;
                        status = "disabled";
                };
@@ -251,13 +290,13 @@ scif3: serial@e6c50000 {
                        reg = <0 0xe6c50000 0 0x40>;
                        interrupts = <GIC_SPI 23 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 204>,
-                                <&cpg CPG_CORE 19>,
+                                <&cpg CPG_CORE R8A77980_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac1 0x57>, <&dmac1 0x56>,
                               <&dmac2 0x57>, <&dmac2 0x56>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 204>;
                        status = "disabled";
                };
@@ -269,13 +308,13 @@ scif4: serial@e6c40000 {
                        reg = <0 0xe6c40000 0 0x40>;
                        interrupts = <GIC_SPI 16 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 203>,
-                                <&cpg CPG_CORE 19>,
+                                <&cpg CPG_CORE R8A77980_CLK_S3D1>,
                                 <&scif_clk>;
                        clock-names = "fck", "brg_int", "scif_clk";
                        dmas = <&dmac1 0x59>, <&dmac1 0x58>,
                               <&dmac2 0x59>, <&dmac2 0x58>;
                        dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 203>;
                        status = "disabled";
                };
@@ -308,7 +347,7 @@ GIC_SPI 359 IRQ_TYPE_LEVEL_HIGH
                                          "ch12", "ch13", "ch14", "ch15";
                        clocks = <&cpg CPG_MOD 218>;
                        clock-names = "fck";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 218>;
                        #dma-cells = <1>;
                        dma-channels = <16>;
@@ -342,12 +381,24 @@ GIC_SPI 367 IRQ_TYPE_LEVEL_HIGH
                                          "ch12", "ch13", "ch14", "ch15";
                        clocks = <&cpg CPG_MOD 217>;
                        clock-names = "fck";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 217>;
                        #dma-cells = <1>;
                        dma-channels = <16>;
                };
 
+               mmc0: mmc@ee140000 {
+                       compatible = "renesas,sdhi-r8a77980",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee140000 0 0x2000>;
+                       interrupts = <GIC_SPI 165 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 314>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
+                       resets = <&cpg 314>;
+                       max-frequency = <200000000>;
+                       status = "disabled";
+               };
+
                gic: interrupt-controller@f1010000 {
                        compatible = "arm,gic-400";
                        #interrupt-cells = <3>;
@@ -361,7 +412,7 @@ gic: interrupt-controller@f1010000 {
                                      IRQ_TYPE_LEVEL_HIGH)>;
                        clocks = <&cpg CPG_MOD 408>;
                        clock-names = "clk";
-                       power-domains = <&sysc 32>;
+                       power-domains = <&sysc R8A77980_PD_ALWAYS_ON>;
                        resets = <&cpg 408>;
                };
 
diff --git a/arch/arm64/boot/dts/renesas/r8a77990-ebisu.dts b/arch/arm64/boot/dts/renesas/r8a77990-ebisu.dts
new file mode 100644 (file)
index 0000000..7a09d05
--- /dev/null
@@ -0,0 +1,65 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Device Tree Source for the ebisu board
+ *
+ * Copyright (C) 2018 Renesas Electronics Corp.
+ */
+
+/dts-v1/;
+#include "r8a77990.dtsi"
+#include <dt-bindings/gpio/gpio.h>
+
+/ {
+       model = "Renesas Ebisu board based on r8a77990";
+       compatible = "renesas,ebisu", "renesas,r8a77990";
+
+       aliases {
+               serial0 = &scif2;
+               ethernet0 = &avb;
+       };
+
+       chosen {
+               bootargs = "ignore_loglevel";
+               stdout-path = "serial0:115200n8";
+       };
+
+       memory@48000000 {
+               device_type = "memory";
+               /* first 128MB is reserved for secure area. */
+               reg = <0x0 0x48000000 0x0 0x38000000>;
+       };
+};
+
+&avb {
+       pinctrl-0 = <&avb_pins>;
+       pinctrl-names = "default";
+       renesas,no-ether-link;
+       phy-handle = <&phy0>;
+       phy-mode = "rgmii-txid";
+       status = "okay";
+
+       phy0: ethernet-phy@0 {
+               rxc-skew-ps = <1500>;
+               reg = <0>;
+               interrupt-parent = <&gpio2>;
+               interrupts = <21 IRQ_TYPE_LEVEL_LOW>;
+               reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>;
+       };
+};
+
+&extal_clk {
+       clock-frequency = <48000000>;
+};
+
+&pfc {
+       avb_pins: avb {
+               mux {
+                       groups = "avb_link", "avb_mii";
+                       function = "avb";
+               };
+       };
+};
+
+&scif2 {
+       status = "okay";
+};
diff --git a/arch/arm64/boot/dts/renesas/r8a77990.dtsi b/arch/arm64/boot/dts/renesas/r8a77990.dtsi
new file mode 100644 (file)
index 0000000..be4f519
--- /dev/null
@@ -0,0 +1,281 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Device Tree Source for the r8a77990 SoC
+ *
+ * Copyright (C) 2018 Renesas Electronics Corp.
+ */
+
+#include <dt-bindings/clock/renesas-cpg-mssr.h>
+#include <dt-bindings/interrupt-controller/arm-gic.h>
+
+/ {
+       compatible = "renesas,r8a77990";
+       #address-cells = <2>;
+       #size-cells = <2>;
+
+       cpus {
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               /* 1 core only at this point */
+               a53_0: cpu@0 {
+                       compatible = "arm,cortex-a53", "arm,armv8";
+                       reg = <0x0>;
+                       device_type = "cpu";
+                       power-domains = <&sysc 5>;
+                       next-level-cache = <&L2_CA53>;
+                       enable-method = "psci";
+               };
+
+               L2_CA53: cache-controller-0 {
+                       compatible = "cache";
+                       power-domains = <&sysc 21>;
+                       cache-unified;
+                       cache-level = <2>;
+               };
+       };
+
+       extal_clk: extal {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               /* This value must be overridden by the board */
+               clock-frequency = <0>;
+       };
+
+       pmu_a53 {
+               compatible = "arm,cortex-a53-pmu";
+               interrupts-extended = <&gic GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-affinity = <&a53_0>;
+       };
+
+       psci {
+               compatible = "arm,psci-1.0", "arm,psci-0.2";
+               method = "smc";
+       };
+
+       soc: soc {
+               compatible = "simple-bus";
+               interrupt-parent = <&gic>;
+               #address-cells = <2>;
+               #size-cells = <2>;
+               ranges;
+
+               gpio0: gpio@e6050000 {
+                       compatible = "renesas,gpio-r8a77990",
+                                    "renesas,rcar-gen3-gpio";
+                       reg = <0 0xe6050000 0 0x50>;
+                       interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 0 18>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 912>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 912>;
+               };
+
+               gpio1: gpio@e6051000 {
+                       compatible = "renesas,gpio-r8a77990",
+                                    "renesas,rcar-gen3-gpio";
+                       reg = <0 0xe6051000 0 0x50>;
+                       interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 32 23>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 911>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 911>;
+               };
+
+               gpio2: gpio@e6052000 {
+                       compatible = "renesas,gpio-r8a77990",
+                                    "renesas,rcar-gen3-gpio";
+                       reg = <0 0xe6052000 0 0x50>;
+                       interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 64 26>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 910>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 910>;
+               };
+
+               gpio3: gpio@e6053000 {
+                       compatible = "renesas,gpio-r8a77990",
+                                    "renesas,rcar-gen3-gpio";
+                       reg = <0 0xe6053000 0 0x50>;
+                       interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 96 16>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 909>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 909>;
+               };
+
+               gpio4: gpio@e6054000 {
+                       compatible = "renesas,gpio-r8a77990",
+                                    "renesas,rcar-gen3-gpio";
+                       reg = <0 0xe6054000 0 0x50>;
+                       interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 128 11>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 908>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 908>;
+               };
+
+               gpio5: gpio@e6055000 {
+                       compatible = "renesas,gpio-r8a77990",
+                                    "renesas,rcar-gen3-gpio";
+                       reg = <0 0xe6055000 0 0x50>;
+                       interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 160 20>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 907>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 907>;
+               };
+
+               gpio6: gpio@e6055400 {
+                       compatible = "renesas,gpio-r8a77990",
+                                    "renesas,rcar-gen3-gpio";
+                       reg = <0 0xe6055400 0 0x50>;
+                       interrupts = <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 192 18>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 906>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 906>;
+               };
+
+               pfc: pin-controller@e6060000 {
+                       compatible = "renesas,pfc-r8a77990";
+                       reg = <0 0xe6060000 0 0x508>;
+               };
+
+               cpg: clock-controller@e6150000 {
+                       compatible = "renesas,r8a77990-cpg-mssr";
+                       reg = <0 0xe6150000 0 0x1000>;
+                       clocks = <&extal_clk>;
+                       clock-names = "extal";
+                       #clock-cells = <2>;
+                       #power-domain-cells = <0>;
+                       #reset-cells = <1>;
+               };
+
+               rst: reset-controller@e6160000 {
+                       compatible = "renesas,r8a77990-rst";
+                       reg = <0 0xe6160000 0 0x0200>;
+               };
+
+               sysc: system-controller@e6180000 {
+                       compatible = "renesas,r8a77990-sysc";
+                       reg = <0 0xe6180000 0 0x0400>;
+                       #power-domain-cells = <1>;
+               };
+
+               avb: ethernet@e6800000 {
+                       compatible = "renesas,etheravb-r8a77990",
+                                    "renesas,etheravb-rcar-gen3";
+                       reg = <0 0xe6800000 0 0x800>, <0 0xe6a00000 0 0x10000>;
+                       interrupts = <GIC_SPI 39 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 40 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 41 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 45 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 46 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 47 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 48 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 51 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 53 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 54 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 55 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 56 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 57 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 58 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 59 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 60 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 62 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 63 IRQ_TYPE_LEVEL_HIGH>;
+                       interrupt-names = "ch0", "ch1", "ch2", "ch3",
+                                         "ch4", "ch5", "ch6", "ch7",
+                                         "ch8", "ch9", "ch10", "ch11",
+                                         "ch12", "ch13", "ch14", "ch15",
+                                         "ch16", "ch17", "ch18", "ch19",
+                                         "ch20", "ch21", "ch22", "ch23",
+                                         "ch24";
+                       clocks = <&cpg CPG_MOD 812>;
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 812>;
+                       phy-mode = "rgmii";
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       status = "disabled";
+               };
+
+               scif2: serial@e6e88000 {
+                       compatible = "renesas,scif-r8a77990",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6e88000 0 64>;
+                       interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 310>;
+                       clock-names = "fck";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 310>;
+                       status = "disabled";
+               };
+
+               gic: interrupt-controller@f1010000 {
+                       compatible = "arm,gic-400";
+                       #interrupt-cells = <3>;
+                       #address-cells = <0>;
+                       interrupt-controller;
+                       reg = <0x0 0xf1010000 0 0x1000>,
+                             <0x0 0xf1020000 0 0x20000>,
+                             <0x0 0xf1040000 0 0x20000>,
+                             <0x0 0xf1060000 0 0x20000>;
+                       interrupts = <GIC_PPI 9
+                                       (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
+                       clocks = <&cpg CPG_MOD 408>;
+                       clock-names = "clk";
+                       power-domains = <&sysc 32>;
+                       resets = <&cpg 408>;
+               };
+
+               prr: chipid@fff00044 {
+                       compatible = "renesas,prr";
+                       reg = <0 0xfff00044 0 4>;
+               };
+       };
+
+       timer {
+               compatible = "arm,armv8-timer";
+               interrupts-extended = <&gic GIC_PPI 13 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 14 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 11 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>,
+                                     <&gic GIC_PPI 10 (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_LOW)>;
+       };
+};
index d03f19414028c6c4e213088e871b62666762c7ad..9d73de8bc94d387398bba01791b2d2888f6dd969 100644 (file)
@@ -91,7 +91,7 @@ &extal_clk {
 &pfc {
        avb0_pins: avb {
                mux {
-                       groups = "avb0_link", "avb0_mdc", "avb0_mii";
+                       groups = "avb0_link", "avb0_mdio", "avb0_mii";
                        function = "avb0";
                };
        };
index 82aed7ee984c34f6faeb464013bd8af03a4e03f2..2506f46293e8a6fc676b87f54bf1540653451a55 100644 (file)
@@ -18,9 +18,11 @@ / {
        #address-cells = <2>;
        #size-cells = <2>;
 
-       psci {
-               compatible = "arm,psci-1.0", "arm,psci-0.2";
-               method = "smc";
+       /* External CAN clock - to be overridden by boards that provide it */
+       can_clk: can {
+               compatible = "fixed-clock";
+               #clock-cells = <0>;
+               clock-frequency = <0>;
        };
 
        cpus {
@@ -51,18 +53,16 @@ extal_clk: extal {
                clock-frequency = <0>;
        };
 
-       /* External CAN clock - to be overridden by boards that provide it */
-       can_clk: can {
-               compatible = "fixed-clock";
-               #clock-cells = <0>;
-               clock-frequency = <0>;
-       };
-
        pmu_a53 {
                compatible = "arm,cortex-a53-pmu";
                interrupts-extended = <&gic GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>;
        };
 
+       psci {
+               compatible = "arm,psci-1.0", "arm,psci-0.2";
+               method = "smc";
+       };
+
        scif_clk: scif {
                compatible = "fixed-clock";
                #clock-cells = <0>;
@@ -76,23 +76,6 @@ soc {
                #size-cells = <2>;
                ranges;
 
-               gic: interrupt-controller@f1010000 {
-                       compatible = "arm,gic-400";
-                       #interrupt-cells = <3>;
-                       #address-cells = <0>;
-                       interrupt-controller;
-                       reg = <0x0 0xf1010000 0 0x1000>,
-                             <0x0 0xf1020000 0 0x20000>,
-                             <0x0 0xf1040000 0 0x20000>,
-                             <0x0 0xf1060000 0 0x20000>;
-                       interrupts = <GIC_PPI 9
-                                       (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
-                       clocks = <&cpg CPG_MOD 408>;
-                       clock-names = "clk";
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 408>;
-               };
-
                rwdt: watchdog@e6020000 {
                        compatible = "renesas,r8a77995-wdt",
                                     "renesas,rcar-gen3-wdt";
@@ -103,88 +86,123 @@ rwdt: watchdog@e6020000 {
                        status = "disabled";
                };
 
-               ipmmu_vi0: mmu@febd0000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xfebd0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 14>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
-               };
-
-               ipmmu_vp0: mmu@fe990000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xfe990000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 16>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
-               };
-
-               ipmmu_vc0: mmu@fe6b0000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xfe6b0000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 12>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+               gpio0: gpio@e6050000 {
+                       compatible = "renesas,gpio-r8a77995",
+                                    "renesas,rcar-gen3-gpio",
+                                    "renesas,gpio-rcar";
+                       reg = <0 0xe6050000 0 0x50>;
+                       interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 0 9>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 912>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 912>;
                };
 
-               ipmmu_pv0: mmu@fd800000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xfd800000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 6>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+               gpio1: gpio@e6051000 {
+                       compatible = "renesas,gpio-r8a77995",
+                                    "renesas,rcar-gen3-gpio",
+                                    "renesas,gpio-rcar";
+                       reg = <0 0xe6051000 0 0x50>;
+                       interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 32 32>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 911>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 911>;
                };
 
-               ipmmu_hc: mmu@e6570000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xe6570000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 2>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+               gpio2: gpio@e6052000 {
+                       compatible = "renesas,gpio-r8a77995",
+                                    "renesas,rcar-gen3-gpio",
+                                    "renesas,gpio-rcar";
+                       reg = <0 0xe6052000 0 0x50>;
+                       interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 64 32>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 910>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 910>;
                };
 
-               ipmmu_rt: mmu@ffc80000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xffc80000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 10>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+               gpio3: gpio@e6053000 {
+                       compatible = "renesas,gpio-r8a77995",
+                                    "renesas,rcar-gen3-gpio",
+                                    "renesas,gpio-rcar";
+                       reg = <0 0xe6053000 0 0x50>;
+                       interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 96 10>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 909>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 909>;
                };
 
-               ipmmu_mp: mmu@ec670000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xec670000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 4>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+               gpio4: gpio@e6054000 {
+                       compatible = "renesas,gpio-r8a77995",
+                                    "renesas,rcar-gen3-gpio",
+                                    "renesas,gpio-rcar";
+                       reg = <0 0xe6054000 0 0x50>;
+                       interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 128 32>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 908>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 908>;
                };
 
-               ipmmu_ds0: mmu@e6740000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xe6740000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 0>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+               gpio5: gpio@e6055000 {
+                       compatible = "renesas,gpio-r8a77995",
+                                    "renesas,rcar-gen3-gpio",
+                                    "renesas,gpio-rcar";
+                       reg = <0 0xe6055000 0 0x50>;
+                       interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 160 21>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 907>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 907>;
                };
 
-               ipmmu_ds1: mmu@e7740000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xe7740000 0 0x1000>;
-                       renesas,ipmmu-main = <&ipmmu_mm 1>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+               gpio6: gpio@e6055400 {
+                       compatible = "renesas,gpio-r8a77995",
+                                    "renesas,rcar-gen3-gpio",
+                                    "renesas,gpio-rcar";
+                       reg = <0 0xe6055400 0 0x50>;
+                       interrupts = <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>;
+                       #gpio-cells = <2>;
+                       gpio-controller;
+                       gpio-ranges = <&pfc 0 192 14>;
+                       #interrupt-cells = <2>;
+                       interrupt-controller;
+                       clocks = <&cpg CPG_MOD 906>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 906>;
                };
 
-               ipmmu_mm: mmu@e67b0000 {
-                       compatible = "renesas,ipmmu-r8a77995";
-                       reg = <0 0xe67b0000 0 0x1000>;
-                       interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
-                                    <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
-                       #iommu-cells = <1>;
-                       status = "disabled";
+               pfc: pin-controller@e6060000 {
+                       compatible = "renesas,pfc-r8a77995";
+                       reg = <0 0xe6060000 0 0x508>;
                };
 
-
                cpg: clock-controller@e6150000 {
                        compatible = "renesas,r8a77995-cpg-mssr";
                        reg = <0 0xe6150000 0 0x1000>;
@@ -200,16 +218,6 @@ rst: reset-controller@e6160000 {
                        reg = <0 0xe6160000 0 0x0200>;
                };
 
-               pfc: pin-controller@e6060000 {
-                       compatible = "renesas,pfc-r8a77995";
-                       reg = <0 0xe6060000 0 0x508>;
-               };
-
-               prr: chipid@fff00044 {
-                       compatible = "renesas,prr";
-                       reg = <0 0xfff00044 0 4>;
-               };
-
                sysc: system-controller@e6180000 {
                        compatible = "renesas,r8a77995-sysc";
                        reg = <0 0xe6180000 0 0x0400>;
@@ -232,6 +240,98 @@ GIC_SPI 18 IRQ_TYPE_LEVEL_HIGH
                        resets = <&cpg 407>;
                };
 
+               i2c0: i2c@e6500000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77995",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6500000 0 0x40>;
+                       interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 931>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 931>;
+                       dmas = <&dmac1 0x91>, <&dmac1 0x90>,
+                              <&dmac2 0x91>, <&dmac2 0x90>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
+                       status = "disabled";
+               };
+
+               i2c1: i2c@e6508000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77995",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6508000 0 0x40>;
+                       interrupts = <GIC_SPI 288 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 930>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 930>;
+                       dmas = <&dmac1 0x93>, <&dmac1 0x92>,
+                              <&dmac2 0x93>, <&dmac2 0x92>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
+                       status = "disabled";
+               };
+
+               i2c2: i2c@e6510000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77995",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe6510000 0 0x40>;
+                       interrupts = <GIC_SPI 286 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 929>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 929>;
+                       dmas = <&dmac1 0x95>, <&dmac1 0x94>,
+                              <&dmac2 0x95>, <&dmac2 0x94>;
+                       dma-names = "tx", "rx", "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
+                       status = "disabled";
+               };
+
+               i2c3: i2c@e66d0000 {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "renesas,i2c-r8a77995",
+                                    "renesas,rcar-gen3-i2c";
+                       reg = <0 0xe66d0000 0 0x40>;
+                       interrupts = <GIC_SPI 290 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 928>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 928>;
+                       dmas = <&dmac0 0x97>, <&dmac0 0x96>;
+                       dma-names = "tx", "rx";
+                       i2c-scl-internal-delay-ns = <6>;
+                       status = "disabled";
+               };
+
+               canfd: can@e66c0000 {
+                       compatible = "renesas,r8a77995-canfd",
+                                    "renesas,rcar-gen3-canfd";
+                       reg = <0 0xe66c0000 0 0x8000>;
+                       interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>,
+                                  <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 914>,
+                              <&cpg CPG_CORE R8A77995_CLK_CANFD>,
+                              <&can_clk>;
+                       clock-names = "fck", "canfd", "can_clk";
+                       assigned-clocks = <&cpg CPG_CORE R8A77995_CLK_CANFD>;
+                       assigned-clock-rates = <40000000>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 914>;
+                       status = "disabled";
+
+                       channel0 {
+                               status = "disabled";
+                       };
+
+                       channel1 {
+                               status = "disabled";
+                       };
+               };
+
                dmac0: dma-controller@e6700000 {
                        compatible = "renesas,dmac-r8a77995",
                                     "renesas,rcar-dmac";
@@ -304,173 +404,75 @@ GIC_SPI 423 IRQ_TYPE_LEVEL_HIGH
                        dma-channels = <8>;
                };
 
-               gpio0: gpio@e6050000 {
-                       compatible = "renesas,gpio-r8a77995",
-                                    "renesas,rcar-gen3-gpio",
-                                    "renesas,gpio-rcar";
-                       reg = <0 0xe6050000 0 0x50>;
-                       interrupts = <GIC_SPI 4 IRQ_TYPE_LEVEL_HIGH>;
-                       #gpio-cells = <2>;
-                       gpio-controller;
-                       gpio-ranges = <&pfc 0 0 9>;
-                       #interrupt-cells = <2>;
-                       interrupt-controller;
-                       clocks = <&cpg CPG_MOD 912>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 912>;
-               };
-
-               gpio1: gpio@e6051000 {
-                       compatible = "renesas,gpio-r8a77995",
-                                    "renesas,rcar-gen3-gpio",
-                                    "renesas,gpio-rcar";
-                       reg = <0 0xe6051000 0 0x50>;
-                       interrupts = <GIC_SPI 5 IRQ_TYPE_LEVEL_HIGH>;
-                       #gpio-cells = <2>;
-                       gpio-controller;
-                       gpio-ranges = <&pfc 0 32 32>;
-                       #interrupt-cells = <2>;
-                       interrupt-controller;
-                       clocks = <&cpg CPG_MOD 911>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 911>;
-               };
-
-               gpio2: gpio@e6052000 {
-                       compatible = "renesas,gpio-r8a77995",
-                                    "renesas,rcar-gen3-gpio",
-                                    "renesas,gpio-rcar";
-                       reg = <0 0xe6052000 0 0x50>;
-                       interrupts = <GIC_SPI 6 IRQ_TYPE_LEVEL_HIGH>;
-                       #gpio-cells = <2>;
-                       gpio-controller;
-                       gpio-ranges = <&pfc 0 64 32>;
-                       #interrupt-cells = <2>;
-                       interrupt-controller;
-                       clocks = <&cpg CPG_MOD 910>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 910>;
-               };
-
-               gpio3: gpio@e6053000 {
-                       compatible = "renesas,gpio-r8a77995",
-                                    "renesas,rcar-gen3-gpio",
-                                    "renesas,gpio-rcar";
-                       reg = <0 0xe6053000 0 0x50>;
-                       interrupts = <GIC_SPI 7 IRQ_TYPE_LEVEL_HIGH>;
-                       #gpio-cells = <2>;
-                       gpio-controller;
-                       gpio-ranges = <&pfc 0 96 10>;
-                       #interrupt-cells = <2>;
-                       interrupt-controller;
-                       clocks = <&cpg CPG_MOD 909>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 909>;
+               ipmmu_ds0: mmu@e6740000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xe6740000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 0>;
+                       #iommu-cells = <1>;
                };
 
-               gpio4: gpio@e6054000 {
-                       compatible = "renesas,gpio-r8a77995",
-                                    "renesas,rcar-gen3-gpio",
-                                    "renesas,gpio-rcar";
-                       reg = <0 0xe6054000 0 0x50>;
-                       interrupts = <GIC_SPI 8 IRQ_TYPE_LEVEL_HIGH>;
-                       #gpio-cells = <2>;
-                       gpio-controller;
-                       gpio-ranges = <&pfc 0 128 32>;
-                       #interrupt-cells = <2>;
-                       interrupt-controller;
-                       clocks = <&cpg CPG_MOD 908>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 908>;
+               ipmmu_ds1: mmu@e7740000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xe7740000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 1>;
+                       #iommu-cells = <1>;
                };
 
-               gpio5: gpio@e6055000 {
-                       compatible = "renesas,gpio-r8a77995",
-                                    "renesas,rcar-gen3-gpio",
-                                    "renesas,gpio-rcar";
-                       reg = <0 0xe6055000 0 0x50>;
-                       interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>;
-                       #gpio-cells = <2>;
-                       gpio-controller;
-                       gpio-ranges = <&pfc 0 160 21>;
-                       #interrupt-cells = <2>;
-                       interrupt-controller;
-                       clocks = <&cpg CPG_MOD 907>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 907>;
+               ipmmu_hc: mmu@e6570000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xe6570000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 2>;
+                       #iommu-cells = <1>;
                };
 
-               gpio6: gpio@e6055400 {
-                       compatible = "renesas,gpio-r8a77995",
-                                    "renesas,rcar-gen3-gpio",
-                                    "renesas,gpio-rcar";
-                       reg = <0 0xe6055400 0 0x50>;
-                       interrupts = <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>;
-                       #gpio-cells = <2>;
-                       gpio-controller;
-                       gpio-ranges = <&pfc 0 192 14>;
-                       #interrupt-cells = <2>;
-                       interrupt-controller;
-                       clocks = <&cpg CPG_MOD 906>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 906>;
+               ipmmu_mm: mmu@e67b0000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xe67b0000 0 0x1000>;
+                       interrupts = <GIC_SPI 196 IRQ_TYPE_LEVEL_HIGH>,
+                                    <GIC_SPI 197 IRQ_TYPE_LEVEL_HIGH>;
+                       #iommu-cells = <1>;
                };
 
-               can0: can@e6c30000 {
-                       compatible = "renesas,can-r8a77995",
-                                    "renesas,rcar-gen3-can";
-                       reg = <0 0xe6c30000 0 0x1000>;
-                       interrupts = <GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 916>,
-                              <&cpg CPG_CORE R8A77995_CLK_CANFD>,
-                              <&can_clk>;
-                       clock-names = "clkp1", "clkp2", "can_clk";
-                       assigned-clocks = <&cpg CPG_CORE R8A77995_CLK_CANFD>;
-                       assigned-clock-rates = <40000000>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 916>;
-                       status = "disabled";
+               ipmmu_mp: mmu@ec670000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xec670000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 4>;
+                       #iommu-cells = <1>;
                };
 
-               can1: can@e6c38000 {
-                       compatible = "renesas,can-r8a77995",
-                                    "renesas,rcar-gen3-can";
-                       reg = <0 0xe6c38000 0 0x1000>;
-                       interrupts = <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 915>,
-                              <&cpg CPG_CORE R8A77995_CLK_CANFD>,
-                              <&can_clk>;
-                       clock-names = "clkp1", "clkp2", "can_clk";
-                       assigned-clocks = <&cpg CPG_CORE R8A77995_CLK_CANFD>;
-                       assigned-clock-rates = <40000000>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 915>;
-                       status = "disabled";
+               ipmmu_pv0: mmu@fd800000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xfd800000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 6>;
+                       #iommu-cells = <1>;
                };
 
-               canfd: can@e66c0000 {
-                       compatible = "renesas,r8a77995-canfd",
-                                    "renesas,rcar-gen3-canfd";
-                       reg = <0 0xe66c0000 0 0x8000>;
-                       interrupts = <GIC_SPI 29 IRQ_TYPE_LEVEL_HIGH>,
-                                  <GIC_SPI 30 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 914>,
-                              <&cpg CPG_CORE R8A77995_CLK_CANFD>,
-                              <&can_clk>;
-                       clock-names = "fck", "canfd", "can_clk";
-                       assigned-clocks = <&cpg CPG_CORE R8A77995_CLK_CANFD>;
-                       assigned-clock-rates = <40000000>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 914>;
-                       status = "disabled";
+               ipmmu_rt: mmu@ffc80000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xffc80000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 10>;
+                       #iommu-cells = <1>;
+               };
 
-                       channel0 {
-                               status = "disabled";
-                       };
+               ipmmu_vc0: mmu@fe6b0000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xfe6b0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 12>;
+                       #iommu-cells = <1>;
+               };
 
-                       channel1 {
-                               status = "disabled";
-                       };
+               ipmmu_vi0: mmu@febd0000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xfebd0000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 14>;
+                       #iommu-cells = <1>;
+               };
+
+               ipmmu_vp0: mmu@fe990000 {
+                       compatible = "renesas,ipmmu-r8a77995";
+                       reg = <0 0xfe990000 0 0x1000>;
+                       renesas,ipmmu-main = <&ipmmu_mm 16>;
+                       #iommu-cells = <1>;
                };
 
                avb: ethernet@e6800000 {
@@ -519,87 +521,35 @@ avb: ethernet@e6800000 {
                        status = "disabled";
                };
 
-               scif2: serial@e6e88000 {
-                       compatible = "renesas,scif-r8a77995",
-                                    "renesas,rcar-gen3-scif", "renesas,scif";
-                       reg = <0 0xe6e88000 0 64>;
-                       interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 310>,
-                                <&cpg CPG_CORE R8A77995_CLK_S3D1C>,
-                                <&scif_clk>;
-                       clock-names = "fck", "brg_int", "scif_clk";
-                       dmas = <&dmac1 0x13>, <&dmac1 0x12>,
-                              <&dmac2 0x13>, <&dmac2 0x12>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 310>;
-                       status = "disabled";
-               };
-
-               i2c0: i2c@e6500000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a77995",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe6500000 0 0x40>;
-                       interrupts = <GIC_SPI 287 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 931>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 931>;
-                       dmas = <&dmac1 0x91>, <&dmac1 0x90>,
-                              <&dmac2 0x91>, <&dmac2 0x90>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       i2c-scl-internal-delay-ns = <6>;
-                       status = "disabled";
-               };
-
-               i2c1: i2c@e6508000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a77995",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe6508000 0 0x40>;
-                       interrupts = <GIC_SPI 288 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 930>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 930>;
-                       dmas = <&dmac1 0x93>, <&dmac1 0x92>,
-                              <&dmac2 0x93>, <&dmac2 0x92>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       i2c-scl-internal-delay-ns = <6>;
-                       status = "disabled";
-               };
-
-               i2c2: i2c@e6510000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a77995",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe6510000 0 0x40>;
-                       interrupts = <GIC_SPI 286 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 929>;
+               can0: can@e6c30000 {
+                       compatible = "renesas,can-r8a77995",
+                                    "renesas,rcar-gen3-can";
+                       reg = <0 0xe6c30000 0 0x1000>;
+                       interrupts = <GIC_SPI 186 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 916>,
+                              <&cpg CPG_CORE R8A77995_CLK_CANFD>,
+                              <&can_clk>;
+                       clock-names = "clkp1", "clkp2", "can_clk";
+                       assigned-clocks = <&cpg CPG_CORE R8A77995_CLK_CANFD>;
+                       assigned-clock-rates = <40000000>;
                        power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 929>;
-                       dmas = <&dmac1 0x95>, <&dmac1 0x94>,
-                              <&dmac2 0x95>, <&dmac2 0x94>;
-                       dma-names = "tx", "rx", "tx", "rx";
-                       i2c-scl-internal-delay-ns = <6>;
+                       resets = <&cpg 916>;
                        status = "disabled";
                };
 
-               i2c3: i2c@e66d0000 {
-                       #address-cells = <1>;
-                       #size-cells = <0>;
-                       compatible = "renesas,i2c-r8a77995",
-                                    "renesas,rcar-gen3-i2c";
-                       reg = <0 0xe66d0000 0 0x40>;
-                       interrupts = <GIC_SPI 290 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 928>;
+               can1: can@e6c38000 {
+                       compatible = "renesas,can-r8a77995",
+                                    "renesas,rcar-gen3-can";
+                       reg = <0 0xe6c38000 0 0x1000>;
+                       interrupts = <GIC_SPI 187 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 915>,
+                              <&cpg CPG_CORE R8A77995_CLK_CANFD>,
+                              <&can_clk>;
+                       clock-names = "clkp1", "clkp2", "can_clk";
+                       assigned-clocks = <&cpg CPG_CORE R8A77995_CLK_CANFD>;
+                       assigned-clock-rates = <40000000>;
                        power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 928>;
-                       dmas = <&dmac0 0x97>, <&dmac0 0x96>;
-                       dma-names = "tx", "rx";
-                       i2c-scl-internal-delay-ns = <6>;
+                       resets = <&cpg 915>;
                        status = "disabled";
                };
 
@@ -643,38 +593,54 @@ pwm3: pwm@e6e33000 {
                        status = "disabled";
                };
 
-               sdhi2: sd@ee140000 {
-                       compatible = "renesas,sdhi-r8a77995",
-                                    "renesas,rcar-gen3-sdhi";
-                       reg = <0 0xee140000 0 0x2000>;
-                       interrupts = <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;
-                       clocks = <&cpg CPG_MOD 312>;
-                       max-frequency = <200000000>;
+               scif2: serial@e6e88000 {
+                       compatible = "renesas,scif-r8a77995",
+                                    "renesas,rcar-gen3-scif", "renesas,scif";
+                       reg = <0 0xe6e88000 0 64>;
+                       interrupts = <GIC_SPI 164 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 310>,
+                                <&cpg CPG_CORE R8A77995_CLK_S3D1C>,
+                                <&scif_clk>;
+                       clock-names = "fck", "brg_int", "scif_clk";
+                       dmas = <&dmac1 0x13>, <&dmac1 0x12>,
+                              <&dmac2 0x13>, <&dmac2 0x12>;
+                       dma-names = "tx", "rx", "tx", "rx";
                        power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 312>;
+                       resets = <&cpg 310>;
                        status = "disabled";
                };
 
-               ehci0: usb@ee080100 {
-                       compatible = "generic-ehci";
-                       reg = <0 0xee080100 0 0x100>;
+               vin4: video@e6ef4000 {
+                       compatible = "renesas,vin-r8a77995";
+                       reg = <0 0xe6ef4000 0 0x1000>;
+                       interrupts = <GIC_SPI 174 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 807>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 807>;
+                       renesas,id = <4>;
+                       status = "disabled";
+               };
+
+               ohci0: usb@ee080000 {
+                       compatible = "generic-ohci";
+                       reg = <0 0xee080000 0 0x100>;
                        interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 703>;
                        phys = <&usb2_phy0>;
                        phy-names = "usb";
-                       companion = <&ohci0>;
                        power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
                        resets = <&cpg 703>;
                        status = "disabled";
                };
 
-               ohci0: usb@ee080000 {
-                       compatible = "generic-ohci";
-                       reg = <0 0xee080000 0 0x100>;
+               ehci0: usb@ee080100 {
+                       compatible = "generic-ehci";
+                       reg = <0 0xee080100 0 0x100>;
                        interrupts = <GIC_SPI 108 IRQ_TYPE_LEVEL_HIGH>;
                        clocks = <&cpg CPG_MOD 703>;
                        phys = <&usb2_phy0>;
                        phy-names = "usb";
+                       companion = <&ohci0>;
                        power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
                        resets = <&cpg 703>;
                        status = "disabled";
@@ -692,6 +658,35 @@ usb2_phy0: usb-phy@ee080200 {
                        status = "disabled";
                };
 
+               sdhi2: sd@ee140000 {
+                       compatible = "renesas,sdhi-r8a77995",
+                                    "renesas,rcar-gen3-sdhi";
+                       reg = <0 0xee140000 0 0x2000>;
+                       interrupts = <GIC_SPI 167 IRQ_TYPE_LEVEL_HIGH>;
+                       clocks = <&cpg CPG_MOD 312>;
+                       max-frequency = <200000000>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 312>;
+                       status = "disabled";
+               };
+
+               gic: interrupt-controller@f1010000 {
+                       compatible = "arm,gic-400";
+                       #interrupt-cells = <3>;
+                       #address-cells = <0>;
+                       interrupt-controller;
+                       reg = <0x0 0xf1010000 0 0x1000>,
+                             <0x0 0xf1020000 0 0x20000>,
+                             <0x0 0xf1040000 0 0x20000>,
+                             <0x0 0xf1060000 0 0x20000>;
+                       interrupts = <GIC_PPI 9
+                                       (GIC_CPU_MASK_SIMPLE(1) | IRQ_TYPE_LEVEL_HIGH)>;
+                       clocks = <&cpg CPG_MOD 408>;
+                       clock-names = "clk";
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 408>;
+               };
+
                vspbs: vsp@fe960000 {
                        compatible = "renesas,vsp2";
                        reg = <0 0xfe960000 0 0x8000>;
@@ -702,15 +697,6 @@ vspbs: vsp@fe960000 {
                        renesas,fcp = <&fcpvb0>;
                };
 
-               fcpvb0: fcp@fe96f000 {
-                       compatible = "renesas,fcpv";
-                       reg = <0 0xfe96f000 0 0x200>;
-                       clocks = <&cpg CPG_MOD 607>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 607>;
-                       iommus = <&ipmmu_vp0 5>;
-               };
-
                vspd0: vsp@fea20000 {
                        compatible = "renesas,vsp2";
                        reg = <0 0xfea20000 0 0x8000>;
@@ -721,15 +707,6 @@ vspd0: vsp@fea20000 {
                        renesas,fcp = <&fcpvd0>;
                };
 
-               fcpvd0: fcp@fea27000 {
-                       compatible = "renesas,fcpv";
-                       reg = <0 0xfea27000 0 0x200>;
-                       clocks = <&cpg CPG_MOD 603>;
-                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
-                       resets = <&cpg 603>;
-                       iommus = <&ipmmu_vi0 8>;
-               };
-
                vspd1: vsp@fea28000 {
                        compatible = "renesas,vsp2";
                        reg = <0 0xfea28000 0 0x8000>;
@@ -740,6 +717,24 @@ vspd1: vsp@fea28000 {
                        renesas,fcp = <&fcpvd1>;
                };
 
+               fcpvb0: fcp@fe96f000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfe96f000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 607>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 607>;
+                       iommus = <&ipmmu_vp0 5>;
+               };
+
+               fcpvd0: fcp@fea27000 {
+                       compatible = "renesas,fcpv";
+                       reg = <0 0xfea27000 0 0x200>;
+                       clocks = <&cpg CPG_MOD 603>;
+                       power-domains = <&sysc R8A77995_PD_ALWAYS_ON>;
+                       resets = <&cpg 603>;
+                       iommus = <&ipmmu_vi0 8>;
+               };
+
                fcpvd1: fcp@fea2f000 {
                        compatible = "renesas,fcpv";
                        reg = <0 0xfea2f000 0 0x200>;
@@ -783,6 +778,11 @@ du_out_lvds1: endpoint {
                                };
                        };
                };
+
+               prr: chipid@fff00044 {
+                       compatible = "renesas,prr";
+                       reg = <0 0xfff00044 0 4>;
+               };
        };
 
        timer {
index 2a7f36abd2dd85c6c71ff17ca9cf85324c893a80..9256fbaaab7f32976633eb2d7bf9a62afdb771b1 100644 (file)
@@ -66,6 +66,29 @@ backlight: backlight {
                enable-gpios = <&gpio6 7 GPIO_ACTIVE_HIGH>;
        };
 
+       cvbs-in {
+               compatible = "composite-video-connector";
+               label = "CVBS IN";
+
+               port {
+                       cvbs_con: endpoint {
+                               remote-endpoint = <&adv7482_ain7>;
+                       };
+               };
+       };
+
+       hdmi-in {
+               compatible = "hdmi-connector";
+               label = "HDMI IN";
+               type = "a";
+
+               port {
+                       hdmi_in_con: endpoint {
+                               remote-endpoint = <&adv7482_hdmi>;
+                       };
+               };
+       };
+
        reg_1p8v: regulator0 {
                compatible = "regulator-fixed";
                regulator-name = "fixed-1.8V";
@@ -93,20 +116,12 @@ reg_12v: regulator2 {
                regulator-always-on;
        };
 
-       rsnd_ak4613: sound {
-               compatible = "simple-audio-card";
-
-               simple-audio-card,format = "left_j";
-               simple-audio-card,bitclock-master = <&sndcpu>;
-               simple-audio-card,frame-master = <&sndcpu>;
+       sound_card: sound {
+               compatible = "audio-graph-card";
 
-               sndcpu: simple-audio-card,cpu {
-                       sound-dai = <&rcar_sound>;
-               };
+               label = "rcar-sound";
 
-               sndcodec: simple-audio-card,codec {
-                       sound-dai = <&ak4613>;
-               };
+               dais = <&rsnd_port0>;
        };
 
        vbus0_usb2: regulator-vbus0-usb2 {
@@ -268,6 +283,37 @@ phy0: ethernet-phy@0 {
        };
 };
 
+&csi20 {
+       status = "okay";
+
+       ports {
+               port@0 {
+                       reg = <0>;
+                       csi20_in: endpoint {
+                               clock-lanes = <0>;
+                               data-lanes = <1>;
+                               remote-endpoint = <&adv7482_txb>;
+                       };
+               };
+       };
+};
+
+&csi40 {
+       status = "okay";
+
+       ports {
+               port@0 {
+                       reg = <0>;
+
+                       csi40_in: endpoint {
+                               clock-lanes = <0>;
+                               data-lanes = <1 2 3 4>;
+                               remote-endpoint = <&adv7482_txa>;
+                       };
+               };
+       };
+};
+
 &du {
        pinctrl-0 = <&du_pins>;
        pinctrl-names = "default";
@@ -322,6 +368,12 @@ ak4613: codec@10 {
                asahi-kasei,out4-single-end;
                asahi-kasei,out5-single-end;
                asahi-kasei,out6-single-end;
+
+               port {
+                       ak4613_endpoint: endpoint {
+                               remote-endpoint = <&rsnd_endpoint0>;
+                       };
+               };
        };
 
        cs2000: clk_multiplier@4f {
@@ -359,6 +411,55 @@ csa_dvfs: adc@7f {
 
                shunt-resistor-micro-ohms = <5000>;
        };
+
+       video-receiver@70 {
+               compatible = "adi,adv7482";
+               reg = <0x70>;
+
+               #address-cells = <1>;
+               #size-cells = <0>;
+
+               interrupt-parent = <&gpio6>;
+               interrupt-names = "intrq1", "intrq2";
+               interrupts = <30 IRQ_TYPE_LEVEL_LOW>,
+                            <31 IRQ_TYPE_LEVEL_LOW>;
+
+               port@7 {
+                       reg = <7>;
+
+                       adv7482_ain7: endpoint {
+                               remote-endpoint = <&cvbs_con>;
+                       };
+               };
+
+               port@8 {
+                       reg = <8>;
+
+                       adv7482_hdmi: endpoint {
+                               remote-endpoint = <&hdmi_in_con>;
+                       };
+               };
+
+               port@10 {
+                       reg = <10>;
+
+                       adv7482_txa: endpoint {
+                               clock-lanes = <0>;
+                               data-lanes = <1 2 3 4>;
+                               remote-endpoint = <&csi40_in>;
+                       };
+               };
+
+               port@11 {
+                       reg = <11>;
+
+                       adv7482_txb: endpoint {
+                               clock-lanes = <0>;
+                               data-lanes = <1>;
+                               remote-endpoint = <&csi20_in>;
+                       };
+               };
+       };
 };
 
 &i2c_dvfs {
@@ -376,6 +477,8 @@ pmic: pmic@30 {
                #interrupt-cells = <2>;
                gpio-controller;
                #gpio-cells = <2>;
+               rohm,ddr-backup-power = <0xf>;
+               rohm,rstbmode-level;
 
                regulators {
                        dvfs: dvfs {
@@ -387,6 +490,12 @@ dvfs: dvfs {
                        };
                };
        };
+
+       eeprom@50 {
+               compatible = "rohm,br24t01", "atmel,24c01";
+               reg = <0x50>;
+               pagesize = <8>;
+       };
 };
 
 &ohci0 {
@@ -416,12 +525,12 @@ &pfc {
 
        avb_pins: avb {
                mux {
-                       groups = "avb_link", "avb_mdc", "avb_mii";
+                       groups = "avb_link", "avb_mdio", "avb_mii";
                        function = "avb";
                };
 
-               pins_mdc {
-                       groups = "avb_mdc";
+               pins_mdio {
+                       groups = "avb_mdio";
                        drive-strength = <24>;
                };
 
@@ -581,10 +690,18 @@ &rcar_sound {
                 <&audio_clk_c>,
                 <&cpg CPG_CORE CPG_AUDIO_CLK_I>;
 
-       rcar_sound,dai {
-               dai0 {
-                       playback = <&ssi0 &src0 &dvc0>;
-                       capture  = <&ssi1 &src1 &dvc1>;
+       ports {
+               rsnd_port0: port@0 {
+                       rsnd_endpoint0: endpoint {
+                               remote-endpoint = <&ak4613_endpoint>;
+
+                               dai-format = "left_j";
+                               bitclock-master = <&rsnd_endpoint0>;
+                               frame-master = <&rsnd_endpoint0>;
+
+                               playback = <&ssi0 &src0 &dvc0>;
+                               capture  = <&ssi1 &src1 &dvc1>;
+                       };
                };
        };
 };
@@ -689,6 +806,38 @@ &usb3s0_clk {
        clock-frequency = <100000000>;
 };
 
+&vin0 {
+       status = "okay";
+};
+
+&vin1 {
+       status = "okay";
+};
+
+&vin2 {
+       status = "okay";
+};
+
+&vin3 {
+       status = "okay";
+};
+
+&vin4 {
+       status = "okay";
+};
+
+&vin5 {
+       status = "okay";
+};
+
+&vin6 {
+       status = "okay";
+};
+
+&vin7 {
+       status = "okay";
+};
+
 &wdt0 {
        timeout-sec = <60>;
        status = "okay";
index 6f814845f8b665f3b13f10921e6bab288c512082..0edb16e6b3728149ecd4ef2cbb56f8be904aa403 100644 (file)
@@ -243,6 +243,32 @@ versaclock5: clock-generator@6a {
 
 &i2c_dvfs {
        status = "okay";
+
+       pmic: pmic@30 {
+               pinctrl-0 = <&irq0_pins>;
+               pinctrl-names = "default";
+
+               compatible = "rohm,bd9571mwv";
+               reg = <0x30>;
+               interrupt-parent = <&intc_ex>;
+               interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+               interrupt-controller;
+               #interrupt-cells = <2>;
+               gpio-controller;
+               #gpio-cells = <2>;
+               rohm,ddr-backup-power = <0xf>;
+               rohm,rstbmode-pulse;
+
+               regulators {
+                       dvfs: dvfs {
+                               regulator-name = "dvfs";
+                               regulator-min-microvolt = <750000>;
+                               regulator-max-microvolt = <1030000>;
+                               regulator-boot-on;
+                               regulator-always-on;
+                       };
+               };
+       };
 };
 
 &ohci1 {
@@ -255,12 +281,12 @@ &pfc {
 
        avb_pins: avb {
                mux {
-                       groups = "avb_link", "avb_mdc", "avb_mii";
+                       groups = "avb_link", "avb_mdio", "avb_mii";
                        function = "avb";
                };
 
-               pins_mdc {
-                       groups = "avb_mdc";
+               pins_mdio {
+                       groups = "avb_mdio";
                        drive-strength = <24>;
                };
 
@@ -276,6 +302,11 @@ i2c2_pins: i2c2 {
                function = "i2c2";
        };
 
+       irq0_pins: irq0 {
+               groups = "intc_ex_irq0";
+               function = "intc_ex";
+       };
+
        scif2_pins: scif2 {
                groups = "scif2_data_a";
                function = "scif2";
index be2bfbc6b4831a82e6567d91b036e46e583de036..b8e9da15e00c5b16ff444f681466d5454184f040 100644 (file)
@@ -595,6 +595,8 @@ h265e_mmu: iommu@ff330200 {
                reg = <0x0 0xff330200 0 0x100>;
                interrupts = <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "h265e_mmu";
+               clocks = <&cru ACLK_H265>, <&cru PCLK_H265>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -604,6 +606,8 @@ vepu_mmu: iommu@ff340800 {
                reg = <0x0 0xff340800 0x0 0x40>;
                interrupts = <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vepu_mmu";
+               clocks = <&cru ACLK_VPU>, <&cru HCLK_VPU>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -613,6 +617,8 @@ vpu_mmu: iommu@ff350800 {
                reg = <0x0 0xff350800 0x0 0x40>;
                interrupts = <GIC_SPI 11 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vpu_mmu";
+               clocks = <&cru ACLK_VPU>, <&cru HCLK_VPU>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -622,6 +628,8 @@ rkvdec_mmu: iommu@ff360480 {
                reg = <0x0 0xff360480 0x0 0x40>, <0x0 0xff3604c0 0x0 0x40>;
                interrupts = <GIC_SPI 74 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "rkvdec_mmu";
+               clocks = <&cru ACLK_RKVDEC>, <&cru HCLK_RKVDEC>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -631,6 +639,8 @@ vop_mmu: iommu@ff373f00 {
                reg = <0x0 0xff373f00 0x0 0x100>;
                interrupts = <GIC_SPI 32 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vop_mmu";
+               clocks = <&cru ACLK_VOP>, <&cru HCLK_VOP>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
index 03458ac44201c7c66d0e991881ab24e292bfdee2..ad91ced786494afdb9428ea9c83adaf8e6f56e71 100644 (file)
@@ -742,6 +742,8 @@ iep_mmu: iommu@ff900800 {
                reg = <0x0 0xff900800 0x0 0x100>;
                interrupts = <GIC_SPI 17 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "iep_mmu";
+               clocks = <&cru ACLK_IEP>, <&cru HCLK_IEP>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -752,6 +754,8 @@ isp_mmu: iommu@ff914000 {
                      <0x0 0xff915000 0x0 0x100>;
                interrupts = <GIC_SPI 14 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "isp_mmu";
+               clocks = <&cru ACLK_ISP>, <&cru HCLK_ISP>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                rockchip,disable-mmu-reset;
                status = "disabled";
@@ -762,6 +766,8 @@ vop_mmu: iommu@ff930300 {
                reg = <0x0 0xff930300 0x0 0x100>;
                interrupts = <GIC_SPI 15 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vop_mmu";
+               clocks = <&cru ACLK_VOP>, <&cru HCLK_VOP>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -772,6 +778,8 @@ hevc_mmu: iommu@ff9a0440 {
                      <0x0 0xff9a0480 0x0 0x40>;
                interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "hevc_mmu";
+               clocks = <&cru ACLK_VIDEO>, <&cru HCLK_VIDEO>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -782,6 +790,8 @@ vpu_mmu: iommu@ff9a0800 {
                interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH>,
                             <GIC_SPI 10 IRQ_TYPE_LEVEL_HIGH>;
                interrupt-names = "vepu_mmu", "vdpu_mmu";
+               clocks = <&cru ACLK_VIDEO>, <&cru HCLK_VIDEO>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
index 4f28628aa09116f553b5e4fafa463bead619293e..2a352763c8489be969fa361ed0543d3163437d56 100644 (file)
@@ -662,6 +662,14 @@ &sdhci {
        status = "okay";
 };
 
+&tcphy0 {
+       status = "okay";
+};
+
+&tcphy1 {
+       status = "okay";
+};
+
 &tsadc {
        /* tshut mode 0:CRU 1:GPIO */
        rockchip,hw-tshut-mode = <1>;
index 191a6bcb1704009830d4c3b5c0a201ffe7b2d670..82179125bfb7c78fcb0d3bc0beef209d1dbaf871 100644 (file)
@@ -255,7 +255,7 @@ digitizer: digitizer@9 {
 
 &ap_i2c_tp {
        trackpad@4a {
-               compatible = "atmel,atmel_mxt_tp";
+               compatible = "atmel,maxtouch";
                reg = <0x4a>;
                pinctrl-names = "default";
                pinctrl-0 = <&trackpad_int_l>;
@@ -271,7 +271,7 @@ KEY_RESERVED
 
 &ap_i2c_ts {
        touchscreen@4b {
-               compatible = "atmel,atmel_mxt_ts";
+               compatible = "atmel,maxtouch";
                reg = <0x4b>;
                pinctrl-names = "default";
                pinctrl-0 = <&touch_int_l>;
index 18f546f2dfd113d018e9935f2a03b18315c46efa..f49bfab75dd031640126b7c9ea50dd0c89b0a4fc 100644 (file)
@@ -588,7 +588,9 @@ &cru {
                <&cru ACLK_PERILP0>, <&cru HCLK_PERILP0>,
                <&cru PCLK_PERILP0>, <&cru ACLK_CCI>,
                <&cru HCLK_PERILP1>, <&cru PCLK_PERILP1>,
-               <&cru ACLK_VIO>;
+               <&cru ACLK_VIO>, <&cru ACLK_HDCP>,
+               <&cru ACLK_GIC_PRE>,
+               <&cru PCLK_DDR>;
        assigned-clock-rates =
                <600000000>, <800000000>,
                <1000000000>,
@@ -597,7 +599,9 @@ &cru {
                <100000000>, <100000000>,
                <50000000>, <800000000>,
                <100000000>, <50000000>,
-               <400000000>;
+               <400000000>, <400000000>,
+               <200000000>,
+               <200000000>;
 };
 
 &emmc_phy {
index 7d3e8bfd51dd4f2fa9a73845ae5cbb0d51cc03b7..e0afdd8b62bd1887c106069ec987c7de30e72a87 100644 (file)
@@ -143,6 +143,11 @@ vddd_codec: vddd-codec {
        };
 };
 
+&hdmi {
+       ddc-i2c-bus = <&i2c3>;
+       status = "okay";
+};
+
 &i2c1 {
        status = "okay";
        clock-frequency = <400000>;
@@ -246,6 +251,10 @@ &spi5 {
        status = "okay";
 };
 
+&tcphy0 {
+       status = "okay";
+};
+
 &u2phy0 {
        status = "okay";
 };
@@ -281,3 +290,19 @@ &usb_host0_ehci {
 &usb_host0_ohci {
        status = "okay";
 };
+
+&vopb {
+       status = "okay";
+};
+
+&vopb_mmu {
+       status = "okay";
+};
+
+&vopl {
+       status = "okay";
+};
+
+&vopl_mmu {
+       status = "okay";
+};
index 4a2d06abe9c1dc892e819d116f6ce3fa3241e9a9..14a0f19986390a7593cd3be04b23b0c7de1e493d 100644 (file)
@@ -527,6 +527,10 @@ norflash: flash@0 {
        };
 };
 
+&tcphy1 {
+       status = "okay";
+};
+
 &tsadc {
        rockchip,hw-tshut-mode = <1>;
        rockchip,hw-tshut-polarity = <1>;
index 56952d1a3fb8bd271e4535f2638fe9f7e691f8e3..ad7548d3b93d50f073f0e93015a9dd107535413d 100644 (file)
@@ -190,6 +190,18 @@ &i2s0 {
        status = "okay";
 };
 
+&pcie_phy {
+       status = "okay";
+};
+
+&pcie0 {
+       ep-gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_HIGH>;
+       num-lanes = <4>;
+       pinctrl-names = "default";
+       pinctrl-0 = <&pcie_clkreqn_cpm>;
+       status = "okay";
+};
+
 &pinctrl {
        sdio-pwrseq {
                wifi_enable_h: wifi-enable-h {
index e5daed7d202633dd60fa4927f7fcd81093ed4393..941b627094d7f2dadcb61459fc7250dfef5634d7 100644 (file)
@@ -471,21 +471,6 @@ &io_domains {
        gpio1830-supply = <&vcc_3v0>;
 };
 
-&pcie_phy {
-       status = "okay";
-};
-
-&pcie0 {
-       assigned-clocks = <&cru SCLK_PCIEPHY_REF>;
-       assigned-clock-parents = <&cru SCLK_PCIEPHY_REF100M>;
-       assigned-clock-rates = <100000000>;
-       ep-gpios = <&gpio2 RK_PA4 GPIO_ACTIVE_HIGH>;
-       num-lanes = <4>;
-       pinctrl-names = "default";
-       pinctrl-0 = <&pcie_clkreqn_cpm>;
-       status = "okay";
-};
-
 &pmu_io_domains {
        pmu1830-supply = <&vcc_3v0>;
        status = "okay";
@@ -560,6 +545,14 @@ &sdmmc {
        status = "okay";
 };
 
+&tcphy0 {
+       status = "okay";
+};
+
+&tcphy1 {
+       status = "okay";
+};
+
 &tsadc {
        /* tshut mode 0:CRU 1:GPIO */
        rockchip,hw-tshut-mode = <1>;
index 4550c0f82be9021c3258ef18da864570800f1cda..e0040b648f4330909066b23fe2129e36435603d6 100644 (file)
@@ -312,6 +312,8 @@ sdmmc: dwmmc@fe320000 {
                reg = <0x0 0xfe320000 0x0 0x4000>;
                interrupts = <GIC_SPI 65 IRQ_TYPE_LEVEL_HIGH 0>;
                max-frequency = <150000000>;
+               assigned-clocks = <&cru HCLK_SD>;
+               assigned-clock-rates = <200000000>;
                clocks = <&cru HCLK_SDMMC>, <&cru SCLK_SDMMC>,
                         <&cru SCLK_SDMMC_DRV>, <&cru SCLK_SDMMC_SAMPLE>;
                clock-names = "biu", "ciu", "ciu-drive", "ciu-sample";
@@ -411,8 +413,8 @@ usbdrd_dwc3_0: dwc3 {
                        reg = <0x0 0xfe800000 0x0 0x100000>;
                        interrupts = <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH 0>;
                        dr_mode = "otg";
-                       phys = <&u2phy0_otg>;
-                       phy-names = "usb2-phy";
+                       phys = <&u2phy0_otg>, <&tcphy0_usb3>;
+                       phy-names = "usb2-phy", "usb3-phy";
                        phy_type = "utmi_wide";
                        snps,dis_enblslpm_quirk;
                        snps,dis-u2-freeclk-exists-quirk;
@@ -444,8 +446,8 @@ usbdrd_dwc3_1: dwc3 {
                        reg = <0x0 0xfe900000 0x0 0x100000>;
                        interrupts = <GIC_SPI 110 IRQ_TYPE_LEVEL_HIGH 0>;
                        dr_mode = "otg";
-                       phys = <&u2phy1_otg>;
-                       phy-names = "usb2-phy";
+                       phys = <&u2phy1_otg>, <&tcphy1_usb3>;
+                       phy-names = "usb2-phy", "usb3-phy";
                        phy_type = "utmi_wide";
                        snps,dis_enblslpm_quirk;
                        snps,dis-u2-freeclk-exists-quirk;
@@ -461,8 +463,8 @@ cdn_dp: dp@fec00000 {
                compatible = "rockchip,rk3399-cdn-dp";
                reg = <0x0 0xfec00000 0x0 0x100000>;
                interrupts = <GIC_SPI 9 IRQ_TYPE_LEVEL_HIGH 0>;
-               assigned-clocks = <&cru SCLK_DP_CORE>;
-               assigned-clock-rates = <100000000>;
+               assigned-clocks = <&cru SCLK_DP_CORE>, <&cru SCLK_SPDIF_REC_DPTX>;
+               assigned-clock-rates = <100000000>, <200000000>;
                clocks = <&cru SCLK_DP_CORE>, <&cru PCLK_DP_CTRL>,
                         <&cru SCLK_SPDIF_REC_DPTX>, <&cru PCLK_VIO_GRF>;
                clock-names = "core-clk", "pclk", "spdif", "grf";
@@ -1234,6 +1236,8 @@ vpu_mmu: iommu@ff650800 {
                reg = <0x0 0xff650800 0x0 0x40>;
                interrupts = <GIC_SPI 115 IRQ_TYPE_LEVEL_HIGH 0>;
                interrupt-names = "vpu_mmu";
+               clocks = <&cru ACLK_VCODEC>, <&cru HCLK_VCODEC>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -1243,6 +1247,8 @@ vdec_mmu: iommu@ff660480 {
                reg = <0x0 0xff660480 0x0 0x40>, <0x0 0xff6604c0 0x0 0x40>;
                interrupts = <GIC_SPI 117 IRQ_TYPE_LEVEL_HIGH 0>;
                interrupt-names = "vdec_mmu";
+               clocks = <&cru ACLK_VDU>, <&cru HCLK_VDU>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -1252,6 +1258,8 @@ iep_mmu: iommu@ff670800 {
                reg = <0x0 0xff670800 0x0 0x40>;
                interrupts = <GIC_SPI 42 IRQ_TYPE_LEVEL_HIGH 0>;
                interrupt-names = "iep_mmu";
+               clocks = <&cru ACLK_IEP>, <&cru HCLK_IEP>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                status = "disabled";
        };
@@ -1323,7 +1331,9 @@ cru: clock-controller@ff760000 {
                        <&cru ACLK_PERILP0>, <&cru HCLK_PERILP0>,
                        <&cru PCLK_PERILP0>, <&cru ACLK_CCI>,
                        <&cru HCLK_PERILP1>, <&cru PCLK_PERILP1>,
-                       <&cru ACLK_VIO>;
+                       <&cru ACLK_VIO>, <&cru ACLK_HDCP>,
+                       <&cru ACLK_GIC_PRE>,
+                       <&cru PCLK_DDR>;
                assigned-clock-rates =
                         <594000000>,  <800000000>,
                        <1000000000>,
@@ -1332,7 +1342,9 @@ cru: clock-controller@ff760000 {
                         <100000000>,  <100000000>,
                          <50000000>, <600000000>,
                         <100000000>,   <50000000>,
-                        <400000000>;
+                        <400000000>, <400000000>,
+                        <200000000>,
+                        <200000000>;
        };
 
        grf: syscon@ff770000 {
@@ -1599,7 +1611,7 @@ vopl_mmu: iommu@ff8f3f00 {
                interrupts = <GIC_SPI 119 IRQ_TYPE_LEVEL_HIGH 0>;
                interrupt-names = "vopl_mmu";
                clocks = <&cru ACLK_VOP1>, <&cru HCLK_VOP1>;
-               clock-names = "aclk", "hclk";
+               clock-names = "aclk", "iface";
                power-domains = <&power RK3399_PD_VOPL>;
                #iommu-cells = <0>;
                status = "disabled";
@@ -1656,7 +1668,7 @@ vopb_mmu: iommu@ff903f00 {
                interrupts = <GIC_SPI 118 IRQ_TYPE_LEVEL_HIGH 0>;
                interrupt-names = "vopb_mmu";
                clocks = <&cru ACLK_VOP0>, <&cru HCLK_VOP0>;
-               clock-names = "aclk", "hclk";
+               clock-names = "aclk", "iface";
                power-domains = <&power RK3399_PD_VOPB>;
                #iommu-cells = <0>;
                status = "disabled";
@@ -1667,6 +1679,8 @@ isp0_mmu: iommu@ff914000 {
                reg = <0x0 0xff914000 0x0 0x100>, <0x0 0xff915000 0x0 0x100>;
                interrupts = <GIC_SPI 43 IRQ_TYPE_LEVEL_HIGH 0>;
                interrupt-names = "isp0_mmu";
+               clocks = <&cru ACLK_ISP0_NOC>, <&cru HCLK_ISP0_NOC>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                rockchip,disable-mmu-reset;
                status = "disabled";
@@ -1677,6 +1691,8 @@ isp1_mmu: iommu@ff924000 {
                reg = <0x0 0xff924000 0x0 0x100>, <0x0 0xff925000 0x0 0x100>;
                interrupts = <GIC_SPI 44 IRQ_TYPE_LEVEL_HIGH 0>;
                interrupt-names = "isp1_mmu";
+               clocks = <&cru ACLK_ISP1_NOC>, <&cru HCLK_ISP1_NOC>;
+               clock-names = "aclk", "iface";
                #iommu-cells = <0>;
                rockchip,disable-mmu-reset;
                status = "disabled";
index c32dd3419c870ef080e58780f7ac46e93c136455..d63b56e944de9202d3fe349e85aa1f34c5e3bafb 100644 (file)
@@ -549,10 +549,13 @@ eth: ethernet@65000000 {
                        status = "disabled";
                        reg = <0x65000000 0x8500>;
                        interrupts = <0 66 4>;
+                       clock-names = "ether";
                        clocks = <&sys_clk 6>;
+                       reset-names = "ether";
                        resets = <&sys_rst 6>;
-                       phy-mode = "rmii";
+                       phy-mode = "internal";
                        local-mac-address = [00 00 00 00 00 00];
+                       socionext,syscon-phy-mode = <&soc_glue 0>;
 
                        mdio: mdio {
                                #address-cells = <1>;
index 3a5ed789c056e37bd8dc07e9aa21f8d7e44ea4b8..0298bd0d0e1a9751dcc9731496ddea4387aa1356 100644 (file)
@@ -604,10 +604,13 @@ eth: ethernet@65000000 {
                        interrupts = <0 66 4>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_ether_rgmii>;
+                       clock-names = "ether";
                        clocks = <&sys_clk 6>;
+                       reset-names = "ether";
                        resets = <&sys_rst 6>;
                        phy-mode = "rgmii";
                        local-mac-address = [00 00 00 00 00 00];
+                       socionext,syscon-phy-mode = <&soc_glue 0>;
 
                        mdio: mdio {
                                #address-cells = <1>;
index e85d6ddea3c2171bec09a6c2a9bf3bfe817c2478..2a4cf427f5d3717317178ea35c0c335e9e32b03b 100644 (file)
@@ -341,7 +341,7 @@ emmc: sdhc@5a000000 {
                        cdns,phy-dll-delay-sdclk-hsmmc = <21>;
                };
 
-               soc-glue@5f800000 {
+               soc_glue: soc-glue@5f800000 {
                        compatible = "socionext,uniphier-pxs3-soc-glue",
                                     "simple-mfd", "syscon";
                        reg = <0x5f800000 0x2000>;
@@ -412,10 +412,13 @@ eth0: ethernet@65000000 {
                        interrupts = <0 66 4>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_ether_rgmii>;
+                       clock-names = "ether";
                        clocks = <&sys_clk 6>;
+                       reset-names = "ether";
                        resets = <&sys_rst 6>;
                        phy-mode = "rgmii";
                        local-mac-address = [00 00 00 00 00 00];
+                       socionext,syscon-phy-mode = <&soc_glue 0>;
 
                        mdio0: mdio {
                                #address-cells = <1>;
@@ -430,10 +433,13 @@ eth1: ethernet@65200000 {
                        interrupts = <0 67 4>;
                        pinctrl-names = "default";
                        pinctrl-0 = <&pinctrl_ether1_rgmii>;
+                       clock-names = "ether";
                        clocks = <&sys_clk 7>;
+                       reset-names = "ether";
                        resets = <&sys_rst 7>;
                        phy-mode = "rgmii";
                        local-mac-address = [00 00 00 00 00 00];
+                       socionext,syscon-phy-mode = <&soc_glue 1>;
 
                        mdio1: mdio {
                                #address-cells = <1>;
index 4331006185bfc60be5a32f20bd263ad24b3762d3..98d3b4fdb9adc9d71f5b747c4dd16c6c5d4639fa 100644 (file)
@@ -24,6 +24,17 @@ rtc@280 {
                        interrupts = <2 IRQ_TYPE_LEVEL_HIGH>;
                };
 
+               pmic_eic: gpio@300 {
+                       compatible = "sprd,sc27xx-eic";
+                       reg = <0x300>;
+                       interrupt-parent = <&sc2731_pmic>;
+                       interrupts = <5 IRQ_TYPE_LEVEL_HIGH>;
+                       gpio-controller;
+                       #gpio-cells = <2>;
+                       interrupt-controller;
+                       #interrupt-cells = <2>;
+               };
+
                regulators {
                        compatible = "sprd,sc27xx-regulator";
 
index 5dbfb796d9f92aa9d6519bd70fde8a1b14fe60a2..3f5160d2f1307b0db5076d3dc2844fffc544489f 100644 (file)
@@ -7,6 +7,8 @@
  */
 
 #include <dt-bindings/interrupt-controller/arm-gic.h>
+#include <dt-bindings/input/input.h>
+#include <dt-bindings/gpio/gpio.h>
 #include "whale2.dtsi"
 
 / {
@@ -326,7 +328,7 @@ port@2 {
                                        reg = <4>;
                                        soc_funnel_in_port1: endpoint {
                                                slave-mode;
-                                               remote-endpioint =
+                                               remote-endpoint =
                                                        <&stm_out_port>;
                                        };
                                };
@@ -679,5 +681,33 @@ etm7_out: endpoint {
                                };
                        };
                };
+
+               gpio-keys {
+                       compatible = "gpio-keys";
+
+                       key-volumedown {
+                               label = "Volume Down Key";
+                               linux,code = <KEY_VOLUMEDOWN>;
+                               gpios = <&eic_debounce 2 GPIO_ACTIVE_LOW>;
+                               debounce-interval = <2>;
+                               wakeup-source;
+                       };
+
+                       key-volumeup {
+                               label = "Volume Up Key";
+                               linux,code = <KEY_VOLUMEUP>;
+                               gpios = <&pmic_eic 10 GPIO_ACTIVE_HIGH>;
+                               debounce-interval = <2>;
+                               wakeup-source;
+                       };
+
+                       key-power {
+                               label = "Power Key";
+                               linux,code = <KEY_POWER>;
+                               gpios = <&pmic_eic 1 GPIO_ACTIVE_HIGH>;
+                               debounce-interval = <2>;
+                               wakeup-source;
+                       };
+               };
        };
 };
index 66a881e6da920d9ee317d188533a8d5c54e571bd..e9db9108f3c0648e4245e84e9c0ddf6ffb4f152b 100644 (file)
@@ -154,6 +154,56 @@ hwlock: hwspinlock@40500000 {
                                clocks = <&aon_gate CLK_SPLK_EB>;
                        };
 
+                       eic_debounce: gpio@40210000 {
+                               compatible = "sprd,sc9860-eic-debounce";
+                               reg = <0 0x40210000 0 0x80>;
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               interrupt-controller;
+                               #interrupt-cells = <2>;
+                               interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+                       };
+
+                       eic_latch: gpio@40210080 {
+                               compatible = "sprd,sc9860-eic-latch";
+                               reg = <0 0x40210080 0 0x20>;
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               interrupt-controller;
+                               #interrupt-cells = <2>;
+                               interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+                       };
+
+                       eic_async: gpio@402100a0 {
+                               compatible = "sprd,sc9860-eic-async";
+                               reg = <0 0x402100a0 0 0x20>;
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               interrupt-controller;
+                               #interrupt-cells = <2>;
+                               interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+                       };
+
+                       eic_sync: gpio@402100c0 {
+                               compatible = "sprd,sc9860-eic-sync";
+                               reg = <0 0x402100c0 0 0x20>;
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               interrupt-controller;
+                               #interrupt-cells = <2>;
+                               interrupts = <GIC_SPI 52 IRQ_TYPE_LEVEL_HIGH>;
+                       };
+
+                       ap_gpio: gpio@40280000 {
+                               compatible = "sprd,sc9860-gpio";
+                               reg = <0 0x40280000 0 0x1000>;
+                               gpio-controller;
+                               #gpio-cells = <2>;
+                               interrupt-controller;
+                               #interrupt-cells = <2>;
+                               interrupts = <GIC_SPI 50 IRQ_TYPE_LEVEL_HIGH>;
+                       };
+
                        pin_controller: pinctrl@402a0000 {
                                compatible = "sprd,sc9860-pinctrl";
                                reg = <0 0x402a0000 0 0x10000>;
@@ -164,8 +214,9 @@ watchdog@40310000 {
                                reg = <0 0x40310000 0 0x1000>;
                                interrupts = <GIC_SPI 61 IRQ_TYPE_LEVEL_HIGH>;
                                timeout-sec = <12>;
-                               clock-names = "enable";
-                               clocks = <&aon_gate CLK_APCPU_WDG_EB>;
+                               clock-names = "enable", "rtc_enable";
+                               clocks = <&aon_gate CLK_APCPU_WDG_EB>,
+                                      <&aon_gate CLK_AP_WDG_RTC_EB>;
                        };
                };
 
diff --git a/arch/arm64/boot/dts/synaptics/Makefile b/arch/arm64/boot/dts/synaptics/Makefile
new file mode 100644 (file)
index 0000000..de71ddd
--- /dev/null
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
+# Berlin SoC Family
+dtb-$(CONFIG_ARCH_BERLIN) += berlin4ct-dmp.dtb
+dtb-$(CONFIG_ARCH_BERLIN) += berlin4ct-stb.dtb
diff --git a/arch/arm64/boot/dts/synaptics/berlin4ct-dmp.dts b/arch/arm64/boot/dts/synaptics/berlin4ct-dmp.dts
new file mode 100644 (file)
index 0000000..c64a179
--- /dev/null
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2015 Marvell Technology Group Ltd.
+ *
+ * Author: Jisheng Zhang <jszhang@marvell.com>
+ */
+
+/dts-v1/;
+
+#include "berlin4ct.dtsi"
+
+/ {
+       model = "Marvell BG4CT DMP board";
+       compatible = "marvell,berlin4ct-dmp", "marvell,berlin4ct", "marvell,berlin";
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       memory@1000000 {
+               device_type = "memory";
+               /* the first 16MB is for firmwares' usage */
+               reg = <0 0x01000000 0 0x7f000000>;
+       };
+};
+
+&uart0 {
+       status = "okay";
+};
diff --git a/arch/arm64/boot/dts/synaptics/berlin4ct-stb.dts b/arch/arm64/boot/dts/synaptics/berlin4ct-stb.dts
new file mode 100644 (file)
index 0000000..277dccf
--- /dev/null
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2015 Marvell Technology Group Ltd.
+ *
+ * Author: Jisheng Zhang <jszhang@marvell.com>
+ */
+
+/dts-v1/;
+
+#include "berlin4ct.dtsi"
+
+/ {
+       model = "Marvell BG4CT STB board";
+       compatible = "marvell,berlin4ct-stb", "marvell,berlin4ct", "marvell,berlin";
+
+       chosen {
+               stdout-path = "serial0:115200n8";
+       };
+
+       memory@1000000 {
+               device_type = "memory";
+               /* the first 16MB is for firmwares' usage */
+               reg = <0 0x01000000 0 0x7f000000>;
+       };
+};
+
+&uart0 {
+       status = "okay";
+};
similarity index 78%
rename from arch/arm64/boot/dts/marvell/berlin4ct.dtsi
rename to arch/arm64/boot/dts/synaptics/berlin4ct.dtsi
index d2f88b92d8e21e867419e8556b4611c2e10a384d..216767e2edf6f319aab131d000cc545fbc96538a 100644 (file)
@@ -1,45 +1,8 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
 /*
  * Copyright (C) 2015 Marvell Technology Group Ltd.
  *
  * Author: Jisheng Zhang <jszhang@marvell.com>
- *
- * This file is dual-licensed: you can use it either under the terms
- * of the GPLv2 or the X11 license, at your option. Note that this dual
- * licensing only applies to this file, and not this project as a
- * whole.
- *
- *  a) This library 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 library is distributed in the hope that it will be useful,
- *     but WITHOUT ANY WARRANTY; without even the implied warranty of
- *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *     GNU General Public License for more details.
- *
- * Or, alternatively,
- *
- *  b) 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 <dt-bindings/interrupt-controller/arm-gic.h>
index 17ea72b1b3898bd0d9ccfb4e0f71128d0bcf1ed6..3cfa8ca267384615694e693ed0371df694fea1f4 100644 (file)
@@ -53,6 +53,7 @@ CONFIG_ARCH_R8A7796=y
 CONFIG_ARCH_R8A77965=y
 CONFIG_ARCH_R8A77970=y
 CONFIG_ARCH_R8A77980=y
+CONFIG_ARCH_R8A77990=y
 CONFIG_ARCH_R8A77995=y
 CONFIG_ARCH_STRATIX10=y
 CONFIG_ARCH_TEGRA=y
@@ -75,6 +76,7 @@ CONFIG_PCI_HISI=y
 CONFIG_PCIE_QCOM=y
 CONFIG_PCIE_KIRIN=y
 CONFIG_PCIE_ARMADA_8K=y
+CONFIG_PCIE_HISI_STB=y
 CONFIG_PCI_AARDVARK=y
 CONFIG_PCI_TEGRA=y
 CONFIG_PCIE_RCAR=y
@@ -158,8 +160,10 @@ CONFIG_BT_HIDP=m
 # CONFIG_BT_LE is not set
 CONFIG_BT_LEDS=y
 # CONFIG_BT_DEBUGFS is not set
+CONFIG_BT_HCIBTUSB=m
 CONFIG_BT_HCIUART=m
 CONFIG_BT_HCIUART_LL=y
+CONFIG_BT_HCIUART_BCM=y
 CONFIG_CFG80211=m
 CONFIG_MAC80211=m
 CONFIG_MAC80211_LEDS=y
@@ -170,6 +174,9 @@ CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
 CONFIG_DEVTMPFS=y
 CONFIG_DEVTMPFS_MOUNT=y
 CONFIG_DMA_CMA=y
+CONFIG_CMA_SIZE_MBYTES=32
+CONFIG_HISILICON_LPC=y
+CONFIG_SIMPLE_PM_BUS=y
 CONFIG_MTD=y
 CONFIG_MTD_BLOCK=y
 CONFIG_MTD_M25P80=y
@@ -188,6 +195,9 @@ CONFIG_BLK_DEV_SD=y
 CONFIG_SCSI_SAS_ATA=y
 CONFIG_SCSI_HISI_SAS=y
 CONFIG_SCSI_HISI_SAS_PCI=y
+CONFIG_SCSI_UFSHCD=m
+CONFIG_SCSI_UFSHCD_PLATFORM=m
+CONFIG_SCSI_UFS_QCOM=m
 CONFIG_ATA=y
 CONFIG_SATA_AHCI=y
 CONFIG_SATA_AHCI_PLATFORM=y
@@ -207,8 +217,10 @@ CONFIG_VETH=m
 CONFIG_VIRTIO_NET=y
 CONFIG_AMD_XGBE=y
 CONFIG_NET_XGENE=y
+CONFIG_ATL1C=m
 CONFIG_MACB=y
 CONFIG_THUNDER_NIC_PF=y
+CONFIG_HIX5HD2_GMAC=y
 CONFIG_HNS_DSAF=y
 CONFIG_HNS_ENET=y
 CONFIG_E1000E=y
@@ -240,6 +252,7 @@ CONFIG_ROCKCHIP_PHY=y
 CONFIG_USB_PEGASUS=m
 CONFIG_USB_RTL8150=m
 CONFIG_USB_RTL8152=m
+CONFIG_USB_LAN78XX=m
 CONFIG_USB_USBNET=m
 CONFIG_USB_NET_DM9601=m
 CONFIG_USB_NET_SR9800=m
@@ -247,13 +260,19 @@ CONFIG_USB_NET_SMSC75XX=m
 CONFIG_USB_NET_SMSC95XX=m
 CONFIG_USB_NET_PLUSB=m
 CONFIG_USB_NET_MCS7830=m
+CONFIG_ATH10K=m
+CONFIG_ATH10K_PCI=m
 CONFIG_BRCMFMAC=m
+CONFIG_MWIFIEX=m
+CONFIG_MWIFIEX_PCIE=m
 CONFIG_WL18XX=m
 CONFIG_WLCORE_SDIO=m
 CONFIG_INPUT_EVDEV=y
 CONFIG_KEYBOARD_ADC=m
 CONFIG_KEYBOARD_CROS_EC=y
 CONFIG_KEYBOARD_GPIO=y
+CONFIG_INPUT_TOUCHSCREEN=y
+CONFIG_TOUCHSCREEN_ATMEL_MXT=m
 CONFIG_INPUT_MISC=y
 CONFIG_INPUT_PM8941_PWRKEY=y
 CONFIG_INPUT_HISI_POWERKEY=y
@@ -287,6 +306,7 @@ CONFIG_SERIAL_MVEBU_UART=y
 CONFIG_SERIAL_DEV_BUS=y
 CONFIG_SERIAL_DEV_CTRL_TTYPORT=y
 CONFIG_VIRTIO_CONSOLE=y
+CONFIG_I2C_HID=m
 CONFIG_I2C_CHARDEV=y
 CONFIG_I2C_MUX=y
 CONFIG_I2C_MUX_PCA954x=y
@@ -304,6 +324,7 @@ CONFIG_I2C_UNIPHIER_F=y
 CONFIG_I2C_RCAR=y
 CONFIG_I2C_CROS_EC_TUNNEL=y
 CONFIG_SPI=y
+CONFIG_SPI_ARMADA_3700=y
 CONFIG_SPI_MESON_SPICC=m
 CONFIG_SPI_MESON_SPIFC=m
 CONFIG_SPI_BCM2835=m
@@ -321,6 +342,7 @@ CONFIG_PINCTRL_MAX77620=y
 CONFIG_PINCTRL_MSM8916=y
 CONFIG_PINCTRL_MSM8994=y
 CONFIG_PINCTRL_MSM8996=y
+CONFIG_PINCTRL_MT7622=y
 CONFIG_PINCTRL_QDF2XXX=y
 CONFIG_PINCTRL_QCOM_SPMI_PMIC=y
 CONFIG_GPIO_DWAPB=y
@@ -333,6 +355,8 @@ CONFIG_GPIO_XGENE_SB=y
 CONFIG_GPIO_PCA953X=y
 CONFIG_GPIO_PCA953X_IRQ=y
 CONFIG_GPIO_MAX77620=y
+CONFIG_POWER_AVS=y
+CONFIG_ROCKCHIP_IODOMAIN=y
 CONFIG_POWER_RESET_MSM=y
 CONFIG_POWER_RESET_XGENE=y
 CONFIG_POWER_RESET_SYSCON=y
@@ -344,6 +368,7 @@ CONFIG_SENSORS_INA2XX=m
 CONFIG_THERMAL_GOV_POWER_ALLOCATOR=y
 CONFIG_CPU_THERMAL=y
 CONFIG_THERMAL_EMULATION=y
+CONFIG_ARMADA_THERMAL=y
 CONFIG_BRCMSTB_THERMAL=m
 CONFIG_EXYNOS_THERMAL=y
 CONFIG_RCAR_GEN3_THERMAL=y
@@ -362,6 +387,7 @@ CONFIG_MFD_AXP20X_RSB=y
 CONFIG_MFD_CROS_EC=y
 CONFIG_MFD_CROS_EC_I2C=y
 CONFIG_MFD_CROS_EC_SPI=y
+CONFIG_MFD_CROS_EC_CHARDEV=m
 CONFIG_MFD_EXYNOS_LPASS=m
 CONFIG_MFD_HI6421_PMIC=y
 CONFIG_MFD_HI655X_PMIC=y
@@ -440,7 +466,8 @@ CONFIG_SND_BCM2835_SOC_I2S=m
 CONFIG_SND_SOC_SAMSUNG=y
 CONFIG_SND_SOC_RCAR=m
 CONFIG_SND_SOC_AK4613=m
-CONFIG_SND_SIMPLE_CARD=y
+CONFIG_SND_SIMPLE_CARD=m
+CONFIG_SND_AUDIO_GRAPH_CARD=m
 CONFIG_USB=y
 CONFIG_USB_OTG=y
 CONFIG_USB_XHCI_HCD=y
@@ -486,6 +513,7 @@ CONFIG_MMC_SPI=y
 CONFIG_MMC_SDHI=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_EXYNOS=y
+CONFIG_MMC_DW_HI3798CV200=y
 CONFIG_MMC_DW_K3=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_MMC_SUNXI=y
@@ -515,6 +543,7 @@ CONFIG_RTC_DRV_SUN6I=y
 CONFIG_RTC_DRV_ARMADA38X=y
 CONFIG_RTC_DRV_TEGRA=y
 CONFIG_RTC_DRV_XGENE=y
+CONFIG_RTC_DRV_CROS_EC=y
 CONFIG_DMADEVICES=y
 CONFIG_DMA_BCM2835=m
 CONFIG_K3_DMA=y
@@ -557,6 +586,7 @@ CONFIG_TEGRA_IOMMU_SMMU=y
 CONFIG_ARM_SMMU=y
 CONFIG_ARM_SMMU_V3=y
 CONFIG_QCOM_IOMMU=y
+CONFIG_RPMSG_QCOM_GLINK_RPM=y
 CONFIG_RPMSG_QCOM_SMD=y
 CONFIG_RASPBERRYPI_POWER=y
 CONFIG_QCOM_SMEM=y
@@ -568,12 +598,18 @@ CONFIG_ARCH_TEGRA_132_SOC=y
 CONFIG_ARCH_TEGRA_210_SOC=y
 CONFIG_ARCH_TEGRA_186_SOC=y
 CONFIG_ARCH_TEGRA_194_SOC=y
+CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND=y
 CONFIG_EXTCON_USB_GPIO=y
+CONFIG_EXTCON_USBC_CROS_EC=y
 CONFIG_MEMORY=y
 CONFIG_TEGRA_MC=y
 CONFIG_IIO=y
 CONFIG_EXYNOS_ADC=y
 CONFIG_ROCKCHIP_SARADC=m
+CONFIG_IIO_CROS_EC_SENSORS_CORE=m
+CONFIG_IIO_CROS_EC_SENSORS=m
+CONFIG_IIO_CROS_EC_LIGHT_PROX=m
+CONFIG_IIO_CROS_EC_BARO=m
 CONFIG_PWM=y
 CONFIG_PWM_BCM2835=m
 CONFIG_PWM_CROS_EC=m
@@ -582,21 +618,26 @@ CONFIG_PWM_RCAR=m
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_PWM_SAMSUNG=y
 CONFIG_PWM_TEGRA=m
+CONFIG_PHY_HISTB_COMBPHY=y
+CONFIG_PHY_HISI_INNO_USB2=y
 CONFIG_PHY_RCAR_GEN3_USB2=y
 CONFIG_PHY_RCAR_GEN3_USB3=m
 CONFIG_PHY_HI6220_USB=y
 CONFIG_PHY_QCOM_USB_HS=y
 CONFIG_PHY_SUN4I_USB=y
 CONFIG_PHY_MVEBU_CP110_COMPHY=y
+CONFIG_PHY_QCOM_QMP=m
 CONFIG_PHY_ROCKCHIP_INNO_USB2=y
 CONFIG_PHY_ROCKCHIP_EMMC=y
 CONFIG_PHY_ROCKCHIP_PCIE=m
+CONFIG_PHY_ROCKCHIP_TYPEC=y
 CONFIG_PHY_XGENE=y
 CONFIG_PHY_TEGRA_XUSB=y
 CONFIG_QCOM_L2_PMU=y
 CONFIG_QCOM_L3_PMU=y
 CONFIG_MESON_EFUSE=m
 CONFIG_QCOM_QFPROM=y
+CONFIG_ROCKCHIP_EFUSE=y
 CONFIG_UNIPHIER_EFUSE=y
 CONFIG_TEE=y
 CONFIG_OPTEE=y
index 0094c6653b06b44ac1172688fac240bae37fe24d..d264a7274811fece4035a054a9f97e01e2ca8aac 100644 (file)
@@ -36,7 +36,7 @@
  *     Start addresses are inclusive and end addresses are exclusive; start
  *     addresses should be rounded down, end addresses up.
  *
- *     See Documentation/cachetlb.txt for more information. Please note that
+ *     See Documentation/core-api/cachetlb.rst for more information. Please note that
  *     the implementation assumes non-aliasing VIPT D-cache and (aliasing)
  *     VIPT I-cache.
  *
index 55bc1f073bfbe4b8905cb43da8cb21a509fad686..1717ba1db35ddb935720c20ec46c318d59ca9b83 100644 (file)
@@ -11,9 +11,7 @@
 
 #include <asm/cpucaps.h>
 #include <asm/cputype.h>
-#include <asm/fpsimd.h>
 #include <asm/hwcap.h>
-#include <asm/sigcontext.h>
 #include <asm/sysreg.h>
 
 /*
@@ -510,33 +508,6 @@ static inline bool system_supports_sve(void)
                cpus_have_const_cap(ARM64_SVE);
 }
 
-/*
- * Read the pseudo-ZCR used by cpufeatures to identify the supported SVE
- * vector length.
- *
- * Use only if SVE is present.
- * This function clobbers the SVE vector length.
- */
-static inline u64 read_zcr_features(void)
-{
-       u64 zcr;
-       unsigned int vq_max;
-
-       /*
-        * Set the maximum possible VL, and write zeroes to all other
-        * bits to see if they stick.
-        */
-       sve_kernel_enable(NULL);
-       write_sysreg_s(ZCR_ELx_LEN_MASK, SYS_ZCR_EL1);
-
-       zcr = read_sysreg_s(SYS_ZCR_EL1);
-       zcr &= ~(u64)ZCR_ELx_LEN_MASK; /* find sticky 1s outside LEN field */
-       vq_max = sve_vq_from_vl(sve_get_vl());
-       zcr |= vq_max - 1; /* set LEN field to maximum effective value */
-
-       return zcr;
-}
-
 #define ARM64_SSBD_UNKNOWN             -1
 #define ARM64_SSBD_FORCE_DISABLE       0
 #define ARM64_SSBD_KERNEL              1
index aa7162ae93e3311d140057a7e3ab4150a008a0ec..fa92747a49c8ee2aae84d104b25732a980d0b72e 100644 (file)
@@ -18,6 +18,8 @@
 
 #include <asm/ptrace.h>
 #include <asm/errno.h>
+#include <asm/processor.h>
+#include <asm/sigcontext.h>
 
 #ifndef __ASSEMBLY__
 
@@ -41,6 +43,8 @@ struct task_struct;
 extern void fpsimd_save_state(struct user_fpsimd_state *state);
 extern void fpsimd_load_state(struct user_fpsimd_state *state);
 
+extern void fpsimd_save(void);
+
 extern void fpsimd_thread_switch(struct task_struct *next);
 extern void fpsimd_flush_thread(void);
 
@@ -49,12 +53,27 @@ extern void fpsimd_preserve_current_state(void);
 extern void fpsimd_restore_current_state(void);
 extern void fpsimd_update_current_state(struct user_fpsimd_state const *state);
 
+extern void fpsimd_bind_task_to_cpu(void);
+extern void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *state);
+
 extern void fpsimd_flush_task_state(struct task_struct *target);
+extern void fpsimd_flush_cpu_state(void);
 extern void sve_flush_cpu_state(void);
 
 /* Maximum VL that SVE VL-agnostic software can transparently support */
 #define SVE_VL_ARCH_MAX 0x100
 
+/* Offset of FFR in the SVE register dump */
+static inline size_t sve_ffr_offset(int vl)
+{
+       return SVE_SIG_FFR_OFFSET(sve_vq_from_vl(vl)) - SVE_SIG_REGS_OFFSET;
+}
+
+static inline void *sve_pffr(struct thread_struct *thread)
+{
+       return (char *)thread->sve_state + sve_ffr_offset(thread->sve_vl);
+}
+
 extern void sve_save_state(void *state, u32 *pfpsr);
 extern void sve_load_state(void const *state, u32 const *pfpsr,
                           unsigned long vq_minus_1);
@@ -63,6 +82,8 @@ extern unsigned int sve_get_vl(void);
 struct arm64_cpu_capabilities;
 extern void sve_kernel_enable(const struct arm64_cpu_capabilities *__unused);
 
+extern u64 read_zcr_features(void);
+
 extern int __ro_after_init sve_max_vl;
 
 #ifdef CONFIG_ARM64_SVE
index 951b2076a5e222036d8fd5eb612ec0302ec0da57..102b5a5c47b6cb4a00040e7efb295d357b20c8a3 100644 (file)
 /* The hyp-stub will return this for any kvm_call_hyp() call */
 #define ARM_EXCEPTION_HYP_GONE   HVC_STUB_ERR
 
-#define KVM_ARM64_DEBUG_DIRTY_SHIFT    0
-#define KVM_ARM64_DEBUG_DIRTY          (1 << KVM_ARM64_DEBUG_DIRTY_SHIFT)
+#ifndef __ASSEMBLY__
+
+#include <linux/mm.h>
 
 /* Translate a kernel address of @sym into its equivalent linear mapping */
 #define kvm_ksym_ref(sym)                                              \
        ({                                                              \
                void *val = &sym;                                       \
                if (!is_kernel_in_hyp_mode())                           \
-                       val = phys_to_virt((u64)&sym - kimage_voffset); \
+                       val = lm_alias(&sym);                           \
                val;                                                    \
         })
 
-#ifndef __ASSEMBLY__
 struct kvm;
 struct kvm_vcpu;
 
index 95d8a0e15b5fbcede8b98a708e1ea6559eb7aada..fda9a8ca48bef71b0d4a76be1a45295af1211dd6 100644 (file)
@@ -30,6 +30,7 @@
 #include <asm/kvm.h>
 #include <asm/kvm_asm.h>
 #include <asm/kvm_mmio.h>
+#include <asm/thread_info.h>
 
 #define __KVM_HAVE_ARCH_INTC_INITIALIZED
 
@@ -219,8 +220,8 @@ struct kvm_vcpu_arch {
        /* State of various workarounds, see kvm_asm.h for bit assignment */
        u64 workaround_flags;
 
-       /* Guest debug state */
-       u64 debug_flags;
+       /* Miscellaneous vcpu state flags */
+       u64 flags;
 
        /*
         * We maintain more than a single set of debug registers to support
@@ -241,6 +242,10 @@ struct kvm_vcpu_arch {
 
        /* Pointer to host CPU context */
        kvm_cpu_context_t *host_cpu_context;
+
+       struct thread_info *host_thread_info;   /* hyp VA */
+       struct user_fpsimd_state *host_fpsimd_state;    /* hyp VA */
+
        struct {
                /* {Break,watch}point registers */
                struct kvm_guest_debug_arch regs;
@@ -296,6 +301,12 @@ struct kvm_vcpu_arch {
        bool sysregs_loaded_on_cpu;
 };
 
+/* vcpu_arch flags field values: */
+#define KVM_ARM64_DEBUG_DIRTY          (1 << 0)
+#define KVM_ARM64_FP_ENABLED           (1 << 1) /* guest FP regs loaded */
+#define KVM_ARM64_FP_HOST              (1 << 2) /* host FP regs loaded */
+#define KVM_ARM64_HOST_SVE_IN_USE      (1 << 3) /* backup for host TIF_SVE */
+
 #define vcpu_gp_regs(v)                (&(v)->arch.ctxt.gp_regs)
 
 /*
@@ -397,6 +408,19 @@ static inline void __cpu_init_hyp_mode(phys_addr_t pgd_ptr,
        kvm_call_hyp(__kvm_set_tpidr_el2, tpidr_el2);
 }
 
+static inline bool kvm_arch_check_sve_has_vhe(void)
+{
+       /*
+        * The Arm architecture specifies that implementation of SVE
+        * requires VHE also to be implemented.  The KVM code for arm64
+        * relies on this when SVE is present:
+        */
+       if (system_supports_sve())
+               return has_vhe();
+       else
+               return true;
+}
+
 static inline void kvm_arch_hardware_unsetup(void) {}
 static inline void kvm_arch_sync_events(struct kvm *kvm) {}
 static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {}
@@ -423,15 +447,18 @@ static inline void __cpu_init_stage2(void)
                  "PARange is %d bits, unsupported configuration!", parange);
 }
 
-/*
- * All host FP/SIMD state is restored on guest exit, so nothing needs
- * doing here except in the SVE case:
-*/
-static inline void kvm_fpsimd_flush_cpu_state(void)
+/* Guest/host FPSIMD coordination helpers */
+int kvm_arch_vcpu_run_map_fp(struct kvm_vcpu *vcpu);
+void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu);
+void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu);
+void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu);
+
+#ifdef CONFIG_KVM /* Avoid conflicts with core headers if CONFIG_KVM=n */
+static inline int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
 {
-       if (system_supports_sve())
-               sve_flush_cpu_state();
+       return kvm_arch_vcpu_run_map_fp(vcpu);
 }
+#endif
 
 static inline void kvm_arm_vhe_guest_enter(void)
 {
@@ -481,4 +508,8 @@ static inline int kvm_arm_have_ssbd(void)
 void kvm_vcpu_load_sysregs(struct kvm_vcpu *vcpu);
 void kvm_vcpu_put_sysregs(struct kvm_vcpu *vcpu);
 
+#define __KVM_HAVE_ARCH_VM_ALLOC
+struct kvm *kvm_arch_alloc_vm(void);
+void kvm_arch_free_vm(struct kvm *kvm);
+
 #endif /* __ARM64_KVM_HOST_H__ */
index 65ab83e8926e794d04dbeaea14b3ba9dff9ad73b..a73ae1e492007e53ffdf7d1c94d15cea33ea25ff 100644 (file)
@@ -158,7 +158,9 @@ static inline void arch_thread_struct_whitelist(unsigned long *offset,
 /* Sync TPIDR_EL0 back to thread_struct for current */
 void tls_preserve_current_state(void);
 
-#define INIT_THREAD  { }
+#define INIT_THREAD {                          \
+       .fpsimd_cpu = NR_CPUS,                  \
+}
 
 static inline void start_thread_common(struct pt_regs *regs, unsigned long pc)
 {
@@ -249,6 +251,17 @@ void cpu_clear_disr(const struct arm64_cpu_capabilities *__unused);
 extern unsigned long __ro_after_init signal_minsigstksz; /* sigframe size */
 extern void __init minsigstksz_setup(void);
 
+/*
+ * Not at the top of the file due to a direct #include cycle between
+ * <asm/fpsimd.h> and <asm/processor.h>.  Deferring this #include
+ * ensures that contents of processor.h are visible to fpsimd.h even if
+ * processor.h is included first.
+ *
+ * These prctl helpers are the only things in this file that require
+ * fpsimd.h.  The core code expects them to be in this header.
+ */
+#include <asm/fpsimd.h>
+
 /* Userspace interface for PR_SVE_{SET,GET}_VL prctl()s: */
 #define SVE_SET_VL(arg)        sve_set_current_vl(arg)
 #define SVE_GET_VL()   sve_get_current_vl()
index cbcf11b5e6377f0b87a59921d7154c1d64fccf39..cb2c10a8f0a8517edc4460809f9e3d5c5e6be178 100644 (file)
@@ -45,12 +45,6 @@ struct thread_info {
        int                     preempt_count;  /* 0 => preemptable, <0 => bug */
 };
 
-#define INIT_THREAD_INFO(tsk)                                          \
-{                                                                      \
-       .preempt_count  = INIT_PREEMPT_COUNT,                           \
-       .addr_limit     = KERNEL_DS,                                    \
-}
-
 #define thread_saved_pc(tsk)   \
        ((unsigned long)(tsk->thread.cpu_context.pc))
 #define thread_saved_sp(tsk)   \
@@ -118,5 +112,12 @@ void arch_release_task_struct(struct task_struct *tsk);
                                 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | \
                                 _TIF_NOHZ)
 
+#define INIT_THREAD_INFO(tsk)                                          \
+{                                                                      \
+       .flags          = _TIF_FOREIGN_FPSTATE,                         \
+       .preempt_count  = INIT_PREEMPT_COUNT,                           \
+       .addr_limit     = KERNEL_DS,                                    \
+}
+
 #endif /* __KERNEL__ */
 #endif /* __ASM_THREAD_INFO_H */
index 04b3256f8e6d5f8e3e368b043f0fdcfeb7c23164..4e76630dd6554673d71ad647c1108bb54f1bcea2 100644 (file)
@@ -91,6 +91,7 @@ struct kvm_regs {
 #define KVM_VGIC_V3_ADDR_TYPE_DIST     2
 #define KVM_VGIC_V3_ADDR_TYPE_REDIST   3
 #define KVM_VGIC_ITS_ADDR_TYPE         4
+#define KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION    5
 
 #define KVM_VGIC_V3_DIST_SIZE          SZ_64K
 #define KVM_VGIC_V3_REDIST_SIZE                (2 * SZ_64K)
index 97d45d5151d42a813a2be2eaee8f224ea7c9480c..d4707abb2f1678fb67cd8d83aa6da5f0ef1ce227 100644 (file)
@@ -234,8 +234,8 @@ static void __init register_insn_emulation_sysctl(void)
        struct insn_emulation *insn;
        struct ctl_table *insns_sysctl, *sysctl;
 
-       insns_sysctl = kzalloc(sizeof(*sysctl) * (nr_insn_emulated + 1),
-                             GFP_KERNEL);
+       insns_sysctl = kcalloc(nr_insn_emulated + 1, sizeof(*sysctl),
+                              GFP_KERNEL);
 
        raw_spin_lock_irqsave(&insn_emulation_lock, flags);
        list_for_each_entry(insn, &insn_emulation, node) {
index 3b527ae46e492b773a98a2a091a608bcec3dc119..84c68b14f1b2f140c97556fd491aada7e06f1410 100644 (file)
 #include <linux/sched/task_stack.h>
 #include <linux/signal.h>
 #include <linux/slab.h>
+#include <linux/stddef.h>
 #include <linux/sysctl.h>
 
 #include <asm/esr.h>
 #include <asm/fpsimd.h>
 #include <asm/cpufeature.h>
 #include <asm/cputype.h>
+#include <asm/processor.h>
 #include <asm/simd.h>
 #include <asm/sigcontext.h>
 #include <asm/sysreg.h>
  */
 struct fpsimd_last_state_struct {
        struct user_fpsimd_state *st;
-       bool sve_in_use;
 };
 
 static DEFINE_PER_CPU(struct fpsimd_last_state_struct, fpsimd_last_state);
@@ -158,19 +159,6 @@ static void sve_free(struct task_struct *task)
        __sve_free(task);
 }
 
-
-/* Offset of FFR in the SVE register dump */
-static size_t sve_ffr_offset(int vl)
-{
-       return SVE_SIG_FFR_OFFSET(sve_vq_from_vl(vl)) - SVE_SIG_REGS_OFFSET;
-}
-
-static void *sve_pffr(struct task_struct *task)
-{
-       return (char *)task->thread.sve_state +
-               sve_ffr_offset(task->thread.sve_vl);
-}
-
 static void change_cpacr(u64 val, u64 mask)
 {
        u64 cpacr = read_sysreg(CPACR_EL1);
@@ -251,31 +239,24 @@ static void task_fpsimd_load(void)
        WARN_ON(!in_softirq() && !irqs_disabled());
 
        if (system_supports_sve() && test_thread_flag(TIF_SVE))
-               sve_load_state(sve_pffr(current),
+               sve_load_state(sve_pffr(&current->thread),
                               &current->thread.uw.fpsimd_state.fpsr,
                               sve_vq_from_vl(current->thread.sve_vl) - 1);
        else
                fpsimd_load_state(&current->thread.uw.fpsimd_state);
-
-       if (system_supports_sve()) {
-               /* Toggle SVE trapping for userspace if needed */
-               if (test_thread_flag(TIF_SVE))
-                       sve_user_enable();
-               else
-                       sve_user_disable();
-
-               /* Serialised by exception return to user */
-       }
 }
 
 /*
- * Ensure current's FPSIMD/SVE storage in thread_struct is up to date
- * with respect to the CPU registers.
+ * Ensure FPSIMD/SVE storage in memory for the loaded context is up to
+ * date with respect to the CPU registers.
  *
  * Softirqs (and preemption) must be disabled.
  */
-static void task_fpsimd_save(void)
+void fpsimd_save(void)
 {
+       struct user_fpsimd_state *st = __this_cpu_read(fpsimd_last_state.st);
+       /* set by fpsimd_bind_task_to_cpu() or fpsimd_bind_state_to_cpu() */
+
        WARN_ON(!in_softirq() && !irqs_disabled());
 
        if (!test_thread_flag(TIF_FOREIGN_FPSTATE)) {
@@ -290,10 +271,9 @@ static void task_fpsimd_save(void)
                                return;
                        }
 
-                       sve_save_state(sve_pffr(current),
-                                      &current->thread.uw.fpsimd_state.fpsr);
+                       sve_save_state(sve_pffr(&current->thread), &st->fpsr);
                } else
-                       fpsimd_save_state(&current->thread.uw.fpsimd_state);
+                       fpsimd_save_state(st);
        }
 }
 
@@ -588,7 +568,7 @@ int sve_set_vector_length(struct task_struct *task,
        if (task == current) {
                local_bh_disable();
 
-               task_fpsimd_save();
+               fpsimd_save();
                set_thread_flag(TIF_FOREIGN_FPSTATE);
        }
 
@@ -608,10 +588,8 @@ int sve_set_vector_length(struct task_struct *task,
        task->thread.sve_vl = vl;
 
 out:
-       if (flags & PR_SVE_VL_INHERIT)
-               set_tsk_thread_flag(task, TIF_SVE_VL_INHERIT);
-       else
-               clear_tsk_thread_flag(task, TIF_SVE_VL_INHERIT);
+       update_tsk_thread_flag(task, TIF_SVE_VL_INHERIT,
+                              flags & PR_SVE_VL_INHERIT);
 
        return 0;
 }
@@ -755,6 +733,33 @@ void sve_kernel_enable(const struct arm64_cpu_capabilities *__always_unused p)
        isb();
 }
 
+/*
+ * Read the pseudo-ZCR used by cpufeatures to identify the supported SVE
+ * vector length.
+ *
+ * Use only if SVE is present.
+ * This function clobbers the SVE vector length.
+ */
+u64 read_zcr_features(void)
+{
+       u64 zcr;
+       unsigned int vq_max;
+
+       /*
+        * Set the maximum possible VL, and write zeroes to all other
+        * bits to see if they stick.
+        */
+       sve_kernel_enable(NULL);
+       write_sysreg_s(ZCR_ELx_LEN_MASK, SYS_ZCR_EL1);
+
+       zcr = read_sysreg_s(SYS_ZCR_EL1);
+       zcr &= ~(u64)ZCR_ELx_LEN_MASK; /* find sticky 1s outside LEN field */
+       vq_max = sve_vq_from_vl(sve_get_vl());
+       zcr |= vq_max - 1; /* set LEN field to maximum effective value */
+
+       return zcr;
+}
+
 void __init sve_setup(void)
 {
        u64 zcr;
@@ -829,7 +834,7 @@ asmlinkage void do_sve_acc(unsigned int esr, struct pt_regs *regs)
 
        local_bh_disable();
 
-       task_fpsimd_save();
+       fpsimd_save();
        fpsimd_to_sve(current);
 
        /* Force ret_to_user to reload the registers: */
@@ -882,31 +887,25 @@ asmlinkage void do_fpsimd_exc(unsigned int esr, struct pt_regs *regs)
 
 void fpsimd_thread_switch(struct task_struct *next)
 {
+       bool wrong_task, wrong_cpu;
+
        if (!system_supports_fpsimd())
                return;
+
+       /* Save unsaved fpsimd state, if any: */
+       fpsimd_save();
+
        /*
-        * Save the current FPSIMD state to memory, but only if whatever is in
-        * the registers is in fact the most recent userland FPSIMD state of
-        * 'current'.
+        * Fix up TIF_FOREIGN_FPSTATE to correctly describe next's
+        * state.  For kernel threads, FPSIMD registers are never loaded
+        * and wrong_task and wrong_cpu will always be true.
         */
-       if (current->mm)
-               task_fpsimd_save();
+       wrong_task = __this_cpu_read(fpsimd_last_state.st) !=
+                                       &next->thread.uw.fpsimd_state;
+       wrong_cpu = next->thread.fpsimd_cpu != smp_processor_id();
 
-       if (next->mm) {
-               /*
-                * If we are switching to a task whose most recent userland
-                * FPSIMD state is already in the registers of *this* cpu,
-                * we can skip loading the state from memory. Otherwise, set
-                * the TIF_FOREIGN_FPSTATE flag so the state will be loaded
-                * upon the next return to userland.
-                */
-               if (__this_cpu_read(fpsimd_last_state.st) ==
-                       &next->thread.uw.fpsimd_state
-                   && next->thread.fpsimd_cpu == smp_processor_id())
-                       clear_tsk_thread_flag(next, TIF_FOREIGN_FPSTATE);
-               else
-                       set_tsk_thread_flag(next, TIF_FOREIGN_FPSTATE);
-       }
+       update_tsk_thread_flag(next, TIF_FOREIGN_FPSTATE,
+                              wrong_task || wrong_cpu);
 }
 
 void fpsimd_flush_thread(void)
@@ -972,7 +971,7 @@ void fpsimd_preserve_current_state(void)
                return;
 
        local_bh_disable();
-       task_fpsimd_save();
+       fpsimd_save();
        local_bh_enable();
 }
 
@@ -992,14 +991,33 @@ void fpsimd_signal_preserve_current_state(void)
  * Associate current's FPSIMD context with this cpu
  * Preemption must be disabled when calling this function.
  */
-static void fpsimd_bind_to_cpu(void)
+void fpsimd_bind_task_to_cpu(void)
 {
        struct fpsimd_last_state_struct *last =
                this_cpu_ptr(&fpsimd_last_state);
 
        last->st = &current->thread.uw.fpsimd_state;
-       last->sve_in_use = test_thread_flag(TIF_SVE);
        current->thread.fpsimd_cpu = smp_processor_id();
+
+       if (system_supports_sve()) {
+               /* Toggle SVE trapping for userspace if needed */
+               if (test_thread_flag(TIF_SVE))
+                       sve_user_enable();
+               else
+                       sve_user_disable();
+
+               /* Serialised by exception return to user */
+       }
+}
+
+void fpsimd_bind_state_to_cpu(struct user_fpsimd_state *st)
+{
+       struct fpsimd_last_state_struct *last =
+               this_cpu_ptr(&fpsimd_last_state);
+
+       WARN_ON(!in_softirq() && !irqs_disabled());
+
+       last->st = st;
 }
 
 /*
@@ -1016,7 +1034,7 @@ void fpsimd_restore_current_state(void)
 
        if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
                task_fpsimd_load();
-               fpsimd_bind_to_cpu();
+               fpsimd_bind_task_to_cpu();
        }
 
        local_bh_enable();
@@ -1039,9 +1057,9 @@ void fpsimd_update_current_state(struct user_fpsimd_state const *state)
                fpsimd_to_sve(current);
 
        task_fpsimd_load();
+       fpsimd_bind_task_to_cpu();
 
-       if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE))
-               fpsimd_bind_to_cpu();
+       clear_thread_flag(TIF_FOREIGN_FPSTATE);
 
        local_bh_enable();
 }
@@ -1054,29 +1072,12 @@ void fpsimd_flush_task_state(struct task_struct *t)
        t->thread.fpsimd_cpu = NR_CPUS;
 }
 
-static inline void fpsimd_flush_cpu_state(void)
+void fpsimd_flush_cpu_state(void)
 {
        __this_cpu_write(fpsimd_last_state.st, NULL);
+       set_thread_flag(TIF_FOREIGN_FPSTATE);
 }
 
-/*
- * Invalidate any task SVE state currently held in this CPU's regs.
- *
- * This is used to prevent the kernel from trying to reuse SVE register data
- * that is detroyed by KVM guest enter/exit.  This function should go away when
- * KVM SVE support is implemented.  Don't use it for anything else.
- */
-#ifdef CONFIG_ARM64_SVE
-void sve_flush_cpu_state(void)
-{
-       struct fpsimd_last_state_struct const *last =
-               this_cpu_ptr(&fpsimd_last_state);
-
-       if (last->st && last->sve_in_use)
-               fpsimd_flush_cpu_state();
-}
-#endif /* CONFIG_ARM64_SVE */
-
 #ifdef CONFIG_KERNEL_MODE_NEON
 
 DEFINE_PER_CPU(bool, kernel_neon_busy);
@@ -1110,11 +1111,8 @@ void kernel_neon_begin(void)
 
        __this_cpu_write(kernel_neon_busy, true);
 
-       /* Save unsaved task fpsimd state, if any: */
-       if (current->mm) {
-               task_fpsimd_save();
-               set_thread_flag(TIF_FOREIGN_FPSTATE);
-       }
+       /* Save unsaved fpsimd state, if any: */
+       fpsimd_save();
 
        /* Invalidate any task state remaining in the fpsimd regs: */
        fpsimd_flush_cpu_state();
@@ -1236,13 +1234,10 @@ static int fpsimd_cpu_pm_notifier(struct notifier_block *self,
 {
        switch (cmd) {
        case CPU_PM_ENTER:
-               if (current->mm)
-                       task_fpsimd_save();
+               fpsimd_save();
                fpsimd_flush_cpu_state();
                break;
        case CPU_PM_EXIT:
-               if (current->mm)
-                       set_thread_flag(TIF_FOREIGN_FPSTATE);
                break;
        case CPU_PM_ENTER_FAILED:
        default:
index f08a2ed9db0db31c8d911ab1e8be3c98953a2f27..e10bc363f533df53f7a9d6e343f6d1b4e7996909 100644 (file)
@@ -59,7 +59,7 @@
 #include <asm/processor.h>
 #include <asm/stacktrace.h>
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 #include <linux/stackprotector.h>
 unsigned long __stack_chk_guard __read_mostly;
 EXPORT_SYMBOL(__stack_chk_guard);
index bd732644c2f6af1bbe5ac00d8aaaa041c621080e..5c338ce5a7fa13e1bccf7f264f7e6db24ca63cc2 100644 (file)
@@ -44,6 +44,7 @@
 #include <asm/compat.h>
 #include <asm/cpufeature.h>
 #include <asm/debug-monitors.h>
+#include <asm/fpsimd.h>
 #include <asm/pgtable.h>
 #include <asm/stacktrace.h>
 #include <asm/syscall.h>
index a2e3a5af11130b4dec6d2270101d635d4c91f264..47b23bf617c76a01516168b8eb0c8e3ea1d64505 100644 (file)
@@ -39,6 +39,7 @@ config KVM
        select HAVE_KVM_IRQ_ROUTING
        select IRQ_BYPASS_MANAGER
        select HAVE_KVM_IRQ_BYPASS
+       select HAVE_KVM_VCPU_RUN_PID_CHANGE
        ---help---
          Support hosting virtualized guest machines.
          We don't support KVM with 16K page tables yet, due to the multiple
index 93afff91cb7cf7d87da504d4855186e94d54180f..0f2a135ba15bbe5bd66d148325d3ed227b1fe072 100644 (file)
@@ -19,7 +19,7 @@ kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/psci.o $(KVM)/arm/perf.o
 kvm-$(CONFIG_KVM_ARM_HOST) += inject_fault.o regmap.o va_layout.o
 kvm-$(CONFIG_KVM_ARM_HOST) += hyp.o hyp-init.o handle_exit.o
 kvm-$(CONFIG_KVM_ARM_HOST) += guest.o debug.o reset.o sys_regs.o sys_regs_generic_v8.o
-kvm-$(CONFIG_KVM_ARM_HOST) += vgic-sys-reg-v3.o
+kvm-$(CONFIG_KVM_ARM_HOST) += vgic-sys-reg-v3.o fpsimd.o
 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/aarch32.o
 
 kvm-$(CONFIG_KVM_ARM_HOST) += $(KVM)/arm/vgic/vgic.o
index a1f4ebdfe6d3fbe59ac5d22a139b9f159b7cd48f..00d422336a45225ea8f9b16c6a99ebf042ebf68c 100644 (file)
@@ -103,7 +103,7 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu)
  *
  * Additionally, KVM only traps guest accesses to the debug registers if
  * the guest is not actively using them (see the KVM_ARM64_DEBUG_DIRTY
- * flag on vcpu->arch.debug_flags).  Since the guest must not interfere
+ * flag on vcpu->arch.flags).  Since the guest must not interfere
  * with the hardware state when debugging the guest, we must ensure that
  * trapping is enabled whenever we are debugging the guest using the
  * debug registers.
@@ -111,7 +111,7 @@ void kvm_arm_reset_debug_ptr(struct kvm_vcpu *vcpu)
 
 void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
 {
-       bool trap_debug = !(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY);
+       bool trap_debug = !(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY);
        unsigned long mdscr;
 
        trace_kvm_arm_setup_debug(vcpu, vcpu->guest_debug);
@@ -184,7 +184,7 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
                        vcpu_write_sys_reg(vcpu, mdscr, MDSCR_EL1);
 
                        vcpu->arch.debug_ptr = &vcpu->arch.external_debug_state;
-                       vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
+                       vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
                        trap_debug = true;
 
                        trace_kvm_arm_set_regset("BKPTS", get_num_brps(),
@@ -206,7 +206,7 @@ void kvm_arm_setup_debug(struct kvm_vcpu *vcpu)
 
        /* If KDE or MDE are set, perform a full save/restore cycle. */
        if (vcpu_read_sys_reg(vcpu, MDSCR_EL1) & (DBG_MDSCR_KDE | DBG_MDSCR_MDE))
-               vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
+               vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
 
        trace_kvm_arm_set_dreg32("MDCR_EL2", vcpu->arch.mdcr_el2);
        trace_kvm_arm_set_dreg32("MDSCR_EL1", vcpu_read_sys_reg(vcpu, MDSCR_EL1));
diff --git a/arch/arm64/kvm/fpsimd.c b/arch/arm64/kvm/fpsimd.c
new file mode 100644 (file)
index 0000000..dc6ecfa
--- /dev/null
@@ -0,0 +1,110 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * arch/arm64/kvm/fpsimd.c: Guest/host FPSIMD context coordination helpers
+ *
+ * Copyright 2018 Arm Limited
+ * Author: Dave Martin <Dave.Martin@arm.com>
+ */
+#include <linux/bottom_half.h>
+#include <linux/sched.h>
+#include <linux/thread_info.h>
+#include <linux/kvm_host.h>
+#include <asm/kvm_asm.h>
+#include <asm/kvm_host.h>
+#include <asm/kvm_mmu.h>
+
+/*
+ * Called on entry to KVM_RUN unless this vcpu previously ran at least
+ * once and the most recent prior KVM_RUN for this vcpu was called from
+ * the same task as current (highly likely).
+ *
+ * This is guaranteed to execute before kvm_arch_vcpu_load_fp(vcpu),
+ * such that on entering hyp the relevant parts of current are already
+ * mapped.
+ */
+int kvm_arch_vcpu_run_map_fp(struct kvm_vcpu *vcpu)
+{
+       int ret;
+
+       struct thread_info *ti = &current->thread_info;
+       struct user_fpsimd_state *fpsimd = &current->thread.uw.fpsimd_state;
+
+       /*
+        * Make sure the host task thread flags and fpsimd state are
+        * visible to hyp:
+        */
+       ret = create_hyp_mappings(ti, ti + 1, PAGE_HYP);
+       if (ret)
+               goto error;
+
+       ret = create_hyp_mappings(fpsimd, fpsimd + 1, PAGE_HYP);
+       if (ret)
+               goto error;
+
+       vcpu->arch.host_thread_info = kern_hyp_va(ti);
+       vcpu->arch.host_fpsimd_state = kern_hyp_va(fpsimd);
+error:
+       return ret;
+}
+
+/*
+ * Prepare vcpu for saving the host's FPSIMD state and loading the guest's.
+ * The actual loading is done by the FPSIMD access trap taken to hyp.
+ *
+ * Here, we just set the correct metadata to indicate that the FPSIMD
+ * state in the cpu regs (if any) belongs to current on the host.
+ *
+ * TIF_SVE is backed up here, since it may get clobbered with guest state.
+ * This flag is restored by kvm_arch_vcpu_put_fp(vcpu).
+ */
+void kvm_arch_vcpu_load_fp(struct kvm_vcpu *vcpu)
+{
+       BUG_ON(!current->mm);
+
+       vcpu->arch.flags &= ~(KVM_ARM64_FP_ENABLED | KVM_ARM64_HOST_SVE_IN_USE);
+       vcpu->arch.flags |= KVM_ARM64_FP_HOST;
+       if (test_thread_flag(TIF_SVE))
+               vcpu->arch.flags |= KVM_ARM64_HOST_SVE_IN_USE;
+}
+
+/*
+ * If the guest FPSIMD state was loaded, update the host's context
+ * tracking data mark the CPU FPSIMD regs as dirty and belonging to vcpu
+ * so that they will be written back if the kernel clobbers them due to
+ * kernel-mode NEON before re-entry into the guest.
+ */
+void kvm_arch_vcpu_ctxsync_fp(struct kvm_vcpu *vcpu)
+{
+       WARN_ON_ONCE(!irqs_disabled());
+
+       if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED) {
+               fpsimd_bind_state_to_cpu(&vcpu->arch.ctxt.gp_regs.fp_regs);
+               clear_thread_flag(TIF_FOREIGN_FPSTATE);
+               clear_thread_flag(TIF_SVE);
+       }
+}
+
+/*
+ * Write back the vcpu FPSIMD regs if they are dirty, and invalidate the
+ * cpu FPSIMD regs so that they can't be spuriously reused if this vcpu
+ * disappears and another task or vcpu appears that recycles the same
+ * struct fpsimd_state.
+ */
+void kvm_arch_vcpu_put_fp(struct kvm_vcpu *vcpu)
+{
+       local_bh_disable();
+
+       update_thread_flag(TIF_SVE,
+                          vcpu->arch.flags & KVM_ARM64_HOST_SVE_IN_USE);
+
+       if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED) {
+               /* Clean guest FP state to memory and invalidate cpu view */
+               fpsimd_save();
+               fpsimd_flush_cpu_state();
+       } else if (!test_thread_flag(TIF_FOREIGN_FPSTATE)) {
+               /* Ensure user trap controls are correctly restored */
+               fpsimd_bind_task_to_cpu();
+       }
+
+       local_bh_enable();
+}
index 3e717f66f011d43ad8a8d0b1424c9c0c66d21daa..50009766e5e5680ef7f6ca71a1e30296c2c7cd6a 100644 (file)
@@ -163,7 +163,7 @@ void __hyp_text __debug_switch_to_guest(struct kvm_vcpu *vcpu)
        if (!has_vhe())
                __debug_save_spe_nvhe(&vcpu->arch.host_debug_state.pmscr_el1);
 
-       if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
+       if (!(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY))
                return;
 
        host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
@@ -185,7 +185,7 @@ void __hyp_text __debug_switch_to_host(struct kvm_vcpu *vcpu)
        if (!has_vhe())
                __debug_restore_spe_nvhe(vcpu->arch.host_debug_state.pmscr_el1);
 
-       if (!(vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY))
+       if (!(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY))
                return;
 
        host_ctxt = kern_hyp_va(vcpu->arch.host_cpu_context);
@@ -196,7 +196,7 @@ void __hyp_text __debug_switch_to_host(struct kvm_vcpu *vcpu)
        __debug_save_state(vcpu, guest_dbg, guest_ctxt);
        __debug_restore_state(vcpu, host_dbg, host_ctxt);
 
-       vcpu->arch.debug_flags &= ~KVM_ARM64_DEBUG_DIRTY;
+       vcpu->arch.flags &= ~KVM_ARM64_DEBUG_DIRTY;
 }
 
 u32 __hyp_text __kvm_get_mdcr_el2(void)
index e41a161d313a6f93ab92690bce5053b7f2b952c8..fad1e164fe4883fc3be8f212fc22ebe3dc28e355 100644 (file)
@@ -166,46 +166,3 @@ abort_guest_exit_end:
        orr     x0, x0, x5
 1:     ret
 ENDPROC(__guest_exit)
-
-ENTRY(__fpsimd_guest_restore)
-       // x0: esr
-       // x1: vcpu
-       // x2-x29,lr: vcpu regs
-       // vcpu x0-x1 on the stack
-       stp     x2, x3, [sp, #-16]!
-       stp     x4, lr, [sp, #-16]!
-
-alternative_if_not ARM64_HAS_VIRT_HOST_EXTN
-       mrs     x2, cptr_el2
-       bic     x2, x2, #CPTR_EL2_TFP
-       msr     cptr_el2, x2
-alternative_else
-       mrs     x2, cpacr_el1
-       orr     x2, x2, #CPACR_EL1_FPEN
-       msr     cpacr_el1, x2
-alternative_endif
-       isb
-
-       mov     x3, x1
-
-       ldr     x0, [x3, #VCPU_HOST_CONTEXT]
-       kern_hyp_va x0
-       add     x0, x0, #CPU_GP_REG_OFFSET(CPU_FP_REGS)
-       bl      __fpsimd_save_state
-
-       add     x2, x3, #VCPU_CONTEXT
-       add     x0, x2, #CPU_GP_REG_OFFSET(CPU_FP_REGS)
-       bl      __fpsimd_restore_state
-
-       // Skip restoring fpexc32 for AArch64 guests
-       mrs     x1, hcr_el2
-       tbnz    x1, #HCR_RW_SHIFT, 1f
-       ldr     x4, [x3, #VCPU_FPEXC32_EL2]
-       msr     fpexc32_el2, x4
-1:
-       ldp     x4, lr, [sp], #16
-       ldp     x2, x3, [sp], #16
-       ldp     x0, x1, [sp], #16
-
-       eret
-ENDPROC(__fpsimd_guest_restore)
index 05d8369790321e48f895eb4e5b802c7b3fdaf16a..24b4fbafe3e4ac9f9c30aaa2da04c16a798bf9ff 100644 (file)
@@ -149,25 +149,6 @@ wa_epilogue:
 
 el1_trap:
        get_vcpu_ptr    x1, x0
-
-       mrs             x0, esr_el2
-       lsr             x0, x0, #ESR_ELx_EC_SHIFT
-       /*
-        * x0: ESR_EC
-        * x1: vcpu pointer
-        */
-
-       /*
-        * We trap the first access to the FP/SIMD to save the host context
-        * and restore the guest context lazily.
-        * If FP/SIMD is not implemented, handle the trap and inject an
-        * undefined instruction exception to the guest.
-        */
-alternative_if_not ARM64_HAS_NO_FPSIMD
-       cmp     x0, #ESR_ELx_EC_FP_ASIMD
-       b.eq    __fpsimd_guest_restore
-alternative_else_nop_endif
-
        mov     x0, #ARM_EXCEPTION_TRAP
        b       __guest_exit
 
index c50cedc447f1ab33e2eda5682d6b72fda272514d..d496ef579859627edd1ba98c1233d9584cd407e3 100644 (file)
 
 #include <kvm/arm_psci.h>
 
+#include <asm/cpufeature.h>
 #include <asm/kvm_asm.h>
 #include <asm/kvm_emulate.h>
+#include <asm/kvm_host.h>
 #include <asm/kvm_hyp.h>
 #include <asm/kvm_mmu.h>
 #include <asm/fpsimd.h>
 #include <asm/debug-monitors.h>
+#include <asm/processor.h>
+#include <asm/thread_info.h>
 
-static bool __hyp_text __fpsimd_enabled_nvhe(void)
+/* Check whether the FP regs were dirtied while in the host-side run loop: */
+static bool __hyp_text update_fp_enabled(struct kvm_vcpu *vcpu)
 {
-       return !(read_sysreg(cptr_el2) & CPTR_EL2_TFP);
-}
+       if (vcpu->arch.host_thread_info->flags & _TIF_FOREIGN_FPSTATE)
+               vcpu->arch.flags &= ~(KVM_ARM64_FP_ENABLED |
+                                     KVM_ARM64_FP_HOST);
 
-static bool fpsimd_enabled_vhe(void)
-{
-       return !!(read_sysreg(cpacr_el1) & CPACR_EL1_FPEN);
+       return !!(vcpu->arch.flags & KVM_ARM64_FP_ENABLED);
 }
 
 /* Save the 32-bit only FPSIMD system register state */
@@ -93,7 +97,10 @@ static void activate_traps_vhe(struct kvm_vcpu *vcpu)
 
        val = read_sysreg(cpacr_el1);
        val |= CPACR_EL1_TTA;
-       val &= ~(CPACR_EL1_FPEN | CPACR_EL1_ZEN);
+       val &= ~CPACR_EL1_ZEN;
+       if (!update_fp_enabled(vcpu))
+               val &= ~CPACR_EL1_FPEN;
+
        write_sysreg(val, cpacr_el1);
 
        write_sysreg(kvm_get_hyp_vector(), vbar_el1);
@@ -106,7 +113,10 @@ static void __hyp_text __activate_traps_nvhe(struct kvm_vcpu *vcpu)
        __activate_traps_common(vcpu);
 
        val = CPTR_EL2_DEFAULT;
-       val |= CPTR_EL2_TTA | CPTR_EL2_TFP | CPTR_EL2_TZ;
+       val |= CPTR_EL2_TTA | CPTR_EL2_TZ;
+       if (!update_fp_enabled(vcpu))
+               val |= CPTR_EL2_TFP;
+
        write_sysreg(val, cptr_el2);
 }
 
@@ -319,6 +329,50 @@ static bool __hyp_text __skip_instr(struct kvm_vcpu *vcpu)
        }
 }
 
+static bool __hyp_text __hyp_switch_fpsimd(struct kvm_vcpu *vcpu)
+{
+       struct user_fpsimd_state *host_fpsimd = vcpu->arch.host_fpsimd_state;
+
+       if (has_vhe())
+               write_sysreg(read_sysreg(cpacr_el1) | CPACR_EL1_FPEN,
+                            cpacr_el1);
+       else
+               write_sysreg(read_sysreg(cptr_el2) & ~(u64)CPTR_EL2_TFP,
+                            cptr_el2);
+
+       isb();
+
+       if (vcpu->arch.flags & KVM_ARM64_FP_HOST) {
+               /*
+                * In the SVE case, VHE is assumed: it is enforced by
+                * Kconfig and kvm_arch_init().
+                */
+               if (system_supports_sve() &&
+                   (vcpu->arch.flags & KVM_ARM64_HOST_SVE_IN_USE)) {
+                       struct thread_struct *thread = container_of(
+                               host_fpsimd,
+                               struct thread_struct, uw.fpsimd_state);
+
+                       sve_save_state(sve_pffr(thread), &host_fpsimd->fpsr);
+               } else {
+                       __fpsimd_save_state(host_fpsimd);
+               }
+
+               vcpu->arch.flags &= ~KVM_ARM64_FP_HOST;
+       }
+
+       __fpsimd_restore_state(&vcpu->arch.ctxt.gp_regs.fp_regs);
+
+       /* Skip restoring fpexc32 for AArch64 guests */
+       if (!(read_sysreg(hcr_el2) & HCR_RW))
+               write_sysreg(vcpu->arch.ctxt.sys_regs[FPEXC32_EL2],
+                            fpexc32_el2);
+
+       vcpu->arch.flags |= KVM_ARM64_FP_ENABLED;
+
+       return true;
+}
+
 /*
  * Return true when we were able to fixup the guest exit and should return to
  * the guest, false when we should restore the host state and return to the
@@ -335,11 +389,23 @@ static bool __hyp_text fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code)
         * same PC once the SError has been injected, and replay the
         * trapping instruction.
         */
-       if (*exit_code == ARM_EXCEPTION_TRAP && !__populate_fault_info(vcpu))
+       if (*exit_code != ARM_EXCEPTION_TRAP)
+               goto exit;
+
+       /*
+        * We trap the first access to the FP/SIMD to save the host context
+        * and restore the guest context lazily.
+        * If FP/SIMD is not implemented, handle the trap and inject an
+        * undefined instruction exception to the guest.
+        */
+       if (system_supports_fpsimd() &&
+           kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_FP_ASIMD)
+               return __hyp_switch_fpsimd(vcpu);
+
+       if (!__populate_fault_info(vcpu))
                return true;
 
-       if (static_branch_unlikely(&vgic_v2_cpuif_trap) &&
-           *exit_code == ARM_EXCEPTION_TRAP) {
+       if (static_branch_unlikely(&vgic_v2_cpuif_trap)) {
                bool valid;
 
                valid = kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_DABT_LOW &&
@@ -351,12 +417,8 @@ static bool __hyp_text fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code)
                if (valid) {
                        int ret = __vgic_v2_perform_cpuif_access(vcpu);
 
-                       if (ret == 1) {
-                               if (__skip_instr(vcpu))
-                                       return true;
-                               else
-                                       *exit_code = ARM_EXCEPTION_TRAP;
-                       }
+                       if (ret ==  1 && __skip_instr(vcpu))
+                               return true;
 
                        if (ret == -1) {
                                /* Promote an illegal access to an
@@ -369,23 +431,21 @@ static bool __hyp_text fixup_guest_exit(struct kvm_vcpu *vcpu, u64 *exit_code)
                                        *vcpu_cpsr(vcpu) &= ~DBG_SPSR_SS;
                                *exit_code = ARM_EXCEPTION_EL1_SERROR;
                        }
+
+                       goto exit;
                }
        }
 
        if (static_branch_unlikely(&vgic_v3_cpuif_trap) &&
-           *exit_code == ARM_EXCEPTION_TRAP &&
            (kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_SYS64 ||
             kvm_vcpu_trap_get_class(vcpu) == ESR_ELx_EC_CP15_32)) {
                int ret = __vgic_v3_perform_cpuif_access(vcpu);
 
-               if (ret == 1) {
-                       if (__skip_instr(vcpu))
-                               return true;
-                       else
-                               *exit_code = ARM_EXCEPTION_TRAP;
-               }
+               if (ret == 1 && __skip_instr(vcpu))
+                       return true;
        }
 
+exit:
        /* Return to the host kernel and handle the exit */
        return false;
 }
@@ -428,7 +488,6 @@ int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu)
 {
        struct kvm_cpu_context *host_ctxt;
        struct kvm_cpu_context *guest_ctxt;
-       bool fp_enabled;
        u64 exit_code;
 
        host_ctxt = vcpu->arch.host_cpu_context;
@@ -454,19 +513,14 @@ int kvm_vcpu_run_vhe(struct kvm_vcpu *vcpu)
 
        __set_host_arch_workaround_state(vcpu);
 
-       fp_enabled = fpsimd_enabled_vhe();
-
        sysreg_save_guest_state_vhe(guest_ctxt);
 
        __deactivate_traps(vcpu);
 
        sysreg_restore_host_state_vhe(host_ctxt);
 
-       if (fp_enabled) {
-               __fpsimd_save_state(&guest_ctxt->gp_regs.fp_regs);
-               __fpsimd_restore_state(&host_ctxt->gp_regs.fp_regs);
+       if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED)
                __fpsimd_save_fpexc32(vcpu);
-       }
 
        __debug_switch_to_host(vcpu);
 
@@ -478,7 +532,6 @@ int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu)
 {
        struct kvm_cpu_context *host_ctxt;
        struct kvm_cpu_context *guest_ctxt;
-       bool fp_enabled;
        u64 exit_code;
 
        vcpu = kern_hyp_va(vcpu);
@@ -514,8 +567,6 @@ int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu)
 
        __set_host_arch_workaround_state(vcpu);
 
-       fp_enabled = __fpsimd_enabled_nvhe();
-
        __sysreg_save_state_nvhe(guest_ctxt);
        __sysreg32_save_state(vcpu);
        __timer_disable_traps(vcpu);
@@ -526,11 +577,8 @@ int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu)
 
        __sysreg_restore_state_nvhe(host_ctxt);
 
-       if (fp_enabled) {
-               __fpsimd_save_state(&guest_ctxt->gp_regs.fp_regs);
-               __fpsimd_restore_state(&host_ctxt->gp_regs.fp_regs);
+       if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED)
                __fpsimd_save_fpexc32(vcpu);
-       }
 
        /*
         * This must come after restoring the host sysregs, since a non-VHE
index b3894df6bf1ad2b6ce4676e239fbc8fad3147d22..35bc16832efe28ae3e6a85d4e906f1e94024f0c4 100644 (file)
@@ -196,7 +196,7 @@ void __hyp_text __sysreg32_save_state(struct kvm_vcpu *vcpu)
        sysreg[DACR32_EL2] = read_sysreg(dacr32_el2);
        sysreg[IFSR32_EL2] = read_sysreg(ifsr32_el2);
 
-       if (has_vhe() || vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY)
+       if (has_vhe() || vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY)
                sysreg[DBGVCR32_EL2] = read_sysreg(dbgvcr32_el2);
 }
 
@@ -218,7 +218,7 @@ void __hyp_text __sysreg32_restore_state(struct kvm_vcpu *vcpu)
        write_sysreg(sysreg[DACR32_EL2], dacr32_el2);
        write_sysreg(sysreg[IFSR32_EL2], ifsr32_el2);
 
-       if (has_vhe() || vcpu->arch.debug_flags & KVM_ARM64_DEBUG_DIRTY)
+       if (has_vhe() || vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY)
                write_sysreg(sysreg[DBGVCR32_EL2], dbgvcr32_el2);
 }
 
index 6e3b969391fdbb853f621fa60f7c8760d79caa78..a4363735d3f8e11e1cac77f57cab32d23fac4915 100644 (file)
@@ -31,7 +31,6 @@
 #include <asm/debug-monitors.h>
 #include <asm/esr.h>
 #include <asm/kvm_arm.h>
-#include <asm/kvm_asm.h>
 #include <asm/kvm_coproc.h>
 #include <asm/kvm_emulate.h>
 #include <asm/kvm_host.h>
@@ -338,7 +337,7 @@ static bool trap_debug_regs(struct kvm_vcpu *vcpu,
 {
        if (p->is_write) {
                vcpu_write_sys_reg(vcpu, p->regval, r->reg);
-               vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
+               vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
        } else {
                p->regval = vcpu_read_sys_reg(vcpu, r->reg);
        }
@@ -369,7 +368,7 @@ static void reg_to_dbg(struct kvm_vcpu *vcpu,
        }
 
        *dbg_reg = val;
-       vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
+       vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
 }
 
 static void dbg_to_reg(struct kvm_vcpu *vcpu,
@@ -1441,7 +1440,7 @@ static bool trap_debug32(struct kvm_vcpu *vcpu,
 {
        if (p->is_write) {
                vcpu_cp14(vcpu, r->reg) = p->regval;
-               vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
+               vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
        } else {
                p->regval = vcpu_cp14(vcpu, r->reg);
        }
@@ -1473,7 +1472,7 @@ static bool trap_xvr(struct kvm_vcpu *vcpu,
                val |= p->regval << 32;
                *dbg_reg = val;
 
-               vcpu->arch.debug_flags |= KVM_ARM64_DEBUG_DIRTY;
+               vcpu->arch.flags |= KVM_ARM64_DEBUG_DIRTY;
        } else {
                p->regval = *dbg_reg >> 32;
        }
index 301417ae2ba815507e1d3ed1abfccd197973ecf2..c127f94da8e2854bc3a3156f4dbe31126618c559 100644 (file)
@@ -263,7 +263,7 @@ static int asids_init(void)
         */
        WARN_ON(NUM_USER_ASIDS - 1 <= num_possible_cpus());
        atomic64_set(&asid_generation, ASID_FIRST_VERSION);
-       asid_map = kzalloc(BITS_TO_LONGS(NUM_USER_ASIDS) * sizeof(*asid_map),
+       asid_map = kcalloc(BITS_TO_LONGS(NUM_USER_ASIDS), sizeof(*asid_map),
                           GFP_KERNEL);
        if (!asid_map)
                panic("Failed to allocate bitmap for %lu ASIDs\n",
index 1b18b472242034b2cfe90ff91a27da8b850bcdaa..325cfb3b858aa698a96b23433230503063375b17 100644 (file)
@@ -310,7 +310,7 @@ static void __init arm64_memory_present(void)
 }
 #endif
 
-static phys_addr_t memory_limit = (phys_addr_t)ULLONG_MAX;
+static phys_addr_t memory_limit = PHYS_ADDR_MAX;
 
 /*
  * Limit the memory size that was specified via FDT.
@@ -401,7 +401,7 @@ void __init arm64_memblock_init(void)
         * high up in memory, add back the kernel region that must be accessible
         * via the linear mapping.
         */
-       if (memory_limit != (phys_addr_t)ULLONG_MAX) {
+       if (memory_limit != PHYS_ADDR_MAX) {
                memblock_mem_limit_remove_map(memory_limit);
                memblock_add(__pa_symbol(_text), (u64)(_end - _text));
        }
@@ -666,7 +666,7 @@ __setup("keepinitrd", keepinitrd_setup);
  */
 static int dump_mem_limit(struct notifier_block *self, unsigned long v, void *p)
 {
-       if (memory_limit != (phys_addr_t)ULLONG_MAX) {
+       if (memory_limit != PHYS_ADDR_MAX) {
                pr_emerg("Memory Limit: %llu MB\n", memory_limit >> 20);
        } else {
                pr_emerg("Memory Limit: none\n");
index aef02f7ca8aaa26f020454b91d785b1614dbb060..65125d0b02dd5102639f01dd39156b3bf133bfd9 100644 (file)
@@ -30,7 +30,6 @@
 
 /* A handy thing to have if one has the RAM. Declared in head.S */
 extern unsigned long empty_zero_page;
-extern unsigned long zero_page_mask;
 
 /*
  * The PTE model described here is that of the Hexagon Virtual Machine,
index 6981949f5df3c3b8a2adef85d99de7501636d045..dc8c7e75b5d1121ac9e6febce5e341a45778b59f 100644 (file)
@@ -66,7 +66,7 @@ void __init setup_arch(char **cmdline_p)
         */
        __vmsetvec(_K_VM_event_vector);
 
-       printk(KERN_INFO "PHYS_OFFSET=0x%08x\n", PHYS_OFFSET);
+       printk(KERN_INFO "PHYS_OFFSET=0x%08lx\n", PHYS_OFFSET);
 
        /*
         * Simulator has a few differences from the hardware.
index 192584d5ac2fb8b5d131379db487968b446643bd..1495d45e472d880a0e484ed8b567435414d91884 100644 (file)
@@ -39,9 +39,6 @@ unsigned long __phys_offset;  /*  physical kernel offset >> 12  */
 /*  Set as variable to limit PMD copies  */
 int max_kernel_seg = 0x303;
 
-/*  think this should be (page_size-1) the way it's used...*/
-unsigned long zero_page_mask;
-
 /*  indicate pfn's of high memory  */
 unsigned long highstart_pfn, highend_pfn;
 
index 792437d526c65e68253b3df174c44553a89d13ef..ff861420b8f56c51dfa5133d8a0266a67027734c 100644 (file)
@@ -455,6 +455,7 @@ config IA64_MCA_RECOVERY
 
 config PERFMON
        bool "Performance monitor support"
+       depends on BROKEN
        help
          Selects whether support for the IA-64 performance monitor hardware
          is included in the kernel.  This makes some kernel data-structures a
index 94f8bf777afa62d84e74cc3456959e2090d0f6f5..dfe40cbdf3b39a70b3812eaa65484618634e7575 100644 (file)
@@ -350,7 +350,8 @@ init_record_index_pools(void)
        /* - 3 - */
        slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
        slidx_pool.buffer =
-               kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL);
+               kmalloc_array(slidx_pool.max_idx, sizeof(slidx_list_t),
+                             GFP_KERNEL);
 
        return slidx_pool.buffer ? 0 : -ENOMEM;
 }
index d76529cbff2003d4746d2a2b7bbf9b4b2d08044c..9b820f7a6a989704e4ffbd25cdfc5a247f85f341 100644 (file)
@@ -85,7 +85,7 @@ static int __init topology_init(void)
        }
 #endif
 
-       sysfs_cpus = kzalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL);
+       sysfs_cpus = kcalloc(NR_CPUS, sizeof(struct ia64_cpu), GFP_KERNEL);
        if (!sysfs_cpus)
                panic("kzalloc in topology_init failed - NR_CPUS too big?");
 
@@ -319,8 +319,8 @@ static int cpu_cache_sysfs_init(unsigned int cpu)
                return -1;
        }
 
-       this_cache=kzalloc(sizeof(struct cache_info)*unique_caches,
-                       GFP_KERNEL);
+       this_cache=kcalloc(unique_caches, sizeof(struct cache_info),
+                          GFP_KERNEL);
        if (this_cache == NULL)
                return -ENOMEM;
 
index 46ecc5d948aae84c553ab5386f969072b968a85e..acf10eb9da15c13252411746fe603785a61bffd7 100644 (file)
@@ -430,8 +430,9 @@ int ia64_itr_entry(u64 target_mask, u64 va, u64 pte, u64 log_size)
        int cpu = smp_processor_id();
 
        if (!ia64_idtrs[cpu]) {
-               ia64_idtrs[cpu] = kmalloc(2 * IA64_TR_ALLOC_MAX *
-                               sizeof (struct ia64_tr_entry), GFP_KERNEL);
+               ia64_idtrs[cpu] = kmalloc_array(2 * IA64_TR_ALLOC_MAX,
+                                               sizeof(struct ia64_tr_entry),
+                                               GFP_KERNEL);
                if (!ia64_idtrs[cpu])
                        return -ENOMEM;
        }
index 8479e9a7ce163f1a670a3c15710384f449d0a364..102aabad6d20afdb9bfff0804311d4fd683a138c 100644 (file)
@@ -132,7 +132,7 @@ static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
        printk_once(KERN_WARNING
                "PROM version < 4.50 -- implementing old PROM flush WAR\n");
 
-       war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
+       war_list = kcalloc(DEV_PER_WIDGET, sizeof(*war_list), GFP_KERNEL);
        BUG_ON(!war_list);
 
        SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
index 85d095154902453fb5896734597e849af07ea74e..d9b576df4f826c0c672d6a5d9164272f6aafa131 100644 (file)
@@ -474,7 +474,8 @@ void __init sn_irq_lh_init(void)
 {
        int i;
 
-       sn_irq_lh = kmalloc(sizeof(struct list_head *) * NR_IRQS, GFP_KERNEL);
+       sn_irq_lh = kmalloc_array(NR_IRQS, sizeof(struct list_head *),
+                                 GFP_KERNEL);
        if (!sn_irq_lh)
                panic("SN PCI INIT: Failed to allocate memory for PCI init\n");
 
index 8dbbef4a4f47be7c6dfa86db4df89c870b7dac6a..7195df1da121fba60ffe69bba64f937fe812e334 100644 (file)
@@ -184,7 +184,7 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
        /* Setup the PMU ATE map */
        soft->pbi_int_ate_resource.lowest_free_index = 0;
        soft->pbi_int_ate_resource.ate =
-           kzalloc(soft->pbi_int_ate_size * sizeof(u64), GFP_KERNEL);
+           kcalloc(soft->pbi_int_ate_size, sizeof(u64), GFP_KERNEL);
 
        if (!soft->pbi_int_ate_resource.ate) {
                kfree(soft);
index ffea82a16d2cb0897c7d2d4b6a79a67cf1130f44..b091de77b15b517960b3af941a6f5aadad936b3d 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/mm.h>
 #include <linux/io.h>
 
-/* Look at Documentation/cachetlb.txt */
+/* Look at Documentation/core-api/cachetlb.rst */
 
 /*
  * Cache handling functions.
index 7074b2215f36ce746a3a1b3a78ba8d131eccc5b8..3f9deec70b92383130b847ef3d9585db5134675e 100644 (file)
@@ -22,6 +22,11 @@ config MIPS
        select GENERIC_CPU_AUTOPROBE
        select GENERIC_IRQ_PROBE
        select GENERIC_IRQ_SHOW
+       select GENERIC_LIB_ASHLDI3
+       select GENERIC_LIB_ASHRDI3
+       select GENERIC_LIB_CMPDI2
+       select GENERIC_LIB_LSHRDI3
+       select GENERIC_LIB_UCMPDI2
        select GENERIC_PCI_IOMAP
        select GENERIC_SCHED_CLOCK if !CAVIUM_OCTEON_SOC
        select GENERIC_SMP_IDLE_THREAD
@@ -36,7 +41,6 @@ config MIPS
        select HAVE_ARCH_TRANSPARENT_HUGEPAGE if CPU_SUPPORTS_HUGEPAGES && 64BIT
        select HAVE_CBPF_JIT if (!64BIT && !CPU_MICROMIPS)
        select HAVE_EBPF_JIT if (64BIT && !CPU_MICROMIPS)
-       select HAVE_CC_STACKPROTECTOR
        select HAVE_CONTEXT_TRACKING
        select HAVE_COPY_THREAD_TLS
        select HAVE_C_RECORDMCOUNT
@@ -61,6 +65,7 @@ config MIPS
        select HAVE_OPROFILE
        select HAVE_PERF_EVENTS
        select HAVE_REGS_AND_STACK_ACCESS_API
+       select HAVE_STACKPROTECTOR
        select HAVE_SYSCALL_TRACEPOINTS
        select HAVE_VIRT_CPU_ACCOUNTING_GEN if 64BIT || !SMP
        select IRQ_FORCED_THREADING
index 4e79dbd54a339143e3a3810ec45b0ee5fb734f2d..fa75d75b5ba9177f669e6f61f6395a6db28563d0 100644 (file)
@@ -29,7 +29,7 @@
 #include <linux/leds.h>
 #include <linux/gpio.h>
 #include <linux/i2c.h>
-#include <linux/i2c-gpio.h>
+#include <linux/platform_data/i2c-gpio.h>
 #include <linux/gpio/machine.h>
 #include <asm/bootinfo.h>
 #include <asm/idle.h>
index 6b6f6851df92b68fdaaa19f2fa6f7dead54b9395..d129475fd40dee71e759d4679c3b9eac48c24e91 100644 (file)
@@ -985,7 +985,7 @@ static int __init alchemy_clk_setup_imux(int ctype)
                return -ENODEV;
        }
 
-       a = kzalloc((sizeof(*a)) * 6, GFP_KERNEL);
+       a = kcalloc(6, sizeof(*a), GFP_KERNEL);
        if (!a)
                return -ENOMEM;
 
index fc482d900dddba69eca81d08df77ccff5fb10998..4ca2c28878e0f7bc970975e75b9458fd3d4ddd8f 100644 (file)
@@ -411,8 +411,8 @@ u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
         * and if we try that first we are likely to not waste larger
         * slabs of memory.
         */
-       desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t),
-                                GFP_KERNEL|GFP_DMA);
+       desc_base = (u32)kmalloc_array(entries, sizeof(au1x_ddma_desc_t),
+                                      GFP_KERNEL|GFP_DMA);
        if (desc_base == 0)
                return 0;
 
@@ -1050,7 +1050,7 @@ static int __init dbdma_setup(unsigned int irq, dbdev_tab_t *idtable)
 {
        int ret;
 
-       dbdev_tab = kzalloc(sizeof(dbdev_tab_t) * DBDEV_TAB_SIZE, GFP_KERNEL);
+       dbdev_tab = kcalloc(DBDEV_TAB_SIZE, sizeof(dbdev_tab_t), GFP_KERNEL);
        if (!dbdev_tab)
                return -ENOMEM;
 
index d77a64f4c78ba2b6c1353373bc41969d7c8d1e4a..1454d9f6ab2d425d7828c6b934e21314e1cb2449 100644 (file)
@@ -115,7 +115,7 @@ static void __init alchemy_setup_uarts(int ctype)
        uartclk = clk_get_rate(clk);
        clk_put(clk);
 
-       ports = kzalloc(s * (c + 1), GFP_KERNEL);
+       ports = kcalloc(s, (c + 1), GFP_KERNEL);
        if (!ports) {
                printk(KERN_INFO "Alchemy: no memory for UART data\n");
                return;
@@ -198,7 +198,7 @@ static unsigned long alchemy_ehci_data[][2] __initdata = {
 
 static int __init _new_usbres(struct resource **r, struct platform_device **d)
 {
-       *r = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+       *r = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
        if (!*r)
                return -ENOMEM;
        *d = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
index 4640edab207c4cb5a3a1c44e4f7255669eaf344e..203854ddd1bb34df9ff90eae917c72515524aa41 100644 (file)
@@ -103,7 +103,7 @@ int __init db1x_register_pcmcia_socket(phys_addr_t pcmcia_attr_start,
        if (stschg_irq)
                cnt++;
 
-       sr = kzalloc(sizeof(struct resource) * cnt, GFP_KERNEL);
+       sr = kcalloc(cnt, sizeof(struct resource), GFP_KERNEL);
        if (!sr)
                return -ENOMEM;
 
@@ -178,7 +178,7 @@ int __init db1x_register_norflash(unsigned long size, int width,
                return -EINVAL;
 
        ret = -ENOMEM;
-       parts = kzalloc(sizeof(struct mtd_partition) * 5, GFP_KERNEL);
+       parts = kcalloc(5, sizeof(struct mtd_partition), GFP_KERNEL);
        if (!parts)
                goto out;
 
index edfaef0d73a4592a4ab89e4bc4f5ae0571ba05d6..a80910d2738c79a055604f1e823af03fd38ff2a6 100644 (file)
@@ -172,6 +172,8 @@ struct bcm47xx_board_type_list1 bcm47xx_board_list_board_id[] __initconst = {
        {{BCM47XX_BOARD_NETGEAR_WNDR4000, "Netgear WNDR4000"}, "U12H181T00_NETGEAR"},
        {{BCM47XX_BOARD_NETGEAR_WNDR4500V1, "Netgear WNDR4500 V1"}, "U12H189T00_NETGEAR"},
        {{BCM47XX_BOARD_NETGEAR_WNDR4500V2, "Netgear WNDR4500 V2"}, "U12H224T00_NETGEAR"},
+       {{BCM47XX_BOARD_NETGEAR_WNR1000_V3, "Netgear WNR1000 V3"}, "U12H139T00_NETGEAR"},
+       {{BCM47XX_BOARD_NETGEAR_WNR1000_V3, "Netgear WNR1000 V3"}, "U12H139T50_NETGEAR"},
        {{BCM47XX_BOARD_NETGEAR_WNR2000, "Netgear WNR2000"}, "U12H114T00_NETGEAR"},
        {{BCM47XX_BOARD_NETGEAR_WNR3500L, "Netgear WNR3500L"}, "U12H136T99_NETGEAR"},
        {{BCM47XX_BOARD_NETGEAR_WNR3500U, "Netgear WNR3500U"}, "U12H136T00_NETGEAR"},
index 88d400d256c416173a41883d2a5c05a809809d17..977990a609ba2e501f7ef4d90e7360c0b2c988a3 100644 (file)
@@ -411,6 +411,12 @@ bcm47xx_buttons_netgear_wndr4500v1[] __initconst = {
        BCM47XX_GPIO_KEY(6, KEY_RESTART),
 };
 
+static const struct gpio_keys_button
+bcm47xx_buttons_netgear_wnr1000_v3[] __initconst = {
+       BCM47XX_GPIO_KEY(2, KEY_WPS_BUTTON),
+       BCM47XX_GPIO_KEY(3, KEY_RESTART),
+};
+
 static const struct gpio_keys_button
 bcm47xx_buttons_netgear_wnr3500lv1[] __initconst = {
        BCM47XX_GPIO_KEY(4, KEY_RESTART),
@@ -670,6 +676,9 @@ int __init bcm47xx_buttons_register(void)
        case BCM47XX_BOARD_NETGEAR_WNDR4500V1:
                err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wndr4500v1);
                break;
+       case BCM47XX_BOARD_NETGEAR_WNR1000_V3:
+               err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wnr1000_v3);
+               break;
        case BCM47XX_BOARD_NETGEAR_WNR3500L:
                err = bcm47xx_copy_bdata(bcm47xx_buttons_netgear_wnr3500lv1);
                break;
index 34a7b3fbdfd9046a1e6f29d5076eecd60d672ef8..d85fcdac8bf0817779775bcde04209366c742cdd 100644 (file)
@@ -497,6 +497,12 @@ bcm47xx_leds_netgear_wndr4500v1[] __initconst = {
        BCM47XX_GPIO_LED(14, "green", "usb2", 1, LEDS_GPIO_DEFSTATE_OFF),
 };
 
+static const struct gpio_led
+bcm47xx_leds_netgear_wnr1000_v3[] __initconst = {
+       BCM47XX_GPIO_LED(0, "blue", "wlan", 0, LEDS_GPIO_DEFSTATE_OFF),
+       BCM47XX_GPIO_LED(1, "green", "wps", 0, LEDS_GPIO_DEFSTATE_OFF),
+};
+
 static const struct gpio_led
 bcm47xx_leds_netgear_wnr3500lv1[] __initconst = {
        BCM47XX_GPIO_LED(0, "blue", "wlan", 1, LEDS_GPIO_DEFSTATE_OFF),
@@ -532,7 +538,7 @@ bcm47xx_leds_simpletech_simpleshare[] __initconst = {
  * Init
  **************************************************/
 
-static struct gpio_led_platform_data bcm47xx_leds_pdata;
+static struct gpio_led_platform_data bcm47xx_leds_pdata __initdata;
 
 #define bcm47xx_set_pdata(dev_leds) do {                               \
        bcm47xx_leds_pdata.leds = dev_leds;                             \
@@ -758,6 +764,9 @@ void __init bcm47xx_leds_register(void)
        case BCM47XX_BOARD_NETGEAR_WNDR4500V1:
                bcm47xx_set_pdata(bcm47xx_leds_netgear_wndr4500v1);
                break;
+       case BCM47XX_BOARD_NETGEAR_WNR1000_V3:
+               bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr1000_v3);
+               break;
        case BCM47XX_BOARD_NETGEAR_WNR3500L:
                bcm47xx_set_pdata(bcm47xx_leds_netgear_wnr3500lv1);
                break;
index 04790f4e1805b5cc4ae5623757baada034e78814..6dec30842b2f44515b3e272e94eb31d88dce976a 100644 (file)
@@ -94,7 +94,7 @@ static int __init bmips_init_dma_ranges(void)
                goto out_bad;
 
        /* add a dummy (zero) entry at the end as a sentinel */
-       bmips_dma_ranges = kzalloc(sizeof(struct bmips_dma_range) * (len + 1),
+       bmips_dma_ranges = kcalloc(len + 1, sizeof(struct bmips_dma_range),
                                   GFP_KERNEL);
        if (!bmips_dma_ranges)
                goto out_bad;
index adce180f3ee4264cabfdf85e7032f7c661b6a4c0..abe77add8789042441d400a3d01434d41dcfc8de 100644 (file)
@@ -46,10 +46,13 @@ $(obj)/uart-ath79.c: $(srctree)/arch/mips/ath79/early_printk.c
 
 vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o $(obj)/bswapsi.o
 
-extra-y += ashldi3.c bswapsi.c
-$(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib
-$(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c
-       $(call cmd,shipped)
+extra-y += ashldi3.c
+$(obj)/ashldi3.c: $(obj)/%.c: $(srctree)/lib/%.c FORCE
+       $(call if_changed,shipped)
+
+extra-y += bswapsi.c
+$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c FORCE
+       $(call if_changed,shipped)
 
 targets := $(notdir $(vmlinuzobjs-y))
 
index d8787c9a499e4713a7e5092f540fe4d3ba49255b..d85f446cc0ce6a1e52f8a13f273a869b39ec257f 100644 (file)
@@ -34,4 +34,4 @@ dtb-$(CONFIG_DT_NONE) += \
        bcm97425svmb.dtb \
        bcm97435svmb.dtb
 
-obj-y                          += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+obj-$(CONFIG_BUILTIN_DTB)      += $(addsuffix .o, $(dtb-y))
index 24a8efcd7b038760db523802c4fbca851a740cf4..17aef35f311b8c2e467728870c24262a35c3592f 100644 (file)
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 dtb-$(CONFIG_CAVIUM_OCTEON_SOC)        += octeon_3xxx.dtb octeon_68xx.dtb
 
-obj-y                          += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+obj-$(CONFIG_BUILTIN_DTB)      += $(addsuffix .o, $(dtb-y))
index 5b1361a89e021c749c7328dbf91a5673dfc0615d..9cc48441eb71912831f0e0424fabd0ec935d0007 100644 (file)
@@ -3,4 +3,4 @@ dtb-$(CONFIG_JZ4740_QI_LB60)    += qi_lb60.dtb
 dtb-$(CONFIG_JZ4770_GCW0)      += gcw0.dtb
 dtb-$(CONFIG_JZ4780_CI20)      += ci20.dtb
 
-obj-y                          += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+obj-$(CONFIG_BUILTIN_DTB)      += $(addsuffix .o, $(dtb-y))
index cd5185bb90ae47222eab9e54570b498503e9c81d..26c6b561d6f721228a01256e9084d258be65479c 100644 (file)
@@ -45,6 +45,14 @@ cgu: jz4740-cgu@10000000 {
                #clock-cells = <1>;
        };
 
+       watchdog: watchdog@10002000 {
+               compatible = "ingenic,jz4740-watchdog";
+               reg = <0x10002000 0x10>;
+
+               clocks = <&cgu JZ4740_CLK_RTC>;
+               clock-names = "rtc";
+       };
+
        rtc_dev: rtc@10003000 {
                compatible = "ingenic,jz4740-rtc";
                reg = <0x10003000 0x40>;
index b72e53bb7292e941562ac0c1a1eb14b803609499..aa4e8f75ff5d137e1e238b62e2b1044edd28b419 100644 (file)
@@ -222,7 +222,10 @@ uart4: serial@10034000 {
 
        watchdog: watchdog@10002000 {
                compatible = "ingenic,jz4780-watchdog";
-               reg = <0x10002000 0x100>;
+               reg = <0x10002000 0x10>;
+
+               clocks = <&cgu JZ4780_CLK_RTCLK>;
+               clock-names = "rtc";
        };
 
        nemc: nemc@13410000 {
index 51ab9c1dff42a2553acc2ce559f5629bd41c4ed5..f5dfc06242b9b7bf826ec77f00f47374d79b8106 100644 (file)
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0
 dtb-$(CONFIG_DT_EASY50712)     += easy50712.dtb
 
-obj-y                          += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+obj-$(CONFIG_BUILTIN_DTB)      += $(addsuffix .o, $(dtb-y))
index c51164537c02cc34bc0a2156ae9323e49b8ed92b..3c6aed9f5439f8ab8f9a33c7c4ac5601f5cf4931 100644 (file)
@@ -1,3 +1,3 @@
 dtb-$(CONFIG_LEGACY_BOARD_OCELOT)      += ocelot_pcb123.dtb
 
-obj-y                          += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+obj-$(CONFIG_BUILTIN_DTB)      += $(addsuffix .o, $(dtb-y))
index dd239cab2f9d6e8574ea8930a2ab77d5656d38ba..4f33dbc6734824142968b1062119b50a83475557 100644 (file)
@@ -91,6 +91,72 @@ uart2: serial@100800 {
                        status = "disabled";
                };
 
+               switch@1010000 {
+                       compatible = "mscc,vsc7514-switch";
+                       reg = <0x1010000 0x10000>,
+                             <0x1030000 0x10000>,
+                             <0x1080000 0x100>,
+                             <0x10d0000 0x10000>,
+                             <0x11e0000 0x100>,
+                             <0x11f0000 0x100>,
+                             <0x1200000 0x100>,
+                             <0x1210000 0x100>,
+                             <0x1220000 0x100>,
+                             <0x1230000 0x100>,
+                             <0x1240000 0x100>,
+                             <0x1250000 0x100>,
+                             <0x1260000 0x100>,
+                             <0x1270000 0x100>,
+                             <0x1280000 0x100>,
+                             <0x1800000 0x80000>,
+                             <0x1880000 0x10000>;
+                       reg-names = "sys", "rew", "qs", "hsio", "port0",
+                                   "port1", "port2", "port3", "port4", "port5",
+                                   "port6", "port7", "port8", "port9", "port10",
+                                   "qsys", "ana";
+                       interrupts = <21 22>;
+                       interrupt-names = "xtr", "inj";
+
+                       ethernet-ports {
+                               #address-cells = <1>;
+                               #size-cells = <0>;
+
+                               port0: port@0 {
+                                       reg = <0>;
+                               };
+                               port1: port@1 {
+                                       reg = <1>;
+                               };
+                               port2: port@2 {
+                                       reg = <2>;
+                               };
+                               port3: port@3 {
+                                       reg = <3>;
+                               };
+                               port4: port@4 {
+                                       reg = <4>;
+                               };
+                               port5: port@5 {
+                                       reg = <5>;
+                               };
+                               port6: port@6 {
+                                       reg = <6>;
+                               };
+                               port7: port@7 {
+                                       reg = <7>;
+                               };
+                               port8: port@8 {
+                                       reg = <8>;
+                               };
+                               port9: port@9 {
+                                       reg = <9>;
+                               };
+                               port10: port@10 {
+                                       reg = <10>;
+                               };
+                       };
+               };
+
                reset@1070008 {
                        compatible = "mscc,ocelot-chip-reset";
                        reg = <0x1070008 0x4>;
@@ -113,5 +179,27 @@ uart2_pins: uart2-pins {
                                function = "uart2";
                        };
                };
+
+               mdio0: mdio@107009c {
+                       #address-cells = <1>;
+                       #size-cells = <0>;
+                       compatible = "mscc,ocelot-miim";
+                       reg = <0x107009c 0x36>, <0x10700f0 0x8>;
+                       interrupts = <14>;
+                       status = "disabled";
+
+                       phy0: ethernet-phy@0 {
+                               reg = <0>;
+                       };
+                       phy1: ethernet-phy@1 {
+                               reg = <1>;
+                       };
+                       phy2: ethernet-phy@2 {
+                               reg = <2>;
+                       };
+                       phy3: ethernet-phy@3 {
+                               reg = <3>;
+                       };
+               };
        };
 };
index 29d6414f88863d6066e04b2a81dc95e7eb32896b..4ccd65379059910f3a142f8e69ffdf9a1c811f31 100644 (file)
@@ -25,3 +25,23 @@ &uart0 {
 &uart2 {
        status = "okay";
 };
+
+&mdio0 {
+       status = "okay";
+};
+
+&port0 {
+       phy-handle = <&phy0>;
+};
+
+&port1 {
+       phy-handle = <&phy1>;
+};
+
+&port2 {
+       phy-handle = <&phy2>;
+};
+
+&port3 {
+       phy-handle = <&phy3>;
+};
index 3508720cb6d9e1da773e52c7ca21b2ac5cb57c30..b5f7426998b13be4218b9730bba8bf74fbb50933 100644 (file)
@@ -2,4 +2,4 @@
 dtb-$(CONFIG_MIPS_MALTA)       += malta.dtb
 dtb-$(CONFIG_LEGACY_BOARD_SEAD3)       += sead3.dtb
 
-obj-y                          += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+obj-$(CONFIG_BUILTIN_DTB)      += $(addsuffix .o, $(dtb-y))
index d630b27950f0605d58d9047cc7ab76090206dafe..45af4224494fe79804bafa62d1c8cfa0b00049ad 100644 (file)
@@ -5,4 +5,4 @@ dtb-$(CONFIG_DT_XLP_FVP)        += xlp_fvp.dtb
 dtb-$(CONFIG_DT_XLP_GVP)       += xlp_gvp.dtb
 dtb-$(CONFIG_DT_XLP_RVP)       += xlp_rvp.dtb
 
-obj-y                          += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+obj-$(CONFIG_BUILTIN_DTB)      += $(addsuffix .o, $(dtb-y))
index ba9bcef8fde91dfaa03a75f61cda7c5edb92e464..fb57f36324db7e05238a9ac4d04e5ea7ac479096 100644 (file)
@@ -4,4 +4,4 @@ dtb-$(CONFIG_DTB_PIC32_MZDA_SK)         += pic32mzda_sk.dtb
 dtb-$(CONFIG_DTB_PIC32_NONE)           += \
                                        pic32mzda_sk.dtb
 
-obj-y                          += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+obj-$(CONFIG_BUILTIN_DTB)      += $(addsuffix .o, $(dtb-y))
index 94bee5b38b53b3701072002e8d5c5939bbfb6dd9..6c26dfa0a9035dbfdc7f4730b8252e177ec4d2fc 100644 (file)
@@ -6,4 +6,4 @@ dtb-$(CONFIG_DTB_MT7620A_EVAL)  += mt7620a_eval.dtb
 dtb-$(CONFIG_DTB_OMEGA2P)      += omega2p.dtb
 dtb-$(CONFIG_DTB_VOCORE2)      += vocore2.dtb
 
-obj-y                          += $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+obj-$(CONFIG_BUILTIN_DTB)      += $(addsuffix .o, $(dtb-y))
index 3b02ff9a7c64fddcafa7b622824b0a487508e643..d8b7211a7b0f18f31a2e21d5a8eedd9f19f320a3 100644 (file)
@@ -72,6 +72,8 @@ CONFIG_POWER_SUPPLY=y
 CONFIG_BATTERY_JZ4740=y
 CONFIG_CHARGER_GPIO=y
 # CONFIG_HWMON is not set
+CONFIG_WATCHDOG=y
+CONFIG_JZ4740_WDT=y
 CONFIG_MFD_JZ4740_ADC=y
 CONFIG_REGULATOR=y
 CONFIG_REGULATOR_FIXED_VOLTAGE=y
index a2a150e4fbc2867773d7d5c4e57fe95985481ad4..c38686f89a1883d954ff3cb7044350c8d559edba 100644 (file)
@@ -19,7 +19,7 @@
 #include <asm/dec/ioasic.h>
 #include <asm/dec/machtype.h>
 
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
        unsigned int year, mon, day, hour, min, sec, real_year;
        unsigned long flags;
@@ -54,19 +54,20 @@ void read_persistent_clock(struct timespec *ts)
 
        year += real_year - 72 + 2000;
 
-       ts->tv_sec = mktime(year, mon, day, hour, min, sec);
+       ts->tv_sec = mktime64(year, mon, day, hour, min, sec);
        ts->tv_nsec = 0;
 }
 
 /*
- * In order to set the CMOS clock precisely, rtc_mips_set_mmss has to
+ * In order to set the CMOS clock precisely, update_persistent_clock64 has to
  * be called 500 ms after the second nowtime has started, because when
  * nowtime is written into the registers of the CMOS clock, it will
  * jump to the next second precisely 500 ms later.  Check the Dallas
  * DS1287 data sheet for details.
  */
-int rtc_mips_set_mmss(unsigned long nowtime)
+int update_persistent_clock64(struct timespec64 now)
 {
+       time64_t nowtime = now.tv_sec;
        int retval = 0;
        int real_seconds, real_minutes, cmos_minutes;
        unsigned char save_control, save_freq_select;
@@ -91,8 +92,7 @@ int rtc_mips_set_mmss(unsigned long nowtime)
         * messing with unknown time zones but requires your
         * RTC not to be off by more than 15 minutes
         */
-       real_seconds = nowtime % 60;
-       real_minutes = nowtime / 60;
+       real_minutes = div_s64_rem(nowtime, 60, &real_seconds);
        if (((abs(real_minutes - cmos_minutes) + 15) / 30) & 1)
                real_minutes += 30;     /* correct for half hour time zone */
        real_minutes %= 60;
index 5f74590e0bea45f526b778efd46d002c113417f1..9cdb4e4ce258390d75325ea0dba6562f13332924 100644 (file)
 # define cpu_has_shared_ftlb_entries 0
 #endif
 
+#ifdef CONFIG_MIPS_MT_SMP
+# define cpu_has_mipsmt_pertccounters \
+       (cpu_data[0].options & MIPS_CPU_MT_PER_TC_PERF_COUNTERS)
+#else
+# define cpu_has_mipsmt_pertccounters 0
+#endif /* CONFIG_MIPS_MT_SMP */
+
 /*
  * Guest capabilities
  */
index d39324c4adf136f497bfd554608b0c6ea0a597e2..5b9d02ef4f60375f9bf4370e12cd2e566890159b 100644 (file)
@@ -418,6 +418,8 @@ enum cpu_type_enum {
                                MBIT_ULL(54)    /* CPU shares FTLB RAM with another */
 #define MIPS_CPU_SHARED_FTLB_ENTRIES \
                                MBIT_ULL(55)    /* CPU shares FTLB entries with another */
+#define MIPS_CPU_MT_PER_TC_PERF_COUNTERS \
+                               MBIT_ULL(56)    /* CPU has perf counters implemented per TC (MIPSMT ASE) */
 
 /*
  * CPU ASE encodings
index cbf9da7f2f9432e93dba7f951f6ba97772b688bd..0ef8893e07f8e2b7cab6d8233673d6517ff7f92f 100644 (file)
@@ -110,6 +110,7 @@ enum bcm47xx_board {
        BCM47XX_BOARD_NETGEAR_WNDR4000,
        BCM47XX_BOARD_NETGEAR_WNDR4500V1,
        BCM47XX_BOARD_NETGEAR_WNDR4500V2,
+       BCM47XX_BOARD_NETGEAR_WNR1000_V3,
        BCM47XX_BOARD_NETGEAR_WNR2000,
        BCM47XX_BOARD_NETGEAR_WNR3500L,
        BCM47XX_BOARD_NETGEAR_WNR3500U,
index 3645974b7f6595ed1f5d6729621b3763b4399e87..c0c932ac72a71fb65c6e38b69e67fe806edcca78 100644 (file)
@@ -29,7 +29,6 @@ extern struct platform_device jz4740_i2s_device;
 extern struct platform_device jz4740_pcm_device;
 extern struct platform_device jz4740_codec_device;
 extern struct platform_device jz4740_adc_device;
-extern struct platform_device jz4740_wdt_device;
 extern struct platform_device jz4740_pwm_device;
 extern struct platform_device jz4740_dma_device;
 
index 9e1ad26abdc0232482fb39e13e4e688a9487693a..cbf5cec345f1ca55effaf34b7b42a49e5873bbd7 100644 (file)
@@ -86,7 +86,7 @@ static inline int mc146818_set_rtc_mmss(unsigned long nowtime)
        return retval;
 }
 
-static inline unsigned long mc146818_get_cmos_time(void)
+static inline time64_t mc146818_get_cmos_time(void)
 {
        unsigned int year, mon, day, hour, min, sec;
        unsigned long flags;
@@ -113,7 +113,7 @@ static inline unsigned long mc146818_get_cmos_time(void)
        spin_unlock_irqrestore(&rtc_lock, flags);
        year = mc146818_decode_year(year);
 
-       return mktime(year, mon, day, hour, min, sec);
+       return mktime64(year, mon, day, hour, min, sec);
 }
 
 #endif /* __ASM_MC146818_TIME_H */
index f65859784a4c1f41b70050b2d35a07bafade6535..ae461d91cd1faef06dc39399e7910eb28471d930 100644 (file)
 #define MIPS_CONF7_IAR         (_ULCAST_(1) << 10)
 #define MIPS_CONF7_AR          (_ULCAST_(1) << 16)
 
+/* Config7 Bits specific to MIPS Technologies. */
+
+/* Performance counters implemented Per TC */
+#define MTI_CONF7_PTC          (_ULCAST_(1) << 19)
+
 /* WatchLo* register definitions */
 #define MIPS_WATCHLO_IRW       (_ULCAST_(0x7) << 0)
 
index 17d4cd20f18c1498ac3416267f31980a56f54245..b85ec64ee7e98a067cf2dc4c35b1dc04411e02cc 100644 (file)
 
 extern spinlock_t rtc_lock;
 
-/*
- * RTC ops.  By default, they point to weak no-op RTC functions.
- *     rtc_mips_set_time - reverse the above translation and set time to RTC.
- *     rtc_mips_set_mmss - similar to rtc_set_time, but only min and sec need
- *                     to be set.  Used by RTC sync-up.
- */
-extern int rtc_mips_set_time(unsigned long);
-extern int rtc_mips_set_mmss(unsigned long);
-
 /*
  * board specific routines required by time_init().
  */
index 5b7cdd67a9d95b624d52d780ab736f779e551904..cbc5f8e87230972c85c775ef043eebe9c500811b 100644 (file)
@@ -233,22 +233,6 @@ struct platform_device jz4740_adc_device = {
        .resource       = jz4740_adc_resources,
 };
 
-/* Watchdog */
-static struct resource jz4740_wdt_resources[] = {
-       {
-               .start = JZ4740_WDT_BASE_ADDR,
-               .end   = JZ4740_WDT_BASE_ADDR + 0x10 - 1,
-               .flags = IORESOURCE_MEM,
-       },
-};
-
-struct platform_device jz4740_wdt_device = {
-       .name          = "jz4740-wdt",
-       .id            = -1,
-       .num_resources = ARRAY_SIZE(jz4740_wdt_resources),
-       .resource      = jz4740_wdt_resources,
-};
-
 /* PWM */
 struct platform_device jz4740_pwm_device = {
        .name = "jz4740-pwm",
index 67780c4b65730597e6d66d08e238b44669456823..5bf0cf44b55fb9c34441cfc30ca90fcdc4041488 100644 (file)
  *
  */
 
-#include <linux/clk.h>
-#include <linux/io.h>
-#include <linux/kernel.h>
-#include <linux/pm.h>
-
 #include <asm/reboot.h>
 
-#include <asm/mach-jz4740/base.h>
-#include <asm/mach-jz4740/timer.h>
-
 #include "reset.h"
-#include "clock.h"
 
 static void jz4740_halt(void)
 {
@@ -36,29 +27,7 @@ static void jz4740_halt(void)
        }
 }
 
-#define JZ_REG_WDT_DATA 0x00
-#define JZ_REG_WDT_COUNTER_ENABLE 0x04
-#define JZ_REG_WDT_COUNTER 0x08
-#define JZ_REG_WDT_CTRL 0x0c
-
-static void jz4740_restart(char *command)
-{
-       void __iomem *wdt_base = ioremap(JZ4740_WDT_BASE_ADDR, 0x0f);
-
-       jz4740_timer_enable_watchdog();
-
-       writeb(0, wdt_base + JZ_REG_WDT_COUNTER_ENABLE);
-
-       writew(0, wdt_base + JZ_REG_WDT_COUNTER);
-       writew(0, wdt_base + JZ_REG_WDT_DATA);
-       writew(BIT(2), wdt_base + JZ_REG_WDT_CTRL);
-
-       writeb(1, wdt_base + JZ_REG_WDT_COUNTER_ENABLE);
-       jz4740_halt();
-}
-
 void jz4740_reset_init(void)
 {
-       _machine_restart = jz4740_restart;
        _machine_halt = jz4740_halt;
 }
index c1cd41456d42f5dd6b5e45b62eee8f6b2393c2aa..cbe4742d2fffe1d8857bef4cf83cb4d7f0185882 100644 (file)
@@ -83,7 +83,7 @@ void output_task_defines(void)
        OFFSET(TASK_FLAGS, task_struct, flags);
        OFFSET(TASK_MM, task_struct, mm);
        OFFSET(TASK_PID, task_struct, pid);
-#if defined(CONFIG_CC_STACKPROTECTOR)
+#if defined(CONFIG_STACKPROTECTOR)
        OFFSET(TASK_STACK_CANARY, task_struct, stack_canary);
 #endif
        DEFINE(TASK_STRUCT_SIZE, sizeof(struct task_struct));
index 6b07b739f914d06ebb6fc8777e4b3fb2be914547..b2509c19cfb5b8cc7185f5cacadfc9f94c59fcbe 100644 (file)
@@ -414,6 +414,14 @@ static int __init ftlb_disable(char *s)
 
 __setup("noftlb", ftlb_disable);
 
+/*
+ * Check if the CPU has per tc perf counters
+ */
+static inline void cpu_set_mt_per_tc_perf(struct cpuinfo_mips *c)
+{
+       if (read_c0_config7() & MTI_CONF7_PTC)
+               c->options |= MIPS_CPU_MT_PER_TC_PERF_COUNTERS;
+}
 
 static inline void check_errata(void)
 {
@@ -1572,6 +1580,7 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
                c->cputype = CPU_34K;
                c->writecombine = _CACHE_UNCACHED;
                __cpu_name[cpu] = "MIPS 34Kc";
+               cpu_set_mt_per_tc_perf(c);
                break;
        case PRID_IMP_74K:
                c->cputype = CPU_74K;
@@ -1592,6 +1601,7 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
                c->cputype = CPU_1004K;
                c->writecombine = _CACHE_UNCACHED;
                __cpu_name[cpu] = "MIPS 1004Kc";
+               cpu_set_mt_per_tc_perf(c);
                break;
        case PRID_IMP_1074K:
                c->cputype = CPU_1074K;
@@ -1601,10 +1611,12 @@ static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
        case PRID_IMP_INTERAPTIV_UP:
                c->cputype = CPU_INTERAPTIV;
                __cpu_name[cpu] = "MIPS interAptiv";
+               cpu_set_mt_per_tc_perf(c);
                break;
        case PRID_IMP_INTERAPTIV_MP:
                c->cputype = CPU_INTERAPTIV;
                __cpu_name[cpu] = "MIPS interAptiv (multi)";
+               cpu_set_mt_per_tc_perf(c);
                break;
        case PRID_IMP_PROAPTIV_UP:
                c->cputype = CPU_PROAPTIV;
index e42113fe2762b5e8298f40a64d0d635799334d5d..896080b445c2db7e4c02adb85ad59a92d2809b2f 100644 (file)
@@ -61,7 +61,7 @@
 #endif
 3:
 
-#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
+#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
        PTR_LA  t8, __stack_chk_guard
        LONG_L  t9, TASK_STACK_CANARY(a1)
        LONG_S  t9, 0(t8)
index ee73550f0b9a422c05d527287bb95aa4dd738180..413863508f6fab1c718a19751fa030b278a506a3 100644 (file)
@@ -129,20 +129,14 @@ static struct mips_pmu mipspmu;
 
 
 #ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS
-static int cpu_has_mipsmt_pertccounters;
-
 static DEFINE_RWLOCK(pmuint_rwlock);
 
 #if defined(CONFIG_CPU_BMIPS5000)
 #define vpe_id()       (cpu_has_mipsmt_pertccounters ? \
                         0 : (smp_processor_id() & MIPS_CPUID_TO_COUNTER_MASK))
 #else
-/*
- * FIXME: For VSMP, vpe_id() is redefined for Perf-events, because
- * cpu_data[cpuid].vpe_id reports 0 for _both_ CPUs.
- */
 #define vpe_id()       (cpu_has_mipsmt_pertccounters ? \
-                        0 : smp_processor_id())
+                        0 : cpu_vpe_id(&current_cpu_data))
 #endif
 
 /* Copied from op_model_mipsxx.c */
@@ -329,7 +323,11 @@ static int mipsxx_pmu_alloc_counter(struct cpu_hw_events *cpuc,
 
 static void mipsxx_pmu_enable_event(struct hw_perf_event *evt, int idx)
 {
+       struct perf_event *event = container_of(evt, struct perf_event, hw);
        struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
+#ifdef CONFIG_MIPS_MT_SMP
+       unsigned int range = evt->event_base >> 24;
+#endif /* CONFIG_MIPS_MT_SMP */
 
        WARN_ON(idx < 0 || idx >= mipspmu.num_counters);
 
@@ -337,11 +335,37 @@ static void mipsxx_pmu_enable_event(struct hw_perf_event *evt, int idx)
                (evt->config_base & M_PERFCTL_CONFIG_MASK) |
                /* Make sure interrupt enabled. */
                MIPS_PERFCTRL_IE;
-       if (IS_ENABLED(CONFIG_CPU_BMIPS5000))
+
+#ifdef CONFIG_CPU_BMIPS5000
+       {
                /* enable the counter for the calling thread */
                cpuc->saved_ctrl[idx] |=
                        (1 << (12 + vpe_id())) | BRCM_PERFCTRL_TC;
+       }
+#else
+#ifdef CONFIG_MIPS_MT_SMP
+       if (range > V) {
+               /* The counter is processor wide. Set it up to count all TCs. */
+               pr_debug("Enabling perf counter for all TCs\n");
+               cpuc->saved_ctrl[idx] |= M_TC_EN_ALL;
+       } else
+#endif /* CONFIG_MIPS_MT_SMP */
+       {
+               unsigned int cpu, ctrl;
+
+               /*
+                * Set up the counter for a particular CPU when event->cpu is
+                * a valid CPU number. Otherwise set up the counter for the CPU
+                * scheduling this thread.
+                */
+               cpu = (event->cpu >= 0) ? event->cpu : smp_processor_id();
 
+               ctrl = M_PERFCTL_VPEID(cpu_vpe_id(&cpu_data[cpu]));
+               ctrl |= M_TC_EN_VPE;
+               cpuc->saved_ctrl[idx] |= ctrl;
+               pr_debug("Enabling perf counter for CPU%d\n", cpu);
+       }
+#endif /* CONFIG_CPU_BMIPS5000 */
        /*
         * We do not actually let the counter run. Leave it until start().
         */
@@ -655,13 +679,14 @@ static unsigned int mipspmu_perf_event_encode(const struct mips_perf_event *pev)
  * event_id.
  */
 #ifdef CONFIG_MIPS_MT_SMP
-       return ((unsigned int)pev->range << 24) |
-               (pev->cntr_mask & 0xffff00) |
-               (pev->event_id & 0xff);
-#else
-       return (pev->cntr_mask & 0xffff00) |
-               (pev->event_id & 0xff);
-#endif
+       if (num_possible_cpus() > 1)
+               return ((unsigned int)pev->range << 24) |
+                       (pev->cntr_mask & 0xffff00) |
+                       (pev->event_id & 0xff);
+       else
+#endif /* CONFIG_MIPS_MT_SMP */
+               return ((pev->cntr_mask & 0xffff00) |
+                       (pev->event_id & 0xff));
 }
 
 static const struct mips_perf_event *mipspmu_map_general_event(int idx)
@@ -1265,37 +1290,6 @@ static const struct mips_perf_event xlp_cache_map
 },
 };
 
-#ifdef CONFIG_MIPS_MT_SMP
-static void check_and_calc_range(struct perf_event *event,
-                                const struct mips_perf_event *pev)
-{
-       struct hw_perf_event *hwc = &event->hw;
-
-       if (event->cpu >= 0) {
-               if (pev->range > V) {
-                       /*
-                        * The user selected an event that is processor
-                        * wide, while expecting it to be VPE wide.
-                        */
-                       hwc->config_base |= M_TC_EN_ALL;
-               } else {
-                       /*
-                        * FIXME: cpu_data[event->cpu].vpe_id reports 0
-                        * for both CPUs.
-                        */
-                       hwc->config_base |= M_PERFCTL_VPEID(event->cpu);
-                       hwc->config_base |= M_TC_EN_VPE;
-               }
-       } else
-               hwc->config_base |= M_TC_EN_ALL;
-}
-#else
-static void check_and_calc_range(struct perf_event *event,
-                                const struct mips_perf_event *pev)
-{
-}
-#endif
-
 static int __hw_perf_event_init(struct perf_event *event)
 {
        struct perf_event_attr *attr = &event->attr;
@@ -1331,10 +1325,6 @@ static int __hw_perf_event_init(struct perf_event *event)
         */
        hwc->config_base = MIPS_PERFCTRL_IE;
 
-       /* Calculate range bits and validate it. */
-       if (num_possible_cpus() > 1)
-               check_and_calc_range(event, pev);
-
        hwc->event_base = mipspmu_perf_event_encode(pev);
        if (PERF_TYPE_RAW == event->attr.type)
                mutex_unlock(&raw_event_mutex);
@@ -1723,7 +1713,6 @@ init_hw_perf_events(void)
        }
 
 #ifdef CONFIG_MIPS_PERF_SHARED_TC_COUNTERS
-       cpu_has_mipsmt_pertccounters = read_c0_config7() & (1<<19);
        if (!cpu_has_mipsmt_pertccounters)
                counters = counters_total_to_per_cpu(counters);
 #endif
index 3775a8d694fb0879ba0abed7b2edc34a06a52a28..8d85046adcc8dd858cb5b392b68dc22da19185c4 100644 (file)
@@ -180,7 +180,7 @@ int copy_thread_tls(unsigned long clone_flags, unsigned long usp,
        return 0;
 }
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 #include <linux/stackprotector.h>
 unsigned long __stack_chk_guard __read_mostly;
 EXPORT_SYMBOL(__stack_chk_guard);
index 0c0c23c9c9f5a7d9b00fbf71c78df697ecbb7612..9f6c3f2aa2e2eff85e31480fee4e765b628364b2 100644 (file)
@@ -811,7 +811,7 @@ long arch_ptrace(struct task_struct *child, long request,
                                /*
                                 * The odd registers are actually the high
                                 * order bits of the values stored in the even
-                                * registers - unless we're using r2k_switch.S.
+                                * registers.
                                 */
                                tmp = get_fpr32(&fregs[(addr & ~1) - FPR_BASE],
                                                addr & 1);
@@ -906,7 +906,7 @@ long arch_ptrace(struct task_struct *child, long request,
                                /*
                                 * The odd registers are actually the high
                                 * order bits of the values stored in the even
-                                * registers - unless we're using r2k_switch.S.
+                                * registers.
                                 */
                                set_fpr32(&fregs[(addr & ~1) - FPR_BASE],
                                          addr & 1, data);
index f30c381d3e1cedf80ec5f25447fcf0c61248f25b..7edc629304c8fe1a7b53b6792486fc2c147b7973 100644 (file)
@@ -103,7 +103,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
                                /*
                                 * The odd registers are actually the high
                                 * order bits of the values stored in the even
-                                * registers - unless we're using r2k_switch.S.
+                                * registers.
                                 */
                                tmp = get_fpr32(&fregs[(addr & ~1) - FPR_BASE],
                                                addr & 1);
@@ -216,7 +216,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
                                /*
                                 * The odd registers are actually the high
                                 * order bits of the values stored in the even
-                                * registers - unless we're using r2k_switch.S.
+                                * registers.
                                 */
                                set_fpr32(&fregs[(addr & ~1) - FPR_BASE],
                                          addr & 1, data);
index 665897139f30c08985ed38352192cabf0148c0f4..71b1aafae1bb1c1a209e4722043b369a34dbfc3e 100644 (file)
@@ -36,7 +36,7 @@ LEAF(resume)
        cpu_save_nonscratch a0
        sw      ra, THREAD_REG31(a0)
 
-#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
+#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
        PTR_LA  t8, __stack_chk_guard
        LONG_L  t9, TASK_STACK_CANARY(a1)
        LONG_S  t9, 0(t8)
index 17cf9341c1cf0c1ad34dc0362b85ee550a82f9ca..58232ae6cfae3e4c26aa96afd09eb3adb378184e 100644 (file)
@@ -31,7 +31,7 @@
        cpu_save_nonscratch a0
        LONG_S  ra, THREAD_REG31(a0)
 
-#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
+#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
        PTR_LA  t8, __stack_chk_guard
        LONG_L  t9, TASK_STACK_CANARY(a1)
        LONG_S  t9, 0(t8)
index 563188ac6fa264ab930cab5a6040d173e21b542c..2c96c0c68116252e2965a4d4ff395a71603779fd 100644 (file)
@@ -93,7 +93,7 @@ void __init add_memory_region(phys_addr_t start, phys_addr_t size, long type)
         * If the region reaches the top of the physical address space, adjust
         * the size slightly so that (start + size) doesn't overflow
         */
-       if (start + size - 1 == (phys_addr_t)ULLONG_MAX)
+       if (start + size - 1 == PHYS_ADDR_MAX)
                --size;
 
        /* Sanity check */
@@ -376,7 +376,7 @@ static void __init bootmem_init(void)
        unsigned long reserved_end;
        unsigned long mapstart = ~0UL;
        unsigned long bootmap_size;
-       phys_addr_t ramstart = (phys_addr_t)ULLONG_MAX;
+       phys_addr_t ramstart = PHYS_ADDR_MAX;
        bool bootmap_valid = false;
        int i;
 
index a6ebc8135112e5c9c22e5598bf25556469f9dbb4..bfe02ded25d1f338db56376c3097871948781a24 100644 (file)
 DEFINE_SPINLOCK(rtc_lock);
 EXPORT_SYMBOL(rtc_lock);
 
-int __weak rtc_mips_set_time(unsigned long sec)
-{
-       return -ENODEV;
-}
-
-int __weak rtc_mips_set_mmss(unsigned long nowtime)
-{
-       return rtc_mips_set_time(nowtime);
-}
-
-int update_persistent_clock(struct timespec now)
-{
-       return rtc_mips_set_mmss(now.tv_sec);
-}
-
 static int null_perf_irq(void)
 {
        return 0;
index 544ea21bfef9cdae6361c964d5cdd91c56f57c88..0bef238d2c0c6fda901e5f20682a26cb33e217eb 100644 (file)
@@ -872,7 +872,7 @@ static ssize_t vpe_write(struct file *file, const char __user *buffer,
                return -ENODEV;
 
        if ((count + v->len) > v->plen) {
-               pr_warn("VPE loader: elf size too big. Perhaps strip uneeded symbols\n");
+               pr_warn("VPE loader: elf size too big. Perhaps strip unneeded symbols\n");
                return -ENOMEM;
        }
 
index 0f725e9cee8f69230ca7ddff5f6023c30294395c..7cd76f93a438ab00d7085b3aaa93a5294c494c55 100644 (file)
@@ -1076,7 +1076,7 @@ int kvm_arch_vcpu_ioctl_set_fpu(struct kvm_vcpu *vcpu, struct kvm_fpu *fpu)
        return -ENOIOCTLCMD;
 }
 
-int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
+vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
 {
        return VM_FAULT_SIGBUS;
 }
index 8bd5cf820eed9978b06fc65f15f91dda9748a7fc..e6ce39fefa784729d2f46e8ee0298271fb72e558 100644 (file)
@@ -136,7 +136,7 @@ static void rtc_end_op(void)
        lasat_ndelay(1000);
 }
 
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
        unsigned long word;
        unsigned long flags;
@@ -152,14 +152,19 @@ void read_persistent_clock(struct timespec *ts)
        ts->tv_nsec = 0;
 }
 
-int rtc_mips_set_mmss(unsigned long time)
+int update_persistent_clock64(struct timespec64 now)
 {
+       time64_t time = now.tv_sec;
        unsigned long flags;
 
        spin_lock_irqsave(&rtc_lock, flags);
        rtc_init_op();
        rtc_write_byte(SET_TIME_CMD);
-       rtc_write_word(time);
+       /*
+        * Due to the hardware limitation, we cast to 'unsigned long' type,
+        * so it will overflow in year 2106 on 32-bit machine.
+        */
+       rtc_write_word((unsigned long)time);
        rtc_end_op();
        spin_unlock_irqrestore(&rtc_lock, flags);
 
index 6f7422400f32aeaca60fc887fcb7d8132b7d9a69..ead07c243c6a2e9db2ba39a4698043e2602a2bab 100644 (file)
@@ -73,8 +73,16 @@ int proc_dolasatrtc(struct ctl_table *table, int write,
        if (r)
                return r;
 
-       if (write)
-               rtc_mips_set_mmss(rtctmp);
+       if (write) {
+               /*
+                * Due to the RTC hardware limitation, we can not actually
+                * use the full 64-bit range here.
+                */
+               ts.tv_sec = rtctmp;
+               ts.tv_nsec = 0;
+
+               update_persistent_clock64(ts);
+       }
 
        return 0;
 }
index e84e12655fa8ac5e8af75f231e8b2f52136be042..6537e022ef627fd58f80bb9699450ea644f0e0ae 100644 (file)
@@ -16,5 +16,4 @@ obj-$(CONFIG_CPU_R3000)               += r3k_dump_tlb.o
 obj-$(CONFIG_CPU_TX39XX)       += r3k_dump_tlb.o
 
 # libgcc-style stuff needed in the kernel
-obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o multi3.o \
-        ucmpdi2.o
+obj-y += bswapsi.o bswapdi.o multi3.o
diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c
deleted file mode 100644 (file)
index 24cd690..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <linux/export.h>
-
-#include "libgcc.h"
-
-long long notrace __ashldi3(long long u, word_type b)
-{
-       DWunion uu, w;
-       word_type bm;
-
-       if (b == 0)
-               return u;
-
-       uu.ll = u;
-       bm = 32 - b;
-
-       if (bm <= 0) {
-               w.s.low = 0;
-               w.s.high = (unsigned int) uu.s.low << -bm;
-       } else {
-               const unsigned int carries = (unsigned int) uu.s.low >> bm;
-
-               w.s.low = (unsigned int) uu.s.low << b;
-               w.s.high = ((unsigned int) uu.s.high << b) | carries;
-       }
-
-       return w.ll;
-}
-
-EXPORT_SYMBOL(__ashldi3);
diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c
deleted file mode 100644 (file)
index 23f5295..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <linux/export.h>
-
-#include "libgcc.h"
-
-long long notrace __ashrdi3(long long u, word_type b)
-{
-       DWunion uu, w;
-       word_type bm;
-
-       if (b == 0)
-               return u;
-
-       uu.ll = u;
-       bm = 32 - b;
-
-       if (bm <= 0) {
-               /* w.s.high = 1..1 or 0..0 */
-               w.s.high =
-                   uu.s.high >> 31;
-               w.s.low = uu.s.high >> -bm;
-       } else {
-               const unsigned int carries = (unsigned int) uu.s.high << bm;
-
-               w.s.high = uu.s.high >> b;
-               w.s.low = ((unsigned int) uu.s.low >> b) | carries;
-       }
-
-       return w.ll;
-}
-
-EXPORT_SYMBOL(__ashrdi3);
diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c
deleted file mode 100644 (file)
index 93cfc78..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <linux/export.h>
-
-#include "libgcc.h"
-
-word_type notrace __cmpdi2(long long a, long long b)
-{
-       const DWunion au = {
-               .ll = a
-       };
-       const DWunion bu = {
-               .ll = b
-       };
-
-       if (au.s.high < bu.s.high)
-               return 0;
-       else if (au.s.high > bu.s.high)
-               return 2;
-
-       if ((unsigned int) au.s.low < (unsigned int) bu.s.low)
-               return 0;
-       else if ((unsigned int) au.s.low > (unsigned int) bu.s.low)
-               return 2;
-
-       return 1;
-}
-
-EXPORT_SYMBOL(__cmpdi2);
diff --git a/arch/mips/lib/lshrdi3.c b/arch/mips/lib/lshrdi3.c
deleted file mode 100644 (file)
index 914b971..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <linux/export.h>
-
-#include "libgcc.h"
-
-long long notrace __lshrdi3(long long u, word_type b)
-{
-       DWunion uu, w;
-       word_type bm;
-
-       if (b == 0)
-               return u;
-
-       uu.ll = u;
-       bm = 32 - b;
-
-       if (bm <= 0) {
-               w.s.high = 0;
-               w.s.low = (unsigned int) uu.s.high >> -bm;
-       } else {
-               const unsigned int carries = (unsigned int) uu.s.high << bm;
-
-               w.s.high = (unsigned int) uu.s.high >> b;
-               w.s.low = ((unsigned int) uu.s.low >> b) | carries;
-       }
-
-       return w.ll;
-}
-
-EXPORT_SYMBOL(__lshrdi3);
index f7327979a8f8e163547dafe4302d12caab809fbd..1cc306520a55be39d316b6b8ec98d09519a14aa5 100644 (file)
@@ -95,7 +95,7 @@
 
        sltiu           t0, a2, STORSIZE        /* very small region? */
        bnez            t0, .Lsmall_memset\@
-       andi            t0, a0, STORMASK        /* aligned? */
+        andi           t0, a0, STORMASK        /* aligned? */
 
 #ifdef CONFIG_CPU_MICROMIPS
        move            t8, a1                  /* used by 'swp' instruction */
 #endif
 #ifndef CONFIG_CPU_DADDI_WORKAROUNDS
        beqz            t0, 1f
-       PTR_SUBU        t0, STORSIZE            /* alignment in bytes */
+        PTR_SUBU       t0, STORSIZE            /* alignment in bytes */
 #else
        .set            noat
        li              AT, STORSIZE
        beqz            t0, 1f
-       PTR_SUBU        t0, AT                  /* alignment in bytes */
+        PTR_SUBU       t0, AT                  /* alignment in bytes */
        .set            at
 #endif
 
 1:     ori             t1, a2, 0x3f            /* # of full blocks */
        xori            t1, 0x3f
        beqz            t1, .Lmemset_partial\@  /* no block to fill */
-       andi            t0, a2, 0x40-STORSIZE
+        andi           t0, a2, 0x40-STORSIZE
 
        PTR_ADDU        t1, a0                  /* end address */
        .set            reorder
        .set            at
 #endif
        jr              t1
-       PTR_ADDU        a0, t0                  /* dest ptr */
+        PTR_ADDU       a0, t0                  /* dest ptr */
 
        .set            push
        .set            noreorder
 
        beqz            a2, 1f
 #ifndef CONFIG_CPU_MIPSR6
-       PTR_ADDU        a0, a2                  /* What's left */
+        PTR_ADDU       a0, a2                  /* What's left */
        R10KCBARRIER(0(ra))
 #ifdef __MIPSEB__
        EX(LONG_S_R, a1, -1(a0), .Llast_fixup\@)
        EX(LONG_S_L, a1, -1(a0), .Llast_fixup\@)
 #endif
 #else
-       PTR_SUBU        t0, $0, a2
+        PTR_SUBU       t0, $0, a2
        PTR_ADDIU       t0, 1
        STORE_BYTE(0)
        STORE_BYTE(1)
 0:
 #endif
 1:     jr              ra
-       move            a2, zero
+        move           a2, zero
 
 .Lsmall_memset\@:
        beqz            a2, 2f
-       PTR_ADDU        t1, a0, a2
+        PTR_ADDU       t1, a0, a2
 
 1:     PTR_ADDIU       a0, 1                   /* fill bytewise */
        R10KCBARRIER(0(ra))
         EX(sb, a1, -1(a0), .Lsmall_fixup\@)
 
 2:     jr              ra                      /* done */
-       move            a2, zero
+        move           a2, zero
        .if __memset == 1
        END(memset)
        .set __memset, 0
 
 .Lfirst_fixup\@:
        jr      ra
-       nop
+        nop
 
 .Lfwd_fixup\@:
        PTR_L           t0, TI_TASK($28)
        LONG_L          t0, THREAD_BUADDR(t0)
        LONG_ADDU       a2, t1
        jr              ra
-       LONG_SUBU       a2, t0
+        LONG_SUBU      a2, t0
 
 .Lpartial_fixup\@:
        PTR_L           t0, TI_TASK($28)
        LONG_L          t0, THREAD_BUADDR(t0)
        LONG_ADDU       a2, a0
        jr              ra
-       LONG_SUBU       a2, t0
+        LONG_SUBU      a2, t0
 
 .Llast_fixup\@:
        jr              ra
 LEAF(memset)
 EXPORT_SYMBOL(memset)
        beqz            a1, 1f
-       move            v0, a0                  /* result */
+        move           v0, a0                  /* result */
 
        andi            a1, 0xff                /* spread fillword */
        LONG_SLL                t1, a1, 8
diff --git a/arch/mips/lib/ucmpdi2.c b/arch/mips/lib/ucmpdi2.c
deleted file mode 100644 (file)
index c31c78c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <linux/export.h>
-
-#include "libgcc.h"
-
-word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b)
-{
-       const DWunion au = {.ll = a};
-       const DWunion bu = {.ll = b};
-
-       if ((unsigned int) au.s.high < (unsigned int) bu.s.high)
-               return 0;
-       else if ((unsigned int) au.s.high > (unsigned int) bu.s.high)
-               return 2;
-       if ((unsigned int) au.s.low < (unsigned int) bu.s.low)
-               return 0;
-       else if ((unsigned int) au.s.low > (unsigned int) bu.s.low)
-               return 2;
-       return 1;
-}
-
-EXPORT_SYMBOL(__ucmpdi2);
index e1a5382ad47e9663d4ea23e0609e01103389df2c..0ba53c55ff33ed01fac3c198220f17fff3c4d212 100644 (file)
@@ -29,7 +29,7 @@ void __init plat_time_init(void)
 #endif
 }
 
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
        ts->tv_sec = mc146818_get_cmos_time();
        ts->tv_nsec = 0;
index 2e2132d3f5c748d04a62a4ed34b528b941976556..2a116084216f2ca7cea3541d85b45a3663f3a5a6 100644 (file)
@@ -31,17 +31,10 @@ static ssize_t sc_prefetch_write(struct file *file,
                                 const char __user *user_buf,
                                 size_t count, loff_t *ppos)
 {
-       char buf[32];
-       ssize_t buf_size;
        bool enabled;
        int err;
 
-       buf_size = min(count, sizeof(buf) - 1);
-       if (copy_from_user(buf, user_buf, buf_size))
-               return -EFAULT;
-
-       buf[buf_size] = '\0';
-       err = strtobool(buf, &enabled);
+       err = kstrtobool_from_user(user_buf, count, &enabled);
        if (err)
                return err;
 
index 66c866740ff227ed788a4d41f4322aeb5198dd9b..d22b7edc3886ba276e0c87187ddb3e6255bd25da 100644 (file)
@@ -134,7 +134,7 @@ static void __init estimate_frequencies(void)
        }
 }
 
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
        ts->tv_sec = mc146818_get_cmos_time();
        ts->tv_nsec = 0;
index c3e4c18ef8d4d1ca5e4dc74ffd990b800ca0fd1b..7c04b17f4a488aa8e50186be84dd0fcc50125ba2 100644 (file)
@@ -36,7 +36,6 @@ static int perfcount_irq;
 #endif
 
 #ifdef CONFIG_MIPS_MT_SMP
-static int cpu_has_mipsmt_pertccounters;
 #define WHAT           (MIPS_PERFCTRL_MT_EN_VPE | \
                         M_PERFCTL_VPEID(cpu_vpe_id(&current_cpu_data)))
 #define vpe_id()       (cpu_has_mipsmt_pertccounters ? \
@@ -326,7 +325,6 @@ static int __init mipsxx_init(void)
        }
 
 #ifdef CONFIG_MIPS_MT_SMP
-       cpu_has_mipsmt_pertccounters = read_c0_config7() & (1<<19);
        if (!cpu_has_mipsmt_pertccounters)
                counters = counters_total_to_per_cpu(counters);
 #endif
index e62466445f0834858447d1583297e9928807ec1f..4ac8ccdf56bba2b2d365893722f1e9f9c8069309 100644 (file)
@@ -141,13 +141,13 @@ static int m41t81_write(uint8_t addr, int b)
        return 0;
 }
 
-int m41t81_set_time(unsigned long t)
+int m41t81_set_time(time64_t t)
 {
        struct rtc_time tm;
        unsigned long flags;
 
        /* Note we don't care about the century */
-       rtc_time_to_tm(t, &tm);
+       rtc_time64_to_tm(t, &tm);
 
        /*
         * Note the write order matters as it ensures the correctness.
@@ -188,7 +188,7 @@ int m41t81_set_time(unsigned long t)
        return 0;
 }
 
-unsigned long m41t81_get_time(void)
+time64_t m41t81_get_time(void)
 {
        unsigned int year, mon, day, hour, min, sec;
        unsigned long flags;
@@ -218,7 +218,7 @@ unsigned long m41t81_get_time(void)
 
        year += 2000;
 
-       return mktime(year, mon, day, hour, min, sec);
+       return mktime64(year, mon, day, hour, min, sec);
 }
 
 int m41t81_probe(void)
index 50a82c495427e863eaddfa09d48a9774fc2b1875..2dcaaa7e3bfa2babd0bbf4cd2802c428d46a504d 100644 (file)
@@ -109,13 +109,13 @@ static int xicor_write(uint8_t addr, int b)
        }
 }
 
-int xicor_set_time(unsigned long t)
+int xicor_set_time(time64_t t)
 {
        struct rtc_time tm;
        int tmp;
        unsigned long flags;
 
-       rtc_time_to_tm(t, &tm);
+       rtc_time64_to_tm(t, &tm);
        tm.tm_year += 1900;
 
        spin_lock_irqsave(&rtc_lock, flags);
@@ -168,7 +168,7 @@ int xicor_set_time(unsigned long t)
        return 0;
 }
 
-unsigned long xicor_get_time(void)
+time64_t xicor_get_time(void)
 {
        unsigned int year, mon, day, hour, min, sec, y2k;
        unsigned long flags;
@@ -201,7 +201,7 @@ unsigned long xicor_get_time(void)
 
        year += (y2k * 100);
 
-       return mktime(year, mon, day, hour, min, sec);
+       return mktime64(year, mon, day, hour, min, sec);
 }
 
 int xicor_probe(void)
index 494fb0a475acd41a202cb71f711764abd71c7ad2..152ca71cc2d7b97a6c17a4f4aa7cb3fdd7dd7ad8 100644 (file)
@@ -57,12 +57,12 @@ extern void sb1250_setup(void);
 #endif
 
 extern int xicor_probe(void);
-extern int xicor_set_time(unsigned long);
-extern unsigned long xicor_get_time(void);
+extern int xicor_set_time(time64_t);
+extern time64_t xicor_get_time(void);
 
 extern int m41t81_probe(void);
-extern int m41t81_set_time(unsigned long);
-extern unsigned long m41t81_get_time(void);
+extern int m41t81_set_time(time64_t);
+extern time64_t m41t81_get_time(void);
 
 const char *get_system_type(void)
 {
@@ -87,9 +87,9 @@ enum swarm_rtc_type {
 
 enum swarm_rtc_type swarm_rtc_type;
 
-void read_persistent_clock(struct timespec *ts)
+void read_persistent_clock64(struct timespec64 *ts)
 {
-       unsigned long sec;
+       time64_t sec;
 
        switch (swarm_rtc_type) {
        case RTC_XICOR:
@@ -102,15 +102,17 @@ void read_persistent_clock(struct timespec *ts)
 
        case RTC_NONE:
        default:
-               sec = mktime(2000, 1, 1, 0, 0, 0);
+               sec = mktime64(2000, 1, 1, 0, 0, 0);
                break;
        }
        ts->tv_sec = sec;
        ts->tv_nsec = 0;
 }
 
-int rtc_mips_set_time(unsigned long sec)
+int update_persistent_clock64(struct timespec64 now)
 {
+       time64_t sec = now.tv_sec;
+
        switch (swarm_rtc_type) {
        case RTC_XICOR:
                return xicor_set_time(sec);
index 0eb7d1e8821be63a0c13394833eb70fcc3e81189..dbace1f3e1a9730d956f91aad1c3beb80543536f 100644 (file)
@@ -171,9 +171,3 @@ void __init plat_time_init(void)
        }
        setup_pit_timer();
 }
-
-void read_persistent_clock(struct timespec *ts)
-{
-       ts->tv_sec = -1;
-       ts->tv_nsec = 0;
-}
index fd26fadc86171d52a757f521617863d9fa1d3b7c..ef29a9c2ffd602e1d6e1ed30ba0860a773f6a1aa 100644 (file)
@@ -219,7 +219,7 @@ static int __init rbtx4939_led_probe(struct platform_device *pdev)
                "nand-disk",
        };
 
-       leds_data = kzalloc(sizeof(*leds_data) * RBTX4939_MAX_7SEGLEDS,
+       leds_data = kcalloc(RBTX4939_MAX_7SEGLEDS, sizeof(*leds_data),
                            GFP_KERNEL);
        if (!leds_data)
                return -ENOMEM;
index 4d8f64d4859790b97b11f337f8e7774164f1ee59..c480770fabcd6287571dacb9d40ccc224f8e13b1 100644 (file)
@@ -275,7 +275,7 @@ config SMP
          machines, but will use only one CPU of a multiprocessor machine.
          On a uniprocessor machine, the kernel will run faster if you say N.
 
-         See also <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO
+         See also <file:Documentation/lockup-watchdogs.txt> and the SMP-HOWTO
          available at <http://www.tldp.org/docs.html#howto>.
 
          If you don't know what to do here, say N.
index eaba5920234d01d8139256832150fb9ae2d27e91..9f2b75fe2c2d40c842c3398009c27ef9217be31d 100644 (file)
@@ -190,7 +190,7 @@ config PPC
        select HAVE_FTRACE_MCOUNT_RECORD
        select HAVE_FUNCTION_GRAPH_TRACER
        select HAVE_FUNCTION_TRACER
-       select HAVE_GCC_PLUGINS
+       select HAVE_GCC_PLUGINS                 if GCC_VERSION >= 50200   # plugin support on gcc <= 5.1 is buggy on PPC
        select HAVE_GENERIC_GUP
        select HAVE_HW_BREAKPOINT               if PERF_EVENTS && (PPC_BOOK3S || PPC_8xx)
        select HAVE_IDE
@@ -461,23 +461,9 @@ config LD_HEAD_STUB_CATCH
 
          If unsure, say "N".
 
-config DISABLE_MPROFILE_KERNEL
-       bool "Disable use of mprofile-kernel for kernel tracing"
-       depends on PPC64 && CPU_LITTLE_ENDIAN
-       default y
-       help
-         Selecting this options disables use of the mprofile-kernel ABI for
-         kernel tracing. That will cause options such as live patching
-         (CONFIG_LIVEPATCH) which depend on CONFIG_DYNAMIC_FTRACE_WITH_REGS to
-         be disabled also.
-
-         If you have a toolchain which supports mprofile-kernel, then you can
-         disable this. Otherwise leave it enabled. If you're not sure, say
-         "Y".
-
 config MPROFILE_KERNEL
        depends on PPC64 && CPU_LITTLE_ENDIAN
-       def_bool !DISABLE_MPROFILE_KERNEL
+       def_bool $(success,$(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__)
 
 config HOTPLUG_CPU
        bool "Support for enabling/disabling CPUs"
index 9b52e42e581b21cd3fb5574e46bf1a90948b028e..bd06a3ccda312a0a645cd0dbff887924f691d2ce 100644 (file)
@@ -161,18 +161,7 @@ CFLAGS-$(CONFIG_GENERIC_CPU) += -mcpu=powerpc64
 endif
 
 ifdef CONFIG_MPROFILE_KERNEL
-    ifeq ($(shell $(srctree)/arch/powerpc/tools/gcc-check-mprofile-kernel.sh $(CC) -I$(srctree)/include -D__KERNEL__),OK)
-        CC_FLAGS_FTRACE := -pg -mprofile-kernel
-        KBUILD_CPPFLAGS += -DCC_USING_MPROFILE_KERNEL
-    else
-        # If the user asked for mprofile-kernel but the toolchain doesn't
-        # support it, emit a warning and deliberately break the build later
-        # with mprofile-kernel-not-supported. We would prefer to make this an
-        # error right here, but then the user would never be able to run
-        # oldconfig to change their configuration.
-        $(warning Compiler does not support mprofile-kernel, set CONFIG_DISABLE_MPROFILE_KERNEL)
-        CC_FLAGS_FTRACE := -mprofile-kernel-not-supported
-    endif
+       CC_FLAGS_FTRACE := -pg -mprofile-kernel
 endif
 
 CFLAGS-$(CONFIG_CELL_CPU) += $(call cc-option,-mcpu=cell)
index aa9e785c59c230c69208bf4c32dfc60fadebc2bb..7841b8a60657906535c3973cd366f5fe8a4a19a8 100644 (file)
@@ -134,7 +134,13 @@ unsigned long prepare_ftrace_return(unsigned long parent, unsigned long ip);
 void pnv_power9_force_smt4_catch(void);
 void pnv_power9_force_smt4_release(void);
 
+/* Transaction memory related */
 void tm_enable(void);
 void tm_disable(void);
 void tm_abort(uint8_t cause);
+
+struct kvm_vcpu;
+void _kvmppc_restore_tm_pr(struct kvm_vcpu *vcpu, u64 guest_msr);
+void _kvmppc_save_tm_pr(struct kvm_vcpu *vcpu, u64 guest_msr);
+
 #endif /* _ASM_POWERPC_ASM_PROTOTYPES_H */
index e7377b73cfecaa2874fe240ee861e472cfa9309d..1f345a0b6ba20b24b5408f21099fb10f68e9ff82 100644 (file)
@@ -104,6 +104,7 @@ struct kvmppc_vcore {
        ulong vtb;              /* virtual timebase */
        ulong conferring_threads;
        unsigned int halt_poll_ns;
+       atomic_t online_count;
 };
 
 struct kvmppc_vcpu_book3s {
@@ -209,6 +210,7 @@ extern void kvmppc_book3s_queue_irqprio(struct kvm_vcpu *vcpu, unsigned int vec)
 extern void kvmppc_book3s_dequeue_irqprio(struct kvm_vcpu *vcpu,
                                          unsigned int vec);
 extern void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags);
+extern void kvmppc_trigger_fac_interrupt(struct kvm_vcpu *vcpu, ulong fac);
 extern void kvmppc_set_bat(struct kvm_vcpu *vcpu, struct kvmppc_bat *bat,
                           bool upper, u32 val);
 extern void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr);
@@ -256,6 +258,21 @@ extern int kvmppc_hcall_impl_pr(unsigned long cmd);
 extern int kvmppc_hcall_impl_hv_realmode(unsigned long cmd);
 extern void kvmppc_copy_to_svcpu(struct kvm_vcpu *vcpu);
 extern void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu);
+
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+void kvmppc_save_tm_pr(struct kvm_vcpu *vcpu);
+void kvmppc_restore_tm_pr(struct kvm_vcpu *vcpu);
+void kvmppc_save_tm_sprs(struct kvm_vcpu *vcpu);
+void kvmppc_restore_tm_sprs(struct kvm_vcpu *vcpu);
+#else
+static inline void kvmppc_save_tm_pr(struct kvm_vcpu *vcpu) {}
+static inline void kvmppc_restore_tm_pr(struct kvm_vcpu *vcpu) {}
+static inline void kvmppc_save_tm_sprs(struct kvm_vcpu *vcpu) {}
+static inline void kvmppc_restore_tm_sprs(struct kvm_vcpu *vcpu) {}
+#endif
+
+void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac);
+
 extern int kvm_irq_bypass;
 
 static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
@@ -274,12 +291,12 @@ static inline struct kvmppc_vcpu_book3s *to_book3s(struct kvm_vcpu *vcpu)
 
 static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
 {
-       vcpu->arch.gpr[num] = val;
+       vcpu->arch.regs.gpr[num] = val;
 }
 
 static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
 {
-       return vcpu->arch.gpr[num];
+       return vcpu->arch.regs.gpr[num];
 }
 
 static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
@@ -294,42 +311,42 @@ static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
 
 static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
 {
-       vcpu->arch.xer = val;
+       vcpu->arch.regs.xer = val;
 }
 
 static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
 {
-       return vcpu->arch.xer;
+       return vcpu->arch.regs.xer;
 }
 
 static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
 {
-       vcpu->arch.ctr = val;
+       vcpu->arch.regs.ctr = val;
 }
 
 static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
 {
-       return vcpu->arch.ctr;
+       return vcpu->arch.regs.ctr;
 }
 
 static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
 {
-       vcpu->arch.lr = val;
+       vcpu->arch.regs.link = val;
 }
 
 static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
 {
-       return vcpu->arch.lr;
+       return vcpu->arch.regs.link;
 }
 
 static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
 {
-       vcpu->arch.pc = val;
+       vcpu->arch.regs.nip = val;
 }
 
 static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
 {
-       return vcpu->arch.pc;
+       return vcpu->arch.regs.nip;
 }
 
 static inline u64 kvmppc_get_msr(struct kvm_vcpu *vcpu);
index c424e44f4c0010e4e6f12f36fac1a792575948be..dc435a5af7d6cfd04ddb81e81d0476f8b214bdb2 100644 (file)
@@ -483,15 +483,15 @@ static inline u64 sanitize_msr(u64 msr)
 static inline void copy_from_checkpoint(struct kvm_vcpu *vcpu)
 {
        vcpu->arch.cr  = vcpu->arch.cr_tm;
-       vcpu->arch.xer = vcpu->arch.xer_tm;
-       vcpu->arch.lr  = vcpu->arch.lr_tm;
-       vcpu->arch.ctr = vcpu->arch.ctr_tm;
+       vcpu->arch.regs.xer = vcpu->arch.xer_tm;
+       vcpu->arch.regs.link  = vcpu->arch.lr_tm;
+       vcpu->arch.regs.ctr = vcpu->arch.ctr_tm;
        vcpu->arch.amr = vcpu->arch.amr_tm;
        vcpu->arch.ppr = vcpu->arch.ppr_tm;
        vcpu->arch.dscr = vcpu->arch.dscr_tm;
        vcpu->arch.tar = vcpu->arch.tar_tm;
-       memcpy(vcpu->arch.gpr, vcpu->arch.gpr_tm,
-              sizeof(vcpu->arch.gpr));
+       memcpy(vcpu->arch.regs.gpr, vcpu->arch.gpr_tm,
+              sizeof(vcpu->arch.regs.gpr));
        vcpu->arch.fp  = vcpu->arch.fp_tm;
        vcpu->arch.vr  = vcpu->arch.vr_tm;
        vcpu->arch.vrsave = vcpu->arch.vrsave_tm;
@@ -500,15 +500,15 @@ static inline void copy_from_checkpoint(struct kvm_vcpu *vcpu)
 static inline void copy_to_checkpoint(struct kvm_vcpu *vcpu)
 {
        vcpu->arch.cr_tm  = vcpu->arch.cr;
-       vcpu->arch.xer_tm = vcpu->arch.xer;
-       vcpu->arch.lr_tm  = vcpu->arch.lr;
-       vcpu->arch.ctr_tm = vcpu->arch.ctr;
+       vcpu->arch.xer_tm = vcpu->arch.regs.xer;
+       vcpu->arch.lr_tm  = vcpu->arch.regs.link;
+       vcpu->arch.ctr_tm = vcpu->arch.regs.ctr;
        vcpu->arch.amr_tm = vcpu->arch.amr;
        vcpu->arch.ppr_tm = vcpu->arch.ppr;
        vcpu->arch.dscr_tm = vcpu->arch.dscr;
        vcpu->arch.tar_tm = vcpu->arch.tar;
-       memcpy(vcpu->arch.gpr_tm, vcpu->arch.gpr,
-              sizeof(vcpu->arch.gpr));
+       memcpy(vcpu->arch.gpr_tm, vcpu->arch.regs.gpr,
+              sizeof(vcpu->arch.regs.gpr));
        vcpu->arch.fp_tm  = vcpu->arch.fp;
        vcpu->arch.vr_tm  = vcpu->arch.vr;
        vcpu->arch.vrsave_tm = vcpu->arch.vrsave;
index bc6e29e4dfd4a125406a5736b995b8fa8500052e..d513e3ed1c659c711d4a68e5db5924f720c66833 100644 (file)
 
 static inline void kvmppc_set_gpr(struct kvm_vcpu *vcpu, int num, ulong val)
 {
-       vcpu->arch.gpr[num] = val;
+       vcpu->arch.regs.gpr[num] = val;
 }
 
 static inline ulong kvmppc_get_gpr(struct kvm_vcpu *vcpu, int num)
 {
-       return vcpu->arch.gpr[num];
+       return vcpu->arch.regs.gpr[num];
 }
 
 static inline void kvmppc_set_cr(struct kvm_vcpu *vcpu, u32 val)
@@ -56,12 +56,12 @@ static inline u32 kvmppc_get_cr(struct kvm_vcpu *vcpu)
 
 static inline void kvmppc_set_xer(struct kvm_vcpu *vcpu, ulong val)
 {
-       vcpu->arch.xer = val;
+       vcpu->arch.regs.xer = val;
 }
 
 static inline ulong kvmppc_get_xer(struct kvm_vcpu *vcpu)
 {
-       return vcpu->arch.xer;
+       return vcpu->arch.regs.xer;
 }
 
 static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
@@ -72,32 +72,32 @@ static inline bool kvmppc_need_byteswap(struct kvm_vcpu *vcpu)
 
 static inline void kvmppc_set_ctr(struct kvm_vcpu *vcpu, ulong val)
 {
-       vcpu->arch.ctr = val;
+       vcpu->arch.regs.ctr = val;
 }
 
 static inline ulong kvmppc_get_ctr(struct kvm_vcpu *vcpu)
 {
-       return vcpu->arch.ctr;
+       return vcpu->arch.regs.ctr;
 }
 
 static inline void kvmppc_set_lr(struct kvm_vcpu *vcpu, ulong val)
 {
-       vcpu->arch.lr = val;
+       vcpu->arch.regs.link = val;
 }
 
 static inline ulong kvmppc_get_lr(struct kvm_vcpu *vcpu)
 {
-       return vcpu->arch.lr;
+       return vcpu->arch.regs.link;
 }
 
 static inline void kvmppc_set_pc(struct kvm_vcpu *vcpu, ulong val)
 {
-       vcpu->arch.pc = val;
+       vcpu->arch.regs.nip = val;
 }
 
 static inline ulong kvmppc_get_pc(struct kvm_vcpu *vcpu)
 {
-       return vcpu->arch.pc;
+       return vcpu->arch.regs.nip;
 }
 
 static inline ulong kvmppc_get_fault_dar(struct kvm_vcpu *vcpu)
index 17498e9a26e443cb67b6e631f0c5b626f06cfc9a..fa4efa7e88f703b10b7a35a22947f1d98d2c5880 100644 (file)
@@ -269,7 +269,6 @@ struct kvm_arch {
        unsigned long host_lpcr;
        unsigned long sdr1;
        unsigned long host_sdr1;
-       int tlbie_lock;
        unsigned long lpcr;
        unsigned long vrma_slb_v;
        int mmu_ready;
@@ -454,6 +453,12 @@ struct mmio_hpte_cache {
 #define KVMPPC_VSX_COPY_WORD           1
 #define KVMPPC_VSX_COPY_DWORD          2
 #define KVMPPC_VSX_COPY_DWORD_LOAD_DUMP        3
+#define KVMPPC_VSX_COPY_WORD_LOAD_DUMP 4
+
+#define KVMPPC_VMX_COPY_BYTE           8
+#define KVMPPC_VMX_COPY_HWORD          9
+#define KVMPPC_VMX_COPY_WORD           10
+#define KVMPPC_VMX_COPY_DWORD          11
 
 struct openpic;
 
@@ -486,7 +491,7 @@ struct kvm_vcpu_arch {
        struct kvmppc_book3s_shadow_vcpu *shadow_vcpu;
 #endif
 
-       ulong gpr[32];
+       struct pt_regs regs;
 
        struct thread_fp_state fp;
 
@@ -521,14 +526,10 @@ struct kvm_vcpu_arch {
        u32 qpr[32];
 #endif
 
-       ulong pc;
-       ulong ctr;
-       ulong lr;
 #ifdef CONFIG_PPC_BOOK3S
        ulong tar;
 #endif
 
-       ulong xer;
        u32 cr;
 
 #ifdef CONFIG_PPC_BOOK3S
@@ -626,7 +627,6 @@ struct kvm_vcpu_arch {
 
        struct thread_vr_state vr_tm;
        u32 vrsave_tm; /* also USPRG0 */
-
 #endif
 
 #ifdef CONFIG_KVM_EXIT_TIMING
@@ -681,16 +681,17 @@ struct kvm_vcpu_arch {
         * Number of simulations for vsx.
         * If we use 2*8bytes to simulate 1*16bytes,
         * then the number should be 2 and
-        * mmio_vsx_copy_type=KVMPPC_VSX_COPY_DWORD.
+        * mmio_copy_type=KVMPPC_VSX_COPY_DWORD.
         * If we use 4*4bytes to simulate 1*16bytes,
         * the number should be 4 and
         * mmio_vsx_copy_type=KVMPPC_VSX_COPY_WORD.
         */
        u8 mmio_vsx_copy_nums;
        u8 mmio_vsx_offset;
-       u8 mmio_vsx_copy_type;
        u8 mmio_vsx_tx_sx_enabled;
        u8 mmio_vmx_copy_nums;
+       u8 mmio_vmx_offset;
+       u8 mmio_copy_type;
        u8 osi_needed;
        u8 osi_enabled;
        u8 papr_enabled;
@@ -772,6 +773,8 @@ struct kvm_vcpu_arch {
        u64 busy_preempt;
 
        u32 emul_inst;
+
+       u32 online;
 #endif
 
 #ifdef CONFIG_KVM_BOOK3S_HV_EXIT_TIMING
index abe7032cdb541df18eeb9d4981d974216c0ac7a0..e991821dd7fa1ccd422c4f2859892c3f4370b645 100644 (file)
@@ -52,7 +52,7 @@ enum emulation_result {
        EMULATE_EXIT_USER,    /* emulation requires exit to user-space */
 };
 
-enum instruction_type {
+enum instruction_fetch_type {
        INST_GENERIC,
        INST_SC,                /* system call */
 };
@@ -81,10 +81,10 @@ extern int kvmppc_handle_loads(struct kvm_run *run, struct kvm_vcpu *vcpu,
 extern int kvmppc_handle_vsx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
                                unsigned int rt, unsigned int bytes,
                        int is_default_endian, int mmio_sign_extend);
-extern int kvmppc_handle_load128_by2x64(struct kvm_run *run,
-               struct kvm_vcpu *vcpu, unsigned int rt, int is_default_endian);
-extern int kvmppc_handle_store128_by2x64(struct kvm_run *run,
-               struct kvm_vcpu *vcpu, unsigned int rs, int is_default_endian);
+extern int kvmppc_handle_vmx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
+               unsigned int rt, unsigned int bytes, int is_default_endian);
+extern int kvmppc_handle_vmx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
+               unsigned int rs, unsigned int bytes, int is_default_endian);
 extern int kvmppc_handle_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
                               u64 val, unsigned int bytes,
                               int is_default_endian);
@@ -93,7 +93,7 @@ extern int kvmppc_handle_vsx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
                                int is_default_endian);
 
 extern int kvmppc_load_last_inst(struct kvm_vcpu *vcpu,
-                                enum instruction_type type, u32 *inst);
+                                enum instruction_fetch_type type, u32 *inst);
 
 extern int kvmppc_ld(struct kvm_vcpu *vcpu, ulong *eaddr, int size, void *ptr,
                     bool data);
@@ -265,6 +265,8 @@ union kvmppc_one_reg {
        vector128 vval;
        u64     vsxval[2];
        u32     vsx32val[4];
+       u16     vsx16val[8];
+       u8      vsx8val[16];
        struct {
                u64     addr;
                u64     length;
@@ -324,13 +326,14 @@ struct kvmppc_ops {
        int (*get_rmmu_info)(struct kvm *kvm, struct kvm_ppc_rmmu_info *info);
        int (*set_smt_mode)(struct kvm *kvm, unsigned long mode,
                            unsigned long flags);
+       void (*giveup_ext)(struct kvm_vcpu *vcpu, ulong msr);
 };
 
 extern struct kvmppc_ops *kvmppc_hv_ops;
 extern struct kvmppc_ops *kvmppc_pr_ops;
 
 static inline int kvmppc_get_last_inst(struct kvm_vcpu *vcpu,
-                                       enum instruction_type type, u32 *inst)
+                               enum instruction_fetch_type type, u32 *inst)
 {
        int ret = EMULATE_DONE;
        u32 fetched_inst;
index d8374f984f39945e4f12451270962777bd0befeb..d61b0818e2676695a64c57f5e53c4af285a67065 100644 (file)
@@ -14,7 +14,7 @@
 #include <asm-generic/module.h>
 
 
-#ifdef CC_USING_MPROFILE_KERNEL
+#ifdef CONFIG_MPROFILE_KERNEL
 #define MODULE_ARCH_VERMAGIC_FTRACE    "mprofile-kernel "
 #else
 #define MODULE_ARCH_VERMAGIC_FTRACE    ""
index 75c5b2cd9d667fefa2e0f628b5a06c9a2489ad3a..562568414cf42ace1e40a012ced84d17abff7295 100644 (file)
 #define SPRN_PSSCR     0x357   /* Processor Stop Status and Control Register (ISA 3.0) */
 #define SPRN_PSSCR_PR  0x337   /* PSSCR ISA 3.0, privileged mode access */
 #define SPRN_PMCR      0x374   /* Power Management Control Register */
+#define SPRN_RWMR      0x375   /* Region-Weighting Mode Register */
 
 /* HFSCR and FSCR bit numbers are the same */
 #define FSCR_SCV_LG    12      /* Enable System Call Vectored */
index 833ed9a16adfd03e0b6cb70adc19fe03055f7344..1b32b56a03d34ce2a5f0b7f79c621f87d8c89dbf 100644 (file)
@@ -633,6 +633,7 @@ struct kvm_ppc_cpu_char {
 #define KVM_REG_PPC_PSSCR      (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbd)
 
 #define KVM_REG_PPC_DEC_EXPIRY (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xbe)
+#define KVM_REG_PPC_ONLINE     (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf)
 
 /* Transactional Memory checkpointed state:
  * This is all GPRs, all VSX regs and a subset of SPRs
index 9fc9e097700990cec7bce9e3e0ac478cfcc31de7..0a05443359503c9f375e2a47953dd8f3aa118bbf 100644 (file)
@@ -426,20 +426,20 @@ int main(void)
        OFFSET(VCPU_HOST_STACK, kvm_vcpu, arch.host_stack);
        OFFSET(VCPU_HOST_PID, kvm_vcpu, arch.host_pid);
        OFFSET(VCPU_GUEST_PID, kvm_vcpu, arch.pid);
-       OFFSET(VCPU_GPRS, kvm_vcpu, arch.gpr);
+       OFFSET(VCPU_GPRS, kvm_vcpu, arch.regs.gpr);
        OFFSET(VCPU_VRSAVE, kvm_vcpu, arch.vrsave);
        OFFSET(VCPU_FPRS, kvm_vcpu, arch.fp.fpr);
 #ifdef CONFIG_ALTIVEC
        OFFSET(VCPU_VRS, kvm_vcpu, arch.vr.vr);
 #endif
-       OFFSET(VCPU_XER, kvm_vcpu, arch.xer);
-       OFFSET(VCPU_CTR, kvm_vcpu, arch.ctr);
-       OFFSET(VCPU_LR, kvm_vcpu, arch.lr);
+       OFFSET(VCPU_XER, kvm_vcpu, arch.regs.xer);
+       OFFSET(VCPU_CTR, kvm_vcpu, arch.regs.ctr);
+       OFFSET(VCPU_LR, kvm_vcpu, arch.regs.link);
 #ifdef CONFIG_PPC_BOOK3S
        OFFSET(VCPU_TAR, kvm_vcpu, arch.tar);
 #endif
        OFFSET(VCPU_CR, kvm_vcpu, arch.cr);
-       OFFSET(VCPU_PC, kvm_vcpu, arch.pc);
+       OFFSET(VCPU_PC, kvm_vcpu, arch.regs.nip);
 #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
        OFFSET(VCPU_MSR, kvm_vcpu, arch.shregs.msr);
        OFFSET(VCPU_SRR0, kvm_vcpu, arch.shregs.srr0);
@@ -696,10 +696,10 @@ int main(void)
 
 #else /* CONFIG_PPC_BOOK3S */
        OFFSET(VCPU_CR, kvm_vcpu, arch.cr);
-       OFFSET(VCPU_XER, kvm_vcpu, arch.xer);
-       OFFSET(VCPU_LR, kvm_vcpu, arch.lr);
-       OFFSET(VCPU_CTR, kvm_vcpu, arch.ctr);
-       OFFSET(VCPU_PC, kvm_vcpu, arch.pc);
+       OFFSET(VCPU_XER, kvm_vcpu, arch.regs.xer);
+       OFFSET(VCPU_LR, kvm_vcpu, arch.regs.link);
+       OFFSET(VCPU_CTR, kvm_vcpu, arch.regs.ctr);
+       OFFSET(VCPU_PC, kvm_vcpu, arch.regs.nip);
        OFFSET(VCPU_SPRG9, kvm_vcpu, arch.sprg9);
        OFFSET(VCPU_LAST_INST, kvm_vcpu, arch.last_inst);
        OFFSET(VCPU_FAULT_DEAR, kvm_vcpu, arch.fault_dear);
index 1b7419579820fb54817cfbcdc2004a4a2a43dae5..b8d61e019d06189f74d56114c23aa3637d1579b7 100644 (file)
@@ -466,7 +466,7 @@ static unsigned long stub_for_addr(const Elf64_Shdr *sechdrs,
        return (unsigned long)&stubs[i];
 }
 
-#ifdef CC_USING_MPROFILE_KERNEL
+#ifdef CONFIG_MPROFILE_KERNEL
 static bool is_mprofile_mcount_callsite(const char *name, u32 *instruction)
 {
        if (strcmp("_mcount", name))
@@ -753,7 +753,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
 
 #ifdef CONFIG_DYNAMIC_FTRACE
 
-#ifdef CC_USING_MPROFILE_KERNEL
+#ifdef CONFIG_MPROFILE_KERNEL
 
 #define PACATOC offsetof(struct paca_struct, kernel_toc)
 
index f915db93cd429d4405089c7f4eb5de1ba708d746..44d66c33d59d5a2d9e38c0138cb0749927eebd6f 100644 (file)
@@ -559,7 +559,8 @@ static int __init rtas_event_scan_init(void)
        rtas_error_log_max = rtas_get_error_log_max();
        rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int);
 
-       rtas_log_buf = vmalloc(rtas_error_log_buffer_max*LOG_NUMBER);
+       rtas_log_buf = vmalloc(array_size(LOG_NUMBER,
+                                         rtas_error_log_buffer_max));
        if (!rtas_log_buf) {
                printk(KERN_ERR "rtasd: no memory\n");
                return -ENOMEM;
index c076a32093fdd90c03209735113d2948a91903c4..4bfbb54dee517de53fd4e9e09c4d0ae1a2cdfdae 100644 (file)
@@ -144,7 +144,7 @@ __ftrace_make_nop(struct module *mod,
                return -EINVAL;
        }
 
-#ifdef CC_USING_MPROFILE_KERNEL
+#ifdef CONFIG_MPROFILE_KERNEL
        /* When using -mkernel_profile there is no load to jump over */
        pop = PPC_INST_NOP;
 
@@ -188,7 +188,7 @@ __ftrace_make_nop(struct module *mod,
                pr_err("Expected %08x found %08x\n", PPC_INST_LD_TOC, op);
                return -EINVAL;
        }
-#endif /* CC_USING_MPROFILE_KERNEL */
+#endif /* CONFIG_MPROFILE_KERNEL */
 
        if (patch_instruction((unsigned int *)ip, pop)) {
                pr_err("Patching NOP failed.\n");
@@ -324,7 +324,7 @@ int ftrace_make_nop(struct module *mod,
  * They should effectively be a NOP, and follow formal constraints,
  * depending on the ABI. Return false if they don't.
  */
-#ifndef CC_USING_MPROFILE_KERNEL
+#ifndef CONFIG_MPROFILE_KERNEL
 static int
 expected_nop_sequence(void *ip, unsigned int op0, unsigned int op1)
 {
index b44ec104a5a16178662f021b768106bb43cda8dd..d2205b97628cdd604114f777d26bf44606c58400 100644 (file)
@@ -791,7 +791,7 @@ static int __init vdso_init(void)
 
 #ifdef CONFIG_VDSO32
        /* Make sure pages are in the correct state */
-       vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 2),
+       vdso32_pagelist = kcalloc(vdso32_pages + 2, sizeof(struct page *),
                                  GFP_KERNEL);
        BUG_ON(vdso32_pagelist == NULL);
        for (i = 0; i < vdso32_pages; i++) {
@@ -805,7 +805,7 @@ static int __init vdso_init(void)
 #endif
 
 #ifdef CONFIG_PPC64
-       vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 2),
+       vdso64_pagelist = kcalloc(vdso64_pages + 2, sizeof(struct page *),
                                  GFP_KERNEL);
        BUG_ON(vdso64_pagelist == NULL);
        for (i = 0; i < vdso64_pages; i++) {
index 4b19da8c87aedfac4435c68e18f797c197e834a5..f872c04bb5b1bb1185a7fcc9df1597540d3d3120 100644 (file)
@@ -63,6 +63,9 @@ kvm-pr-y := \
        book3s_64_mmu.o \
        book3s_32_mmu.o
 
+kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
+       tm.o
+
 ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE
 kvm-book3s_64-builtin-objs-$(CONFIG_KVM_BOOK3S_64_HANDLER) += \
        book3s_rmhandlers.o
index 97d4a112648fd6540948fc1564f1a77d698f65bc..edaf4720d1567abfd4e44a9ed2dab424c6e6c920 100644 (file)
@@ -134,7 +134,7 @@ void kvmppc_inject_interrupt(struct kvm_vcpu *vcpu, int vec, u64 flags)
 {
        kvmppc_unfixup_split_real(vcpu);
        kvmppc_set_srr0(vcpu, kvmppc_get_pc(vcpu));
-       kvmppc_set_srr1(vcpu, kvmppc_get_msr(vcpu) | flags);
+       kvmppc_set_srr1(vcpu, (kvmppc_get_msr(vcpu) & ~0x783f0000ul) | flags);
        kvmppc_set_pc(vcpu, kvmppc_interrupt_offset(vcpu) + vec);
        vcpu->arch.mmu.reset_msr(vcpu);
 }
@@ -256,18 +256,15 @@ void kvmppc_core_queue_data_storage(struct kvm_vcpu *vcpu, ulong dar,
 {
        kvmppc_set_dar(vcpu, dar);
        kvmppc_set_dsisr(vcpu, flags);
-       kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_DATA_STORAGE);
+       kvmppc_inject_interrupt(vcpu, BOOK3S_INTERRUPT_DATA_STORAGE, 0);
 }
-EXPORT_SYMBOL_GPL(kvmppc_core_queue_data_storage);     /* used by kvm_hv */
+EXPORT_SYMBOL_GPL(kvmppc_core_queue_data_storage);
 
 void kvmppc_core_queue_inst_storage(struct kvm_vcpu *vcpu, ulong flags)
 {
-       u64 msr = kvmppc_get_msr(vcpu);
-       msr &= ~(SRR1_ISI_NOPT | SRR1_ISI_N_OR_G | SRR1_ISI_PROT);
-       msr |= flags & (SRR1_ISI_NOPT | SRR1_ISI_N_OR_G | SRR1_ISI_PROT);
-       kvmppc_set_msr_fast(vcpu, msr);
-       kvmppc_book3s_queue_irqprio(vcpu, BOOK3S_INTERRUPT_INST_STORAGE);
+       kvmppc_inject_interrupt(vcpu, BOOK3S_INTERRUPT_INST_STORAGE, flags);
 }
+EXPORT_SYMBOL_GPL(kvmppc_core_queue_inst_storage);
 
 static int kvmppc_book3s_irqprio_deliver(struct kvm_vcpu *vcpu,
                                         unsigned int priority)
@@ -450,8 +447,8 @@ int kvmppc_xlate(struct kvm_vcpu *vcpu, ulong eaddr, enum xlate_instdata xlid,
        return r;
 }
 
-int kvmppc_load_last_inst(struct kvm_vcpu *vcpu, enum instruction_type type,
-                                        u32 *inst)
+int kvmppc_load_last_inst(struct kvm_vcpu *vcpu,
+               enum instruction_fetch_type type, u32 *inst)
 {
        ulong pc = kvmppc_get_pc(vcpu);
        int r;
@@ -509,8 +506,6 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 {
        int i;
 
-       vcpu_load(vcpu);
-
        regs->pc = kvmppc_get_pc(vcpu);
        regs->cr = kvmppc_get_cr(vcpu);
        regs->ctr = kvmppc_get_ctr(vcpu);
@@ -532,7 +527,6 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
        for (i = 0; i < ARRAY_SIZE(regs->gpr); i++)
                regs->gpr[i] = kvmppc_get_gpr(vcpu, i);
 
-       vcpu_put(vcpu);
        return 0;
 }
 
@@ -540,8 +534,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 {
        int i;
 
-       vcpu_load(vcpu);
-
        kvmppc_set_pc(vcpu, regs->pc);
        kvmppc_set_cr(vcpu, regs->cr);
        kvmppc_set_ctr(vcpu, regs->ctr);
@@ -562,7 +554,6 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
        for (i = 0; i < ARRAY_SIZE(regs->gpr); i++)
                kvmppc_set_gpr(vcpu, i, regs->gpr[i]);
 
-       vcpu_put(vcpu);
        return 0;
 }
 
index 4ad5e287b8bc68f1267cfc163a1c07793e530b4e..14ef03501d2191c42b9dcbd23d6200728b2113db 100644 (file)
@@ -31,4 +31,10 @@ extern int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu,
 extern int kvmppc_book3s_init_pr(void);
 extern void kvmppc_book3s_exit_pr(void);
 
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+extern void kvmppc_emulate_tabort(struct kvm_vcpu *vcpu, int ra_val);
+#else
+static inline void kvmppc_emulate_tabort(struct kvm_vcpu *vcpu, int ra_val) {}
+#endif
+
 #endif
index 1992676c7a9479f00fe9717b7ff16aeb5204ae8b..45c8ea4a04879f140fcf037a3b33225a75b538cd 100644 (file)
@@ -52,7 +52,7 @@
 static inline bool check_debug_ip(struct kvm_vcpu *vcpu)
 {
 #ifdef DEBUG_MMU_PTE_IP
-       return vcpu->arch.pc == DEBUG_MMU_PTE_IP;
+       return vcpu->arch.regs.nip == DEBUG_MMU_PTE_IP;
 #else
        return true;
 #endif
index a93d719edc906887b0f4bf412b2b76ac04babfec..cf9d686e81621fca1628ae772cb5150b2cb1209d 100644 (file)
 
 static void kvmppc_mmu_book3s_64_reset_msr(struct kvm_vcpu *vcpu)
 {
-       kvmppc_set_msr(vcpu, vcpu->arch.intr_msr);
+       unsigned long msr = vcpu->arch.intr_msr;
+       unsigned long cur_msr = kvmppc_get_msr(vcpu);
+
+       /* If transactional, change to suspend mode on IRQ delivery */
+       if (MSR_TM_TRANSACTIONAL(cur_msr))
+               msr |= MSR_TS_S;
+       else
+               msr |= cur_msr & MSR_TS_MASK;
+
+       kvmppc_set_msr(vcpu, msr);
 }
 
 static struct kvmppc_slb *kvmppc_mmu_book3s_64_find_slbe(
index a670fa5fbe5056ca7e8cd20e0973fc4c56e0e07f..7f3a8cf5d66f338197e84446f8a6685855fff9e2 100644 (file)
@@ -108,7 +108,7 @@ int kvmppc_allocate_hpt(struct kvm_hpt_info *info, u32 order)
        npte = 1ul << (order - 4);
 
        /* Allocate reverse map array */
-       rev = vmalloc(sizeof(struct revmap_entry) * npte);
+       rev = vmalloc(array_size(npte, sizeof(struct revmap_entry)));
        if (!rev) {
                if (cma)
                        kvm_free_hpt_cma(page, 1 << (order - PAGE_SHIFT));
@@ -272,6 +272,9 @@ int kvmppc_mmu_hv_init(void)
        if (!cpu_has_feature(CPU_FTR_HVMODE))
                return -EINVAL;
 
+       if (!mmu_has_feature(MMU_FTR_LOCKLESS_TLBIE))
+               return -EINVAL;
+
        /* POWER7 has 10-bit LPIDs (12-bit in POWER8) */
        host_lpid = mfspr(SPRN_LPID);
        rsvd_lpid = LPID_RSVD;
index 481da8f93fa449ac9cb3261755a3d1eeee152006..176f911ee983a6347b9643b925bfcfedb21b9809 100644 (file)
@@ -139,44 +139,24 @@ int kvmppc_mmu_radix_xlate(struct kvm_vcpu *vcpu, gva_t eaddr,
        return 0;
 }
 
-#ifdef CONFIG_PPC_64K_PAGES
-#define MMU_BASE_PSIZE MMU_PAGE_64K
-#else
-#define MMU_BASE_PSIZE MMU_PAGE_4K
-#endif
-
 static void kvmppc_radix_tlbie_page(struct kvm *kvm, unsigned long addr,
                                    unsigned int pshift)
 {
-       int psize = MMU_BASE_PSIZE;
-
-       if (pshift >= PUD_SHIFT)
-               psize = MMU_PAGE_1G;
-       else if (pshift >= PMD_SHIFT)
-               psize = MMU_PAGE_2M;
-       addr &= ~0xfffUL;
-       addr |= mmu_psize_defs[psize].ap << 5;
-       asm volatile("ptesync": : :"memory");
-       asm volatile(PPC_TLBIE_5(%0, %1, 0, 0, 1)
-                    : : "r" (addr), "r" (kvm->arch.lpid) : "memory");
-       if (cpu_has_feature(CPU_FTR_P9_TLBIE_BUG))
-               asm volatile(PPC_TLBIE_5(%0, %1, 0, 0, 1)
-                            : : "r" (addr), "r" (kvm->arch.lpid) : "memory");
-       asm volatile("eieio ; tlbsync ; ptesync": : :"memory");
+       unsigned long psize = PAGE_SIZE;
+
+       if (pshift)
+               psize = 1UL << pshift;
+
+       addr &= ~(psize - 1);
+       radix__flush_tlb_lpid_page(kvm->arch.lpid, addr, psize);
 }
 
-static void kvmppc_radix_flush_pwc(struct kvm *kvm, unsigned long addr)
+static void kvmppc_radix_flush_pwc(struct kvm *kvm)
 {
-       unsigned long rb = 0x2 << PPC_BITLSHIFT(53); /* IS = 2 */
-
-       asm volatile("ptesync": : :"memory");
-       /* RIC=1 PRS=0 R=1 IS=2 */
-       asm volatile(PPC_TLBIE_5(%0, %1, 1, 0, 1)
-                    : : "r" (rb), "r" (kvm->arch.lpid) : "memory");
-       asm volatile("eieio ; tlbsync ; ptesync": : :"memory");
+       radix__flush_pwc_lpid(kvm->arch.lpid);
 }
 
-unsigned long kvmppc_radix_update_pte(struct kvm *kvm, pte_t *ptep,
+static unsigned long kvmppc_radix_update_pte(struct kvm *kvm, pte_t *ptep,
                                      unsigned long clr, unsigned long set,
                                      unsigned long addr, unsigned int shift)
 {
@@ -228,6 +208,167 @@ static void kvmppc_pmd_free(pmd_t *pmdp)
        kmem_cache_free(kvm_pmd_cache, pmdp);
 }
 
+static void kvmppc_unmap_pte(struct kvm *kvm, pte_t *pte,
+                            unsigned long gpa, unsigned int shift)
+
+{
+       unsigned long page_size = 1ul << shift;
+       unsigned long old;
+
+       old = kvmppc_radix_update_pte(kvm, pte, ~0UL, 0, gpa, shift);
+       kvmppc_radix_tlbie_page(kvm, gpa, shift);
+       if (old & _PAGE_DIRTY) {
+               unsigned long gfn = gpa >> PAGE_SHIFT;
+               struct kvm_memory_slot *memslot;
+
+               memslot = gfn_to_memslot(kvm, gfn);
+               if (memslot && memslot->dirty_bitmap)
+                       kvmppc_update_dirty_map(memslot, gfn, page_size);
+       }
+}
+
+/*
+ * kvmppc_free_p?d are used to free existing page tables, and recursively
+ * descend and clear and free children.
+ * Callers are responsible for flushing the PWC.
+ *
+ * When page tables are being unmapped/freed as part of page fault path
+ * (full == false), ptes are not expected. There is code to unmap them
+ * and emit a warning if encountered, but there may already be data
+ * corruption due to the unexpected mappings.
+ */
+static void kvmppc_unmap_free_pte(struct kvm *kvm, pte_t *pte, bool full)
+{
+       if (full) {
+               memset(pte, 0, sizeof(long) << PTE_INDEX_SIZE);
+       } else {
+               pte_t *p = pte;
+               unsigned long it;
+
+               for (it = 0; it < PTRS_PER_PTE; ++it, ++p) {
+                       if (pte_val(*p) == 0)
+                               continue;
+                       WARN_ON_ONCE(1);
+                       kvmppc_unmap_pte(kvm, p,
+                                        pte_pfn(*p) << PAGE_SHIFT,
+                                        PAGE_SHIFT);
+               }
+       }
+
+       kvmppc_pte_free(pte);
+}
+
+static void kvmppc_unmap_free_pmd(struct kvm *kvm, pmd_t *pmd, bool full)
+{
+       unsigned long im;
+       pmd_t *p = pmd;
+
+       for (im = 0; im < PTRS_PER_PMD; ++im, ++p) {
+               if (!pmd_present(*p))
+                       continue;
+               if (pmd_is_leaf(*p)) {
+                       if (full) {
+                               pmd_clear(p);
+                       } else {
+                               WARN_ON_ONCE(1);
+                               kvmppc_unmap_pte(kvm, (pte_t *)p,
+                                        pte_pfn(*(pte_t *)p) << PAGE_SHIFT,
+                                        PMD_SHIFT);
+                       }
+               } else {
+                       pte_t *pte;
+
+                       pte = pte_offset_map(p, 0);
+                       kvmppc_unmap_free_pte(kvm, pte, full);
+                       pmd_clear(p);
+               }
+       }
+       kvmppc_pmd_free(pmd);
+}
+
+static void kvmppc_unmap_free_pud(struct kvm *kvm, pud_t *pud)
+{
+       unsigned long iu;
+       pud_t *p = pud;
+
+       for (iu = 0; iu < PTRS_PER_PUD; ++iu, ++p) {
+               if (!pud_present(*p))
+                       continue;
+               if (pud_huge(*p)) {
+                       pud_clear(p);
+               } else {
+                       pmd_t *pmd;
+
+                       pmd = pmd_offset(p, 0);
+                       kvmppc_unmap_free_pmd(kvm, pmd, true);
+                       pud_clear(p);
+               }
+       }
+       pud_free(kvm->mm, pud);
+}
+
+void kvmppc_free_radix(struct kvm *kvm)
+{
+       unsigned long ig;
+       pgd_t *pgd;
+
+       if (!kvm->arch.pgtable)
+               return;
+       pgd = kvm->arch.pgtable;
+       for (ig = 0; ig < PTRS_PER_PGD; ++ig, ++pgd) {
+               pud_t *pud;
+
+               if (!pgd_present(*pgd))
+                       continue;
+               pud = pud_offset(pgd, 0);
+               kvmppc_unmap_free_pud(kvm, pud);
+               pgd_clear(pgd);
+       }
+       pgd_free(kvm->mm, kvm->arch.pgtable);
+       kvm->arch.pgtable = NULL;
+}
+
+static void kvmppc_unmap_free_pmd_entry_table(struct kvm *kvm, pmd_t *pmd,
+                                             unsigned long gpa)
+{
+       pte_t *pte = pte_offset_kernel(pmd, 0);
+
+       /*
+        * Clearing the pmd entry then flushing the PWC ensures that the pte
+        * page no longer be cached by the MMU, so can be freed without
+        * flushing the PWC again.
+        */
+       pmd_clear(pmd);
+       kvmppc_radix_flush_pwc(kvm);
+
+       kvmppc_unmap_free_pte(kvm, pte, false);
+}
+
+static void kvmppc_unmap_free_pud_entry_table(struct kvm *kvm, pud_t *pud,
+                                       unsigned long gpa)
+{
+       pmd_t *pmd = pmd_offset(pud, 0);
+
+       /*
+        * Clearing the pud entry then flushing the PWC ensures that the pmd
+        * page and any children pte pages will no longer be cached by the MMU,
+        * so can be freed without flushing the PWC again.
+        */
+       pud_clear(pud);
+       kvmppc_radix_flush_pwc(kvm);
+
+       kvmppc_unmap_free_pmd(kvm, pmd, false);
+}
+
+/*
+ * There are a number of bits which may differ between different faults to
+ * the same partition scope entry. RC bits, in the course of cleaning and
+ * aging. And the write bit can change, either the access could have been
+ * upgraded, or a read fault could happen concurrently with a write fault
+ * that sets those bits first.
+ */
+#define PTE_BITS_MUST_MATCH (~(_PAGE_WRITE | _PAGE_DIRTY | _PAGE_ACCESSED))
+
 static int kvmppc_create_pte(struct kvm *kvm, pte_t pte, unsigned long gpa,
                             unsigned int level, unsigned long mmu_seq)
 {
@@ -235,7 +376,6 @@ static int kvmppc_create_pte(struct kvm *kvm, pte_t pte, unsigned long gpa,
        pud_t *pud, *new_pud = NULL;
        pmd_t *pmd, *new_pmd = NULL;
        pte_t *ptep, *new_ptep = NULL;
-       unsigned long old;
        int ret;
 
        /* Traverse the guest's 2nd-level tree, allocate new levels needed */
@@ -273,42 +413,39 @@ static int kvmppc_create_pte(struct kvm *kvm, pte_t pte, unsigned long gpa,
        if (pud_huge(*pud)) {
                unsigned long hgpa = gpa & PUD_MASK;
 
+               /* Check if we raced and someone else has set the same thing */
+               if (level == 2) {
+                       if (pud_raw(*pud) == pte_raw(pte)) {
+                               ret = 0;
+                               goto out_unlock;
+                       }
+                       /* Valid 1GB page here already, add our extra bits */
+                       WARN_ON_ONCE((pud_val(*pud) ^ pte_val(pte)) &
+                                                       PTE_BITS_MUST_MATCH);
+                       kvmppc_radix_update_pte(kvm, (pte_t *)pud,
+                                             0, pte_val(pte), hgpa, PUD_SHIFT);
+                       ret = 0;
+                       goto out_unlock;
+               }
                /*
                 * If we raced with another CPU which has just put
                 * a 1GB pte in after we saw a pmd page, try again.
                 */
-               if (level <= 1 && !new_pmd) {
+               if (!new_pmd) {
                        ret = -EAGAIN;
                        goto out_unlock;
                }
-               /* Check if we raced and someone else has set the same thing */
-               if (level == 2 && pud_raw(*pud) == pte_raw(pte)) {
-                       ret = 0;
-                       goto out_unlock;
-               }
                /* Valid 1GB page here already, remove it */
-               old = kvmppc_radix_update_pte(kvm, (pte_t *)pud,
-                                             ~0UL, 0, hgpa, PUD_SHIFT);
-               kvmppc_radix_tlbie_page(kvm, hgpa, PUD_SHIFT);
-               if (old & _PAGE_DIRTY) {
-                       unsigned long gfn = hgpa >> PAGE_SHIFT;
-                       struct kvm_memory_slot *memslot;
-                       memslot = gfn_to_memslot(kvm, gfn);
-                       if (memslot && memslot->dirty_bitmap)
-                               kvmppc_update_dirty_map(memslot,
-                                                       gfn, PUD_SIZE);
-               }
+               kvmppc_unmap_pte(kvm, (pte_t *)pud, hgpa, PUD_SHIFT);
        }
        if (level == 2) {
                if (!pud_none(*pud)) {
                        /*
                         * There's a page table page here, but we wanted to
                         * install a large page, so remove and free the page
-                        * table page.  new_pmd will be NULL since level == 2.
+                        * table page.
                         */
-                       new_pmd = pmd_offset(pud, 0);
-                       pud_clear(pud);
-                       kvmppc_radix_flush_pwc(kvm, gpa);
+                       kvmppc_unmap_free_pud_entry_table(kvm, pud, gpa);
                }
                kvmppc_radix_set_pte_at(kvm, gpa, (pte_t *)pud, pte);
                ret = 0;
@@ -324,42 +461,40 @@ static int kvmppc_create_pte(struct kvm *kvm, pte_t pte, unsigned long gpa,
        if (pmd_is_leaf(*pmd)) {
                unsigned long lgpa = gpa & PMD_MASK;
 
+               /* Check if we raced and someone else has set the same thing */
+               if (level == 1) {
+                       if (pmd_raw(*pmd) == pte_raw(pte)) {
+                               ret = 0;
+                               goto out_unlock;
+                       }
+                       /* Valid 2MB page here already, add our extra bits */
+                       WARN_ON_ONCE((pmd_val(*pmd) ^ pte_val(pte)) &
+                                                       PTE_BITS_MUST_MATCH);
+                       kvmppc_radix_update_pte(kvm, pmdp_ptep(pmd),
+                                             0, pte_val(pte), lgpa, PMD_SHIFT);
+                       ret = 0;
+                       goto out_unlock;
+               }
+
                /*
                 * If we raced with another CPU which has just put
                 * a 2MB pte in after we saw a pte page, try again.
                 */
-               if (level == 0 && !new_ptep) {
+               if (!new_ptep) {
                        ret = -EAGAIN;
                        goto out_unlock;
                }
-               /* Check if we raced and someone else has set the same thing */
-               if (level == 1 && pmd_raw(*pmd) == pte_raw(pte)) {
-                       ret = 0;
-                       goto out_unlock;
-               }
                /* Valid 2MB page here already, remove it */
-               old = kvmppc_radix_update_pte(kvm, pmdp_ptep(pmd),
-                                             ~0UL, 0, lgpa, PMD_SHIFT);
-               kvmppc_radix_tlbie_page(kvm, lgpa, PMD_SHIFT);
-               if (old & _PAGE_DIRTY) {
-                       unsigned long gfn = lgpa >> PAGE_SHIFT;
-                       struct kvm_memory_slot *memslot;
-                       memslot = gfn_to_memslot(kvm, gfn);
-                       if (memslot && memslot->dirty_bitmap)
-                               kvmppc_update_dirty_map(memslot,
-                                                       gfn, PMD_SIZE);
-               }
+               kvmppc_unmap_pte(kvm, pmdp_ptep(pmd), lgpa, PMD_SHIFT);
        }
        if (level == 1) {
                if (!pmd_none(*pmd)) {
                        /*
                         * There's a page table page here, but we wanted to
                         * install a large page, so remove and free the page
-                        * table page.  new_ptep will be NULL since level == 1.
+                        * table page.
                         */
-                       new_ptep = pte_offset_kernel(pmd, 0);
-                       pmd_clear(pmd);
-                       kvmppc_radix_flush_pwc(kvm, gpa);
+                       kvmppc_unmap_free_pmd_entry_table(kvm, pmd, gpa);
                }
                kvmppc_radix_set_pte_at(kvm, gpa, pmdp_ptep(pmd), pte);
                ret = 0;
@@ -378,12 +513,12 @@ static int kvmppc_create_pte(struct kvm *kvm, pte_t pte, unsigned long gpa,
                        ret = 0;
                        goto out_unlock;
                }
-               /* PTE was previously valid, so invalidate it */
-               old = kvmppc_radix_update_pte(kvm, ptep, _PAGE_PRESENT,
-                                             0, gpa, 0);
-               kvmppc_radix_tlbie_page(kvm, gpa, 0);
-               if (old & _PAGE_DIRTY)
-                       mark_page_dirty(kvm, gpa >> PAGE_SHIFT);
+               /* Valid page here already, add our extra bits */
+               WARN_ON_ONCE((pte_val(*ptep) ^ pte_val(pte)) &
+                                                       PTE_BITS_MUST_MATCH);
+               kvmppc_radix_update_pte(kvm, ptep, 0, pte_val(pte), gpa, 0);
+               ret = 0;
+               goto out_unlock;
        }
        kvmppc_radix_set_pte_at(kvm, gpa, ptep, pte);
        ret = 0;
@@ -565,9 +700,13 @@ int kvmppc_book3s_radix_page_fault(struct kvm_run *run, struct kvm_vcpu *vcpu,
                        unsigned long mask = (1ul << shift) - PAGE_SIZE;
                        pte = __pte(pte_val(pte) | (hva & mask));
                }
-               if (!(writing || upgrade_write))
-                       pte = __pte(pte_val(pte) & ~ _PAGE_WRITE);
-               pte = __pte(pte_val(pte) | _PAGE_EXEC);
+               pte = __pte(pte_val(pte) | _PAGE_EXEC | _PAGE_ACCESSED);
+               if (writing || upgrade_write) {
+                       if (pte_val(pte) & _PAGE_WRITE)
+                               pte = __pte(pte_val(pte) | _PAGE_DIRTY);
+               } else {
+                       pte = __pte(pte_val(pte) & ~(_PAGE_WRITE | _PAGE_DIRTY));
+               }
        }
 
        /* Allocate space in the tree and write the PTE */
@@ -734,51 +873,6 @@ int kvmppc_init_vm_radix(struct kvm *kvm)
        return 0;
 }
 
-void kvmppc_free_radix(struct kvm *kvm)
-{
-       unsigned long ig, iu, im;
-       pte_t *pte;
-       pmd_t *pmd;
-       pud_t *pud;
-       pgd_t *pgd;
-
-       if (!kvm->arch.pgtable)
-               return;
-       pgd = kvm->arch.pgtable;
-       for (ig = 0; ig < PTRS_PER_PGD; ++ig, ++pgd) {
-               if (!pgd_present(*pgd))
-                       continue;
-               pud = pud_offset(pgd, 0);
-               for (iu = 0; iu < PTRS_PER_PUD; ++iu, ++pud) {
-                       if (!pud_present(*pud))
-                               continue;
-                       if (pud_huge(*pud)) {
-                               pud_clear(pud);
-                               continue;
-                       }
-                       pmd = pmd_offset(pud, 0);
-                       for (im = 0; im < PTRS_PER_PMD; ++im, ++pmd) {
-                               if (pmd_is_leaf(*pmd)) {
-                                       pmd_clear(pmd);
-                                       continue;
-                               }
-                               if (!pmd_present(*pmd))
-                                       continue;
-                               pte = pte_offset_map(pmd, 0);
-                               memset(pte, 0, sizeof(long) << PTE_INDEX_SIZE);
-                               kvmppc_pte_free(pte);
-                               pmd_clear(pmd);
-                       }
-                       kvmppc_pmd_free(pmd_offset(pud, 0));
-                       pud_clear(pud);
-               }
-               pud_free(kvm->mm, pud_offset(pgd, 0));
-               pgd_clear(pgd);
-       }
-       pgd_free(kvm->mm, kvm->arch.pgtable);
-       kvm->arch.pgtable = NULL;
-}
-
 static void pte_ctor(void *addr)
 {
        memset(addr, 0, RADIX_PTE_TABLE_SIZE);
index 4dffa611376d67850ac4ef8730a547fcccf63491..d066e37551ec861c1d71a8a958784fd792e2dae6 100644 (file)
@@ -176,14 +176,12 @@ extern long kvm_spapr_tce_attach_iommu_group(struct kvm *kvm, int tablefd,
 
                if (!tbltmp)
                        continue;
-               /*
-                * Make sure hardware table parameters are exactly the same;
-                * this is used in the TCE handlers where boundary checks
-                * use only the first attached table.
-                */
-               if ((tbltmp->it_page_shift == stt->page_shift) &&
-                               (tbltmp->it_offset == stt->offset) &&
-                               (tbltmp->it_size == stt->size)) {
+               /* Make sure hardware table parameters are compatible */
+               if ((tbltmp->it_page_shift <= stt->page_shift) &&
+                               (tbltmp->it_offset << tbltmp->it_page_shift ==
+                                stt->offset << stt->page_shift) &&
+                               (tbltmp->it_size << tbltmp->it_page_shift ==
+                                stt->size << stt->page_shift)) {
                        /*
                         * Reference the table to avoid races with
                         * add/remove DMA windows.
@@ -237,7 +235,7 @@ static void release_spapr_tce_table(struct rcu_head *head)
        kfree(stt);
 }
 
-static int kvm_spapr_tce_fault(struct vm_fault *vmf)
+static vm_fault_t kvm_spapr_tce_fault(struct vm_fault *vmf)
 {
        struct kvmppc_spapr_tce_table *stt = vmf->vma->vm_file->private_data;
        struct page *page;
@@ -302,7 +300,8 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm,
        int ret = -ENOMEM;
        int i;
 
-       if (!args->size)
+       if (!args->size || args->page_shift < 12 || args->page_shift > 34 ||
+               (args->offset + args->size > (ULLONG_MAX >> args->page_shift)))
                return -EINVAL;
 
        size = _ALIGN_UP(args->size, PAGE_SIZE >> 3);
@@ -396,7 +395,7 @@ static long kvmppc_tce_iommu_mapped_dec(struct kvm *kvm,
        return H_SUCCESS;
 }
 
-static long kvmppc_tce_iommu_unmap(struct kvm *kvm,
+static long kvmppc_tce_iommu_do_unmap(struct kvm *kvm,
                struct iommu_table *tbl, unsigned long entry)
 {
        enum dma_data_direction dir = DMA_NONE;
@@ -416,7 +415,24 @@ static long kvmppc_tce_iommu_unmap(struct kvm *kvm,
        return ret;
 }
 
-long kvmppc_tce_iommu_map(struct kvm *kvm, struct iommu_table *tbl,
+static long kvmppc_tce_iommu_unmap(struct kvm *kvm,
+               struct kvmppc_spapr_tce_table *stt, struct iommu_table *tbl,
+               unsigned long entry)
+{
+       unsigned long i, ret = H_SUCCESS;
+       unsigned long subpages = 1ULL << (stt->page_shift - tbl->it_page_shift);
+       unsigned long io_entry = entry * subpages;
+
+       for (i = 0; i < subpages; ++i) {
+               ret = kvmppc_tce_iommu_do_unmap(kvm, tbl, io_entry + i);
+               if (ret != H_SUCCESS)
+                       break;
+       }
+
+       return ret;
+}
+
+long kvmppc_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl,
                unsigned long entry, unsigned long ua,
                enum dma_data_direction dir)
 {
@@ -453,6 +469,27 @@ long kvmppc_tce_iommu_map(struct kvm *kvm, struct iommu_table *tbl,
        return 0;
 }
 
+static long kvmppc_tce_iommu_map(struct kvm *kvm,
+               struct kvmppc_spapr_tce_table *stt, struct iommu_table *tbl,
+               unsigned long entry, unsigned long ua,
+               enum dma_data_direction dir)
+{
+       unsigned long i, pgoff, ret = H_SUCCESS;
+       unsigned long subpages = 1ULL << (stt->page_shift - tbl->it_page_shift);
+       unsigned long io_entry = entry * subpages;
+
+       for (i = 0, pgoff = 0; i < subpages;
+                       ++i, pgoff += IOMMU_PAGE_SIZE(tbl)) {
+
+               ret = kvmppc_tce_iommu_do_map(kvm, tbl,
+                               io_entry + i, ua + pgoff, dir);
+               if (ret != H_SUCCESS)
+                       break;
+       }
+
+       return ret;
+}
+
 long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
                      unsigned long ioba, unsigned long tce)
 {
@@ -491,10 +528,10 @@ long kvmppc_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
 
        list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
                if (dir == DMA_NONE)
-                       ret = kvmppc_tce_iommu_unmap(vcpu->kvm,
+                       ret = kvmppc_tce_iommu_unmap(vcpu->kvm, stt,
                                        stit->tbl, entry);
                else
-                       ret = kvmppc_tce_iommu_map(vcpu->kvm, stit->tbl,
+                       ret = kvmppc_tce_iommu_map(vcpu->kvm, stt, stit->tbl,
                                        entry, ua, dir);
 
                if (ret == H_SUCCESS)
@@ -570,7 +607,7 @@ long kvmppc_h_put_tce_indirect(struct kvm_vcpu *vcpu,
                        return H_PARAMETER;
 
                list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
-                       ret = kvmppc_tce_iommu_map(vcpu->kvm,
+                       ret = kvmppc_tce_iommu_map(vcpu->kvm, stt,
                                        stit->tbl, entry + i, ua,
                                        iommu_tce_direction(tce));
 
@@ -615,10 +652,10 @@ long kvmppc_h_stuff_tce(struct kvm_vcpu *vcpu,
                return H_PARAMETER;
 
        list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
-               unsigned long entry = ioba >> stit->tbl->it_page_shift;
+               unsigned long entry = ioba >> stt->page_shift;
 
                for (i = 0; i < npages; ++i) {
-                       ret = kvmppc_tce_iommu_unmap(vcpu->kvm,
+                       ret = kvmppc_tce_iommu_unmap(vcpu->kvm, stt,
                                        stit->tbl, entry + i);
 
                        if (ret == H_SUCCESS)
index 6651f736a0b1e449e4be6384169e1ced35eff89f..925fc316a104cc1ce33b6630cf9aaa46ffde7c0c 100644 (file)
@@ -221,7 +221,7 @@ static long kvmppc_rm_tce_iommu_mapped_dec(struct kvm *kvm,
        return H_SUCCESS;
 }
 
-static long kvmppc_rm_tce_iommu_unmap(struct kvm *kvm,
+static long kvmppc_rm_tce_iommu_do_unmap(struct kvm *kvm,
                struct iommu_table *tbl, unsigned long entry)
 {
        enum dma_data_direction dir = DMA_NONE;
@@ -245,7 +245,24 @@ static long kvmppc_rm_tce_iommu_unmap(struct kvm *kvm,
        return ret;
 }
 
-static long kvmppc_rm_tce_iommu_map(struct kvm *kvm, struct iommu_table *tbl,
+static long kvmppc_rm_tce_iommu_unmap(struct kvm *kvm,
+               struct kvmppc_spapr_tce_table *stt, struct iommu_table *tbl,
+               unsigned long entry)
+{
+       unsigned long i, ret = H_SUCCESS;
+       unsigned long subpages = 1ULL << (stt->page_shift - tbl->it_page_shift);
+       unsigned long io_entry = entry * subpages;
+
+       for (i = 0; i < subpages; ++i) {
+               ret = kvmppc_rm_tce_iommu_do_unmap(kvm, tbl, io_entry + i);
+               if (ret != H_SUCCESS)
+                       break;
+       }
+
+       return ret;
+}
+
+static long kvmppc_rm_tce_iommu_do_map(struct kvm *kvm, struct iommu_table *tbl,
                unsigned long entry, unsigned long ua,
                enum dma_data_direction dir)
 {
@@ -290,6 +307,27 @@ static long kvmppc_rm_tce_iommu_map(struct kvm *kvm, struct iommu_table *tbl,
        return 0;
 }
 
+static long kvmppc_rm_tce_iommu_map(struct kvm *kvm,
+               struct kvmppc_spapr_tce_table *stt, struct iommu_table *tbl,
+               unsigned long entry, unsigned long ua,
+               enum dma_data_direction dir)
+{
+       unsigned long i, pgoff, ret = H_SUCCESS;
+       unsigned long subpages = 1ULL << (stt->page_shift - tbl->it_page_shift);
+       unsigned long io_entry = entry * subpages;
+
+       for (i = 0, pgoff = 0; i < subpages;
+                       ++i, pgoff += IOMMU_PAGE_SIZE(tbl)) {
+
+               ret = kvmppc_rm_tce_iommu_do_map(kvm, tbl,
+                               io_entry + i, ua + pgoff, dir);
+               if (ret != H_SUCCESS)
+                       break;
+       }
+
+       return ret;
+}
+
 long kvmppc_rm_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
                unsigned long ioba, unsigned long tce)
 {
@@ -327,10 +365,10 @@ long kvmppc_rm_h_put_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
 
        list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
                if (dir == DMA_NONE)
-                       ret = kvmppc_rm_tce_iommu_unmap(vcpu->kvm,
+                       ret = kvmppc_rm_tce_iommu_unmap(vcpu->kvm, stt,
                                        stit->tbl, entry);
                else
-                       ret = kvmppc_rm_tce_iommu_map(vcpu->kvm,
+                       ret = kvmppc_rm_tce_iommu_map(vcpu->kvm, stt,
                                        stit->tbl, entry, ua, dir);
 
                if (ret == H_SUCCESS)
@@ -477,7 +515,7 @@ long kvmppc_rm_h_put_tce_indirect(struct kvm_vcpu *vcpu,
                        return H_PARAMETER;
 
                list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
-                       ret = kvmppc_rm_tce_iommu_map(vcpu->kvm,
+                       ret = kvmppc_rm_tce_iommu_map(vcpu->kvm, stt,
                                        stit->tbl, entry + i, ua,
                                        iommu_tce_direction(tce));
 
@@ -526,10 +564,10 @@ long kvmppc_rm_h_stuff_tce(struct kvm_vcpu *vcpu,
                return H_PARAMETER;
 
        list_for_each_entry_lockless(stit, &stt->iommu_tables, next) {
-               unsigned long entry = ioba >> stit->tbl->it_page_shift;
+               unsigned long entry = ioba >> stt->page_shift;
 
                for (i = 0; i < npages; ++i) {
-                       ret = kvmppc_rm_tce_iommu_unmap(vcpu->kvm,
+                       ret = kvmppc_rm_tce_iommu_unmap(vcpu->kvm, stt,
                                        stit->tbl, entry + i);
 
                        if (ret == H_SUCCESS)
@@ -571,7 +609,7 @@ long kvmppc_h_get_tce(struct kvm_vcpu *vcpu, unsigned long liobn,
        page = stt->pages[idx / TCES_PER_PAGE];
        tbl = (u64 *)page_address(page);
 
-       vcpu->arch.gpr[4] = tbl[idx % TCES_PER_PAGE];
+       vcpu->arch.regs.gpr[4] = tbl[idx % TCES_PER_PAGE];
 
        return H_SUCCESS;
 }
index 68d68983948e13813221627e0dcfe743d1c91037..36b11c5a0dbb968444da85b230cbc7020f69f583 100644 (file)
@@ -23,7 +23,9 @@
 #include <asm/reg.h>
 #include <asm/switch_to.h>
 #include <asm/time.h>
+#include <asm/tm.h>
 #include "book3s.h"
+#include <asm/asm-prototypes.h>
 
 #define OP_19_XOP_RFID         18
 #define OP_19_XOP_RFI          50
 #define OP_31_XOP_EIOIO                854
 #define OP_31_XOP_SLBMFEE      915
 
+#define OP_31_XOP_TBEGIN       654
+#define OP_31_XOP_TABORT       910
+
+#define OP_31_XOP_TRECLAIM     942
+#define OP_31_XOP_TRCHKPT      1006
+
 /* DCBZ is actually 1014, but we patch it to 1010 so we get a trap */
 #define OP_31_XOP_DCBZ         1010
 
@@ -87,6 +95,157 @@ static bool spr_allowed(struct kvm_vcpu *vcpu, enum priv_level level)
        return true;
 }
 
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+static inline void kvmppc_copyto_vcpu_tm(struct kvm_vcpu *vcpu)
+{
+       memcpy(&vcpu->arch.gpr_tm[0], &vcpu->arch.regs.gpr[0],
+                       sizeof(vcpu->arch.gpr_tm));
+       memcpy(&vcpu->arch.fp_tm, &vcpu->arch.fp,
+                       sizeof(struct thread_fp_state));
+       memcpy(&vcpu->arch.vr_tm, &vcpu->arch.vr,
+                       sizeof(struct thread_vr_state));
+       vcpu->arch.ppr_tm = vcpu->arch.ppr;
+       vcpu->arch.dscr_tm = vcpu->arch.dscr;
+       vcpu->arch.amr_tm = vcpu->arch.amr;
+       vcpu->arch.ctr_tm = vcpu->arch.regs.ctr;
+       vcpu->arch.tar_tm = vcpu->arch.tar;
+       vcpu->arch.lr_tm = vcpu->arch.regs.link;
+       vcpu->arch.cr_tm = vcpu->arch.cr;
+       vcpu->arch.xer_tm = vcpu->arch.regs.xer;
+       vcpu->arch.vrsave_tm = vcpu->arch.vrsave;
+}
+
+static inline void kvmppc_copyfrom_vcpu_tm(struct kvm_vcpu *vcpu)
+{
+       memcpy(&vcpu->arch.regs.gpr[0], &vcpu->arch.gpr_tm[0],
+                       sizeof(vcpu->arch.regs.gpr));
+       memcpy(&vcpu->arch.fp, &vcpu->arch.fp_tm,
+                       sizeof(struct thread_fp_state));
+       memcpy(&vcpu->arch.vr, &vcpu->arch.vr_tm,
+                       sizeof(struct thread_vr_state));
+       vcpu->arch.ppr = vcpu->arch.ppr_tm;
+       vcpu->arch.dscr = vcpu->arch.dscr_tm;
+       vcpu->arch.amr = vcpu->arch.amr_tm;
+       vcpu->arch.regs.ctr = vcpu->arch.ctr_tm;
+       vcpu->arch.tar = vcpu->arch.tar_tm;
+       vcpu->arch.regs.link = vcpu->arch.lr_tm;
+       vcpu->arch.cr = vcpu->arch.cr_tm;
+       vcpu->arch.regs.xer = vcpu->arch.xer_tm;
+       vcpu->arch.vrsave = vcpu->arch.vrsave_tm;
+}
+
+static void kvmppc_emulate_treclaim(struct kvm_vcpu *vcpu, int ra_val)
+{
+       unsigned long guest_msr = kvmppc_get_msr(vcpu);
+       int fc_val = ra_val ? ra_val : 1;
+       uint64_t texasr;
+
+       /* CR0 = 0 | MSR[TS] | 0 */
+       vcpu->arch.cr = (vcpu->arch.cr & ~(CR0_MASK << CR0_SHIFT)) |
+               (((guest_msr & MSR_TS_MASK) >> (MSR_TS_S_LG - 1))
+                << CR0_SHIFT);
+
+       preempt_disable();
+       tm_enable();
+       texasr = mfspr(SPRN_TEXASR);
+       kvmppc_save_tm_pr(vcpu);
+       kvmppc_copyfrom_vcpu_tm(vcpu);
+
+       /* failure recording depends on Failure Summary bit */
+       if (!(texasr & TEXASR_FS)) {
+               texasr &= ~TEXASR_FC;
+               texasr |= ((u64)fc_val << TEXASR_FC_LG) | TEXASR_FS;
+
+               texasr &= ~(TEXASR_PR | TEXASR_HV);
+               if (kvmppc_get_msr(vcpu) & MSR_PR)
+                       texasr |= TEXASR_PR;
+
+               if (kvmppc_get_msr(vcpu) & MSR_HV)
+                       texasr |= TEXASR_HV;
+
+               vcpu->arch.texasr = texasr;
+               vcpu->arch.tfiar = kvmppc_get_pc(vcpu);
+               mtspr(SPRN_TEXASR, texasr);
+               mtspr(SPRN_TFIAR, vcpu->arch.tfiar);
+       }
+       tm_disable();
+       /*
+        * treclaim need quit to non-transactional state.
+        */
+       guest_msr &= ~(MSR_TS_MASK);
+       kvmppc_set_msr(vcpu, guest_msr);
+       preempt_enable();
+
+       if (vcpu->arch.shadow_fscr & FSCR_TAR)
+               mtspr(SPRN_TAR, vcpu->arch.tar);
+}
+
+static void kvmppc_emulate_trchkpt(struct kvm_vcpu *vcpu)
+{
+       unsigned long guest_msr = kvmppc_get_msr(vcpu);
+
+       preempt_disable();
+       /*
+        * need flush FP/VEC/VSX to vcpu save area before
+        * copy.
+        */
+       kvmppc_giveup_ext(vcpu, MSR_VSX);
+       kvmppc_giveup_fac(vcpu, FSCR_TAR_LG);
+       kvmppc_copyto_vcpu_tm(vcpu);
+       kvmppc_save_tm_sprs(vcpu);
+
+       /*
+        * as a result of trecheckpoint. set TS to suspended.
+        */
+       guest_msr &= ~(MSR_TS_MASK);
+       guest_msr |= MSR_TS_S;
+       kvmppc_set_msr(vcpu, guest_msr);
+       kvmppc_restore_tm_pr(vcpu);
+       preempt_enable();
+}
+
+/* emulate tabort. at guest privilege state */
+void kvmppc_emulate_tabort(struct kvm_vcpu *vcpu, int ra_val)
+{
+       /* currently we only emulate tabort. but no emulation of other
+        * tabort variants since there is no kernel usage of them at
+        * present.
+        */
+       unsigned long guest_msr = kvmppc_get_msr(vcpu);
+       uint64_t org_texasr;
+
+       preempt_disable();
+       tm_enable();
+       org_texasr = mfspr(SPRN_TEXASR);
+       tm_abort(ra_val);
+
+       /* CR0 = 0 | MSR[TS] | 0 */
+       vcpu->arch.cr = (vcpu->arch.cr & ~(CR0_MASK << CR0_SHIFT)) |
+               (((guest_msr & MSR_TS_MASK) >> (MSR_TS_S_LG - 1))
+                << CR0_SHIFT);
+
+       vcpu->arch.texasr = mfspr(SPRN_TEXASR);
+       /* failure recording depends on Failure Summary bit,
+        * and tabort will be treated as nops in non-transactional
+        * state.
+        */
+       if (!(org_texasr & TEXASR_FS) &&
+                       MSR_TM_ACTIVE(guest_msr)) {
+               vcpu->arch.texasr &= ~(TEXASR_PR | TEXASR_HV);
+               if (guest_msr & MSR_PR)
+                       vcpu->arch.texasr |= TEXASR_PR;
+
+               if (guest_msr & MSR_HV)
+                       vcpu->arch.texasr |= TEXASR_HV;
+
+               vcpu->arch.tfiar = kvmppc_get_pc(vcpu);
+       }
+       tm_disable();
+       preempt_enable();
+}
+
+#endif
+
 int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
                              unsigned int inst, int *advance)
 {
@@ -117,11 +276,28 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
        case 19:
                switch (get_xop(inst)) {
                case OP_19_XOP_RFID:
-               case OP_19_XOP_RFI:
+               case OP_19_XOP_RFI: {
+                       unsigned long srr1 = kvmppc_get_srr1(vcpu);
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+                       unsigned long cur_msr = kvmppc_get_msr(vcpu);
+
+                       /*
+                        * add rules to fit in ISA specification regarding TM
+                        * state transistion in TM disable/Suspended state,
+                        * and target TM state is TM inactive(00) state. (the
+                        * change should be suppressed).
+                        */
+                       if (((cur_msr & MSR_TM) == 0) &&
+                               ((srr1 & MSR_TM) == 0) &&
+                               MSR_TM_SUSPENDED(cur_msr) &&
+                               !MSR_TM_ACTIVE(srr1))
+                               srr1 |= MSR_TS_S;
+#endif
                        kvmppc_set_pc(vcpu, kvmppc_get_srr0(vcpu));
-                       kvmppc_set_msr(vcpu, kvmppc_get_srr1(vcpu));
+                       kvmppc_set_msr(vcpu, srr1);
                        *advance = 0;
                        break;
+               }
 
                default:
                        emulated = EMULATE_FAIL;
@@ -304,6 +480,140 @@ int kvmppc_core_emulate_op_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
 
                        break;
                }
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+               case OP_31_XOP_TBEGIN:
+               {
+                       if (!cpu_has_feature(CPU_FTR_TM))
+                               break;
+
+                       if (!(kvmppc_get_msr(vcpu) & MSR_TM)) {
+                               kvmppc_trigger_fac_interrupt(vcpu, FSCR_TM_LG);
+                               emulated = EMULATE_AGAIN;
+                               break;
+                       }
+
+                       if (!(kvmppc_get_msr(vcpu) & MSR_PR)) {
+                               preempt_disable();
+                               vcpu->arch.cr = (CR0_TBEGIN_FAILURE |
+                                 (vcpu->arch.cr & ~(CR0_MASK << CR0_SHIFT)));
+
+                               vcpu->arch.texasr = (TEXASR_FS | TEXASR_EXACT |
+                                       (((u64)(TM_CAUSE_EMULATE | TM_CAUSE_PERSISTENT))
+                                                << TEXASR_FC_LG));
+
+                               if ((inst >> 21) & 0x1)
+                                       vcpu->arch.texasr |= TEXASR_ROT;
+
+                               if (kvmppc_get_msr(vcpu) & MSR_HV)
+                                       vcpu->arch.texasr |= TEXASR_HV;
+
+                               vcpu->arch.tfhar = kvmppc_get_pc(vcpu) + 4;
+                               vcpu->arch.tfiar = kvmppc_get_pc(vcpu);
+
+                               kvmppc_restore_tm_sprs(vcpu);
+                               preempt_enable();
+                       } else
+                               emulated = EMULATE_FAIL;
+                       break;
+               }
+               case OP_31_XOP_TABORT:
+               {
+                       ulong guest_msr = kvmppc_get_msr(vcpu);
+                       unsigned long ra_val = 0;
+
+                       if (!cpu_has_feature(CPU_FTR_TM))
+                               break;
+
+                       if (!(kvmppc_get_msr(vcpu) & MSR_TM)) {
+                               kvmppc_trigger_fac_interrupt(vcpu, FSCR_TM_LG);
+                               emulated = EMULATE_AGAIN;
+                               break;
+                       }
+
+                       /* only emulate for privilege guest, since problem state
+                        * guest can run with TM enabled and we don't expect to
+                        * trap at here for that case.
+                        */
+                       WARN_ON(guest_msr & MSR_PR);
+
+                       if (ra)
+                               ra_val = kvmppc_get_gpr(vcpu, ra);
+
+                       kvmppc_emulate_tabort(vcpu, ra_val);
+                       break;
+               }
+               case OP_31_XOP_TRECLAIM:
+               {
+                       ulong guest_msr = kvmppc_get_msr(vcpu);
+                       unsigned long ra_val = 0;
+
+                       if (!cpu_has_feature(CPU_FTR_TM))
+                               break;
+
+                       if (!(kvmppc_get_msr(vcpu) & MSR_TM)) {
+                               kvmppc_trigger_fac_interrupt(vcpu, FSCR_TM_LG);
+                               emulated = EMULATE_AGAIN;
+                               break;
+                       }
+
+                       /* generate interrupts based on priorities */
+                       if (guest_msr & MSR_PR) {
+                               /* Privileged Instruction type Program Interrupt */
+                               kvmppc_core_queue_program(vcpu, SRR1_PROGPRIV);
+                               emulated = EMULATE_AGAIN;
+                               break;
+                       }
+
+                       if (!MSR_TM_ACTIVE(guest_msr)) {
+                               /* TM bad thing interrupt */
+                               kvmppc_core_queue_program(vcpu, SRR1_PROGTM);
+                               emulated = EMULATE_AGAIN;
+                               break;
+                       }
+
+                       if (ra)
+                               ra_val = kvmppc_get_gpr(vcpu, ra);
+                       kvmppc_emulate_treclaim(vcpu, ra_val);
+                       break;
+               }
+               case OP_31_XOP_TRCHKPT:
+               {
+                       ulong guest_msr = kvmppc_get_msr(vcpu);
+                       unsigned long texasr;
+
+                       if (!cpu_has_feature(CPU_FTR_TM))
+                               break;
+
+                       if (!(kvmppc_get_msr(vcpu) & MSR_TM)) {
+                               kvmppc_trigger_fac_interrupt(vcpu, FSCR_TM_LG);
+                               emulated = EMULATE_AGAIN;
+                               break;
+                       }
+
+                       /* generate interrupt based on priorities */
+                       if (guest_msr & MSR_PR) {
+                               /* Privileged Instruction type Program Intr */
+                               kvmppc_core_queue_program(vcpu, SRR1_PROGPRIV);
+                               emulated = EMULATE_AGAIN;
+                               break;
+                       }
+
+                       tm_enable();
+                       texasr = mfspr(SPRN_TEXASR);
+                       tm_disable();
+
+                       if (MSR_TM_ACTIVE(guest_msr) ||
+                               !(texasr & (TEXASR_FS))) {
+                               /* TM bad thing interrupt */
+                               kvmppc_core_queue_program(vcpu, SRR1_PROGTM);
+                               emulated = EMULATE_AGAIN;
+                               break;
+                       }
+
+                       kvmppc_emulate_trchkpt(vcpu);
+                       break;
+               }
+#endif
                default:
                        emulated = EMULATE_FAIL;
                }
@@ -465,13 +775,38 @@ int kvmppc_core_emulate_mtspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong spr_val)
                break;
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
        case SPRN_TFHAR:
-               vcpu->arch.tfhar = spr_val;
-               break;
        case SPRN_TEXASR:
-               vcpu->arch.texasr = spr_val;
-               break;
        case SPRN_TFIAR:
-               vcpu->arch.tfiar = spr_val;
+               if (!cpu_has_feature(CPU_FTR_TM))
+                       break;
+
+               if (!(kvmppc_get_msr(vcpu) & MSR_TM)) {
+                       kvmppc_trigger_fac_interrupt(vcpu, FSCR_TM_LG);
+                       emulated = EMULATE_AGAIN;
+                       break;
+               }
+
+               if (MSR_TM_ACTIVE(kvmppc_get_msr(vcpu)) &&
+                       !((MSR_TM_SUSPENDED(kvmppc_get_msr(vcpu))) &&
+                                       (sprn == SPRN_TFHAR))) {
+                       /* it is illegal to mtspr() TM regs in
+                        * other than non-transactional state, with
+                        * the exception of TFHAR in suspend state.
+                        */
+                       kvmppc_core_queue_program(vcpu, SRR1_PROGTM);
+                       emulated = EMULATE_AGAIN;
+                       break;
+               }
+
+               tm_enable();
+               if (sprn == SPRN_TFHAR)
+                       mtspr(SPRN_TFHAR, spr_val);
+               else if (sprn == SPRN_TEXASR)
+                       mtspr(SPRN_TEXASR, spr_val);
+               else
+                       mtspr(SPRN_TFIAR, spr_val);
+               tm_disable();
+
                break;
 #endif
 #endif
@@ -618,13 +953,25 @@ int kvmppc_core_emulate_mfspr_pr(struct kvm_vcpu *vcpu, int sprn, ulong *spr_val
                break;
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
        case SPRN_TFHAR:
-               *spr_val = vcpu->arch.tfhar;
-               break;
        case SPRN_TEXASR:
-               *spr_val = vcpu->arch.texasr;
-               break;
        case SPRN_TFIAR:
-               *spr_val = vcpu->arch.tfiar;
+               if (!cpu_has_feature(CPU_FTR_TM))
+                       break;
+
+               if (!(kvmppc_get_msr(vcpu) & MSR_TM)) {
+                       kvmppc_trigger_fac_interrupt(vcpu, FSCR_TM_LG);
+                       emulated = EMULATE_AGAIN;
+                       break;
+               }
+
+               tm_enable();
+               if (sprn == SPRN_TFHAR)
+                       *spr_val = mfspr(SPRN_TFHAR);
+               else if (sprn == SPRN_TEXASR)
+                       *spr_val = mfspr(SPRN_TEXASR);
+               else if (sprn == SPRN_TFIAR)
+                       *spr_val = mfspr(SPRN_TFIAR);
+               tm_disable();
                break;
 #endif
 #endif
index cb6d2313b19f482ec9ee0dc089008cc9feb9ee1b..de686b340f4aa4ccccaf47e3349eba94d6fddda2 100644 (file)
@@ -123,6 +123,32 @@ static bool no_mixing_hpt_and_radix;
 static void kvmppc_end_cede(struct kvm_vcpu *vcpu);
 static int kvmppc_hv_setup_htab_rma(struct kvm_vcpu *vcpu);
 
+/*
+ * RWMR values for POWER8.  These control the rate at which PURR
+ * and SPURR count and should be set according to the number of
+ * online threads in the vcore being run.
+ */
+#define RWMR_RPA_P8_1THREAD    0x164520C62609AECA
+#define RWMR_RPA_P8_2THREAD    0x7FFF2908450D8DA9
+#define RWMR_RPA_P8_3THREAD    0x164520C62609AECA
+#define RWMR_RPA_P8_4THREAD    0x199A421245058DA9
+#define RWMR_RPA_P8_5THREAD    0x164520C62609AECA
+#define RWMR_RPA_P8_6THREAD    0x164520C62609AECA
+#define RWMR_RPA_P8_7THREAD    0x164520C62609AECA
+#define RWMR_RPA_P8_8THREAD    0x164520C62609AECA
+
+static unsigned long p8_rwmr_values[MAX_SMT_THREADS + 1] = {
+       RWMR_RPA_P8_1THREAD,
+       RWMR_RPA_P8_1THREAD,
+       RWMR_RPA_P8_2THREAD,
+       RWMR_RPA_P8_3THREAD,
+       RWMR_RPA_P8_4THREAD,
+       RWMR_RPA_P8_5THREAD,
+       RWMR_RPA_P8_6THREAD,
+       RWMR_RPA_P8_7THREAD,
+       RWMR_RPA_P8_8THREAD,
+};
+
 static inline struct kvm_vcpu *next_runnable_thread(struct kvmppc_vcore *vc,
                int *ip)
 {
@@ -371,13 +397,13 @@ static void kvmppc_dump_regs(struct kvm_vcpu *vcpu)
 
        pr_err("vcpu %p (%d):\n", vcpu, vcpu->vcpu_id);
        pr_err("pc  = %.16lx  msr = %.16llx  trap = %x\n",
-              vcpu->arch.pc, vcpu->arch.shregs.msr, vcpu->arch.trap);
+              vcpu->arch.regs.nip, vcpu->arch.shregs.msr, vcpu->arch.trap);
        for (r = 0; r < 16; ++r)
                pr_err("r%2d = %.16lx  r%d = %.16lx\n",
                       r, kvmppc_get_gpr(vcpu, r),
                       r+16, kvmppc_get_gpr(vcpu, r+16));
        pr_err("ctr = %.16lx  lr  = %.16lx\n",
-              vcpu->arch.ctr, vcpu->arch.lr);
+              vcpu->arch.regs.ctr, vcpu->arch.regs.link);
        pr_err("srr0 = %.16llx srr1 = %.16llx\n",
               vcpu->arch.shregs.srr0, vcpu->arch.shregs.srr1);
        pr_err("sprg0 = %.16llx sprg1 = %.16llx\n",
@@ -385,7 +411,7 @@ static void kvmppc_dump_regs(struct kvm_vcpu *vcpu)
        pr_err("sprg2 = %.16llx sprg3 = %.16llx\n",
               vcpu->arch.shregs.sprg2, vcpu->arch.shregs.sprg3);
        pr_err("cr = %.8x  xer = %.16lx  dsisr = %.8x\n",
-              vcpu->arch.cr, vcpu->arch.xer, vcpu->arch.shregs.dsisr);
+              vcpu->arch.cr, vcpu->arch.regs.xer, vcpu->arch.shregs.dsisr);
        pr_err("dar = %.16llx\n", vcpu->arch.shregs.dar);
        pr_err("fault dar = %.16lx dsisr = %.8x\n",
               vcpu->arch.fault_dar, vcpu->arch.fault_dsisr);
@@ -1526,6 +1552,9 @@ static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
                *val = get_reg_val(id, vcpu->arch.dec_expires +
                                   vcpu->arch.vcore->tb_offset);
                break;
+       case KVM_REG_PPC_ONLINE:
+               *val = get_reg_val(id, vcpu->arch.online);
+               break;
        default:
                r = -EINVAL;
                break;
@@ -1757,6 +1786,14 @@ static int kvmppc_set_one_reg_hv(struct kvm_vcpu *vcpu, u64 id,
                vcpu->arch.dec_expires = set_reg_val(id, *val) -
                        vcpu->arch.vcore->tb_offset;
                break;
+       case KVM_REG_PPC_ONLINE:
+               i = set_reg_val(id, *val);
+               if (i && !vcpu->arch.online)
+                       atomic_inc(&vcpu->arch.vcore->online_count);
+               else if (!i && vcpu->arch.online)
+                       atomic_dec(&vcpu->arch.vcore->online_count);
+               vcpu->arch.online = i;
+               break;
        default:
                r = -EINVAL;
                break;
@@ -2850,6 +2887,25 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc)
                }
        }
 
+       /*
+        * On POWER8, set RWMR register.
+        * Since it only affects PURR and SPURR, it doesn't affect
+        * the host, so we don't save/restore the host value.
+        */
+       if (is_power8) {
+               unsigned long rwmr_val = RWMR_RPA_P8_8THREAD;
+               int n_online = atomic_read(&vc->online_count);
+
+               /*
+                * Use the 8-thread value if we're doing split-core
+                * or if the vcore's online count looks bogus.
+                */
+               if (split == 1 && threads_per_subcore == MAX_SMT_THREADS &&
+                   n_online >= 1 && n_online <= MAX_SMT_THREADS)
+                       rwmr_val = p8_rwmr_values[n_online];
+               mtspr(SPRN_RWMR, rwmr_val);
+       }
+
        /* Start all the threads */
        active = 0;
        for (sub = 0; sub < core_info.n_subcores; ++sub) {
@@ -2902,6 +2958,32 @@ static noinline void kvmppc_run_core(struct kvmppc_vcore *vc)
        for (sub = 0; sub < core_info.n_subcores; ++sub)
                spin_unlock(&core_info.vc[sub]->lock);
 
+       if (kvm_is_radix(vc->kvm)) {
+               int tmp = pcpu;
+
+               /*
+                * Do we need to flush the process scoped TLB for the LPAR?
+                *
+                * On POWER9, individual threads can come in here, but the
+                * TLB is shared between the 4 threads in a core, hence
+                * invalidating on one thread invalidates for all.
+                * Thus we make all 4 threads use the same bit here.
+                *
+                * Hash must be flushed in realmode in order to use tlbiel.
+                */
+               mtspr(SPRN_LPID, vc->kvm->arch.lpid);
+               isync();
+
+               if (cpu_has_feature(CPU_FTR_ARCH_300))
+                       tmp &= ~0x3UL;
+
+               if (cpumask_test_cpu(tmp, &vc->kvm->arch.need_tlb_flush)) {
+                       radix__local_flush_tlb_lpid_guest(vc->kvm->arch.lpid);
+                       /* Clear the bit after the TLB flush */
+                       cpumask_clear_cpu(tmp, &vc->kvm->arch.need_tlb_flush);
+               }
+       }
+
        /*
         * Interrupts will be enabled once we get into the guest,
         * so tell lockdep that we're about to enable interrupts.
@@ -3356,6 +3438,15 @@ static int kvmppc_vcpu_run_hv(struct kvm_run *run, struct kvm_vcpu *vcpu)
        }
 #endif
 
+       /*
+        * Force online to 1 for the sake of old userspace which doesn't
+        * set it.
+        */
+       if (!vcpu->arch.online) {
+               atomic_inc(&vcpu->arch.vcore->online_count);
+               vcpu->arch.online = 1;
+       }
+
        kvmppc_core_prepare_to_enter(vcpu);
 
        /* No need to go into the guest when all we'll do is come back out */
@@ -3548,7 +3639,7 @@ static void kvmppc_core_free_memslot_hv(struct kvm_memory_slot *free,
 static int kvmppc_core_create_memslot_hv(struct kvm_memory_slot *slot,
                                         unsigned long npages)
 {
-       slot->arch.rmap = vzalloc(npages * sizeof(*slot->arch.rmap));
+       slot->arch.rmap = vzalloc(array_size(npages, sizeof(*slot->arch.rmap)));
        if (!slot->arch.rmap)
                return -ENOMEM;
 
@@ -3955,8 +4046,7 @@ static int kvmppc_core_init_vm_hv(struct kvm *kvm)
         */
        snprintf(buf, sizeof(buf), "vm%d", current->pid);
        kvm->arch.debugfs_dir = debugfs_create_dir(buf, kvm_debugfs_dir);
-       if (!IS_ERR_OR_NULL(kvm->arch.debugfs_dir))
-               kvmppc_mmu_debugfs_init(kvm);
+       kvmppc_mmu_debugfs_init(kvm);
 
        return 0;
 }
index de18299f92b759288c13df1b3479cf6bc3403b08..d4a3f4da409bf2a39e2c0ed60b22760edf0975a0 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/cma.h>
 #include <linux/bitops.h>
 
+#include <asm/asm-prototypes.h>
 #include <asm/cputable.h>
 #include <asm/kvm_ppc.h>
 #include <asm/kvm_book3s.h>
@@ -211,9 +212,9 @@ long kvmppc_h_random(struct kvm_vcpu *vcpu)
 
        /* Only need to do the expensive mfmsr() on radix */
        if (kvm_is_radix(vcpu->kvm) && (mfmsr() & MSR_IR))
-               r = powernv_get_random_long(&vcpu->arch.gpr[4]);
+               r = powernv_get_random_long(&vcpu->arch.regs.gpr[4]);
        else
-               r = powernv_get_random_real_mode(&vcpu->arch.gpr[4]);
+               r = powernv_get_random_real_mode(&vcpu->arch.regs.gpr[4]);
        if (r)
                return H_SUCCESS;
 
@@ -562,7 +563,7 @@ unsigned long kvmppc_rm_h_xirr_x(struct kvm_vcpu *vcpu)
 {
        if (!kvmppc_xics_enabled(vcpu))
                return H_TOO_HARD;
-       vcpu->arch.gpr[5] = get_tb();
+       vcpu->arch.regs.gpr[5] = get_tb();
        if (xive_enabled()) {
                if (is_rm())
                        return xive_rm_h_xirr(vcpu);
@@ -633,7 +634,19 @@ int kvmppc_rm_h_eoi(struct kvm_vcpu *vcpu, unsigned long xirr)
 
 void kvmppc_bad_interrupt(struct pt_regs *regs)
 {
-       die("Bad interrupt in KVM entry/exit code", regs, SIGABRT);
+       /*
+        * 100 could happen at any time, 200 can happen due to invalid real
+        * address access for example (or any time due to a hardware problem).
+        */
+       if (TRAP(regs) == 0x100) {
+               get_paca()->in_nmi++;
+               system_reset_exception(regs);
+               get_paca()->in_nmi--;
+       } else if (TRAP(regs) == 0x200) {
+               machine_check_exception(regs);
+       } else {
+               die("Bad interrupt in KVM entry/exit code", regs, SIGABRT);
+       }
        panic("Bad KVM trap");
 }
 
index 0e84930332889507ce2461986c080aadd2bb14b2..82f2ff9410b6a3d398a290f2703a30b38b93ea10 100644 (file)
@@ -137,7 +137,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
 /*
  * We return here in virtual mode after the guest exits
  * with something that we can't handle in real mode.
- * Interrupts are enabled again at this point.
+ * Interrupts are still hard-disabled.
  */
 
        /*
index 78e6a392330f78b8407f8f7102762944c39c7d1f..1f22d9e977d4e8e031cf25436fad18a4904d4928 100644 (file)
@@ -418,7 +418,8 @@ long kvmppc_h_enter(struct kvm_vcpu *vcpu, unsigned long flags,
                    long pte_index, unsigned long pteh, unsigned long ptel)
 {
        return kvmppc_do_h_enter(vcpu->kvm, flags, pte_index, pteh, ptel,
-                                vcpu->arch.pgdir, true, &vcpu->arch.gpr[4]);
+                                vcpu->arch.pgdir, true,
+                                &vcpu->arch.regs.gpr[4]);
 }
 
 #ifdef __BIG_ENDIAN__
@@ -434,24 +435,6 @@ static inline int is_mmio_hpte(unsigned long v, unsigned long r)
                (HPTE_R_KEY_HI | HPTE_R_KEY_LO));
 }
 
-static inline int try_lock_tlbie(unsigned int *lock)
-{
-       unsigned int tmp, old;
-       unsigned int token = LOCK_TOKEN;
-
-       asm volatile("1:lwarx   %1,0,%2\n"
-                    "  cmpwi   cr0,%1,0\n"
-                    "  bne     2f\n"
-                    "  stwcx.  %3,0,%2\n"
-                    "  bne-    1b\n"
-                    "  isync\n"
-                    "2:"
-                    : "=&r" (tmp), "=&r" (old)
-                    : "r" (lock), "r" (token)
-                    : "cc", "memory");
-       return old == 0;
-}
-
 static void do_tlbies(struct kvm *kvm, unsigned long *rbvalues,
                      long npages, int global, bool need_sync)
 {
@@ -463,8 +446,6 @@ static void do_tlbies(struct kvm *kvm, unsigned long *rbvalues,
         * the RS field, this is backwards-compatible with P7 and P8.
         */
        if (global) {
-               while (!try_lock_tlbie(&kvm->arch.tlbie_lock))
-                       cpu_relax();
                if (need_sync)
                        asm volatile("ptesync" : : : "memory");
                for (i = 0; i < npages; ++i) {
@@ -483,7 +464,6 @@ static void do_tlbies(struct kvm *kvm, unsigned long *rbvalues,
                }
 
                asm volatile("eieio; tlbsync; ptesync" : : : "memory");
-               kvm->arch.tlbie_lock = 0;
        } else {
                if (need_sync)
                        asm volatile("ptesync" : : : "memory");
@@ -561,13 +541,13 @@ long kvmppc_h_remove(struct kvm_vcpu *vcpu, unsigned long flags,
                     unsigned long pte_index, unsigned long avpn)
 {
        return kvmppc_do_h_remove(vcpu->kvm, flags, pte_index, avpn,
-                                 &vcpu->arch.gpr[4]);
+                                 &vcpu->arch.regs.gpr[4]);
 }
 
 long kvmppc_h_bulk_remove(struct kvm_vcpu *vcpu)
 {
        struct kvm *kvm = vcpu->kvm;
-       unsigned long *args = &vcpu->arch.gpr[4];
+       unsigned long *args = &vcpu->arch.regs.gpr[4];
        __be64 *hp, *hptes[4];
        unsigned long tlbrb[4];
        long int i, j, k, n, found, indexes[4];
@@ -787,8 +767,8 @@ long kvmppc_h_read(struct kvm_vcpu *vcpu, unsigned long flags,
                        r = rev[i].guest_rpte | (r & (HPTE_R_R | HPTE_R_C));
                        r &= ~HPTE_GR_RESERVED;
                }
-               vcpu->arch.gpr[4 + i * 2] = v;
-               vcpu->arch.gpr[5 + i * 2] = r;
+               vcpu->arch.regs.gpr[4 + i * 2] = v;
+               vcpu->arch.regs.gpr[5 + i * 2] = r;
        }
        return H_SUCCESS;
 }
@@ -834,7 +814,7 @@ long kvmppc_h_clear_ref(struct kvm_vcpu *vcpu, unsigned long flags,
                        }
                }
        }
-       vcpu->arch.gpr[4] = gr;
+       vcpu->arch.regs.gpr[4] = gr;
        ret = H_SUCCESS;
  out:
        unlock_hpte(hpte, v & ~HPTE_V_HVLOCK);
@@ -881,7 +861,7 @@ long kvmppc_h_clear_mod(struct kvm_vcpu *vcpu, unsigned long flags,
                        kvmppc_set_dirty_from_hpte(kvm, v, gr);
                }
        }
-       vcpu->arch.gpr[4] = gr;
+       vcpu->arch.regs.gpr[4] = gr;
        ret = H_SUCCESS;
  out:
        unlock_hpte(hpte, v & ~HPTE_V_HVLOCK);
index 2a862618f072b63ee27915be5ab43468bcffbb2f..758d1d23215e94b2feb25cf9a53fd778a4785f44 100644 (file)
@@ -517,7 +517,7 @@ unsigned long xics_rm_h_xirr(struct kvm_vcpu *vcpu)
        } while (!icp_rm_try_update(icp, old_state, new_state));
 
        /* Return the result in GPR4 */
-       vcpu->arch.gpr[4] = xirr;
+       vcpu->arch.regs.gpr[4] = xirr;
 
        return check_too_hard(xics, icp);
 }
index b97d261d3b8998b67f4fc6cf7f022959ada9ad53..153988d878e8f1797ded66a265df97555194cb34 100644 (file)
@@ -39,8 +39,6 @@ BEGIN_FTR_SECTION;                            \
        extsw   reg, reg;                       \
 END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300)
 
-#define VCPU_GPRS_TM(reg) (((reg) * ULONG_SIZE) + VCPU_GPR_TM)
-
 /* Values in HSTATE_NAPPING(r13) */
 #define NAPPING_CEDE   1
 #define NAPPING_NOVCPU 2
@@ -639,6 +637,10 @@ kvmppc_hv_entry:
        /* Primary thread switches to guest partition. */
        cmpwi   r6,0
        bne     10f
+
+       /* Radix has already switched LPID and flushed core TLB */
+       bne     cr7, 22f
+
        lwz     r7,KVM_LPID(r9)
 BEGIN_FTR_SECTION
        ld      r6,KVM_SDR1(r9)
@@ -650,7 +652,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_ARCH_300)
        mtspr   SPRN_LPID,r7
        isync
 
-       /* See if we need to flush the TLB */
+       /* See if we need to flush the TLB. Hash has to be done in RM */
        lhz     r6,PACAPACAINDEX(r13)   /* test_bit(cpu, need_tlb_flush) */
 BEGIN_FTR_SECTION
        /*
@@ -677,15 +679,10 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
        li      r7,0x800                /* IS field = 0b10 */
        ptesync
        li      r0,0                    /* RS for P9 version of tlbiel */
-       bne     cr7, 29f
 28:    tlbiel  r7                      /* On P9, rs=0, RIC=0, PRS=0, R=0 */
        addi    r7,r7,0x1000
        bdnz    28b
-       b       30f
-29:    PPC_TLBIEL(7,0,2,1,1)           /* for radix, RIC=2, PRS=1, R=1 */
-       addi    r7,r7,0x1000
-       bdnz    29b
-30:    ptesync
+       ptesync
 23:    ldarx   r7,0,r6                 /* clear the bit after TLB flushed */
        andc    r7,r7,r8
        stdcx.  r7,0,r6
@@ -799,7 +796,10 @@ END_FTR_SECTION(CPU_FTR_TM | CPU_FTR_P9_TM_HV_ASSIST, 0)
        /*
         * NOTE THAT THIS TRASHES ALL NON-VOLATILE REGISTERS INCLUDING CR
         */
-       bl      kvmppc_restore_tm
+       mr      r3, r4
+       ld      r4, VCPU_MSR(r3)
+       bl      kvmppc_restore_tm_hv
+       ld      r4, HSTATE_KVM_VCPU(r13)
 91:
 #endif
 
@@ -1783,7 +1783,10 @@ END_FTR_SECTION(CPU_FTR_TM | CPU_FTR_P9_TM_HV_ASSIST, 0)
        /*
         * NOTE THAT THIS TRASHES ALL NON-VOLATILE REGISTERS INCLUDING CR
         */
-       bl      kvmppc_save_tm
+       mr      r3, r9
+       ld      r4, VCPU_MSR(r3)
+       bl      kvmppc_save_tm_hv
+       ld      r9, HSTATE_KVM_VCPU(r13)
 91:
 #endif
 
@@ -2686,8 +2689,9 @@ END_FTR_SECTION(CPU_FTR_TM | CPU_FTR_P9_TM_HV_ASSIST, 0)
        /*
         * NOTE THAT THIS TRASHES ALL NON-VOLATILE REGISTERS INCLUDING CR
         */
-       ld      r9, HSTATE_KVM_VCPU(r13)
-       bl      kvmppc_save_tm
+       ld      r3, HSTATE_KVM_VCPU(r13)
+       ld      r4, VCPU_MSR(r3)
+       bl      kvmppc_save_tm_hv
 91:
 #endif
 
@@ -2805,7 +2809,10 @@ END_FTR_SECTION(CPU_FTR_TM | CPU_FTR_P9_TM_HV_ASSIST, 0)
        /*
         * NOTE THAT THIS TRASHES ALL NON-VOLATILE REGISTERS INCLUDING CR
         */
-       bl      kvmppc_restore_tm
+       mr      r3, r4
+       ld      r4, VCPU_MSR(r3)
+       bl      kvmppc_restore_tm_hv
+       ld      r4, HSTATE_KVM_VCPU(r13)
 91:
 #endif
 
@@ -3126,11 +3133,22 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 /*
  * Save transactional state and TM-related registers.
- * Called with r9 pointing to the vcpu struct.
+ * Called with r3 pointing to the vcpu struct and r4 containing
+ * the guest MSR value.
  * This can modify all checkpointed registers, but
- * restores r1, r2 and r9 (vcpu pointer) before exit.
+ * restores r1 and r2 before exit.
  */
-kvmppc_save_tm:
+kvmppc_save_tm_hv:
+       /* See if we need to handle fake suspend mode */
+BEGIN_FTR_SECTION
+       b       __kvmppc_save_tm
+END_FTR_SECTION_IFCLR(CPU_FTR_P9_TM_HV_ASSIST)
+
+       lbz     r0, HSTATE_FAKE_SUSPEND(r13) /* Were we fake suspended? */
+       cmpwi   r0, 0
+       beq     __kvmppc_save_tm
+
+       /* The following code handles the fake_suspend = 1 case */
        mflr    r0
        std     r0, PPC_LR_STKOFF(r1)
        stdu    r1, -PPC_MIN_STKFRM(r1)
@@ -3141,59 +3159,37 @@ kvmppc_save_tm:
        rldimi  r8, r0, MSR_TM_LG, 63-MSR_TM_LG
        mtmsrd  r8
 
-       ld      r5, VCPU_MSR(r9)
-       rldicl. r5, r5, 64 - MSR_TS_S_LG, 62
-       beq     1f      /* TM not active in guest. */
-
-       std     r1, HSTATE_HOST_R1(r13)
-       li      r3, TM_CAUSE_KVM_RESCHED
-
-BEGIN_FTR_SECTION
-       lbz     r0, HSTATE_FAKE_SUSPEND(r13) /* Were we fake suspended? */
-       cmpwi   r0, 0
-       beq     3f
        rldicl. r8, r8, 64 - MSR_TS_S_LG, 62 /* Did we actually hrfid? */
        beq     4f
-BEGIN_FTR_SECTION_NESTED(96)
+BEGIN_FTR_SECTION
        bl      pnv_power9_force_smt4_catch
-END_FTR_SECTION_NESTED(CPU_FTR_P9_TM_XER_SO_BUG, CPU_FTR_P9_TM_XER_SO_BUG, 96)
+END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_XER_SO_BUG)
        nop
-       b       6f
-3:
-       /* Emulation of the treclaim instruction needs TEXASR before treclaim */
-       mfspr   r6, SPRN_TEXASR
-       std     r6, VCPU_ORIG_TEXASR(r9)
-6:
-END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_HV_ASSIST)
 
-       /* Clear the MSR RI since r1, r13 are all going to be foobar. */
+       std     r1, HSTATE_HOST_R1(r13)
+
+       /* Clear the MSR RI since r1, r13 may be foobar. */
        li      r5, 0
        mtmsrd  r5, 1
 
-       /* All GPRs are volatile at this point. */
+       /* We have to treclaim here because that's the only way to do S->N */
+       li      r3, TM_CAUSE_KVM_RESCHED
        TRECLAIM(R3)
 
-       /* Temporarily store r13 and r9 so we have some regs to play with */
-       SET_SCRATCH0(r13)
-       GET_PACA(r13)
-       std     r9, PACATMSCRATCH(r13)
-
-       /* If doing TM emulation on POWER9 DD2.2, check for fake suspend mode */
-BEGIN_FTR_SECTION
-       lbz     r9, HSTATE_FAKE_SUSPEND(r13)
-       cmpwi   r9, 0
-       beq     2f
        /*
         * We were in fake suspend, so we are not going to save the
         * register state as the guest checkpointed state (since
         * we already have it), therefore we can now use any volatile GPR.
         */
-       /* Reload stack pointer and TOC. */
+       /* Reload PACA pointer, stack pointer and TOC. */
+       GET_PACA(r13)
        ld      r1, HSTATE_HOST_R1(r13)
        ld      r2, PACATOC(r13)
+
        /* Set MSR RI now we have r1 and r13 back. */
        li      r5, MSR_RI
        mtmsrd  r5, 1
+
        HMT_MEDIUM
        ld      r6, HSTATE_DSCR(r13)
        mtspr   SPRN_DSCR, r6
@@ -3208,85 +3204,9 @@ END_FTR_SECTION_NESTED(CPU_FTR_P9_TM_XER_SO_BUG, CPU_FTR_P9_TM_XER_SO_BUG, 96)
        li      r0, PSSCR_FAKE_SUSPEND
        andc    r3, r3, r0
        mtspr   SPRN_PSSCR, r3
-       ld      r9, HSTATE_KVM_VCPU(r13)
-       /* Don't save TEXASR, use value from last exit in real suspend state */
-       b       11f
-2:
-END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_HV_ASSIST)
 
+       /* Don't save TEXASR, use value from last exit in real suspend state */
        ld      r9, HSTATE_KVM_VCPU(r13)
-
-       /* Get a few more GPRs free. */
-       std     r29, VCPU_GPRS_TM(29)(r9)
-       std     r30, VCPU_GPRS_TM(30)(r9)
-       std     r31, VCPU_GPRS_TM(31)(r9)
-
-       /* Save away PPR and DSCR soon so don't run with user values. */
-       mfspr   r31, SPRN_PPR
-       HMT_MEDIUM
-       mfspr   r30, SPRN_DSCR
-       ld      r29, HSTATE_DSCR(r13)
-       mtspr   SPRN_DSCR, r29
-
-       /* Save all but r9, r13 & r29-r31 */
-       reg = 0
-       .rept   29
-       .if (reg != 9) && (reg != 13)
-       std     reg, VCPU_GPRS_TM(reg)(r9)
-       .endif
-       reg = reg + 1
-       .endr
-       /* ... now save r13 */
-       GET_SCRATCH0(r4)
-       std     r4, VCPU_GPRS_TM(13)(r9)
-       /* ... and save r9 */
-       ld      r4, PACATMSCRATCH(r13)
-       std     r4, VCPU_GPRS_TM(9)(r9)
-
-       /* Reload stack pointer and TOC. */
-       ld      r1, HSTATE_HOST_R1(r13)
-       ld      r2, PACATOC(r13)
-
-       /* Set MSR RI now we have r1 and r13 back. */
-       li      r5, MSR_RI
-       mtmsrd  r5, 1
-
-       /* Save away checkpinted SPRs. */
-       std     r31, VCPU_PPR_TM(r9)
-       std     r30, VCPU_DSCR_TM(r9)
-       mflr    r5
-       mfcr    r6
-       mfctr   r7
-       mfspr   r8, SPRN_AMR
-       mfspr   r10, SPRN_TAR
-       mfxer   r11
-       std     r5, VCPU_LR_TM(r9)
-       stw     r6, VCPU_CR_TM(r9)
-       std     r7, VCPU_CTR_TM(r9)
-       std     r8, VCPU_AMR_TM(r9)
-       std     r10, VCPU_TAR_TM(r9)
-       std     r11, VCPU_XER_TM(r9)
-
-       /* Restore r12 as trap number. */
-       lwz     r12, VCPU_TRAP(r9)
-
-       /* Save FP/VSX. */
-       addi    r3, r9, VCPU_FPRS_TM
-       bl      store_fp_state
-       addi    r3, r9, VCPU_VRS_TM
-       bl      store_vr_state
-       mfspr   r6, SPRN_VRSAVE
-       stw     r6, VCPU_VRSAVE_TM(r9)
-1:
-       /*
-        * We need to save these SPRs after the treclaim so that the software
-        * error code is recorded correctly in the TEXASR.  Also the user may
-        * change these outside of a transaction, so they must always be
-        * context switched.
-        */
-       mfspr   r7, SPRN_TEXASR
-       std     r7, VCPU_TEXASR(r9)
-11:
        mfspr   r5, SPRN_TFHAR
        mfspr   r6, SPRN_TFIAR
        std     r5, VCPU_TFHAR(r9)
@@ -3299,149 +3219,63 @@ END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_HV_ASSIST)
 
 /*
  * Restore transactional state and TM-related registers.
- * Called with r4 pointing to the vcpu struct.
+ * Called with r3 pointing to the vcpu struct
+ * and r4 containing the guest MSR value.
  * This potentially modifies all checkpointed registers.
- * It restores r1, r2, r4 from the PACA.
+ * It restores r1 and r2 from the PACA.
  */
-kvmppc_restore_tm:
+kvmppc_restore_tm_hv:
+       /*
+        * If we are doing TM emulation for the guest on a POWER9 DD2,
+        * then we don't actually do a trechkpt -- we either set up
+        * fake-suspend mode, or emulate a TM rollback.
+        */
+BEGIN_FTR_SECTION
+       b       __kvmppc_restore_tm
+END_FTR_SECTION_IFCLR(CPU_FTR_P9_TM_HV_ASSIST)
        mflr    r0
        std     r0, PPC_LR_STKOFF(r1)
 
-       /* Turn on TM/FP/VSX/VMX so we can restore them. */
+       li      r0, 0
+       stb     r0, HSTATE_FAKE_SUSPEND(r13)
+
+       /* Turn on TM so we can restore TM SPRs */
        mfmsr   r5
-       li      r6, MSR_TM >> 32
-       sldi    r6, r6, 32
-       or      r5, r5, r6
-       ori     r5, r5, MSR_FP
-       oris    r5, r5, (MSR_VEC | MSR_VSX)@h
+       li      r0, 1
+       rldimi  r5, r0, MSR_TM_LG, 63-MSR_TM_LG
        mtmsrd  r5
 
        /*
         * The user may change these outside of a transaction, so they must
         * always be context switched.
         */
-       ld      r5, VCPU_TFHAR(r4)
-       ld      r6, VCPU_TFIAR(r4)
-       ld      r7, VCPU_TEXASR(r4)
+       ld      r5, VCPU_TFHAR(r3)
+       ld      r6, VCPU_TFIAR(r3)
+       ld      r7, VCPU_TEXASR(r3)
        mtspr   SPRN_TFHAR, r5
        mtspr   SPRN_TFIAR, r6
        mtspr   SPRN_TEXASR, r7
 
-       li      r0, 0
-       stb     r0, HSTATE_FAKE_SUSPEND(r13)
-       ld      r5, VCPU_MSR(r4)
-       rldicl. r5, r5, 64 - MSR_TS_S_LG, 62
+       rldicl. r5, r4, 64 - MSR_TS_S_LG, 62
        beqlr           /* TM not active in guest */
-       std     r1, HSTATE_HOST_R1(r13)
 
-       /* Make sure the failure summary is set, otherwise we'll program check
-        * when we trechkpt.  It's possible that this might have been not set
-        * on a kvmppc_set_one_reg() call but we shouldn't let this crash the
-        * host.
-        */
+       /* Make sure the failure summary is set */
        oris    r7, r7, (TEXASR_FS)@h
        mtspr   SPRN_TEXASR, r7
 
-       /*
-        * If we are doing TM emulation for the guest on a POWER9 DD2,
-        * then we don't actually do a trechkpt -- we either set up
-        * fake-suspend mode, or emulate a TM rollback.
-        */
-BEGIN_FTR_SECTION
-       b       .Ldo_tm_fake_load
-END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_HV_ASSIST)
-
-       /*
-        * We need to load up the checkpointed state for the guest.
-        * We need to do this early as it will blow away any GPRs, VSRs and
-        * some SPRs.
-        */
-
-       mr      r31, r4
-       addi    r3, r31, VCPU_FPRS_TM
-       bl      load_fp_state
-       addi    r3, r31, VCPU_VRS_TM
-       bl      load_vr_state
-       mr      r4, r31
-       lwz     r7, VCPU_VRSAVE_TM(r4)
-       mtspr   SPRN_VRSAVE, r7
-
-       ld      r5, VCPU_LR_TM(r4)
-       lwz     r6, VCPU_CR_TM(r4)
-       ld      r7, VCPU_CTR_TM(r4)
-       ld      r8, VCPU_AMR_TM(r4)
-       ld      r9, VCPU_TAR_TM(r4)
-       ld      r10, VCPU_XER_TM(r4)
-       mtlr    r5
-       mtcr    r6
-       mtctr   r7
-       mtspr   SPRN_AMR, r8
-       mtspr   SPRN_TAR, r9
-       mtxer   r10
-
-       /*
-        * Load up PPR and DSCR values but don't put them in the actual SPRs
-        * till the last moment to avoid running with userspace PPR and DSCR for
-        * too long.
-        */
-       ld      r29, VCPU_DSCR_TM(r4)
-       ld      r30, VCPU_PPR_TM(r4)
-
-       std     r2, PACATMSCRATCH(r13) /* Save TOC */
-
-       /* Clear the MSR RI since r1, r13 are all going to be foobar. */
-       li      r5, 0
-       mtmsrd  r5, 1
-
-       /* Load GPRs r0-r28 */
-       reg = 0
-       .rept   29
-       ld      reg, VCPU_GPRS_TM(reg)(r31)
-       reg = reg + 1
-       .endr
-
-       mtspr   SPRN_DSCR, r29
-       mtspr   SPRN_PPR, r30
-
-       /* Load final GPRs */
-       ld      29, VCPU_GPRS_TM(29)(r31)
-       ld      30, VCPU_GPRS_TM(30)(r31)
-       ld      31, VCPU_GPRS_TM(31)(r31)
-
-       /* TM checkpointed state is now setup.  All GPRs are now volatile. */
-       TRECHKPT
-
-       /* Now let's get back the state we need. */
-       HMT_MEDIUM
-       GET_PACA(r13)
-       ld      r29, HSTATE_DSCR(r13)
-       mtspr   SPRN_DSCR, r29
-       ld      r4, HSTATE_KVM_VCPU(r13)
-       ld      r1, HSTATE_HOST_R1(r13)
-       ld      r2, PACATMSCRATCH(r13)
-
-       /* Set the MSR RI since we have our registers back. */
-       li      r5, MSR_RI
-       mtmsrd  r5, 1
-9:
-       ld      r0, PPC_LR_STKOFF(r1)
-       mtlr    r0
-       blr
-
-.Ldo_tm_fake_load:
        cmpwi   r5, 1           /* check for suspended state */
        bgt     10f
        stb     r5, HSTATE_FAKE_SUSPEND(r13)
-       b       9b              /* and return */
+       b       9f              /* and return */
 10:    stdu    r1, -PPC_MIN_STKFRM(r1)
        /* guest is in transactional state, so simulate rollback */
-       mr      r3, r4
        bl      kvmhv_emulate_tm_rollback
        nop
-       ld      r4, HSTATE_KVM_VCPU(r13) /* our vcpu pointer has been trashed */
        addi    r1, r1, PPC_MIN_STKFRM
-       b       9b
-#endif
+9:     ld      r0, PPC_LR_STKOFF(r1)
+       mtlr    r0
+       blr
+#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
 
 /*
  * We come here if we get any exception or interrupt while we are
@@ -3572,6 +3406,8 @@ END_MMU_FTR_SECTION_IFSET(MMU_FTR_TYPE_RADIX)
        bcl     20, 31, .+4
 5:     mflr    r3
        addi    r3, r3, 9f - 5b
+       li      r4, -1
+       rldimi  r3, r4, 62, 0   /* ensure 0xc000000000000000 bits are set */
        ld      r4, PACAKMSR(r13)
        mtspr   SPRN_SRR0, r3
        mtspr   SPRN_SRR1, r4
index bf710ad3a6d71449bce9ba6a05fe9de577853280..008285058f9b554616cb52fdc53a85843826ae23 100644 (file)
@@ -19,7 +19,7 @@ static void emulate_tx_failure(struct kvm_vcpu *vcpu, u64 failure_cause)
        u64 texasr, tfiar;
        u64 msr = vcpu->arch.shregs.msr;
 
-       tfiar = vcpu->arch.pc & ~0x3ull;
+       tfiar = vcpu->arch.regs.nip & ~0x3ull;
        texasr = (failure_cause << 56) | TEXASR_ABORT | TEXASR_FS | TEXASR_EXACT;
        if (MSR_TM_SUSPENDED(vcpu->arch.shregs.msr))
                texasr |= TEXASR_SUSP;
@@ -57,8 +57,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu)
                               (newmsr & MSR_TM)));
                newmsr = sanitize_msr(newmsr);
                vcpu->arch.shregs.msr = newmsr;
-               vcpu->arch.cfar = vcpu->arch.pc - 4;
-               vcpu->arch.pc = vcpu->arch.shregs.srr0;
+               vcpu->arch.cfar = vcpu->arch.regs.nip - 4;
+               vcpu->arch.regs.nip = vcpu->arch.shregs.srr0;
                return RESUME_GUEST;
 
        case PPC_INST_RFEBB:
@@ -90,8 +90,8 @@ int kvmhv_p9_tm_emulation(struct kvm_vcpu *vcpu)
                vcpu->arch.bescr = bescr;
                msr = (msr & ~MSR_TS_MASK) | MSR_TS_T;
                vcpu->arch.shregs.msr = msr;
-               vcpu->arch.cfar = vcpu->arch.pc - 4;
-               vcpu->arch.pc = vcpu->arch.ebbrr;
+               vcpu->arch.cfar = vcpu->arch.regs.nip - 4;
+               vcpu->arch.regs.nip = vcpu->arch.ebbrr;
                return RESUME_GUEST;
 
        case PPC_INST_MTMSRD:
index d98ccfd2b88cd5379c3aefe086347466135d38a4..b2c7c6fca4f96e5a315371e39ec9d25dc220da8d 100644 (file)
@@ -35,8 +35,8 @@ int kvmhv_p9_tm_emulation_early(struct kvm_vcpu *vcpu)
                        return 0;
                newmsr = sanitize_msr(newmsr);
                vcpu->arch.shregs.msr = newmsr;
-               vcpu->arch.cfar = vcpu->arch.pc - 4;
-               vcpu->arch.pc = vcpu->arch.shregs.srr0;
+               vcpu->arch.cfar = vcpu->arch.regs.nip - 4;
+               vcpu->arch.regs.nip = vcpu->arch.shregs.srr0;
                return 1;
 
        case PPC_INST_RFEBB:
@@ -58,8 +58,8 @@ int kvmhv_p9_tm_emulation_early(struct kvm_vcpu *vcpu)
                mtspr(SPRN_BESCR, bescr);
                msr = (msr & ~MSR_TS_MASK) | MSR_TS_T;
                vcpu->arch.shregs.msr = msr;
-               vcpu->arch.cfar = vcpu->arch.pc - 4;
-               vcpu->arch.pc = mfspr(SPRN_EBBRR);
+               vcpu->arch.cfar = vcpu->arch.regs.nip - 4;
+               vcpu->arch.regs.nip = mfspr(SPRN_EBBRR);
                return 1;
 
        case PPC_INST_MTMSRD:
@@ -103,7 +103,7 @@ int kvmhv_p9_tm_emulation_early(struct kvm_vcpu *vcpu)
 void kvmhv_emulate_tm_rollback(struct kvm_vcpu *vcpu)
 {
        vcpu->arch.shregs.msr &= ~MSR_TS_MASK;  /* go to N state */
-       vcpu->arch.pc = vcpu->arch.tfhar;
+       vcpu->arch.regs.nip = vcpu->arch.tfhar;
        copy_from_checkpoint(vcpu);
        vcpu->arch.cr = (vcpu->arch.cr & 0x0fffffff) | 0xa0000000;
 }
index d3f304d06adfcb27dfd87b890b2fde37152d877d..c3b8006f0eac14a5d1f35a7b9b31f5fe106b98b8 100644 (file)
@@ -42,6 +42,8 @@
 #include <linux/highmem.h>
 #include <linux/module.h>
 #include <linux/miscdevice.h>
+#include <asm/asm-prototypes.h>
+#include <asm/tm.h>
 
 #include "book3s.h"
 
@@ -53,7 +55,9 @@
 
 static int kvmppc_handle_ext(struct kvm_vcpu *vcpu, unsigned int exit_nr,
                             ulong msr);
-static void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac);
+#ifdef CONFIG_PPC_BOOK3S_64
+static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac);
+#endif
 
 /* Some compatibility defines */
 #ifdef CONFIG_PPC_BOOK3S_32
@@ -114,6 +118,8 @@ static void kvmppc_core_vcpu_load_pr(struct kvm_vcpu *vcpu, int cpu)
 
        if (kvmppc_is_split_real(vcpu))
                kvmppc_fixup_split_real(vcpu);
+
+       kvmppc_restore_tm_pr(vcpu);
 }
 
 static void kvmppc_core_vcpu_put_pr(struct kvm_vcpu *vcpu)
@@ -133,6 +139,7 @@ static void kvmppc_core_vcpu_put_pr(struct kvm_vcpu *vcpu)
 
        kvmppc_giveup_ext(vcpu, MSR_FP | MSR_VEC | MSR_VSX);
        kvmppc_giveup_fac(vcpu, FSCR_TAR_LG);
+       kvmppc_save_tm_pr(vcpu);
 
        /* Enable AIL if supported */
        if (cpu_has_feature(CPU_FTR_HVMODE) &&
@@ -147,25 +154,25 @@ void kvmppc_copy_to_svcpu(struct kvm_vcpu *vcpu)
 {
        struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
 
-       svcpu->gpr[0] = vcpu->arch.gpr[0];
-       svcpu->gpr[1] = vcpu->arch.gpr[1];
-       svcpu->gpr[2] = vcpu->arch.gpr[2];
-       svcpu->gpr[3] = vcpu->arch.gpr[3];
-       svcpu->gpr[4] = vcpu->arch.gpr[4];
-       svcpu->gpr[5] = vcpu->arch.gpr[5];
-       svcpu->gpr[6] = vcpu->arch.gpr[6];
-       svcpu->gpr[7] = vcpu->arch.gpr[7];
-       svcpu->gpr[8] = vcpu->arch.gpr[8];
-       svcpu->gpr[9] = vcpu->arch.gpr[9];
-       svcpu->gpr[10] = vcpu->arch.gpr[10];
-       svcpu->gpr[11] = vcpu->arch.gpr[11];
-       svcpu->gpr[12] = vcpu->arch.gpr[12];
-       svcpu->gpr[13] = vcpu->arch.gpr[13];
+       svcpu->gpr[0] = vcpu->arch.regs.gpr[0];
+       svcpu->gpr[1] = vcpu->arch.regs.gpr[1];
+       svcpu->gpr[2] = vcpu->arch.regs.gpr[2];
+       svcpu->gpr[3] = vcpu->arch.regs.gpr[3];
+       svcpu->gpr[4] = vcpu->arch.regs.gpr[4];
+       svcpu->gpr[5] = vcpu->arch.regs.gpr[5];
+       svcpu->gpr[6] = vcpu->arch.regs.gpr[6];
+       svcpu->gpr[7] = vcpu->arch.regs.gpr[7];
+       svcpu->gpr[8] = vcpu->arch.regs.gpr[8];
+       svcpu->gpr[9] = vcpu->arch.regs.gpr[9];
+       svcpu->gpr[10] = vcpu->arch.regs.gpr[10];
+       svcpu->gpr[11] = vcpu->arch.regs.gpr[11];
+       svcpu->gpr[12] = vcpu->arch.regs.gpr[12];
+       svcpu->gpr[13] = vcpu->arch.regs.gpr[13];
        svcpu->cr  = vcpu->arch.cr;
-       svcpu->xer = vcpu->arch.xer;
-       svcpu->ctr = vcpu->arch.ctr;
-       svcpu->lr  = vcpu->arch.lr;
-       svcpu->pc  = vcpu->arch.pc;
+       svcpu->xer = vcpu->arch.regs.xer;
+       svcpu->ctr = vcpu->arch.regs.ctr;
+       svcpu->lr  = vcpu->arch.regs.link;
+       svcpu->pc  = vcpu->arch.regs.nip;
 #ifdef CONFIG_PPC_BOOK3S_64
        svcpu->shadow_fscr = vcpu->arch.shadow_fscr;
 #endif
@@ -182,10 +189,45 @@ void kvmppc_copy_to_svcpu(struct kvm_vcpu *vcpu)
        svcpu_put(svcpu);
 }
 
+static void kvmppc_recalc_shadow_msr(struct kvm_vcpu *vcpu)
+{
+       ulong guest_msr = kvmppc_get_msr(vcpu);
+       ulong smsr = guest_msr;
+
+       /* Guest MSR values */
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       smsr &= MSR_FE0 | MSR_FE1 | MSR_SF | MSR_SE | MSR_BE | MSR_LE |
+               MSR_TM | MSR_TS_MASK;
+#else
+       smsr &= MSR_FE0 | MSR_FE1 | MSR_SF | MSR_SE | MSR_BE | MSR_LE;
+#endif
+       /* Process MSR values */
+       smsr |= MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_PR | MSR_EE;
+       /* External providers the guest reserved */
+       smsr |= (guest_msr & vcpu->arch.guest_owned_ext);
+       /* 64-bit Process MSR values */
+#ifdef CONFIG_PPC_BOOK3S_64
+       smsr |= MSR_ISF | MSR_HV;
+#endif
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       /*
+        * in guest privileged state, we want to fail all TM transactions.
+        * So disable MSR TM bit so that all tbegin. will be able to be
+        * trapped into host.
+        */
+       if (!(guest_msr & MSR_PR))
+               smsr &= ~MSR_TM;
+#endif
+       vcpu->arch.shadow_msr = smsr;
+}
+
 /* Copy data touched by real-mode code from shadow vcpu back to vcpu */
 void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu)
 {
        struct kvmppc_book3s_shadow_vcpu *svcpu = svcpu_get(vcpu);
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       ulong old_msr;
+#endif
 
        /*
         * Maybe we were already preempted and synced the svcpu from
@@ -194,25 +236,25 @@ void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu)
        if (!svcpu->in_use)
                goto out;
 
-       vcpu->arch.gpr[0] = svcpu->gpr[0];
-       vcpu->arch.gpr[1] = svcpu->gpr[1];
-       vcpu->arch.gpr[2] = svcpu->gpr[2];
-       vcpu->arch.gpr[3] = svcpu->gpr[3];
-       vcpu->arch.gpr[4] = svcpu->gpr[4];
-       vcpu->arch.gpr[5] = svcpu->gpr[5];
-       vcpu->arch.gpr[6] = svcpu->gpr[6];
-       vcpu->arch.gpr[7] = svcpu->gpr[7];
-       vcpu->arch.gpr[8] = svcpu->gpr[8];
-       vcpu->arch.gpr[9] = svcpu->gpr[9];
-       vcpu->arch.gpr[10] = svcpu->gpr[10];
-       vcpu->arch.gpr[11] = svcpu->gpr[11];
-       vcpu->arch.gpr[12] = svcpu->gpr[12];
-       vcpu->arch.gpr[13] = svcpu->gpr[13];
+       vcpu->arch.regs.gpr[0] = svcpu->gpr[0];
+       vcpu->arch.regs.gpr[1] = svcpu->gpr[1];
+       vcpu->arch.regs.gpr[2] = svcpu->gpr[2];
+       vcpu->arch.regs.gpr[3] = svcpu->gpr[3];
+       vcpu->arch.regs.gpr[4] = svcpu->gpr[4];
+       vcpu->arch.regs.gpr[5] = svcpu->gpr[5];
+       vcpu->arch.regs.gpr[6] = svcpu->gpr[6];
+       vcpu->arch.regs.gpr[7] = svcpu->gpr[7];
+       vcpu->arch.regs.gpr[8] = svcpu->gpr[8];
+       vcpu->arch.regs.gpr[9] = svcpu->gpr[9];
+       vcpu->arch.regs.gpr[10] = svcpu->gpr[10];
+       vcpu->arch.regs.gpr[11] = svcpu->gpr[11];
+       vcpu->arch.regs.gpr[12] = svcpu->gpr[12];
+       vcpu->arch.regs.gpr[13] = svcpu->gpr[13];
        vcpu->arch.cr  = svcpu->cr;
-       vcpu->arch.xer = svcpu->xer;
-       vcpu->arch.ctr = svcpu->ctr;
-       vcpu->arch.lr  = svcpu->lr;
-       vcpu->arch.pc  = svcpu->pc;
+       vcpu->arch.regs.xer = svcpu->xer;
+       vcpu->arch.regs.ctr = svcpu->ctr;
+       vcpu->arch.regs.link  = svcpu->lr;
+       vcpu->arch.regs.nip  = svcpu->pc;
        vcpu->arch.shadow_srr1 = svcpu->shadow_srr1;
        vcpu->arch.fault_dar   = svcpu->fault_dar;
        vcpu->arch.fault_dsisr = svcpu->fault_dsisr;
@@ -228,12 +270,116 @@ void kvmppc_copy_from_svcpu(struct kvm_vcpu *vcpu)
        to_book3s(vcpu)->vtb += get_vtb() - vcpu->arch.entry_vtb;
        if (cpu_has_feature(CPU_FTR_ARCH_207S))
                vcpu->arch.ic += mfspr(SPRN_IC) - vcpu->arch.entry_ic;
+
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       /*
+        * Unlike other MSR bits, MSR[TS]bits can be changed at guest without
+        * notifying host:
+        *  modified by unprivileged instructions like "tbegin"/"tend"/
+        * "tresume"/"tsuspend" in PR KVM guest.
+        *
+        * It is necessary to sync here to calculate a correct shadow_msr.
+        *
+        * privileged guest's tbegin will be failed at present. So we
+        * only take care of problem state guest.
+        */
+       old_msr = kvmppc_get_msr(vcpu);
+       if (unlikely((old_msr & MSR_PR) &&
+               (vcpu->arch.shadow_srr1 & (MSR_TS_MASK)) !=
+                               (old_msr & (MSR_TS_MASK)))) {
+               old_msr &= ~(MSR_TS_MASK);
+               old_msr |= (vcpu->arch.shadow_srr1 & (MSR_TS_MASK));
+               kvmppc_set_msr_fast(vcpu, old_msr);
+               kvmppc_recalc_shadow_msr(vcpu);
+       }
+#endif
+
        svcpu->in_use = false;
 
 out:
        svcpu_put(svcpu);
 }
 
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+void kvmppc_save_tm_sprs(struct kvm_vcpu *vcpu)
+{
+       tm_enable();
+       vcpu->arch.tfhar = mfspr(SPRN_TFHAR);
+       vcpu->arch.texasr = mfspr(SPRN_TEXASR);
+       vcpu->arch.tfiar = mfspr(SPRN_TFIAR);
+       tm_disable();
+}
+
+void kvmppc_restore_tm_sprs(struct kvm_vcpu *vcpu)
+{
+       tm_enable();
+       mtspr(SPRN_TFHAR, vcpu->arch.tfhar);
+       mtspr(SPRN_TEXASR, vcpu->arch.texasr);
+       mtspr(SPRN_TFIAR, vcpu->arch.tfiar);
+       tm_disable();
+}
+
+/* loadup math bits which is enabled at kvmppc_get_msr() but not enabled at
+ * hardware.
+ */
+static void kvmppc_handle_lost_math_exts(struct kvm_vcpu *vcpu)
+{
+       ulong exit_nr;
+       ulong ext_diff = (kvmppc_get_msr(vcpu) & ~vcpu->arch.guest_owned_ext) &
+               (MSR_FP | MSR_VEC | MSR_VSX);
+
+       if (!ext_diff)
+               return;
+
+       if (ext_diff == MSR_FP)
+               exit_nr = BOOK3S_INTERRUPT_FP_UNAVAIL;
+       else if (ext_diff == MSR_VEC)
+               exit_nr = BOOK3S_INTERRUPT_ALTIVEC;
+       else
+               exit_nr = BOOK3S_INTERRUPT_VSX;
+
+       kvmppc_handle_ext(vcpu, exit_nr, ext_diff);
+}
+
+void kvmppc_save_tm_pr(struct kvm_vcpu *vcpu)
+{
+       if (!(MSR_TM_ACTIVE(kvmppc_get_msr(vcpu)))) {
+               kvmppc_save_tm_sprs(vcpu);
+               return;
+       }
+
+       kvmppc_giveup_fac(vcpu, FSCR_TAR_LG);
+       kvmppc_giveup_ext(vcpu, MSR_VSX);
+
+       preempt_disable();
+       _kvmppc_save_tm_pr(vcpu, mfmsr());
+       preempt_enable();
+}
+
+void kvmppc_restore_tm_pr(struct kvm_vcpu *vcpu)
+{
+       if (!MSR_TM_ACTIVE(kvmppc_get_msr(vcpu))) {
+               kvmppc_restore_tm_sprs(vcpu);
+               if (kvmppc_get_msr(vcpu) & MSR_TM) {
+                       kvmppc_handle_lost_math_exts(vcpu);
+                       if (vcpu->arch.fscr & FSCR_TAR)
+                               kvmppc_handle_fac(vcpu, FSCR_TAR_LG);
+               }
+               return;
+       }
+
+       preempt_disable();
+       _kvmppc_restore_tm_pr(vcpu, kvmppc_get_msr(vcpu));
+       preempt_enable();
+
+       if (kvmppc_get_msr(vcpu) & MSR_TM) {
+               kvmppc_handle_lost_math_exts(vcpu);
+               if (vcpu->arch.fscr & FSCR_TAR)
+                       kvmppc_handle_fac(vcpu, FSCR_TAR_LG);
+       }
+}
+#endif
+
 static int kvmppc_core_check_requests_pr(struct kvm_vcpu *vcpu)
 {
        int r = 1; /* Indicate we want to get back into the guest */
@@ -306,32 +452,29 @@ static void kvm_set_spte_hva_pr(struct kvm *kvm, unsigned long hva, pte_t pte)
 
 /*****************************************/
 
-static void kvmppc_recalc_shadow_msr(struct kvm_vcpu *vcpu)
-{
-       ulong guest_msr = kvmppc_get_msr(vcpu);
-       ulong smsr = guest_msr;
-
-       /* Guest MSR values */
-       smsr &= MSR_FE0 | MSR_FE1 | MSR_SF | MSR_SE | MSR_BE | MSR_LE;
-       /* Process MSR values */
-       smsr |= MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_PR | MSR_EE;
-       /* External providers the guest reserved */
-       smsr |= (guest_msr & vcpu->arch.guest_owned_ext);
-       /* 64-bit Process MSR values */
-#ifdef CONFIG_PPC_BOOK3S_64
-       smsr |= MSR_ISF | MSR_HV;
-#endif
-       vcpu->arch.shadow_msr = smsr;
-}
-
 static void kvmppc_set_msr_pr(struct kvm_vcpu *vcpu, u64 msr)
 {
-       ulong old_msr = kvmppc_get_msr(vcpu);
+       ulong old_msr;
+
+       /* For PAPR guest, make sure MSR reflects guest mode */
+       if (vcpu->arch.papr_enabled)
+               msr = (msr & ~MSR_HV) | MSR_ME;
 
 #ifdef EXIT_DEBUG
        printk(KERN_INFO "KVM: Set MSR to 0x%llx\n", msr);
 #endif
 
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       /* We should never target guest MSR to TS=10 && PR=0,
+        * since we always fail transaction for guest privilege
+        * state.
+        */
+       if (!(msr & MSR_PR) && MSR_TM_TRANSACTIONAL(msr))
+               kvmppc_emulate_tabort(vcpu,
+                       TM_CAUSE_KVM_FAC_UNAV | TM_CAUSE_PERSISTENT);
+#endif
+
+       old_msr = kvmppc_get_msr(vcpu);
        msr &= to_book3s(vcpu)->msr_mask;
        kvmppc_set_msr_fast(vcpu, msr);
        kvmppc_recalc_shadow_msr(vcpu);
@@ -387,6 +530,11 @@ static void kvmppc_set_msr_pr(struct kvm_vcpu *vcpu, u64 msr)
        /* Preload FPU if it's enabled */
        if (kvmppc_get_msr(vcpu) & MSR_FP)
                kvmppc_handle_ext(vcpu, BOOK3S_INTERRUPT_FP_UNAVAIL, MSR_FP);
+
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       if (kvmppc_get_msr(vcpu) & MSR_TM)
+               kvmppc_handle_lost_math_exts(vcpu);
+#endif
 }
 
 void kvmppc_set_pvr_pr(struct kvm_vcpu *vcpu, u32 pvr)
@@ -584,24 +732,20 @@ int kvmppc_handle_pagefault(struct kvm_run *run, struct kvm_vcpu *vcpu,
                pte.may_execute = !data;
        }
 
-       if (page_found == -ENOENT) {
-               /* Page not found in guest PTE entries */
-               u64 ssrr1 = vcpu->arch.shadow_srr1;
-               u64 msr = kvmppc_get_msr(vcpu);
-               kvmppc_set_dar(vcpu, kvmppc_get_fault_dar(vcpu));
-               kvmppc_set_dsisr(vcpu, vcpu->arch.fault_dsisr);
-               kvmppc_set_msr_fast(vcpu, msr | (ssrr1 & 0xf8000000ULL));
-               kvmppc_book3s_queue_irqprio(vcpu, vec);
-       } else if (page_found == -EPERM) {
-               /* Storage protection */
-               u32 dsisr = vcpu->arch.fault_dsisr;
-               u64 ssrr1 = vcpu->arch.shadow_srr1;
-               u64 msr = kvmppc_get_msr(vcpu);
-               kvmppc_set_dar(vcpu, kvmppc_get_fault_dar(vcpu));
-               dsisr = (dsisr & ~DSISR_NOHPTE) | DSISR_PROTFAULT;
-               kvmppc_set_dsisr(vcpu, dsisr);
-               kvmppc_set_msr_fast(vcpu, msr | (ssrr1 & 0xf8000000ULL));
-               kvmppc_book3s_queue_irqprio(vcpu, vec);
+       if (page_found == -ENOENT || page_found == -EPERM) {
+               /* Page not found in guest PTE entries, or protection fault */
+               u64 flags;
+
+               if (page_found == -EPERM)
+                       flags = DSISR_PROTFAULT;
+               else
+                       flags = DSISR_NOHPTE;
+               if (data) {
+                       flags |= vcpu->arch.fault_dsisr & DSISR_ISSTORE;
+                       kvmppc_core_queue_data_storage(vcpu, eaddr, flags);
+               } else {
+                       kvmppc_core_queue_inst_storage(vcpu, flags);
+               }
        } else if (page_found == -EINVAL) {
                /* Page not found in guest SLB */
                kvmppc_set_dar(vcpu, kvmppc_get_fault_dar(vcpu));
@@ -683,7 +827,7 @@ void kvmppc_giveup_ext(struct kvm_vcpu *vcpu, ulong msr)
 }
 
 /* Give up facility (TAR / EBB / DSCR) */
-static void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac)
+void kvmppc_giveup_fac(struct kvm_vcpu *vcpu, ulong fac)
 {
 #ifdef CONFIG_PPC_BOOK3S_64
        if (!(vcpu->arch.shadow_fscr & (1ULL << fac))) {
@@ -802,7 +946,7 @@ static void kvmppc_handle_lost_ext(struct kvm_vcpu *vcpu)
 
 #ifdef CONFIG_PPC_BOOK3S_64
 
-static void kvmppc_trigger_fac_interrupt(struct kvm_vcpu *vcpu, ulong fac)
+void kvmppc_trigger_fac_interrupt(struct kvm_vcpu *vcpu, ulong fac)
 {
        /* Inject the Interrupt Cause field and trigger a guest interrupt */
        vcpu->arch.fscr &= ~(0xffULL << 56);
@@ -864,6 +1008,18 @@ static int kvmppc_handle_fac(struct kvm_vcpu *vcpu, ulong fac)
                break;
        }
 
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       /* Since we disabled MSR_TM at privilege state, the mfspr instruction
+        * for TM spr can trigger TM fac unavailable. In this case, the
+        * emulation is handled by kvmppc_emulate_fac(), which invokes
+        * kvmppc_emulate_mfspr() finally. But note the mfspr can include
+        * RT for NV registers. So it need to restore those NV reg to reflect
+        * the update.
+        */
+       if ((fac == FSCR_TM_LG) && !(kvmppc_get_msr(vcpu) & MSR_PR))
+               return RESUME_GUEST_NV;
+#endif
+
        return RESUME_GUEST;
 }
 
@@ -872,7 +1028,12 @@ void kvmppc_set_fscr(struct kvm_vcpu *vcpu, u64 fscr)
        if ((vcpu->arch.fscr & FSCR_TAR) && !(fscr & FSCR_TAR)) {
                /* TAR got dropped, drop it in shadow too */
                kvmppc_giveup_fac(vcpu, FSCR_TAR_LG);
+       } else if (!(vcpu->arch.fscr & FSCR_TAR) && (fscr & FSCR_TAR)) {
+               vcpu->arch.fscr = fscr;
+               kvmppc_handle_fac(vcpu, FSCR_TAR_LG);
+               return;
        }
+
        vcpu->arch.fscr = fscr;
 }
 #endif
@@ -1017,10 +1178,8 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
                        kvmppc_mmu_pte_flush(vcpu, kvmppc_get_pc(vcpu), ~0xFFFUL);
                        r = RESUME_GUEST;
                } else {
-                       u64 msr = kvmppc_get_msr(vcpu);
-                       msr |= shadow_srr1 & 0x58000000;
-                       kvmppc_set_msr_fast(vcpu, msr);
-                       kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
+                       kvmppc_core_queue_inst_storage(vcpu,
+                                               shadow_srr1 & 0x58000000);
                        r = RESUME_GUEST;
                }
                break;
@@ -1059,9 +1218,7 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
                        r = kvmppc_handle_pagefault(run, vcpu, dar, exit_nr);
                        srcu_read_unlock(&vcpu->kvm->srcu, idx);
                } else {
-                       kvmppc_set_dar(vcpu, dar);
-                       kvmppc_set_dsisr(vcpu, fault_dsisr);
-                       kvmppc_book3s_queue_irqprio(vcpu, exit_nr);
+                       kvmppc_core_queue_data_storage(vcpu, dar, fault_dsisr);
                        r = RESUME_GUEST;
                }
                break;
@@ -1092,10 +1249,13 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
        case BOOK3S_INTERRUPT_EXTERNAL:
        case BOOK3S_INTERRUPT_EXTERNAL_LEVEL:
        case BOOK3S_INTERRUPT_EXTERNAL_HV:
+       case BOOK3S_INTERRUPT_H_VIRT:
                vcpu->stat.ext_intr_exits++;
                r = RESUME_GUEST;
                break;
+       case BOOK3S_INTERRUPT_HMI:
        case BOOK3S_INTERRUPT_PERFMON:
+       case BOOK3S_INTERRUPT_SYSTEM_RESET:
                r = RESUME_GUEST;
                break;
        case BOOK3S_INTERRUPT_PROGRAM:
@@ -1225,8 +1385,7 @@ int kvmppc_handle_exit_pr(struct kvm_run *run, struct kvm_vcpu *vcpu,
        }
 #ifdef CONFIG_PPC_BOOK3S_64
        case BOOK3S_INTERRUPT_FAC_UNAVAIL:
-               kvmppc_handle_fac(vcpu, vcpu->arch.shadow_fscr >> 56);
-               r = RESUME_GUEST;
+               r = kvmppc_handle_fac(vcpu, vcpu->arch.shadow_fscr >> 56);
                break;
 #endif
        case BOOK3S_INTERRUPT_MACHINE_CHECK:
@@ -1379,6 +1538,73 @@ static int kvmppc_get_one_reg_pr(struct kvm_vcpu *vcpu, u64 id,
                else
                        *val = get_reg_val(id, 0);
                break;
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       case KVM_REG_PPC_TFHAR:
+               *val = get_reg_val(id, vcpu->arch.tfhar);
+               break;
+       case KVM_REG_PPC_TFIAR:
+               *val = get_reg_val(id, vcpu->arch.tfiar);
+               break;
+       case KVM_REG_PPC_TEXASR:
+               *val = get_reg_val(id, vcpu->arch.texasr);
+               break;
+       case KVM_REG_PPC_TM_GPR0 ... KVM_REG_PPC_TM_GPR31:
+               *val = get_reg_val(id,
+                               vcpu->arch.gpr_tm[id-KVM_REG_PPC_TM_GPR0]);
+               break;
+       case KVM_REG_PPC_TM_VSR0 ... KVM_REG_PPC_TM_VSR63:
+       {
+               int i, j;
+
+               i = id - KVM_REG_PPC_TM_VSR0;
+               if (i < 32)
+                       for (j = 0; j < TS_FPRWIDTH; j++)
+                               val->vsxval[j] = vcpu->arch.fp_tm.fpr[i][j];
+               else {
+                       if (cpu_has_feature(CPU_FTR_ALTIVEC))
+                               val->vval = vcpu->arch.vr_tm.vr[i-32];
+                       else
+                               r = -ENXIO;
+               }
+               break;
+       }
+       case KVM_REG_PPC_TM_CR:
+               *val = get_reg_val(id, vcpu->arch.cr_tm);
+               break;
+       case KVM_REG_PPC_TM_XER:
+               *val = get_reg_val(id, vcpu->arch.xer_tm);
+               break;
+       case KVM_REG_PPC_TM_LR:
+               *val = get_reg_val(id, vcpu->arch.lr_tm);
+               break;
+       case KVM_REG_PPC_TM_CTR:
+               *val = get_reg_val(id, vcpu->arch.ctr_tm);
+               break;
+       case KVM_REG_PPC_TM_FPSCR:
+               *val = get_reg_val(id, vcpu->arch.fp_tm.fpscr);
+               break;
+       case KVM_REG_PPC_TM_AMR:
+               *val = get_reg_val(id, vcpu->arch.amr_tm);
+               break;
+       case KVM_REG_PPC_TM_PPR:
+               *val = get_reg_val(id, vcpu->arch.ppr_tm);
+               break;
+       case KVM_REG_PPC_TM_VRSAVE:
+               *val = get_reg_val(id, vcpu->arch.vrsave_tm);
+               break;
+       case KVM_REG_PPC_TM_VSCR:
+               if (cpu_has_feature(CPU_FTR_ALTIVEC))
+                       *val = get_reg_val(id, vcpu->arch.vr_tm.vscr.u[3]);
+               else
+                       r = -ENXIO;
+               break;
+       case KVM_REG_PPC_TM_DSCR:
+               *val = get_reg_val(id, vcpu->arch.dscr_tm);
+               break;
+       case KVM_REG_PPC_TM_TAR:
+               *val = get_reg_val(id, vcpu->arch.tar_tm);
+               break;
+#endif
        default:
                r = -EINVAL;
                break;
@@ -1412,6 +1638,72 @@ static int kvmppc_set_one_reg_pr(struct kvm_vcpu *vcpu, u64 id,
        case KVM_REG_PPC_LPCR_64:
                kvmppc_set_lpcr_pr(vcpu, set_reg_val(id, *val));
                break;
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       case KVM_REG_PPC_TFHAR:
+               vcpu->arch.tfhar = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TFIAR:
+               vcpu->arch.tfiar = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TEXASR:
+               vcpu->arch.texasr = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_GPR0 ... KVM_REG_PPC_TM_GPR31:
+               vcpu->arch.gpr_tm[id - KVM_REG_PPC_TM_GPR0] =
+                       set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_VSR0 ... KVM_REG_PPC_TM_VSR63:
+       {
+               int i, j;
+
+               i = id - KVM_REG_PPC_TM_VSR0;
+               if (i < 32)
+                       for (j = 0; j < TS_FPRWIDTH; j++)
+                               vcpu->arch.fp_tm.fpr[i][j] = val->vsxval[j];
+               else
+                       if (cpu_has_feature(CPU_FTR_ALTIVEC))
+                               vcpu->arch.vr_tm.vr[i-32] = val->vval;
+                       else
+                               r = -ENXIO;
+               break;
+       }
+       case KVM_REG_PPC_TM_CR:
+               vcpu->arch.cr_tm = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_XER:
+               vcpu->arch.xer_tm = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_LR:
+               vcpu->arch.lr_tm = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_CTR:
+               vcpu->arch.ctr_tm = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_FPSCR:
+               vcpu->arch.fp_tm.fpscr = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_AMR:
+               vcpu->arch.amr_tm = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_PPR:
+               vcpu->arch.ppr_tm = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_VRSAVE:
+               vcpu->arch.vrsave_tm = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_VSCR:
+               if (cpu_has_feature(CPU_FTR_ALTIVEC))
+                       vcpu->arch.vr.vscr.u[3] = set_reg_val(id, *val);
+               else
+                       r = -ENXIO;
+               break;
+       case KVM_REG_PPC_TM_DSCR:
+               vcpu->arch.dscr_tm = set_reg_val(id, *val);
+               break;
+       case KVM_REG_PPC_TM_TAR:
+               vcpu->arch.tar_tm = set_reg_val(id, *val);
+               break;
+#endif
        default:
                r = -EINVAL;
                break;
@@ -1687,6 +1979,17 @@ static int kvm_vm_ioctl_get_smmu_info_pr(struct kvm *kvm,
 
        return 0;
 }
+
+static int kvm_configure_mmu_pr(struct kvm *kvm, struct kvm_ppc_mmuv3_cfg *cfg)
+{
+       if (!cpu_has_feature(CPU_FTR_ARCH_300))
+               return -ENODEV;
+       /* Require flags and process table base and size to all be zero. */
+       if (cfg->flags || cfg->process_table)
+               return -EINVAL;
+       return 0;
+}
+
 #else
 static int kvm_vm_ioctl_get_smmu_info_pr(struct kvm *kvm,
                                         struct kvm_ppc_smmu_info *info)
@@ -1735,9 +2038,12 @@ static void kvmppc_core_destroy_vm_pr(struct kvm *kvm)
 static int kvmppc_core_check_processor_compat_pr(void)
 {
        /*
-        * Disable KVM for Power9 untill the required bits merged.
+        * PR KVM can work on POWER9 inside a guest partition
+        * running in HPT mode.  It can't work if we are using
+        * radix translation (because radix provides no way for
+        * a process to have unique translations in quadrant 3).
         */
-       if (cpu_has_feature(CPU_FTR_ARCH_300))
+       if (cpu_has_feature(CPU_FTR_ARCH_300) && radix_enabled())
                return -EIO;
        return 0;
 }
@@ -1781,7 +2087,9 @@ static struct kvmppc_ops kvm_ops_pr = {
        .arch_vm_ioctl  = kvm_arch_vm_ioctl_pr,
 #ifdef CONFIG_PPC_BOOK3S_64
        .hcall_implemented = kvmppc_hcall_impl_pr,
+       .configure_mmu = kvm_configure_mmu_pr,
 #endif
+       .giveup_ext = kvmppc_giveup_ext,
 };
 
 
index 93a180ceefad03343d1f9064420ee00ca54973d7..98ccc7ec5d488c18c99f452d32ca22770ebf6b8d 100644 (file)
@@ -383,6 +383,19 @@ END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S)
         */
 
        PPC_LL  r6, HSTATE_HOST_MSR(r13)
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+       /*
+        * We don't want to change MSR[TS] bits via rfi here.
+        * The actual TM handling logic will be in host with
+        * recovered DR/IR bits after HSTATE_VMHANDLER.
+        * And MSR_TM can be enabled in HOST_MSR so rfid may
+        * not suppress this change and can lead to exception.
+        * Manually set MSR to prevent TS state change here.
+        */
+       mfmsr   r7
+       rldicl  r7, r7, 64 - MSR_TS_S_LG, 62
+       rldimi  r6, r7, MSR_TS_S_LG, 63 - MSR_TS_T_LG
+#endif
        PPC_LL  r8, HSTATE_VMHANDLER(r13)
 
 #ifdef CONFIG_PPC64
index 99c3620b40d95b91481a5485ab6e2649ea40c37c..6e41ba7ec8f45b8c7861f038820e18b5d9cbb507 100644 (file)
@@ -334,7 +334,7 @@ X_STATIC unsigned long GLUE(X_PFX,h_xirr)(struct kvm_vcpu *vcpu)
         */
 
        /* Return interrupt and old CPPR in GPR4 */
-       vcpu->arch.gpr[4] = hirq | (old_cppr << 24);
+       vcpu->arch.regs.gpr[4] = hirq | (old_cppr << 24);
 
        return H_SUCCESS;
 }
@@ -369,7 +369,7 @@ X_STATIC unsigned long GLUE(X_PFX,h_ipoll)(struct kvm_vcpu *vcpu, unsigned long
        hirq = GLUE(X_PFX,scan_interrupts)(xc, pending, scan_poll);
 
        /* Return interrupt and old CPPR in GPR4 */
-       vcpu->arch.gpr[4] = hirq | (xc->cppr << 24);
+       vcpu->arch.regs.gpr[4] = hirq | (xc->cppr << 24);
 
        return H_SUCCESS;
 }
index 876d4f294fdd89fc160439073a3c04c9c8e81174..a9ca016da67021691de512d0a8a2f9f0039d56e5 100644 (file)
@@ -77,8 +77,10 @@ void kvmppc_dump_vcpu(struct kvm_vcpu *vcpu)
 {
        int i;
 
-       printk("pc:   %08lx msr:  %08llx\n", vcpu->arch.pc, vcpu->arch.shared->msr);
-       printk("lr:   %08lx ctr:  %08lx\n", vcpu->arch.lr, vcpu->arch.ctr);
+       printk("pc:   %08lx msr:  %08llx\n", vcpu->arch.regs.nip,
+                       vcpu->arch.shared->msr);
+       printk("lr:   %08lx ctr:  %08lx\n", vcpu->arch.regs.link,
+                       vcpu->arch.regs.ctr);
        printk("srr0: %08llx srr1: %08llx\n", vcpu->arch.shared->srr0,
                                            vcpu->arch.shared->srr1);
 
@@ -491,24 +493,25 @@ static int kvmppc_booke_irqprio_deliver(struct kvm_vcpu *vcpu,
        if (allowed) {
                switch (int_class) {
                case INT_CLASS_NONCRIT:
-                       set_guest_srr(vcpu, vcpu->arch.pc,
+                       set_guest_srr(vcpu, vcpu->arch.regs.nip,
                                      vcpu->arch.shared->msr);
                        break;
                case INT_CLASS_CRIT:
-                       set_guest_csrr(vcpu, vcpu->arch.pc,
+                       set_guest_csrr(vcpu, vcpu->arch.regs.nip,
                                       vcpu->arch.shared->msr);
                        break;
                case INT_CLASS_DBG:
-                       set_guest_dsrr(vcpu, vcpu->arch.pc,
+                       set_guest_dsrr(vcpu, vcpu->arch.regs.nip,
                                       vcpu->arch.shared->msr);
                        break;
                case INT_CLASS_MC:
-                       set_guest_mcsrr(vcpu, vcpu->arch.pc,
+                       set_guest_mcsrr(vcpu, vcpu->arch.regs.nip,
                                        vcpu->arch.shared->msr);
                        break;
                }
 
-               vcpu->arch.pc = vcpu->arch.ivpr | vcpu->arch.ivor[priority];
+               vcpu->arch.regs.nip = vcpu->arch.ivpr |
+                                       vcpu->arch.ivor[priority];
                if (update_esr == true)
                        kvmppc_set_esr(vcpu, vcpu->arch.queued_esr);
                if (update_dear == true)
@@ -826,7 +829,7 @@ static int emulation_exit(struct kvm_run *run, struct kvm_vcpu *vcpu)
 
        case EMULATE_FAIL:
                printk(KERN_CRIT "%s: emulation at %lx failed (%08x)\n",
-                      __func__, vcpu->arch.pc, vcpu->arch.last_inst);
+                      __func__, vcpu->arch.regs.nip, vcpu->arch.last_inst);
                /* For debugging, encode the failing instruction and
                 * report it to userspace. */
                run->hw.hardware_exit_reason = ~0ULL << 32;
@@ -875,7 +878,7 @@ static int kvmppc_handle_debug(struct kvm_run *run, struct kvm_vcpu *vcpu)
         */
        vcpu->arch.dbsr = 0;
        run->debug.arch.status = 0;
-       run->debug.arch.address = vcpu->arch.pc;
+       run->debug.arch.address = vcpu->arch.regs.nip;
 
        if (dbsr & (DBSR_IAC1 | DBSR_IAC2 | DBSR_IAC3 | DBSR_IAC4)) {
                run->debug.arch.status |= KVMPPC_DEBUG_BREAKPOINT;
@@ -971,7 +974,7 @@ static int kvmppc_resume_inst_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
 
        case EMULATE_FAIL:
                pr_debug("%s: load instruction from guest address %lx failed\n",
-                      __func__, vcpu->arch.pc);
+                      __func__, vcpu->arch.regs.nip);
                /* For debugging, encode the failing instruction and
                 * report it to userspace. */
                run->hw.hardware_exit_reason = ~0ULL << 32;
@@ -1169,7 +1172,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
        case BOOKE_INTERRUPT_SPE_FP_DATA:
        case BOOKE_INTERRUPT_SPE_FP_ROUND:
                printk(KERN_CRIT "%s: unexpected SPE interrupt %u at %08lx\n",
-                      __func__, exit_nr, vcpu->arch.pc);
+                      __func__, exit_nr, vcpu->arch.regs.nip);
                run->hw.hardware_exit_reason = exit_nr;
                r = RESUME_HOST;
                break;
@@ -1299,7 +1302,7 @@ int kvmppc_handle_exit(struct kvm_run *run, struct kvm_vcpu *vcpu,
        }
 
        case BOOKE_INTERRUPT_ITLB_MISS: {
-               unsigned long eaddr = vcpu->arch.pc;
+               unsigned long eaddr = vcpu->arch.regs.nip;
                gpa_t gpaddr;
                gfn_t gfn;
                int gtlb_index;
@@ -1391,7 +1394,7 @@ int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu)
        int i;
        int r;
 
-       vcpu->arch.pc = 0;
+       vcpu->arch.regs.nip = 0;
        vcpu->arch.shared->pir = vcpu->vcpu_id;
        kvmppc_set_gpr(vcpu, 1, (16<<20) - 8); /* -8 for the callee-save LR slot */
        kvmppc_set_msr(vcpu, 0);
@@ -1440,10 +1443,10 @@ int kvm_arch_vcpu_ioctl_get_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 
        vcpu_load(vcpu);
 
-       regs->pc = vcpu->arch.pc;
+       regs->pc = vcpu->arch.regs.nip;
        regs->cr = kvmppc_get_cr(vcpu);
-       regs->ctr = vcpu->arch.ctr;
-       regs->lr = vcpu->arch.lr;
+       regs->ctr = vcpu->arch.regs.ctr;
+       regs->lr = vcpu->arch.regs.link;
        regs->xer = kvmppc_get_xer(vcpu);
        regs->msr = vcpu->arch.shared->msr;
        regs->srr0 = kvmppc_get_srr0(vcpu);
@@ -1471,10 +1474,10 @@ int kvm_arch_vcpu_ioctl_set_regs(struct kvm_vcpu *vcpu, struct kvm_regs *regs)
 
        vcpu_load(vcpu);
 
-       vcpu->arch.pc = regs->pc;
+       vcpu->arch.regs.nip = regs->pc;
        kvmppc_set_cr(vcpu, regs->cr);
-       vcpu->arch.ctr = regs->ctr;
-       vcpu->arch.lr = regs->lr;
+       vcpu->arch.regs.ctr = regs->ctr;
+       vcpu->arch.regs.link = regs->lr;
        kvmppc_set_xer(vcpu, regs->xer);
        kvmppc_set_msr(vcpu, regs->msr);
        kvmppc_set_srr0(vcpu, regs->srr0);
index a82f64502de124c6df3a899cac632548353048d5..d23e582f0feec3328635234bfdd62ef5f260f92c 100644 (file)
 
 static void kvmppc_emul_rfi(struct kvm_vcpu *vcpu)
 {
-       vcpu->arch.pc = vcpu->arch.shared->srr0;
+       vcpu->arch.regs.nip = vcpu->arch.shared->srr0;
        kvmppc_set_msr(vcpu, vcpu->arch.shared->srr1);
 }
 
 static void kvmppc_emul_rfdi(struct kvm_vcpu *vcpu)
 {
-       vcpu->arch.pc = vcpu->arch.dsrr0;
+       vcpu->arch.regs.nip = vcpu->arch.dsrr0;
        kvmppc_set_msr(vcpu, vcpu->arch.dsrr1);
 }
 
 static void kvmppc_emul_rfci(struct kvm_vcpu *vcpu)
 {
-       vcpu->arch.pc = vcpu->arch.csrr0;
+       vcpu->arch.regs.nip = vcpu->arch.csrr0;
        kvmppc_set_msr(vcpu, vcpu->arch.csrr1);
 }
 
index 990db69a1d0b0f9a76d31ae1323fb6e23cb39a82..3f8189eb56ed038f2be56f478f8c6e6925c11f27 100644 (file)
@@ -53,7 +53,7 @@ static int dbell2prio(ulong param)
 
 static int kvmppc_e500_emul_msgclr(struct kvm_vcpu *vcpu, int rb)
 {
-       ulong param = vcpu->arch.gpr[rb];
+       ulong param = vcpu->arch.regs.gpr[rb];
        int prio = dbell2prio(param);
 
        if (prio < 0)
@@ -65,7 +65,7 @@ static int kvmppc_e500_emul_msgclr(struct kvm_vcpu *vcpu, int rb)
 
 static int kvmppc_e500_emul_msgsnd(struct kvm_vcpu *vcpu, int rb)
 {
-       ulong param = vcpu->arch.gpr[rb];
+       ulong param = vcpu->arch.regs.gpr[rb];
        int prio = dbell2prio(rb);
        int pir = param & PPC_DBELL_PIR_MASK;
        int i;
@@ -94,7 +94,7 @@ static int kvmppc_e500_emul_ehpriv(struct kvm_run *run, struct kvm_vcpu *vcpu,
        switch (get_oc(inst)) {
        case EHPRIV_OC_DEBUG:
                run->exit_reason = KVM_EXIT_DEBUG;
-               run->debug.arch.address = vcpu->arch.pc;
+               run->debug.arch.address = vcpu->arch.regs.nip;
                run->debug.arch.status = 0;
                kvmppc_account_exit(vcpu, DEBUG_EXITS);
                emulated = EMULATE_EXIT_USER;
index ddbf8f0284c0e1f8590c05151aa1f5c978ea325e..24296f4cadc6c43c529c9d7e9eb81823c8ff963d 100644 (file)
@@ -513,7 +513,7 @@ void kvmppc_mmu_itlb_miss(struct kvm_vcpu *vcpu)
 {
        unsigned int as = !!(vcpu->arch.shared->msr & MSR_IS);
 
-       kvmppc_e500_deliver_tlb_miss(vcpu, vcpu->arch.pc, as);
+       kvmppc_e500_deliver_tlb_miss(vcpu, vcpu->arch.regs.nip, as);
 }
 
 void kvmppc_mmu_dtlb_miss(struct kvm_vcpu *vcpu)
index c878b4ffb86fe6c284aa3f6b4cb8f8de630eb72a..8f2985e46f6f193d975e2d26ca92c2df60742649 100644 (file)
@@ -625,8 +625,8 @@ void kvmppc_mmu_map(struct kvm_vcpu *vcpu, u64 eaddr, gpa_t gpaddr,
 }
 
 #ifdef CONFIG_KVM_BOOKE_HV
-int kvmppc_load_last_inst(struct kvm_vcpu *vcpu, enum instruction_type type,
-                         u32 *instr)
+int kvmppc_load_last_inst(struct kvm_vcpu *vcpu,
+               enum instruction_fetch_type type, u32 *instr)
 {
        gva_t geaddr;
        hpa_t addr;
@@ -715,8 +715,8 @@ int kvmppc_load_last_inst(struct kvm_vcpu *vcpu, enum instruction_type type,
        return EMULATE_DONE;
 }
 #else
-int kvmppc_load_last_inst(struct kvm_vcpu *vcpu, enum instruction_type type,
-                         u32 *instr)
+int kvmppc_load_last_inst(struct kvm_vcpu *vcpu,
+               enum instruction_fetch_type type, u32 *instr)
 {
        return EMULATE_AGAIN;
 }
index a382e15135e6d3e2358d19745d02b1385ed56312..afde788be14148bf1386b4442e103789dcb181ad 100644 (file)
@@ -31,6 +31,7 @@
 #include <asm/kvm_ppc.h>
 #include <asm/disassemble.h>
 #include <asm/ppc-opcode.h>
+#include <asm/sstep.h>
 #include "timing.h"
 #include "trace.h"
 
@@ -84,8 +85,9 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
        struct kvm_run *run = vcpu->run;
        u32 inst;
        int ra, rs, rt;
-       enum emulation_result emulated;
+       enum emulation_result emulated = EMULATE_FAIL;
        int advance = 1;
+       struct instruction_op op;
 
        /* this default type might be overwritten by subcategories */
        kvmppc_set_exit_type(vcpu, EMULATED_INST_EXITS);
@@ -107,580 +109,276 @@ int kvmppc_emulate_loadstore(struct kvm_vcpu *vcpu)
        vcpu->arch.mmio_vsx_tx_sx_enabled = get_tx_or_sx(inst);
        vcpu->arch.mmio_vsx_copy_nums = 0;
        vcpu->arch.mmio_vsx_offset = 0;
-       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_NONE;
+       vcpu->arch.mmio_copy_type = KVMPPC_VSX_COPY_NONE;
        vcpu->arch.mmio_sp64_extend = 0;
        vcpu->arch.mmio_sign_extend = 0;
        vcpu->arch.mmio_vmx_copy_nums = 0;
+       vcpu->arch.mmio_vmx_offset = 0;
+       vcpu->arch.mmio_host_swabbed = 0;
 
-       switch (get_op(inst)) {
-       case 31:
-               switch (get_xop(inst)) {
-               case OP_31_XOP_LWZX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1);
-                       break;
-
-               case OP_31_XOP_LWZUX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
+       emulated = EMULATE_FAIL;
+       vcpu->arch.regs.msr = vcpu->arch.shared->msr;
+       vcpu->arch.regs.ccr = vcpu->arch.cr;
+       if (analyse_instr(&op, &vcpu->arch.regs, inst) == 0) {
+               int type = op.type & INSTR_TYPE_MASK;
+               int size = GETSIZE(op.type);
 
-               case OP_31_XOP_LBZX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 1, 1);
-                       break;
-
-               case OP_31_XOP_LBZUX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 1, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
+               switch (type) {
+               case LOAD:  {
+                       int instr_byte_swap = op.type & BYTEREV;
 
-               case OP_31_XOP_STDX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 8, 1);
-                       break;
+                       if (op.type & SIGNEXT)
+                               emulated = kvmppc_handle_loads(run, vcpu,
+                                               op.reg, size, !instr_byte_swap);
+                       else
+                               emulated = kvmppc_handle_load(run, vcpu,
+                                               op.reg, size, !instr_byte_swap);
 
-               case OP_31_XOP_STDUX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 8, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
+                       if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
+                               kvmppc_set_gpr(vcpu, op.update_reg, op.ea);
 
-               case OP_31_XOP_STWX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 4, 1);
-                       break;
-
-               case OP_31_XOP_STWUX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 4, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-
-               case OP_31_XOP_STBX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 1, 1);
-                       break;
-
-               case OP_31_XOP_STBUX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 1, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-
-               case OP_31_XOP_LHAX:
-                       emulated = kvmppc_handle_loads(run, vcpu, rt, 2, 1);
-                       break;
-
-               case OP_31_XOP_LHAUX:
-                       emulated = kvmppc_handle_loads(run, vcpu, rt, 2, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-
-               case OP_31_XOP_LHZX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 2, 1);
-                       break;
-
-               case OP_31_XOP_LHZUX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 2, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-
-               case OP_31_XOP_STHX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 2, 1);
-                       break;
-
-               case OP_31_XOP_STHUX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 2, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-
-               case OP_31_XOP_DCBST:
-               case OP_31_XOP_DCBF:
-               case OP_31_XOP_DCBI:
-                       /* Do nothing. The guest is performing dcbi because
-                        * hardware DMA is not snooped by the dcache, but
-                        * emulated DMA either goes through the dcache as
-                        * normal writes, or the host kernel has handled dcache
-                        * coherence. */
-                       break;
-
-               case OP_31_XOP_LWBRX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 4, 0);
-                       break;
-
-               case OP_31_XOP_STWBRX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 4, 0);
                        break;
-
-               case OP_31_XOP_LHBRX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 2, 0);
-                       break;
-
-               case OP_31_XOP_STHBRX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 2, 0);
-                       break;
-
-               case OP_31_XOP_LDBRX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 8, 0);
-                       break;
-
-               case OP_31_XOP_STDBRX:
-                       emulated = kvmppc_handle_store(run, vcpu,
-                                       kvmppc_get_gpr(vcpu, rs), 8, 0);
-                       break;
-
-               case OP_31_XOP_LDX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 8, 1);
-                       break;
-
-               case OP_31_XOP_LDUX:
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 8, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-
-               case OP_31_XOP_LWAX:
-                       emulated = kvmppc_handle_loads(run, vcpu, rt, 4, 1);
-                       break;
-
-               case OP_31_XOP_LWAUX:
-                       emulated = kvmppc_handle_loads(run, vcpu, rt, 4, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-
+               }
 #ifdef CONFIG_PPC_FPU
-               case OP_31_XOP_LFSX:
-                       if (kvmppc_check_fp_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_sp64_extend = 1;
-                       emulated = kvmppc_handle_load(run, vcpu,
-                               KVM_MMIO_REG_FPR|rt, 4, 1);
-                       break;
-
-               case OP_31_XOP_LFSUX:
+               case LOAD_FP:
                        if (kvmppc_check_fp_disabled(vcpu))
                                return EMULATE_DONE;
-                       vcpu->arch.mmio_sp64_extend = 1;
-                       emulated = kvmppc_handle_load(run, vcpu,
-                               KVM_MMIO_REG_FPR|rt, 4, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
 
-               case OP_31_XOP_LFDX:
-                       if (kvmppc_check_fp_disabled(vcpu))
-                               return EMULATE_DONE;
-                       emulated = kvmppc_handle_load(run, vcpu,
-                               KVM_MMIO_REG_FPR|rt, 8, 1);
-                       break;
+                       if (op.type & FPCONV)
+                               vcpu->arch.mmio_sp64_extend = 1;
 
-               case OP_31_XOP_LFDUX:
-                       if (kvmppc_check_fp_disabled(vcpu))
-                               return EMULATE_DONE;
-                       emulated = kvmppc_handle_load(run, vcpu,
-                               KVM_MMIO_REG_FPR|rt, 8, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-
-               case OP_31_XOP_LFIWAX:
-                       if (kvmppc_check_fp_disabled(vcpu))
-                               return EMULATE_DONE;
-                       emulated = kvmppc_handle_loads(run, vcpu,
-                               KVM_MMIO_REG_FPR|rt, 4, 1);
-                       break;
+                       if (op.type & SIGNEXT)
+                               emulated = kvmppc_handle_loads(run, vcpu,
+                                            KVM_MMIO_REG_FPR|op.reg, size, 1);
+                       else
+                               emulated = kvmppc_handle_load(run, vcpu,
+                                            KVM_MMIO_REG_FPR|op.reg, size, 1);
 
-               case OP_31_XOP_LFIWZX:
-                       if (kvmppc_check_fp_disabled(vcpu))
-                               return EMULATE_DONE;
-                       emulated = kvmppc_handle_load(run, vcpu,
-                               KVM_MMIO_REG_FPR|rt, 4, 1);
-                       break;
+                       if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
+                               kvmppc_set_gpr(vcpu, op.update_reg, op.ea);
 
-               case OP_31_XOP_STFSX:
-                       if (kvmppc_check_fp_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_sp64_extend = 1;
-                       emulated = kvmppc_handle_store(run, vcpu,
-                               VCPU_FPR(vcpu, rs), 4, 1);
                        break;
-
-               case OP_31_XOP_STFSUX:
-                       if (kvmppc_check_fp_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_sp64_extend = 1;
-                       emulated = kvmppc_handle_store(run, vcpu,
-                               VCPU_FPR(vcpu, rs), 4, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-
-               case OP_31_XOP_STFDX:
-                       if (kvmppc_check_fp_disabled(vcpu))
-                               return EMULATE_DONE;
-                       emulated = kvmppc_handle_store(run, vcpu,
-                               VCPU_FPR(vcpu, rs), 8, 1);
-                       break;
-
-               case OP_31_XOP_STFDUX:
-                       if (kvmppc_check_fp_disabled(vcpu))
+#endif
+#ifdef CONFIG_ALTIVEC
+               case LOAD_VMX:
+                       if (kvmppc_check_altivec_disabled(vcpu))
                                return EMULATE_DONE;
-                       emulated = kvmppc_handle_store(run, vcpu,
-                               VCPU_FPR(vcpu, rs), 8, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
 
-               case OP_31_XOP_STFIWX:
-                       if (kvmppc_check_fp_disabled(vcpu))
-                               return EMULATE_DONE;
-                       emulated = kvmppc_handle_store(run, vcpu,
-                               VCPU_FPR(vcpu, rs), 4, 1);
+                       /* Hardware enforces alignment of VMX accesses */
+                       vcpu->arch.vaddr_accessed &= ~((unsigned long)size - 1);
+                       vcpu->arch.paddr_accessed &= ~((unsigned long)size - 1);
+
+                       if (size == 16) { /* lvx */
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VMX_COPY_DWORD;
+                       } else if (size == 4) { /* lvewx  */
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VMX_COPY_WORD;
+                       } else if (size == 2) { /* lvehx  */
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VMX_COPY_HWORD;
+                       } else if (size == 1) { /* lvebx  */
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VMX_COPY_BYTE;
+                       } else
+                               break;
+
+                       vcpu->arch.mmio_vmx_offset =
+                               (vcpu->arch.vaddr_accessed & 0xf)/size;
+
+                       if (size == 16) {
+                               vcpu->arch.mmio_vmx_copy_nums = 2;
+                               emulated = kvmppc_handle_vmx_load(run,
+                                               vcpu, KVM_MMIO_REG_VMX|op.reg,
+                                               8, 1);
+                       } else {
+                               vcpu->arch.mmio_vmx_copy_nums = 1;
+                               emulated = kvmppc_handle_vmx_load(run, vcpu,
+                                               KVM_MMIO_REG_VMX|op.reg,
+                                               size, 1);
+                       }
                        break;
 #endif
-
 #ifdef CONFIG_VSX
-               case OP_31_XOP_LXSDX:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 1;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_DWORD;
-                       emulated = kvmppc_handle_vsx_load(run, vcpu,
-                               KVM_MMIO_REG_VSX|rt, 8, 1, 0);
-                       break;
-
-               case OP_31_XOP_LXSSPX:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 1;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_DWORD;
-                       vcpu->arch.mmio_sp64_extend = 1;
-                       emulated = kvmppc_handle_vsx_load(run, vcpu,
-                               KVM_MMIO_REG_VSX|rt, 4, 1, 0);
-                       break;
+               case LOAD_VSX: {
+                       int io_size_each;
+
+                       if (op.vsx_flags & VSX_CHECK_VEC) {
+                               if (kvmppc_check_altivec_disabled(vcpu))
+                                       return EMULATE_DONE;
+                       } else {
+                               if (kvmppc_check_vsx_disabled(vcpu))
+                                       return EMULATE_DONE;
+                       }
+
+                       if (op.vsx_flags & VSX_FPCONV)
+                               vcpu->arch.mmio_sp64_extend = 1;
+
+                       if (op.element_size == 8)  {
+                               if (op.vsx_flags & VSX_SPLAT)
+                                       vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VSX_COPY_DWORD_LOAD_DUMP;
+                               else
+                                       vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VSX_COPY_DWORD;
+                       } else if (op.element_size == 4) {
+                               if (op.vsx_flags & VSX_SPLAT)
+                                       vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VSX_COPY_WORD_LOAD_DUMP;
+                               else
+                                       vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VSX_COPY_WORD;
+                       } else
+                               break;
+
+                       if (size < op.element_size) {
+                               /* precision convert case: lxsspx, etc */
+                               vcpu->arch.mmio_vsx_copy_nums = 1;
+                               io_size_each = size;
+                       } else { /* lxvw4x, lxvd2x, etc */
+                               vcpu->arch.mmio_vsx_copy_nums =
+                                       size/op.element_size;
+                               io_size_each = op.element_size;
+                       }
 
-               case OP_31_XOP_LXSIWAX:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 1;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_DWORD;
                        emulated = kvmppc_handle_vsx_load(run, vcpu,
-                               KVM_MMIO_REG_VSX|rt, 4, 1, 1);
-                       break;
-
-               case OP_31_XOP_LXSIWZX:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 1;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_DWORD;
-                       emulated = kvmppc_handle_vsx_load(run, vcpu,
-                               KVM_MMIO_REG_VSX|rt, 4, 1, 0);
+                                       KVM_MMIO_REG_VSX | (op.reg & 0x1f),
+                                       io_size_each, 1, op.type & SIGNEXT);
                        break;
+               }
+#endif
+               case STORE:
+                       /* if need byte reverse, op.val has been reversed by
+                        * analyse_instr().
+                        */
+                       emulated = kvmppc_handle_store(run, vcpu, op.val,
+                                       size, 1);
 
-               case OP_31_XOP_LXVD2X:
-               /*
-                * In this case, the official load/store process is like this:
-                * Step1, exit from vm by page fault isr, then kvm save vsr.
-                * Please see guest_exit_cont->store_fp_state->SAVE_32VSRS
-                * as reference.
-                *
-                * Step2, copy data between memory and VCPU
-                * Notice: for LXVD2X/STXVD2X/LXVW4X/STXVW4X, we use
-                * 2copies*8bytes or 4copies*4bytes
-                * to simulate one copy of 16bytes.
-                * Also there is an endian issue here, we should notice the
-                * layout of memory.
-                * Please see MARCO of LXVD2X_ROT/STXVD2X_ROT as more reference.
-                * If host is little-endian, kvm will call XXSWAPD for
-                * LXVD2X_ROT/STXVD2X_ROT.
-                * So, if host is little-endian,
-                * the postion of memeory should be swapped.
-                *
-                * Step3, return to guest, kvm reset register.
-                * Please see kvmppc_hv_entry->load_fp_state->REST_32VSRS
-                * as reference.
-                */
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 2;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_DWORD;
-                       emulated = kvmppc_handle_vsx_load(run, vcpu,
-                               KVM_MMIO_REG_VSX|rt, 8, 1, 0);
-                       break;
+                       if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
+                               kvmppc_set_gpr(vcpu, op.update_reg, op.ea);
 
-               case OP_31_XOP_LXVW4X:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 4;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_WORD;
-                       emulated = kvmppc_handle_vsx_load(run, vcpu,
-                               KVM_MMIO_REG_VSX|rt, 4, 1, 0);
                        break;
-
-               case OP_31_XOP_LXVDSX:
-                       if (kvmppc_check_vsx_disabled(vcpu))
+#ifdef CONFIG_PPC_FPU
+               case STORE_FP:
+                       if (kvmppc_check_fp_disabled(vcpu))
                                return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 1;
-                       vcpu->arch.mmio_vsx_copy_type =
-                                KVMPPC_VSX_COPY_DWORD_LOAD_DUMP;
-                       emulated = kvmppc_handle_vsx_load(run, vcpu,
-                               KVM_MMIO_REG_VSX|rt, 8, 1, 0);
-                       break;
 
-               case OP_31_XOP_STXSDX:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 1;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_DWORD;
-                       emulated = kvmppc_handle_vsx_store(run, vcpu,
-                                                rs, 8, 1);
-                       break;
+                       /* The FP registers need to be flushed so that
+                        * kvmppc_handle_store() can read actual FP vals
+                        * from vcpu->arch.
+                        */
+                       if (vcpu->kvm->arch.kvm_ops->giveup_ext)
+                               vcpu->kvm->arch.kvm_ops->giveup_ext(vcpu,
+                                               MSR_FP);
 
-               case OP_31_XOP_STXSSPX:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 1;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_DWORD;
-                       vcpu->arch.mmio_sp64_extend = 1;
-                       emulated = kvmppc_handle_vsx_store(run, vcpu,
-                                                rs, 4, 1);
-                       break;
+                       if (op.type & FPCONV)
+                               vcpu->arch.mmio_sp64_extend = 1;
 
-               case OP_31_XOP_STXSIWX:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_offset = 1;
-                       vcpu->arch.mmio_vsx_copy_nums = 1;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_WORD;
-                       emulated = kvmppc_handle_vsx_store(run, vcpu,
-                                                        rs, 4, 1);
-                       break;
+                       emulated = kvmppc_handle_store(run, vcpu,
+                                       VCPU_FPR(vcpu, op.reg), size, 1);
 
-               case OP_31_XOP_STXVD2X:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 2;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_DWORD;
-                       emulated = kvmppc_handle_vsx_store(run, vcpu,
-                                                        rs, 8, 1);
-                       break;
+                       if ((op.type & UPDATE) && (emulated != EMULATE_FAIL))
+                               kvmppc_set_gpr(vcpu, op.update_reg, op.ea);
 
-               case OP_31_XOP_STXVW4X:
-                       if (kvmppc_check_vsx_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.mmio_vsx_copy_nums = 4;
-                       vcpu->arch.mmio_vsx_copy_type = KVMPPC_VSX_COPY_WORD;
-                       emulated = kvmppc_handle_vsx_store(run, vcpu,
-                                                        rs, 4, 1);
                        break;
-#endif /* CONFIG_VSX */
-
+#endif
 #ifdef CONFIG_ALTIVEC
-               case OP_31_XOP_LVX:
+               case STORE_VMX:
                        if (kvmppc_check_altivec_disabled(vcpu))
                                return EMULATE_DONE;
-                       vcpu->arch.vaddr_accessed &= ~0xFULL;
-                       vcpu->arch.paddr_accessed &= ~0xFULL;
-                       vcpu->arch.mmio_vmx_copy_nums = 2;
-                       emulated = kvmppc_handle_load128_by2x64(run, vcpu,
-                                       KVM_MMIO_REG_VMX|rt, 1);
-                       break;
 
-               case OP_31_XOP_STVX:
-                       if (kvmppc_check_altivec_disabled(vcpu))
-                               return EMULATE_DONE;
-                       vcpu->arch.vaddr_accessed &= ~0xFULL;
-                       vcpu->arch.paddr_accessed &= ~0xFULL;
-                       vcpu->arch.mmio_vmx_copy_nums = 2;
-                       emulated = kvmppc_handle_store128_by2x64(run, vcpu,
-                                       rs, 1);
-                       break;
-#endif /* CONFIG_ALTIVEC */
+                       /* Hardware enforces alignment of VMX accesses. */
+                       vcpu->arch.vaddr_accessed &= ~((unsigned long)size - 1);
+                       vcpu->arch.paddr_accessed &= ~((unsigned long)size - 1);
+
+                       if (vcpu->kvm->arch.kvm_ops->giveup_ext)
+                               vcpu->kvm->arch.kvm_ops->giveup_ext(vcpu,
+                                               MSR_VEC);
+                       if (size == 16) { /* stvx */
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VMX_COPY_DWORD;
+                       } else if (size == 4) { /* stvewx  */
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VMX_COPY_WORD;
+                       } else if (size == 2) { /* stvehx  */
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VMX_COPY_HWORD;
+                       } else if (size == 1) { /* stvebx  */
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VMX_COPY_BYTE;
+                       } else
+                               break;
+
+                       vcpu->arch.mmio_vmx_offset =
+                               (vcpu->arch.vaddr_accessed & 0xf)/size;
+
+                       if (size == 16) {
+                               vcpu->arch.mmio_vmx_copy_nums = 2;
+                               emulated = kvmppc_handle_vmx_store(run,
+                                               vcpu, op.reg, 8, 1);
+                       } else {
+                               vcpu->arch.mmio_vmx_copy_nums = 1;
+                               emulated = kvmppc_handle_vmx_store(run,
+                                               vcpu, op.reg, size, 1);
+                       }
 
-               default:
-                       emulated = EMULATE_FAIL;
                        break;
-               }
-               break;
-
-       case OP_LWZ:
-               emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1);
-               break;
-
-#ifdef CONFIG_PPC_FPU
-       case OP_STFS:
-               if (kvmppc_check_fp_disabled(vcpu))
-                       return EMULATE_DONE;
-               vcpu->arch.mmio_sp64_extend = 1;
-               emulated = kvmppc_handle_store(run, vcpu,
-                       VCPU_FPR(vcpu, rs),
-                       4, 1);
-               break;
-
-       case OP_STFSU:
-               if (kvmppc_check_fp_disabled(vcpu))
-                       return EMULATE_DONE;
-               vcpu->arch.mmio_sp64_extend = 1;
-               emulated = kvmppc_handle_store(run, vcpu,
-                       VCPU_FPR(vcpu, rs),
-                       4, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-
-       case OP_STFD:
-               if (kvmppc_check_fp_disabled(vcpu))
-                       return EMULATE_DONE;
-               emulated = kvmppc_handle_store(run, vcpu,
-                       VCPU_FPR(vcpu, rs),
-                                      8, 1);
-               break;
-
-       case OP_STFDU:
-               if (kvmppc_check_fp_disabled(vcpu))
-                       return EMULATE_DONE;
-               emulated = kvmppc_handle_store(run, vcpu,
-                       VCPU_FPR(vcpu, rs),
-                                      8, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
 #endif
+#ifdef CONFIG_VSX
+               case STORE_VSX: {
+                       int io_size_each;
+
+                       if (op.vsx_flags & VSX_CHECK_VEC) {
+                               if (kvmppc_check_altivec_disabled(vcpu))
+                                       return EMULATE_DONE;
+                       } else {
+                               if (kvmppc_check_vsx_disabled(vcpu))
+                                       return EMULATE_DONE;
+                       }
+
+                       if (vcpu->kvm->arch.kvm_ops->giveup_ext)
+                               vcpu->kvm->arch.kvm_ops->giveup_ext(vcpu,
+                                               MSR_VSX);
+
+                       if (op.vsx_flags & VSX_FPCONV)
+                               vcpu->arch.mmio_sp64_extend = 1;
+
+                       if (op.element_size == 8)
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VSX_COPY_DWORD;
+                       else if (op.element_size == 4)
+                               vcpu->arch.mmio_copy_type =
+                                               KVMPPC_VSX_COPY_WORD;
+                       else
+                               break;
+
+                       if (size < op.element_size) {
+                               /* precise conversion case, like stxsspx */
+                               vcpu->arch.mmio_vsx_copy_nums = 1;
+                               io_size_each = size;
+                       } else { /* stxvw4x, stxvd2x, etc */
+                               vcpu->arch.mmio_vsx_copy_nums =
+                                               size/op.element_size;
+                               io_size_each = op.element_size;
+                       }
 
-       case OP_LD:
-               rt = get_rt(inst);
-               switch (inst & 3) {
-               case 0: /* ld */
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 8, 1);
-                       break;
-               case 1: /* ldu */
-                       emulated = kvmppc_handle_load(run, vcpu, rt, 8, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-                       break;
-               case 2: /* lwa */
-                       emulated = kvmppc_handle_loads(run, vcpu, rt, 4, 1);
+                       emulated = kvmppc_handle_vsx_store(run, vcpu,
+                                       op.reg & 0x1f, io_size_each, 1);
                        break;
-               default:
-                       emulated = EMULATE_FAIL;
                }
-               break;
-
-       case OP_LWZU:
-               emulated = kvmppc_handle_load(run, vcpu, rt, 4, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-
-       case OP_LBZ:
-               emulated = kvmppc_handle_load(run, vcpu, rt, 1, 1);
-               break;
-
-       case OP_LBZU:
-               emulated = kvmppc_handle_load(run, vcpu, rt, 1, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-
-       case OP_STW:
-               emulated = kvmppc_handle_store(run, vcpu,
-                                              kvmppc_get_gpr(vcpu, rs),
-                                              4, 1);
-               break;
-
-       case OP_STD:
-               rs = get_rs(inst);
-               switch (inst & 3) {
-               case 0: /* std */
-                       emulated = kvmppc_handle_store(run, vcpu,
-                               kvmppc_get_gpr(vcpu, rs), 8, 1);
-                       break;
-               case 1: /* stdu */
-                       emulated = kvmppc_handle_store(run, vcpu,
-                               kvmppc_get_gpr(vcpu, rs), 8, 1);
-                       kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
+#endif
+               case CACHEOP:
+                       /* Do nothing. The guest is performing dcbi because
+                        * hardware DMA is not snooped by the dcache, but
+                        * emulated DMA either goes through the dcache as
+                        * normal writes, or the host kernel has handled dcache
+                        * coherence.
+                        */
+                       emulated = EMULATE_DONE;
                        break;
                default:
-                       emulated = EMULATE_FAIL;
+                       break;
                }
-               break;
-
-       case OP_STWU:
-               emulated = kvmppc_handle_store(run, vcpu,
-                               kvmppc_get_gpr(vcpu, rs), 4, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-
-       case OP_STB:
-               emulated = kvmppc_handle_store(run, vcpu,
-                               kvmppc_get_gpr(vcpu, rs), 1, 1);
-               break;
-
-       case OP_STBU:
-               emulated = kvmppc_handle_store(run, vcpu,
-                               kvmppc_get_gpr(vcpu, rs), 1, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-
-       case OP_LHZ:
-               emulated = kvmppc_handle_load(run, vcpu, rt, 2, 1);
-               break;
-
-       case OP_LHZU:
-               emulated = kvmppc_handle_load(run, vcpu, rt, 2, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-
-       case OP_LHA:
-               emulated = kvmppc_handle_loads(run, vcpu, rt, 2, 1);
-               break;
-
-       case OP_LHAU:
-               emulated = kvmppc_handle_loads(run, vcpu, rt, 2, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-
-       case OP_STH:
-               emulated = kvmppc_handle_store(run, vcpu,
-                               kvmppc_get_gpr(vcpu, rs), 2, 1);
-               break;
-
-       case OP_STHU:
-               emulated = kvmppc_handle_store(run, vcpu,
-                               kvmppc_get_gpr(vcpu, rs), 2, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-
-#ifdef CONFIG_PPC_FPU
-       case OP_LFS:
-               if (kvmppc_check_fp_disabled(vcpu))
-                       return EMULATE_DONE;
-               vcpu->arch.mmio_sp64_extend = 1;
-               emulated = kvmppc_handle_load(run, vcpu,
-                       KVM_MMIO_REG_FPR|rt, 4, 1);
-               break;
-
-       case OP_LFSU:
-               if (kvmppc_check_fp_disabled(vcpu))
-                       return EMULATE_DONE;
-               vcpu->arch.mmio_sp64_extend = 1;
-               emulated = kvmppc_handle_load(run, vcpu,
-                       KVM_MMIO_REG_FPR|rt, 4, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-
-       case OP_LFD:
-               if (kvmppc_check_fp_disabled(vcpu))
-                       return EMULATE_DONE;
-               emulated = kvmppc_handle_load(run, vcpu,
-                       KVM_MMIO_REG_FPR|rt, 8, 1);
-               break;
-
-       case OP_LFDU:
-               if (kvmppc_check_fp_disabled(vcpu))
-                       return EMULATE_DONE;
-               emulated = kvmppc_handle_load(run, vcpu,
-                       KVM_MMIO_REG_FPR|rt, 8, 1);
-               kvmppc_set_gpr(vcpu, ra, vcpu->arch.vaddr_accessed);
-               break;
-#endif
-
-       default:
-               emulated = EMULATE_FAIL;
-               break;
        }
 
        if (emulated == EMULATE_FAIL) {
index 4e387647b5af0a9fc351a675d872d96d7269d99b..0e8c20c5eaace243850e255acf5be966c85f0a5c 100644 (file)
@@ -648,9 +648,8 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
 #endif
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
        case KVM_CAP_PPC_HTM:
-               r = hv_enabled &&
-                   (!!(cur_cpu_spec->cpu_user_features2 & PPC_FEATURE2_HTM) ||
-                    cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST));
+               r = !!(cur_cpu_spec->cpu_user_features2 & PPC_FEATURE2_HTM) ||
+                    (hv_enabled && cpu_has_feature(CPU_FTR_P9_TM_HV_ASSIST));
                break;
 #endif
        default:
@@ -907,6 +906,26 @@ static inline void kvmppc_set_vsr_dword_dump(struct kvm_vcpu *vcpu,
        }
 }
 
+static inline void kvmppc_set_vsr_word_dump(struct kvm_vcpu *vcpu,
+       u32 gpr)
+{
+       union kvmppc_one_reg val;
+       int index = vcpu->arch.io_gpr & KVM_MMIO_REG_MASK;
+
+       if (vcpu->arch.mmio_vsx_tx_sx_enabled) {
+               val.vsx32val[0] = gpr;
+               val.vsx32val[1] = gpr;
+               val.vsx32val[2] = gpr;
+               val.vsx32val[3] = gpr;
+               VCPU_VSX_VR(vcpu, index) = val.vval;
+       } else {
+               val.vsx32val[0] = gpr;
+               val.vsx32val[1] = gpr;
+               VCPU_VSX_FPR(vcpu, index, 0) = val.vsxval[0];
+               VCPU_VSX_FPR(vcpu, index, 1) = val.vsxval[0];
+       }
+}
+
 static inline void kvmppc_set_vsr_word(struct kvm_vcpu *vcpu,
        u32 gpr32)
 {
@@ -933,30 +952,110 @@ static inline void kvmppc_set_vsr_word(struct kvm_vcpu *vcpu,
 #endif /* CONFIG_VSX */
 
 #ifdef CONFIG_ALTIVEC
+static inline int kvmppc_get_vmx_offset_generic(struct kvm_vcpu *vcpu,
+               int index, int element_size)
+{
+       int offset;
+       int elts = sizeof(vector128)/element_size;
+
+       if ((index < 0) || (index >= elts))
+               return -1;
+
+       if (kvmppc_need_byteswap(vcpu))
+               offset = elts - index - 1;
+       else
+               offset = index;
+
+       return offset;
+}
+
+static inline int kvmppc_get_vmx_dword_offset(struct kvm_vcpu *vcpu,
+               int index)
+{
+       return kvmppc_get_vmx_offset_generic(vcpu, index, 8);
+}
+
+static inline int kvmppc_get_vmx_word_offset(struct kvm_vcpu *vcpu,
+               int index)
+{
+       return kvmppc_get_vmx_offset_generic(vcpu, index, 4);
+}
+
+static inline int kvmppc_get_vmx_hword_offset(struct kvm_vcpu *vcpu,
+               int index)
+{
+       return kvmppc_get_vmx_offset_generic(vcpu, index, 2);
+}
+
+static inline int kvmppc_get_vmx_byte_offset(struct kvm_vcpu *vcpu,
+               int index)
+{
+       return kvmppc_get_vmx_offset_generic(vcpu, index, 1);
+}
+
+
 static inline void kvmppc_set_vmx_dword(struct kvm_vcpu *vcpu,
-               u64 gpr)
+       u64 gpr)
 {
+       union kvmppc_one_reg val;
+       int offset = kvmppc_get_vmx_dword_offset(vcpu,
+                       vcpu->arch.mmio_vmx_offset);
        int index = vcpu->arch.io_gpr & KVM_MMIO_REG_MASK;
-       u32 hi, lo;
-       u32 di;
 
-#ifdef __BIG_ENDIAN
-       hi = gpr >> 32;
-       lo = gpr & 0xffffffff;
-#else
-       lo = gpr >> 32;
-       hi = gpr & 0xffffffff;
-#endif
+       if (offset == -1)
+               return;
+
+       val.vval = VCPU_VSX_VR(vcpu, index);
+       val.vsxval[offset] = gpr;
+       VCPU_VSX_VR(vcpu, index) = val.vval;
+}
+
+static inline void kvmppc_set_vmx_word(struct kvm_vcpu *vcpu,
+       u32 gpr32)
+{
+       union kvmppc_one_reg val;
+       int offset = kvmppc_get_vmx_word_offset(vcpu,
+                       vcpu->arch.mmio_vmx_offset);
+       int index = vcpu->arch.io_gpr & KVM_MMIO_REG_MASK;
 
-       di = 2 - vcpu->arch.mmio_vmx_copy_nums;         /* doubleword index */
-       if (di > 1)
+       if (offset == -1)
                return;
 
-       if (vcpu->arch.mmio_host_swabbed)
-               di = 1 - di;
+       val.vval = VCPU_VSX_VR(vcpu, index);
+       val.vsx32val[offset] = gpr32;
+       VCPU_VSX_VR(vcpu, index) = val.vval;
+}
+
+static inline void kvmppc_set_vmx_hword(struct kvm_vcpu *vcpu,
+       u16 gpr16)
+{
+       union kvmppc_one_reg val;
+       int offset = kvmppc_get_vmx_hword_offset(vcpu,
+                       vcpu->arch.mmio_vmx_offset);
+       int index = vcpu->arch.io_gpr & KVM_MMIO_REG_MASK;
+
+       if (offset == -1)
+               return;
+
+       val.vval = VCPU_VSX_VR(vcpu, index);
+       val.vsx16val[offset] = gpr16;
+       VCPU_VSX_VR(vcpu, index) = val.vval;
+}
+
+static inline void kvmppc_set_vmx_byte(struct kvm_vcpu *vcpu,
+       u8 gpr8)
+{
+       union kvmppc_one_reg val;
+       int offset = kvmppc_get_vmx_byte_offset(vcpu,
+                       vcpu->arch.mmio_vmx_offset);
+       int index = vcpu->arch.io_gpr & KVM_MMIO_REG_MASK;
+
+       if (offset == -1)
+               return;
 
-       VCPU_VSX_VR(vcpu, index).u[di * 2] = hi;
-       VCPU_VSX_VR(vcpu, index).u[di * 2 + 1] = lo;
+       val.vval = VCPU_VSX_VR(vcpu, index);
+       val.vsx8val[offset] = gpr8;
+       VCPU_VSX_VR(vcpu, index) = val.vval;
 }
 #endif /* CONFIG_ALTIVEC */
 
@@ -1041,6 +1140,9 @@ static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu,
                kvmppc_set_gpr(vcpu, vcpu->arch.io_gpr, gpr);
                break;
        case KVM_MMIO_REG_FPR:
+               if (vcpu->kvm->arch.kvm_ops->giveup_ext)
+                       vcpu->kvm->arch.kvm_ops->giveup_ext(vcpu, MSR_FP);
+
                VCPU_FPR(vcpu, vcpu->arch.io_gpr & KVM_MMIO_REG_MASK) = gpr;
                break;
 #ifdef CONFIG_PPC_BOOK3S
@@ -1054,18 +1156,36 @@ static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu,
 #endif
 #ifdef CONFIG_VSX
        case KVM_MMIO_REG_VSX:
-               if (vcpu->arch.mmio_vsx_copy_type == KVMPPC_VSX_COPY_DWORD)
+               if (vcpu->kvm->arch.kvm_ops->giveup_ext)
+                       vcpu->kvm->arch.kvm_ops->giveup_ext(vcpu, MSR_VSX);
+
+               if (vcpu->arch.mmio_copy_type == KVMPPC_VSX_COPY_DWORD)
                        kvmppc_set_vsr_dword(vcpu, gpr);
-               else if (vcpu->arch.mmio_vsx_copy_type == KVMPPC_VSX_COPY_WORD)
+               else if (vcpu->arch.mmio_copy_type == KVMPPC_VSX_COPY_WORD)
                        kvmppc_set_vsr_word(vcpu, gpr);
-               else if (vcpu->arch.mmio_vsx_copy_type ==
+               else if (vcpu->arch.mmio_copy_type ==
                                KVMPPC_VSX_COPY_DWORD_LOAD_DUMP)
                        kvmppc_set_vsr_dword_dump(vcpu, gpr);
+               else if (vcpu->arch.mmio_copy_type ==
+                               KVMPPC_VSX_COPY_WORD_LOAD_DUMP)
+                       kvmppc_set_vsr_word_dump(vcpu, gpr);
                break;
 #endif
 #ifdef CONFIG_ALTIVEC
        case KVM_MMIO_REG_VMX:
-               kvmppc_set_vmx_dword(vcpu, gpr);
+               if (vcpu->kvm->arch.kvm_ops->giveup_ext)
+                       vcpu->kvm->arch.kvm_ops->giveup_ext(vcpu, MSR_VEC);
+
+               if (vcpu->arch.mmio_copy_type == KVMPPC_VMX_COPY_DWORD)
+                       kvmppc_set_vmx_dword(vcpu, gpr);
+               else if (vcpu->arch.mmio_copy_type == KVMPPC_VMX_COPY_WORD)
+                       kvmppc_set_vmx_word(vcpu, gpr);
+               else if (vcpu->arch.mmio_copy_type ==
+                               KVMPPC_VMX_COPY_HWORD)
+                       kvmppc_set_vmx_hword(vcpu, gpr);
+               else if (vcpu->arch.mmio_copy_type ==
+                               KVMPPC_VMX_COPY_BYTE)
+                       kvmppc_set_vmx_byte(vcpu, gpr);
                break;
 #endif
        default:
@@ -1228,7 +1348,7 @@ static inline int kvmppc_get_vsr_data(struct kvm_vcpu *vcpu, int rs, u64 *val)
        u32 dword_offset, word_offset;
        union kvmppc_one_reg reg;
        int vsx_offset = 0;
-       int copy_type = vcpu->arch.mmio_vsx_copy_type;
+       int copy_type = vcpu->arch.mmio_copy_type;
        int result = 0;
 
        switch (copy_type) {
@@ -1344,14 +1464,16 @@ static int kvmppc_emulate_mmio_vsx_loadstore(struct kvm_vcpu *vcpu,
 #endif /* CONFIG_VSX */
 
 #ifdef CONFIG_ALTIVEC
-/* handle quadword load access in two halves */
-int kvmppc_handle_load128_by2x64(struct kvm_run *run, struct kvm_vcpu *vcpu,
-               unsigned int rt, int is_default_endian)
+int kvmppc_handle_vmx_load(struct kvm_run *run, struct kvm_vcpu *vcpu,
+               unsigned int rt, unsigned int bytes, int is_default_endian)
 {
        enum emulation_result emulated = EMULATE_DONE;
 
+       if (vcpu->arch.mmio_vsx_copy_nums > 2)
+               return EMULATE_FAIL;
+
        while (vcpu->arch.mmio_vmx_copy_nums) {
-               emulated = __kvmppc_handle_load(run, vcpu, rt, 8,
+               emulated = __kvmppc_handle_load(run, vcpu, rt, bytes,
                                is_default_endian, 0);
 
                if (emulated != EMULATE_DONE)
@@ -1359,55 +1481,127 @@ int kvmppc_handle_load128_by2x64(struct kvm_run *run, struct kvm_vcpu *vcpu,
 
                vcpu->arch.paddr_accessed += run->mmio.len;
                vcpu->arch.mmio_vmx_copy_nums--;
+               vcpu->arch.mmio_vmx_offset++;
        }
 
        return emulated;
 }
 
-static inline int kvmppc_get_vmx_data(struct kvm_vcpu *vcpu, int rs, u64 *val)
+int kvmppc_get_vmx_dword(struct kvm_vcpu *vcpu, int index, u64 *val)
 {
-       vector128 vrs = VCPU_VSX_VR(vcpu, rs);
-       u32 di;
-       u64 w0, w1;
+       union kvmppc_one_reg reg;
+       int vmx_offset = 0;
+       int result = 0;
 
-       di = 2 - vcpu->arch.mmio_vmx_copy_nums;         /* doubleword index */
-       if (di > 1)
+       vmx_offset =
+               kvmppc_get_vmx_dword_offset(vcpu, vcpu->arch.mmio_vmx_offset);
+
+       if (vmx_offset == -1)
                return -1;
 
-       if (vcpu->arch.mmio_host_swabbed)
-               di = 1 - di;
+       reg.vval = VCPU_VSX_VR(vcpu, index);
+       *val = reg.vsxval[vmx_offset];
 
-       w0 = vrs.u[di * 2];
-       w1 = vrs.u[di * 2 + 1];
+       return result;
+}
 
-#ifdef __BIG_ENDIAN
-       *val = (w0 << 32) | w1;
-#else
-       *val = (w1 << 32) | w0;
-#endif
-       return 0;
+int kvmppc_get_vmx_word(struct kvm_vcpu *vcpu, int index, u64 *val)
+{
+       union kvmppc_one_reg reg;
+       int vmx_offset = 0;
+       int result = 0;
+
+       vmx_offset =
+               kvmppc_get_vmx_word_offset(vcpu, vcpu->arch.mmio_vmx_offset);
+
+       if (vmx_offset == -1)
+               return -1;
+
+       reg.vval = VCPU_VSX_VR(vcpu, index);
+       *val = reg.vsx32val[vmx_offset];
+
+       return result;
+}
+
+int kvmppc_get_vmx_hword(struct kvm_vcpu *vcpu, int index, u64 *val)
+{
+       union kvmppc_one_reg reg;
+       int vmx_offset = 0;
+       int result = 0;
+
+       vmx_offset =
+               kvmppc_get_vmx_hword_offset(vcpu, vcpu->arch.mmio_vmx_offset);
+
+       if (vmx_offset == -1)
+               return -1;
+
+       reg.vval = VCPU_VSX_VR(vcpu, index);
+       *val = reg.vsx16val[vmx_offset];
+
+       return result;
 }
 
-/* handle quadword store in two halves */
-int kvmppc_handle_store128_by2x64(struct kvm_run *run, struct kvm_vcpu *vcpu,
-               unsigned int rs, int is_default_endian)
+int kvmppc_get_vmx_byte(struct kvm_vcpu *vcpu, int index, u64 *val)
+{
+       union kvmppc_one_reg reg;
+       int vmx_offset = 0;
+       int result = 0;
+
+       vmx_offset =
+               kvmppc_get_vmx_byte_offset(vcpu, vcpu->arch.mmio_vmx_offset);
+
+       if (vmx_offset == -1)
+               return -1;
+
+       reg.vval = VCPU_VSX_VR(vcpu, index);
+       *val = reg.vsx8val[vmx_offset];
+
+       return result;
+}
+
+int kvmppc_handle_vmx_store(struct kvm_run *run, struct kvm_vcpu *vcpu,
+               unsigned int rs, unsigned int bytes, int is_default_endian)
 {
        u64 val = 0;
+       unsigned int index = rs & KVM_MMIO_REG_MASK;
        enum emulation_result emulated = EMULATE_DONE;
 
+       if (vcpu->arch.mmio_vsx_copy_nums > 2)
+               return EMULATE_FAIL;
+
        vcpu->arch.io_gpr = rs;
 
        while (vcpu->arch.mmio_vmx_copy_nums) {
-               if (kvmppc_get_vmx_data(vcpu, rs, &val) == -1)
+               switch (vcpu->arch.mmio_copy_type) {
+               case KVMPPC_VMX_COPY_DWORD:
+                       if (kvmppc_get_vmx_dword(vcpu, index, &val) == -1)
+                               return EMULATE_FAIL;
+
+                       break;
+               case KVMPPC_VMX_COPY_WORD:
+                       if (kvmppc_get_vmx_word(vcpu, index, &val) == -1)
+                               return EMULATE_FAIL;
+                       break;
+               case KVMPPC_VMX_COPY_HWORD:
+                       if (kvmppc_get_vmx_hword(vcpu, index, &val) == -1)
+                               return EMULATE_FAIL;
+                       break;
+               case KVMPPC_VMX_COPY_BYTE:
+                       if (kvmppc_get_vmx_byte(vcpu, index, &val) == -1)
+                               return EMULATE_FAIL;
+                       break;
+               default:
                        return EMULATE_FAIL;
+               }
 
-               emulated = kvmppc_handle_store(run, vcpu, val, 8,
+               emulated = kvmppc_handle_store(run, vcpu, val, bytes,
                                is_default_endian);
                if (emulated != EMULATE_DONE)
                        break;
 
                vcpu->arch.paddr_accessed += run->mmio.len;
                vcpu->arch.mmio_vmx_copy_nums--;
+               vcpu->arch.mmio_vmx_offset++;
        }
 
        return emulated;
@@ -1422,11 +1616,11 @@ static int kvmppc_emulate_mmio_vmx_loadstore(struct kvm_vcpu *vcpu,
        vcpu->arch.paddr_accessed += run->mmio.len;
 
        if (!vcpu->mmio_is_write) {
-               emulated = kvmppc_handle_load128_by2x64(run, vcpu,
-                               vcpu->arch.io_gpr, 1);
+               emulated = kvmppc_handle_vmx_load(run, vcpu,
+                               vcpu->arch.io_gpr, run->mmio.len, 1);
        } else {
-               emulated = kvmppc_handle_store128_by2x64(run, vcpu,
-                               vcpu->arch.io_gpr, 1);
+               emulated = kvmppc_handle_vmx_store(run, vcpu,
+                               vcpu->arch.io_gpr, run->mmio.len, 1);
        }
 
        switch (emulated) {
@@ -1570,8 +1764,10 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
                }
 #endif
 #ifdef CONFIG_ALTIVEC
-               if (vcpu->arch.mmio_vmx_copy_nums > 0)
+               if (vcpu->arch.mmio_vmx_copy_nums > 0) {
                        vcpu->arch.mmio_vmx_copy_nums--;
+                       vcpu->arch.mmio_vmx_offset++;
+               }
 
                if (vcpu->arch.mmio_vmx_copy_nums > 0) {
                        r = kvmppc_emulate_mmio_vmx_loadstore(vcpu, run);
@@ -1784,16 +1980,16 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
        void __user *argp = (void __user *)arg;
        long r;
 
-       vcpu_load(vcpu);
-
        switch (ioctl) {
        case KVM_ENABLE_CAP:
        {
                struct kvm_enable_cap cap;
                r = -EFAULT;
+               vcpu_load(vcpu);
                if (copy_from_user(&cap, argp, sizeof(cap)))
                        goto out;
                r = kvm_vcpu_ioctl_enable_cap(vcpu, &cap);
+               vcpu_put(vcpu);
                break;
        }
 
@@ -1815,9 +2011,11 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
        case KVM_DIRTY_TLB: {
                struct kvm_dirty_tlb dirty;
                r = -EFAULT;
+               vcpu_load(vcpu);
                if (copy_from_user(&dirty, argp, sizeof(dirty)))
                        goto out;
                r = kvm_vcpu_ioctl_dirty_tlb(vcpu, &dirty);
+               vcpu_put(vcpu);
                break;
        }
 #endif
@@ -1826,11 +2024,10 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
        }
 
 out:
-       vcpu_put(vcpu);
        return r;
 }
 
-int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
+vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
 {
        return VM_FAULT_SIGBUS;
 }
diff --git a/arch/powerpc/kvm/tm.S b/arch/powerpc/kvm/tm.S
new file mode 100644 (file)
index 0000000..90e330f
--- /dev/null
@@ -0,0 +1,384 @@
+/*
+ * 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.
+ *
+ * Derived from book3s_hv_rmhandlers.S, which is:
+ *
+ * Copyright 2011 Paul Mackerras, IBM Corp. <paulus@au1.ibm.com>
+ *
+ */
+
+#include <asm/reg.h>
+#include <asm/ppc_asm.h>
+#include <asm/asm-offsets.h>
+#include <asm/export.h>
+#include <asm/tm.h>
+#include <asm/cputable.h>
+
+#ifdef CONFIG_PPC_TRANSACTIONAL_MEM
+#define VCPU_GPRS_TM(reg) (((reg) * ULONG_SIZE) + VCPU_GPR_TM)
+
+/*
+ * Save transactional state and TM-related registers.
+ * Called with:
+ * - r3 pointing to the vcpu struct
+ * - r4 points to the MSR with current TS bits:
+ *     (For HV KVM, it is VCPU_MSR ; For PR KVM, it is host MSR).
+ * This can modify all checkpointed registers, but
+ * restores r1, r2 before exit.
+ */
+_GLOBAL(__kvmppc_save_tm)
+       mflr    r0
+       std     r0, PPC_LR_STKOFF(r1)
+
+       /* Turn on TM. */
+       mfmsr   r8
+       li      r0, 1
+       rldimi  r8, r0, MSR_TM_LG, 63-MSR_TM_LG
+       ori     r8, r8, MSR_FP
+       oris    r8, r8, (MSR_VEC | MSR_VSX)@h
+       mtmsrd  r8
+
+       rldicl. r4, r4, 64 - MSR_TS_S_LG, 62
+       beq     1f      /* TM not active in guest. */
+
+       std     r1, HSTATE_SCRATCH2(r13)
+       std     r3, HSTATE_SCRATCH1(r13)
+
+#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
+BEGIN_FTR_SECTION
+       /* Emulation of the treclaim instruction needs TEXASR before treclaim */
+       mfspr   r6, SPRN_TEXASR
+       std     r6, VCPU_ORIG_TEXASR(r3)
+END_FTR_SECTION_IFSET(CPU_FTR_P9_TM_HV_ASSIST)
+#endif
+
+       /* Clear the MSR RI since r1, r13 are all going to be foobar. */
+       li      r5, 0
+       mtmsrd  r5, 1
+
+       li      r3, TM_CAUSE_KVM_RESCHED
+
+       /* All GPRs are volatile at this point. */
+       TRECLAIM(R3)
+
+       /* Temporarily store r13 and r9 so we have some regs to play with */
+       SET_SCRATCH0(r13)
+       GET_PACA(r13)
+       std     r9, PACATMSCRATCH(r13)
+       ld      r9, HSTATE_SCRATCH1(r13)
+
+       /* Get a few more GPRs free. */
+       std     r29, VCPU_GPRS_TM(29)(r9)
+       std     r30, VCPU_GPRS_TM(30)(r9)
+       std     r31, VCPU_GPRS_TM(31)(r9)
+
+       /* Save away PPR and DSCR soon so don't run with user values. */
+       mfspr   r31, SPRN_PPR
+       HMT_MEDIUM
+       mfspr   r30, SPRN_DSCR
+#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
+       ld      r29, HSTATE_DSCR(r13)
+       mtspr   SPRN_DSCR, r29
+#endif
+
+       /* Save all but r9, r13 & r29-r31 */
+       reg = 0
+       .rept   29
+       .if (reg != 9) && (reg != 13)
+       std     reg, VCPU_GPRS_TM(reg)(r9)
+       .endif
+       reg = reg + 1
+       .endr
+       /* ... now save r13 */
+       GET_SCRATCH0(r4)
+       std     r4, VCPU_GPRS_TM(13)(r9)
+       /* ... and save r9 */
+       ld      r4, PACATMSCRATCH(r13)
+       std     r4, VCPU_GPRS_TM(9)(r9)
+
+       /* Reload stack pointer and TOC. */
+       ld      r1, HSTATE_SCRATCH2(r13)
+       ld      r2, PACATOC(r13)
+
+       /* Set MSR RI now we have r1 and r13 back. */
+       li      r5, MSR_RI
+       mtmsrd  r5, 1
+
+       /* Save away checkpinted SPRs. */
+       std     r31, VCPU_PPR_TM(r9)
+       std     r30, VCPU_DSCR_TM(r9)
+       mflr    r5
+       mfcr    r6
+       mfctr   r7
+       mfspr   r8, SPRN_AMR
+       mfspr   r10, SPRN_TAR
+       mfxer   r11
+       std     r5, VCPU_LR_TM(r9)
+       stw     r6, VCPU_CR_TM(r9)
+       std     r7, VCPU_CTR_TM(r9)
+       std     r8, VCPU_AMR_TM(r9)
+       std     r10, VCPU_TAR_TM(r9)
+       std     r11, VCPU_XER_TM(r9)
+
+       /* Restore r12 as trap number. */
+       lwz     r12, VCPU_TRAP(r9)
+
+       /* Save FP/VSX. */
+       addi    r3, r9, VCPU_FPRS_TM
+       bl      store_fp_state
+       addi    r3, r9, VCPU_VRS_TM
+       bl      store_vr_state
+       mfspr   r6, SPRN_VRSAVE
+       stw     r6, VCPU_VRSAVE_TM(r9)
+1:
+       /*
+        * We need to save these SPRs after the treclaim so that the software
+        * error code is recorded correctly in the TEXASR.  Also the user may
+        * change these outside of a transaction, so they must always be
+        * context switched.
+        */
+       mfspr   r7, SPRN_TEXASR
+       std     r7, VCPU_TEXASR(r9)
+11:
+       mfspr   r5, SPRN_TFHAR
+       mfspr   r6, SPRN_TFIAR
+       std     r5, VCPU_TFHAR(r9)
+       std     r6, VCPU_TFIAR(r9)
+
+       ld      r0, PPC_LR_STKOFF(r1)
+       mtlr    r0
+       blr
+
+/*
+ * _kvmppc_save_tm_pr() is a wrapper around __kvmppc_save_tm(), so that it can
+ * be invoked from C function by PR KVM only.
+ */
+_GLOBAL(_kvmppc_save_tm_pr)
+       mflr    r5
+       std     r5, PPC_LR_STKOFF(r1)
+       stdu    r1, -SWITCH_FRAME_SIZE(r1)
+       SAVE_NVGPRS(r1)
+
+       /* save MSR since TM/math bits might be impacted
+        * by __kvmppc_save_tm().
+        */
+       mfmsr   r5
+       SAVE_GPR(5, r1)
+
+       /* also save DSCR/CR/TAR so that it can be recovered later */
+       mfspr   r6, SPRN_DSCR
+       SAVE_GPR(6, r1)
+
+       mfcr    r7
+       stw     r7, _CCR(r1)
+
+       mfspr   r8, SPRN_TAR
+       SAVE_GPR(8, r1)
+
+       bl      __kvmppc_save_tm
+
+       REST_GPR(8, r1)
+       mtspr   SPRN_TAR, r8
+
+       ld      r7, _CCR(r1)
+       mtcr    r7
+
+       REST_GPR(6, r1)
+       mtspr   SPRN_DSCR, r6
+
+       /* need preserve current MSR's MSR_TS bits */
+       REST_GPR(5, r1)
+       mfmsr   r6
+       rldicl  r6, r6, 64 - MSR_TS_S_LG, 62
+       rldimi  r5, r6, MSR_TS_S_LG, 63 - MSR_TS_T_LG
+       mtmsrd  r5
+
+       REST_NVGPRS(r1)
+       addi    r1, r1, SWITCH_FRAME_SIZE
+       ld      r5, PPC_LR_STKOFF(r1)
+       mtlr    r5
+       blr
+
+EXPORT_SYMBOL_GPL(_kvmppc_save_tm_pr);
+
+/*
+ * Restore transactional state and TM-related registers.
+ * Called with:
+ *  - r3 pointing to the vcpu struct.
+ *  - r4 is the guest MSR with desired TS bits:
+ *     For HV KVM, it is VCPU_MSR
+ *     For PR KVM, it is provided by caller
+ * This potentially modifies all checkpointed registers.
+ * It restores r1, r2 from the PACA.
+ */
+_GLOBAL(__kvmppc_restore_tm)
+       mflr    r0
+       std     r0, PPC_LR_STKOFF(r1)
+
+       /* Turn on TM/FP/VSX/VMX so we can restore them. */
+       mfmsr   r5
+       li      r6, MSR_TM >> 32
+       sldi    r6, r6, 32
+       or      r5, r5, r6
+       ori     r5, r5, MSR_FP
+       oris    r5, r5, (MSR_VEC | MSR_VSX)@h
+       mtmsrd  r5
+
+       /*
+        * The user may change these outside of a transaction, so they must
+        * always be context switched.
+        */
+       ld      r5, VCPU_TFHAR(r3)
+       ld      r6, VCPU_TFIAR(r3)
+       ld      r7, VCPU_TEXASR(r3)
+       mtspr   SPRN_TFHAR, r5
+       mtspr   SPRN_TFIAR, r6
+       mtspr   SPRN_TEXASR, r7
+
+       mr      r5, r4
+       rldicl. r5, r5, 64 - MSR_TS_S_LG, 62
+       beqlr           /* TM not active in guest */
+       std     r1, HSTATE_SCRATCH2(r13)
+
+       /* Make sure the failure summary is set, otherwise we'll program check
+        * when we trechkpt.  It's possible that this might have been not set
+        * on a kvmppc_set_one_reg() call but we shouldn't let this crash the
+        * host.
+        */
+       oris    r7, r7, (TEXASR_FS)@h
+       mtspr   SPRN_TEXASR, r7
+
+       /*
+        * We need to load up the checkpointed state for the guest.
+        * We need to do this early as it will blow away any GPRs, VSRs and
+        * some SPRs.
+        */
+
+       mr      r31, r3
+       addi    r3, r31, VCPU_FPRS_TM
+       bl      load_fp_state
+       addi    r3, r31, VCPU_VRS_TM
+       bl      load_vr_state
+       mr      r3, r31
+       lwz     r7, VCPU_VRSAVE_TM(r3)
+       mtspr   SPRN_VRSAVE, r7
+
+       ld      r5, VCPU_LR_TM(r3)
+       lwz     r6, VCPU_CR_TM(r3)
+       ld      r7, VCPU_CTR_TM(r3)
+       ld      r8, VCPU_AMR_TM(r3)
+       ld      r9, VCPU_TAR_TM(r3)
+       ld      r10, VCPU_XER_TM(r3)
+       mtlr    r5
+       mtcr    r6
+       mtctr   r7
+       mtspr   SPRN_AMR, r8
+       mtspr   SPRN_TAR, r9
+       mtxer   r10
+
+       /*
+        * Load up PPR and DSCR values but don't put them in the actual SPRs
+        * till the last moment to avoid running with userspace PPR and DSCR for
+        * too long.
+        */
+       ld      r29, VCPU_DSCR_TM(r3)
+       ld      r30, VCPU_PPR_TM(r3)
+
+       std     r2, PACATMSCRATCH(r13) /* Save TOC */
+
+       /* Clear the MSR RI since r1, r13 are all going to be foobar. */
+       li      r5, 0
+       mtmsrd  r5, 1
+
+       /* Load GPRs r0-r28 */
+       reg = 0
+       .rept   29
+       ld      reg, VCPU_GPRS_TM(reg)(r31)
+       reg = reg + 1
+       .endr
+
+       mtspr   SPRN_DSCR, r29
+       mtspr   SPRN_PPR, r30
+
+       /* Load final GPRs */
+       ld      29, VCPU_GPRS_TM(29)(r31)
+       ld      30, VCPU_GPRS_TM(30)(r31)
+       ld      31, VCPU_GPRS_TM(31)(r31)
+
+       /* TM checkpointed state is now setup.  All GPRs are now volatile. */
+       TRECHKPT
+
+       /* Now let's get back the state we need. */
+       HMT_MEDIUM
+       GET_PACA(r13)
+#ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
+       ld      r29, HSTATE_DSCR(r13)
+       mtspr   SPRN_DSCR, r29
+#endif
+       ld      r1, HSTATE_SCRATCH2(r13)
+       ld      r2, PACATMSCRATCH(r13)
+
+       /* Set the MSR RI since we have our registers back. */
+       li      r5, MSR_RI
+       mtmsrd  r5, 1
+       ld      r0, PPC_LR_STKOFF(r1)
+       mtlr    r0
+       blr
+
+/*
+ * _kvmppc_restore_tm_pr() is a wrapper around __kvmppc_restore_tm(), so that it
+ * can be invoked from C function by PR KVM only.
+ */
+_GLOBAL(_kvmppc_restore_tm_pr)
+       mflr    r5
+       std     r5, PPC_LR_STKOFF(r1)
+       stdu    r1, -SWITCH_FRAME_SIZE(r1)
+       SAVE_NVGPRS(r1)
+
+       /* save MSR to avoid TM/math bits change */
+       mfmsr   r5
+       SAVE_GPR(5, r1)
+
+       /* also save DSCR/CR/TAR so that it can be recovered later */
+       mfspr   r6, SPRN_DSCR
+       SAVE_GPR(6, r1)
+
+       mfcr    r7
+       stw     r7, _CCR(r1)
+
+       mfspr   r8, SPRN_TAR
+       SAVE_GPR(8, r1)
+
+       bl      __kvmppc_restore_tm
+
+       REST_GPR(8, r1)
+       mtspr   SPRN_TAR, r8
+
+       ld      r7, _CCR(r1)
+       mtcr    r7
+
+       REST_GPR(6, r1)
+       mtspr   SPRN_DSCR, r6
+
+       /* need preserve current MSR's MSR_TS bits */
+       REST_GPR(5, r1)
+       mfmsr   r6
+       rldicl  r6, r6, 64 - MSR_TS_S_LG, 62
+       rldimi  r5, r6, MSR_TS_S_LG, 63 - MSR_TS_T_LG
+       mtmsrd  r5
+
+       REST_NVGPRS(r1)
+       addi    r1, r1, SWITCH_FRAME_SIZE
+       ld      r5, PPC_LR_STKOFF(r1)
+       mtlr    r5
+       blr
+
+EXPORT_SYMBOL_GPL(_kvmppc_restore_tm_pr);
+#endif /* CONFIG_PPC_TRANSACTIONAL_MEM */
index 94058c21a4827697bb964ff9acb542b0c42d6471..6aa774aa5b16974d46d510d322912c992006bcde 100644 (file)
@@ -54,7 +54,7 @@ static int grow(rh_info_t * info, int max_blocks)
 
        new_blocks = max_blocks - info->max_blocks;
 
-       block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_ATOMIC);
+       block = kmalloc_array(max_blocks, sizeof(rh_block_t), GFP_ATOMIC);
        if (block == NULL)
                return -ENOMEM;
 
index 8cecda4bd66ae43d79f1c16beb4e229ecd26cc92..5c8530d0c611898f012e2cc8f300a7112715c351 100644 (file)
@@ -215,7 +215,7 @@ void __init mem_topology_setup(void)
        /* Place all memblock_regions in the same node and merge contiguous
         * memblock_regions
         */
-       memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
+       memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
 }
 
 void __init initmem_init(void)
index 4c615fcb0cf073bbdc8f746c0e54abdd1082e142..abb43646927aa9575c3aeec91ae55905545b6026 100644 (file)
@@ -159,7 +159,7 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries,
                goto unlock_exit;
        }
 
-       mem->hpas = vzalloc(entries * sizeof(mem->hpas[0]));
+       mem->hpas = vzalloc(array_size(entries, sizeof(mem->hpas[0])));
        if (!mem->hpas) {
                kfree(mem);
                ret = -ENOMEM;
index 57a5029b4521b0ea0f179b259ee3bef4dc0cfde5..0c7e05d8924481f3e4b3fca1d23cb293bab5320d 100644 (file)
@@ -1316,7 +1316,7 @@ int numa_update_cpu_topology(bool cpus_locked)
        if (!weight)
                return 0;
 
-       updates = kzalloc(weight * (sizeof(*updates)), GFP_KERNEL);
+       updates = kcalloc(weight, sizeof(*updates), GFP_KERNEL);
        if (!updates)
                return 0;
 
index a9636d8cba153a1fb43469c1b8070b59ae4ba210..5b061fc81df30a2c0d6065518b05d46ce568f290 100644 (file)
@@ -566,7 +566,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
        if (!bpf_jit_enable)
                return;
 
-       addrs = kzalloc((flen+1) * sizeof(*addrs), GFP_KERNEL);
+       addrs = kcalloc(flen + 1, sizeof(*addrs), GFP_KERNEL);
        if (addrs == NULL)
                return;
 
index f1c95779843bcf3f603d22af7d1d1f50263b473d..380cbf9a40d98f76718f22d6e6b5ffa6c1cd25bc 100644 (file)
@@ -949,7 +949,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
                goto skip_init_ctx;
        }
 
-       addrs = kzalloc((flen+1) * sizeof(*addrs), GFP_KERNEL);
+       addrs = kcalloc(flen + 1, sizeof(*addrs), GFP_KERNEL);
        if (addrs == NULL) {
                fp = org_fp;
                goto out_addrs;
index 5182f2936af2c8c718ee06e65a837d174fa88d19..4e099e556645ad082de4c24e58ef07e108bf0947 100644 (file)
@@ -210,8 +210,8 @@ int start_spu_profiling_cycles(unsigned int cycles_reset)
        timer.function = profile_spus;
 
        /* Allocate arrays for collecting SPU PC samples */
-       samples = kzalloc(SPUS_PER_NODE *
-                         TRACE_ARRAY_SIZE * sizeof(u32), GFP_KERNEL);
+       samples = kcalloc(SPUS_PER_NODE * TRACE_ARRAY_SIZE, sizeof(u32),
+                         GFP_KERNEL);
 
        if (!samples)
                return -ENOMEM;
index 9926ad67af761acbfcc5dcf173bbaa55dc59f3d1..1c18f2955f7d38906a9743e3198c723726eeedf8 100644 (file)
@@ -156,7 +156,8 @@ static int hsta_msi_probe(struct platform_device *pdev)
        if (ret)
                goto out;
 
-       ppc4xx_hsta_msi.irq_map = kmalloc(sizeof(int) * irq_count, GFP_KERNEL);
+       ppc4xx_hsta_msi.irq_map = kmalloc_array(irq_count, sizeof(int),
+                                               GFP_KERNEL);
        if (!ppc4xx_hsta_msi.irq_map) {
                ret = -ENOMEM;
                goto out1;
index 96aaae67892802d9153d3f603c67437d5fe802eb..81b2cbce7df8703d0a09480865be5d9f95e3068b 100644 (file)
@@ -89,7 +89,7 @@ static int ppc4xx_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
        if (type == PCI_CAP_ID_MSIX)
                pr_debug("ppc4xx msi: MSI-X untested, trying anyway.\n");
 
-       msi_data->msi_virqs = kmalloc((msi_irqs) * sizeof(int), GFP_KERNEL);
+       msi_data->msi_virqs = kmalloc_array(msi_irqs, sizeof(int), GFP_KERNEL);
        if (!msi_data->msi_virqs)
                return -ENOMEM;
 
index 73e6b36bcd5125724a0c913d745e1a4bab9b1133..5aca523551aed01706cc125947fa6ac84216de7a 100644 (file)
@@ -1449,7 +1449,7 @@ static int __init ppc4xx_pciex_check_core_init(struct device_node *np)
        count = ppc4xx_pciex_hwops->core_init(np);
        if (count > 0) {
                ppc4xx_pciex_ports =
-                      kzalloc(count * sizeof(struct ppc4xx_pciex_port),
+                      kcalloc(count, sizeof(struct ppc4xx_pciex_port),
                               GFP_KERNEL);
                if (ppc4xx_pciex_ports) {
                        ppc4xx_pciex_port_count = count;
index 6fd4092798d5f5b415cd73e26211ddfc26e0359f..9aa87df114fd10782a432fd4aa37b993a7e88fd6 100644 (file)
@@ -198,21 +198,21 @@ void __init opal_sys_param_init(void)
                goto out_param_buf;
        }
 
-       id = kzalloc(sizeof(*id) * count, GFP_KERNEL);
+       id = kcalloc(count, sizeof(*id), GFP_KERNEL);
        if (!id) {
                pr_err("SYSPARAM: Failed to allocate memory to read parameter "
                                "id\n");
                goto out_param_buf;
        }
 
-       size = kzalloc(sizeof(*size) * count, GFP_KERNEL);
+       size = kcalloc(count, sizeof(*size), GFP_KERNEL);
        if (!size) {
                pr_err("SYSPARAM: Failed to allocate memory to read parameter "
                                "size\n");
                goto out_free_id;
        }
 
-       perm = kzalloc(sizeof(*perm) * count, GFP_KERNEL);
+       perm = kcalloc(count, sizeof(*perm), GFP_KERNEL);
        if (!perm) {
                pr_err("SYSPARAM: Failed to allocate memory to read supported "
                                "action on the parameter");
@@ -235,7 +235,7 @@ void __init opal_sys_param_init(void)
                goto out_free_perm;
        }
 
-       attr = kzalloc(sizeof(*attr) * count, GFP_KERNEL);
+       attr = kcalloc(count, sizeof(*attr), GFP_KERNEL);
        if (!attr) {
                pr_err("SYSPARAM: Failed to allocate memory for parameter "
                                "attributes\n");
index 1d4e0ef658d38f4ba7deafa877d1250b82e1459c..353b43972bbffd122699700f16751e93b6748474 100644 (file)
@@ -544,7 +544,7 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
        printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n");
 
        /* Allocate fixups array */
-       mpic->fixups = kzalloc(128 * sizeof(*mpic->fixups), GFP_KERNEL);
+       mpic->fixups = kcalloc(128, sizeof(*mpic->fixups), GFP_KERNEL);
        BUG_ON(mpic->fixups == NULL);
 
        /* Init spinlock */
@@ -1324,7 +1324,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
        if (psrc) {
                /* Allocate a bitmap with one bit per interrupt */
                unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1);
-               mpic->protected = kzalloc(mapsize*sizeof(long), GFP_KERNEL);
+               mpic->protected = kcalloc(mapsize, sizeof(long), GFP_KERNEL);
                BUG_ON(mpic->protected == NULL);
                for (i = 0; i < psize/sizeof(u32); i++) {
                        if (psrc[i] > intvec_top)
@@ -1639,8 +1639,9 @@ void __init mpic_init(struct mpic *mpic)
 
 #ifdef CONFIG_PM
        /* allocate memory to save mpic state */
-       mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data),
-                                 GFP_KERNEL);
+       mpic->save_data = kmalloc_array(mpic->num_sources,
+                                       sizeof(*mpic->save_data),
+                                       GFP_KERNEL);
        BUG_ON(mpic->save_data == NULL);
 #endif
 
index 83bcd72b21cf7820a6da70698eb1c8e6bf49ae09..311185b9960a1b755d19313d6da55217c73d90c0 100644 (file)
@@ -489,7 +489,7 @@ static bool xive_parse_provisioning(struct device_node *np)
        if (rc == 0)
                return true;
 
-       xive_provision_chips = kzalloc(4 * xive_provision_chip_count,
+       xive_provision_chips = kcalloc(4, xive_provision_chip_count,
                                       GFP_KERNEL);
        if (WARN_ON(!xive_provision_chips))
                return false;
index a7dd0e5d9f98485bdecf93663f069a8cfd52067d..137f3376ac2bb05a3debbcdbe913594dbd7f54a8 100755 (executable)
@@ -24,5 +24,4 @@ echo -e "#include <linux/compiler.h>\nnotrace int func() { return 0; }" | \
     2> /dev/null | grep -q "_mcount" && \
     exit 1
 
-echo "OK"
 exit 0
index 17f19e67993b10e462abb9ad8b3e88b8da6ee5df..f12680c9b9475e2b130da3369644e797575f7a80 100644 (file)
@@ -32,6 +32,7 @@ config RISCV
        select HAVE_MEMBLOCK_NODE_MAP
        select HAVE_DMA_CONTIGUOUS
        select HAVE_GENERIC_DMA_COHERENT
+       select HAVE_PERF_EVENTS
        select IRQ_DOMAIN
        select NO_BOOTMEM
        select RISCV_ISA_A if SMP
@@ -103,9 +104,9 @@ choice
 config ARCH_RV32I
        bool "RV32I"
        select 32BIT
-       select GENERIC_ASHLDI3
-       select GENERIC_ASHRDI3
-       select GENERIC_LSHRDI3
+       select GENERIC_LIB_ASHLDI3
+       select GENERIC_LIB_ASHRDI3
+       select GENERIC_LIB_LSHRDI3
 
 config ARCH_RV64I
        bool "RV64I"
@@ -193,6 +194,19 @@ config RISCV_ISA_C
 config RISCV_ISA_A
        def_bool y
 
+menu "supported PMU type"
+       depends on PERF_EVENTS
+
+config RISCV_BASE_PMU
+       bool "Base Performance Monitoring Unit"
+       def_bool y
+       help
+         A base PMU that serves as a reference implementation and has limited
+         feature of perf.  It can run on any RISC-V machines so serves as the
+         fallback, but this option can also be disable to reduce kernel size.
+
+endmenu
+
 endmenu
 
 menu "Kernel type"
index 76e958a5414a88f9314b7bf1298eed790c1415a2..6d4a5f6c3f4f6e92b3c709520c5230da5a3826d7 100644 (file)
@@ -71,6 +71,9 @@ KBUILD_CFLAGS_MODULE += $(call cc-option,-mno-relax)
 # architectures.  It's faster to have GCC emit only aligned accesses.
 KBUILD_CFLAGS += $(call cc-option,-mstrict-align)
 
+# arch specific predefines for sparse
+CHECKFLAGS += -D__riscv -D__riscv_xlen=$(BITS)
+
 head-y := arch/riscv/kernel/head.o
 
 core-y += arch/riscv/kernel/ arch/riscv/mm/
index bca0eee733b05fc5f3217296184b57aac6f90faf..07326466871b0d74fb0c43f219bc49058f663468 100644 (file)
@@ -44,6 +44,7 @@ CONFIG_INPUT_MOUSEDEV=y
 CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_HVC_RISCV_SBI=y
 # CONFIG_PTP_1588_CLOCK is not set
 CONFIG_DRM=y
 CONFIG_DRM_RADEON=y
index 4286a5f838760c7ad4d922ddd2b49286c374df56..576ffdca06baf1d7fe51de655a63286550c93626 100644 (file)
@@ -25,6 +25,7 @@ generic-y += kdebug.h
 generic-y += kmap_types.h
 generic-y += kvm_para.h
 generic-y += local.h
+generic-y += local64.h
 generic-y += mm-arch-hooks.h
 generic-y += mman.h
 generic-y += module.h
index efd89a88d2d0e9b2bcd639a436a6143440a24d77..8f13074413a7d652729f7fc4871ac5d2a74eea3e 100644 (file)
@@ -47,7 +47,7 @@ static inline void flush_dcache_page(struct page *page)
 
 #else /* CONFIG_SMP */
 
-#define flush_icache_all() sbi_remote_fence_i(0)
+#define flush_icache_all() sbi_remote_fence_i(NULL)
 void flush_icache_mm(struct mm_struct *mm, bool local);
 
 #endif /* CONFIG_SMP */
diff --git a/arch/riscv/include/asm/perf_event.h b/arch/riscv/include/asm/perf_event.h
new file mode 100644 (file)
index 0000000..0e638a0
--- /dev/null
@@ -0,0 +1,84 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 SiFive
+ * Copyright (C) 2018 Andes Technology Corporation
+ *
+ */
+
+#ifndef _ASM_RISCV_PERF_EVENT_H
+#define _ASM_RISCV_PERF_EVENT_H
+
+#include <linux/perf_event.h>
+#include <linux/ptrace.h>
+
+#define RISCV_BASE_COUNTERS    2
+
+/*
+ * The RISCV_MAX_COUNTERS parameter should be specified.
+ */
+
+#ifdef CONFIG_RISCV_BASE_PMU
+#define RISCV_MAX_COUNTERS     2
+#endif
+
+#ifndef RISCV_MAX_COUNTERS
+#error "Please provide a valid RISCV_MAX_COUNTERS for the PMU."
+#endif
+
+/*
+ * These are the indexes of bits in counteren register *minus* 1,
+ * except for cycle.  It would be coherent if it can directly mapped
+ * to counteren bit definition, but there is a *time* register at
+ * counteren[1].  Per-cpu structure is scarce resource here.
+ *
+ * According to the spec, an implementation can support counter up to
+ * mhpmcounter31, but many high-end processors has at most 6 general
+ * PMCs, we give the definition to MHPMCOUNTER8 here.
+ */
+#define RISCV_PMU_CYCLE                0
+#define RISCV_PMU_INSTRET      1
+#define RISCV_PMU_MHPMCOUNTER3 2
+#define RISCV_PMU_MHPMCOUNTER4 3
+#define RISCV_PMU_MHPMCOUNTER5 4
+#define RISCV_PMU_MHPMCOUNTER6 5
+#define RISCV_PMU_MHPMCOUNTER7 6
+#define RISCV_PMU_MHPMCOUNTER8 7
+
+#define RISCV_OP_UNSUPP                (-EOPNOTSUPP)
+
+struct cpu_hw_events {
+       /* # currently enabled events*/
+       int                     n_events;
+       /* currently enabled events */
+       struct perf_event       *events[RISCV_MAX_COUNTERS];
+       /* vendor-defined PMU data */
+       void                    *platform;
+};
+
+struct riscv_pmu {
+       struct pmu      *pmu;
+
+       /* generic hw/cache events table */
+       const int       *hw_events;
+       const int       (*cache_events)[PERF_COUNT_HW_CACHE_MAX]
+                                      [PERF_COUNT_HW_CACHE_OP_MAX]
+                                      [PERF_COUNT_HW_CACHE_RESULT_MAX];
+       /* method used to map hw/cache events */
+       int             (*map_hw_event)(u64 config);
+       int             (*map_cache_event)(u64 config);
+
+       /* max generic hw events in map */
+       int             max_events;
+       /* number total counters, 2(base) + x(general) */
+       int             num_counters;
+       /* the width of the counter */
+       int             counter_width;
+
+       /* vendor-defined PMU features */
+       void            *platform;
+
+       irqreturn_t     (*handle_irq)(int irq_num, void *dev);
+       int             irq;
+};
+
+#endif /* _ASM_RISCV_PERF_EVENT_H */
index 7b209aec355db5edeff57c186f542ad4ac44c894..85c2d8bae9571ab2c3557b34b04b59d3355733a6 100644 (file)
@@ -49,7 +49,7 @@ static inline void flush_tlb_range(struct vm_area_struct *vma,
 
 #include <asm/sbi.h>
 
-#define flush_tlb_all() sbi_remote_sfence_vma(0, 0, -1)
+#define flush_tlb_all() sbi_remote_sfence_vma(NULL, 0, -1)
 #define flush_tlb_page(vma, addr) flush_tlb_range(vma, addr, 0)
 #define flush_tlb_range(vma, start, end) \
        sbi_remote_sfence_vma(mm_cpumask((vma)->vm_mm)->bits, \
index 14b0b22fb57875dfe920685265a79da317c517e0..473cfc84e412f3827703caaadffa34a8983c978d 100644 (file)
@@ -392,19 +392,21 @@ do {                                                              \
 })
 
 
-extern unsigned long __must_check __copy_user(void __user *to,
+extern unsigned long __must_check __asm_copy_to_user(void __user *to,
+       const void *from, unsigned long n);
+extern unsigned long __must_check __asm_copy_from_user(void *to,
        const void __user *from, unsigned long n);
 
 static inline unsigned long
 raw_copy_from_user(void *to, const void __user *from, unsigned long n)
 {
-       return __copy_user(to, from, n);
+       return __asm_copy_to_user(to, from, n);
 }
 
 static inline unsigned long
 raw_copy_to_user(void __user *to, const void *from, unsigned long n)
 {
-       return __copy_user(to, from, n);
+       return __asm_copy_from_user(to, from, n);
 }
 
 extern long strncpy_from_user(char *dest, const char __user *src, long count);
index 8586dd96c2f012ca42af358c0ab58cd2ce277322..e1274fc03af42de6b0a98fe0911e98d14db4dec8 100644 (file)
@@ -39,4 +39,6 @@ obj-$(CONFIG_MODULE_SECTIONS) += module-sections.o
 obj-$(CONFIG_FUNCTION_TRACER)  += mcount.o ftrace.o
 obj-$(CONFIG_DYNAMIC_FTRACE)   += mcount-dyn.o
 
+obj-$(CONFIG_PERF_EVENTS)      += perf_event.o
+
 clean:
index ce9bdc57a2a161b1ab16b8a593b031a0e2df72ed..5721624886a1cc8f0af054da3bec133b53de0381 100644 (file)
@@ -126,5 +126,5 @@ do_trace:
        RESTORE_ABI_STATE
        ret
 ENDPROC(_mcount)
-EXPORT_SYMBOL(_mcount)
 #endif
+EXPORT_SYMBOL(_mcount)
index 5dddba301d0a726ff78e97acca1b051c123a8bb7..1d5e9b934b8ca5b5b78a64af5e1c06e334b7e5f2 100644 (file)
 #include <linux/errno.h>
 #include <linux/moduleloader.h>
 
+static int apply_r_riscv_32_rela(struct module *me, u32 *location, Elf_Addr v)
+{
+       if (v != (u32)v) {
+               pr_err("%s: value %016llx out of range for 32-bit field\n",
+                      me->name, v);
+               return -EINVAL;
+       }
+       *location = v;
+       return 0;
+}
+
 static int apply_r_riscv_64_rela(struct module *me, u32 *location, Elf_Addr v)
 {
        *(u64 *)location = v;
@@ -265,6 +276,7 @@ static int apply_r_riscv_sub32_rela(struct module *me, u32 *location,
 
 static int (*reloc_handlers_rela[]) (struct module *me, u32 *location,
                                Elf_Addr v) = {
+       [R_RISCV_32]                    = apply_r_riscv_32_rela,
        [R_RISCV_64]                    = apply_r_riscv_64_rela,
        [R_RISCV_BRANCH]                = apply_r_riscv_branch_rela,
        [R_RISCV_JAL]                   = apply_r_riscv_jal_rela,
diff --git a/arch/riscv/kernel/perf_event.c b/arch/riscv/kernel/perf_event.c
new file mode 100644 (file)
index 0000000..b0e10c4
--- /dev/null
@@ -0,0 +1,485 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2008 Thomas Gleixner <tglx@linutronix.de>
+ * Copyright (C) 2008-2009 Red Hat, Inc., Ingo Molnar
+ * Copyright (C) 2009 Jaswinder Singh Rajput
+ * Copyright (C) 2009 Advanced Micro Devices, Inc., Robert Richter
+ * Copyright (C) 2008-2009 Red Hat, Inc., Peter Zijlstra
+ * Copyright (C) 2009 Intel Corporation, <markus.t.metzger@intel.com>
+ * Copyright (C) 2009 Google, Inc., Stephane Eranian
+ * Copyright 2014 Tilera Corporation. All Rights Reserved.
+ * Copyright (C) 2018 Andes Technology Corporation
+ *
+ * Perf_events support for RISC-V platforms.
+ *
+ * Since the spec. (as of now, Priv-Spec 1.10) does not provide enough
+ * functionality for perf event to fully work, this file provides
+ * the very basic framework only.
+ *
+ * For platform portings, please check Documentations/riscv/pmu.txt.
+ *
+ * The Copyright line includes x86 and tile ones.
+ */
+
+#include <linux/kprobes.h>
+#include <linux/kernel.h>
+#include <linux/kdebug.h>
+#include <linux/mutex.h>
+#include <linux/bitmap.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <linux/perf_event.h>
+#include <linux/atomic.h>
+#include <linux/of.h>
+#include <asm/perf_event.h>
+
+static const struct riscv_pmu *riscv_pmu __read_mostly;
+static DEFINE_PER_CPU(struct cpu_hw_events, cpu_hw_events);
+
+/*
+ * Hardware & cache maps and their methods
+ */
+
+static const int riscv_hw_event_map[] = {
+       [PERF_COUNT_HW_CPU_CYCLES]              = RISCV_PMU_CYCLE,
+       [PERF_COUNT_HW_INSTRUCTIONS]            = RISCV_PMU_INSTRET,
+       [PERF_COUNT_HW_CACHE_REFERENCES]        = RISCV_OP_UNSUPP,
+       [PERF_COUNT_HW_CACHE_MISSES]            = RISCV_OP_UNSUPP,
+       [PERF_COUNT_HW_BRANCH_INSTRUCTIONS]     = RISCV_OP_UNSUPP,
+       [PERF_COUNT_HW_BRANCH_MISSES]           = RISCV_OP_UNSUPP,
+       [PERF_COUNT_HW_BUS_CYCLES]              = RISCV_OP_UNSUPP,
+};
+
+#define C(x) PERF_COUNT_HW_CACHE_##x
+static const int riscv_cache_event_map[PERF_COUNT_HW_CACHE_MAX]
+[PERF_COUNT_HW_CACHE_OP_MAX]
+[PERF_COUNT_HW_CACHE_RESULT_MAX] = {
+       [C(L1D)] = {
+               [C(OP_READ)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_WRITE)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_PREFETCH)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+       },
+       [C(L1I)] = {
+               [C(OP_READ)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_WRITE)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_PREFETCH)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+       },
+       [C(LL)] = {
+               [C(OP_READ)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_WRITE)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_PREFETCH)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+       },
+       [C(DTLB)] = {
+               [C(OP_READ)] = {
+                       [C(RESULT_ACCESS)] =  RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] =  RISCV_OP_UNSUPP,
+               },
+               [C(OP_WRITE)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_PREFETCH)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+       },
+       [C(ITLB)] = {
+               [C(OP_READ)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_WRITE)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_PREFETCH)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+       },
+       [C(BPU)] = {
+               [C(OP_READ)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_WRITE)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+               [C(OP_PREFETCH)] = {
+                       [C(RESULT_ACCESS)] = RISCV_OP_UNSUPP,
+                       [C(RESULT_MISS)] = RISCV_OP_UNSUPP,
+               },
+       },
+};
+
+static int riscv_map_hw_event(u64 config)
+{
+       if (config >= riscv_pmu->max_events)
+               return -EINVAL;
+
+       return riscv_pmu->hw_events[config];
+}
+
+int riscv_map_cache_decode(u64 config, unsigned int *type,
+                          unsigned int *op, unsigned int *result)
+{
+       return -ENOENT;
+}
+
+static int riscv_map_cache_event(u64 config)
+{
+       unsigned int type, op, result;
+       int err = -ENOENT;
+               int code;
+
+       err = riscv_map_cache_decode(config, &type, &op, &result);
+       if (!riscv_pmu->cache_events || err)
+               return err;
+
+       if (type >= PERF_COUNT_HW_CACHE_MAX ||
+           op >= PERF_COUNT_HW_CACHE_OP_MAX ||
+           result >= PERF_COUNT_HW_CACHE_RESULT_MAX)
+               return -EINVAL;
+
+       code = (*riscv_pmu->cache_events)[type][op][result];
+       if (code == RISCV_OP_UNSUPP)
+               return -EINVAL;
+
+       return code;
+}
+
+/*
+ * Low-level functions: reading/writing counters
+ */
+
+static inline u64 read_counter(int idx)
+{
+       u64 val = 0;
+
+       switch (idx) {
+       case RISCV_PMU_CYCLE:
+               val = csr_read(cycle);
+               break;
+       case RISCV_PMU_INSTRET:
+               val = csr_read(instret);
+               break;
+       default:
+               WARN_ON_ONCE(idx < 0 || idx > RISCV_MAX_COUNTERS);
+               return -EINVAL;
+       }
+
+       return val;
+}
+
+static inline void write_counter(int idx, u64 value)
+{
+       /* currently not supported */
+       WARN_ON_ONCE(1);
+}
+
+/*
+ * pmu->read: read and update the counter
+ *
+ * Other architectures' implementation often have a xxx_perf_event_update
+ * routine, which can return counter values when called in the IRQ, but
+ * return void when being called by the pmu->read method.
+ */
+static void riscv_pmu_read(struct perf_event *event)
+{
+       struct hw_perf_event *hwc = &event->hw;
+       u64 prev_raw_count, new_raw_count;
+       u64 oldval;
+       int idx = hwc->idx;
+       u64 delta;
+
+       do {
+               prev_raw_count = local64_read(&hwc->prev_count);
+               new_raw_count = read_counter(idx);
+
+               oldval = local64_cmpxchg(&hwc->prev_count, prev_raw_count,
+                                        new_raw_count);
+       } while (oldval != prev_raw_count);
+
+       /*
+        * delta is the value to update the counter we maintain in the kernel.
+        */
+       delta = (new_raw_count - prev_raw_count) &
+               ((1ULL << riscv_pmu->counter_width) - 1);
+       local64_add(delta, &event->count);
+       /*
+        * Something like local64_sub(delta, &hwc->period_left) here is
+        * needed if there is an interrupt for perf.
+        */
+}
+
+/*
+ * State transition functions:
+ *
+ * stop()/start() & add()/del()
+ */
+
+/*
+ * pmu->stop: stop the counter
+ */
+static void riscv_pmu_stop(struct perf_event *event, int flags)
+{
+       struct hw_perf_event *hwc = &event->hw;
+
+       WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED);
+       hwc->state |= PERF_HES_STOPPED;
+
+       if ((flags & PERF_EF_UPDATE) && !(hwc->state & PERF_HES_UPTODATE)) {
+               riscv_pmu->pmu->read(event);
+               hwc->state |= PERF_HES_UPTODATE;
+       }
+}
+
+/*
+ * pmu->start: start the event.
+ */
+static void riscv_pmu_start(struct perf_event *event, int flags)
+{
+       struct hw_perf_event *hwc = &event->hw;
+
+       if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED)))
+               return;
+
+       if (flags & PERF_EF_RELOAD) {
+               WARN_ON_ONCE(!(event->hw.state & PERF_HES_UPTODATE));
+
+               /*
+                * Set the counter to the period to the next interrupt here,
+                * if you have any.
+                */
+       }
+
+       hwc->state = 0;
+       perf_event_update_userpage(event);
+
+       /*
+        * Since we cannot write to counters, this serves as an initialization
+        * to the delta-mechanism in pmu->read(); otherwise, the delta would be
+        * wrong when pmu->read is called for the first time.
+        */
+       local64_set(&hwc->prev_count, read_counter(hwc->idx));
+}
+
+/*
+ * pmu->add: add the event to PMU.
+ */
+static int riscv_pmu_add(struct perf_event *event, int flags)
+{
+       struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
+       struct hw_perf_event *hwc = &event->hw;
+
+       if (cpuc->n_events == riscv_pmu->num_counters)
+               return -ENOSPC;
+
+       /*
+        * We don't have general conunters, so no binding-event-to-counter
+        * process here.
+        *
+        * Indexing using hwc->config generally not works, since config may
+        * contain extra information, but here the only info we have in
+        * hwc->config is the event index.
+        */
+       hwc->idx = hwc->config;
+       cpuc->events[hwc->idx] = event;
+       cpuc->n_events++;
+
+       hwc->state = PERF_HES_UPTODATE | PERF_HES_STOPPED;
+
+       if (flags & PERF_EF_START)
+               riscv_pmu->pmu->start(event, PERF_EF_RELOAD);
+
+       return 0;
+}
+
+/*
+ * pmu->del: delete the event from PMU.
+ */
+static void riscv_pmu_del(struct perf_event *event, int flags)
+{
+       struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
+       struct hw_perf_event *hwc = &event->hw;
+
+       cpuc->events[hwc->idx] = NULL;
+       cpuc->n_events--;
+       riscv_pmu->pmu->stop(event, PERF_EF_UPDATE);
+       perf_event_update_userpage(event);
+}
+
+/*
+ * Interrupt: a skeletion for reference.
+ */
+
+static DEFINE_MUTEX(pmc_reserve_mutex);
+
+irqreturn_t riscv_base_pmu_handle_irq(int irq_num, void *dev)
+{
+       return IRQ_NONE;
+}
+
+static int reserve_pmc_hardware(void)
+{
+       int err = 0;
+
+       mutex_lock(&pmc_reserve_mutex);
+       if (riscv_pmu->irq >= 0 && riscv_pmu->handle_irq) {
+               err = request_irq(riscv_pmu->irq, riscv_pmu->handle_irq,
+                                 IRQF_PERCPU, "riscv-base-perf", NULL);
+       }
+       mutex_unlock(&pmc_reserve_mutex);
+
+       return err;
+}
+
+void release_pmc_hardware(void)
+{
+       mutex_lock(&pmc_reserve_mutex);
+       if (riscv_pmu->irq >= 0)
+               free_irq(riscv_pmu->irq, NULL);
+       mutex_unlock(&pmc_reserve_mutex);
+}
+
+/*
+ * Event Initialization/Finalization
+ */
+
+static atomic_t riscv_active_events = ATOMIC_INIT(0);
+
+static void riscv_event_destroy(struct perf_event *event)
+{
+       if (atomic_dec_return(&riscv_active_events) == 0)
+               release_pmc_hardware();
+}
+
+static int riscv_event_init(struct perf_event *event)
+{
+       struct perf_event_attr *attr = &event->attr;
+       struct hw_perf_event *hwc = &event->hw;
+       int err;
+       int code;
+
+       if (atomic_inc_return(&riscv_active_events) == 1) {
+               err = reserve_pmc_hardware();
+
+               if (err) {
+                       pr_warn("PMC hardware not available\n");
+                       atomic_dec(&riscv_active_events);
+                       return -EBUSY;
+               }
+       }
+
+       switch (event->attr.type) {
+       case PERF_TYPE_HARDWARE:
+               code = riscv_pmu->map_hw_event(attr->config);
+               break;
+       case PERF_TYPE_HW_CACHE:
+               code = riscv_pmu->map_cache_event(attr->config);
+               break;
+       case PERF_TYPE_RAW:
+               return -EOPNOTSUPP;
+       default:
+               return -ENOENT;
+       }
+
+       event->destroy = riscv_event_destroy;
+       if (code < 0) {
+               event->destroy(event);
+               return code;
+       }
+
+       /*
+        * idx is set to -1 because the index of a general event should not be
+        * decided until binding to some counter in pmu->add().
+        *
+        * But since we don't have such support, later in pmu->add(), we just
+        * use hwc->config as the index instead.
+        */
+       hwc->config = code;
+       hwc->idx = -1;
+
+       return 0;
+}
+
+/*
+ * Initialization
+ */
+
+static struct pmu min_pmu = {
+       .name           = "riscv-base",
+       .event_init     = riscv_event_init,
+       .add            = riscv_pmu_add,
+       .del            = riscv_pmu_del,
+       .start          = riscv_pmu_start,
+       .stop           = riscv_pmu_stop,
+       .read           = riscv_pmu_read,
+};
+
+static const struct riscv_pmu riscv_base_pmu = {
+       .pmu = &min_pmu,
+       .max_events = ARRAY_SIZE(riscv_hw_event_map),
+       .map_hw_event = riscv_map_hw_event,
+       .hw_events = riscv_hw_event_map,
+       .map_cache_event = riscv_map_cache_event,
+       .cache_events = &riscv_cache_event_map,
+       .counter_width = 63,
+       .num_counters = RISCV_BASE_COUNTERS + 0,
+       .handle_irq = &riscv_base_pmu_handle_irq,
+
+       /* This means this PMU has no IRQ. */
+       .irq = -1,
+};
+
+static const struct of_device_id riscv_pmu_of_ids[] = {
+       {.compatible = "riscv,base-pmu",        .data = &riscv_base_pmu},
+       { /* sentinel value */ }
+};
+
+int __init init_hw_perf_events(void)
+{
+       struct device_node *node = of_find_node_by_type(NULL, "pmu");
+       const struct of_device_id *of_id;
+
+       riscv_pmu = &riscv_base_pmu;
+
+       if (node) {
+               of_id = of_match_node(riscv_pmu_of_ids, node);
+
+               if (of_id)
+                       riscv_pmu = of_id->data;
+       }
+
+       perf_pmu_register(riscv_pmu->pmu, "cpu", PERF_TYPE_RAW);
+       return 0;
+}
+arch_initcall(init_hw_perf_events);
index 5517342487489b6ee35c4a95bbfa3d5c4a31f2aa..f247d6d2137c4515678052565b1ab43a29c523e2 100644 (file)
@@ -13,6 +13,7 @@
  * Assembly functions that may be used (directly or indirectly) by modules
  */
 EXPORT_SYMBOL(__clear_user);
-EXPORT_SYMBOL(__copy_user);
+EXPORT_SYMBOL(__asm_copy_to_user);
+EXPORT_SYMBOL(__asm_copy_from_user);
 EXPORT_SYMBOL(memset);
 EXPORT_SYMBOL(memcpy);
index b99d9dd21fd0bfdbe837969d22b01f4f220cc184..81a1952015a6556d3428f6e3ab3b541d7f371bfa 100644 (file)
@@ -148,7 +148,7 @@ int is_valid_bugaddr(unsigned long pc)
 
        if (pc < PAGE_OFFSET)
                return 0;
-       if (probe_kernel_address((bug_insn_t __user *)pc, insn))
+       if (probe_kernel_address((bug_insn_t *)pc, insn))
                return 0;
        return (insn == __BUG_INSN);
 }
index 58fb2877c865286a32894d343f483202f28c229e..399e6f0c2d98ee7be7926c490f3b356f2053f7d0 100644 (file)
@@ -13,7 +13,8 @@ _epc:
        .previous
        .endm
 
-ENTRY(__copy_user)
+ENTRY(__asm_copy_to_user)
+ENTRY(__asm_copy_from_user)
 
        /* Enable access to user memory */
        li t6, SR_SUM
@@ -63,7 +64,8 @@ ENTRY(__copy_user)
        addi a0, a0, 1
        bltu a1, a3, 5b
        j 3b
-ENDPROC(__copy_user)
+ENDPROC(__asm_copy_to_user)
+ENDPROC(__asm_copy_from_user)
 
 
 ENTRY(__clear_user)
@@ -84,7 +86,7 @@ ENTRY(__clear_user)
        bgeu t0, t1, 2f
        bltu a0, t0, 4f
 1:
-       fixup REG_S, zero, (a0), 10f
+       fixup REG_S, zero, (a0), 11f
        addi a0, a0, SZREG
        bltu a0, t1, 1b
 2:
@@ -96,12 +98,12 @@ ENTRY(__clear_user)
        li a0, 0
        ret
 4: /* Edge case: unalignment */
-       fixup sb, zero, (a0), 10f
+       fixup sb, zero, (a0), 11f
        addi a0, a0, 1
        bltu a0, t0, 4b
        j 1b
 5: /* Edge case: remainder */
-       fixup sb, zero, (a0), 10f
+       fixup sb, zero, (a0), 11f
        addi a0, a0, 1
        bltu a0, a3, 5b
        j 3b
@@ -109,9 +111,14 @@ ENDPROC(__clear_user)
 
        .section .fixup,"ax"
        .balign 4
+       /* Fixup code for __copy_user(10) and __clear_user(11) */
 10:
        /* Disable access to user memory */
        csrs sstatus, t6
-       sub a0, a3, a0
+       mv a0, a2
+       ret
+11:
+       csrs sstatus, t6
+       mv a0, a1
        ret
        .previous
index cb6e8066b1ad64b1a65ee441e3c1fb53e5599a8b..ee6a9c387c8796cb8bc035c052d0806f6cec4dae 100644 (file)
@@ -391,7 +391,7 @@ int appldata_register_ops(struct appldata_ops *ops)
        if (ops->size > APPLDATA_MAX_REC_SIZE)
                return -EINVAL;
 
-       ops->ctl_table = kzalloc(4 * sizeof(struct ctl_table), GFP_KERNEL);
+       ops->ctl_table = kcalloc(4, sizeof(struct ctl_table), GFP_KERNEL);
        if (!ops->ctl_table)
                return -ENOMEM;
 
index be8cc53204b5088425af0f79d23bff276bc0b1c8..a2945b289a2928b5fd94b2ad0a85a93920423ed7 100644 (file)
@@ -239,7 +239,7 @@ static void *page_align_ptr(void *ptr)
 static void *diag204_alloc_vbuf(int pages)
 {
        /* The buffer has to be page aligned! */
-       diag204_buf_vmalloc = vmalloc(PAGE_SIZE * (pages + 1));
+       diag204_buf_vmalloc = vmalloc(array_size(PAGE_SIZE, (pages + 1)));
        if (!diag204_buf_vmalloc)
                return ERR_PTR(-ENOMEM);
        diag204_buf = page_align_ptr(diag204_buf_vmalloc);
index dce87f1bec94672b31b633c9f02098f565fa9b25..cebf05150cc17e5757dbcb859e20a887f16d8845 100644 (file)
@@ -49,7 +49,8 @@ static void *diag0c_store(unsigned int *count)
 
        get_online_cpus();
        cpu_count = num_online_cpus();
-       cpu_vec = kmalloc(sizeof(*cpu_vec) * num_possible_cpus(), GFP_KERNEL);
+       cpu_vec = kmalloc_array(num_possible_cpus(), sizeof(*cpu_vec),
+                               GFP_KERNEL);
        if (!cpu_vec)
                goto fail_put_online_cpus;
        /* Note: Diag 0c needs 8 byte alignment and real storage */
index 99c93d0346f9feda966ec81f3a881035712d5528..4600453536c2bc0e6842ac7e46cfc8b6ef10cea6 100644 (file)
 
 #include <linux/const.h>
 
+#define CR0_CLOCK_COMPARATOR_SIGN      _BITUL(63 - 10)
+#define CR0_EMERGENCY_SIGNAL_SUBMASK   _BITUL(63 - 49)
+#define CR0_EXTERNAL_CALL_SUBMASK      _BITUL(63 - 50)
+#define CR0_CLOCK_COMPARATOR_SUBMASK   _BITUL(63 - 52)
+#define CR0_CPU_TIMER_SUBMASK          _BITUL(63 - 53)
+#define CR0_SERVICE_SIGNAL_SUBMASK     _BITUL(63 - 54)
+#define CR0_UNUSED_56                  _BITUL(63 - 56)
+#define CR0_INTERRUPT_KEY_SUBMASK      _BITUL(63 - 57)
+#define CR0_MEASUREMENT_ALERT_SUBMASK  _BITUL(63 - 58)
+
 #define CR2_GUARDED_STORAGE            _BITUL(63 - 59)
 
+#define CR14_UNUSED_32                 _BITUL(63 - 32)
+#define CR14_UNUSED_33                 _BITUL(63 - 33)
 #define CR14_CHANNEL_REPORT_SUBMASK    _BITUL(63 - 35)
 #define CR14_RECOVERY_SUBMASK          _BITUL(63 - 36)
 #define CR14_DEGRADATION_SUBMASK       _BITUL(63 - 37)
index 81cdb6b5511840ae39721c24ea386ed881670011..a2188e309bd6faedb524510198ec9671e20494cf 100644 (file)
@@ -812,6 +812,7 @@ struct kvm_arch{
        int use_irqchip;
        int use_cmma;
        int use_pfmfi;
+       int use_skf;
        int user_cpu_state_ctrl;
        int user_sigp;
        int user_stsi;
index c639c95850e469de3f834d93d3b66317d7d8a418..f5ff9dbad8ac9590a1bbdfc80979bc1c74cf8ede 100644 (file)
@@ -21,7 +21,7 @@ typedef struct {
        /* The mmu context uses extended page tables. */
        unsigned int has_pgste:1;
        /* The mmu context uses storage keys. */
-       unsigned int use_skey:1;
+       unsigned int uses_skeys:1;
        /* The mmu context uses CMM. */
        unsigned int uses_cmm:1;
 } mm_context_t;
index 324f6f452982ca9ce9844c9818943fbc0c5766cd..d16bc79c30bbfe216b4d7f662e972f60631f055f 100644 (file)
@@ -30,7 +30,7 @@ static inline int init_new_context(struct task_struct *tsk,
                test_thread_flag(TIF_PGSTE) ||
                (current->mm && current->mm->context.alloc_pgste);
        mm->context.has_pgste = 0;
-       mm->context.use_skey = 0;
+       mm->context.uses_skeys = 0;
        mm->context.uses_cmm = 0;
 #endif
        switch (mm->context.asce_limit) {
index 9809694e1389ef836f4d5ea1eb4d9b08be5e1260..5ab636089c6052c51cb5ac15046ee0975bcfd026 100644 (file)
@@ -506,10 +506,10 @@ static inline int mm_alloc_pgste(struct mm_struct *mm)
  * faults should no longer be backed by zero pages
  */
 #define mm_forbids_zeropage mm_has_pgste
-static inline int mm_use_skey(struct mm_struct *mm)
+static inline int mm_uses_skeys(struct mm_struct *mm)
 {
 #ifdef CONFIG_PGSTE
-       if (mm->context.use_skey)
+       if (mm->context.uses_skeys)
                return 1;
 #endif
        return 0;
index 80e974adb9e8be39d4ab558495eb69d110a2b3a3..d374f9b218b4c278101ebcd451c7304c0ef390a0 100644 (file)
@@ -194,11 +194,13 @@ static debug_entry_t ***debug_areas_alloc(int pages_per_area, int nr_areas)
        debug_entry_t ***areas;
        int i, j;
 
-       areas = kmalloc(nr_areas * sizeof(debug_entry_t **), GFP_KERNEL);
+       areas = kmalloc_array(nr_areas, sizeof(debug_entry_t **), GFP_KERNEL);
        if (!areas)
                goto fail_malloc_areas;
        for (i = 0; i < nr_areas; i++) {
-               areas[i] = kmalloc(pages_per_area * sizeof(debug_entry_t *), GFP_KERNEL);
+               areas[i] = kmalloc_array(pages_per_area,
+                                        sizeof(debug_entry_t *),
+                                        GFP_KERNEL);
                if (!areas[i])
                        goto fail_malloc_areas2;
                for (j = 0; j < pages_per_area; j++) {
index 0dc8ac8548ee3f32904038b41b5b30517516bf41..d298d3cb46d0e716c7093324f0e04bc6b5f7b593 100644 (file)
@@ -123,8 +123,8 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
 
        /* Allocate one syminfo structure per symbol. */
        me->arch.nsyms = symtab->sh_size / sizeof(Elf_Sym);
-       me->arch.syminfo = vmalloc(me->arch.nsyms *
-                                  sizeof(struct mod_arch_syminfo));
+       me->arch.syminfo = vmalloc(array_size(sizeof(struct mod_arch_syminfo),
+                                             me->arch.nsyms));
        if (!me->arch.syminfo)
                return -ENOMEM;
        symbols = (void *) hdr + symtab->sh_offset;
index feebb294488203b77899f5415f841e12cefedf29..d63fb3c56b8ad891ac05ce725214d59a2dd4d72a 100644 (file)
@@ -527,7 +527,7 @@ static __init struct attribute **merge_attr(struct attribute **a,
                j++;
        j++;
 
-       new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
+       new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL);
        if (!new)
                return NULL;
        j = 0;
index 80b862e9c53c6b108e611935ab8dd7c9b794ff13..0859cde36f7520616e62df133c2f88df69a47e27 100644 (file)
@@ -315,7 +315,7 @@ static void fill_diag(struct sthyi_sctns *sctns)
        if (pages <= 0)
                return;
 
-       diag204_buf = vmalloc(PAGE_SIZE * pages);
+       diag204_buf = vmalloc(array_size(pages, PAGE_SIZE));
        if (!diag204_buf)
                return;
 
index f3a1c7c6824ef0da8933fbb64864fdf5b97bd99a..09abae40f9178a9d8789d9ef647fc85b74fcc82b 100644 (file)
@@ -285,7 +285,7 @@ static int __init vdso_init(void)
                         + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
 
        /* Make sure pages are in the correct state */
-       vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 1),
+       vdso32_pagelist = kcalloc(vdso32_pages + 1, sizeof(struct page *),
                                  GFP_KERNEL);
        BUG_ON(vdso32_pagelist == NULL);
        for (i = 0; i < vdso32_pages - 1; i++) {
@@ -303,7 +303,7 @@ static int __init vdso_init(void)
                         + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
 
        /* Make sure pages are in the correct state */
-       vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 1),
+       vdso64_pagelist = kcalloc(vdso64_pages + 1, sizeof(struct page *),
                                  GFP_KERNEL);
        BUG_ON(vdso64_pagelist == NULL);
        for (i = 0; i < vdso64_pages - 1; i++) {
index 8e2b8647ee124b3253cd71f75d35f8623f97d5c8..07d30ffcfa4129522ae0592ccd57e5c0e65b97bd 100644 (file)
@@ -847,7 +847,7 @@ int access_guest(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar, void *data,
        nr_pages = (((ga & ~PAGE_MASK) + len - 1) >> PAGE_SHIFT) + 1;
        pages = pages_array;
        if (nr_pages > ARRAY_SIZE(pages_array))
-               pages = vmalloc(nr_pages * sizeof(unsigned long));
+               pages = vmalloc(array_size(nr_pages, sizeof(unsigned long)));
        if (!pages)
                return -ENOMEM;
        need_ipte_lock = psw_bits(*psw).dat && !asce.r;
index b5f3e82006d0b2e2d8806e8a7e5e58e559255e5b..394a5f53805baab46a56603fbec92da33a42ca80 100644 (file)
@@ -153,7 +153,7 @@ void kvm_s390_patch_guest_per_regs(struct kvm_vcpu *vcpu)
 
        if (guestdbg_sstep_enabled(vcpu)) {
                /* disable timer (clock-comparator) interrupts */
-               vcpu->arch.sie_block->gcr[0] &= ~0x800ul;
+               vcpu->arch.sie_block->gcr[0] &= ~CR0_CLOCK_COMPARATOR_SUBMASK;
                vcpu->arch.sie_block->gcr[9] |= PER_EVENT_IFETCH;
                vcpu->arch.sie_block->gcr[10] = 0;
                vcpu->arch.sie_block->gcr[11] = -1UL;
index 37d06e022238001fa41bceae30d4f28423af6046..daa09f89ca2de66af6f1b0fc79da3a71cce4dc27 100644 (file)
@@ -159,7 +159,7 @@ static int psw_interrupts_disabled(struct kvm_vcpu *vcpu)
 static int ckc_interrupts_enabled(struct kvm_vcpu *vcpu)
 {
        if (psw_extint_disabled(vcpu) ||
-           !(vcpu->arch.sie_block->gcr[0] & 0x800ul))
+           !(vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SUBMASK))
                return 0;
        if (guestdbg_enabled(vcpu) && guestdbg_sstep_enabled(vcpu))
                /* No timer interrupts when single stepping */
@@ -172,7 +172,7 @@ static int ckc_irq_pending(struct kvm_vcpu *vcpu)
        const u64 now = kvm_s390_get_tod_clock_fast(vcpu->kvm);
        const u64 ckc = vcpu->arch.sie_block->ckc;
 
-       if (vcpu->arch.sie_block->gcr[0] & 0x0020000000000000ul) {
+       if (vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SIGN) {
                if ((s64)ckc >= (s64)now)
                        return 0;
        } else if (ckc >= now) {
@@ -184,7 +184,7 @@ static int ckc_irq_pending(struct kvm_vcpu *vcpu)
 static int cpu_timer_interrupts_enabled(struct kvm_vcpu *vcpu)
 {
        return !psw_extint_disabled(vcpu) &&
-              (vcpu->arch.sie_block->gcr[0] & 0x400ul);
+              (vcpu->arch.sie_block->gcr[0] & CR0_CPU_TIMER_SUBMASK);
 }
 
 static int cpu_timer_irq_pending(struct kvm_vcpu *vcpu)
@@ -285,15 +285,15 @@ static unsigned long deliverable_irqs(struct kvm_vcpu *vcpu)
                active_mask &= ~IRQ_PEND_IO_MASK;
        else
                active_mask = disable_iscs(vcpu, active_mask);
-       if (!(vcpu->arch.sie_block->gcr[0] & 0x2000ul))
+       if (!(vcpu->arch.sie_block->gcr[0] & CR0_EXTERNAL_CALL_SUBMASK))
                __clear_bit(IRQ_PEND_EXT_EXTERNAL, &active_mask);
-       if (!(vcpu->arch.sie_block->gcr[0] & 0x4000ul))
+       if (!(vcpu->arch.sie_block->gcr[0] & CR0_EMERGENCY_SIGNAL_SUBMASK))
                __clear_bit(IRQ_PEND_EXT_EMERGENCY, &active_mask);
-       if (!(vcpu->arch.sie_block->gcr[0] & 0x800ul))
+       if (!(vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SUBMASK))
                __clear_bit(IRQ_PEND_EXT_CLOCK_COMP, &active_mask);
-       if (!(vcpu->arch.sie_block->gcr[0] & 0x400ul))
+       if (!(vcpu->arch.sie_block->gcr[0] & CR0_CPU_TIMER_SUBMASK))
                __clear_bit(IRQ_PEND_EXT_CPU_TIMER, &active_mask);
-       if (!(vcpu->arch.sie_block->gcr[0] & 0x200ul))
+       if (!(vcpu->arch.sie_block->gcr[0] & CR0_SERVICE_SIGNAL_SUBMASK))
                __clear_bit(IRQ_PEND_EXT_SERVICE, &active_mask);
        if (psw_mchk_disabled(vcpu))
                active_mask &= ~IRQ_PEND_MCHK_MASK;
@@ -1042,7 +1042,7 @@ int kvm_s390_vcpu_has_irq(struct kvm_vcpu *vcpu, int exclude_stop)
        /* external call pending and deliverable */
        if (kvm_s390_ext_call_pending(vcpu) &&
            !psw_extint_disabled(vcpu) &&
-           (vcpu->arch.sie_block->gcr[0] & 0x2000ul))
+           (vcpu->arch.sie_block->gcr[0] & CR0_EXTERNAL_CALL_SUBMASK))
                return 1;
 
        if (!exclude_stop && kvm_s390_is_stop_irq_pending(vcpu))
@@ -1062,7 +1062,7 @@ static u64 __calculate_sltime(struct kvm_vcpu *vcpu)
        u64 cputm, sltime = 0;
 
        if (ckc_interrupts_enabled(vcpu)) {
-               if (vcpu->arch.sie_block->gcr[0] & 0x0020000000000000ul) {
+               if (vcpu->arch.sie_block->gcr[0] & CR0_CLOCK_COMPARATOR_SIGN) {
                        if ((s64)now < (s64)ckc)
                                sltime = tod_to_ns((s64)ckc - (s64)now);
                } else if (now < ckc) {
index 64c9862430187b90e132ce96cb51a410c6fabff9..3b7a5151b6a5effa6dabc5aa95ac027a4af53198 100644 (file)
@@ -791,11 +791,21 @@ static int kvm_s390_set_mem_control(struct kvm *kvm, struct kvm_device_attr *att
 
 static void kvm_s390_vcpu_crypto_setup(struct kvm_vcpu *vcpu);
 
-static int kvm_s390_vm_set_crypto(struct kvm *kvm, struct kvm_device_attr *attr)
+void kvm_s390_vcpu_crypto_reset_all(struct kvm *kvm)
 {
        struct kvm_vcpu *vcpu;
        int i;
 
+       kvm_s390_vcpu_block_all(kvm);
+
+       kvm_for_each_vcpu(i, vcpu, kvm)
+               kvm_s390_vcpu_crypto_setup(vcpu);
+
+       kvm_s390_vcpu_unblock_all(kvm);
+}
+
+static int kvm_s390_vm_set_crypto(struct kvm *kvm, struct kvm_device_attr *attr)
+{
        if (!test_kvm_facility(kvm, 76))
                return -EINVAL;
 
@@ -832,10 +842,7 @@ static int kvm_s390_vm_set_crypto(struct kvm *kvm, struct kvm_device_attr *attr)
                return -ENXIO;
        }
 
-       kvm_for_each_vcpu(i, vcpu, kvm) {
-               kvm_s390_vcpu_crypto_setup(vcpu);
-               exit_sie(vcpu);
-       }
+       kvm_s390_vcpu_crypto_reset_all(kvm);
        mutex_unlock(&kvm->lock);
        return 0;
 }
@@ -1033,8 +1040,8 @@ static int kvm_s390_set_tod(struct kvm *kvm, struct kvm_device_attr *attr)
        return ret;
 }
 
-static void kvm_s390_get_tod_clock_ext(struct kvm *kvm,
-                                       struct kvm_s390_vm_tod_clock *gtod)
+static void kvm_s390_get_tod_clock(struct kvm *kvm,
+                                  struct kvm_s390_vm_tod_clock *gtod)
 {
        struct kvm_s390_tod_clock_ext htod;
 
@@ -1043,10 +1050,12 @@ static void kvm_s390_get_tod_clock_ext(struct kvm *kvm,
        get_tod_clock_ext((char *)&htod);
 
        gtod->tod = htod.tod + kvm->arch.epoch;
-       gtod->epoch_idx = htod.epoch_idx + kvm->arch.epdx;
-
-       if (gtod->tod < htod.tod)
-               gtod->epoch_idx += 1;
+       gtod->epoch_idx = 0;
+       if (test_kvm_facility(kvm, 139)) {
+               gtod->epoch_idx = htod.epoch_idx + kvm->arch.epdx;
+               if (gtod->tod < htod.tod)
+                       gtod->epoch_idx += 1;
+       }
 
        preempt_enable();
 }
@@ -1056,12 +1065,7 @@ static int kvm_s390_get_tod_ext(struct kvm *kvm, struct kvm_device_attr *attr)
        struct kvm_s390_vm_tod_clock gtod;
 
        memset(&gtod, 0, sizeof(gtod));
-
-       if (test_kvm_facility(kvm, 139))
-               kvm_s390_get_tod_clock_ext(kvm, &gtod);
-       else
-               gtod.tod = kvm_s390_get_tod_clock_fast(kvm);
-
+       kvm_s390_get_tod_clock(kvm, &gtod);
        if (copy_to_user((void __user *)attr->addr, &gtod, sizeof(gtod)))
                return -EFAULT;
 
@@ -1493,7 +1497,7 @@ static long kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
                return -EINVAL;
 
        /* Is this guest using storage keys? */
-       if (!mm_use_skey(current->mm))
+       if (!mm_uses_skeys(current->mm))
                return KVM_S390_GET_SKEYS_NONE;
 
        /* Enforce sane limit on memory allocation */
@@ -1725,7 +1729,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,
        if (args->count == 0)
                return 0;
 
-       bits = vmalloc(sizeof(*bits) * args->count);
+       bits = vmalloc(array_size(sizeof(*bits), args->count));
        if (!bits)
                return -ENOMEM;
 
@@ -1982,10 +1986,10 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
 
        rc = -ENOMEM;
 
-       kvm->arch.use_esca = 0; /* start with basic SCA */
        if (!sclp.has_64bscao)
                alloc_flags |= GFP_DMA;
        rwlock_init(&kvm->arch.sca_lock);
+       /* start with basic SCA */
        kvm->arch.sca = (struct bsca_block *) get_zeroed_page(alloc_flags);
        if (!kvm->arch.sca)
                goto out_err;
@@ -2036,8 +2040,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
        kvm_s390_crypto_init(kvm);
 
        mutex_init(&kvm->arch.float_int.ais_lock);
-       kvm->arch.float_int.simm = 0;
-       kvm->arch.float_int.nimm = 0;
        spin_lock_init(&kvm->arch.float_int.lock);
        for (i = 0; i < FIRQ_LIST_COUNT; i++)
                INIT_LIST_HEAD(&kvm->arch.float_int.lists[i]);
@@ -2063,11 +2065,8 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
                kvm->arch.gmap->pfault_enabled = 0;
        }
 
-       kvm->arch.css_support = 0;
-       kvm->arch.use_irqchip = 0;
        kvm->arch.use_pfmfi = sclp.has_pfmfi;
-       kvm->arch.epoch = 0;
-
+       kvm->arch.use_skf = sclp.has_skey;
        spin_lock_init(&kvm->arch.start_stop_lock);
        kvm_s390_vsie_init(kvm);
        kvm_s390_gisa_init(kvm);
@@ -2433,8 +2432,12 @@ static void kvm_s390_vcpu_initial_reset(struct kvm_vcpu *vcpu)
        vcpu->arch.sie_block->ckc       = 0UL;
        vcpu->arch.sie_block->todpr     = 0;
        memset(vcpu->arch.sie_block->gcr, 0, 16 * sizeof(__u64));
-       vcpu->arch.sie_block->gcr[0]  = 0xE0UL;
-       vcpu->arch.sie_block->gcr[14] = 0xC2000000UL;
+       vcpu->arch.sie_block->gcr[0]  = CR0_UNUSED_56 |
+                                       CR0_INTERRUPT_KEY_SUBMASK |
+                                       CR0_MEASUREMENT_ALERT_SUBMASK;
+       vcpu->arch.sie_block->gcr[14] = CR14_UNUSED_32 |
+                                       CR14_UNUSED_33 |
+                                       CR14_EXTERNAL_DAMAGE_SUBMASK;
        /* make sure the new fpc will be lazily loaded */
        save_fpu_regs();
        current->thread.fpu.fpc = 0;
@@ -3192,7 +3195,7 @@ static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu)
                return 0;
        if (kvm_s390_vcpu_has_irq(vcpu, 0))
                return 0;
-       if (!(vcpu->arch.sie_block->gcr[0] & 0x200ul))
+       if (!(vcpu->arch.sie_block->gcr[0] & CR0_SERVICE_SIGNAL_SUBMASK))
                return 0;
        if (!vcpu->arch.gmap->pfault_enabled)
                return 0;
@@ -3990,7 +3993,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
        return r;
 }
 
-int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
+vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
 {
 #ifdef CONFIG_KVM_S390_UCONTROL
        if ((vmf->pgoff == KVM_S390_SIE_PAGE_OFFSET)
index 1b5621f4fe5bfd5bd353b96e30bf82440430a1b2..981e3ba974616d5597e5ebd87a58c78e2d11ca27 100644 (file)
@@ -410,4 +410,17 @@ static inline int kvm_s390_use_sca_entries(void)
 }
 void kvm_s390_reinject_machine_check(struct kvm_vcpu *vcpu,
                                     struct mcck_volatile_info *mcck_info);
+
+/**
+ * kvm_s390_vcpu_crypto_reset_all
+ *
+ * Reset the crypto attributes for each vcpu. This can be done while the vcpus
+ * are running as each vcpu will be removed from SIE before resetting the crypt
+ * attributes and restored to SIE afterward.
+ *
+ * Note: The kvm->lock must be held while calling this function
+ *
+ * @kvm: the KVM guest
+ */
+void kvm_s390_vcpu_crypto_reset_all(struct kvm *kvm);
 #endif
index a3bce0e8434628a1c8d05404149e6573a71bd4ab..eb0eb60c7be6a26677f8ed20509aba88df6da337 100644 (file)
@@ -204,24 +204,28 @@ static int handle_store_cpu_address(struct kvm_vcpu *vcpu)
 
 int kvm_s390_skey_check_enable(struct kvm_vcpu *vcpu)
 {
-       int rc = 0;
+       int rc;
        struct kvm_s390_sie_block *sie_block = vcpu->arch.sie_block;
 
        trace_kvm_s390_skey_related_inst(vcpu);
-       if (!(sie_block->ictl & (ICTL_ISKE | ICTL_SSKE | ICTL_RRBE)) &&
+       /* Already enabled? */
+       if (vcpu->kvm->arch.use_skf &&
+           !(sie_block->ictl & (ICTL_ISKE | ICTL_SSKE | ICTL_RRBE)) &&
            !kvm_s390_test_cpuflags(vcpu, CPUSTAT_KSS))
-               return rc;
+               return 0;
 
        rc = s390_enable_skey();
        VCPU_EVENT(vcpu, 3, "enabling storage keys for guest: %d", rc);
-       if (!rc) {
-               if (kvm_s390_test_cpuflags(vcpu, CPUSTAT_KSS))
-                       kvm_s390_clear_cpuflags(vcpu, CPUSTAT_KSS);
-               else
-                       sie_block->ictl &= ~(ICTL_ISKE | ICTL_SSKE |
-                                            ICTL_RRBE);
-       }
-       return rc;
+       if (rc)
+               return rc;
+
+       if (kvm_s390_test_cpuflags(vcpu, CPUSTAT_KSS))
+               kvm_s390_clear_cpuflags(vcpu, CPUSTAT_KSS);
+       if (!vcpu->kvm->arch.use_skf)
+               sie_block->ictl |= ICTL_ISKE | ICTL_SSKE | ICTL_RRBE;
+       else
+               sie_block->ictl &= ~(ICTL_ISKE | ICTL_SSKE | ICTL_RRBE);
+       return 0;
 }
 
 static int try_handle_skey(struct kvm_vcpu *vcpu)
@@ -231,7 +235,7 @@ static int try_handle_skey(struct kvm_vcpu *vcpu)
        rc = kvm_s390_skey_check_enable(vcpu);
        if (rc)
                return rc;
-       if (sclp.has_skey) {
+       if (vcpu->kvm->arch.use_skf) {
                /* with storage-key facility, SIE interprets it for us */
                kvm_s390_retry_instr(vcpu);
                VCPU_EVENT(vcpu, 4, "%s", "retrying storage key operation");
index 969882b542669be1648093224c0ef802d027a161..84c89cb9636f7e854c2ad197b74f355f5815cfaa 100644 (file)
@@ -557,7 +557,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
        if (test_kvm_cpu_feat(vcpu->kvm, KVM_S390_VM_CPU_FEAT_64BSCAO))
                gpa |= (u64) READ_ONCE(scb_o->scaoh) << 32;
        if (gpa) {
-               if (!(gpa & ~0x1fffUL))
+               if (gpa < 2 * PAGE_SIZE)
                        rc = set_validity_icpt(scb_s, 0x0038U);
                else if ((gpa & ~0x1fffUL) == kvm_s390_get_prefix(vcpu))
                        rc = set_validity_icpt(scb_s, 0x0011U);
@@ -578,7 +578,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 
        gpa = READ_ONCE(scb_o->itdba) & ~0xffUL;
        if (gpa && (scb_s->ecb & ECB_TE)) {
-               if (!(gpa & ~0x1fffUL)) {
+               if (gpa < 2 * PAGE_SIZE) {
                        rc = set_validity_icpt(scb_s, 0x0080U);
                        goto unpin;
                }
@@ -594,7 +594,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 
        gpa = READ_ONCE(scb_o->gvrd) & ~0x1ffUL;
        if (gpa && (scb_s->eca & ECA_VX) && !(scb_s->ecd & ECD_HOSTREGMGMT)) {
-               if (!(gpa & ~0x1fffUL)) {
+               if (gpa < 2 * PAGE_SIZE) {
                        rc = set_validity_icpt(scb_s, 0x1310U);
                        goto unpin;
                }
@@ -613,7 +613,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 
        gpa = READ_ONCE(scb_o->riccbd) & ~0x3fUL;
        if (gpa && (scb_s->ecb3 & ECB3_RI)) {
-               if (!(gpa & ~0x1fffUL)) {
+               if (gpa < 2 * PAGE_SIZE) {
                        rc = set_validity_icpt(scb_s, 0x0043U);
                        goto unpin;
                }
@@ -632,7 +632,7 @@ static int pin_blocks(struct kvm_vcpu *vcpu, struct vsie_page *vsie_page)
 
                gpa = READ_ONCE(scb_o->sdnxo) & ~0xfUL;
                sdnxc = READ_ONCE(scb_o->sdnxo) & 0xfUL;
-               if (!gpa || !(gpa & ~0x1fffUL)) {
+               if (!gpa || gpa < 2 * PAGE_SIZE) {
                        rc = set_validity_icpt(scb_s, 0x10b0U);
                        goto unpin;
                }
index 920d408945359351e20e2ae397598390a0ad2f27..6ad15d3fab819d9f17109f7bd08c1d3311ea76ba 100644 (file)
@@ -103,7 +103,7 @@ static int scode_set;
 static int
 dcss_set_subcodes(void)
 {
-       char *name = kmalloc(8 * sizeof(char), GFP_KERNEL | GFP_DMA);
+       char *name = kmalloc(8, GFP_KERNEL | GFP_DMA);
        unsigned long rx, ry;
        int rc;
 
index 2c55a2b9d6c65bde78efacf77c71826001b3d4b1..bc56ec8abcf7f7ec680568908e05d0de3fd303e4 100644 (file)
@@ -2184,14 +2184,14 @@ int s390_enable_skey(void)
        int rc = 0;
 
        down_write(&mm->mmap_sem);
-       if (mm_use_skey(mm))
+       if (mm_uses_skeys(mm))
                goto out_up;
 
-       mm->context.use_skey = 1;
+       mm->context.uses_skeys = 1;
        for (vma = mm->mmap; vma; vma = vma->vm_next) {
                if (ksm_madvise(vma, vma->vm_start, vma->vm_end,
                                MADV_UNMERGEABLE, &vma->vm_flags)) {
-                       mm->context.use_skey = 0;
+                       mm->context.uses_skeys = 0;
                        rc = -ENOMEM;
                        goto out_up;
                }
index 4f2b65d01a70418c802d6ce33713101ec0e2909b..301e466e4263d8c87abd9069952c10dac371f640 100644 (file)
@@ -158,7 +158,7 @@ static inline pgste_t pgste_update_all(pte_t pte, pgste_t pgste,
 #ifdef CONFIG_PGSTE
        unsigned long address, bits, skey;
 
-       if (!mm_use_skey(mm) || pte_val(pte) & _PAGE_INVALID)
+       if (!mm_uses_skeys(mm) || pte_val(pte) & _PAGE_INVALID)
                return pgste;
        address = pte_val(pte) & PAGE_MASK;
        skey = (unsigned long) page_get_storage_key(address);
@@ -180,7 +180,7 @@ static inline void pgste_set_key(pte_t *ptep, pgste_t pgste, pte_t entry,
        unsigned long address;
        unsigned long nkey;
 
-       if (!mm_use_skey(mm) || pte_val(entry) & _PAGE_INVALID)
+       if (!mm_uses_skeys(mm) || pte_val(entry) & _PAGE_INVALID)
                return;
        VM_BUG_ON(!(pte_val(*ptep) & _PAGE_INVALID));
        address = pte_val(entry) & PAGE_MASK;
index 4d61a085982b3e2a669141372fd38c40c6ebb851..dd4f3d3e644fc537a8613e0c611d0932ae2d4707 100644 (file)
@@ -77,7 +77,7 @@ config SUPERH32
        select PERF_EVENTS
        select ARCH_HIBERNATION_POSSIBLE if MMU
        select SPARSE_IRQ
-       select HAVE_CC_STACKPROTECTOR
+       select HAVE_STACKPROTECTOR
 
 config SUPERH64
        def_bool "$(ARCH)" = "sh64"
@@ -687,7 +687,7 @@ config SMP
          People using multiprocessor machines who say Y here should also say
          Y to "Enhanced Real Time Clock Support", below.
 
-         See also <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO
+         See also <file:Documentation/lockup-watchdogs.txt> and the SMP-HOWTO
          available at <http://www.tldp.org/docs.html#howto>.
 
          If you don't know what to do here, say N.
index d7d232dea33e61839d02f50b623127ea87329c43..3cba60ff7aab0941ab557707ed39647734e9bc36 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/i2c.h>
-#include <linux/i2c-pca-platform.h>
+#include <linux/platform_data/i2c-pca-platform.h>
 #include <linux/i2c-algo-pca.h>
 #include <linux/usb/r8a66597.h>
 #include <linux/sh_intc.h>
index c0dd904483c76ffb4d1d53a4f53ac29974b393cf..e5a57a109d6ce03cf2cabf628a595425fdf2ed8f 100644 (file)
@@ -154,7 +154,7 @@ static int __init dmabrg_init(void)
        unsigned long or;
        int ret;
 
-       dmabrg_handlers = kzalloc(10 * sizeof(struct dmabrg_handler),
+       dmabrg_handlers = kcalloc(10, sizeof(struct dmabrg_handler),
                                  GFP_KERNEL);
        if (!dmabrg_handlers)
                return -ENOMEM;
index 382e7ecf4c82d096a8ecd2fd807727f1132fb04e..3d81a8b809427907754053549caa7aff654c6dcd 100644 (file)
@@ -561,7 +561,7 @@ static int __init sh7786_pcie_init(void)
        if (unlikely(nr_ports == 0))
                return -ENODEV;
 
-       sh7786_pcie_ports = kzalloc(nr_ports * sizeof(struct sh7786_pcie_port),
+       sh7786_pcie_ports = kcalloc(nr_ports, sizeof(struct sh7786_pcie_port),
                                    GFP_KERNEL);
        if (unlikely(!sh7786_pcie_ports))
                return -ENOMEM;
index f312813f39d8a256f322a428b5740f1476e35b2f..992955685874b5ba2c3f0abf14a0fcea1aded4f6 100644 (file)
@@ -7,9 +7,9 @@
 #ifdef CONFIG_DWARF_UNWINDER
 #define DWARF_EH_FRAME                                                 \
        .eh_frame : AT(ADDR(.eh_frame) - LOAD_OFFSET) {                 \
-                 VMLINUX_SYMBOL(__start_eh_frame) = .;                 \
+                 __start_eh_frame = .;                                 \
                  *(.eh_frame)                                          \
-                 VMLINUX_SYMBOL(__stop_eh_frame) = .;                  \
+                 __stop_eh_frame = .;                                  \
        }
 #else
 #define DWARF_EH_FRAME
index 68b1a67533cea1b4c54965af7991cd0cef224c17..4d1bfc848dd31b6face5540bca24b1871368eba4 100644 (file)
@@ -12,7 +12,7 @@
 struct kmem_cache *task_xstate_cachep = NULL;
 unsigned int xstate_size;
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 unsigned long __stack_chk_guard __read_mostly;
 EXPORT_SYMBOL(__stack_chk_guard);
 #endif
index 93522069cb155149535681e996c813cdcf7bb49e..27fddb56b3e1a1806cb0de99527edd4df4436f3e 100644 (file)
@@ -177,7 +177,7 @@ __switch_to(struct task_struct *prev, struct task_struct *next)
 {
        struct thread_struct *next_t = &next->thread;
 
-#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
+#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
        __stack_chk_guard = next->stack_canary;
 #endif
 
index 9a2b8877f1749a4ec067032c7c2002755f45e5d9..0f535debf8025df4cdd4d378f848c3a4049aaf4b 100644 (file)
@@ -178,7 +178,7 @@ config SMP
          Y to "Enhanced Real Time Clock Support", below. The "Advanced Power
          Management" code will be disabled if you say Y here.
 
-         See also <file:Documentation/nmi_watchdog.txt> and the SMP-HOWTO
+         See also <file:Documentation/lockup-watchdogs.txt> and the SMP-HOWTO
          available at <http://www.tldp.org/docs.html#howto>.
 
          If you don't know what to do here, say N.
index 048ad783ea3fe45adfa5ce23d48a106910e02de4..8babbeb30adf9bee71b822bf9adc99cd905ec4f3 100644 (file)
@@ -166,7 +166,8 @@ static int __init check_nmi_watchdog(void)
        if (!atomic_read(&nmi_active))
                return 0;
 
-       prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(unsigned int), GFP_KERNEL);
+       prev_nmi_count = kmalloc_array(nr_cpu_ids, sizeof(unsigned int),
+                                      GFP_KERNEL);
        if (!prev_nmi_count) {
                err = -ENOMEM;
                goto error;
index 7e49bbc925a575ebd78d3d79e61e3f6710e41904..63baa8aa94142b9da0a2cdf9022b7f54d0761a74 100644 (file)
@@ -565,7 +565,8 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,
        }
        if (!current_thread_info()->utraps) {
                current_thread_info()->utraps =
-                       kzalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), GFP_KERNEL);
+                       kcalloc(UT_TRAP_INSTRUCTION_31 + 1, sizeof(long),
+                               GFP_KERNEL);
                if (!current_thread_info()->utraps)
                        return -ENOMEM;
                current_thread_info()->utraps[0] = 1;
@@ -575,8 +576,9 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,
                        unsigned long *p = current_thread_info()->utraps;
 
                        current_thread_info()->utraps =
-                               kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long),
-                                       GFP_KERNEL);
+                               kmalloc_array(UT_TRAP_INSTRUCTION_31 + 1,
+                                             sizeof(long),
+                                             GFP_KERNEL);
                        if (!current_thread_info()->utraps) {
                                current_thread_info()->utraps = p;
                                return -ENOMEM;
index 8aeb1aabe76e04ce694318e87ccd154f931c8d99..f396048a0d6808f7faddc7addbd6c461e3c835ad 100644 (file)
@@ -1620,7 +1620,7 @@ static void __init bootmem_init_nonnuma(void)
               (top_of_ram - total_ram) >> 20);
 
        init_node_masks_nonnuma();
-       memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
+       memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
        allocate_node_data(0);
        node_set_online(0);
 }
index 3bd8ca95e5210a5f7dd5c1700a90a650379de37a..a5ff88643d5c98aed49150b591f75ecb189fedc2 100644 (file)
@@ -335,7 +335,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
        if (!bpf_jit_enable)
                return;
 
-       addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL);
+       addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL);
        if (addrs == NULL)
                return;
 
index 3e7f228b22e17bf5e011402b9518cfdef41b697d..20da5a8ca9490ae469c12cef016edecb89542509 100644 (file)
@@ -80,7 +80,7 @@ config MAGIC_SYSRQ
          On UML, this is accomplished by sending a "sysrq" command with
          mconsole, followed by the letter for the requested command.
 
-         The keys are documented in <file:Documentation/sysrq.txt>. Don't say Y
+         The keys are documented in <file:Documentation/admin-guide/sysrq.rst>. Don't say Y
          unless you really know what this hack does.
 
 config KERNEL_STACK_ORDER
index dcf5ea28a2815803977cc12757aa4b2c21a70e13..83c470364dfb34dce51320322e9b119c10157f3e 100644 (file)
@@ -1127,9 +1127,9 @@ static int __init ubd_init(void)
                        return -1;
        }
 
-       irq_req_buffer = kmalloc(
-                       sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE,
-                       GFP_KERNEL
+       irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
+                                      sizeof(struct io_thread_req *),
+                                      GFP_KERNEL
                );
        irq_remainder = 0;
 
@@ -1137,9 +1137,9 @@ static int __init ubd_init(void)
                printk(KERN_ERR "Failed to initialize ubd buffering\n");
                return -1;
        }
-       io_req_buffer = kmalloc(
-                       sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE,
-                       GFP_KERNEL
+       io_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
+                                     sizeof(struct io_thread_req *),
+                                     GFP_KERNEL
                );
 
        io_remainder = 0;
index 02168fe2510592f1ac7f8728e8c5004bf3e55a48..50ee3bb5a63a9eb950d76baeba475bcf7f0700b8 100644 (file)
@@ -188,7 +188,7 @@ static int get_transport_options(struct arglist *def)
        if (strncmp(transport, TRANS_TAP, TRANS_TAP_LEN) == 0)
                return (vec_rx | VECTOR_BPF);
        if (strncmp(transport, TRANS_RAW, TRANS_RAW_LEN) == 0)
-               return (vec_rx | vec_tx);
+               return (vec_rx | vec_tx | VECTOR_QDISC_BYPASS);
        return (vec_rx | vec_tx);
 }
 
@@ -504,15 +504,19 @@ static struct vector_queue *create_queue(
 
        result = kmalloc(sizeof(struct vector_queue), GFP_KERNEL);
        if (result == NULL)
-               goto out_fail;
+               return NULL;
        result->max_depth = max_size;
        result->dev = vp->dev;
        result->mmsg_vector = kmalloc(
                (sizeof(struct mmsghdr) * max_size), GFP_KERNEL);
+       if (result->mmsg_vector == NULL)
+               goto out_mmsg_fail;
        result->skbuff_vector = kmalloc(
                (sizeof(void *) * max_size), GFP_KERNEL);
-       if (result->mmsg_vector == NULL || result->skbuff_vector == NULL)
-               goto out_fail;
+       if (result->skbuff_vector == NULL)
+               goto out_skb_fail;
+
+       /* further failures can be handled safely by destroy_queue*/
 
        mmsg_vector = result->mmsg_vector;
        for (i = 0; i < max_size; i++) {
@@ -527,14 +531,14 @@ static struct vector_queue *create_queue(
        result->max_iov_frags = num_extra_frags;
        for (i = 0; i < max_size; i++) {
                if (vp->header_size > 0)
-                       iov = kmalloc(
-                               sizeof(struct iovec) * (3 + num_extra_frags),
-                               GFP_KERNEL
+                       iov = kmalloc_array(3 + num_extra_frags,
+                                           sizeof(struct iovec),
+                                           GFP_KERNEL
                        );
                else
-                       iov = kmalloc(
-                               sizeof(struct iovec) * (2 + num_extra_frags),
-                               GFP_KERNEL
+                       iov = kmalloc_array(2 + num_extra_frags,
+                                           sizeof(struct iovec),
+                                           GFP_KERNEL
                        );
                if (iov == NULL)
                        goto out_fail;
@@ -563,6 +567,11 @@ static struct vector_queue *create_queue(
        result->head = 0;
        result->tail = 0;
        return result;
+out_skb_fail:
+       kfree(result->mmsg_vector);
+out_mmsg_fail:
+       kfree(result);
+       return NULL;
 out_fail:
        destroy_queue(result);
        return NULL;
@@ -1232,9 +1241,8 @@ static int vector_net_open(struct net_device *dev)
 
        if ((vp->options & VECTOR_QDISC_BYPASS) != 0) {
                if (!uml_raw_enable_qdisc_bypass(vp->fds->rx_fd))
-                       vp->options = vp->options | VECTOR_BPF;
+                       vp->options |= VECTOR_BPF;
        }
-
        if ((vp->options & VECTOR_BPF) != 0)
                vp->bpf = uml_vector_default_bpf(vp->fds->rx_fd, dev->dev_addr);
 
index b30d73ca29d08b8ff413c37275d8e65a05ac78e8..7adb4e6b658a1b86cc2d879caae17d6441402a8c 100644 (file)
        CON_INITCALL
   }
 
-  .uml.initcall.init : {
-       __uml_initcall_start = .;
-       *(.uml.initcall.init)
-       __uml_initcall_end = .;
-  }
-
   SECURITY_INIT
 
   .exitcall : {
index b3f5865a92c911b8ad82ff8ce1d4ec143d175296..c66de434a983b0a179b01597c13d0e9a049c6536 100644 (file)
@@ -64,14 +64,10 @@ struct uml_param {
         int (*setup_func)(char *, int *);
 };
 
-extern initcall_t __uml_initcall_start, __uml_initcall_end;
 extern initcall_t __uml_postsetup_start, __uml_postsetup_end;
 extern const char *__uml_help_start, *__uml_help_end;
 #endif
 
-#define __uml_initcall(fn)                                             \
-       static initcall_t __uml_initcall_##fn __uml_init_call = fn
-
 #define __uml_exitcall(fn)                                             \
        static exitcall_t __uml_exitcall_##fn __uml_exit_call = fn
 
@@ -108,7 +104,6 @@ extern struct uml_param __uml_setup_start, __uml_setup_end;
  */
 #define __uml_init_setup       __used __section(.uml.setup.init)
 #define __uml_setup_help       __used __section(.uml.help.init)
-#define __uml_init_call                __used __section(.uml.initcall.init)
 #define __uml_postsetup_call   __used __section(.uml.postsetup.init)
 #define __uml_exit_call                __used __section(.uml.exitcall.exit)
 
index 5f970ece5ac3cdb9af504b62b56762800748f7aa..f1fee2b9123942c117ac1d498027da2f33f004b9 100644 (file)
@@ -40,17 +40,6 @@ static void set_stklim(void)
        }
 }
 
-static __init void do_uml_initcalls(void)
-{
-       initcall_t *call;
-
-       call = &__uml_initcall_start;
-       while (call < &__uml_initcall_end) {
-               (*call)();
-               call++;
-       }
-}
-
 static void last_ditch_exit(int sig)
 {
        uml_cleanup();
@@ -151,7 +140,6 @@ int __init main(int argc, char **argv, char **envp)
        scan_elf_aux(envp);
 #endif
 
-       do_uml_initcalls();
        change_sig(SIGPIPE, 0);
        ret = linux_main(argc, argv);
 
index 1d9132b66039a2366d122400b733562c9eba68ec..1c8b9f13a9e1cb8f85c60d140cadc04cbd4f9575 100644 (file)
@@ -33,7 +33,7 @@
  *     Start addresses are inclusive and end addresses are exclusive;
  *     start addresses should be rounded down, end addresses up.
  *
- *     See Documentation/cachetlb.txt for more information.
+ *     See Documentation/core-api/cachetlb.rst for more information.
  *     Please note that the implementation of these, and the required
  *     effects are cache-type (VIVT/VIPT/PIPT) specific.
  *
index 784bc2db3b289bd7adc235fac6d30de81daac2a5..6f8164d91dc2e041d55cc97cb175bc07d82a3ea7 100644 (file)
@@ -109,8 +109,9 @@ static int __init puv3_pm_init(void)
                return -EINVAL;
        }
 
-       sleep_save = kmalloc(puv3_cpu_pm_fns->save_count
-                               * sizeof(unsigned long), GFP_KERNEL);
+       sleep_save = kmalloc_array(puv3_cpu_pm_fns->save_count,
+                                  sizeof(unsigned long),
+                                  GFP_KERNEL);
        if (!sleep_save) {
                printk(KERN_ERR "failed to alloc memory for pm save\n");
                return -ENOMEM;
index 297789aef9fa19d93abaea4442ba47d2d0adaa91..f1dbb4ee19d781751ac22f233ec7dea5f9a66ed3 100644 (file)
@@ -130,7 +130,6 @@ config X86
        select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if X86_64
        select HAVE_ARCH_VMAP_STACK             if X86_64
        select HAVE_ARCH_WITHIN_STACK_FRAMES
-       select HAVE_CC_STACKPROTECTOR
        select HAVE_CMPXCHG_DOUBLE
        select HAVE_CMPXCHG_LOCAL
        select HAVE_CONTEXT_TRACKING            if X86_64
@@ -182,6 +181,7 @@ config X86
        select HAVE_RCU_TABLE_FREE
        select HAVE_REGS_AND_STACK_ACCESS_API
        select HAVE_RELIABLE_STACKTRACE         if X86_64 && UNWINDER_FRAME_POINTER && STACK_VALIDATION
+       select HAVE_STACKPROTECTOR              if CC_HAS_SANE_STACKPROTECTOR
        select HAVE_STACK_VALIDATION            if X86_64
        select HAVE_RSEQ
        select HAVE_SYSCALL_TRACEPOINTS
@@ -327,7 +327,7 @@ config X86_64_SMP
 
 config X86_32_LAZY_GS
        def_bool y
-       depends on X86_32 && CC_STACKPROTECTOR_NONE
+       depends on X86_32 && !STACKPROTECTOR
 
 config ARCH_SUPPORTS_UPROBES
        def_bool y
@@ -346,6 +346,15 @@ config PGTABLE_LEVELS
        default 2
 
 source "init/Kconfig"
+
+config CC_HAS_SANE_STACKPROTECTOR
+       bool
+       default $(success,$(srctree)/scripts/gcc-x86_64-has-stack-protector.sh $(CC)) if 64BIT
+       default $(success,$(srctree)/scripts/gcc-x86_32-has-stack-protector.sh $(CC))
+       help
+          We have to make sure stack protector is unconditionally disabled if
+          the compiler produces broken code.
+
 source "kernel/Kconfig.freezer"
 
 menu "Processor type and features"
index bef8e2b202a8c0a608fb3dad7e38fb58889ee88e..2582881d19ceeeb75a9a90588547914ccdefdbd0 100644 (file)
@@ -239,7 +239,7 @@ ENTRY(__switch_to_asm)
        movl    %esp, TASK_threadsp(%eax)
        movl    TASK_threadsp(%edx), %esp
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
        movl    TASK_stack_canary(%edx), %ebx
        movl    %ebx, PER_CPU_VAR(stack_canary)+stack_canary_offset
 #endif
index 3166b967442966734b9db6e8fea541f501aa1e1e..73a522d53b5376b7eaa17cb3d0a7e7be317b02d1 100644 (file)
@@ -357,7 +357,7 @@ ENTRY(__switch_to_asm)
        movq    %rsp, TASK_threadsp(%rdi)
        movq    TASK_threadsp(%rsi), %rsp
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
        movq    TASK_stack_canary(%rsi), %rbx
        movq    %rbx, PER_CPU_VAR(irq_stack_union)+stack_canary_offset
 #endif
index 7782cdbcd67d94e025b740e362f2a4e64e575887..82ed001e8909d69db9ab6827151534a921e2434d 100644 (file)
@@ -201,7 +201,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)
 
        /*
         * Handle seccomp.  regs->ip must be the original value.
-        * See seccomp_send_sigsys and Documentation/prctl/seccomp_filter.txt.
+        * See seccomp_send_sigsys and Documentation/userspace-api/seccomp_filter.rst.
         *
         * We could optimize the seccomp disabled case, but performance
         * here doesn't matter.
index 38b5d41b0c37d6d4b76237060bee30b7de2ff049..3210fee27e7f9ac55a844d9709dc31ff14907e9c 100644 (file)
@@ -387,7 +387,7 @@ static __init int _init_events_attrs(void)
        while (amd_iommu_v2_event_descs[i].attr.attr.name)
                i++;
 
-       attrs = kzalloc(sizeof(struct attribute **) * (i + 1), GFP_KERNEL);
+       attrs = kcalloc(i + 1, sizeof(struct attribute **), GFP_KERNEL);
        if (!attrs)
                return -ENOMEM;
 
index 6e461fb1e0d476f80def177b43c7cc01726d89ce..5f4829f10129c5bfd59b803d0ddd4a21be0b3107 100644 (file)
@@ -1637,7 +1637,7 @@ __init struct attribute **merge_attr(struct attribute **a, struct attribute **b)
                j++;
        j++;
 
-       new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
+       new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL);
        if (!new)
                return NULL;
 
index 15b07379e72dc40c26a48a42de7e8ba03064a29d..27a461414b306851d70ca2438d054a43d8aa9fed 100644 (file)
@@ -865,12 +865,10 @@ static void uncore_types_exit(struct intel_uncore_type **types)
 static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
 {
        struct intel_uncore_pmu *pmus;
-       struct attribute_group *attr_group;
-       struct attribute **attrs;
        size_t size;
        int i, j;
 
-       pmus = kzalloc(sizeof(*pmus) * type->num_boxes, GFP_KERNEL);
+       pmus = kcalloc(type->num_boxes, sizeof(*pmus), GFP_KERNEL);
        if (!pmus)
                return -ENOMEM;
 
@@ -891,21 +889,24 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
                                0, type->num_counters, 0, 0);
 
        if (type->event_descs) {
+               struct {
+                       struct attribute_group group;
+                       struct attribute *attrs[];
+               } *attr_group;
                for (i = 0; type->event_descs[i].attr.attr.name; i++);
 
-               attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
-                                       sizeof(*attr_group), GFP_KERNEL);
+               attr_group = kzalloc(struct_size(attr_group, attrs, i + 1),
+                                                               GFP_KERNEL);
                if (!attr_group)
                        goto err;
 
-               attrs = (struct attribute **)(attr_group + 1);
-               attr_group->name = "events";
-               attr_group->attrs = attrs;
+               attr_group->group.name = "events";
+               attr_group->group.attrs = attr_group->attrs;
 
                for (j = 0; j < i; j++)
-                       attrs[j] = &type->event_descs[j].attr.attr;
+                       attr_group->attrs[j] = &type->event_descs[j].attr.attr;
 
-               type->events_group = attr_group;
+               type->events_group = &attr_group->group;
        }
 
        type->pmu_group = &uncore_pmu_attr_group;
index 5f053d7d1bd972425a2af829a82345c295ad6533..de27615c51ea3fe951c2d2065734b5a79693c00a 100644 (file)
 #define CREATE_TRACE_POINTS
 #include <asm/trace/hyperv.h>
 
-/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
-struct hv_flush_pcpu {
-       u64 address_space;
-       u64 flags;
-       u64 processor_mask;
-       u64 gva_list[];
-};
-
-/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */
-struct hv_flush_pcpu_ex {
-       u64 address_space;
-       u64 flags;
-       struct hv_vpset hv_vp_set;
-       u64 gva_list[];
-};
-
 /* Each gva in gva_list encodes up to 4096 pages to flush */
 #define HV_TLB_FLUSH_UNIT (4096 * PAGE_SIZE)
 
@@ -67,8 +51,8 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus,
                                    const struct flush_tlb_info *info)
 {
        int cpu, vcpu, gva_n, max_gvas;
-       struct hv_flush_pcpu **flush_pcpu;
-       struct hv_flush_pcpu *flush;
+       struct hv_tlb_flush **flush_pcpu;
+       struct hv_tlb_flush *flush;
        u64 status = U64_MAX;
        unsigned long flags;
 
@@ -82,7 +66,7 @@ static void hyperv_flush_tlb_others(const struct cpumask *cpus,
 
        local_irq_save(flags);
 
-       flush_pcpu = (struct hv_flush_pcpu **)
+       flush_pcpu = (struct hv_tlb_flush **)
                     this_cpu_ptr(hyperv_pcpu_input_arg);
 
        flush = *flush_pcpu;
@@ -152,8 +136,8 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus,
                                       const struct flush_tlb_info *info)
 {
        int nr_bank = 0, max_gvas, gva_n;
-       struct hv_flush_pcpu_ex **flush_pcpu;
-       struct hv_flush_pcpu_ex *flush;
+       struct hv_tlb_flush_ex **flush_pcpu;
+       struct hv_tlb_flush_ex *flush;
        u64 status = U64_MAX;
        unsigned long flags;
 
@@ -167,7 +151,7 @@ static void hyperv_flush_tlb_others_ex(const struct cpumask *cpus,
 
        local_irq_save(flags);
 
-       flush_pcpu = (struct hv_flush_pcpu_ex **)
+       flush_pcpu = (struct hv_tlb_flush_ex **)
                     this_cpu_ptr(hyperv_pcpu_input_arg);
 
        flush = *flush_pcpu;
index 3bfa92c2793c707d0deb82c25211f8789225470b..b8c89265baf0dbc253d1c5ed2c217f53326cb64e 100644 (file)
@@ -308,6 +308,9 @@ struct ms_hyperv_tsc_page {
 /* TSC emulation after migration */
 #define HV_X64_MSR_REENLIGHTENMENT_CONTROL     0x40000106
 
+/* Nested features (CPUID 0x4000000A) EAX */
+#define HV_X64_NESTED_MSR_BITMAP               BIT(19)
+
 struct hv_reenlightenment_control {
        __u64 vector:8;
        __u64 reserved1:8;
@@ -678,7 +681,11 @@ struct hv_enlightened_vmcs {
        u32 hv_clean_fields;
        u32 hv_padding_32;
        u32 hv_synthetic_controls;
-       u32 hv_enlightenments_control;
+       struct {
+               u32 nested_flush_hypercall:1;
+               u32 msr_bitmap:1;
+               u32 reserved:30;
+       } hv_enlightenments_control;
        u32 hv_vp_id;
 
        u64 hv_vm_id;
@@ -734,4 +741,20 @@ struct ipi_arg_ex {
        struct hv_vpset vp_set;
 };
 
+/* HvFlushVirtualAddressSpace, HvFlushVirtualAddressList hypercalls */
+struct hv_tlb_flush {
+       u64 address_space;
+       u64 flags;
+       u64 processor_mask;
+       u64 gva_list[];
+};
+
+/* HvFlushVirtualAddressSpaceEx, HvFlushVirtualAddressListEx hypercalls */
+struct hv_tlb_flush_ex {
+       u64 address_space;
+       u64 flags;
+       struct hv_vpset hv_vp_set;
+       u64 gva_list[];
+};
+
 #endif
index b24b1c8b397989304ec88d9979c66b1b5415f78e..0f82cd91cd3c4d630993d573d7c6e9970d476414 100644 (file)
@@ -107,11 +107,12 @@ struct x86_emulate_ops {
         *  @addr:  [IN ] Linear address from which to read.
         *  @val:   [OUT] Value read from memory, zero-extended to 'u_long'.
         *  @bytes: [IN ] Number of bytes to read from memory.
+        *  @system:[IN ] Whether the access is forced to be at CPL0.
         */
        int (*read_std)(struct x86_emulate_ctxt *ctxt,
                        unsigned long addr, void *val,
                        unsigned int bytes,
-                       struct x86_exception *fault);
+                       struct x86_exception *fault, bool system);
 
        /*
         * read_phys: Read bytes of standard (non-emulated/special) memory.
@@ -129,10 +130,11 @@ struct x86_emulate_ops {
         *  @addr:  [IN ] Linear address to which to write.
         *  @val:   [OUT] Value write to memory, zero-extended to 'u_long'.
         *  @bytes: [IN ] Number of bytes to write to memory.
+        *  @system:[IN ] Whether the access is forced to be at CPL0.
         */
        int (*write_std)(struct x86_emulate_ctxt *ctxt,
                         unsigned long addr, void *val, unsigned int bytes,
-                        struct x86_exception *fault);
+                        struct x86_exception *fault, bool system);
        /*
         * fetch: Read bytes of standard (non-emulated/special) memory.
         *        Used for instruction fetch.
index f4b2588865e9f7ad16696d3e70255a2b794d26b3..c13cd28d9d1be5abdff8fdf93692d51755c8930c 100644 (file)
@@ -258,7 +258,8 @@ union kvm_mmu_page_role {
                unsigned smep_andnot_wp:1;
                unsigned smap_andnot_wp:1;
                unsigned ad_disabled:1;
-               unsigned :7;
+               unsigned guest_mode:1;
+               unsigned :6;
 
                /*
                 * This is left at the top of the word so that
@@ -476,6 +477,7 @@ struct kvm_vcpu_hv {
        struct kvm_hyperv_exit exit;
        struct kvm_vcpu_hv_stimer stimer[HV_SYNIC_STIMER_COUNT];
        DECLARE_BITMAP(stimer_pending_bitmap, HV_SYNIC_STIMER_COUNT);
+       cpumask_t tlb_lush;
 };
 
 struct kvm_vcpu_arch {
@@ -995,7 +997,7 @@ struct kvm_x86_ops {
        void (*hwapic_irr_update)(struct kvm_vcpu *vcpu, int max_irr);
        void (*hwapic_isr_update)(struct kvm_vcpu *vcpu, int isr);
        void (*load_eoi_exitmap)(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap);
-       void (*set_virtual_x2apic_mode)(struct kvm_vcpu *vcpu, bool set);
+       void (*set_virtual_apic_mode)(struct kvm_vcpu *vcpu);
        void (*set_apic_access_page_addr)(struct kvm_vcpu *vcpu, hpa_t hpa);
        void (*deliver_posted_interrupt)(struct kvm_vcpu *vcpu, int vector);
        int (*sync_pir_to_irr)(struct kvm_vcpu *vcpu);
@@ -1277,6 +1279,7 @@ void __kvm_mmu_free_some_pages(struct kvm_vcpu *vcpu);
 int kvm_mmu_load(struct kvm_vcpu *vcpu);
 void kvm_mmu_unload(struct kvm_vcpu *vcpu);
 void kvm_mmu_sync_roots(struct kvm_vcpu *vcpu);
+void kvm_mmu_free_roots(struct kvm_vcpu *vcpu);
 gpa_t translate_nested_gpa(struct kvm_vcpu *vcpu, gpa_t gpa, u32 access,
                           struct x86_exception *exception);
 gpa_t kvm_mmu_gva_to_gpa_read(struct kvm_vcpu *vcpu, gva_t gva,
index 997192131b7b864ab73e0e6656c8eaaa6c620a56..3cd14311edfad6d04c5ea382b2b6845f66a9d6f8 100644 (file)
@@ -269,7 +269,7 @@ static inline int cpumask_to_vpset(struct hv_vpset *vpset,
                return 0;
 
        /*
-        * Clear all banks up to the maximum possible bank as hv_flush_pcpu_ex
+        * Clear all banks up to the maximum possible bank as hv_tlb_flush_ex
         * structs are not cleared between calls, we risk flushing unneeded
         * vCPUs otherwise.
         */
index e28add6b791f29b70e342defe208c54d98d0d246..cfd29ee8c3da930eabc38a96d2aacbbbc1c965c3 100644 (file)
@@ -412,7 +412,7 @@ extern asmlinkage void ignore_sysret(void);
 void save_fsgs_for_kvm(void);
 #endif
 #else  /* X86_64 */
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 /*
  * Make sure stack canary segment base is cached-aligned:
  *   "For Intel Atom processors, avoid non zero segment base address
index 8f09012b92e779d7aabf4ad663b8eb10b2379c37..e293c122d0d54fbc802c1212edc9ed099be582f0 100644 (file)
 # define __KERNEL_PERCPU               0
 #endif
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 # define __KERNEL_STACK_CANARY         (GDT_ENTRY_STACK_CANARY*8)
 #else
 # define __KERNEL_STACK_CANARY         0
index 371b3a4af000764bcae483e8f1125765a35e76e8..8ec97a62c245175e87d96c0376eb962f51f8e91d 100644 (file)
@@ -34,7 +34,7 @@
 #ifndef _ASM_STACKPROTECTOR_H
 #define _ASM_STACKPROTECTOR_H 1
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 
 #include <asm/tsc.h>
 #include <asm/processor.h>
@@ -105,7 +105,7 @@ static inline void load_stack_canary_segment(void)
 #endif
 }
 
-#else  /* CC_STACKPROTECTOR */
+#else  /* STACKPROTECTOR */
 
 #define GDT_STACK_CANARY_INIT
 
@@ -121,5 +121,5 @@ static inline void load_stack_canary_segment(void)
 #endif
 }
 
-#endif /* CC_STACKPROTECTOR */
+#endif /* STACKPROTECTOR */
 #endif /* _ASM_STACKPROTECTOR_H */
index 5db8b0b1076649fa287ad8ebfe2ba9853cd949d8..425e6b8b95478248dd3a32122b1aca408691cadf 100644 (file)
@@ -207,7 +207,9 @@ enum vmcs_field {
        EPTP_LIST_ADDRESS               = 0x00002024,
        EPTP_LIST_ADDRESS_HIGH          = 0x00002025,
        VMREAD_BITMAP                   = 0x00002026,
+       VMREAD_BITMAP_HIGH              = 0x00002027,
        VMWRITE_BITMAP                  = 0x00002028,
+       VMWRITE_BITMAP_HIGH             = 0x00002029,
        XSS_EXIT_BITMAP                 = 0x0000202C,
        XSS_EXIT_BITMAP_HIGH            = 0x0000202D,
        TSC_MULTIPLIER                  = 0x00002032,
index 76417a9aab73c3f7e3376261eb9ec592b16adf3b..dcb008c320fe05c2f236993815f18f20ab6e9d5d 100644 (file)
@@ -32,7 +32,7 @@
 void common(void) {
        BLANK();
        OFFSET(TASK_threadsp, task_struct, thread.sp);
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
        OFFSET(TASK_stack_canary, task_struct, stack_canary);
 #endif
 
index f91ba53e06c8b90f9d5557a2713896a1a50100f0..a4a3be399f4b27ab5adf1df10c0a8ee4b2738e13 100644 (file)
@@ -50,7 +50,7 @@ void foo(void)
        DEFINE(TSS_sysenter_sp0, offsetof(struct cpu_entry_area, tss.x86_tss.sp0) -
               offsetofend(struct cpu_entry_area, entry_stack_page.stack));
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
        BLANK();
        OFFSET(stack_canary_offset, stack_canary, canary);
 #endif
index bf51e51d808dd8914abd3b4bca69b37ce3ec023b..b2dcd161f5149492e8a24f06d7074d527308528c 100644 (file)
@@ -69,7 +69,7 @@ int main(void)
        OFFSET(TSS_sp1, tss_struct, x86_tss.sp1);
        BLANK();
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
        DEFINE(stack_canary_offset, offsetof(union irq_stack_union, stack_canary));
        BLANK();
 #endif
index 910b47ee8078081e615f733440b61dd1df79dc78..0df7151cfef42cb908c9d76f0b4e78db1620f615 100644 (file)
@@ -1599,7 +1599,7 @@ DEFINE_PER_CPU(unsigned long, cpu_current_top_of_stack) =
        (unsigned long)&init_thread_union + THREAD_SIZE;
 EXPORT_PER_CPU_SYMBOL(cpu_current_top_of_stack);
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 DEFINE_PER_CPU_ALIGNED(struct stack_canary, stack_canary);
 #endif
 
index cd76380af79fbbdd2a17cf356f8fd5cd72968290..e4cf6ff1c2e1d341bb5ca890cd8dba266ce2aa18 100644 (file)
@@ -1457,7 +1457,7 @@ static int __mcheck_cpu_mce_banks_init(void)
        int i;
        u8 num_banks = mca_cfg.banks;
 
-       mce_banks = kzalloc(num_banks * sizeof(struct mce_bank), GFP_KERNEL);
+       mce_banks = kcalloc(num_banks, sizeof(struct mce_bank), GFP_KERNEL);
        if (!mce_banks)
                return -ENOMEM;
 
index f591b01930db4abf6740b41d588644e0facbd61e..dd33c357548f11c0ac21c367d0edc20b34671218 100644 (file)
@@ -1384,7 +1384,7 @@ int mce_threshold_create_device(unsigned int cpu)
        if (bp)
                return 0;
 
-       bp = kzalloc(sizeof(struct threshold_bank *) * mca_cfg.banks,
+       bp = kcalloc(mca_cfg.banks, sizeof(struct threshold_bank *),
                     GFP_KERNEL);
        if (!bp)
                return -ENOMEM;
index c610f47373e443ccd4b44441b5a631009e8f43a6..4021d3859499c77c14eaa1c40864c752547df68c 100644 (file)
@@ -43,7 +43,7 @@ mtrr_file_add(unsigned long base, unsigned long size,
 
        max = num_var_ranges;
        if (fcount == NULL) {
-               fcount = kzalloc(max * sizeof *fcount, GFP_KERNEL);
+               fcount = kcalloc(max, sizeof(*fcount), GFP_KERNEL);
                if (!fcount)
                        return -ENOMEM;
                FILE_FCOUNT(file) = fcount;
index b59e4fb40fd9986c0cc6b629b4c7a3a18a6d23b4..abe6df15a8fbb798bf9cb8bfec5252494a943e63 100644 (file)
@@ -375,7 +375,7 @@ ENDPROC(startup_32_smp)
  */
 __INIT
 setup_once:
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
        /*
         * Configure the stack canary. The linker can't handle this by
         * relocation.  Manually set base address in stack canary
index b6be34ee88e9181219ad939b42744f8312cae9b5..346b24883911dc2296b518653c03b15a81edfc52 100644 (file)
@@ -610,7 +610,7 @@ static void hpet_msi_capability_lookup(unsigned int start_timer)
        if (!hpet_domain)
                return;
 
-       hpet_devs = kzalloc(sizeof(struct hpet_dev) * num_timers, GFP_KERNEL);
+       hpet_devs = kcalloc(num_timers, sizeof(struct hpet_dev), GFP_KERNEL);
        if (!hpet_devs)
                return;
 
@@ -966,8 +966,8 @@ int __init hpet_enable(void)
 #endif
 
        cfg = hpet_readl(HPET_CFG);
-       hpet_boot_cfg = kmalloc((last + 2) * sizeof(*hpet_boot_cfg),
-                               GFP_KERNEL);
+       hpet_boot_cfg = kmalloc_array(last + 2, sizeof(*hpet_boot_cfg),
+                                     GFP_KERNEL);
        if (hpet_boot_cfg)
                *hpet_boot_cfg = cfg;
        else
index 8c1cc08f514f4362bdaefa933fda3cd3769b04f9..163ae706a0d4f9d58975e6ddaf49313d89345e14 100644 (file)
@@ -283,7 +283,7 @@ static int __init create_setup_data_nodes(struct kobject *parent)
        if (ret)
                goto out_setup_data_kobj;
 
-       kobjp = kmalloc(sizeof(*kobjp) * nr, GFP_KERNEL);
+       kobjp = kmalloc_array(nr, sizeof(*kobjp), GFP_KERNEL);
        if (!kobjp) {
                ret = -ENOMEM;
                goto out_setup_data_kobj;
index f4f30d0c25c426388fb962fdcd04e76b508755cc..7e042e3d47fd5a007cd70ad20d2f5d6ee525c28e 100644 (file)
@@ -203,8 +203,9 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
                goto out;
        r = -ENOMEM;
        if (cpuid->nent) {
-               cpuid_entries = vmalloc(sizeof(struct kvm_cpuid_entry) *
-                                       cpuid->nent);
+               cpuid_entries =
+                       vmalloc(array_size(sizeof(struct kvm_cpuid_entry),
+                                          cpuid->nent));
                if (!cpuid_entries)
                        goto out;
                r = -EFAULT;
@@ -404,7 +405,8 @@ static inline int __do_cpuid_ent(struct kvm_cpuid_entry2 *entry, u32 function,
        const u32 kvm_cpuid_7_0_ecx_x86_features =
                F(AVX512VBMI) | F(LA57) | F(PKU) | 0 /*OSPKE*/ |
                F(AVX512_VPOPCNTDQ) | F(UMIP) | F(AVX512_VBMI2) | F(GFNI) |
-               F(VAES) | F(VPCLMULQDQ) | F(AVX512_VNNI) | F(AVX512_BITALG);
+               F(VAES) | F(VPCLMULQDQ) | F(AVX512_VNNI) | F(AVX512_BITALG) |
+               F(CLDEMOTE);
 
        /* cpuid 7.0.edx*/
        const u32 kvm_cpuid_7_0_edx_x86_features =
@@ -784,7 +786,8 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
                return -EINVAL;
 
        r = -ENOMEM;
-       cpuid_entries = vzalloc(sizeof(struct kvm_cpuid_entry2) * cpuid->nent);
+       cpuid_entries = vzalloc(array_size(sizeof(struct kvm_cpuid_entry2),
+                                          cpuid->nent));
        if (!cpuid_entries)
                goto out;
 
index b3705ae52824907085bb613cd1e16a843138e8b0..4c4f4263420c057b530c799b1a7af4dff421d67d 100644 (file)
@@ -812,6 +812,19 @@ static inline int jmp_rel(struct x86_emulate_ctxt *ctxt, int rel)
        return assign_eip_near(ctxt, ctxt->_eip + rel);
 }
 
+static int linear_read_system(struct x86_emulate_ctxt *ctxt, ulong linear,
+                             void *data, unsigned size)
+{
+       return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception, true);
+}
+
+static int linear_write_system(struct x86_emulate_ctxt *ctxt,
+                              ulong linear, void *data,
+                              unsigned int size)
+{
+       return ctxt->ops->write_std(ctxt, linear, data, size, &ctxt->exception, true);
+}
+
 static int segmented_read_std(struct x86_emulate_ctxt *ctxt,
                              struct segmented_address addr,
                              void *data,
@@ -823,7 +836,7 @@ static int segmented_read_std(struct x86_emulate_ctxt *ctxt,
        rc = linearize(ctxt, addr, size, false, &linear);
        if (rc != X86EMUL_CONTINUE)
                return rc;
-       return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception);
+       return ctxt->ops->read_std(ctxt, linear, data, size, &ctxt->exception, false);
 }
 
 static int segmented_write_std(struct x86_emulate_ctxt *ctxt,
@@ -837,7 +850,7 @@ static int segmented_write_std(struct x86_emulate_ctxt *ctxt,
        rc = linearize(ctxt, addr, size, true, &linear);
        if (rc != X86EMUL_CONTINUE)
                return rc;
-       return ctxt->ops->write_std(ctxt, linear, data, size, &ctxt->exception);
+       return ctxt->ops->write_std(ctxt, linear, data, size, &ctxt->exception, false);
 }
 
 /*
@@ -1496,8 +1509,7 @@ static int read_interrupt_descriptor(struct x86_emulate_ctxt *ctxt,
                return emulate_gp(ctxt, index << 3 | 0x2);
 
        addr = dt.address + index * 8;
-       return ctxt->ops->read_std(ctxt, addr, desc, sizeof *desc,
-                                  &ctxt->exception);
+       return linear_read_system(ctxt, addr, desc, sizeof *desc);
 }
 
 static void get_descriptor_table_ptr(struct x86_emulate_ctxt *ctxt,
@@ -1560,8 +1572,7 @@ static int read_segment_descriptor(struct x86_emulate_ctxt *ctxt,
        if (rc != X86EMUL_CONTINUE)
                return rc;
 
-       return ctxt->ops->read_std(ctxt, *desc_addr_p, desc, sizeof(*desc),
-                                  &ctxt->exception);
+       return linear_read_system(ctxt, *desc_addr_p, desc, sizeof(*desc));
 }
 
 /* allowed just for 8 bytes segments */
@@ -1575,8 +1586,7 @@ static int write_segment_descriptor(struct x86_emulate_ctxt *ctxt,
        if (rc != X86EMUL_CONTINUE)
                return rc;
 
-       return ctxt->ops->write_std(ctxt, addr, desc, sizeof *desc,
-                                   &ctxt->exception);
+       return linear_write_system(ctxt, addr, desc, sizeof *desc);
 }
 
 static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
@@ -1737,8 +1747,7 @@ static int __load_segment_descriptor(struct x86_emulate_ctxt *ctxt,
                                return ret;
                }
        } else if (ctxt->mode == X86EMUL_MODE_PROT64) {
-               ret = ctxt->ops->read_std(ctxt, desc_addr+8, &base3,
-                               sizeof(base3), &ctxt->exception);
+               ret = linear_read_system(ctxt, desc_addr+8, &base3, sizeof(base3));
                if (ret != X86EMUL_CONTINUE)
                        return ret;
                if (emul_is_noncanonical_address(get_desc_base(&seg_desc) |
@@ -2051,11 +2060,11 @@ static int __emulate_int_real(struct x86_emulate_ctxt *ctxt, int irq)
        eip_addr = dt.address + (irq << 2);
        cs_addr = dt.address + (irq << 2) + 2;
 
-       rc = ops->read_std(ctxt, cs_addr, &cs, 2, &ctxt->exception);
+       rc = linear_read_system(ctxt, cs_addr, &cs, 2);
        if (rc != X86EMUL_CONTINUE)
                return rc;
 
-       rc = ops->read_std(ctxt, eip_addr, &eip, 2, &ctxt->exception);
+       rc = linear_read_system(ctxt, eip_addr, &eip, 2);
        if (rc != X86EMUL_CONTINUE)
                return rc;
 
@@ -2919,12 +2928,12 @@ static bool emulator_io_port_access_allowed(struct x86_emulate_ctxt *ctxt,
 #ifdef CONFIG_X86_64
        base |= ((u64)base3) << 32;
 #endif
-       r = ops->read_std(ctxt, base + 102, &io_bitmap_ptr, 2, NULL);
+       r = ops->read_std(ctxt, base + 102, &io_bitmap_ptr, 2, NULL, true);
        if (r != X86EMUL_CONTINUE)
                return false;
        if (io_bitmap_ptr + port/8 > desc_limit_scaled(&tr_seg))
                return false;
-       r = ops->read_std(ctxt, base + io_bitmap_ptr + port/8, &perm, 2, NULL);
+       r = ops->read_std(ctxt, base + io_bitmap_ptr + port/8, &perm, 2, NULL, true);
        if (r != X86EMUL_CONTINUE)
                return false;
        if ((perm >> bit_idx) & mask)
@@ -3053,35 +3062,30 @@ static int task_switch_16(struct x86_emulate_ctxt *ctxt,
                          u16 tss_selector, u16 old_tss_sel,
                          ulong old_tss_base, struct desc_struct *new_desc)
 {
-       const struct x86_emulate_ops *ops = ctxt->ops;
        struct tss_segment_16 tss_seg;
        int ret;
        u32 new_tss_base = get_desc_base(new_desc);
 
-       ret = ops->read_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg,
-                           &ctxt->exception);
+       ret = linear_read_system(ctxt, old_tss_base, &tss_seg, sizeof tss_seg);
        if (ret != X86EMUL_CONTINUE)
                return ret;
 
        save_state_to_tss16(ctxt, &tss_seg);
 
-       ret = ops->write_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg,
-                            &ctxt->exception);
+       ret = linear_write_system(ctxt, old_tss_base, &tss_seg, sizeof tss_seg);
        if (ret != X86EMUL_CONTINUE)
                return ret;
 
-       ret = ops->read_std(ctxt, new_tss_base, &tss_seg, sizeof tss_seg,
-                           &ctxt->exception);
+       ret = linear_read_system(ctxt, new_tss_base, &tss_seg, sizeof tss_seg);
        if (ret != X86EMUL_CONTINUE)
                return ret;
 
        if (old_tss_sel != 0xffff) {
                tss_seg.prev_task_link = old_tss_sel;
 
-               ret = ops->write_std(ctxt, new_tss_base,
-                                    &tss_seg.prev_task_link,
-                                    sizeof tss_seg.prev_task_link,
-                                    &ctxt->exception);
+               ret = linear_write_system(ctxt, new_tss_base,
+                                         &tss_seg.prev_task_link,
+                                         sizeof tss_seg.prev_task_link);
                if (ret != X86EMUL_CONTINUE)
                        return ret;
        }
@@ -3197,38 +3201,34 @@ static int task_switch_32(struct x86_emulate_ctxt *ctxt,
                          u16 tss_selector, u16 old_tss_sel,
                          ulong old_tss_base, struct desc_struct *new_desc)
 {
-       const struct x86_emulate_ops *ops = ctxt->ops;
        struct tss_segment_32 tss_seg;
        int ret;
        u32 new_tss_base = get_desc_base(new_desc);
        u32 eip_offset = offsetof(struct tss_segment_32, eip);
        u32 ldt_sel_offset = offsetof(struct tss_segment_32, ldt_selector);
 
-       ret = ops->read_std(ctxt, old_tss_base, &tss_seg, sizeof tss_seg,
-                           &ctxt->exception);
+       ret = linear_read_system(ctxt, old_tss_base, &tss_seg, sizeof tss_seg);
        if (ret != X86EMUL_CONTINUE)
                return ret;
 
        save_state_to_tss32(ctxt, &tss_seg);
 
        /* Only GP registers and segment selectors are saved */
-       ret = ops->write_std(ctxt, old_tss_base + eip_offset, &tss_seg.eip,
-                            ldt_sel_offset - eip_offset, &ctxt->exception);
+       ret = linear_write_system(ctxt, old_tss_base + eip_offset, &tss_seg.eip,
+                                 ldt_sel_offset - eip_offset);
        if (ret != X86EMUL_CONTINUE)
                return ret;
 
-       ret = ops->read_std(ctxt, new_tss_base, &tss_seg, sizeof tss_seg,
-                           &ctxt->exception);
+       ret = linear_read_system(ctxt, new_tss_base, &tss_seg, sizeof tss_seg);
        if (ret != X86EMUL_CONTINUE)
                return ret;
 
        if (old_tss_sel != 0xffff) {
                tss_seg.prev_task_link = old_tss_sel;
 
-               ret = ops->write_std(ctxt, new_tss_base,
-                                    &tss_seg.prev_task_link,
-                                    sizeof tss_seg.prev_task_link,
-                                    &ctxt->exception);
+               ret = linear_write_system(ctxt, new_tss_base,
+                                         &tss_seg.prev_task_link,
+                                         sizeof tss_seg.prev_task_link);
                if (ret != X86EMUL_CONTINUE)
                        return ret;
        }
@@ -4189,7 +4189,9 @@ static int check_cr_write(struct x86_emulate_ctxt *ctxt)
                                maxphyaddr = eax & 0xff;
                        else
                                maxphyaddr = 36;
-                       rsvd = rsvd_bits(maxphyaddr, 62);
+                       rsvd = rsvd_bits(maxphyaddr, 63);
+                       if (ctxt->ops->get_cr(ctxt, 4) & X86_CR4_PCIDE)
+                               rsvd &= ~CR3_PCID_INVD;
                }
 
                if (new_val & rsvd)
index 46ff64da44cab46d637facafffb10ba1a1269a1f..af8caf965baa291319a7e5825b27ab28f97a24cf 100644 (file)
@@ -1242,6 +1242,121 @@ int kvm_hv_get_msr_common(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
                return kvm_hv_get_msr(vcpu, msr, pdata);
 }
 
+static __always_inline int get_sparse_bank_no(u64 valid_bank_mask, int bank_no)
+{
+       int i = 0, j;
+
+       if (!(valid_bank_mask & BIT_ULL(bank_no)))
+               return -1;
+
+       for (j = 0; j < bank_no; j++)
+               if (valid_bank_mask & BIT_ULL(j))
+                       i++;
+
+       return i;
+}
+
+static u64 kvm_hv_flush_tlb(struct kvm_vcpu *current_vcpu, u64 ingpa,
+                           u16 rep_cnt, bool ex)
+{
+       struct kvm *kvm = current_vcpu->kvm;
+       struct kvm_vcpu_hv *hv_current = &current_vcpu->arch.hyperv;
+       struct hv_tlb_flush_ex flush_ex;
+       struct hv_tlb_flush flush;
+       struct kvm_vcpu *vcpu;
+       unsigned long vcpu_bitmap[BITS_TO_LONGS(KVM_MAX_VCPUS)] = {0};
+       unsigned long valid_bank_mask = 0;
+       u64 sparse_banks[64];
+       int sparse_banks_len, i;
+       bool all_cpus;
+
+       if (!ex) {
+               if (unlikely(kvm_read_guest(kvm, ingpa, &flush, sizeof(flush))))
+                       return HV_STATUS_INVALID_HYPERCALL_INPUT;
+
+               trace_kvm_hv_flush_tlb(flush.processor_mask,
+                                      flush.address_space, flush.flags);
+
+               sparse_banks[0] = flush.processor_mask;
+               all_cpus = flush.flags & HV_FLUSH_ALL_PROCESSORS;
+       } else {
+               if (unlikely(kvm_read_guest(kvm, ingpa, &flush_ex,
+                                           sizeof(flush_ex))))
+                       return HV_STATUS_INVALID_HYPERCALL_INPUT;
+
+               trace_kvm_hv_flush_tlb_ex(flush_ex.hv_vp_set.valid_bank_mask,
+                                         flush_ex.hv_vp_set.format,
+                                         flush_ex.address_space,
+                                         flush_ex.flags);
+
+               valid_bank_mask = flush_ex.hv_vp_set.valid_bank_mask;
+               all_cpus = flush_ex.hv_vp_set.format !=
+                       HV_GENERIC_SET_SPARSE_4K;
+
+               sparse_banks_len = bitmap_weight(&valid_bank_mask, 64) *
+                       sizeof(sparse_banks[0]);
+
+               if (!sparse_banks_len && !all_cpus)
+                       goto ret_success;
+
+               if (!all_cpus &&
+                   kvm_read_guest(kvm,
+                                  ingpa + offsetof(struct hv_tlb_flush_ex,
+                                                   hv_vp_set.bank_contents),
+                                  sparse_banks,
+                                  sparse_banks_len))
+                       return HV_STATUS_INVALID_HYPERCALL_INPUT;
+       }
+
+       cpumask_clear(&hv_current->tlb_lush);
+
+       kvm_for_each_vcpu(i, vcpu, kvm) {
+               struct kvm_vcpu_hv *hv = &vcpu->arch.hyperv;
+               int bank = hv->vp_index / 64, sbank = 0;
+
+               if (!all_cpus) {
+                       /* Banks >64 can't be represented */
+                       if (bank >= 64)
+                               continue;
+
+                       /* Non-ex hypercalls can only address first 64 vCPUs */
+                       if (!ex && bank)
+                               continue;
+
+                       if (ex) {
+                               /*
+                                * Check is the bank of this vCPU is in sparse
+                                * set and get the sparse bank number.
+                                */
+                               sbank = get_sparse_bank_no(valid_bank_mask,
+                                                          bank);
+
+                               if (sbank < 0)
+                                       continue;
+                       }
+
+                       if (!(sparse_banks[sbank] & BIT_ULL(hv->vp_index % 64)))
+                               continue;
+               }
+
+               /*
+                * vcpu->arch.cr3 may not be up-to-date for running vCPUs so we
+                * can't analyze it here, flush TLB regardless of the specified
+                * address space.
+                */
+               __set_bit(i, vcpu_bitmap);
+       }
+
+       kvm_make_vcpus_request_mask(kvm,
+                                   KVM_REQ_TLB_FLUSH | KVM_REQUEST_NO_WAKEUP,
+                                   vcpu_bitmap, &hv_current->tlb_lush);
+
+ret_success:
+       /* We always do full TLB flush, set rep_done = rep_cnt. */
+       return (u64)HV_STATUS_SUCCESS |
+               ((u64)rep_cnt << HV_HYPERCALL_REP_COMP_OFFSET);
+}
+
 bool kvm_hv_hypercall_enabled(struct kvm *kvm)
 {
        return READ_ONCE(kvm->arch.hyperv.hv_hypercall) & HV_X64_MSR_HYPERCALL_ENABLE;
@@ -1315,7 +1430,7 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 {
        u64 param, ingpa, outgpa, ret = HV_STATUS_SUCCESS;
        uint16_t code, rep_idx, rep_cnt;
-       bool fast, longmode;
+       bool fast, longmode, rep;
 
        /*
         * hypercall generates UD from non zero cpl and real mode
@@ -1345,31 +1460,34 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
 #endif
 
        code = param & 0xffff;
-       fast = (param >> 16) & 0x1;
-       rep_cnt = (param >> 32) & 0xfff;
-       rep_idx = (param >> 48) & 0xfff;
+       fast = !!(param & HV_HYPERCALL_FAST_BIT);
+       rep_cnt = (param >> HV_HYPERCALL_REP_COMP_OFFSET) & 0xfff;
+       rep_idx = (param >> HV_HYPERCALL_REP_START_OFFSET) & 0xfff;
+       rep = !!(rep_cnt || rep_idx);
 
        trace_kvm_hv_hypercall(code, fast, rep_cnt, rep_idx, ingpa, outgpa);
 
-       /* Hypercall continuation is not supported yet */
-       if (rep_cnt || rep_idx) {
-               ret = HV_STATUS_INVALID_HYPERCALL_CODE;
-               goto out;
-       }
-
        switch (code) {
        case HVCALL_NOTIFY_LONG_SPIN_WAIT:
+               if (unlikely(rep)) {
+                       ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
+                       break;
+               }
                kvm_vcpu_on_spin(vcpu, true);
                break;
        case HVCALL_SIGNAL_EVENT:
+               if (unlikely(rep)) {
+                       ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
+                       break;
+               }
                ret = kvm_hvcall_signal_event(vcpu, fast, ingpa);
                if (ret != HV_STATUS_INVALID_PORT_ID)
                        break;
                /* maybe userspace knows this conn_id: fall through */
        case HVCALL_POST_MESSAGE:
                /* don't bother userspace if it has no way to handle it */
-               if (!vcpu_to_synic(vcpu)->active) {
-                       ret = HV_STATUS_INVALID_HYPERCALL_CODE;
+               if (unlikely(rep || !vcpu_to_synic(vcpu)->active)) {
+                       ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
                        break;
                }
                vcpu->run->exit_reason = KVM_EXIT_HYPERV;
@@ -1380,12 +1498,39 @@ int kvm_hv_hypercall(struct kvm_vcpu *vcpu)
                vcpu->arch.complete_userspace_io =
                                kvm_hv_hypercall_complete_userspace;
                return 0;
+       case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST:
+               if (unlikely(fast || !rep_cnt || rep_idx)) {
+                       ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
+                       break;
+               }
+               ret = kvm_hv_flush_tlb(vcpu, ingpa, rep_cnt, false);
+               break;
+       case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE:
+               if (unlikely(fast || rep)) {
+                       ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
+                       break;
+               }
+               ret = kvm_hv_flush_tlb(vcpu, ingpa, rep_cnt, false);
+               break;
+       case HVCALL_FLUSH_VIRTUAL_ADDRESS_LIST_EX:
+               if (unlikely(fast || !rep_cnt || rep_idx)) {
+                       ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
+                       break;
+               }
+               ret = kvm_hv_flush_tlb(vcpu, ingpa, rep_cnt, true);
+               break;
+       case HVCALL_FLUSH_VIRTUAL_ADDRESS_SPACE_EX:
+               if (unlikely(fast || rep)) {
+                       ret = HV_STATUS_INVALID_HYPERCALL_INPUT;
+                       break;
+               }
+               ret = kvm_hv_flush_tlb(vcpu, ingpa, rep_cnt, true);
+               break;
        default:
                ret = HV_STATUS_INVALID_HYPERCALL_CODE;
                break;
        }
 
-out:
        return kvm_hv_hypercall_complete(vcpu, ret);
 }
 
index 3773c462511404bcc94ad69742b16fdfdc26a504..b5cd8465d44f6cb99a9ae705cf2f44f3c310a1ac 100644 (file)
@@ -2002,13 +2002,11 @@ void kvm_lapic_set_base(struct kvm_vcpu *vcpu, u64 value)
                }
        }
 
-       if ((old_value ^ value) & X2APIC_ENABLE) {
-               if (value & X2APIC_ENABLE) {
-                       kvm_apic_set_x2apic_id(apic, vcpu->vcpu_id);
-                       kvm_x86_ops->set_virtual_x2apic_mode(vcpu, true);
-               } else
-                       kvm_x86_ops->set_virtual_x2apic_mode(vcpu, false);
-       }
+       if (((old_value ^ value) & X2APIC_ENABLE) && (value & X2APIC_ENABLE))
+               kvm_apic_set_x2apic_id(apic, vcpu->vcpu_id);
+
+       if ((old_value ^ value) & (MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE))
+               kvm_x86_ops->set_virtual_apic_mode(vcpu);
 
        apic->base_address = apic->vcpu->arch.apic_base &
                             MSR_IA32_APICBASE_BASE;
index edce055e9fd70845e1575a00ac6e9e2e6d41535b..ed0ed39abd36970601e39ed04edde1850c849ece 100644 (file)
 #define APIC_BUS_CYCLE_NS       1
 #define APIC_BUS_FREQUENCY      (1000000000ULL / APIC_BUS_CYCLE_NS)
 
+enum lapic_mode {
+       LAPIC_MODE_DISABLED = 0,
+       LAPIC_MODE_INVALID = X2APIC_ENABLE,
+       LAPIC_MODE_XAPIC = MSR_IA32_APICBASE_ENABLE,
+       LAPIC_MODE_X2APIC = MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE,
+};
+
 struct kvm_timer {
        struct hrtimer timer;
        s64 period;                             /* unit: ns */
@@ -89,6 +96,7 @@ u64 kvm_get_apic_base(struct kvm_vcpu *vcpu);
 int kvm_set_apic_base(struct kvm_vcpu *vcpu, struct msr_data *msr_info);
 int kvm_apic_get_state(struct kvm_vcpu *vcpu, struct kvm_lapic_state *s);
 int kvm_apic_set_state(struct kvm_vcpu *vcpu, struct kvm_lapic_state *s);
+enum lapic_mode kvm_get_apic_mode(struct kvm_vcpu *vcpu);
 int kvm_lapic_find_highest_irr(struct kvm_vcpu *vcpu);
 
 u64 kvm_get_lapic_tscdeadline_msr(struct kvm_vcpu *vcpu);
@@ -220,4 +228,10 @@ void kvm_lapic_switch_to_hv_timer(struct kvm_vcpu *vcpu);
 void kvm_lapic_expired_hv_timer(struct kvm_vcpu *vcpu);
 bool kvm_lapic_hv_timer_in_use(struct kvm_vcpu *vcpu);
 void kvm_lapic_restart_hv_timer(struct kvm_vcpu *vcpu);
+
+static inline enum lapic_mode kvm_apic_mode(u64 apic_base)
+{
+       return apic_base & (MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE);
+}
+
 #endif
index d634f0332c0fad5aec8b7e285b97d7423e064dcc..d594690d8b9597a87f4cba26e8c1be5cb2de22de 100644 (file)
@@ -222,7 +222,6 @@ static const u64 shadow_acc_track_saved_bits_mask = PT64_EPT_READABLE_MASK |
 static const u64 shadow_acc_track_saved_bits_shift = PT64_SECOND_AVAIL_BITS_SHIFT;
 
 static void mmu_spte_set(u64 *sptep, u64 spte);
-static void mmu_free_roots(struct kvm_vcpu *vcpu);
 
 void kvm_mmu_set_mmio_spte_mask(u64 mmio_mask, u64 mmio_value)
 {
@@ -3343,51 +3342,48 @@ static int nonpaging_map(struct kvm_vcpu *vcpu, gva_t v, u32 error_code,
        return RET_PF_RETRY;
 }
 
-
-static void mmu_free_roots(struct kvm_vcpu *vcpu)
+static void mmu_free_root_page(struct kvm *kvm, hpa_t *root_hpa,
+                              struct list_head *invalid_list)
 {
-       int i;
        struct kvm_mmu_page *sp;
-       LIST_HEAD(invalid_list);
 
-       if (!VALID_PAGE(vcpu->arch.mmu.root_hpa))
+       if (!VALID_PAGE(*root_hpa))
                return;
 
-       if (vcpu->arch.mmu.shadow_root_level >= PT64_ROOT_4LEVEL &&
-           (vcpu->arch.mmu.root_level >= PT64_ROOT_4LEVEL ||
-            vcpu->arch.mmu.direct_map)) {
-               hpa_t root = vcpu->arch.mmu.root_hpa;
+       sp = page_header(*root_hpa & PT64_BASE_ADDR_MASK);
+       --sp->root_count;
+       if (!sp->root_count && sp->role.invalid)
+               kvm_mmu_prepare_zap_page(kvm, sp, invalid_list);
 
-               spin_lock(&vcpu->kvm->mmu_lock);
-               sp = page_header(root);
-               --sp->root_count;
-               if (!sp->root_count && sp->role.invalid) {
-                       kvm_mmu_prepare_zap_page(vcpu->kvm, sp, &invalid_list);
-                       kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list);
-               }
-               spin_unlock(&vcpu->kvm->mmu_lock);
-               vcpu->arch.mmu.root_hpa = INVALID_PAGE;
+       *root_hpa = INVALID_PAGE;
+}
+
+void kvm_mmu_free_roots(struct kvm_vcpu *vcpu)
+{
+       int i;
+       LIST_HEAD(invalid_list);
+       struct kvm_mmu *mmu = &vcpu->arch.mmu;
+
+       if (!VALID_PAGE(mmu->root_hpa))
                return;
-       }
 
        spin_lock(&vcpu->kvm->mmu_lock);
-       for (i = 0; i < 4; ++i) {
-               hpa_t root = vcpu->arch.mmu.pae_root[i];
 
-               if (root) {
-                       root &= PT64_BASE_ADDR_MASK;
-                       sp = page_header(root);
-                       --sp->root_count;
-                       if (!sp->root_count && sp->role.invalid)
-                               kvm_mmu_prepare_zap_page(vcpu->kvm, sp,
-                                                        &invalid_list);
-               }
-               vcpu->arch.mmu.pae_root[i] = INVALID_PAGE;
+       if (mmu->shadow_root_level >= PT64_ROOT_4LEVEL &&
+           (mmu->root_level >= PT64_ROOT_4LEVEL || mmu->direct_map)) {
+               mmu_free_root_page(vcpu->kvm, &mmu->root_hpa, &invalid_list);
+       } else {
+               for (i = 0; i < 4; ++i)
+                       if (mmu->pae_root[i] != 0)
+                               mmu_free_root_page(vcpu->kvm, &mmu->pae_root[i],
+                                                  &invalid_list);
+               mmu->root_hpa = INVALID_PAGE;
        }
+
        kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list);
        spin_unlock(&vcpu->kvm->mmu_lock);
-       vcpu->arch.mmu.root_hpa = INVALID_PAGE;
 }
+EXPORT_SYMBOL_GPL(kvm_mmu_free_roots);
 
 static int mmu_check_root(struct kvm_vcpu *vcpu, gfn_t root_gfn)
 {
@@ -3720,7 +3716,6 @@ static int handle_mmio_page_fault(struct kvm_vcpu *vcpu, u64 addr, bool direct)
         */
        return RET_PF_RETRY;
 }
-EXPORT_SYMBOL_GPL(handle_mmio_page_fault);
 
 static bool page_fault_handle_page_track(struct kvm_vcpu *vcpu,
                                         u32 error_code, gfn_t gfn)
@@ -3812,6 +3807,14 @@ static bool try_async_pf(struct kvm_vcpu *vcpu, bool prefault, gfn_t gfn,
        struct kvm_memory_slot *slot;
        bool async;
 
+       /*
+        * Don't expose private memslots to L2.
+        */
+       if (is_guest_mode(vcpu) && !kvm_is_visible_gfn(vcpu->kvm, gfn)) {
+               *pfn = KVM_PFN_NOSLOT;
+               return false;
+       }
+
        slot = kvm_vcpu_gfn_to_memslot(vcpu, gfn);
        async = false;
        *pfn = __gfn_to_pfn_memslot(slot, gfn, false, &async, write, writable);
@@ -3951,7 +3954,7 @@ static void nonpaging_init_context(struct kvm_vcpu *vcpu,
 
 void kvm_mmu_new_cr3(struct kvm_vcpu *vcpu)
 {
-       mmu_free_roots(vcpu);
+       kvm_mmu_free_roots(vcpu);
 }
 
 static unsigned long get_cr3(struct kvm_vcpu *vcpu)
@@ -4473,6 +4476,7 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
        struct kvm_mmu *context = &vcpu->arch.mmu;
 
        context->base_role.word = 0;
+       context->base_role.guest_mode = is_guest_mode(vcpu);
        context->base_role.smm = is_smm(vcpu);
        context->base_role.ad_disabled = (shadow_accessed_mask == 0);
        context->page_fault = tdp_page_fault;
@@ -4539,6 +4543,7 @@ void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu)
                = smep && !is_write_protection(vcpu);
        context->base_role.smap_andnot_wp
                = smap && !is_write_protection(vcpu);
+       context->base_role.guest_mode = is_guest_mode(vcpu);
        context->base_role.smm = is_smm(vcpu);
        reset_shadow_zero_bits_mask(vcpu, context);
 }
@@ -4564,7 +4569,7 @@ void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly,
        context->root_hpa = INVALID_PAGE;
        context->direct_map = false;
        context->base_role.ad_disabled = !accessed_dirty;
-
+       context->base_role.guest_mode = 1;
        update_permission_bitmask(vcpu, context, true);
        update_pkru_bitmask(vcpu, context, true);
        update_last_nonleaf_level(vcpu, context);
@@ -4664,7 +4669,7 @@ EXPORT_SYMBOL_GPL(kvm_mmu_load);
 
 void kvm_mmu_unload(struct kvm_vcpu *vcpu)
 {
-       mmu_free_roots(vcpu);
+       kvm_mmu_free_roots(vcpu);
        WARN_ON(VALID_PAGE(vcpu->arch.mmu.root_hpa));
 }
 EXPORT_SYMBOL_GPL(kvm_mmu_unload);
@@ -4825,6 +4830,7 @@ static void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa,
        mask.smep_andnot_wp = 1;
        mask.smap_andnot_wp = 1;
        mask.smm = 1;
+       mask.guest_mode = 1;
        mask.ad_disabled = 1;
 
        /*
index 01c1371f39f8cd91912d9f4027587bfe6479dc29..3052a59a30655bcadccb53ec0cd1c14dab2b7591 100644 (file)
@@ -40,8 +40,9 @@ int kvm_page_track_create_memslot(struct kvm_memory_slot *slot,
        int  i;
 
        for (i = 0; i < KVM_PAGE_TRACK_MAX; i++) {
-               slot->arch.gfn_track[i] = kvzalloc(npages *
-                                           sizeof(*slot->arch.gfn_track[i]), GFP_KERNEL);
+               slot->arch.gfn_track[i] =
+                       kvcalloc(npages, sizeof(*slot->arch.gfn_track[i]),
+                                GFP_KERNEL);
                if (!slot->arch.gfn_track[i])
                        goto track_free;
        }
index 950ec50f77c30b71545fd93a4154875b4d9f0e4e..f059a73f0fd088fcec5f1c6cee05cf4bb9dcc9a8 100644 (file)
@@ -1001,7 +1001,9 @@ static int svm_cpu_init(int cpu)
 
        if (svm_sev_enabled()) {
                r = -ENOMEM;
-               sd->sev_vmcbs = kmalloc((max_sev_asid + 1) * sizeof(void *), GFP_KERNEL);
+               sd->sev_vmcbs = kmalloc_array(max_sev_asid + 1,
+                                             sizeof(void *),
+                                             GFP_KERNEL);
                if (!sd->sev_vmcbs)
                        goto err_1;
        }
@@ -1768,7 +1770,10 @@ static struct page **sev_pin_memory(struct kvm *kvm, unsigned long uaddr,
        unsigned long npages, npinned, size;
        unsigned long locked, lock_limit;
        struct page **pages;
-       int first, last;
+       unsigned long first, last;
+
+       if (ulen == 0 || uaddr + ulen < uaddr)
+               return NULL;
 
        /* Calculate number of pages. */
        first = (uaddr & PAGE_MASK) >> PAGE_SHIFT;
@@ -1855,13 +1860,13 @@ static void __unregister_enc_region_locked(struct kvm *kvm,
 
 static struct kvm *svm_vm_alloc(void)
 {
-       struct kvm_svm *kvm_svm = kzalloc(sizeof(struct kvm_svm), GFP_KERNEL);
+       struct kvm_svm *kvm_svm = vzalloc(sizeof(struct kvm_svm));
        return &kvm_svm->kvm;
 }
 
 static void svm_vm_free(struct kvm *kvm)
 {
-       kfree(to_kvm_svm(kvm));
+       vfree(to_kvm_svm(kvm));
 }
 
 static void sev_vm_destroy(struct kvm *kvm)
@@ -5062,7 +5067,7 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu, int tpr, int irr)
                set_cr_intercept(svm, INTERCEPT_CR8_WRITE);
 }
 
-static void svm_set_virtual_x2apic_mode(struct kvm_vcpu *vcpu, bool set)
+static void svm_set_virtual_apic_mode(struct kvm_vcpu *vcpu)
 {
        return;
 }
@@ -6949,6 +6954,9 @@ static int svm_register_enc_region(struct kvm *kvm,
        if (!sev_guest(kvm))
                return -ENOTTY;
 
+       if (range->addr > ULONG_MAX || range->size > ULONG_MAX)
+               return -EINVAL;
+
        region = kzalloc(sizeof(*region), GFP_KERNEL);
        if (!region)
                return -ENOMEM;
@@ -7100,7 +7108,7 @@ static struct kvm_x86_ops svm_x86_ops __ro_after_init = {
        .enable_nmi_window = enable_nmi_window,
        .enable_irq_window = enable_irq_window,
        .update_cr8_intercept = update_cr8_intercept,
-       .set_virtual_x2apic_mode = svm_set_virtual_x2apic_mode,
+       .set_virtual_apic_mode = svm_set_virtual_apic_mode,
        .get_enable_apicv = svm_get_enable_apicv,
        .refresh_apicv_exec_ctrl = svm_refresh_apicv_exec_ctrl,
        .load_eoi_exitmap = svm_load_eoi_exitmap,
index 9807c314c4788bad75ede5c9c8a804976f889bb6..0f997683404fad647b55abd7ad375a6c499dc75c 100644 (file)
@@ -1367,6 +1367,57 @@ TRACE_EVENT(kvm_hv_timer_state,
                        __entry->vcpu_id,
                        __entry->hv_timer_in_use)
 );
+
+/*
+ * Tracepoint for kvm_hv_flush_tlb.
+ */
+TRACE_EVENT(kvm_hv_flush_tlb,
+       TP_PROTO(u64 processor_mask, u64 address_space, u64 flags),
+       TP_ARGS(processor_mask, address_space, flags),
+
+       TP_STRUCT__entry(
+               __field(u64, processor_mask)
+               __field(u64, address_space)
+               __field(u64, flags)
+       ),
+
+       TP_fast_assign(
+               __entry->processor_mask = processor_mask;
+               __entry->address_space = address_space;
+               __entry->flags = flags;
+       ),
+
+       TP_printk("processor_mask 0x%llx address_space 0x%llx flags 0x%llx",
+                 __entry->processor_mask, __entry->address_space,
+                 __entry->flags)
+);
+
+/*
+ * Tracepoint for kvm_hv_flush_tlb_ex.
+ */
+TRACE_EVENT(kvm_hv_flush_tlb_ex,
+       TP_PROTO(u64 valid_bank_mask, u64 format, u64 address_space, u64 flags),
+       TP_ARGS(valid_bank_mask, format, address_space, flags),
+
+       TP_STRUCT__entry(
+               __field(u64, valid_bank_mask)
+               __field(u64, format)
+               __field(u64, address_space)
+               __field(u64, flags)
+       ),
+
+       TP_fast_assign(
+               __entry->valid_bank_mask = valid_bank_mask;
+               __entry->format = format;
+               __entry->address_space = address_space;
+               __entry->flags = flags;
+       ),
+
+       TP_printk("valid_bank_mask 0x%llx format 0x%llx "
+                 "address_space 0x%llx flags 0x%llx",
+                 __entry->valid_bank_mask, __entry->format,
+                 __entry->address_space, __entry->flags)
+);
 #endif /* _TRACE_KVM_H */
 
 #undef TRACE_INCLUDE_PATH
index 40aa29204baf80aee54056dffb69519cc6cb5f89..559a12b6184de38c67ef4f2001963600f41f8753 100644 (file)
@@ -242,7 +242,11 @@ struct shared_msr_entry {
  * underlying hardware which will be used to run L2.
  * This structure is packed to ensure that its layout is identical across
  * machines (necessary for live migration).
- * If there are changes in this struct, VMCS12_REVISION must be changed.
+ *
+ * IMPORTANT: Changing the layout of existing fields in this structure
+ * will break save/restore compatibility with older kvm releases. When
+ * adding new fields, either use space in the reserved padding* arrays
+ * or add the new fields to the end of the structure.
  */
 typedef u64 natural_width;
 struct __packed vmcs12 {
@@ -265,17 +269,14 @@ struct __packed vmcs12 {
        u64 virtual_apic_page_addr;
        u64 apic_access_addr;
        u64 posted_intr_desc_addr;
-       u64 vm_function_control;
        u64 ept_pointer;
        u64 eoi_exit_bitmap0;
        u64 eoi_exit_bitmap1;
        u64 eoi_exit_bitmap2;
        u64 eoi_exit_bitmap3;
-       u64 eptp_list_address;
        u64 xss_exit_bitmap;
        u64 guest_physical_address;
        u64 vmcs_link_pointer;
-       u64 pml_address;
        u64 guest_ia32_debugctl;
        u64 guest_ia32_pat;
        u64 guest_ia32_efer;
@@ -288,7 +289,12 @@ struct __packed vmcs12 {
        u64 host_ia32_pat;
        u64 host_ia32_efer;
        u64 host_ia32_perf_global_ctrl;
-       u64 padding64[8]; /* room for future expansion */
+       u64 vmread_bitmap;
+       u64 vmwrite_bitmap;
+       u64 vm_function_control;
+       u64 eptp_list_address;
+       u64 pml_address;
+       u64 padding64[3]; /* room for future expansion */
        /*
         * To allow migration of L1 (complete with its L2 guests) between
         * machines of different natural widths (32 or 64 bit), we cannot have
@@ -397,7 +403,6 @@ struct __packed vmcs12 {
        u16 guest_ldtr_selector;
        u16 guest_tr_selector;
        u16 guest_intr_status;
-       u16 guest_pml_index;
        u16 host_es_selector;
        u16 host_cs_selector;
        u16 host_ss_selector;
@@ -405,12 +410,172 @@ struct __packed vmcs12 {
        u16 host_fs_selector;
        u16 host_gs_selector;
        u16 host_tr_selector;
+       u16 guest_pml_index;
 };
 
+/*
+ * For save/restore compatibility, the vmcs12 field offsets must not change.
+ */
+#define CHECK_OFFSET(field, loc)                               \
+       BUILD_BUG_ON_MSG(offsetof(struct vmcs12, field) != (loc),       \
+               "Offset of " #field " in struct vmcs12 has changed.")
+
+static inline void vmx_check_vmcs12_offsets(void) {
+       CHECK_OFFSET(revision_id, 0);
+       CHECK_OFFSET(abort, 4);
+       CHECK_OFFSET(launch_state, 8);
+       CHECK_OFFSET(io_bitmap_a, 40);
+       CHECK_OFFSET(io_bitmap_b, 48);
+       CHECK_OFFSET(msr_bitmap, 56);
+       CHECK_OFFSET(vm_exit_msr_store_addr, 64);
+       CHECK_OFFSET(vm_exit_msr_load_addr, 72);
+       CHECK_OFFSET(vm_entry_msr_load_addr, 80);
+       CHECK_OFFSET(tsc_offset, 88);
+       CHECK_OFFSET(virtual_apic_page_addr, 96);
+       CHECK_OFFSET(apic_access_addr, 104);
+       CHECK_OFFSET(posted_intr_desc_addr, 112);
+       CHECK_OFFSET(ept_pointer, 120);
+       CHECK_OFFSET(eoi_exit_bitmap0, 128);
+       CHECK_OFFSET(eoi_exit_bitmap1, 136);
+       CHECK_OFFSET(eoi_exit_bitmap2, 144);
+       CHECK_OFFSET(eoi_exit_bitmap3, 152);
+       CHECK_OFFSET(xss_exit_bitmap, 160);
+       CHECK_OFFSET(guest_physical_address, 168);
+       CHECK_OFFSET(vmcs_link_pointer, 176);
+       CHECK_OFFSET(guest_ia32_debugctl, 184);
+       CHECK_OFFSET(guest_ia32_pat, 192);
+       CHECK_OFFSET(guest_ia32_efer, 200);
+       CHECK_OFFSET(guest_ia32_perf_global_ctrl, 208);
+       CHECK_OFFSET(guest_pdptr0, 216);
+       CHECK_OFFSET(guest_pdptr1, 224);
+       CHECK_OFFSET(guest_pdptr2, 232);
+       CHECK_OFFSET(guest_pdptr3, 240);
+       CHECK_OFFSET(guest_bndcfgs, 248);
+       CHECK_OFFSET(host_ia32_pat, 256);
+       CHECK_OFFSET(host_ia32_efer, 264);
+       CHECK_OFFSET(host_ia32_perf_global_ctrl, 272);
+       CHECK_OFFSET(vmread_bitmap, 280);
+       CHECK_OFFSET(vmwrite_bitmap, 288);
+       CHECK_OFFSET(vm_function_control, 296);
+       CHECK_OFFSET(eptp_list_address, 304);
+       CHECK_OFFSET(pml_address, 312);
+       CHECK_OFFSET(cr0_guest_host_mask, 344);
+       CHECK_OFFSET(cr4_guest_host_mask, 352);
+       CHECK_OFFSET(cr0_read_shadow, 360);
+       CHECK_OFFSET(cr4_read_shadow, 368);
+       CHECK_OFFSET(cr3_target_value0, 376);
+       CHECK_OFFSET(cr3_target_value1, 384);
+       CHECK_OFFSET(cr3_target_value2, 392);
+       CHECK_OFFSET(cr3_target_value3, 400);
+       CHECK_OFFSET(exit_qualification, 408);
+       CHECK_OFFSET(guest_linear_address, 416);
+       CHECK_OFFSET(guest_cr0, 424);
+       CHECK_OFFSET(guest_cr3, 432);
+       CHECK_OFFSET(guest_cr4, 440);
+       CHECK_OFFSET(guest_es_base, 448);
+       CHECK_OFFSET(guest_cs_base, 456);
+       CHECK_OFFSET(guest_ss_base, 464);
+       CHECK_OFFSET(guest_ds_base, 472);
+       CHECK_OFFSET(guest_fs_base, 480);
+       CHECK_OFFSET(guest_gs_base, 488);
+       CHECK_OFFSET(guest_ldtr_base, 496);
+       CHECK_OFFSET(guest_tr_base, 504);
+       CHECK_OFFSET(guest_gdtr_base, 512);
+       CHECK_OFFSET(guest_idtr_base, 520);
+       CHECK_OFFSET(guest_dr7, 528);
+       CHECK_OFFSET(guest_rsp, 536);
+       CHECK_OFFSET(guest_rip, 544);
+       CHECK_OFFSET(guest_rflags, 552);
+       CHECK_OFFSET(guest_pending_dbg_exceptions, 560);
+       CHECK_OFFSET(guest_sysenter_esp, 568);
+       CHECK_OFFSET(guest_sysenter_eip, 576);
+       CHECK_OFFSET(host_cr0, 584);
+       CHECK_OFFSET(host_cr3, 592);
+       CHECK_OFFSET(host_cr4, 600);
+       CHECK_OFFSET(host_fs_base, 608);
+       CHECK_OFFSET(host_gs_base, 616);
+       CHECK_OFFSET(host_tr_base, 624);
+       CHECK_OFFSET(host_gdtr_base, 632);
+       CHECK_OFFSET(host_idtr_base, 640);
+       CHECK_OFFSET(host_ia32_sysenter_esp, 648);
+       CHECK_OFFSET(host_ia32_sysenter_eip, 656);
+       CHECK_OFFSET(host_rsp, 664);
+       CHECK_OFFSET(host_rip, 672);
+       CHECK_OFFSET(pin_based_vm_exec_control, 744);
+       CHECK_OFFSET(cpu_based_vm_exec_control, 748);
+       CHECK_OFFSET(exception_bitmap, 752);
+       CHECK_OFFSET(page_fault_error_code_mask, 756);
+       CHECK_OFFSET(page_fault_error_code_match, 760);
+       CHECK_OFFSET(cr3_target_count, 764);
+       CHECK_OFFSET(vm_exit_controls, 768);
+       CHECK_OFFSET(vm_exit_msr_store_count, 772);
+       CHECK_OFFSET(vm_exit_msr_load_count, 776);
+       CHECK_OFFSET(vm_entry_controls, 780);
+       CHECK_OFFSET(vm_entry_msr_load_count, 784);
+       CHECK_OFFSET(vm_entry_intr_info_field, 788);
+       CHECK_OFFSET(vm_entry_exception_error_code, 792);
+       CHECK_OFFSET(vm_entry_instruction_len, 796);
+       CHECK_OFFSET(tpr_threshold, 800);
+       CHECK_OFFSET(secondary_vm_exec_control, 804);
+       CHECK_OFFSET(vm_instruction_error, 808);
+       CHECK_OFFSET(vm_exit_reason, 812);
+       CHECK_OFFSET(vm_exit_intr_info, 816);
+       CHECK_OFFSET(vm_exit_intr_error_code, 820);
+       CHECK_OFFSET(idt_vectoring_info_field, 824);
+       CHECK_OFFSET(idt_vectoring_error_code, 828);
+       CHECK_OFFSET(vm_exit_instruction_len, 832);
+       CHECK_OFFSET(vmx_instruction_info, 836);
+       CHECK_OFFSET(guest_es_limit, 840);
+       CHECK_OFFSET(guest_cs_limit, 844);
+       CHECK_OFFSET(guest_ss_limit, 848);
+       CHECK_OFFSET(guest_ds_limit, 852);
+       CHECK_OFFSET(guest_fs_limit, 856);
+       CHECK_OFFSET(guest_gs_limit, 860);
+       CHECK_OFFSET(guest_ldtr_limit, 864);
+       CHECK_OFFSET(guest_tr_limit, 868);
+       CHECK_OFFSET(guest_gdtr_limit, 872);
+       CHECK_OFFSET(guest_idtr_limit, 876);
+       CHECK_OFFSET(guest_es_ar_bytes, 880);
+       CHECK_OFFSET(guest_cs_ar_bytes, 884);
+       CHECK_OFFSET(guest_ss_ar_bytes, 888);
+       CHECK_OFFSET(guest_ds_ar_bytes, 892);
+       CHECK_OFFSET(guest_fs_ar_bytes, 896);
+       CHECK_OFFSET(guest_gs_ar_bytes, 900);
+       CHECK_OFFSET(guest_ldtr_ar_bytes, 904);
+       CHECK_OFFSET(guest_tr_ar_bytes, 908);
+       CHECK_OFFSET(guest_interruptibility_info, 912);
+       CHECK_OFFSET(guest_activity_state, 916);
+       CHECK_OFFSET(guest_sysenter_cs, 920);
+       CHECK_OFFSET(host_ia32_sysenter_cs, 924);
+       CHECK_OFFSET(vmx_preemption_timer_value, 928);
+       CHECK_OFFSET(virtual_processor_id, 960);
+       CHECK_OFFSET(posted_intr_nv, 962);
+       CHECK_OFFSET(guest_es_selector, 964);
+       CHECK_OFFSET(guest_cs_selector, 966);
+       CHECK_OFFSET(guest_ss_selector, 968);
+       CHECK_OFFSET(guest_ds_selector, 970);
+       CHECK_OFFSET(guest_fs_selector, 972);
+       CHECK_OFFSET(guest_gs_selector, 974);
+       CHECK_OFFSET(guest_ldtr_selector, 976);
+       CHECK_OFFSET(guest_tr_selector, 978);
+       CHECK_OFFSET(guest_intr_status, 980);
+       CHECK_OFFSET(host_es_selector, 982);
+       CHECK_OFFSET(host_cs_selector, 984);
+       CHECK_OFFSET(host_ss_selector, 986);
+       CHECK_OFFSET(host_ds_selector, 988);
+       CHECK_OFFSET(host_fs_selector, 990);
+       CHECK_OFFSET(host_gs_selector, 992);
+       CHECK_OFFSET(host_tr_selector, 994);
+       CHECK_OFFSET(guest_pml_index, 996);
+}
+
 /*
  * VMCS12_REVISION is an arbitrary id that should be changed if the content or
  * layout of struct vmcs12 is changed. MSR_IA32_VMX_BASIC returns this id, and
  * VMPTRLD verifies that the VMCS region that L1 is loading contains this id.
+ *
+ * IMPORTANT: Changing this value will break save/restore compatibility with
+ * older kvm releases.
  */
 #define VMCS12_REVISION 0x11e57ed0
 
@@ -481,7 +646,8 @@ struct nested_vmx {
        bool sync_shadow_vmcs;
        bool dirty_vmcs12;
 
-       bool change_vmcs01_virtual_x2apic_mode;
+       bool change_vmcs01_virtual_apic_mode;
+
        /* L2 must run next, and mustn't decide to exit to L1. */
        bool nested_run_pending;
 
@@ -761,6 +927,7 @@ static const unsigned short vmcs_field_to_offset_table[] = {
        FIELD64(VM_EXIT_MSR_STORE_ADDR, vm_exit_msr_store_addr),
        FIELD64(VM_EXIT_MSR_LOAD_ADDR, vm_exit_msr_load_addr),
        FIELD64(VM_ENTRY_MSR_LOAD_ADDR, vm_entry_msr_load_addr),
+       FIELD64(PML_ADDRESS, pml_address),
        FIELD64(TSC_OFFSET, tsc_offset),
        FIELD64(VIRTUAL_APIC_PAGE_ADDR, virtual_apic_page_addr),
        FIELD64(APIC_ACCESS_ADDR, apic_access_addr),
@@ -772,10 +939,11 @@ static const unsigned short vmcs_field_to_offset_table[] = {
        FIELD64(EOI_EXIT_BITMAP2, eoi_exit_bitmap2),
        FIELD64(EOI_EXIT_BITMAP3, eoi_exit_bitmap3),
        FIELD64(EPTP_LIST_ADDRESS, eptp_list_address),
+       FIELD64(VMREAD_BITMAP, vmread_bitmap),
+       FIELD64(VMWRITE_BITMAP, vmwrite_bitmap),
        FIELD64(XSS_EXIT_BITMAP, xss_exit_bitmap),
        FIELD64(GUEST_PHYSICAL_ADDRESS, guest_physical_address),
        FIELD64(VMCS_LINK_POINTER, vmcs_link_pointer),
-       FIELD64(PML_ADDRESS, pml_address),
        FIELD64(GUEST_IA32_DEBUGCTL, guest_ia32_debugctl),
        FIELD64(GUEST_IA32_PAT, guest_ia32_pat),
        FIELD64(GUEST_IA32_EFER, guest_ia32_efer),
@@ -1089,6 +1257,16 @@ static inline u16 evmcs_read16(unsigned long field)
        return *(u16 *)((char *)current_evmcs + offset);
 }
 
+static inline void evmcs_touch_msr_bitmap(void)
+{
+       if (unlikely(!current_evmcs))
+               return;
+
+       if (current_evmcs->hv_enlightenments_control.msr_bitmap)
+               current_evmcs->hv_clean_fields &=
+                       ~HV_VMX_ENLIGHTENED_CLEAN_FIELD_MSR_BITMAP;
+}
+
 static void evmcs_load(u64 phys_addr)
 {
        struct hv_vp_assist_page *vp_ap =
@@ -1173,6 +1351,7 @@ static inline u32 evmcs_read32(unsigned long field) { return 0; }
 static inline u16 evmcs_read16(unsigned long field) { return 0; }
 static inline void evmcs_load(u64 phys_addr) {}
 static inline void evmcs_sanitize_exec_ctrls(struct vmcs_config *vmcs_conf) {}
+static inline void evmcs_touch_msr_bitmap(void) {}
 #endif /* IS_ENABLED(CONFIG_HYPERV) */
 
 static inline bool is_exception_n(u32 intr_info, u8 vector)
@@ -1393,6 +1572,11 @@ static inline bool cpu_has_vmx_invept_global(void)
        return vmx_capability.ept & VMX_EPT_EXTENT_GLOBAL_BIT;
 }
 
+static inline bool cpu_has_vmx_invvpid_individual_addr(void)
+{
+       return vmx_capability.vpid & VMX_VPID_EXTENT_INDIVIDUAL_ADDR_BIT;
+}
+
 static inline bool cpu_has_vmx_invvpid_single(void)
 {
        return vmx_capability.vpid & VMX_VPID_EXTENT_SINGLE_CONTEXT_BIT;
@@ -1510,6 +1694,17 @@ static inline unsigned nested_cpu_vmx_misc_cr3_count(struct kvm_vcpu *vcpu)
        return vmx_misc_cr3_count(to_vmx(vcpu)->nested.msrs.misc_low);
 }
 
+/*
+ * Do the virtual VMX capability MSRs specify that L1 can use VMWRITE
+ * to modify any valid field of the VMCS, or are the VM-exit
+ * information fields read-only?
+ */
+static inline bool nested_cpu_has_vmwrite_any_field(struct kvm_vcpu *vcpu)
+{
+       return to_vmx(vcpu)->nested.msrs.misc_low &
+               MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS;
+}
+
 static inline bool nested_cpu_has(struct vmcs12 *vmcs12, u32 bit)
 {
        return vmcs12->cpu_based_vm_exec_control & bit;
@@ -3127,6 +3322,7 @@ static void nested_vmx_setup_ctls_msrs(struct nested_vmx_msrs *msrs, bool apicv)
                msrs->misc_high);
        msrs->misc_low &= VMX_MISC_SAVE_EFER_LMA;
        msrs->misc_low |=
+               MSR_IA32_VMX_MISC_VMWRITE_SHADOW_RO_FIELDS |
                VMX_MISC_EMULATED_PREEMPTION_TIMER_RATE |
                VMX_MISC_ACTIVITY_HLT;
        msrs->misc_high = 0;
@@ -3300,6 +3496,15 @@ static int vmx_restore_vmx_misc(struct vcpu_vmx *vmx, u64 data)
 
        vmx->nested.msrs.misc_low = data;
        vmx->nested.msrs.misc_high = data >> 32;
+
+       /*
+        * If L1 has read-only VM-exit information fields, use the
+        * less permissive vmx_vmwrite_bitmap to specify write
+        * permissions for the shadow VMCS.
+        */
+       if (enable_shadow_vmcs && !nested_cpu_has_vmwrite_any_field(&vmx->vcpu))
+               vmcs_write64(VMWRITE_BITMAP, __pa(vmx_vmwrite_bitmap));
+
        return 0;
 }
 
@@ -3354,6 +3559,13 @@ static int vmx_set_vmx_msr(struct kvm_vcpu *vcpu, u32 msr_index, u64 data)
 {
        struct vcpu_vmx *vmx = to_vmx(vcpu);
 
+       /*
+        * Don't allow changes to the VMX capability MSRs while the vCPU
+        * is in VMX operation.
+        */
+       if (vmx->nested.vmxon)
+               return -EBUSY;
+
        switch (msr_index) {
        case MSR_IA32_VMX_BASIC:
                return vmx_restore_vmx_basic(vmx, data);
@@ -4216,6 +4428,15 @@ static int alloc_loaded_vmcs(struct loaded_vmcs *loaded_vmcs)
                if (!loaded_vmcs->msr_bitmap)
                        goto out_vmcs;
                memset(loaded_vmcs->msr_bitmap, 0xff, PAGE_SIZE);
+
+               if (IS_ENABLED(CONFIG_HYPERV) &&
+                   static_branch_unlikely(&enable_evmcs) &&
+                   (ms_hyperv.nested_features & HV_X64_NESTED_MSR_BITMAP)) {
+                       struct hv_enlightened_vmcs *evmcs =
+                               (struct hv_enlightened_vmcs *)loaded_vmcs->vmcs;
+
+                       evmcs->hv_enlightenments_control.msr_bitmap = 1;
+               }
        }
        return 0;
 
@@ -5329,6 +5550,9 @@ static void __always_inline vmx_disable_intercept_for_msr(unsigned long *msr_bit
        if (!cpu_has_vmx_msr_bitmap())
                return;
 
+       if (static_branch_unlikely(&enable_evmcs))
+               evmcs_touch_msr_bitmap();
+
        /*
         * See Intel PRM Vol. 3, 20.6.9 (MSR-Bitmap Address). Early manuals
         * have the write-low and read-high bitmap offsets the wrong way round.
@@ -5364,6 +5588,9 @@ static void __always_inline vmx_enable_intercept_for_msr(unsigned long *msr_bitm
        if (!cpu_has_vmx_msr_bitmap())
                return;
 
+       if (static_branch_unlikely(&enable_evmcs))
+               evmcs_touch_msr_bitmap();
+
        /*
         * See Intel PRM Vol. 3, 20.6.9 (MSR-Bitmap Address). Early manuals
         * have the write-low and read-high bitmap offsets the wrong way round.
@@ -5946,8 +6173,14 @@ static void vmx_vcpu_setup(struct vcpu_vmx *vmx)
        int i;
 
        if (enable_shadow_vmcs) {
+               /*
+                * At vCPU creation, "VMWRITE to any supported field
+                * in the VMCS" is supported, so use the more
+                * permissive vmx_vmread_bitmap to specify both read
+                * and write permissions for the shadow VMCS.
+                */
                vmcs_write64(VMREAD_BITMAP, __pa(vmx_vmread_bitmap));
-               vmcs_write64(VMWRITE_BITMAP, __pa(vmx_vmwrite_bitmap));
+               vmcs_write64(VMWRITE_BITMAP, __pa(vmx_vmread_bitmap));
        }
        if (cpu_has_vmx_msr_bitmap())
                vmcs_write64(MSR_BITMAP, __pa(vmx->vmcs01.msr_bitmap));
@@ -7588,8 +7821,7 @@ static int nested_vmx_get_vmptr(struct kvm_vcpu *vcpu, gpa_t *vmpointer)
                        vmcs_read32(VMX_INSTRUCTION_INFO), false, &gva))
                return 1;
 
-       if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva, vmpointer,
-                               sizeof(*vmpointer), &e)) {
+       if (kvm_read_guest_virt(vcpu, gva, vmpointer, sizeof(*vmpointer), &e)) {
                kvm_inject_page_fault(vcpu, &e);
                return 1;
        }
@@ -7670,6 +7902,12 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
                return 1;
        }
 
+       /* CPL=0 must be checked manually. */
+       if (vmx_get_cpl(vcpu)) {
+               kvm_queue_exception(vcpu, UD_VECTOR);
+               return 1;
+       }
+
        if (vmx->nested.vmxon) {
                nested_vmx_failValid(vcpu, VMXERR_VMXON_IN_VMX_ROOT_OPERATION);
                return kvm_skip_emulated_instruction(vcpu);
@@ -7729,6 +7967,11 @@ static int handle_vmon(struct kvm_vcpu *vcpu)
  */
 static int nested_vmx_check_permission(struct kvm_vcpu *vcpu)
 {
+       if (vmx_get_cpl(vcpu)) {
+               kvm_queue_exception(vcpu, UD_VECTOR);
+               return 0;
+       }
+
        if (!to_vmx(vcpu)->nested.vmxon) {
                kvm_queue_exception(vcpu, UD_VECTOR);
                return 0;
@@ -7928,23 +8171,42 @@ static inline int vmcs12_write_any(struct kvm_vcpu *vcpu,
 
 }
 
+/*
+ * Copy the writable VMCS shadow fields back to the VMCS12, in case
+ * they have been modified by the L1 guest. Note that the "read-only"
+ * VM-exit information fields are actually writable if the vCPU is
+ * configured to support "VMWRITE to any supported field in the VMCS."
+ */
 static void copy_shadow_to_vmcs12(struct vcpu_vmx *vmx)
 {
-       int i;
+       const u16 *fields[] = {
+               shadow_read_write_fields,
+               shadow_read_only_fields
+       };
+       const int max_fields[] = {
+               max_shadow_read_write_fields,
+               max_shadow_read_only_fields
+       };
+       int i, q;
        unsigned long field;
        u64 field_value;
        struct vmcs *shadow_vmcs = vmx->vmcs01.shadow_vmcs;
-       const u16 *fields = shadow_read_write_fields;
-       const int num_fields = max_shadow_read_write_fields;
 
        preempt_disable();
 
        vmcs_load(shadow_vmcs);
 
-       for (i = 0; i < num_fields; i++) {
-               field = fields[i];
-               field_value = __vmcs_readl(field);
-               vmcs12_write_any(&vmx->vcpu, field, field_value);
+       for (q = 0; q < ARRAY_SIZE(fields); q++) {
+               for (i = 0; i < max_fields[q]; i++) {
+                       field = fields[q][i];
+                       field_value = __vmcs_readl(field);
+                       vmcs12_write_any(&vmx->vcpu, field, field_value);
+               }
+               /*
+                * Skip the VM-exit information fields if they are read-only.
+                */
+               if (!nested_cpu_has_vmwrite_any_field(&vmx->vcpu))
+                       break;
        }
 
        vmcs_clear(shadow_vmcs);
@@ -8029,9 +8291,9 @@ static int handle_vmread(struct kvm_vcpu *vcpu)
                if (get_vmx_mem_address(vcpu, exit_qualification,
                                vmx_instruction_info, true, &gva))
                        return 1;
-               /* _system ok, as hardware has verified cpl=0 */
-               kvm_write_guest_virt_system(&vcpu->arch.emulate_ctxt, gva,
-                            &field_value, (is_long_mode(vcpu) ? 8 : 4), NULL);
+               /* _system ok, nested_vmx_check_permission has verified cpl=0 */
+               kvm_write_guest_virt_system(vcpu, gva, &field_value,
+                                           (is_long_mode(vcpu) ? 8 : 4), NULL);
        }
 
        nested_vmx_succeed(vcpu);
@@ -8069,8 +8331,8 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu)
                if (get_vmx_mem_address(vcpu, exit_qualification,
                                vmx_instruction_info, false, &gva))
                        return 1;
-               if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva,
-                          &field_value, (is_64_bit_mode(vcpu) ? 8 : 4), &e)) {
+               if (kvm_read_guest_virt(vcpu, gva, &field_value,
+                                       (is_64_bit_mode(vcpu) ? 8 : 4), &e)) {
                        kvm_inject_page_fault(vcpu, &e);
                        return 1;
                }
@@ -8078,7 +8340,12 @@ static int handle_vmwrite(struct kvm_vcpu *vcpu)
 
 
        field = kvm_register_readl(vcpu, (((vmx_instruction_info) >> 28) & 0xf));
-       if (vmcs_field_readonly(field)) {
+       /*
+        * If the vCPU supports "VMWRITE to any supported field in the
+        * VMCS," then the "read-only" fields are actually read/write.
+        */
+       if (vmcs_field_readonly(field) &&
+           !nested_cpu_has_vmwrite_any_field(vcpu)) {
                nested_vmx_failValid(vcpu,
                        VMXERR_VMWRITE_READ_ONLY_VMCS_COMPONENT);
                return kvm_skip_emulated_instruction(vcpu);
@@ -8189,10 +8456,10 @@ static int handle_vmptrst(struct kvm_vcpu *vcpu)
        if (get_vmx_mem_address(vcpu, exit_qualification,
                        vmx_instruction_info, true, &vmcs_gva))
                return 1;
-       /* ok to use *_system, as hardware has verified cpl=0 */
-       if (kvm_write_guest_virt_system(&vcpu->arch.emulate_ctxt, vmcs_gva,
-                                (void *)&to_vmx(vcpu)->nested.current_vmptr,
-                                sizeof(u64), &e)) {
+       /* *_system ok, nested_vmx_check_permission has verified cpl=0 */
+       if (kvm_write_guest_virt_system(vcpu, vmcs_gva,
+                                       (void *)&to_vmx(vcpu)->nested.current_vmptr,
+                                       sizeof(u64), &e)) {
                kvm_inject_page_fault(vcpu, &e);
                return 1;
        }
@@ -8239,8 +8506,7 @@ static int handle_invept(struct kvm_vcpu *vcpu)
        if (get_vmx_mem_address(vcpu, vmcs_readl(EXIT_QUALIFICATION),
                        vmx_instruction_info, false, &gva))
                return 1;
-       if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva, &operand,
-                               sizeof(operand), &e)) {
+       if (kvm_read_guest_virt(vcpu, gva, &operand, sizeof(operand), &e)) {
                kvm_inject_page_fault(vcpu, &e);
                return 1;
        }
@@ -8304,8 +8570,7 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
        if (get_vmx_mem_address(vcpu, vmcs_readl(EXIT_QUALIFICATION),
                        vmx_instruction_info, false, &gva))
                return 1;
-       if (kvm_read_guest_virt(&vcpu->arch.emulate_ctxt, gva, &operand,
-                               sizeof(operand), &e)) {
+       if (kvm_read_guest_virt(vcpu, gva, &operand, sizeof(operand), &e)) {
                kvm_inject_page_fault(vcpu, &e);
                return 1;
        }
@@ -8317,12 +8582,19 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
 
        switch (type) {
        case VMX_VPID_EXTENT_INDIVIDUAL_ADDR:
-               if (is_noncanonical_address(operand.gla, vcpu)) {
+               if (!operand.vpid ||
+                   is_noncanonical_address(operand.gla, vcpu)) {
                        nested_vmx_failValid(vcpu,
                                VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
                        return kvm_skip_emulated_instruction(vcpu);
                }
-               /* fall through */
+               if (cpu_has_vmx_invvpid_individual_addr() &&
+                   vmx->nested.vpid02) {
+                       __invvpid(VMX_VPID_EXTENT_INDIVIDUAL_ADDR,
+                               vmx->nested.vpid02, operand.gla);
+               } else
+                       __vmx_flush_tlb(vcpu, vmx->nested.vpid02, true);
+               break;
        case VMX_VPID_EXTENT_SINGLE_CONTEXT:
        case VMX_VPID_EXTENT_SINGLE_NON_GLOBAL:
                if (!operand.vpid) {
@@ -8330,15 +8602,16 @@ static int handle_invvpid(struct kvm_vcpu *vcpu)
                                VMXERR_INVALID_OPERAND_TO_INVEPT_INVVPID);
                        return kvm_skip_emulated_instruction(vcpu);
                }
+               __vmx_flush_tlb(vcpu, vmx->nested.vpid02, true);
                break;
        case VMX_VPID_EXTENT_ALL_CONTEXT:
+               __vmx_flush_tlb(vcpu, vmx->nested.vpid02, true);
                break;
        default:
                WARN_ON_ONCE(1);
                return kvm_skip_emulated_instruction(vcpu);
        }
 
-       __vmx_flush_tlb(vcpu, vmx->nested.vpid02, true);
        nested_vmx_succeed(vcpu);
 
        return kvm_skip_emulated_instruction(vcpu);
@@ -8842,11 +9115,13 @@ static bool nested_vmx_exit_reflected(struct kvm_vcpu *vcpu, u32 exit_reason)
        case EXIT_REASON_TPR_BELOW_THRESHOLD:
                return nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW);
        case EXIT_REASON_APIC_ACCESS:
-               return nested_cpu_has2(vmcs12,
-                       SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES);
        case EXIT_REASON_APIC_WRITE:
        case EXIT_REASON_EOI_INDUCED:
-               /* apic_write and eoi_induced should exit unconditionally. */
+               /*
+                * The controls for "virtualize APIC accesses," "APIC-
+                * register virtualization," and "virtual-interrupt
+                * delivery" only come from vmcs12.
+                */
                return true;
        case EXIT_REASON_EPT_VIOLATION:
                /*
@@ -9253,31 +9528,43 @@ static void update_cr8_intercept(struct kvm_vcpu *vcpu, int tpr, int irr)
        vmcs_write32(TPR_THRESHOLD, irr);
 }
 
-static void vmx_set_virtual_x2apic_mode(struct kvm_vcpu *vcpu, bool set)
+static void vmx_set_virtual_apic_mode(struct kvm_vcpu *vcpu)
 {
        u32 sec_exec_control;
 
+       if (!lapic_in_kernel(vcpu))
+               return;
+
        /* Postpone execution until vmcs01 is the current VMCS. */
        if (is_guest_mode(vcpu)) {
-               to_vmx(vcpu)->nested.change_vmcs01_virtual_x2apic_mode = true;
+               to_vmx(vcpu)->nested.change_vmcs01_virtual_apic_mode = true;
                return;
        }
 
-       if (!cpu_has_vmx_virtualize_x2apic_mode())
-               return;
-
        if (!cpu_need_tpr_shadow(vcpu))
                return;
 
        sec_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
+       sec_exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
+                             SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE);
 
-       if (set) {
-               sec_exec_control &= ~SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
-               sec_exec_control |= SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE;
-       } else {
-               sec_exec_control &= ~SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE;
-               sec_exec_control |= SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
-               vmx_flush_tlb(vcpu, true);
+       switch (kvm_get_apic_mode(vcpu)) {
+       case LAPIC_MODE_INVALID:
+               WARN_ONCE(true, "Invalid local APIC state");
+       case LAPIC_MODE_DISABLED:
+               break;
+       case LAPIC_MODE_XAPIC:
+               if (flexpriority_enabled) {
+                       sec_exec_control |=
+                               SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES;
+                       vmx_flush_tlb(vcpu, true);
+               }
+               break;
+       case LAPIC_MODE_X2APIC:
+               if (cpu_has_vmx_virtualize_x2apic_mode())
+                       sec_exec_control |=
+                               SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE;
+               break;
        }
        vmcs_write32(SECONDARY_VM_EXEC_CONTROL, sec_exec_control);
 
@@ -9286,24 +9573,7 @@ static void vmx_set_virtual_x2apic_mode(struct kvm_vcpu *vcpu, bool set)
 
 static void vmx_set_apic_access_page_addr(struct kvm_vcpu *vcpu, hpa_t hpa)
 {
-       struct vcpu_vmx *vmx = to_vmx(vcpu);
-
-       /*
-        * Currently we do not handle the nested case where L2 has an
-        * APIC access page of its own; that page is still pinned.
-        * Hence, we skip the case where the VCPU is in guest mode _and_
-        * L1 prepared an APIC access page for L2.
-        *
-        * For the case where L1 and L2 share the same APIC access page
-        * (flexpriority=Y but SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES clear
-        * in the vmcs12), this function will only update either the vmcs01
-        * or the vmcs02.  If the former, the vmcs02 will be updated by
-        * prepare_vmcs02.  If the latter, the vmcs01 will be updated in
-        * the next L2->L1 exit.
-        */
-       if (!is_guest_mode(vcpu) ||
-           !nested_cpu_has2(get_vmcs12(&vmx->vcpu),
-                            SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) {
+       if (!is_guest_mode(vcpu)) {
                vmcs_write64(APIC_ACCESS_ADDR, hpa);
                vmx_flush_tlb(vcpu, true);
        }
@@ -9943,13 +10213,13 @@ STACK_FRAME_NON_STANDARD(vmx_vcpu_run);
 
 static struct kvm *vmx_vm_alloc(void)
 {
-       struct kvm_vmx *kvm_vmx = kzalloc(sizeof(struct kvm_vmx), GFP_KERNEL);
+       struct kvm_vmx *kvm_vmx = vzalloc(sizeof(struct kvm_vmx));
        return &kvm_vmx->kvm;
 }
 
 static void vmx_vm_free(struct kvm *kvm)
 {
-       kfree(to_kvm_vmx(kvm));
+       vfree(to_kvm_vmx(kvm));
 }
 
 static void vmx_switch_vmcs(struct kvm_vcpu *vcpu, struct loaded_vmcs *vmcs)
@@ -10387,11 +10657,6 @@ static void nested_get_vmcs12_pages(struct kvm_vcpu *vcpu,
                        vmcs_clear_bits(SECONDARY_VM_EXEC_CONTROL,
                                        SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES);
                }
-       } else if (!(nested_cpu_has_virt_x2apic_mode(vmcs12)) &&
-                  cpu_need_virtualize_apic_accesses(&vmx->vcpu)) {
-               vmcs_set_bits(SECONDARY_VM_EXEC_CONTROL,
-                             SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES);
-               kvm_vcpu_reload_apic_access_page(vcpu);
        }
 
        if (nested_cpu_has(vmcs12, CPU_BASED_TPR_SHADOW)) {
@@ -10871,8 +11136,7 @@ static int nested_vmx_load_cr3(struct kvm_vcpu *vcpu, unsigned long cr3, bool ne
        return 0;
 }
 
-static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
-                              bool from_vmentry)
+static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12)
 {
        struct vcpu_vmx *vmx = to_vmx(vcpu);
 
@@ -11006,13 +11270,13 @@ static void prepare_vmcs02_full(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
  * is assigned to entry_failure_code on failure.
  */
 static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
-                         bool from_vmentry, u32 *entry_failure_code)
+                         u32 *entry_failure_code)
 {
        struct vcpu_vmx *vmx = to_vmx(vcpu);
        u32 exec_control, vmcs12_exec_ctrl;
 
        if (vmx->nested.dirty_vmcs12) {
-               prepare_vmcs02_full(vcpu, vmcs12, from_vmentry);
+               prepare_vmcs02_full(vcpu, vmcs12);
                vmx->nested.dirty_vmcs12 = false;
        }
 
@@ -11032,7 +11296,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
         * HOST_FS_BASE, HOST_GS_BASE.
         */
 
-       if (from_vmentry &&
+       if (vmx->nested.nested_run_pending &&
            (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_DEBUG_CONTROLS)) {
                kvm_set_dr(vcpu, 7, vmcs12->guest_dr7);
                vmcs_write64(GUEST_IA32_DEBUGCTL, vmcs12->guest_ia32_debugctl);
@@ -11040,7 +11304,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
                kvm_set_dr(vcpu, 7, vcpu->arch.dr7);
                vmcs_write64(GUEST_IA32_DEBUGCTL, vmx->nested.vmcs01_debugctl);
        }
-       if (from_vmentry) {
+       if (vmx->nested.nested_run_pending) {
                vmcs_write32(VM_ENTRY_INTR_INFO_FIELD,
                             vmcs12->vm_entry_intr_info_field);
                vmcs_write32(VM_ENTRY_EXCEPTION_ERROR_CODE,
@@ -11172,7 +11436,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
                        ~VM_ENTRY_IA32E_MODE) |
                (vmcs_config.vmentry_ctrl & ~VM_ENTRY_IA32E_MODE));
 
-       if (from_vmentry &&
+       if (vmx->nested.nested_run_pending &&
            (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_PAT)) {
                vmcs_write64(GUEST_IA32_PAT, vmcs12->guest_ia32_pat);
                vcpu->arch.pat = vmcs12->guest_ia32_pat;
@@ -11197,7 +11461,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
                if (nested_cpu_has_vpid(vmcs12) && vmx->nested.vpid02) {
                        if (vmcs12->virtual_processor_id != vmx->nested.last_vpid) {
                                vmx->nested.last_vpid = vmcs12->virtual_processor_id;
-                               __vmx_flush_tlb(vcpu, to_vmx(vcpu)->nested.vpid02, true);
+                               __vmx_flush_tlb(vcpu, vmx->nested.vpid02, true);
                        }
                } else {
                        vmx_flush_tlb(vcpu, true);
@@ -11240,7 +11504,7 @@ static int prepare_vmcs02(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
        vmx_set_cr4(vcpu, vmcs12->guest_cr4);
        vmcs_writel(CR4_READ_SHADOW, nested_read_cr4(vmcs12));
 
-       if (from_vmentry &&
+       if (vmx->nested.nested_run_pending &&
            (vmcs12->vm_entry_controls & VM_ENTRY_LOAD_IA32_EFER))
                vcpu->arch.efer = vmcs12->guest_ia32_efer;
        else if (vmcs12->vm_entry_controls & VM_ENTRY_IA32E_MODE)
@@ -11418,7 +11682,7 @@ static int check_vmentry_postreqs(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
        return 0;
 }
 
-static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry)
+static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu)
 {
        struct vcpu_vmx *vmx = to_vmx(vcpu);
        struct vmcs12 *vmcs12 = get_vmcs12(vcpu);
@@ -11438,7 +11702,7 @@ static int enter_vmx_non_root_mode(struct kvm_vcpu *vcpu, bool from_vmentry)
                vcpu->arch.tsc_offset += vmcs12->tsc_offset;
 
        r = EXIT_REASON_INVALID_STATE;
-       if (prepare_vmcs02(vcpu, vmcs12, from_vmentry, &exit_qual))
+       if (prepare_vmcs02(vcpu, vmcs12, &exit_qual))
                goto fail;
 
        nested_get_vmcs12_pages(vcpu, vmcs12);
@@ -11540,20 +11804,22 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
         * the nested entry.
         */
 
-       ret = enter_vmx_non_root_mode(vcpu, true);
-       if (ret)
+       vmx->nested.nested_run_pending = 1;
+       ret = enter_vmx_non_root_mode(vcpu);
+       if (ret) {
+               vmx->nested.nested_run_pending = 0;
                return ret;
+       }
 
        /*
         * If we're entering a halted L2 vcpu and the L2 vcpu won't be woken
         * by event injection, halt vcpu.
         */
        if ((vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) &&
-           !(vmcs12->vm_entry_intr_info_field & INTR_INFO_VALID_MASK))
+           !(vmcs12->vm_entry_intr_info_field & INTR_INFO_VALID_MASK)) {
+               vmx->nested.nested_run_pending = 0;
                return kvm_vcpu_halt(vcpu);
-
-       vmx->nested.nested_run_pending = 1;
-
+       }
        return 1;
 
 out:
@@ -11925,12 +12191,20 @@ static void load_vmcs12_host_state(struct kvm_vcpu *vcpu,
 
        load_vmcs12_mmu_host_state(vcpu, vmcs12);
 
-       if (enable_vpid) {
-               /*
-                * Trivially support vpid by letting L2s share their parent
-                * L1's vpid. TODO: move to a more elaborate solution, giving
-                * each L2 its own vpid and exposing the vpid feature to L1.
-                */
+       /*
+        * If vmcs01 don't use VPID, CPU flushes TLB on every
+        * VMEntry/VMExit. Thus, no need to flush TLB.
+        *
+        * If vmcs12 uses VPID, TLB entries populated by L2 are
+        * tagged with vmx->nested.vpid02 while L1 entries are tagged
+        * with vmx->vpid. Thus, no need to flush TLB.
+        *
+        * Therefore, flush TLB only in case vmcs01 uses VPID and
+        * vmcs12 don't use VPID as in this case L1 & L2 TLB entries
+        * are both tagged with vmx->vpid.
+        */
+       if (enable_vpid &&
+           !(nested_cpu_has_vpid(vmcs12) && to_vmx(vcpu)->nested.vpid02)) {
                vmx_flush_tlb(vcpu, true);
        }
 
@@ -12069,10 +12343,9 @@ static void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
        if (kvm_has_tsc_control)
                decache_tsc_multiplier(vmx);
 
-       if (vmx->nested.change_vmcs01_virtual_x2apic_mode) {
-               vmx->nested.change_vmcs01_virtual_x2apic_mode = false;
-               vmx_set_virtual_x2apic_mode(vcpu,
-                               vcpu->arch.apic_base & X2APIC_ENABLE);
+       if (vmx->nested.change_vmcs01_virtual_apic_mode) {
+               vmx->nested.change_vmcs01_virtual_apic_mode = false;
+               vmx_set_virtual_apic_mode(vcpu);
        } else if (!nested_cpu_has_ept(vmcs12) &&
                   nested_cpu_has2(vmcs12,
                                   SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES)) {
@@ -12236,7 +12509,7 @@ static inline int u64_shl_div_u64(u64 a, unsigned int shift,
 static int vmx_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc)
 {
        struct vcpu_vmx *vmx;
-       u64 tscl, guest_tscl, delta_tsc;
+       u64 tscl, guest_tscl, delta_tsc, lapic_timer_advance_cycles;
 
        if (kvm_mwait_in_guest(vcpu->kvm))
                return -EOPNOTSUPP;
@@ -12245,6 +12518,12 @@ static int vmx_set_hv_timer(struct kvm_vcpu *vcpu, u64 guest_deadline_tsc)
        tscl = rdtsc();
        guest_tscl = kvm_read_l1_tsc(vcpu, tscl);
        delta_tsc = max(guest_deadline_tsc, guest_tscl) - guest_tscl;
+       lapic_timer_advance_cycles = nsec_to_cycles(vcpu, lapic_timer_advance_ns);
+
+       if (delta_tsc > lapic_timer_advance_cycles)
+               delta_tsc -= lapic_timer_advance_cycles;
+       else
+               delta_tsc = 0;
 
        /* Convert to host delta tsc if tsc scaling is enabled */
        if (vcpu->arch.tsc_scaling_ratio != kvm_default_tsc_scaling_ratio &&
@@ -12615,7 +12894,7 @@ static int vmx_pre_leave_smm(struct kvm_vcpu *vcpu, u64 smbase)
 
        if (vmx->nested.smm.guest_mode) {
                vcpu->arch.hflags &= ~HF_SMM_MASK;
-               ret = enter_vmx_non_root_mode(vcpu, false);
+               ret = enter_vmx_non_root_mode(vcpu);
                vcpu->arch.hflags |= HF_SMM_MASK;
                if (ret)
                        return ret;
@@ -12700,7 +12979,7 @@ static struct kvm_x86_ops vmx_x86_ops __ro_after_init = {
        .enable_nmi_window = enable_nmi_window,
        .enable_irq_window = enable_irq_window,
        .update_cr8_intercept = update_cr8_intercept,
-       .set_virtual_x2apic_mode = vmx_set_virtual_x2apic_mode,
+       .set_virtual_apic_mode = vmx_set_virtual_apic_mode,
        .set_apic_access_page_addr = vmx_set_apic_access_page_addr,
        .get_enable_apicv = vmx_get_enable_apicv,
        .refresh_apicv_exec_ctrl = vmx_refresh_apicv_exec_ctrl,
@@ -12812,6 +13091,7 @@ static int __init vmx_init(void)
        rcu_assign_pointer(crash_vmclear_loaded_vmcss,
                           crash_vmclear_local_loaded_vmcss);
 #endif
+       vmx_check_vmcs12_offsets();
 
        return 0;
 }
index 71e7cda6d01430bca8ef226238589ab0e830d6c9..0046aa70205aa2dfbc0577065250be717ca25b4e 100644 (file)
@@ -138,6 +138,7 @@ module_param(tsc_tolerance_ppm, uint, S_IRUGO | S_IWUSR);
 /* lapic timer advance (tscdeadline mode only) in nanoseconds */
 unsigned int __read_mostly lapic_timer_advance_ns = 0;
 module_param(lapic_timer_advance_ns, uint, S_IRUGO | S_IWUSR);
+EXPORT_SYMBOL_GPL(lapic_timer_advance_ns);
 
 static bool __read_mostly vector_hashing = true;
 module_param(vector_hashing, bool, S_IRUGO);
@@ -318,23 +319,27 @@ u64 kvm_get_apic_base(struct kvm_vcpu *vcpu)
 }
 EXPORT_SYMBOL_GPL(kvm_get_apic_base);
 
+enum lapic_mode kvm_get_apic_mode(struct kvm_vcpu *vcpu)
+{
+       return kvm_apic_mode(kvm_get_apic_base(vcpu));
+}
+EXPORT_SYMBOL_GPL(kvm_get_apic_mode);
+
 int kvm_set_apic_base(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 {
-       u64 old_state = vcpu->arch.apic_base &
-               (MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE);
-       u64 new_state = msr_info->data &
-               (MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE);
+       enum lapic_mode old_mode = kvm_get_apic_mode(vcpu);
+       enum lapic_mode new_mode = kvm_apic_mode(msr_info->data);
        u64 reserved_bits = ((~0ULL) << cpuid_maxphyaddr(vcpu)) | 0x2ff |
                (guest_cpuid_has(vcpu, X86_FEATURE_X2APIC) ? 0 : X2APIC_ENABLE);
 
-       if ((msr_info->data & reserved_bits) || new_state == X2APIC_ENABLE)
-               return 1;
-       if (!msr_info->host_initiated &&
-           ((new_state == MSR_IA32_APICBASE_ENABLE &&
-             old_state == (MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE)) ||
-            (new_state == (MSR_IA32_APICBASE_ENABLE | X2APIC_ENABLE) &&
-             old_state == 0)))
+       if ((msr_info->data & reserved_bits) != 0 || new_mode == LAPIC_MODE_INVALID)
                return 1;
+       if (!msr_info->host_initiated) {
+               if (old_mode == LAPIC_MODE_X2APIC && new_mode == LAPIC_MODE_XAPIC)
+                       return 1;
+               if (old_mode == LAPIC_MODE_DISABLED && new_mode == LAPIC_MODE_X2APIC)
+                       return 1;
+       }
 
        kvm_lapic_set_base(vcpu, msr_info->data);
        return 0;
@@ -856,7 +861,7 @@ int kvm_set_cr3(struct kvm_vcpu *vcpu, unsigned long cr3)
        }
 
        if (is_long_mode(vcpu) &&
-           (cr3 & rsvd_bits(cpuid_maxphyaddr(vcpu), 62)))
+           (cr3 & rsvd_bits(cpuid_maxphyaddr(vcpu), 63)))
                return 1;
        else if (is_pae(vcpu) && is_paging(vcpu) &&
                   !load_pdptrs(vcpu, vcpu->arch.walk_mmu, cr3))
@@ -1761,7 +1766,7 @@ static int do_monotonic_boot(s64 *t, u64 *tsc_timestamp)
        return mode;
 }
 
-static int do_realtime(struct timespec *ts, u64 *tsc_timestamp)
+static int do_realtime(struct timespec64 *ts, u64 *tsc_timestamp)
 {
        struct pvclock_gtod_data *gtod = &pvclock_gtod_data;
        unsigned long seq;
@@ -1794,7 +1799,7 @@ static bool kvm_get_time_and_clockread(s64 *kernel_ns, u64 *tsc_timestamp)
 }
 
 /* returns true if host is using TSC based clocksource */
-static bool kvm_get_walltime_and_clockread(struct timespec *ts,
+static bool kvm_get_walltime_and_clockread(struct timespec64 *ts,
                                           u64 *tsc_timestamp)
 {
        /* checked again under seqlock below */
@@ -2868,6 +2873,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
        case KVM_CAP_HYPERV_SYNIC2:
        case KVM_CAP_HYPERV_VP_INDEX:
        case KVM_CAP_HYPERV_EVENTFD:
+       case KVM_CAP_HYPERV_TLBFLUSH:
        case KVM_CAP_PCI_SEGMENT:
        case KVM_CAP_DEBUGREGS:
        case KVM_CAP_X86_ROBUST_SINGLESTEP:
@@ -2894,7 +2900,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
                r = KVM_CLOCK_TSC_STABLE;
                break;
        case KVM_CAP_X86_DISABLE_EXITS:
-               r |=  KVM_X86_DISABLE_EXITS_HTL | KVM_X86_DISABLE_EXITS_PAUSE;
+               r |=  KVM_X86_DISABLE_EXITS_HLT | KVM_X86_DISABLE_EXITS_PAUSE;
                if(kvm_can_mwait_in_guest())
                        r |= KVM_X86_DISABLE_EXITS_MWAIT;
                break;
@@ -3962,7 +3968,7 @@ long kvm_arch_vcpu_ioctl(struct file *filp,
        return r;
 }
 
-int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
+vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
 {
        return VM_FAULT_SIGBUS;
 }
@@ -4248,7 +4254,7 @@ static int kvm_vm_ioctl_enable_cap(struct kvm *kvm,
                if ((cap->args[0] & KVM_X86_DISABLE_EXITS_MWAIT) &&
                        kvm_can_mwait_in_guest())
                        kvm->arch.mwait_in_guest = true;
-               if (cap->args[0] & KVM_X86_DISABLE_EXITS_HTL)
+               if (cap->args[0] & KVM_X86_DISABLE_EXITS_HLT)
                        kvm->arch.hlt_in_guest = true;
                if (cap->args[0] & KVM_X86_DISABLE_EXITS_PAUSE)
                        kvm->arch.pause_in_guest = true;
@@ -4787,11 +4793,10 @@ static int kvm_fetch_guest_virt(struct x86_emulate_ctxt *ctxt,
        return X86EMUL_CONTINUE;
 }
 
-int kvm_read_guest_virt(struct x86_emulate_ctxt *ctxt,
+int kvm_read_guest_virt(struct kvm_vcpu *vcpu,
                               gva_t addr, void *val, unsigned int bytes,
                               struct x86_exception *exception)
 {
-       struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
        u32 access = (kvm_x86_ops->get_cpl(vcpu) == 3) ? PFERR_USER_MASK : 0;
 
        return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, access,
@@ -4799,12 +4804,17 @@ int kvm_read_guest_virt(struct x86_emulate_ctxt *ctxt,
 }
 EXPORT_SYMBOL_GPL(kvm_read_guest_virt);
 
-static int kvm_read_guest_virt_system(struct x86_emulate_ctxt *ctxt,
-                                     gva_t addr, void *val, unsigned int bytes,
-                                     struct x86_exception *exception)
+static int emulator_read_std(struct x86_emulate_ctxt *ctxt,
+                            gva_t addr, void *val, unsigned int bytes,
+                            struct x86_exception *exception, bool system)
 {
        struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
-       return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, 0, exception);
+       u32 access = 0;
+
+       if (!system && kvm_x86_ops->get_cpl(vcpu) == 3)
+               access |= PFERR_USER_MASK;
+
+       return kvm_read_guest_virt_helper(addr, val, bytes, vcpu, access, exception);
 }
 
 static int kvm_read_guest_phys_system(struct x86_emulate_ctxt *ctxt,
@@ -4816,18 +4826,16 @@ static int kvm_read_guest_phys_system(struct x86_emulate_ctxt *ctxt,
        return r < 0 ? X86EMUL_IO_NEEDED : X86EMUL_CONTINUE;
 }
 
-int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
-                                      gva_t addr, void *val,
-                                      unsigned int bytes,
-                                      struct x86_exception *exception)
+static int kvm_write_guest_virt_helper(gva_t addr, void *val, unsigned int bytes,
+                                     struct kvm_vcpu *vcpu, u32 access,
+                                     struct x86_exception *exception)
 {
-       struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
        void *data = val;
        int r = X86EMUL_CONTINUE;
 
        while (bytes) {
                gpa_t gpa =  vcpu->arch.walk_mmu->gva_to_gpa(vcpu, addr,
-                                                            PFERR_WRITE_MASK,
+                                                            access,
                                                             exception);
                unsigned offset = addr & (PAGE_SIZE-1);
                unsigned towrite = min(bytes, (unsigned)PAGE_SIZE - offset);
@@ -4848,6 +4856,27 @@ int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
 out:
        return r;
 }
+
+static int emulator_write_std(struct x86_emulate_ctxt *ctxt, gva_t addr, void *val,
+                             unsigned int bytes, struct x86_exception *exception,
+                             bool system)
+{
+       struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt);
+       u32 access = PFERR_WRITE_MASK;
+
+       if (!system && kvm_x86_ops->get_cpl(vcpu) == 3)
+               access |= PFERR_USER_MASK;
+
+       return kvm_write_guest_virt_helper(addr, val, bytes, vcpu,
+                                          access, exception);
+}
+
+int kvm_write_guest_virt_system(struct kvm_vcpu *vcpu, gva_t addr, void *val,
+                               unsigned int bytes, struct x86_exception *exception)
+{
+       return kvm_write_guest_virt_helper(addr, val, bytes, vcpu,
+                                          PFERR_WRITE_MASK, exception);
+}
 EXPORT_SYMBOL_GPL(kvm_write_guest_virt_system);
 
 int handle_ud(struct kvm_vcpu *vcpu)
@@ -4858,8 +4887,8 @@ int handle_ud(struct kvm_vcpu *vcpu)
        struct x86_exception e;
 
        if (force_emulation_prefix &&
-           kvm_read_guest_virt(&vcpu->arch.emulate_ctxt,
-                               kvm_get_linear_rip(vcpu), sig, sizeof(sig), &e) == 0 &&
+           kvm_read_guest_virt(vcpu, kvm_get_linear_rip(vcpu),
+                               sig, sizeof(sig), &e) == 0 &&
            memcmp(sig, "\xf\xbkvm", sizeof(sig)) == 0) {
                kvm_rip_write(vcpu, kvm_rip_read(vcpu) + sizeof(sig));
                emul_type = 0;
@@ -5600,8 +5629,8 @@ static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt, u64 smbase)
 static const struct x86_emulate_ops emulate_ops = {
        .read_gpr            = emulator_read_gpr,
        .write_gpr           = emulator_write_gpr,
-       .read_std            = kvm_read_guest_virt_system,
-       .write_std           = kvm_write_guest_virt_system,
+       .read_std            = emulator_read_std,
+       .write_std           = emulator_write_std,
        .read_phys           = kvm_read_guest_phys_system,
        .fetch               = kvm_fetch_guest_virt,
        .read_emulated       = emulator_read_emulated,
@@ -6617,7 +6646,7 @@ static int kvm_pv_clock_pairing(struct kvm_vcpu *vcpu, gpa_t paddr,
                                unsigned long clock_type)
 {
        struct kvm_clock_pairing clock_pairing;
-       struct timespec ts;
+       struct timespec64 ts;
        u64 cycle;
        int ret;
 
@@ -8538,7 +8567,7 @@ int kvm_arch_hardware_setup(void)
                /*
                 * Make sure the user can only configure tsc_khz values that
                 * fit into a signed integer.
-                * A min value is not calculated needed because it will always
+                * A min value is not calculated because it will always
                 * be 1 on all machines.
                 */
                u64 max = min(0x7fffffffULL,
@@ -8871,13 +8900,14 @@ int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot,
                                      slot->base_gfn, level) + 1;
 
                slot->arch.rmap[i] =
-                       kvzalloc(lpages * sizeof(*slot->arch.rmap[i]), GFP_KERNEL);
+                       kvcalloc(lpages, sizeof(*slot->arch.rmap[i]),
+                                GFP_KERNEL);
                if (!slot->arch.rmap[i])
                        goto out_free;
                if (i == 0)
                        continue;
 
-               linfo = kvzalloc(lpages * sizeof(*linfo), GFP_KERNEL);
+               linfo = kvcalloc(lpages, sizeof(*linfo), GFP_KERNEL);
                if (!linfo)
                        goto out_free;
 
index c9492f7649020e2990b420e545e91470ec744e73..331993c49dae9bd852c759afecbb3c6c17477e15 100644 (file)
@@ -247,11 +247,11 @@ int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip);
 void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr);
 u64 get_kvmclock_ns(struct kvm *kvm);
 
-int kvm_read_guest_virt(struct x86_emulate_ctxt *ctxt,
+int kvm_read_guest_virt(struct kvm_vcpu *vcpu,
        gva_t addr, void *val, unsigned int bytes,
        struct x86_exception *exception);
 
-int kvm_write_guest_virt_system(struct x86_emulate_ctxt *ctxt,
+int kvm_write_guest_virt_system(struct kvm_vcpu *vcpu,
        gva_t addr, void *val, unsigned int bytes,
        struct x86_exception *exception);
 
index fec82b577c183f516b4c3c416d94127f9ccd26ad..cee58a972cb20ff948e6384df5d9fc25f3e47ab7 100644 (file)
@@ -706,7 +706,9 @@ void __init init_mem_mapping(void)
  */
 int devmem_is_allowed(unsigned long pagenr)
 {
-       if (page_is_ram(pagenr)) {
+       if (region_intersects(PFN_PHYS(pagenr), PAGE_SIZE,
+                               IORESOURCE_SYSTEM_RAM, IORES_DESC_NONE)
+                       != REGION_DISJOINT) {
                /*
                 * For disallowed memory regions in the low 1MB range,
                 * request that the page be shown as all zeros.
index c893c6a3d7079cf1210ad9562644ec8eb240d1d7..979e0a02cbe1a12d67fad130592a6e68c98925c5 100644 (file)
@@ -692,7 +692,7 @@ void __init initmem_init(void)
        high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
 #endif
 
-       memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
+       memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
        sparse_memory_present_with_active_regions(0);
 
 #ifdef CONFIG_FLATMEM
index 17383f9677faf25819aabb549b24cf0269f653d9..045f492d5f68260a581f44c210aa3753dc4bc225 100644 (file)
@@ -742,7 +742,7 @@ kernel_physical_mapping_init(unsigned long paddr_start,
 #ifndef CONFIG_NUMA
 void __init initmem_init(void)
 {
-       memblock_set_node(0, (phys_addr_t)ULLONG_MAX, &memblock.memory, 0);
+       memblock_set_node(0, PHYS_ADDR_MAX, &memblock.memory, 0);
 }
 #endif
 
index 8fca446aaef62b92a79a5b76ac3a708aa249b935..2580cd2e98b1700f2bc048377d431a56dd69eccb 100644 (file)
@@ -1107,7 +1107,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
                extra_pass = true;
                goto skip_init_addrs;
        }
-       addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL);
+       addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL);
        if (!addrs) {
                prog = orig_prog;
                goto out_addrs;
index 0cc04e30adc12f4badfce2d4185fba1564e4153b..55799873ebe53375b8cf492af137461bba00b9b8 100644 (file)
@@ -2345,7 +2345,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
                prog = tmp;
        }
 
-       addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL);
+       addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL);
        if (!addrs) {
                prog = orig_prog;
                goto out;
index 9542a746dc50ed62d1d34b98a368f5d85b5be6d5..9112d1cb397bb56faa637216f1e39815c50edd9d 100644 (file)
@@ -168,7 +168,7 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
        if (type == PCI_CAP_ID_MSI && nvec > 1)
                return 1;
 
-       v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL);
+       v = kcalloc(max(1, nvec), sizeof(int), GFP_KERNEL);
        if (!v)
                return -ENOMEM;
 
index b96d38288c6005790c75f80dad4737477837fdea..ca446da48fd2872e262b789ebbfe12c2ec1d4976 100644 (file)
@@ -2142,7 +2142,7 @@ static int __init init_per_cpu(int nuvhubs, int base_part_pnode)
        if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
                timeout_us = calculate_destination_timeout();
 
-       vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
+       vp = kmalloc_array(nuvhubs, sizeof(struct uvhub_desc), GFP_KERNEL);
        uvhub_descs = (struct uvhub_desc *)vp;
        memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
        uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL);
index b082d71b08eed6b486b1a9956adc71431dd7b7d8..a36b368eea0840b1a4765b8ac6e23191468ce5f9 100644 (file)
@@ -158,7 +158,7 @@ static __init int uv_rtc_allocate_timers(void)
 {
        int cpu;
 
-       blade_info = kzalloc(uv_possible_blades * sizeof(void *), GFP_KERNEL);
+       blade_info = kcalloc(uv_possible_blades, sizeof(void *), GFP_KERNEL);
        if (!blade_info)
                return -ENOMEM;
 
index 17df332269b2b5a296ec4906dff660f023933c42..d575e8701955a3f46703162332a549946316f02d 100644 (file)
@@ -17,7 +17,6 @@ config XTENSA
        select GENERIC_SCHED_CLOCK
        select GENERIC_STRNCPY_FROM_USER if KASAN
        select HAVE_ARCH_KASAN if MMU
-       select HAVE_CC_STACKPROTECTOR
        select HAVE_DEBUG_KMEMLEAK
        select HAVE_DMA_CONTIGUOUS
        select HAVE_EXIT_THREAD
@@ -28,6 +27,7 @@ config XTENSA
        select HAVE_MEMBLOCK
        select HAVE_OPROFILE
        select HAVE_PERF_EVENTS
+       select HAVE_STACKPROTECTOR
        select IRQ_DOMAIN
        select MODULES_USE_ELF_RELA
        select NO_BOOTMEM
index 397d6a1a4224fb66b70dfc86cee06353e07fbc1b..a0d50be5a8cb192562537e1ef36a6dfd73f0011a 100644 (file)
@@ -88,7 +88,7 @@ static inline void __invalidate_icache_page_alias(unsigned long virt,
  *
  * Pages can get remapped. Because this might change the 'color' of that page,
  * we have to flush the cache before the PTE is changed.
- * (see also Documentation/cachetlb.txt)
+ * (see also Documentation/core-api/cachetlb.rst)
  */
 
 #if defined(CONFIG_MMU) && \
@@ -152,7 +152,7 @@ void local_flush_cache_page(struct vm_area_struct *vma,
                __invalidate_icache_range(start,(end) - (start));       \
        } while (0)
 
-/* This is not required, see Documentation/cachetlb.txt */
+/* This is not required, see Documentation/core-api/cachetlb.rst */
 #define        flush_icache_page(vma,page)                     do { } while (0)
 
 #define flush_dcache_mmap_lock(mapping)                        do { } while (0)
index 022cf918ec208db6e51627c786ec7f80f345c178..67904f55f1884f52893b3a99b1be785a48dc69da 100644 (file)
@@ -76,7 +76,7 @@ int main(void)
        DEFINE(TASK_PID, offsetof (struct task_struct, pid));
        DEFINE(TASK_THREAD, offsetof (struct task_struct, thread));
        DEFINE(TASK_THREAD_INFO, offsetof (struct task_struct, stack));
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
        DEFINE(TASK_STACK_CANARY, offsetof(struct task_struct, stack_canary));
 #endif
        DEFINE(TASK_STRUCT_SIZE, sizeof (struct task_struct));
index 5caff0744f3cb7e75855a607028822a4850d7dbe..9cbc380e95727f2f0394f7cf778f412d086e05e3 100644 (file)
@@ -1971,7 +1971,7 @@ ENTRY(_switch_to)
        s32i    a1, a2, THREAD_SP       # save stack pointer
 #endif
 
-#if defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_SMP)
+#if defined(CONFIG_STACKPROTECTOR) && !defined(CONFIG_SMP)
        movi    a6, __stack_chk_guard
        l32i    a8, a3, TASK_STACK_CANARY
        s32i    a8, a6, 0
index 8dd0593fb2c4264e6f752589227f4d10aa4bcebe..483dcfb6e681d7d483ef8ebfb948d91b7ee8f1fd 100644 (file)
@@ -58,7 +58,7 @@ void (*pm_power_off)(void) = NULL;
 EXPORT_SYMBOL(pm_power_off);
 
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 #include <linux/stackprotector.h>
 unsigned long __stack_chk_guard __read_mostly;
 EXPORT_SYMBOL(__stack_chk_guard);
index 28ec55752b68e89bd1babc0b0c6eb4b3e4576014..eb50fd4977c2f5b5de3ef1a3c4ee597d1689936a 100644 (file)
@@ -114,7 +114,7 @@ config BLK_DEV_THROTTLING
        one needs to mount and use blkio cgroup controller for creating
        cgroups and specifying per device IO rate policies.
 
-       See Documentation/cgroups/blkio-controller.txt for more information.
+       See Documentation/cgroup-v1/blkio-controller.txt for more information.
 
 config BLK_DEV_THROTTLING_LOW
        bool "Block throttling .low limit interface support (EXPERIMENTAL)"
index db9a40e9a136b262f92b2bb13789e18dea3dcd85..9710e275f23079b8b7548ee935ab653036e82c5d 100644 (file)
@@ -2091,7 +2091,8 @@ static int __init init_bio(void)
 {
        bio_slab_max = 2;
        bio_slab_nr = 0;
-       bio_slabs = kzalloc(bio_slab_max * sizeof(struct bio_slab), GFP_KERNEL);
+       bio_slabs = kcalloc(bio_slab_max, sizeof(struct bio_slab),
+                           GFP_KERNEL);
        if (!bio_slabs)
                panic("bio: can't allocate bios\n");
 
index 8e57b84e50e95587839d2d2476f5be039da11e2a..70c65bb6c0131c84130fae44808acb51cf427ace 100644 (file)
@@ -1908,7 +1908,7 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set,
        if (!tags)
                return NULL;
 
-       tags->rqs = kzalloc_node(nr_tags * sizeof(struct request *),
+       tags->rqs = kcalloc_node(nr_tags, sizeof(struct request *),
                                 GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
                                 node);
        if (!tags->rqs) {
@@ -1916,9 +1916,9 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set,
                return NULL;
        }
 
-       tags->static_rqs = kzalloc_node(nr_tags * sizeof(struct request *),
-                                GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
-                                node);
+       tags->static_rqs = kcalloc_node(nr_tags, sizeof(struct request *),
+                                       GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
+                                       node);
        if (!tags->static_rqs) {
                kfree(tags->rqs);
                blk_mq_free_tags(tags);
@@ -2526,7 +2526,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set,
        /* init q->mq_kobj and sw queues' kobjects */
        blk_mq_sysfs_init(q);
 
-       q->queue_hw_ctx = kzalloc_node(nr_cpu_ids * sizeof(*(q->queue_hw_ctx)),
+       q->queue_hw_ctx = kcalloc_node(nr_cpu_ids, sizeof(*(q->queue_hw_ctx)),
                                                GFP_KERNEL, set->numa_node);
        if (!q->queue_hw_ctx)
                goto err_percpu;
@@ -2745,14 +2745,14 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set)
        if (set->nr_hw_queues > nr_cpu_ids)
                set->nr_hw_queues = nr_cpu_ids;
 
-       set->tags = kzalloc_node(nr_cpu_ids * sizeof(struct blk_mq_tags *),
+       set->tags = kcalloc_node(nr_cpu_ids, sizeof(struct blk_mq_tags *),
                                 GFP_KERNEL, set->numa_node);
        if (!set->tags)
                return -ENOMEM;
 
        ret = -ENOMEM;
-       set->mq_map = kzalloc_node(sizeof(*set->mq_map) * nr_cpu_ids,
-                       GFP_KERNEL, set->numa_node);
+       set->mq_map = kcalloc_node(nr_cpu_ids, sizeof(*set->mq_map),
+                                  GFP_KERNEL, set->numa_node);
        if (!set->mq_map)
                goto out_free_tags;
 
index ada0d7cff62b36d02e917b41dda6bf4bca360fae..fbc153aef166d7faa27b65f41d0870ca844d9aad 100644 (file)
@@ -99,12 +99,12 @@ init_tag_map(struct request_queue *q, struct blk_queue_tag *tags, int depth)
                       __func__, depth);
        }
 
-       tag_index = kzalloc(depth * sizeof(struct request *), GFP_ATOMIC);
+       tag_index = kcalloc(depth, sizeof(struct request *), GFP_ATOMIC);
        if (!tag_index)
                goto fail;
 
        nr_ulongs = ALIGN(depth, BITS_PER_LONG) / BITS_PER_LONG;
-       tag_map = kzalloc(nr_ulongs * sizeof(unsigned long), GFP_ATOMIC);
+       tag_map = kcalloc(nr_ulongs, sizeof(unsigned long), GFP_ATOMIC);
        if (!tag_map)
                goto fail;
 
index 3d08dc84db1674b056d9a5a6078e276f2af37b70..51000914e23f966f7a9e324cfcf301c27f0a105c 100644 (file)
@@ -331,8 +331,8 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
        if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone))
                return -ERANGE;
 
-       zones = kvmalloc(rep.nr_zones * sizeof(struct blk_zone),
-                       GFP_KERNEL | __GFP_ZERO);
+       zones = kvmalloc_array(rep.nr_zones, sizeof(struct blk_zone),
+                              GFP_KERNEL | __GFP_ZERO);
        if (!zones)
                return -ENOMEM;
 
index 720145c49066ccd6e77449033aa3c6f910b7c2d5..ffe408fead0cdf8ca137be725540e35aa122572a 100644 (file)
@@ -122,7 +122,7 @@ static struct parsed_partitions *allocate_partitions(struct gendisk *hd)
                return NULL;
 
        nr = disk_max_parts(hd);
-       state->parts = vzalloc(nr * sizeof(state->parts[0]));
+       state->parts = vzalloc(array_size(nr, sizeof(state->parts[0])));
        if (!state->parts) {
                kfree(state);
                return NULL;
index 2a365c756648ca66f55274a49cf1aaad2d1c96e8..0417937dfe9964eba13a62a10c963cba1f71421e 100644 (file)
@@ -378,7 +378,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state,
        BUG_ON(!state || !ldb);
        ph = &ldb->ph;
        tb[0] = &ldb->toc;
-       tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
+       tb[1] = kmalloc_array(3, sizeof(*tb[1]), GFP_KERNEL);
        if (!tb[1]) {
                ldm_crit("Out of memory.");
                goto err;
index 5f7663df6e8e306fb7181e7fb94c11a88a49c828..c94e93d8bccf038f4684c4cce93d558d9e7269ff 100644 (file)
@@ -13,7 +13,7 @@ config MODULE_SIG_KEY
 
          If this option is unchanged from its default "certs/signing_key.pem",
          then the kernel will automatically generate the private key and
-         certificate as described in Documentation/module-signing.txt
+         certificate as described in Documentation/admin-guide/module-signing.rst
 
 config SYSTEM_TRUSTED_KEYRING
        bool "Provide system-wide ring of trusted keys"
index 330cf9f2b767728ff4116562ed73b839627722d5..825524f274384fdfd2a569be01e593d8f41a72b2 100644 (file)
@@ -255,8 +255,8 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg,
                                                       processed - as);
                if (!areq->tsgl_entries)
                        areq->tsgl_entries = 1;
-               areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) *
-                                             areq->tsgl_entries,
+               areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl),
+                                                        areq->tsgl_entries),
                                          GFP_KERNEL);
                if (!areq->tsgl) {
                        err = -ENOMEM;
index 15cf3c5222e0186871e590912f9028d19b1aaf69..4c04eb9888adf82f68a18d17c9d6e73adc74aa90 100644 (file)
@@ -100,7 +100,8 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
        areq->tsgl_entries = af_alg_count_tsgl(sk, len, 0);
        if (!areq->tsgl_entries)
                areq->tsgl_entries = 1;
-       areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) * areq->tsgl_entries,
+       areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl),
+                                                areq->tsgl_entries),
                                  GFP_KERNEL);
        if (!areq->tsgl) {
                err = -ENOMEM;
index 39aecad286fe482ff3f44fe08b286c2edbf3553b..26539e9a8bda41c37a664490e037f2365da7f15c 100644 (file)
@@ -1,6 +1,6 @@
 /* Asymmetric public-key cryptography key type
  *
- * See Documentation/security/asymmetric-keys.txt
+ * See Documentation/crypto/asymmetric-keys.txt
  *
  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
index 11b7ba1709041864868a6ca2b05680a20b5fb3f9..28198314bc39f4f4a27da38565619f6e262a7fd4 100644 (file)
@@ -1,6 +1,6 @@
 /* Signature verification with an asymmetric key
  *
- * See Documentation/security/asymmetric-keys.txt
+ * See Documentation/crypto/asymmetric-keys.txt
  *
  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
index d1d99843cce4d731f3cca0df1c3af6ec32d50308..11e45352fd0b825e25e7a80259a9c5c24bfc20f1 100644 (file)
@@ -603,7 +603,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
                goto out_nooutbuf;
 
        /* avoid "the frame size is larger than 1024 bytes" compiler warning */
-       sg = kmalloc(sizeof(*sg) * 8 * (diff_dst ? 4 : 2), GFP_KERNEL);
+       sg = kmalloc(array3_size(sizeof(*sg), 8, (diff_dst ? 4 : 2)),
+                    GFP_KERNEL);
        if (!sg)
                goto out_nosg;
        sgout = &sg[16];
index cb6ac5c65c2e4c97f4cc9432d8d701b9e3b3f0da..38a286975c31e152206b3e55b28473a2763a717a 100644 (file)
@@ -233,11 +233,13 @@ static const struct lpss_device_desc lpt_sdio_dev_desc = {
 
 static const struct lpss_device_desc byt_pwm_dev_desc = {
        .flags = LPSS_SAVE_CTX,
+       .prv_offset = 0x800,
        .setup = byt_pwm_setup,
 };
 
 static const struct lpss_device_desc bsw_pwm_dev_desc = {
        .flags = LPSS_SAVE_CTX | LPSS_NO_D3_DELAY,
+       .prv_offset = 0x800,
        .setup = bsw_pwm_setup,
 };
 
index 88cd949003f3e397175579621b2513da257d7895..eaa60c94205a82f685190a5c0790d6ca91df69cb 100644 (file)
@@ -82,7 +82,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
        if (count < 0) {
                return NULL;
        } else if (count > 0) {
-               resources = kzalloc(count * sizeof(struct resource),
+               resources = kcalloc(count, sizeof(struct resource),
                                    GFP_KERNEL);
                if (!resources) {
                        dev_err(&adev->dev, "No memory for resources\n");
index 2f2e737be0f84a966020102ba21ce906c21b9584..f0b52266b3ac6c45ea83a7f446513a179d60531b 100644 (file)
@@ -832,8 +832,9 @@ int acpi_video_get_levels(struct acpi_device *device,
         * in order to account for buggy BIOS which don't export the first two
         * special levels (see below)
         */
-       br->levels = kmalloc((obj->package.count + ACPI_VIDEO_FIRST_LEVEL) *
-                            sizeof(*br->levels), GFP_KERNEL);
+       br->levels = kmalloc_array(obj->package.count + ACPI_VIDEO_FIRST_LEVEL,
+                                  sizeof(*br->levels),
+                                  GFP_KERNEL);
        if (!br->levels) {
                result = -ENOMEM;
                goto out_free;
index dc94de91033e653c004c9dc499f4bc52cae94773..992bd7b92540d6afff1083164e0f0e237a2f2a08 100644 (file)
@@ -322,6 +322,7 @@ acpi_db_walk_and_match_name(acpi_handle obj_handle,
                acpi_os_printf("Could Not get pathname for object %p\n",
                               obj_handle);
        } else {
+               info.count = 0;
                info.owner_id = ACPI_OWNER_ID_MAX;
                info.debug_level = ACPI_UINT32_MAX;
                info.display_type = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
index 58c3253b533aaf4aeda8f8862d0d0e7974c2ed19..a1c76bf211227d672e992982a11e3aa24dd8bbcf 100644 (file)
@@ -35,6 +35,15 @@ void
 acpi_db_dump_method_info(acpi_status status, struct acpi_walk_state *walk_state)
 {
        struct acpi_thread_state *thread;
+       struct acpi_namespace_node *node;
+
+       node = walk_state->method_node;
+
+       /* There are no locals or arguments for the module-level code case */
+
+       if (node == acpi_gbl_root_node) {
+               return;
+       }
 
        /* Ignore control codes, they are not errors */
 
@@ -384,8 +393,14 @@ void acpi_db_decode_locals(struct acpi_walk_state *walk_state)
        struct acpi_namespace_node *node;
        u8 display_locals = FALSE;
 
-       obj_desc = walk_state->method_desc;
        node = walk_state->method_node;
+       obj_desc = walk_state->method_desc;
+
+       /* There are no locals for the module-level code case */
+
+       if (node == acpi_gbl_root_node) {
+               return;
+       }
 
        if (!node) {
                acpi_os_printf
@@ -452,6 +467,12 @@ void acpi_db_decode_arguments(struct acpi_walk_state *walk_state)
        node = walk_state->method_node;
        obj_desc = walk_state->method_desc;
 
+       /* There are no arguments for the module-level code case */
+
+       if (node == acpi_gbl_root_node) {
+               return;
+       }
+
        if (!node) {
                acpi_os_printf
                    ("No method node (Executing subtree for buffer or opregion)\n");
index 70a2fca60306b2e96ce2e757220f2a586bd7a4d6..9d33f0bb28855050b5d67302dd0ad58bc6c66631 100644 (file)
@@ -162,9 +162,15 @@ acpi_ds_dump_method_stack(acpi_status status,
                                op->common.next = NULL;
 
 #ifdef ACPI_DISASSEMBLER
-                               acpi_os_printf("Failed at ");
-                               acpi_dm_disassemble(next_walk_state, op,
-                                                   ACPI_UINT32_MAX);
+                               if (walk_state->method_node !=
+                                   acpi_gbl_root_node) {
+
+                                       /* More verbose if not module-level code */
+
+                                       acpi_os_printf("Failed at ");
+                                       acpi_dm_disassemble(next_walk_state, op,
+                                                           ACPI_UINT32_MAX);
+                               }
 #endif
                                op->common.next = next;
                        }
index f85c6f3271f64fb060fbf5029a4b41ee151389d5..2373a749215124ab62bfd206643252349192a29e 100644 (file)
@@ -489,6 +489,17 @@ acpi_status acpi_ex_unload_table(union acpi_operand_object *ddb_handle)
         */
        ACPI_WARNING((AE_INFO, "Received request to unload an ACPI table"));
 
+       /*
+        * May 2018: Unload is no longer supported for the following reasons:
+        * 1) A correct implementation on some hosts may not be possible.
+        * 2) Other ACPI implementations do not correctly/fully support it.
+        * 3) It requires host device driver support which does not exist.
+        *    (To properly support namespace unload out from underneath.)
+        * 4) This AML operator has never been seen in the field.
+        */
+       ACPI_EXCEPTION((AE_INFO, AE_NOT_IMPLEMENTED,
+                       "AML Unload operator is not supported"));
+
        /*
         * Validate the handle
         * Although the handle is partially validated in acpi_ex_reconfiguration()
index 4bdbd1d8431b1f67f316ac9c6908dc6f70d321f7..90ccffcd770b16740d1f35bbe224f07ec83e6dea 100644 (file)
@@ -170,6 +170,7 @@ acpi_ns_dump_one_object(acpi_handle obj_handle,
        }
 
        type = this_node->type;
+       info->count++;
 
        /* Check if the owner matches */
 
@@ -639,6 +640,7 @@ acpi_ns_dump_objects(acpi_object_type type,
                return;
        }
 
+       info.count = 0;
        info.debug_level = ACPI_LV_TABLES;
        info.owner_id = owner_id;
        info.display_type = display_type;
@@ -649,6 +651,7 @@ acpi_ns_dump_objects(acpi_object_type type,
                                     acpi_ns_dump_one_object, NULL,
                                     (void *)&info, NULL);
 
+       acpi_os_printf("\nNamespace node count: %u\n\n", info.count);
        (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
 }
 
index 68422afc365f2ac48f98c29f540058ca519fc0c5..bc5f05906bd1c871403896c3a2bce9122f3a67df 100644 (file)
@@ -515,6 +515,22 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
                                if (ACPI_FAILURE(status)) {
                                        return_ACPI_STATUS(status);
                                }
+                               if (walk_state->opcode == AML_SCOPE_OP) {
+                                       /*
+                                        * If the scope op fails to parse, skip the body of the
+                                        * scope op because the parse failure indicates that the
+                                        * device may not exist.
+                                        */
+                                       walk_state->parser_state.aml =
+                                           walk_state->aml + 1;
+                                       walk_state->parser_state.aml =
+                                           acpi_ps_get_next_package_end
+                                           (&walk_state->parser_state);
+                                       walk_state->aml =
+                                           walk_state->parser_state.aml;
+                                       ACPI_ERROR((AE_INFO,
+                                                   "Skipping Scope block"));
+                               }
 
                                continue;
                        }
@@ -557,7 +573,40 @@ acpi_status acpi_ps_parse_loop(struct acpi_walk_state *walk_state)
                                if (ACPI_FAILURE(status)) {
                                        return_ACPI_STATUS(status);
                                }
-
+                               if ((walk_state->control_state) &&
+                                   ((walk_state->control_state->control.
+                                     opcode == AML_IF_OP)
+                                    || (walk_state->control_state->control.
+                                        opcode == AML_WHILE_OP))) {
+                                       /*
+                                        * If the if/while op fails to parse, we will skip parsing
+                                        * the body of the op.
+                                        */
+                                       parser_state->aml =
+                                           walk_state->control_state->control.
+                                           aml_predicate_start + 1;
+                                       parser_state->aml =
+                                           acpi_ps_get_next_package_end
+                                           (parser_state);
+                                       walk_state->aml = parser_state->aml;
+
+                                       ACPI_ERROR((AE_INFO,
+                                                   "Skipping While/If block"));
+                                       if (*walk_state->aml == AML_ELSE_OP) {
+                                               ACPI_ERROR((AE_INFO,
+                                                           "Skipping Else block"));
+                                               walk_state->parser_state.aml =
+                                                   walk_state->aml + 1;
+                                               walk_state->parser_state.aml =
+                                                   acpi_ps_get_next_package_end
+                                                   (parser_state);
+                                               walk_state->aml =
+                                                   parser_state->aml;
+                                       }
+                                       ACPI_FREE(acpi_ut_pop_generic_state
+                                                 (&walk_state->control_state));
+                               }
+                               op = NULL;
                                continue;
                        }
                }
index 7d9d0151ee54dc3a48875f1efeb3b905ae960988..3138e7a00da815dc44f882b4be35f97b3250e82b 100644 (file)
@@ -12,6 +12,7 @@
 #include "acparser.h"
 #include "amlcode.h"
 #include "acconvert.h"
+#include "acnamesp.h"
 
 #define _COMPONENT          ACPI_PARSER
 ACPI_MODULE_NAME("psobject")
@@ -549,6 +550,21 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state,
 
                do {
                        if (*op) {
+                               /*
+                                * These Opcodes need to be removed from the namespace because they
+                                * get created even if these opcodes cannot be created due to
+                                * errors.
+                                */
+                               if (((*op)->common.aml_opcode == AML_REGION_OP)
+                                   || ((*op)->common.aml_opcode ==
+                                       AML_DATA_REGION_OP)) {
+                                       acpi_ns_delete_children((*op)->common.
+                                                               node);
+                                       acpi_ns_remove_node((*op)->common.node);
+                                       (*op)->common.node = NULL;
+                                       acpi_ps_delete_parse_tree(*op);
+                               }
+
                                status2 =
                                    acpi_ps_complete_this_op(walk_state, *op);
                                if (ACPI_FAILURE(status2)) {
@@ -574,6 +590,20 @@ acpi_ps_complete_op(struct acpi_walk_state *walk_state,
 #endif
                walk_state->prev_op = NULL;
                walk_state->prev_arg_types = walk_state->arg_types;
+
+               if (walk_state->parse_flags & ACPI_PARSE_MODULE_LEVEL) {
+                       /*
+                        * There was something that went wrong while executing code at the
+                        * module-level. We need to skip parsing whatever caused the
+                        * error and keep going. One runtime error during the table load
+                        * should not cause the entire table to not be loaded. This is
+                        * because there could be correct AML beyond the parts that caused
+                        * the runtime error.
+                        */
+                       ACPI_ERROR((AE_INFO,
+                                   "Ignore error and continue table load"));
+                       return_ACPI_STATUS(AE_OK);
+               }
                return_ACPI_STATUS(status);
        }
 
index e0a442b8648b791f970f77b0e3d7cd4ac25175e8..bd6af8c87d48e4446716868044477a07c9909ca7 100644 (file)
@@ -25,22 +25,48 @@ ACPI_MODULE_NAME("pswalk")
  * DESCRIPTION: Delete a portion of or an entire parse tree.
  *
  ******************************************************************************/
+#include "amlcode.h"
 void acpi_ps_delete_parse_tree(union acpi_parse_object *subtree_root)
 {
        union acpi_parse_object *op = subtree_root;
        union acpi_parse_object *next = NULL;
        union acpi_parse_object *parent = NULL;
+       u32 level = 0;
 
        ACPI_FUNCTION_TRACE_PTR(ps_delete_parse_tree, subtree_root);
 
+       ACPI_DEBUG_PRINT((ACPI_DB_PARSE_TREES, " root %p\n", subtree_root));
+
        /* Visit all nodes in the subtree */
 
        while (op) {
-
-               /* Check if we are not ascending */
-
                if (op != parent) {
 
+                       /* This is the descending case */
+
+                       if (ACPI_IS_DEBUG_ENABLED
+                           (ACPI_LV_PARSE_TREES, _COMPONENT)) {
+
+                               /* This debug option will print the entire parse tree */
+
+                               acpi_os_printf("      %*.s%s %p", (level * 4),
+                                              " ",
+                                              acpi_ps_get_opcode_name(op->
+                                                                      common.
+                                                                      aml_opcode),
+                                              op);
+
+                               if (op->named.aml_opcode == AML_INT_NAMEPATH_OP) {
+                                       acpi_os_printf("  %4.4s",
+                                                      op->common.value.string);
+                               }
+                               if (op->named.aml_opcode == AML_STRING_OP) {
+                                       acpi_os_printf("  %s",
+                                                      op->common.value.string);
+                               }
+                               acpi_os_printf("\n");
+                       }
+
                        /* Look for an argument or child of the current op */
 
                        next = acpi_ps_get_arg(op, 0);
@@ -49,6 +75,7 @@ void acpi_ps_delete_parse_tree(union acpi_parse_object *subtree_root)
                                /* Still going downward in tree (Op is not completed yet) */
 
                                op = next;
+                               level++;
                                continue;
                        }
                }
@@ -69,6 +96,7 @@ void acpi_ps_delete_parse_tree(union acpi_parse_object *subtree_root)
                if (next) {
                        op = next;
                } else {
+                       level--;
                        op = parent;
                }
        }
index 12d4a0f6b8d298cb54a576695f607bc2929d20fb..5a64ddaed8a3782f94e278424368a7ce7167bfbb 100644 (file)
@@ -182,20 +182,20 @@ acpi_ut_prefixed_namespace_error(const char *module_name,
        switch (lookup_status) {
        case AE_ALREADY_EXISTS:
 
-               acpi_os_printf(ACPI_MSG_BIOS_ERROR);
+               acpi_os_printf("\n" ACPI_MSG_BIOS_ERROR);
                message = "Failure creating";
                break;
 
        case AE_NOT_FOUND:
 
-               acpi_os_printf(ACPI_MSG_BIOS_ERROR);
-               message = "Failure looking up";
+               acpi_os_printf("\n" ACPI_MSG_BIOS_ERROR);
+               message = "Could not resolve";
                break;
 
        default:
 
-               acpi_os_printf(ACPI_MSG_ERROR);
-               message = "Failure looking up";
+               acpi_os_printf("\n" ACPI_MSG_ERROR);
+               message = "Failure resolving";
                break;
        }
 
index 1b415fa90cf8151f40cd2f43acc0ef3df63475b2..64b63c81994b696d7e4885b662eba7af3a0859e1 100644 (file)
@@ -69,6 +69,7 @@ static struct acpi_interface_info acpi_default_supported_interfaces[] = {
        {"Windows 2015", NULL, 0, ACPI_OSI_WIN_10},     /* Windows 10 - Added 03/2015 */
        {"Windows 2016", NULL, 0, ACPI_OSI_WIN_10_RS1}, /* Windows 10 version 1607 - Added 12/2017 */
        {"Windows 2017", NULL, 0, ACPI_OSI_WIN_10_RS2}, /* Windows 10 version 1703 - Added 12/2017 */
+       {"Windows 2017.2", NULL, 0, ACPI_OSI_WIN_10_RS3},       /* Windows 10 version 1709 - Added 02/2018 */
 
        /* Feature Group Strings */
 
index 9bff853e85f37831d8d053a2aa363f139537c9b5..3c5ea7cb693ef558829ab15b930d234cd51b9d67 100644 (file)
@@ -524,7 +524,8 @@ static int __erst_record_id_cache_add_one(void)
                                pr_warn(FW_WARN "too many record IDs!\n");
                        return 0;
                }
-               new_entries = kvmalloc(new_size * sizeof(entries[0]), GFP_KERNEL);
+               new_entries = kvmalloc_array(new_size, sizeof(entries[0]),
+                                            GFP_KERNEL);
                if (!new_entries)
                        return -ENOMEM;
                memcpy(new_entries, entries,
index 9cb74115a43d76bbfa845feb57ef779bf320f0ad..b1e9f81ebeea25b58ba6c0f9820ad38b4bc5b9e0 100644 (file)
@@ -195,7 +195,8 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count)
        struct ghes_arr ghes_arr;
 
        ghes_arr.count = 0;
-       ghes_arr.ghes_devs = kmalloc(sizeof(void *) * ghes_count, GFP_KERNEL);
+       ghes_arr.ghes_devs = kmalloc_array(ghes_count, sizeof(void *),
+                                          GFP_KERNEL);
        if (!ghes_arr.ghes_devs)
                return -ENOMEM;
 
index 3563103590c6f69e4cc5abbf7fd3a9ea727ad501..fe0183d48dcd7ab7d0e81bfe53f8c07bc8e284ef 100644 (file)
@@ -298,8 +298,8 @@ static int acpi_fan_get_fps(struct acpi_device *device)
        }
 
        fan->fps_count = obj->package.count - 1; /* minus revision field */
-       fan->fps = devm_kzalloc(&device->dev,
-                               fan->fps_count * sizeof(struct acpi_fan_fps),
+       fan->fps = devm_kcalloc(&device->dev,
+                               fan->fps_count, sizeof(struct acpi_fan_fps),
                                GFP_KERNEL);
        if (!fan->fps) {
                dev_err(&device->dev, "Not enough memory\n");
index b87252bf4571775ba8344376e7a2c985b91e0487..d15814e1727fad991bf8c24c2d7fa728ad1bfcad 100644 (file)
@@ -1082,9 +1082,10 @@ static int __nfit_mem_init(struct acpi_nfit_desc *acpi_desc,
                                continue;
                        nfit_mem->nfit_flush = nfit_flush;
                        flush = nfit_flush->flush;
-                       nfit_mem->flush_wpq = devm_kzalloc(acpi_desc->dev,
-                                       flush->hint_count
-                                       * sizeof(struct resource), GFP_KERNEL);
+                       nfit_mem->flush_wpq = devm_kcalloc(acpi_desc->dev,
+                                       flush->hint_count,
+                                       sizeof(struct resource),
+                                       GFP_KERNEL);
                        if (!nfit_mem->flush_wpq)
                                return -ENOMEM;
                        for (i = 0; i < flush->hint_count; i++) {
index a651ab3490d8bbbe843204c6065bb30c64f7dfb8..a303fd0e108ccbe8180d233462deea15b5f570f9 100644 (file)
@@ -343,8 +343,9 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 
        pr->performance->state_count = pss->package.count;
        pr->performance->states =
-           kmalloc(sizeof(struct acpi_processor_px) * pss->package.count,
-                   GFP_KERNEL);
+           kmalloc_array(pss->package.count,
+                         sizeof(struct acpi_processor_px),
+                         GFP_KERNEL);
        if (!pr->performance->states) {
                result = -ENOMEM;
                goto end;
index 7f9aff4b8d627db3accf80a12054b698887a314d..fbc936cf2025c7eaa1d3a51d5463dcafabb3894c 100644 (file)
@@ -534,8 +534,9 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 
        pr->throttling.state_count = tss->package.count;
        pr->throttling.states_tss =
-           kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count,
-                   GFP_KERNEL);
+           kmalloc_array(tss->package.count,
+                         sizeof(struct acpi_processor_tx_tss),
+                         GFP_KERNEL);
        if (!pr->throttling.states_tss) {
                result = -ENOMEM;
                goto end;
index 4fc59c3bc6734406831ef665aceb54205629ce96..41324f0b1bee26b73a55ddc027fb8f52928a31a5 100644 (file)
@@ -857,12 +857,12 @@ void acpi_irq_stats_init(void)
        num_gpes = acpi_current_gpe_count;
        num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA;
 
-       all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1),
+       all_attrs = kcalloc(num_counters + 1, sizeof(struct attribute *),
                            GFP_KERNEL);
        if (all_attrs == NULL)
                return;
 
-       all_counters = kzalloc(sizeof(struct event_counter) * (num_counters),
+       all_counters = kcalloc(num_counters, sizeof(struct event_counter),
                               GFP_KERNEL);
        if (all_counters == NULL)
                goto fail;
@@ -871,7 +871,7 @@ void acpi_irq_stats_init(void)
        if (ACPI_FAILURE(status))
                goto fail;
 
-       counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters),
+       counter_attrs = kcalloc(num_counters, sizeof(struct kobj_attribute),
                                GFP_KERNEL);
        if (counter_attrs == NULL)
                goto fail;
index 4f382d51def11f4816694be6e7e02aa1598f720f..2628806c64a2265cead6a13cec928ba785267677 100644 (file)
@@ -692,8 +692,8 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
                }
        }
 #endif
-       alloc->pages = kzalloc(sizeof(alloc->pages[0]) *
-                                  ((vma->vm_end - vma->vm_start) / PAGE_SIZE),
+       alloc->pages = kcalloc((vma->vm_end - vma->vm_start) / PAGE_SIZE,
+                              sizeof(alloc->pages[0]),
                               GFP_KERNEL);
        if (alloc->pages == NULL) {
                ret = -ENOMEM;
index c41b9eeabe7c748d86bd4c64ba04f92f734e0e3c..27d15ed7fa3d03771f020cf064749f6f9fe38633 100644 (file)
@@ -6987,7 +6987,7 @@ static void __init ata_parse_force_param(void)
                if (*p == ',')
                        size++;
 
-       ata_force_tbl = kzalloc(sizeof(ata_force_tbl[0]) * size, GFP_KERNEL);
+       ata_force_tbl = kcalloc(size, sizeof(ata_force_tbl[0]), GFP_KERNEL);
        if (!ata_force_tbl) {
                printk(KERN_WARNING "ata: failed to extend force table, "
                       "libata.force ignored\n");
index 85aa76116a305eb50d77f2544c87f09914998bed..2ae1799f49927231f16cf49cbfb872607c128ea3 100644 (file)
@@ -340,7 +340,7 @@ static int sata_pmp_init_links (struct ata_port *ap, int nr_ports)
        int i, err;
 
        if (!pmp_link) {
-               pmp_link = kzalloc(sizeof(pmp_link[0]) * SATA_PMP_MAX_PORTS,
+               pmp_link = kcalloc(SATA_PMP_MAX_PORTS, sizeof(pmp_link[0]),
                                   GFP_NOIO);
                if (!pmp_link)
                        return -ENOMEM;
index cddf96f6e431fa7676db9d9fe097d80d864413ff..73ba8e134ca9a9054867ae4e32581f9cc825539d 100644 (file)
@@ -4114,13 +4114,13 @@ static int mv_platform_probe(struct platform_device *pdev)
 
        if (!host || !hpriv)
                return -ENOMEM;
-       hpriv->port_clks = devm_kzalloc(&pdev->dev,
-                                       sizeof(struct clk *) * n_ports,
+       hpriv->port_clks = devm_kcalloc(&pdev->dev,
+                                       n_ports, sizeof(struct clk *),
                                        GFP_KERNEL);
        if (!hpriv->port_clks)
                return -ENOMEM;
-       hpriv->port_phys = devm_kzalloc(&pdev->dev,
-                                       sizeof(struct phy *) * n_ports,
+       hpriv->port_phys = devm_kcalloc(&pdev->dev,
+                                       n_ports, sizeof(struct phy *),
                                        GFP_KERNEL);
        if (!hpriv->port_phys)
                return -ENOMEM;
index 6ebc4e4820fc4b267351970047e29a7c700902cc..99a38115b0a8fcdf4fc3037802f050a89b9d8ee1 100644 (file)
@@ -2094,7 +2094,8 @@ static int fore200e_alloc_rx_buf(struct fore200e *fore200e)
            DPRINTK(2, "rx buffers %d / %d are being allocated\n", scheme, magn);
 
            /* allocate the array of receive buffers */
-           buffer = bsq->buffer = kzalloc(nbr * sizeof(struct buffer), GFP_KERNEL);
+           buffer = bsq->buffer = kcalloc(nbr, sizeof(struct buffer),
+                                           GFP_KERNEL);
 
            if (buffer == NULL)
                return -ENOMEM;
index be076606d30e09cb3b56fe779059cd892ef796b8..ff81a576347e5154c10c997717548be69e81bbab 100644 (file)
@@ -1618,7 +1618,7 @@ static int rx_init(struct atm_dev *dev)
        skb_queue_head_init(&iadev->rx_dma_q);  
        iadev->rx_free_desc_qhead = NULL;   
 
-       iadev->rx_open = kzalloc(4 * iadev->num_vc, GFP_KERNEL);
+       iadev->rx_open = kcalloc(4, iadev->num_vc, GFP_KERNEL);
        if (!iadev->rx_open) {
                printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n",
                dev->number);  
index 0df1a1c80b00126e7d6083de7a51328758d4742b..17283018269f0343df85e9c2bed32d6276d369a7 100644 (file)
@@ -1291,7 +1291,8 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
                card->using_dma = 1;
                if (1) { /* All known FPGA versions so far */
                        card->dma_alignment = 3;
-                       card->dma_bounce = kmalloc(card->nr_ports * BUF_SIZE, GFP_KERNEL);
+                       card->dma_bounce = kmalloc_array(card->nr_ports,
+                                                        BUF_SIZE, GFP_KERNEL);
                        if (!card->dma_bounce) {
                                dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n");
                                err = -ENOMEM;
index 6bd2f65e116a0dee8986f10f5e83f654992eaa6d..7eebae7e322c605e97d2592223beb92ab82054c3 100644 (file)
@@ -333,8 +333,8 @@ static int __init cfag12864b_init(void)
                goto none;
        }
 
-       cfag12864b_cache = kmalloc(sizeof(unsigned char) *
-               CFAG12864B_SIZE, GFP_KERNEL);
+       cfag12864b_cache = kmalloc(CFAG12864B_SIZE,
+                                  GFP_KERNEL);
        if (cfag12864b_cache == NULL) {
                printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
                        "can't alloc cache buffer (%i bytes)\n",
index fb4e2df68d95b9f16d6cf4f07dee1fa828decc05..1435d7281c66e3d82e877fc98eb8b7ae7321ec19 100644 (file)
@@ -580,7 +580,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
        pr_debug("bus: '%s': %s: matched device %s with driver %s\n",
                 drv->bus->name, __func__, dev_name(dev), drv->name);
 
-       pm_runtime_resume_suppliers(dev);
+       pm_runtime_get_suppliers(dev);
        if (dev->parent)
                pm_runtime_get_sync(dev->parent);
 
@@ -591,6 +591,7 @@ int driver_probe_device(struct device_driver *drv, struct device *dev)
        if (dev->parent)
                pm_runtime_put(dev->parent);
 
+       pm_runtime_put_suppliers(dev);
        return ret;
 }
 
index b676a99c469c2fcf475db6ff81359a0f363f8d4f..7f732744f0d368ba38e4ebb062bc9cff5f1762d6 100644 (file)
@@ -403,7 +403,7 @@ static int fw_realloc_pages(struct fw_sysfs *fw_sysfs, int min_size)
                                         fw_priv->page_array_size * 2);
                struct page **new_pages;
 
-               new_pages = vmalloc(new_array_size * sizeof(void *));
+               new_pages = vmalloc(array_size(new_array_size, sizeof(void *)));
                if (!new_pages) {
                        fw_load_abort(fw_sysfs);
                        return -ENOMEM;
index 7ae62b6355b8d9ce5da5518f0be8f9c3bf217ab1..df41b4780b3b71bf11d2fd0e6c7242c54f3a1086 100644 (file)
@@ -116,14 +116,51 @@ int dev_pm_domain_attach(struct device *dev, bool power_on)
 }
 EXPORT_SYMBOL_GPL(dev_pm_domain_attach);
 
+/**
+ * dev_pm_domain_attach_by_id - Associate a device with one of its PM domains.
+ * @dev: The device used to lookup the PM domain.
+ * @index: The index of the PM domain.
+ *
+ * As @dev may only be attached to a single PM domain, the backend PM domain
+ * provider creates a virtual device to attach instead. If attachment succeeds,
+ * the ->detach() callback in the struct dev_pm_domain are assigned by the
+ * corresponding backend attach function, as to deal with detaching of the
+ * created virtual device.
+ *
+ * This function should typically be invoked by a driver during the probe phase,
+ * in case its device requires power management through multiple PM domains. The
+ * driver may benefit from using the received device, to configure device-links
+ * towards its original device. Depending on the use-case and if needed, the
+ * links may be dynamically changed by the driver, which allows it to control
+ * the power to the PM domains independently from each other.
+ *
+ * Callers must ensure proper synchronization of this function with power
+ * management callbacks.
+ *
+ * Returns the virtual created device when successfully attached to its PM
+ * domain, NULL in case @dev don't need a PM domain, else an ERR_PTR().
+ * Note that, to detach the returned virtual device, the driver shall call
+ * dev_pm_domain_detach() on it, typically during the remove phase.
+ */
+struct device *dev_pm_domain_attach_by_id(struct device *dev,
+                                         unsigned int index)
+{
+       if (dev->pm_domain)
+               return ERR_PTR(-EEXIST);
+
+       return genpd_dev_pm_attach_by_id(dev, index);
+}
+EXPORT_SYMBOL_GPL(dev_pm_domain_attach_by_id);
+
 /**
  * dev_pm_domain_detach - Detach a device from its PM domain.
  * @dev: Device to detach.
  * @power_off: Used to indicate whether we should power off the device.
  *
- * This functions will reverse the actions from dev_pm_domain_attach() and thus
- * try to detach the @dev from its PM domain. Typically it should be invoked
- * from subsystem level code during the remove phase.
+ * This functions will reverse the actions from dev_pm_domain_attach() and
+ * dev_pm_domain_attach_by_id(), thus it detaches @dev from its PM domain.
+ * Typically it should be invoked during the remove phase, either from
+ * subsystem level code or from drivers.
  *
  * Callers must ensure proper synchronization of this function with power
  * management callbacks.
index 6f403d6fccb2b3d86287ef0a03ae12226889f032..4925af5c4cf039e6cc07918967aa6995353e4bd8 100644 (file)
@@ -2171,6 +2171,15 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np)
 }
 EXPORT_SYMBOL_GPL(of_genpd_remove_last);
 
+static void genpd_release_dev(struct device *dev)
+{
+       kfree(dev);
+}
+
+static struct bus_type genpd_bus_type = {
+       .name           = "genpd",
+};
+
 /**
  * genpd_dev_pm_detach - Detach a device from its PM domain.
  * @dev: Device to detach.
@@ -2208,6 +2217,10 @@ static void genpd_dev_pm_detach(struct device *dev, bool power_off)
 
        /* Check if PM domain can be powered off after removing this device. */
        genpd_queue_power_off_work(pd);
+
+       /* Unregister the device if it was created by genpd. */
+       if (dev->bus == &genpd_bus_type)
+               device_unregister(dev);
 }
 
 static void genpd_dev_pm_sync(struct device *dev)
@@ -2221,32 +2234,17 @@ static void genpd_dev_pm_sync(struct device *dev)
        genpd_queue_power_off_work(pd);
 }
 
-/**
- * genpd_dev_pm_attach - Attach a device to its PM domain using DT.
- * @dev: Device to attach.
- *
- * Parse device's OF node to find a PM domain specifier. If such is found,
- * attaches the device to retrieved pm_domain ops.
- *
- * Returns 1 on successfully attached PM domain, 0 when the device don't need a
- * PM domain or a negative error code in case of failures. Note that if a
- * power-domain exists for the device, but it cannot be found or turned on,
- * then return -EPROBE_DEFER to ensure that the device is not probed and to
- * re-try again later.
- */
-int genpd_dev_pm_attach(struct device *dev)
+static int __genpd_dev_pm_attach(struct device *dev, struct device_node *np,
+                                unsigned int index)
 {
        struct of_phandle_args pd_args;
        struct generic_pm_domain *pd;
        int ret;
 
-       if (!dev->of_node)
-               return 0;
-
-       ret = of_parse_phandle_with_args(dev->of_node, "power-domains",
-                                       "#power-domain-cells", 0, &pd_args);
+       ret = of_parse_phandle_with_args(np, "power-domains",
+                               "#power-domain-cells", index, &pd_args);
        if (ret < 0)
-               return 0;
+               return ret;
 
        mutex_lock(&gpd_list_lock);
        pd = genpd_get_from_provider(&pd_args);
@@ -2282,8 +2280,98 @@ int genpd_dev_pm_attach(struct device *dev)
 
        return ret ? -EPROBE_DEFER : 1;
 }
+
+/**
+ * genpd_dev_pm_attach - Attach a device to its PM domain using DT.
+ * @dev: Device to attach.
+ *
+ * Parse device's OF node to find a PM domain specifier. If such is found,
+ * attaches the device to retrieved pm_domain ops.
+ *
+ * Returns 1 on successfully attached PM domain, 0 when the device don't need a
+ * PM domain or when multiple power-domains exists for it, else a negative error
+ * code. Note that if a power-domain exists for the device, but it cannot be
+ * found or turned on, then return -EPROBE_DEFER to ensure that the device is
+ * not probed and to re-try again later.
+ */
+int genpd_dev_pm_attach(struct device *dev)
+{
+       if (!dev->of_node)
+               return 0;
+
+       /*
+        * Devices with multiple PM domains must be attached separately, as we
+        * can only attach one PM domain per device.
+        */
+       if (of_count_phandle_with_args(dev->of_node, "power-domains",
+                                      "#power-domain-cells") != 1)
+               return 0;
+
+       return __genpd_dev_pm_attach(dev, dev->of_node, 0);
+}
 EXPORT_SYMBOL_GPL(genpd_dev_pm_attach);
 
+/**
+ * genpd_dev_pm_attach_by_id - Associate a device with one of its PM domains.
+ * @dev: The device used to lookup the PM domain.
+ * @index: The index of the PM domain.
+ *
+ * Parse device's OF node to find a PM domain specifier at the provided @index.
+ * If such is found, creates a virtual device and attaches it to the retrieved
+ * pm_domain ops. To deal with detaching of the virtual device, the ->detach()
+ * callback in the struct dev_pm_domain are assigned to genpd_dev_pm_detach().
+ *
+ * Returns the created virtual device if successfully attached PM domain, NULL
+ * when the device don't need a PM domain, else an ERR_PTR() in case of
+ * failures. If a power-domain exists for the device, but cannot be found or
+ * turned on, then ERR_PTR(-EPROBE_DEFER) is returned to ensure that the device
+ * is not probed and to re-try again later.
+ */
+struct device *genpd_dev_pm_attach_by_id(struct device *dev,
+                                        unsigned int index)
+{
+       struct device *genpd_dev;
+       int num_domains;
+       int ret;
+
+       if (!dev->of_node)
+               return NULL;
+
+       /* Deal only with devices using multiple PM domains. */
+       num_domains = of_count_phandle_with_args(dev->of_node, "power-domains",
+                                                "#power-domain-cells");
+       if (num_domains < 2 || index >= num_domains)
+               return NULL;
+
+       /* Allocate and register device on the genpd bus. */
+       genpd_dev = kzalloc(sizeof(*genpd_dev), GFP_KERNEL);
+       if (!genpd_dev)
+               return ERR_PTR(-ENOMEM);
+
+       dev_set_name(genpd_dev, "genpd:%u:%s", index, dev_name(dev));
+       genpd_dev->bus = &genpd_bus_type;
+       genpd_dev->release = genpd_release_dev;
+
+       ret = device_register(genpd_dev);
+       if (ret) {
+               kfree(genpd_dev);
+               return ERR_PTR(ret);
+       }
+
+       /* Try to attach the device to the PM domain at the specified index. */
+       ret = __genpd_dev_pm_attach(genpd_dev, dev->of_node, index);
+       if (ret < 1) {
+               device_unregister(genpd_dev);
+               return ret ? ERR_PTR(ret) : NULL;
+       }
+
+       pm_runtime_set_active(genpd_dev);
+       pm_runtime_enable(genpd_dev);
+
+       return genpd_dev;
+}
+EXPORT_SYMBOL_GPL(genpd_dev_pm_attach_by_id);
+
 static const struct of_device_id idle_state_match[] = {
        { .compatible = "domain-idle-state", },
        { }
@@ -2443,6 +2531,12 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev,
 }
 EXPORT_SYMBOL_GPL(of_genpd_opp_to_performance_state);
 
+static int __init genpd_bus_init(void)
+{
+       return bus_register(&genpd_bus_type);
+}
+core_initcall(genpd_bus_init);
+
 #endif /* CONFIG_PM_GENERIC_DOMAINS_OF */
 
 
index c6030f100c087fc5edb4ca216f35b4945692f69e..beb85c31f3fa3b9f997a4f21c72891f40e7535ed 100644 (file)
@@ -1563,16 +1563,37 @@ void pm_runtime_clean_up_links(struct device *dev)
 }
 
 /**
- * pm_runtime_resume_suppliers - Resume supplier devices.
+ * pm_runtime_get_suppliers - Resume and reference-count supplier devices.
  * @dev: Consumer device.
  */
-void pm_runtime_resume_suppliers(struct device *dev)
+void pm_runtime_get_suppliers(struct device *dev)
 {
+       struct device_link *link;
        int idx;
 
        idx = device_links_read_lock();
 
-       rpm_get_suppliers(dev);
+       list_for_each_entry_rcu(link, &dev->links.suppliers, c_node)
+               if (link->flags & DL_FLAG_PM_RUNTIME)
+                       pm_runtime_get_sync(link->supplier);
+
+       device_links_read_unlock(idx);
+}
+
+/**
+ * pm_runtime_put_suppliers - Drop references to supplier devices.
+ * @dev: Consumer device.
+ */
+void pm_runtime_put_suppliers(struct device *dev)
+{
+       struct device_link *link;
+       int idx;
+
+       idx = device_links_read_lock();
+
+       list_for_each_entry_rcu(link, &dev->links.suppliers, c_node)
+               if (link->flags & DL_FLAG_PM_RUNTIME)
+                       pm_runtime_put(link->supplier);
 
        device_links_read_unlock(idx);
 }
index 0f651efc58a1ad8352f2f97e0c310332cdd4b174..d713738ce7967cdb8003166fc17bf63116d3b629 100644 (file)
@@ -353,7 +353,7 @@ static ssize_t wakeup_count_show(struct device *dev,
 
        spin_lock_irq(&dev->power.lock);
        if (dev->power.wakeup) {
-               count = dev->power.wakeup->event_count;
+               count = dev->power.wakeup->wakeup_count;
                enabled = true;
        }
        spin_unlock_irq(&dev->power.lock);
index 6ca77d6047d619dd54ea5ef464af625d1712db8f..f6518067aa7d069009bd6a2215805f2ca71c6380 100644 (file)
@@ -5719,8 +5719,8 @@ static bool DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
       Controller->CombinedStatusBufferLength = NewStatusBufferLength;
       return true;
     }
-  NewStatusBuffer = kmalloc(2 * Controller->CombinedStatusBufferLength,
-                            GFP_ATOMIC);
+  NewStatusBuffer = kmalloc_array(2, Controller->CombinedStatusBufferLength,
+                                  GFP_ATOMIC);
   if (NewStatusBuffer == NULL)
     {
       DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n",
index 7655d6133139961a26e02df3de444a7950683436..a80809bd305715c92015292413ccd19ec2bb253b 100644 (file)
@@ -511,7 +511,8 @@ static void drbd_calc_cpu_mask(cpumask_var_t *cpu_mask)
 {
        unsigned int *resources_per_cpu, min_index = ~0;
 
-       resources_per_cpu = kzalloc(nr_cpu_ids * sizeof(*resources_per_cpu), GFP_KERNEL);
+       resources_per_cpu = kcalloc(nr_cpu_ids, sizeof(*resources_per_cpu),
+                                   GFP_KERNEL);
        if (resources_per_cpu) {
                struct drbd_resource *resource;
                unsigned int cpu, min = ~0;
index 21e6d1b3b393448cea181f5e06f2978543b48a9a..d6b6f434fd4bb7652faf597ef9ab6c7b6dd7c362 100644 (file)
@@ -524,7 +524,8 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
 
                __rq_for_each_bio(bio, rq)
                        segments += bio_segments(bio);
-               bvec = kmalloc(sizeof(struct bio_vec) * segments, GFP_NOIO);
+               bvec = kmalloc_array(segments, sizeof(struct bio_vec),
+                                    GFP_NOIO);
                if (!bvec)
                        return -EIO;
                cmd->bvec = bvec;
index 2bdadd7f14542fab264c02b73534bbfbd7379edc..7948049f6c4321b02e1611383dae1be86a7748f1 100644 (file)
@@ -1575,12 +1575,12 @@ static int setup_commands(struct nullb_queue *nq)
        struct nullb_cmd *cmd;
        int i, tag_size;
 
-       nq->cmds = kzalloc(nq->queue_depth * sizeof(*cmd), GFP_KERNEL);
+       nq->cmds = kcalloc(nq->queue_depth, sizeof(*cmd), GFP_KERNEL);
        if (!nq->cmds)
                return -ENOMEM;
 
        tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG;
-       nq->tag_map = kzalloc(tag_size * sizeof(unsigned long), GFP_KERNEL);
+       nq->tag_map = kcalloc(tag_size, sizeof(unsigned long), GFP_KERNEL);
        if (!nq->tag_map) {
                kfree(nq->cmds);
                return -ENOMEM;
@@ -1598,8 +1598,9 @@ static int setup_commands(struct nullb_queue *nq)
 
 static int setup_queues(struct nullb *nullb)
 {
-       nullb->queues = kzalloc(nullb->dev->submit_queues *
-               sizeof(struct nullb_queue), GFP_KERNEL);
+       nullb->queues = kcalloc(nullb->dev->submit_queues,
+                               sizeof(struct nullb_queue),
+                               GFP_KERNEL);
        if (!nullb->queues)
                return -ENOMEM;
 
index 8fa4533a1249a6d74825f3bac3088e213f5bd980..1e3d5de9d8387e16ed0735711328314380ca8873 100644 (file)
@@ -407,8 +407,9 @@ static int ps3vram_cache_init(struct ps3_system_bus_device *dev)
 
        priv->cache.page_count = CACHE_PAGE_COUNT;
        priv->cache.page_size = CACHE_PAGE_SIZE;
-       priv->cache.tags = kzalloc(sizeof(struct ps3vram_tag) *
-                                  CACHE_PAGE_COUNT, GFP_KERNEL);
+       priv->cache.tags = kcalloc(CACHE_PAGE_COUNT,
+                                  sizeof(struct ps3vram_tag),
+                                  GFP_KERNEL);
        if (!priv->cache.tags)
                return -ENOMEM;
 
index af354047ac4b67dc3be6eb55689387cc4219de4d..fa0729c1e776e21834f02caa2d42ac7867c5ad36 100644 (file)
@@ -2339,6 +2339,7 @@ static bool is_zero_bvecs(struct bio_vec *bvecs, u32 bytes)
 static int rbd_obj_issue_copyup(struct rbd_obj_request *obj_req, u32 bytes)
 {
        unsigned int num_osd_ops = obj_req->osd_req->r_num_ops;
+       int ret;
 
        dout("%s obj_req %p bytes %u\n", __func__, obj_req, bytes);
        rbd_assert(obj_req->osd_req->r_ops[0].op == CEPH_OSD_OP_STAT);
@@ -2353,6 +2354,11 @@ static int rbd_obj_issue_copyup(struct rbd_obj_request *obj_req, u32 bytes)
        if (!obj_req->osd_req)
                return -ENOMEM;
 
+       ret = osd_req_op_cls_init(obj_req->osd_req, 0, CEPH_OSD_OP_CALL, "rbd",
+                                 "copyup");
+       if (ret)
+               return ret;
+
        /*
         * Only send non-zero copyup data to save some I/O and network
         * bandwidth -- zero copyup data is equivalent to the object not
@@ -2362,9 +2368,6 @@ static int rbd_obj_issue_copyup(struct rbd_obj_request *obj_req, u32 bytes)
                dout("%s obj_req %p detected zeroes\n", __func__, obj_req);
                bytes = 0;
        }
-
-       osd_req_op_cls_init(obj_req->osd_req, 0, CEPH_OSD_OP_CALL, "rbd",
-                           "copyup");
        osd_req_op_cls_request_data_bvecs(obj_req->osd_req, 0,
                                          obj_req->copyup_bvecs,
                                          obj_req->copyup_bvec_count,
@@ -3397,7 +3400,6 @@ static void cancel_tasks_sync(struct rbd_device *rbd_dev)
 {
        dout("%s rbd_dev %p\n", __func__, rbd_dev);
 
-       cancel_delayed_work_sync(&rbd_dev->watch_dwork);
        cancel_work_sync(&rbd_dev->acquired_lock_work);
        cancel_work_sync(&rbd_dev->released_lock_work);
        cancel_delayed_work_sync(&rbd_dev->lock_dwork);
@@ -3415,6 +3417,7 @@ static void rbd_unregister_watch(struct rbd_device *rbd_dev)
        rbd_dev->watch_state = RBD_WATCH_STATE_UNREGISTERED;
        mutex_unlock(&rbd_dev->watch_mutex);
 
+       cancel_delayed_work_sync(&rbd_dev->watch_dwork);
        ceph_osdc_flush_notifies(&rbd_dev->rbd_client->client->osdc);
 }
 
index 09537bee387f85fcbaea962ecc960e5bcf4dccad..b7d71914a32a8b66541fb308a9cd4aa95056fdd2 100644 (file)
@@ -873,7 +873,8 @@ static int rsxx_pci_probe(struct pci_dev *dev,
                dev_info(CARD_TO_DEV(card),
                        "Failed reading the number of DMA targets\n");
 
-       card->ctrl = kzalloc(card->n_targets * sizeof(*card->ctrl), GFP_KERNEL);
+       card->ctrl = kcalloc(card->n_targets, sizeof(*card->ctrl),
+                            GFP_KERNEL);
        if (!card->ctrl) {
                st = -ENOMEM;
                goto failed_dma_setup;
index beaccf197a5a85f41eaf1798862f32ce3eb0cd06..8fbc1bf6db3d2cce92974b291f20c92fc90dc538 100644 (file)
@@ -1038,7 +1038,7 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
        struct rsxx_dma *dma;
        struct list_head *issued_dmas;
 
-       issued_dmas = kzalloc(sizeof(*issued_dmas) * card->n_targets,
+       issued_dmas = kcalloc(card->n_targets, sizeof(*issued_dmas),
                              GFP_KERNEL);
        if (!issued_dmas)
                return -ENOMEM;
index 66412eededda2b17dadcfaf8222d8c34edb58571..a4bc74e72c394965f31dcbe7b55c8e5cd0fc6cd5 100644 (file)
@@ -139,7 +139,8 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif)
 {
        unsigned int r;
 
-       blkif->rings = kzalloc(blkif->nr_rings * sizeof(struct xen_blkif_ring), GFP_KERNEL);
+       blkif->rings = kcalloc(blkif->nr_rings, sizeof(struct xen_blkif_ring),
+                              GFP_KERNEL);
        if (!blkif->rings)
                return -ENOMEM;
 
index ae00a82f350b55b4f38010ccd746146c2b7d6c44..b5cedccb5d7db10ec9d75632e221acd73308933b 100644 (file)
@@ -1906,7 +1906,9 @@ static int negotiate_mq(struct blkfront_info *info)
        if (!info->nr_rings)
                info->nr_rings = 1;
 
-       info->rinfo = kzalloc(sizeof(struct blkfront_ring_info) * info->nr_rings, GFP_KERNEL);
+       info->rinfo = kcalloc(info->nr_rings,
+                             sizeof(struct blkfront_ring_info),
+                             GFP_KERNEL);
        if (!info->rinfo) {
                xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure");
                return -ENOMEM;
@@ -2216,15 +2218,18 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo)
        }
 
        for (i = 0; i < BLK_RING_SIZE(info); i++) {
-               rinfo->shadow[i].grants_used = kzalloc(
-                       sizeof(rinfo->shadow[i].grants_used[0]) * grants,
-                       GFP_NOIO);
-               rinfo->shadow[i].sg = kzalloc(sizeof(rinfo->shadow[i].sg[0]) * psegs, GFP_NOIO);
-               if (info->max_indirect_segments)
-                       rinfo->shadow[i].indirect_grants = kzalloc(
-                               sizeof(rinfo->shadow[i].indirect_grants[0]) *
-                               INDIRECT_GREFS(grants),
+               rinfo->shadow[i].grants_used =
+                       kcalloc(grants,
+                               sizeof(rinfo->shadow[i].grants_used[0]),
                                GFP_NOIO);
+               rinfo->shadow[i].sg = kcalloc(psegs,
+                                             sizeof(rinfo->shadow[i].sg[0]),
+                                             GFP_NOIO);
+               if (info->max_indirect_segments)
+                       rinfo->shadow[i].indirect_grants =
+                               kcalloc(INDIRECT_GREFS(grants),
+                                       sizeof(rinfo->shadow[i].indirect_grants[0]),
+                                       GFP_NOIO);
                if ((rinfo->shadow[i].grants_used == NULL) ||
                        (rinfo->shadow[i].sg == NULL) ||
                     (info->max_indirect_segments &&
index 8f9130ab5887273d8feba518fabb76524fa7b579..d0c5bc4e07039bcaf1625e614b56093f7a0c4c46 100644 (file)
@@ -197,8 +197,9 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
                vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size);
 #endif
                z2ram_map = 
-                       kmalloc((size/Z2RAM_CHUNKSIZE)*sizeof(z2ram_map[0]),
-                               GFP_KERNEL);
+                       kmalloc_array(size / Z2RAM_CHUNKSIZE,
+                                      sizeof(z2ram_map[0]),
+                                      GFP_KERNEL);
                if ( z2ram_map == NULL )
                {
                    printk( KERN_ERR DEVICE_NAME
index da51293e7c03c172ba824e303d5bbc4ae3d7d745..7436b2d27fa38513602207c6b4bc9213c97af436 100644 (file)
@@ -898,7 +898,7 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize)
        size_t num_pages;
 
        num_pages = disksize >> PAGE_SHIFT;
-       zram->table = vzalloc(num_pages * sizeof(*zram->table));
+       zram->table = vzalloc(array_size(num_pages, sizeof(*zram->table)));
        if (!zram->table)
                return false;
 
index 6dc177bf4c42f6fce5b9787072aba2b7aa94e98c..d1c0b60e9326f5f5a0b0db56ac7d328283f27506 100644 (file)
@@ -33,7 +33,6 @@ config HISILICON_LPC
        bool "Support for ISA I/O space on HiSilicon Hip06/7"
        depends on ARM64 && (ARCH_HISI || COMPILE_TEST)
        select INDIRECT_PIO
-       select MFD_CORE if ACPI
        help
          Driver to enable I/O access to devices attached to the Low Pin
          Count bus on the HiSilicon Hip06/7 SoC.
index 443e4c3fd35794a84ec657d443fa48f3c7a956e2..b8184a9035837bcb29dfcb168741b929b8e7ade4 100644 (file)
@@ -371,8 +371,6 @@ asmlinkage void __naked cci_enable_port_for_self(void)
        [sizeof_struct_cpu_port] "i" (sizeof(struct cpu_port)),
        [sizeof_struct_ace_port] "i" (sizeof(struct cci_ace_port)),
        [offsetof_port_phys] "i" (offsetof(struct cci_ace_port, phys)) );
-
-       unreachable();
 }
 
 /**
index fb1442b08962fed3a61550d09958cae4e0730cd4..e906ecfe23dd82025cdfc9b412f309a7f04fdfdf 100644 (file)
@@ -354,8 +354,8 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
        if (error < 0)
                return error;
 
-       irq_resources = devm_kzalloc(&mc_bus_dev->dev,
-                                    sizeof(*irq_resources) * irq_count,
+       irq_resources = devm_kcalloc(&mc_bus_dev->dev,
+                                    irq_count, sizeof(*irq_resources),
                                     GFP_KERNEL);
        if (!irq_resources) {
                error = -ENOMEM;
@@ -455,7 +455,7 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev)
                return -ENOSPC;
        }
 
-       irqs = devm_kzalloc(&mc_dev->dev, irq_count * sizeof(irqs[0]),
+       irqs = devm_kcalloc(&mc_dev->dev, irq_count, sizeof(irqs[0]),
                            GFP_KERNEL);
        if (!irqs)
                return -ENOMEM;
index 2d4611e4c3392654d05f7c80f9676622b3964394..d5f85455fa6216fc2c7660e5f543f5aab71f50f5 100644 (file)
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <linux/logic_pio.h>
-#include <linux/mfd/core.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/pci.h>
+#include <linux/serial_8250.h>
 #include <linux/slab.h>
 
 #define DRV_NAME "hisi-lpc"
@@ -341,15 +341,6 @@ static const struct logic_pio_host_ops hisi_lpc_ops = {
 };
 
 #ifdef CONFIG_ACPI
-#define MFD_CHILD_NAME_PREFIX DRV_NAME"-"
-#define MFD_CHILD_NAME_LEN (ACPI_ID_LEN + sizeof(MFD_CHILD_NAME_PREFIX) - 1)
-
-struct hisi_lpc_mfd_cell {
-       struct mfd_cell_acpi_match acpi_match;
-       char name[MFD_CHILD_NAME_LEN];
-       char pnpid[ACPI_ID_LEN];
-};
-
 static int hisi_lpc_acpi_xlat_io_res(struct acpi_device *adev,
                                     struct acpi_device *host,
                                     struct resource *res)
@@ -368,7 +359,7 @@ static int hisi_lpc_acpi_xlat_io_res(struct acpi_device *adev,
 }
 
 /*
- * hisi_lpc_acpi_set_io_res - set the resources for a child's MFD
+ * hisi_lpc_acpi_set_io_res - set the resources for a child
  * @child: the device node to be updated the I/O resource
  * @hostdev: the device node associated with host controller
  * @res: double pointer to be set to the address of translated resources
@@ -452,78 +443,122 @@ static int hisi_lpc_acpi_set_io_res(struct device *child,
        return 0;
 }
 
+static int hisi_lpc_acpi_remove_subdev(struct device *dev, void *unused)
+{
+       platform_device_unregister(to_platform_device(dev));
+       return 0;
+}
+
+struct hisi_lpc_acpi_cell {
+       const char *hid;
+       const char *name;
+       void *pdata;
+       size_t pdata_size;
+};
+
 /*
  * hisi_lpc_acpi_probe - probe children for ACPI FW
  * @hostdev: LPC host device pointer
  *
  * Returns 0 when successful, and a negative value for failure.
  *
- * Scan all child devices and create a per-device MFD with
- * logical PIO translated IO resources.
+ * Create a platform device per child, fixing up the resources
+ * from bus addresses to Logical PIO addresses.
+ *
  */
 static int hisi_lpc_acpi_probe(struct device *hostdev)
 {
        struct acpi_device *adev = ACPI_COMPANION(hostdev);
-       struct hisi_lpc_mfd_cell *hisi_lpc_mfd_cells;
-       struct mfd_cell *mfd_cells;
        struct acpi_device *child;
-       int size, ret, count = 0, cell_num = 0;
-
-       list_for_each_entry(child, &adev->children, node)
-               cell_num++;
-
-       /* allocate the mfd cell and companion ACPI info, one per child */
-       size = sizeof(*mfd_cells) + sizeof(*hisi_lpc_mfd_cells);
-       mfd_cells = devm_kcalloc(hostdev, cell_num, size, GFP_KERNEL);
-       if (!mfd_cells)
-               return -ENOMEM;
+       int ret;
 
-       hisi_lpc_mfd_cells = (struct hisi_lpc_mfd_cell *)&mfd_cells[cell_num];
        /* Only consider the children of the host */
        list_for_each_entry(child, &adev->children, node) {
-               struct mfd_cell *mfd_cell = &mfd_cells[count];
-               struct hisi_lpc_mfd_cell *hisi_lpc_mfd_cell =
-                                       &hisi_lpc_mfd_cells[count];
-               struct mfd_cell_acpi_match *acpi_match =
-                                       &hisi_lpc_mfd_cell->acpi_match;
-               char *name = hisi_lpc_mfd_cell[count].name;
-               char *pnpid = hisi_lpc_mfd_cell[count].pnpid;
-               struct mfd_cell_acpi_match match = {
-                       .pnpid = pnpid,
+               const char *hid = acpi_device_hid(child);
+               const struct hisi_lpc_acpi_cell *cell;
+               struct platform_device *pdev;
+               const struct resource *res;
+               bool found = false;
+               int num_res;
+
+               ret = hisi_lpc_acpi_set_io_res(&child->dev, &adev->dev, &res,
+                                              &num_res);
+               if (ret) {
+                       dev_warn(hostdev, "set resource fail (%d)\n", ret);
+                       goto fail;
+               }
+
+               cell = (struct hisi_lpc_acpi_cell []){
+                       /* ipmi */
+                       {
+                               .hid = "IPI0001",
+                               .name = "hisi-lpc-ipmi",
+                       },
+                       /* 8250-compatible uart */
+                       {
+                               .hid = "HISI1031",
+                               .name = "serial8250",
+                               .pdata = (struct plat_serial8250_port []) {
+                                       {
+                                               .iobase = res->start,
+                                               .uartclk = 1843200,
+                                               .iotype = UPIO_PORT,
+                                               .flags = UPF_BOOT_AUTOCONF,
+                                       },
+                                       {}
+                               },
+                               .pdata_size = 2 *
+                                       sizeof(struct plat_serial8250_port),
+                       },
+                       {}
                };
 
-               /*
-                * For any instances of this host controller (Hip06 and Hip07
-                * are the only chipsets), we would not have multiple slaves
-                * with the same HID. And in any system we would have just one
-                * controller active. So don't worrry about MFD name clashes.
-                */
-               snprintf(name, MFD_CHILD_NAME_LEN, MFD_CHILD_NAME_PREFIX"%s",
-                        acpi_device_hid(child));
-               snprintf(pnpid, ACPI_ID_LEN, "%s", acpi_device_hid(child));
-
-               memcpy(acpi_match, &match, sizeof(*acpi_match));
-               mfd_cell->name = name;
-               mfd_cell->acpi_match = acpi_match;
-
-               ret = hisi_lpc_acpi_set_io_res(&child->dev, &adev->dev,
-                                              &mfd_cell->resources,
-                                              &mfd_cell->num_resources);
-               if (ret) {
-                       dev_warn(&child->dev, "set resource fail (%d)\n", ret);
-                       return ret;
+               for (; cell && cell->name; cell++) {
+                       if (!strcmp(cell->hid, hid)) {
+                               found = true;
+                               break;
+                       }
                }
-               count++;
-       }
 
-       ret = mfd_add_devices(hostdev, PLATFORM_DEVID_NONE,
-                             mfd_cells, cell_num, NULL, 0, NULL);
-       if (ret) {
-               dev_err(hostdev, "failed to add mfd cells (%d)\n", ret);
-               return ret;
+               if (!found) {
+                       dev_warn(hostdev,
+                                "could not find cell for child device (%s)\n",
+                                hid);
+                       ret = -ENODEV;
+                       goto fail;
+               }
+
+               pdev = platform_device_alloc(cell->name, PLATFORM_DEVID_AUTO);
+               if (!pdev) {
+                       ret = -ENOMEM;
+                       goto fail;
+               }
+
+               pdev->dev.parent = hostdev;
+               ACPI_COMPANION_SET(&pdev->dev, child);
+
+               ret = platform_device_add_resources(pdev, res, num_res);
+               if (ret)
+                       goto fail;
+
+               ret = platform_device_add_data(pdev, cell->pdata,
+                                              cell->pdata_size);
+               if (ret)
+                       goto fail;
+
+               ret = platform_device_add(pdev);
+               if (ret)
+                       goto fail;
+
+               acpi_device_set_enumerated(child);
        }
 
        return 0;
+
+fail:
+       device_for_each_child(hostdev, NULL,
+                             hisi_lpc_acpi_remove_subdev);
+       return ret;
 }
 
 static const struct acpi_device_id hisi_lpc_acpi_match[] = {
index 7cd2fd04b212de5b7228c8d5a68e5432069c0a5a..1cc29629d23807b83bfee9f7d23fec1d5757941d 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/platform_device.h>
 #include <linux/pm_domain.h>
 #include <linux/pm_runtime.h>
+#include <linux/reset.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/slab.h>
@@ -32,10 +33,18 @@ static const char * const reg_names[] = { "rev", "sysc", "syss", };
 enum sysc_clocks {
        SYSC_FCK,
        SYSC_ICK,
+       SYSC_OPTFCK0,
+       SYSC_OPTFCK1,
+       SYSC_OPTFCK2,
+       SYSC_OPTFCK3,
+       SYSC_OPTFCK4,
+       SYSC_OPTFCK5,
+       SYSC_OPTFCK6,
+       SYSC_OPTFCK7,
        SYSC_MAX_CLOCKS,
 };
 
-static const char * const clock_names[] = { "fck", "ick", };
+static const char * const clock_names[SYSC_ICK + 1] = { "fck", "ick", };
 
 #define SYSC_IDLEMODE_MASK             3
 #define SYSC_CLOCKACTIVITY_MASK                3
@@ -48,6 +57,8 @@ static const char * const clock_names[] = { "fck", "ick", };
  * @module_va: virtual address of the interconnect target module
  * @offsets: register offsets from module base
  * @clocks: clocks used by the interconnect target module
+ * @clock_roles: clock role names for the found clocks
+ * @nr_clocks: number of clocks used by the interconnect target module
  * @legacy_mode: configured for legacy mode if set
  * @cap: interconnect target module capabilities
  * @cfg: interconnect target module configuration
@@ -61,7 +72,10 @@ struct sysc {
        u32 module_size;
        void __iomem *module_va;
        int offsets[SYSC_MAX_REGS];
-       struct clk *clocks[SYSC_MAX_CLOCKS];
+       struct clk **clocks;
+       const char **clock_roles;
+       int nr_clocks;
+       struct reset_control *rsts;
        const char *legacy_mode;
        const struct sysc_capabilities *cap;
        struct sysc_config cfg;
@@ -88,6 +102,11 @@ static u32 sysc_read(struct sysc *ddata, int offset)
        return readl_relaxed(ddata->module_va + offset);
 }
 
+static bool sysc_opt_clks_needed(struct sysc *ddata)
+{
+       return !!(ddata->cfg.quirks & SYSC_QUIRK_OPT_CLKS_NEEDED);
+}
+
 static u32 sysc_read_revision(struct sysc *ddata)
 {
        int offset = ddata->offsets[SYSC_REVISION];
@@ -98,21 +117,28 @@ static u32 sysc_read_revision(struct sysc *ddata)
        return sysc_read(ddata, offset);
 }
 
-static int sysc_get_one_clock(struct sysc *ddata,
-                             enum sysc_clocks index)
+static int sysc_get_one_clock(struct sysc *ddata, const char *name)
 {
-       const char *name;
-       int error;
+       int error, i, index = -ENODEV;
+
+       if (!strncmp(clock_names[SYSC_FCK], name, 3))
+               index = SYSC_FCK;
+       else if (!strncmp(clock_names[SYSC_ICK], name, 3))
+               index = SYSC_ICK;
+
+       if (index < 0) {
+               for (i = SYSC_OPTFCK0; i < SYSC_MAX_CLOCKS; i++) {
+                       if (!ddata->clocks[i]) {
+                               index = i;
+                               break;
+                       }
+               }
+       }
 
-       switch (index) {
-       case SYSC_FCK:
-               break;
-       case SYSC_ICK:
-               break;
-       default:
-               return -EINVAL;
+       if (index < 0) {
+               dev_err(ddata->dev, "clock %s not added\n", name);
+               return index;
        }
-       name = clock_names[index];
 
        ddata->clocks[index] = devm_clk_get(ddata->dev, name);
        if (IS_ERR(ddata->clocks[index])) {
@@ -138,10 +164,50 @@ static int sysc_get_one_clock(struct sysc *ddata,
 
 static int sysc_get_clocks(struct sysc *ddata)
 {
-       int i, error;
+       struct device_node *np = ddata->dev->of_node;
+       struct property *prop;
+       const char *name;
+       int nr_fck = 0, nr_ick = 0, i, error = 0;
 
-       for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
-               error = sysc_get_one_clock(ddata, i);
+       ddata->clock_roles = devm_kzalloc(ddata->dev,
+                                         sizeof(*ddata->clock_roles) *
+                                         SYSC_MAX_CLOCKS,
+                                         GFP_KERNEL);
+       if (!ddata->clock_roles)
+               return -ENOMEM;
+
+       of_property_for_each_string(np, "clock-names", prop, name) {
+               if (!strncmp(clock_names[SYSC_FCK], name, 3))
+                       nr_fck++;
+               if (!strncmp(clock_names[SYSC_ICK], name, 3))
+                       nr_ick++;
+               ddata->clock_roles[ddata->nr_clocks] = name;
+               ddata->nr_clocks++;
+       }
+
+       if (ddata->nr_clocks < 1)
+               return 0;
+
+       if (ddata->nr_clocks > SYSC_MAX_CLOCKS) {
+               dev_err(ddata->dev, "too many clocks for %pOF\n", np);
+
+               return -EINVAL;
+       }
+
+       if (nr_fck > 1 || nr_ick > 1) {
+               dev_err(ddata->dev, "max one fck and ick for %pOF\n", np);
+
+               return -EINVAL;
+       }
+
+       ddata->clocks = devm_kzalloc(ddata->dev,
+                                    sizeof(*ddata->clocks) * ddata->nr_clocks,
+                                    GFP_KERNEL);
+       if (!ddata->clocks)
+               return -ENOMEM;
+
+       for (i = 0; i < ddata->nr_clocks; i++) {
+               error = sysc_get_one_clock(ddata, ddata->clock_roles[i]);
                if (error && error != -ENOENT)
                        return error;
        }
@@ -149,6 +215,42 @@ static int sysc_get_clocks(struct sysc *ddata)
        return 0;
 }
 
+/**
+ * sysc_init_resets - reset module on init
+ * @ddata: device driver data
+ *
+ * A module can have both OCP softreset control and external rstctrl.
+ * If more complicated rstctrl resets are needed, please handle these
+ * directly from the child device driver and map only the module reset
+ * for the parent interconnect target module device.
+ *
+ * Automatic reset of the module on init can be skipped with the
+ * "ti,no-reset-on-init" device tree property.
+ */
+static int sysc_init_resets(struct sysc *ddata)
+{
+       int error;
+
+       ddata->rsts =
+               devm_reset_control_array_get_optional_exclusive(ddata->dev);
+       if (IS_ERR(ddata->rsts))
+               return PTR_ERR(ddata->rsts);
+
+       if (ddata->cfg.quirks & SYSC_QUIRK_NO_RESET_ON_INIT)
+               goto deassert;
+
+       error = reset_control_assert(ddata->rsts);
+       if (error)
+               return error;
+
+deassert:
+       error = reset_control_deassert(ddata->rsts);
+       if (error)
+               return error;
+
+       return 0;
+}
+
 /**
  * sysc_parse_and_check_child_range - parses module IO region from ranges
  * @ddata: device driver data
@@ -533,9 +635,13 @@ static int __maybe_unused sysc_runtime_suspend(struct device *dev)
                goto idled;
        }
 
-       for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
+       for (i = 0; i < ddata->nr_clocks; i++) {
                if (IS_ERR_OR_NULL(ddata->clocks[i]))
                        continue;
+
+               if (i >= SYSC_OPTFCK0 && !sysc_opt_clks_needed(ddata))
+                       break;
+
                clk_disable(ddata->clocks[i]);
        }
 
@@ -572,9 +678,13 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev)
                goto awake;
        }
 
-       for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
+       for (i = 0; i < ddata->nr_clocks; i++) {
                if (IS_ERR_OR_NULL(ddata->clocks[i]))
                        continue;
+
+               if (i >= SYSC_OPTFCK0 && !sysc_opt_clks_needed(ddata))
+                       break;
+
                error = clk_enable(ddata->clocks[i]);
                if (error)
                        return error;
@@ -590,23 +700,103 @@ static int __maybe_unused sysc_runtime_resume(struct device *dev)
 static int sysc_suspend(struct device *dev)
 {
        struct sysc *ddata;
+       int error;
 
        ddata = dev_get_drvdata(dev);
 
+       if (ddata->cfg.quirks & (SYSC_QUIRK_RESOURCE_PROVIDER |
+                                SYSC_QUIRK_LEGACY_IDLE))
+               return 0;
+
        if (!ddata->enabled)
                return 0;
 
+       dev_dbg(ddata->dev, "%s %s\n", __func__,
+               ddata->name ? ddata->name : "");
+
+       error = pm_runtime_put_sync_suspend(dev);
+       if (error < 0) {
+               dev_warn(ddata->dev, "%s not idle %i %s\n",
+                        __func__, error,
+                        ddata->name ? ddata->name : "");
+
+               return 0;
+       }
+
        ddata->needs_resume = true;
 
-       return sysc_runtime_suspend(dev);
+       return 0;
 }
 
 static int sysc_resume(struct device *dev)
+{
+       struct sysc *ddata;
+       int error;
+
+       ddata = dev_get_drvdata(dev);
+
+       if (ddata->cfg.quirks & (SYSC_QUIRK_RESOURCE_PROVIDER |
+                                SYSC_QUIRK_LEGACY_IDLE))
+               return 0;
+
+       if (ddata->needs_resume) {
+               dev_dbg(ddata->dev, "%s %s\n", __func__,
+                       ddata->name ? ddata->name : "");
+
+               error = pm_runtime_get_sync(dev);
+               if (error < 0) {
+                       dev_err(ddata->dev, "%s  error %i %s\n",
+                               __func__, error,
+                                ddata->name ? ddata->name : "");
+
+                       return error;
+               }
+
+               ddata->needs_resume = false;
+       }
+
+       return 0;
+}
+
+static int sysc_noirq_suspend(struct device *dev)
 {
        struct sysc *ddata;
 
        ddata = dev_get_drvdata(dev);
+
+       if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
+               return 0;
+
+       if (!(ddata->cfg.quirks & SYSC_QUIRK_RESOURCE_PROVIDER))
+               return 0;
+
+       if (!ddata->enabled)
+               return 0;
+
+       dev_dbg(ddata->dev, "%s %s\n", __func__,
+               ddata->name ? ddata->name : "");
+
+       ddata->needs_resume = true;
+
+       return sysc_runtime_suspend(dev);
+}
+
+static int sysc_noirq_resume(struct device *dev)
+{
+       struct sysc *ddata;
+
+       ddata = dev_get_drvdata(dev);
+
+       if (ddata->cfg.quirks & SYSC_QUIRK_LEGACY_IDLE)
+               return 0;
+
+       if (!(ddata->cfg.quirks & SYSC_QUIRK_RESOURCE_PROVIDER))
+               return 0;
+
        if (ddata->needs_resume) {
+               dev_dbg(ddata->dev, "%s %s\n", __func__,
+                       ddata->name ? ddata->name : "");
+
                ddata->needs_resume = false;
 
                return sysc_runtime_resume(dev);
@@ -618,6 +808,7 @@ static int sysc_resume(struct device *dev)
 
 static const struct dev_pm_ops sysc_pm_ops = {
        SET_SYSTEM_SLEEP_PM_OPS(sysc_suspend, sysc_resume)
+       SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(sysc_noirq_suspend, sysc_noirq_resume)
        SET_RUNTIME_PM_OPS(sysc_runtime_suspend,
                           sysc_runtime_resume,
                           NULL)
@@ -649,9 +840,29 @@ struct sysc_revision_quirk {
        }
 
 static const struct sysc_revision_quirk sysc_revision_quirks[] = {
+       /* These need to use noirq_suspend */
+       SYSC_QUIRK("control", 0, 0, 0x10, -1, 0x40000900, 0xffffffff,
+                  SYSC_QUIRK_RESOURCE_PROVIDER),
+       SYSC_QUIRK("i2c", 0, 0, 0x10, 0x90, 0x5040000a, 0xffffffff,
+                  SYSC_QUIRK_RESOURCE_PROVIDER),
+       SYSC_QUIRK("mcspi", 0, 0, 0x10, -1, 0x40300a0b, 0xffffffff,
+                  SYSC_QUIRK_RESOURCE_PROVIDER),
+       SYSC_QUIRK("prcm", 0, 0, -1, -1, 0x40000100, 0xffffffff,
+                  SYSC_QUIRK_RESOURCE_PROVIDER),
+       SYSC_QUIRK("ocp2scp", 0, 0, 0x10, 0x14, 0x50060005, 0xffffffff,
+                  SYSC_QUIRK_RESOURCE_PROVIDER),
+       SYSC_QUIRK("padconf", 0, 0, 0x10, -1, 0x4fff0800, 0xffffffff,
+                  SYSC_QUIRK_RESOURCE_PROVIDER),
+       SYSC_QUIRK("scm", 0, 0, 0x10, -1, 0x40000900, 0xffffffff,
+                  SYSC_QUIRK_RESOURCE_PROVIDER),
+       SYSC_QUIRK("scrm", 0, 0, -1, -1, 0x00000010, 0xffffffff,
+                  SYSC_QUIRK_RESOURCE_PROVIDER),
+       SYSC_QUIRK("sdma", 0, 0, 0x2c, 0x28, 0x00010900, 0xffffffff,
+                  SYSC_QUIRK_RESOURCE_PROVIDER),
+
        /* These drivers need to be fixed to not use pm_runtime_irq_safe() */
        SYSC_QUIRK("gpio", 0, 0, 0x10, 0x114, 0x50600801, 0xffffffff,
-                  SYSC_QUIRK_LEGACY_IDLE),
+                  SYSC_QUIRK_LEGACY_IDLE | SYSC_QUIRK_OPT_CLKS_IN_RESET),
        SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000020, 0xffffffff,
                   SYSC_QUIRK_LEGACY_IDLE),
        SYSC_QUIRK("mmu", 0, 0, 0x10, 0x14, 0x00000030, 0xffffffff,
@@ -664,8 +875,40 @@ static const struct sysc_revision_quirk sysc_revision_quirks[] = {
                   SYSC_QUIRK_LEGACY_IDLE),
        SYSC_QUIRK("timer", 0, 0, 0x10, 0x14, 0x00000015, 0xffffffff,
                   SYSC_QUIRK_LEGACY_IDLE),
+       /* Some timers on omap4 and later */
+       SYSC_QUIRK("timer", 0, 0, 0x10, -1, 0x4fff1301, 0xffffffff,
+                  SYSC_QUIRK_LEGACY_IDLE),
        SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x00000052, 0xffffffff,
                   SYSC_QUIRK_LEGACY_IDLE),
+       /* Uarts on omap4 and later */
+       SYSC_QUIRK("uart", 0, 0x50, 0x54, 0x58, 0x50411e03, 0xffffffff,
+                  SYSC_QUIRK_LEGACY_IDLE),
+
+       /* These devices don't yet suspend properly without legacy setting */
+       SYSC_QUIRK("sdio", 0, 0, 0x10, -1, 0x40202301, 0xffffffff,
+                  SYSC_QUIRK_LEGACY_IDLE),
+       SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0500, 0xffffffff,
+                  SYSC_QUIRK_LEGACY_IDLE),
+       SYSC_QUIRK("wdt", 0, 0, 0x10, 0x14, 0x502a0d00, 0xffffffff,
+                  SYSC_QUIRK_LEGACY_IDLE),
+
+#ifdef DEBUG
+       SYSC_QUIRK("aess", 0, 0, 0x10, -1, 0x40000000, 0xffffffff, 0),
+       SYSC_QUIRK("gpu", 0, 0x1fc00, 0x1fc10, -1, 0, 0, 0),
+       SYSC_QUIRK("hdq1w", 0, 0, 0x14, 0x18, 0x00000006, 0xffffffff, 0),
+       SYSC_QUIRK("hsi", 0, 0, 0x10, 0x14, 0x50043101, 0xffffffff, 0),
+       SYSC_QUIRK("iss", 0, 0, 0x10, -1, 0x40000101, 0xffffffff, 0),
+       SYSC_QUIRK("mcasp", 0, 0, 0x4, -1, 0x44306302, 0xffffffff, 0),
+       SYSC_QUIRK("mcbsp", 0, -1, 0x8c, -1, 0, 0, 0),
+       SYSC_QUIRK("mailbox", 0, 0, 0x10, -1, 0x00000400, 0xffffffff, 0),
+       SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40000902, 0xffffffff, 0),
+       SYSC_QUIRK("slimbus", 0, 0, 0x10, -1, 0x40002903, 0xffffffff, 0),
+       SYSC_QUIRK("spinlock", 0, 0, 0x10, -1, 0x50020000, 0xffffffff, 0),
+       SYSC_QUIRK("usbhstll", 0, 0, 0x10, 0x14, 0x00000004, 0xffffffff, 0),
+       SYSC_QUIRK("usb_host_hs", 0, 0, 0x10, 0x14, 0x50700100, 0xffffffff, 0),
+       SYSC_QUIRK("usb_otg_hs", 0, 0x400, 0x404, 0x408, 0x00000050,
+                  0xffffffff, 0),
+#endif
 };
 
 static void sysc_init_revision_quirks(struct sysc *ddata)
@@ -716,6 +959,7 @@ static int sysc_init_module(struct sysc *ddata)
 
                return 0;
        }
+
        ddata->revision = sysc_read_revision(ddata);
        pm_runtime_put_sync(ddata->dev);
 
@@ -811,29 +1055,58 @@ static int sysc_init_syss_mask(struct sysc *ddata)
 }
 
 /*
- * Many child device drivers need to have fck available to get the clock
- * rate for device internal configuration.
+ * Many child device drivers need to have fck and opt clocks available
+ * to get the clock rate for device internal configuration etc.
  */
-static int sysc_child_add_fck(struct sysc *ddata,
-                             struct device *child)
+static int sysc_child_add_named_clock(struct sysc *ddata,
+                                     struct device *child,
+                                     const char *name)
 {
-       struct clk *fck;
+       struct clk *clk;
        struct clk_lookup *l;
-       const char *name = clock_names[SYSC_FCK];
+       int error = 0;
 
-       if (IS_ERR_OR_NULL(ddata->clocks[SYSC_FCK]))
+       if (!name)
                return 0;
 
-       fck = clk_get(child, name);
-       if (!IS_ERR(fck)) {
-               clk_put(fck);
+       clk = clk_get(child, name);
+       if (!IS_ERR(clk)) {
+               clk_put(clk);
 
                return -EEXIST;
        }
 
-       l = clkdev_create(ddata->clocks[SYSC_FCK], name, dev_name(child));
+       clk = clk_get(ddata->dev, name);
+       if (IS_ERR(clk))
+               return -ENODEV;
+
+       l = clkdev_create(clk, name, dev_name(child));
+       if (!l)
+               error = -ENOMEM;
+
+       clk_put(clk);
+
+       return error;
+}
+
+static int sysc_child_add_clocks(struct sysc *ddata,
+                                struct device *child)
+{
+       int i, error;
+
+       for (i = 0; i < ddata->nr_clocks; i++) {
+               error = sysc_child_add_named_clock(ddata,
+                                                  child,
+                                                  ddata->clock_roles[i]);
+               if (error && error != -EEXIST) {
+                       dev_err(ddata->dev, "could not add child clock %s: %i\n",
+                               ddata->clock_roles[i], error);
+
+                       return error;
+               }
+       }
 
-       return l ? 0 : -ENODEV;
+       return 0;
 }
 
 static struct device_type sysc_device_type = {
@@ -891,18 +1164,33 @@ static int sysc_child_suspend_noirq(struct device *dev)
 
        ddata = sysc_child_to_parent(dev);
 
+       dev_dbg(ddata->dev, "%s %s\n", __func__,
+               ddata->name ? ddata->name : "");
+
        error = pm_generic_suspend_noirq(dev);
-       if (error)
+       if (error) {
+               dev_err(dev, "%s error at %i: %i\n",
+                       __func__, __LINE__, error);
+
                return error;
+       }
 
        if (!pm_runtime_status_suspended(dev)) {
                error = pm_generic_runtime_suspend(dev);
-               if (error)
+               if (error) {
+                       dev_err(dev, "%s error at %i: %i\n",
+                               __func__, __LINE__, error);
+
                        return error;
+               }
 
                error = sysc_runtime_suspend(ddata->dev);
-               if (error)
+               if (error) {
+                       dev_err(dev, "%s error at %i: %i\n",
+                               __func__, __LINE__, error);
+
                        return error;
+               }
 
                ddata->child_needs_resume = true;
        }
@@ -917,6 +1205,9 @@ static int sysc_child_resume_noirq(struct device *dev)
 
        ddata = sysc_child_to_parent(dev);
 
+       dev_dbg(ddata->dev, "%s %s\n", __func__,
+               ddata->name ? ddata->name : "");
+
        if (ddata->child_needs_resume) {
                ddata->child_needs_resume = false;
 
@@ -983,10 +1274,9 @@ static int sysc_notifier_call(struct notifier_block *nb,
 
        switch (event) {
        case BUS_NOTIFY_ADD_DEVICE:
-               error = sysc_child_add_fck(ddata, dev);
-               if (error && error != -EEXIST)
-                       dev_warn(ddata->dev, "could not add %s fck: %i\n",
-                                dev_name(dev), error);
+               error = sysc_child_add_clocks(ddata, dev);
+               if (error)
+                       return error;
                sysc_legacy_idle_quirk(ddata, dev);
                break;
        default:
@@ -1314,6 +1604,11 @@ static void ti_sysc_idle(struct work_struct *work)
                pm_runtime_put_sync(ddata->dev);
 }
 
+static const struct of_device_id sysc_match_table[] = {
+       { .compatible = "simple-bus", },
+       { /* sentinel */ },
+};
+
 static int sysc_probe(struct platform_device *pdev)
 {
        struct ti_sysc_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -1359,8 +1654,11 @@ static int sysc_probe(struct platform_device *pdev)
        if (error)
                goto unprepare;
 
-       pm_runtime_enable(ddata->dev);
+       error = sysc_init_resets(ddata);
+       if (error)
+               return error;
 
+       pm_runtime_enable(ddata->dev);
        error = sysc_init_module(ddata);
        if (error)
                goto unprepare;
@@ -1375,8 +1673,8 @@ static int sysc_probe(struct platform_device *pdev)
        sysc_show_registers(ddata);
 
        ddata->dev->type = &sysc_device_type;
-       error = of_platform_populate(ddata->dev->of_node,
-                                    NULL, pdata ? pdata->auxdata : NULL,
+       error = of_platform_populate(ddata->dev->of_node, sysc_match_table,
+                                    pdata ? pdata->auxdata : NULL,
                                     ddata->dev);
        if (error)
                goto err;
@@ -1391,6 +1689,9 @@ static int sysc_probe(struct platform_device *pdev)
                pm_runtime_put(&pdev->dev);
        }
 
+       if (!of_get_available_child_count(ddata->dev->of_node))
+               reset_control_assert(ddata->rsts);
+
        return 0;
 
 err:
@@ -1420,6 +1721,7 @@ static int sysc_remove(struct platform_device *pdev)
 
        pm_runtime_put_sync(&pdev->dev);
        pm_runtime_disable(&pdev->dev);
+       reset_control_assert(ddata->rsts);
 
 unprepare:
        sysc_unprepare(ddata);
index 9adc8c3eb0fa7affa56f8e9ade8bd2e62f8025a7..a78b8e7085e9bc71497e81002cd014776ff9767b 100644 (file)
@@ -2132,7 +2132,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
         */
        nr = nframes;
        do {
-               cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
+               cgc.buffer = kmalloc_array(nr, CD_FRAMESIZE_RAW, GFP_KERNEL);
                if (cgc.buffer)
                        break;
 
index 410c30c42120ab9645838aa37768cbdc65e43104..212f447938ae95a695a7980f26263f017f72ee47 100644 (file)
@@ -81,7 +81,7 @@ config PRINTER
          corresponding drivers into the kernel.
 
          To compile this driver as a module, choose M here and read
-         <file:Documentation/parport.txt>.  The module will be called lp.
+         <file:Documentation/admin-guide/parport.rst>.  The module will be called lp.
 
          If you have several parallel ports, you can specify which ports to
          use with the "lp" kernel command line option.  (Try "man bootparam"
index b450544dcaf0fc3c188b3eabfea7319438709ed7..6914e4f0ce985d584ee06c23c7ffc83c7204214d 100644 (file)
@@ -85,7 +85,8 @@ static int amd_create_gatt_pages(int nr_tables)
        int retval = 0;
        int i;
 
-       tables = kzalloc((nr_tables + 1) * sizeof(struct amd_page_map *),GFP_KERNEL);
+       tables = kcalloc(nr_tables + 1, sizeof(struct amd_page_map *),
+                        GFP_KERNEL);
        if (tables == NULL)
                return -ENOMEM;
 
index 88b4cbee4dac1cf748aa8a5799e7c1654ef5929c..20bf5f78a362073e6068a2dd0bd7ddadcb8e32dd 100644 (file)
@@ -108,7 +108,8 @@ static int ati_create_gatt_pages(int nr_tables)
        int retval = 0;
        int i;
 
-       tables = kzalloc((nr_tables + 1) * sizeof(struct ati_page_map *),GFP_KERNEL);
+       tables = kcalloc(nr_tables + 1, sizeof(struct ati_page_map *),
+                        GFP_KERNEL);
        if (tables == NULL)
                return -ENOMEM;
 
index 2053f70ef66b2de7c93700daf081f41a26442eef..52ffe1706ce0512e472992b0897c82e5e7c155fe 100644 (file)
@@ -98,11 +98,15 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
                if (ureserve.seg_count >= 16384)
                        return -EINVAL;
 
-               usegment = kmalloc(sizeof(*usegment) * ureserve.seg_count, GFP_KERNEL);
+               usegment = kmalloc_array(ureserve.seg_count,
+                                        sizeof(*usegment),
+                                        GFP_KERNEL);
                if (!usegment)
                        return -ENOMEM;
 
-               ksegment = kmalloc(sizeof(*ksegment) * kreserve.seg_count, GFP_KERNEL);
+               ksegment = kmalloc_array(kreserve.seg_count,
+                                        sizeof(*ksegment),
+                                        GFP_KERNEL);
                if (!ksegment) {
                        kfree(usegment);
                        return -ENOMEM;
index fc8e1bc3347d10853e0bdbb47b55ec8f73e040c6..31c374b1b91b038827254824b48bb91b8b577d68 100644 (file)
@@ -93,7 +93,8 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge,
         * We'll work with an array of isoch_data's (one for each
         * device in dev_list) throughout this function.
         */
-       if ((master = kmalloc(ndevs * sizeof(*master), GFP_KERNEL)) == NULL) {
+       master = kmalloc_array(ndevs, sizeof(*master), GFP_KERNEL);
+       if (master == NULL) {
                ret = -ENOMEM;
                goto get_out;
        }
index 3051c73bc3838a0ccdbc0784d7a5bac76d356cd2..e7d5bdc02d93d75daa05be0aabf370d073325028 100644 (file)
@@ -280,9 +280,9 @@ static int agp_sgi_init(void)
        else
                return 0;
 
-       sgi_tioca_agp_bridges = kmalloc(tioca_gart_found *
-                                       sizeof(struct agp_bridge_data *),
-                                       GFP_KERNEL);
+       sgi_tioca_agp_bridges = kmalloc_array(tioca_gart_found,
+                                             sizeof(struct agp_bridge_data *),
+                                             GFP_KERNEL);
        if (!sgi_tioca_agp_bridges)
                return -ENOMEM;
 
index 4dbdd3bc9bb8855e6e557abaac0aefe5feb0eb5c..7729414100ffa5d33509f78c298dd7779186e01f 100644 (file)
@@ -96,7 +96,7 @@ static int serverworks_create_gatt_pages(int nr_tables)
        int retval = 0;
        int i;
 
-       tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *),
+       tables = kcalloc(nr_tables + 1, sizeof(struct serverworks_page_map *),
                         GFP_KERNEL);
        if (tables == NULL)
                return -ENOMEM;
index 79d8c84693a185264990d40185006f5eaec0f145..31fcd04304263a21161d2e7aae378a2daa789995 100644 (file)
@@ -402,7 +402,9 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
        if (table == NULL)
                return -ENOMEM;
 
-       uninorth_priv.pages_arr = kmalloc((1 << page_order) * sizeof(struct page*), GFP_KERNEL);
+       uninorth_priv.pages_arr = kmalloc_array(1 << page_order,
+                                               sizeof(struct page *),
+                                               GFP_KERNEL);
        if (uninorth_priv.pages_arr == NULL)
                goto enomem;
 
index 22f634eb09fd5c523ec8fa12975a62de73d36924..18e4650c233b1de514ee836dfc28021f35953a5b 100644 (file)
@@ -1757,7 +1757,8 @@ static unsigned short *ssif_address_list(void)
        list_for_each_entry(info, &ssif_infos, link)
                count++;
 
-       address_list = kzalloc(sizeof(*address_list) * (count + 1), GFP_KERNEL);
+       address_list = kcalloc(count + 1, sizeof(*address_list),
+                              GFP_KERNEL);
        if (!address_list)
                return NULL;
 
index 293167c6e2548864d281c105248cb58466bf0650..fd6eec8085b4eee46f2fa15870d2f6287a00f2d4 100644 (file)
@@ -321,7 +321,8 @@ static int __init raw_init(void)
                max_raw_minors = MAX_RAW_MINORS;
        }
 
-       raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
+       raw_devices = vzalloc(array_size(max_raw_minors,
+                                        sizeof(struct raw_device_data)));
        if (!raw_devices) {
                printk(KERN_ERR "Not enough memory for raw device structures\n");
                ret = -ENOMEM;
index 96c77c8e7f402818fc629d10e115bd882937a9d6..d31b090992163d12a4f7bda31be1464f6caf66e9 100644 (file)
@@ -980,7 +980,7 @@ static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip)
                goto out;
        }
 
-       chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands,
+       chip->cc_attrs_tbl = devm_kcalloc(&chip->dev, 4, nr_commands,
                                          GFP_KERNEL);
 
        rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY);
index 21085515814f23f09e6fbea4cb49d4d3d99d86c7..17084cfcf53ecdbcbf83f5efec201384da70aaa1 100644 (file)
@@ -433,8 +433,7 @@ static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size
         * Allocate buffer and the sg list. The sg list array is allocated
         * directly after the port_buffer struct.
         */
-       buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages,
-                     GFP_KERNEL);
+       buf = kmalloc(struct_size(buf, sg, pages), GFP_KERNEL);
        if (!buf)
                goto fail;
 
@@ -1892,13 +1891,14 @@ static int init_vqs(struct ports_device *portdev)
        nr_ports = portdev->max_nr_ports;
        nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;
 
-       vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL);
-       io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL);
-       io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL);
-       portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
-                                 GFP_KERNEL);
-       portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
-                                  GFP_KERNEL);
+       vqs = kmalloc_array(nr_queues, sizeof(struct virtqueue *), GFP_KERNEL);
+       io_callbacks = kmalloc_array(nr_queues, sizeof(vq_callback_t *),
+                                    GFP_KERNEL);
+       io_names = kmalloc_array(nr_queues, sizeof(char *), GFP_KERNEL);
+       portdev->in_vqs = kmalloc_array(nr_ports, sizeof(struct virtqueue *),
+                                       GFP_KERNEL);
+       portdev->out_vqs = kmalloc_array(nr_ports, sizeof(struct virtqueue *),
+                                        GFP_KERNEL);
        if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs ||
            !portdev->out_vqs) {
                err = -ENOMEM;
index 9e0b2f2b48e7421b3214f451f6d52c9f075592bf..7bef0666ae7e74646a59298eb4abddf1753e9e37 100644 (file)
@@ -734,7 +734,7 @@ static void bcm2835_pll_debug_init(struct clk_hw *hw,
        const struct bcm2835_pll_data *data = pll->data;
        struct debugfs_reg32 *regs;
 
-       regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
+       regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL);
        if (!regs)
                return;
 
@@ -865,7 +865,7 @@ static void bcm2835_pll_divider_debug_init(struct clk_hw *hw,
        const struct bcm2835_pll_divider_data *data = divider->data;
        struct debugfs_reg32 *regs;
 
-       regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
+       regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL);
        if (!regs)
                return;
 
index a24a6afb50b6bd63531d39f98e503df052ea78b0..9760b526ca31da90c4c288ac096cb0fee7d16cbf 100644 (file)
@@ -6,7 +6,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * Standard functionality for the common clock API.  See Documentation/clk.txt
+ * Standard functionality for the common clock API.  See Documentation/driver-api/clk.rst
  */
 
 #include <linux/clk.h>
@@ -2747,7 +2747,7 @@ static int __clk_core_init(struct clk_core *core)
                goto out;
        }
 
-       /* check that clk_ops are sane.  See Documentation/clk.txt */
+       /* check that clk_ops are sane.  See Documentation/driver-api/clk.rst */
        if (core->ops->set_rate &&
            !((core->ops->round_rate || core->ops->determine_rate) &&
              core->ops->recalc_rate)) {
index 542192376ebffd1abf0401f2b3d809d23696f703..502bcbb61b047a5331b56d7bdfafaeee2e3cb61b 100644 (file)
@@ -194,7 +194,7 @@ struct ingenic_cgu {
 
 /**
  * struct ingenic_clk - private data for a clock
- * @hw: see Documentation/clk.txt
+ * @hw: see Documentation/driver-api/clk.rst
  * @cgu: a pointer to the CGU data
  * @idx: the index of this clock in cgu->clock_info
  */
index d074f8e982d0851cae185375f7548e6cebeb74c6..a7a30d2eca418f6e15febe5cf47aac91d426ec32 100644 (file)
@@ -161,7 +161,7 @@ static void __init r8a7740_cpg_clocks_init(struct device_node *np)
        }
 
        cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
-       clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
+       clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
        if (cpg == NULL || clks == NULL) {
                /* We're leaking memory on purpose, there's no point in cleaning
                 * up as the system won't boot anyway.
index 27fbfafaf2cd035327ed50ea86479fae0f4a4c23..5adcca4656c33303e9630f6a3624b09b50242ddb 100644 (file)
@@ -138,7 +138,7 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np)
        }
 
        cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
-       clks = kzalloc(CPG_NUM_CLOCKS * sizeof(*clks), GFP_KERNEL);
+       clks = kcalloc(CPG_NUM_CLOCKS, sizeof(*clks), GFP_KERNEL);
        if (cpg == NULL || clks == NULL) {
                /* We're leaking memory on purpose, there's no point in cleaning
                 * up as the system won't boot anyway.
index ee32a022e6da9548bfd13e1b82b811332a9869ab..bccd62f2cb092fac27416764d4eba89d98e305ba 100644 (file)
@@ -417,7 +417,7 @@ static void __init rcar_gen2_cpg_clocks_init(struct device_node *np)
        }
 
        cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
-       clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
+       clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
        if (cpg == NULL || clks == NULL) {
                /* We're leaking memory on purpose, there's no point in cleaning
                 * up as the system won't boot anyway.
index 67dd712aa723c77c2ffab83c3913c78ac9abd439..ac2f86d626b694be3824c7465c7e7aae3897a9af 100644 (file)
@@ -97,7 +97,7 @@ static void __init rz_cpg_clocks_init(struct device_node *np)
                return;
 
        cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
-       clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
+       clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
        BUG_ON(!cpg || !clks);
 
        cpg->data.clks = clks;
index 14819d919df10d8871d8d6cb24700d06bbdb1671..a79d81985c4e0251a6049d5d09b89415d0354ba3 100644 (file)
@@ -874,7 +874,7 @@ static void __init st_of_create_quadfs_fsynths(
                return;
 
        clk_data->clk_num = QUADFS_MAX_CHAN;
-       clk_data->clks = kzalloc(QUADFS_MAX_CHAN * sizeof(struct clk *),
+       clk_data->clks = kcalloc(QUADFS_MAX_CHAN, sizeof(struct clk *),
                                 GFP_KERNEL);
 
        if (!clk_data->clks) {
index 25bda48a5d35b919f37eb74228a2710d78d4b0b5..7a7106dc80bf446c62038bdd006846662cd9ce8f 100644 (file)
@@ -738,7 +738,7 @@ static void __init clkgen_c32_pll_setup(struct device_node *np,
                return;
 
        clk_data->clk_num = num_odfs;
-       clk_data->clks = kzalloc(clk_data->clk_num * sizeof(struct clk *),
+       clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *),
                                 GFP_KERNEL);
 
        if (!clk_data->clks)
index fe0c3d169377272bccde5f8464429a9ea5ef43de..917fc27a33ddccc6f79349d8bf083e6ff9d461d4 100644 (file)
@@ -122,7 +122,7 @@ static void __init sunxi_usb_clk_setup(struct device_node *node,
        if (!clk_data)
                return;
 
-       clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL);
+       clk_data->clks = kcalloc(qty + 1, sizeof(struct clk *), GFP_KERNEL);
        if (!clk_data->clks) {
                kfree(clk_data);
                return;
index 593d76a114f991a0aa95289e89bb5f8bf6cc77ea..ffaf17f71860f98a198ebc33f31a4ccac6442931 100644 (file)
@@ -216,14 +216,15 @@ struct clk ** __init tegra_clk_init(void __iomem *regs, int num, int banks)
        if (WARN_ON(banks > ARRAY_SIZE(periph_regs)))
                return NULL;
 
-       periph_clk_enb_refcnt = kzalloc(32 * banks *
-                               sizeof(*periph_clk_enb_refcnt), GFP_KERNEL);
+       periph_clk_enb_refcnt = kcalloc(32 * banks,
+                                       sizeof(*periph_clk_enb_refcnt),
+                                       GFP_KERNEL);
        if (!periph_clk_enb_refcnt)
                return NULL;
 
        periph_banks = banks;
 
-       clks = kzalloc(num * sizeof(struct clk *), GFP_KERNEL);
+       clks = kcalloc(num, sizeof(struct clk *), GFP_KERNEL);
        if (!clks)
                kfree(periph_clk_enb_refcnt);
 
index d6036c788fab8fcbebb72bebbf9a6eaaccbda839..688e403333b914ef900a001c452da96110a40cd0 100644 (file)
@@ -501,8 +501,9 @@ static int ti_adpll_init_dco(struct ti_adpll_data *d)
        const char *postfix;
        int width, err;
 
-       d->outputs.clks = devm_kzalloc(d->dev, sizeof(struct clk *) *
+       d->outputs.clks = devm_kcalloc(d->dev,
                                       MAX_ADPLL_OUTPUTS,
+                                      sizeof(struct clk *),
                                       GFP_KERNEL);
        if (!d->outputs.clks)
                return -ENOMEM;
@@ -915,8 +916,9 @@ static int ti_adpll_probe(struct platform_device *pdev)
        if (err)
                return err;
 
-       d->clocks = devm_kzalloc(d->dev, sizeof(struct ti_adpll_clock) *
+       d->clocks = devm_kcalloc(d->dev,
                                 TI_ADPLL_NR_CLOCKS,
+                                sizeof(struct ti_adpll_clock),
                                 GFP_KERNEL);
        if (!d->clocks)
                return -ENOMEM;
index 9498e9363b573c4675738b85f33621110beb03de..61c126a5d26ad88aacc4491c73f85248fe2d2f4f 100644 (file)
@@ -206,7 +206,7 @@ static void __init of_dra7_apll_setup(struct device_node *node)
                goto cleanup;
        }
 
-       parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
+       parent_names = kcalloc(init->num_parents, sizeof(char *), GFP_KERNEL);
        if (!parent_names)
                goto cleanup;
 
index aaa277dd6d991e9de2cb7bc7f9087d7d131a9637..ccfb4d9a152aea55c3e414dc26d2ddd3ce792ee4 100644 (file)
@@ -366,7 +366,7 @@ int ti_clk_parse_divider_data(int *div_table, int num_dividers, int max_div,
 
        num_dividers = i;
 
-       tmp = kzalloc(sizeof(*tmp) * (valid_div + 1), GFP_KERNEL);
+       tmp = kcalloc(valid_div + 1, sizeof(*tmp), GFP_KERNEL);
        if (!tmp)
                return -ENOMEM;
 
@@ -496,7 +496,7 @@ __init ti_clk_get_div_table(struct device_node *node)
                return ERR_PTR(-EINVAL);
        }
 
-       table = kzalloc(sizeof(*table) * (valid_div + 1), GFP_KERNEL);
+       table = kcalloc(valid_div + 1, sizeof(*table), GFP_KERNEL);
 
        if (!table)
                return ERR_PTR(-ENOMEM);
index 7d33ca9042cb816abeff4939ea0816a6ba6f6d17..dc86d07d09211e35a6b9bf9338381ac2f4ef9183 100644 (file)
@@ -309,7 +309,7 @@ static void __init of_ti_dpll_setup(struct device_node *node,
                goto cleanup;
        }
 
-       parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
+       parent_names = kcalloc(init->num_parents, sizeof(char *), GFP_KERNEL);
        if (!parent_names)
                goto cleanup;
 
index 70b3cf8e23d01bd80caf92859171df39b3e171ff..bbbf37c471a3919f7fb177f0439cd15d020d8d08 100644 (file)
@@ -1000,7 +1000,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 
        /* Allocate and setup the channels. */
        cmt->num_channels = hweight8(cmt->hw_channels);
-       cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels),
+       cmt->channels = kcalloc(cmt->num_channels, sizeof(*cmt->channels),
                                GFP_KERNEL);
        if (cmt->channels == NULL) {
                ret = -ENOMEM;
index 53aa7e92a7d77b7efc052466e8904efc110cc2eb..6812e099b6a3851b27f619ee3476bf31129f978b 100644 (file)
@@ -418,7 +418,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
        /* Allocate and setup the channels. */
        mtu->num_channels = 3;
 
-       mtu->channels = kzalloc(sizeof(*mtu->channels) * mtu->num_channels,
+       mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels),
                                GFP_KERNEL);
        if (mtu->channels == NULL) {
                ret = -ENOMEM;
index 31d881621e41865ea01dc19728d30256045e55f1..c74a6c543ca2667d239c3bd7a1a0944d936f6cc1 100644 (file)
@@ -569,7 +569,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
        }
 
        /* Allocate and setup the channels. */
-       tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels,
+       tmu->channels = kcalloc(tmu->num_channels, sizeof(*tmu->channels),
                                GFP_KERNEL);
        if (tmu->channels == NULL) {
                ret = -ENOMEM;
index c7ce928fbf1f55e108e150235afd18b1ee98c314..52f5f1a2040c38002885c1e804be3d8721bcac6f 100644 (file)
@@ -125,7 +125,7 @@ config ARM_OMAP2PLUS_CPUFREQ
        default ARCH_OMAP2PLUS
 
 config ARM_QCOM_CPUFREQ_KRYO
-       bool "Qualcomm Kryo based CPUFreq"
+       tristate "Qualcomm Kryo based CPUFreq"
        depends on ARM64
        depends on QCOM_QFPROM
        depends on QCOM_SMEM
index 9449657d72f0243b78e899efa25f716a12b9a2db..b61f4ec43e0685f6b1ea28035cff16a19a8247d9 100644 (file)
@@ -465,8 +465,8 @@ static int acpi_cpufreq_target(struct cpufreq_policy *policy,
        return result;
 }
 
-unsigned int acpi_cpufreq_fast_switch(struct cpufreq_policy *policy,
-                                     unsigned int target_freq)
+static unsigned int acpi_cpufreq_fast_switch(struct cpufreq_policy *policy,
+                                            unsigned int target_freq)
 {
        struct acpi_cpufreq_data *data = policy->driver_data;
        struct acpi_processor_performance *perf;
@@ -759,8 +759,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
                goto err_unreg;
        }
 
-       freq_table = kzalloc(sizeof(*freq_table) *
-                   (perf->state_count+1), GFP_KERNEL);
+       freq_table = kcalloc(perf->state_count + 1, sizeof(*freq_table),
+                            GFP_KERNEL);
        if (!freq_table) {
                result = -ENOMEM;
                goto err_unreg;
index 1d7ef5fc197728b6cad6844f3f6eda8de45dcf05..cf62a1f64dd71d457ae45e40e7ec84d1ec35e23a 100644 (file)
@@ -280,7 +280,7 @@ static int merge_cluster_tables(void)
        for (i = 0; i < MAX_CLUSTERS; i++)
                count += get_table_count(freq_table[i]);
 
-       table = kzalloc(sizeof(*table) * count, GFP_KERNEL);
+       table = kcalloc(count, sizeof(*table), GFP_KERNEL);
        if (!table)
                return -ENOMEM;
 
index 1653151b77df31b9e78c039a9bf8f9df5dd89f0d..56a4ebbf00e02479b17cb3eb4efc1d2c830adefd 100644 (file)
@@ -71,7 +71,7 @@ bmips_cpufreq_get_freq_table(const struct cpufreq_policy *policy)
 
        cpu_freq = htp_freq_to_cpu_freq(priv->clk_mult);
 
-       table = kmalloc((priv->max_freqs + 1) * sizeof(*table), GFP_KERNEL);
+       table = kmalloc_array(priv->max_freqs + 1, sizeof(*table), GFP_KERNEL);
        if (!table)
                return ERR_PTR(-ENOMEM);
 
index b07559b9ed99a6e256ba5afce20b5e156304ade7..e6f9cbe5835f96883599d86006c54fd805f4e7e7 100644 (file)
@@ -410,7 +410,7 @@ brcm_avs_get_freq_table(struct device *dev, struct private_data *priv)
        if (ret)
                return ERR_PTR(ret);
 
-       table = devm_kzalloc(dev, (AVS_PSTATE_MAX + 1) * sizeof(*table),
+       table = devm_kcalloc(dev, AVS_PSTATE_MAX + 1, sizeof(*table),
                             GFP_KERNEL);
        if (!table)
                return ERR_PTR(-ENOMEM);
index 3464580ac3ca4d4284c704c81676a3fad9da93fb..a9d3eec327959d59cc6089716fe3df7c59f384bf 100644 (file)
@@ -313,7 +313,8 @@ static int __init cppc_cpufreq_init(void)
        if (acpi_disabled)
                return -ENODEV;
 
-       all_cpu_data = kzalloc(sizeof(void *) * num_possible_cpus(), GFP_KERNEL);
+       all_cpu_data = kcalloc(num_possible_cpus(), sizeof(void *),
+                              GFP_KERNEL);
        if (!all_cpu_data)
                return -ENOMEM;
 
index 871bf9cf55cf0dc95ee9952774c406280a7cbcee..1d50e97d49f192cd8bf1c5eb0ce569e9641cf43e 100644 (file)
@@ -165,7 +165,7 @@ unsigned int dbs_update(struct cpufreq_policy *policy)
                         * calls, so the previous load value can be used then.
                         */
                        load = j_cdbs->prev_load;
-               } else if (unlikely(time_elapsed > 2 * sampling_rate &&
+               } else if (unlikely((int)idle_time > 2 * sampling_rate &&
                                    j_cdbs->prev_load)) {
                        /*
                         * If the CPU had gone completely idle and a task has
@@ -185,10 +185,8 @@ unsigned int dbs_update(struct cpufreq_policy *policy)
                         * clear prev_load to guarantee that the load will be
                         * computed again next time.
                         *
-                        * Detecting this situation is easy: the governor's
-                        * utilization update handler would not have run during
-                        * CPU-idle periods.  Hence, an unusually large
-                        * 'time_elapsed' (as compared to the sampling rate)
+                        * Detecting this situation is easy: an unusually large
+                        * 'idle_time' (as compared to the sampling rate)
                         * indicates this scenario.
                         */
                        load = j_cdbs->prev_load;
@@ -217,8 +215,8 @@ unsigned int dbs_update(struct cpufreq_policy *policy)
                        j_cdbs->prev_load = load;
                }
 
-               if (time_elapsed > 2 * sampling_rate) {
-                       unsigned int periods = time_elapsed / sampling_rate;
+               if (unlikely((int)idle_time > 2 * sampling_rate)) {
+                       unsigned int periods = idle_time / sampling_rate;
 
                        if (periods < idle_periods)
                                idle_periods = periods;
index 7974a2fdb760391c3aa3aa784bf77e254d1b99e9..dd5440d3372d21528f0df5715fcc03e656863b1f 100644 (file)
@@ -241,8 +241,8 @@ acpi_cpufreq_cpu_init (
        }
 
        /* alloc freq_table */
-       freq_table = kzalloc(sizeof(*freq_table) *
-                                  (data->acpi_data.state_count + 1),
+       freq_table = kcalloc(data->acpi_data.state_count + 1,
+                                  sizeof(*freq_table),
                                   GFP_KERNEL);
        if (!freq_table) {
                result = -ENOMEM;
index 83cf631fc9bc6fe9d9ff3a9ebea418f87a40d139..8b3c2a79ad6cd113e38982f6cb1700a282ebff16 100644 (file)
@@ -266,6 +266,8 @@ static void imx6q_opp_check_speed_grading(struct device *dev)
 }
 
 #define OCOTP_CFG3_6UL_SPEED_696MHZ    0x2
+#define OCOTP_CFG3_6ULL_SPEED_792MHZ   0x2
+#define OCOTP_CFG3_6ULL_SPEED_900MHZ   0x3
 
 static void imx6ul_opp_check_speed_grading(struct device *dev)
 {
@@ -287,16 +289,30 @@ static void imx6ul_opp_check_speed_grading(struct device *dev)
         * Speed GRADING[1:0] defines the max speed of ARM:
         * 2b'00: Reserved;
         * 2b'01: 528000000Hz;
-        * 2b'10: 696000000Hz;
-        * 2b'11: Reserved;
+        * 2b'10: 696000000Hz on i.MX6UL, 792000000Hz on i.MX6ULL;
+        * 2b'11: 900000000Hz on i.MX6ULL only;
         * We need to set the max speed of ARM according to fuse map.
         */
        val = readl_relaxed(base + OCOTP_CFG3);
        val >>= OCOTP_CFG3_SPEED_SHIFT;
        val &= 0x3;
-       if (val != OCOTP_CFG3_6UL_SPEED_696MHZ)
-               if (dev_pm_opp_disable(dev, 696000000))
-                       dev_warn(dev, "failed to disable 696MHz OPP\n");
+
+       if (of_machine_is_compatible("fsl,imx6ul")) {
+               if (val != OCOTP_CFG3_6UL_SPEED_696MHZ)
+                       if (dev_pm_opp_disable(dev, 696000000))
+                               dev_warn(dev, "failed to disable 696MHz OPP\n");
+       }
+
+       if (of_machine_is_compatible("fsl,imx6ull")) {
+               if (val != OCOTP_CFG3_6ULL_SPEED_792MHZ)
+                       if (dev_pm_opp_disable(dev, 792000000))
+                               dev_warn(dev, "failed to disable 792MHz OPP\n");
+
+               if (val != OCOTP_CFG3_6ULL_SPEED_900MHZ)
+                       if (dev_pm_opp_disable(dev, 900000000))
+                               dev_warn(dev, "failed to disable 900MHz OPP\n");
+       }
+
        iounmap(base);
 put_node:
        of_node_put(np);
@@ -356,7 +372,8 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
                goto put_reg;
        }
 
-       if (of_machine_is_compatible("fsl,imx6ul"))
+       if (of_machine_is_compatible("fsl,imx6ul") ||
+           of_machine_is_compatible("fsl,imx6ull"))
                imx6ul_opp_check_speed_grading(cpu_dev);
        else
                imx6q_opp_check_speed_grading(cpu_dev);
@@ -377,7 +394,8 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
        }
 
        /* Make imx6_soc_volt array's size same as arm opp number */
-       imx6_soc_volt = devm_kzalloc(cpu_dev, sizeof(*imx6_soc_volt) * num, GFP_KERNEL);
+       imx6_soc_volt = devm_kcalloc(cpu_dev, num, sizeof(*imx6_soc_volt),
+                                    GFP_KERNEL);
        if (imx6_soc_volt == NULL) {
                ret = -ENOMEM;
                goto free_freq_table;
index 08960a55eb27a43e3b99bc2c7d70518166d84a22..1de5ec8d5ea3e9995e3ffd413f728df078c25f8f 100644 (file)
@@ -221,6 +221,11 @@ struct global_params {
  *                     preference/bias
  * @epp_saved:         Saved EPP/EPB during system suspend or CPU offline
  *                     operation
+ * @hwp_req_cached:    Cached value of the last HWP Request MSR
+ * @hwp_cap_cached:    Cached value of the last HWP Capabilities MSR
+ * @last_io_update:    Last time when IO wake flag was set
+ * @sched_flags:       Store scheduler flags for possible cross CPU update
+ * @hwp_boost_min:     Last HWP boosted min performance
  *
  * This structure stores per CPU instance data for all CPUs.
  */
@@ -253,6 +258,11 @@ struct cpudata {
        s16 epp_policy;
        s16 epp_default;
        s16 epp_saved;
+       u64 hwp_req_cached;
+       u64 hwp_cap_cached;
+       u64 last_io_update;
+       unsigned int sched_flags;
+       u32 hwp_boost_min;
 };
 
 static struct cpudata **all_cpu_data;
@@ -285,6 +295,7 @@ static struct pstate_funcs pstate_funcs __read_mostly;
 
 static int hwp_active __read_mostly;
 static bool per_cpu_limits __read_mostly;
+static bool hwp_boost __read_mostly;
 
 static struct cpufreq_driver *intel_pstate_driver __read_mostly;
 
@@ -689,6 +700,7 @@ static void intel_pstate_get_hwp_max(unsigned int cpu, int *phy_max,
        u64 cap;
 
        rdmsrl_on_cpu(cpu, MSR_HWP_CAPABILITIES, &cap);
+       WRITE_ONCE(all_cpu_data[cpu]->hwp_cap_cached, cap);
        if (global.no_turbo)
                *current_max = HWP_GUARANTEED_PERF(cap);
        else
@@ -763,6 +775,7 @@ static void intel_pstate_hwp_set(unsigned int cpu)
                intel_pstate_set_epb(cpu, epp);
        }
 skip_epp:
+       WRITE_ONCE(cpu_data->hwp_req_cached, value);
        wrmsrl_on_cpu(cpu, MSR_HWP_REQUEST, value);
 }
 
@@ -1020,6 +1033,30 @@ static ssize_t store_min_perf_pct(struct kobject *a, struct attribute *b,
        return count;
 }
 
+static ssize_t show_hwp_dynamic_boost(struct kobject *kobj,
+                               struct attribute *attr, char *buf)
+{
+       return sprintf(buf, "%u\n", hwp_boost);
+}
+
+static ssize_t store_hwp_dynamic_boost(struct kobject *a, struct attribute *b,
+                                      const char *buf, size_t count)
+{
+       unsigned int input;
+       int ret;
+
+       ret = kstrtouint(buf, 10, &input);
+       if (ret)
+               return ret;
+
+       mutex_lock(&intel_pstate_driver_lock);
+       hwp_boost = !!input;
+       intel_pstate_update_policies();
+       mutex_unlock(&intel_pstate_driver_lock);
+
+       return count;
+}
+
 show_one(max_perf_pct, max_perf_pct);
 show_one(min_perf_pct, min_perf_pct);
 
@@ -1029,6 +1066,7 @@ define_one_global_rw(max_perf_pct);
 define_one_global_rw(min_perf_pct);
 define_one_global_ro(turbo_pct);
 define_one_global_ro(num_pstates);
+define_one_global_rw(hwp_dynamic_boost);
 
 static struct attribute *intel_pstate_attributes[] = {
        &status.attr,
@@ -1069,6 +1107,11 @@ static void __init intel_pstate_sysfs_expose_params(void)
        rc = sysfs_create_file(intel_pstate_kobject, &min_perf_pct.attr);
        WARN_ON(rc);
 
+       if (hwp_active) {
+               rc = sysfs_create_file(intel_pstate_kobject,
+                                      &hwp_dynamic_boost.attr);
+               WARN_ON(rc);
+       }
 }
 /************************** sysfs end ************************/
 
@@ -1381,6 +1424,116 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu)
        intel_pstate_set_min_pstate(cpu);
 }
 
+/*
+ * Long hold time will keep high perf limits for long time,
+ * which negatively impacts perf/watt for some workloads,
+ * like specpower. 3ms is based on experiements on some
+ * workoads.
+ */
+static int hwp_boost_hold_time_ns = 3 * NSEC_PER_MSEC;
+
+static inline void intel_pstate_hwp_boost_up(struct cpudata *cpu)
+{
+       u64 hwp_req = READ_ONCE(cpu->hwp_req_cached);
+       u32 max_limit = (hwp_req & 0xff00) >> 8;
+       u32 min_limit = (hwp_req & 0xff);
+       u32 boost_level1;
+
+       /*
+        * Cases to consider (User changes via sysfs or boot time):
+        * If, P0 (Turbo max) = P1 (Guaranteed max) = min:
+        *      No boost, return.
+        * If, P0 (Turbo max) > P1 (Guaranteed max) = min:
+        *     Should result in one level boost only for P0.
+        * If, P0 (Turbo max) = P1 (Guaranteed max) > min:
+        *     Should result in two level boost:
+        *         (min + p1)/2 and P1.
+        * If, P0 (Turbo max) > P1 (Guaranteed max) > min:
+        *     Should result in three level boost:
+        *        (min + p1)/2, P1 and P0.
+        */
+
+       /* If max and min are equal or already at max, nothing to boost */
+       if (max_limit == min_limit || cpu->hwp_boost_min >= max_limit)
+               return;
+
+       if (!cpu->hwp_boost_min)
+               cpu->hwp_boost_min = min_limit;
+
+       /* level at half way mark between min and guranteed */
+       boost_level1 = (HWP_GUARANTEED_PERF(cpu->hwp_cap_cached) + min_limit) >> 1;
+
+       if (cpu->hwp_boost_min < boost_level1)
+               cpu->hwp_boost_min = boost_level1;
+       else if (cpu->hwp_boost_min < HWP_GUARANTEED_PERF(cpu->hwp_cap_cached))
+               cpu->hwp_boost_min = HWP_GUARANTEED_PERF(cpu->hwp_cap_cached);
+       else if (cpu->hwp_boost_min == HWP_GUARANTEED_PERF(cpu->hwp_cap_cached) &&
+                max_limit != HWP_GUARANTEED_PERF(cpu->hwp_cap_cached))
+               cpu->hwp_boost_min = max_limit;
+       else
+               return;
+
+       hwp_req = (hwp_req & ~GENMASK_ULL(7, 0)) | cpu->hwp_boost_min;
+       wrmsrl(MSR_HWP_REQUEST, hwp_req);
+       cpu->last_update = cpu->sample.time;
+}
+
+static inline void intel_pstate_hwp_boost_down(struct cpudata *cpu)
+{
+       if (cpu->hwp_boost_min) {
+               bool expired;
+
+               /* Check if we are idle for hold time to boost down */
+               expired = time_after64(cpu->sample.time, cpu->last_update +
+                                      hwp_boost_hold_time_ns);
+               if (expired) {
+                       wrmsrl(MSR_HWP_REQUEST, cpu->hwp_req_cached);
+                       cpu->hwp_boost_min = 0;
+               }
+       }
+       cpu->last_update = cpu->sample.time;
+}
+
+static inline void intel_pstate_update_util_hwp_local(struct cpudata *cpu,
+                                                     u64 time)
+{
+       cpu->sample.time = time;
+
+       if (cpu->sched_flags & SCHED_CPUFREQ_IOWAIT) {
+               bool do_io = false;
+
+               cpu->sched_flags = 0;
+               /*
+                * Set iowait_boost flag and update time. Since IO WAIT flag
+                * is set all the time, we can't just conclude that there is
+                * some IO bound activity is scheduled on this CPU with just
+                * one occurrence. If we receive at least two in two
+                * consecutive ticks, then we treat as boost candidate.
+                */
+               if (time_before64(time, cpu->last_io_update + 2 * TICK_NSEC))
+                       do_io = true;
+
+               cpu->last_io_update = time;
+
+               if (do_io)
+                       intel_pstate_hwp_boost_up(cpu);
+
+       } else {
+               intel_pstate_hwp_boost_down(cpu);
+       }
+}
+
+static inline void intel_pstate_update_util_hwp(struct update_util_data *data,
+                                               u64 time, unsigned int flags)
+{
+       struct cpudata *cpu = container_of(data, struct cpudata, update_util);
+
+       cpu->sched_flags |= flags;
+
+       if (smp_processor_id() == cpu->cpu)
+               intel_pstate_update_util_hwp_local(cpu, time);
+}
+
 static inline void intel_pstate_calc_avg_perf(struct cpudata *cpu)
 {
        struct sample *sample = &cpu->sample;
@@ -1641,6 +1794,12 @@ static const struct x86_cpu_id intel_pstate_cpu_ee_disable_ids[] = {
        {}
 };
 
+static const struct x86_cpu_id intel_pstate_hwp_boost_ids[] = {
+       ICPU(INTEL_FAM6_SKYLAKE_X, core_funcs),
+       ICPU(INTEL_FAM6_SKYLAKE_DESKTOP, core_funcs),
+       {}
+};
+
 static int intel_pstate_init_cpu(unsigned int cpunum)
 {
        struct cpudata *cpu;
@@ -1671,6 +1830,10 @@ static int intel_pstate_init_cpu(unsigned int cpunum)
                        intel_pstate_disable_ee(cpunum);
 
                intel_pstate_hwp_enable(cpu);
+
+               id = x86_match_cpu(intel_pstate_hwp_boost_ids);
+               if (id)
+                       hwp_boost = true;
        }
 
        intel_pstate_get_cpu_pstates(cpu);
@@ -1684,7 +1847,7 @@ static void intel_pstate_set_update_util_hook(unsigned int cpu_num)
 {
        struct cpudata *cpu = all_cpu_data[cpu_num];
 
-       if (hwp_active)
+       if (hwp_active && !hwp_boost)
                return;
 
        if (cpu->update_util_set)
@@ -1693,7 +1856,9 @@ static void intel_pstate_set_update_util_hook(unsigned int cpu_num)
        /* Prevent intel_pstate_update_util() from using stale data. */
        cpu->sample.time = 0;
        cpufreq_add_update_util_hook(cpu_num, &cpu->update_util,
-                                    intel_pstate_update_util);
+                                    (hwp_active ?
+                                     intel_pstate_update_util_hwp :
+                                     intel_pstate_update_util));
        cpu->update_util_set = true;
 }
 
@@ -1805,8 +1970,16 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy)
                intel_pstate_set_update_util_hook(policy->cpu);
        }
 
-       if (hwp_active)
+       if (hwp_active) {
+               /*
+                * When hwp_boost was active before and dynamically it
+                * was turned off, in that case we need to clear the
+                * update util hook.
+                */
+               if (!hwp_boost)
+                       intel_pstate_clear_update_util_hook(policy->cpu);
                intel_pstate_hwp_set(policy->cpu);
+       }
 
        mutex_unlock(&intel_pstate_limits_lock);
 
@@ -2339,7 +2512,7 @@ static int __init intel_pstate_init(void)
 
        pr_info("Intel P-state driver initializing\n");
 
-       all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus());
+       all_cpu_data = vzalloc(array_size(sizeof(void *), num_possible_cpus()));
        if (!all_cpu_data)
                return -ENOMEM;
 
index 61a4c5b0821971d0dfab329d2a56ed541a7fc551..279bd9e9fa95f6a8fabae628c3829f6f4746f29c 100644 (file)
@@ -474,8 +474,8 @@ static int longhaul_get_ranges(void)
                return -EINVAL;
        }
 
-       longhaul_table = kzalloc((numscales + 1) * sizeof(*longhaul_table),
-                       GFP_KERNEL);
+       longhaul_table = kcalloc(numscales + 1, sizeof(*longhaul_table),
+                                GFP_KERNEL);
        if (!longhaul_table)
                return -ENOMEM;
 
index 7acc7fa4536dbb58c3b7588b28a1cc9d648da103..9daa2cc318bbfadfa23d8493304d0dd170235166 100644 (file)
@@ -93,7 +93,7 @@ static int setup_freqs_table(struct cpufreq_policy *policy,
        struct cpufreq_frequency_table *table;
        int i;
 
-       table = kzalloc((num + 1) * sizeof(*table), GFP_KERNEL);
+       table = kcalloc(num + 1, sizeof(*table), GFP_KERNEL);
        if (table == NULL)
                return -ENOMEM;
 
index 909bd6e2763933587da7fea5c918e586a76dc807..3b291a2b0cb3414ab0178adde205203d57c2b2b6 100644 (file)
@@ -562,7 +562,7 @@ static int s3c_cpufreq_build_freq(void)
        size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0);
        size++;
 
-       ftab = kzalloc(sizeof(*ftab) * size, GFP_KERNEL);
+       ftab = kcalloc(size, sizeof(*ftab), GFP_KERNEL);
        if (!ftab)
                return -ENOMEM;
 
index b4dbc77459b6b58fba1b197609337eb85b36a31a..50b1551ba8942d43d0a3f28824c83d0e0b837b26 100644 (file)
@@ -117,7 +117,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
                return -ENODEV;
        }
 
-       ret = handle->perf_ops->add_opps_to_device(handle, cpu_dev);
+       ret = handle->perf_ops->device_opps_add(handle, cpu_dev);
        if (ret) {
                dev_warn(cpu_dev, "failed to add opps to the device\n");
                return ret;
@@ -164,7 +164,7 @@ static int scmi_cpufreq_init(struct cpufreq_policy *policy)
        /* SCMI allows DVFS request for any domain from any CPU */
        policy->dvfs_possible_from_any_cpu = true;
 
-       latency = handle->perf_ops->get_transition_latency(handle, cpu_dev);
+       latency = handle->perf_ops->transition_latency_get(handle, cpu_dev);
        if (!latency)
                latency = CPUFREQ_ETERNAL;
 
index 9767afe05da21780017ff19f05869bf5b7423e7c..978770432b13545030c7396da590082c04ac713d 100644 (file)
@@ -95,8 +95,8 @@ static int __init sfi_cpufreq_init(void)
        if (ret)
                return ret;
 
-       freq_table = kzalloc(sizeof(*freq_table) *
-                       (num_freq_table_entries + 1), GFP_KERNEL);
+       freq_table = kcalloc(num_freq_table_entries + 1, sizeof(*freq_table),
+                            GFP_KERNEL);
        if (!freq_table) {
                ret = -ENOMEM;
                goto err_free_array;
index 195f27f9c1cbe45b623089fa2a43612fb0034ee6..4074e261552238ccbcdad859944f85a3effac1be 100644 (file)
@@ -195,7 +195,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev)
        cnt = prop->length / sizeof(u32);
        val = prop->value;
 
-       freq_tbl = kzalloc(sizeof(*freq_tbl) * (cnt + 1), GFP_KERNEL);
+       freq_tbl = kcalloc(cnt + 1, sizeof(*freq_tbl), GFP_KERNEL);
        if (!freq_tbl) {
                ret = -ENOMEM;
                goto out_put_node;
index 6ba709b6f0950ee3665f718448dbf97710eb039d..3f0e2a14895a03dc0c4bc1d01c032d0f50a4b4ae 100644 (file)
@@ -217,7 +217,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
        if (!match)
                return -ENODEV;
 
-       opp_data = kzalloc(sizeof(*opp_data), GFP_KERNEL);
+       opp_data = devm_kzalloc(&pdev->dev, sizeof(*opp_data), GFP_KERNEL);
        if (!opp_data)
                return -ENOMEM;
 
@@ -226,8 +226,7 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
        opp_data->cpu_dev = get_cpu_device(0);
        if (!opp_data->cpu_dev) {
                pr_err("%s: Failed to get device for CPU0\n", __func__);
-               ret = ENODEV;
-               goto free_opp_data;
+               return -ENODEV;
        }
 
        opp_data->opp_node = dev_pm_opp_of_get_opp_desc_node(opp_data->cpu_dev);
@@ -285,8 +284,6 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
 
 fail_put_node:
        of_node_put(opp_data->opp_node);
-free_opp_data:
-       kfree(opp_data);
 
        return ret;
 }
index 9cb234c72549faa902b1aa94a7c9446be492aac8..05981ccd9901a90ec5e216e2ce01a1ba41e0a51e 100644 (file)
@@ -141,11 +141,11 @@ static void crypto4xx_hw_init(struct crypto4xx_device *dev)
 
 int crypto4xx_alloc_sa(struct crypto4xx_ctx *ctx, u32 size)
 {
-       ctx->sa_in = kzalloc(size * 4, GFP_ATOMIC);
+       ctx->sa_in = kcalloc(size, 4, GFP_ATOMIC);
        if (ctx->sa_in == NULL)
                return -ENOMEM;
 
-       ctx->sa_out = kzalloc(size * 4, GFP_ATOMIC);
+       ctx->sa_out = kcalloc(size, 4, GFP_ATOMIC);
        if (ctx->sa_out == NULL) {
                kfree(ctx->sa_in);
                ctx->sa_in = NULL;
@@ -180,8 +180,8 @@ static u32 crypto4xx_build_pdr(struct crypto4xx_device *dev)
        if (!dev->pdr)
                return -ENOMEM;
 
-       dev->pdr_uinfo = kzalloc(sizeof(struct pd_uinfo) * PPC4XX_NUM_PD,
-                               GFP_KERNEL);
+       dev->pdr_uinfo = kcalloc(PPC4XX_NUM_PD, sizeof(struct pd_uinfo),
+                                GFP_KERNEL);
        if (!dev->pdr_uinfo) {
                dma_free_coherent(dev->core_dev->device,
                                  sizeof(struct ce_pd) * PPC4XX_NUM_PD,
index dbead5f45df31ec3c6e0b94667fc60993186ec83..ee0d70ba25d5574c0b073bb28d5a69c250e3ccbb 100644 (file)
@@ -254,7 +254,7 @@ static int nitrox_enable_msix(struct nitrox_device *ndev)
         * Entry 192: NPS_CORE_INT_ACTIVE
         */
        nr_entries = (ndev->nr_queues * NR_RING_VECTORS) + 1;
-       entries = kzalloc_node(nr_entries * sizeof(struct msix_entry),
+       entries = kcalloc_node(nr_entries, sizeof(struct msix_entry),
                               GFP_KERNEL, ndev->node);
        if (!entries)
                return -ENOMEM;
index 51fc6821cbbf4c1dd01a9e93c870923d539a64bf..00c7aab8e7d0f5861e778dc4d26affe5c1234603 100644 (file)
@@ -240,7 +240,7 @@ static int tls_copy_ivs(struct sock *sk, struct sk_buff *skb)
        }
 
        /* generate the  IVs */
-       ivs = kmalloc(number_of_ivs * CIPHER_BLOCK_SIZE, GFP_ATOMIC);
+       ivs = kmalloc_array(CIPHER_BLOCK_SIZE, number_of_ivs, GFP_ATOMIC);
        if (!ivs)
                return -ENOMEM;
        get_random_bytes(ivs, number_of_ivs * CIPHER_BLOCK_SIZE);
index d138d6b8fec5946333d50a7d73fc58020adad2ec..c77b0e1655a8357f100bc820dde88afdb82570a4 100644 (file)
@@ -922,7 +922,7 @@ int safexcel_hmac_setkey(const char *alg, const u8 *key, unsigned int keylen,
        crypto_ahash_clear_flags(tfm, ~0);
        blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
 
-       ipad = kzalloc(2 * blocksize, GFP_KERNEL);
+       ipad = kcalloc(2, blocksize, GFP_KERNEL);
        if (!ipad) {
                ret = -ENOMEM;
                goto free_request;
index f81fa4a3e66bdcea4b64419f3f2586fbc1d70d68..a4aa6813de4b8b2e67e32a63c3cf519332e74bd5 100644 (file)
@@ -471,7 +471,7 @@ static int mv_cesa_probe(struct platform_device *pdev)
                sram_size = CESA_SA_MIN_SRAM_SIZE;
 
        cesa->sram_size = sram_size;
-       cesa->engines = devm_kzalloc(dev, caps->nengines * sizeof(*engines),
+       cesa->engines = devm_kcalloc(dev, caps->nengines, sizeof(*engines),
                                     GFP_KERNEL);
        if (!cesa->engines)
                return -ENOMEM;
index e61b08566093277b01987e21181ffc39fb3ed20d..e34d80b6b7e58b38fc1a8a036809cec35f4d6153 100644 (file)
@@ -1198,7 +1198,7 @@ static int mv_cesa_ahmac_setkey(const char *hash_alg_name,
 
        blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
 
-       ipad = kzalloc(2 * blocksize, GFP_KERNEL);
+       ipad = kcalloc(2, blocksize, GFP_KERNEL);
        if (!ipad) {
                ret = -ENOMEM;
                goto free_req;
index 80e9c842aad463d0ece3b48862c202564488f8ec..ab6235b7ff227f59ea7401deb9e62a16d7c64823 100644 (file)
@@ -1919,12 +1919,12 @@ static int grab_global_resources(void)
                goto out_hvapi_release;
 
        err = -ENOMEM;
-       cpu_to_cwq = kzalloc(sizeof(struct spu_queue *) * NR_CPUS,
+       cpu_to_cwq = kcalloc(NR_CPUS, sizeof(struct spu_queue *),
                             GFP_KERNEL);
        if (!cpu_to_cwq)
                goto out_queue_cache_destroy;
 
-       cpu_to_mau = kzalloc(sizeof(struct spu_queue *) * NR_CPUS,
+       cpu_to_mau = kcalloc(NR_CPUS, sizeof(struct spu_queue *),
                             GFP_KERNEL);
        if (!cpu_to_mau)
                goto out_free_cwq_table;
index 06d49017a52b7ddeb8737833293e2295b84637df..cd1cdf5305bc961ebd8169004ecf304c15000c31 100644 (file)
@@ -238,7 +238,7 @@ static int adf_isr_alloc_msix_entry_table(struct adf_accel_dev *accel_dev)
        if (!accel_dev->pf.vf_info)
                msix_num_entries += hw_data->num_banks;
 
-       entries = kzalloc_node(msix_num_entries * sizeof(*entries),
+       entries = kcalloc_node(msix_num_entries, sizeof(*entries),
                               GFP_KERNEL, dev_to_node(&GET_DEV(accel_dev)));
        if (!entries)
                return -ENOMEM;
index 98d22c2096e375bed1200885a9daf5bb1f10d40d..6bd8f6a2a24fa390acf98f5815fe4e5d86e073a5 100644 (file)
@@ -1162,8 +1162,9 @@ static int qat_uclo_map_suof(struct icp_qat_fw_loader_handle *handle,
        suof_handle->img_table.num_simgs = suof_ptr->num_chunks - 1;
 
        if (suof_handle->img_table.num_simgs != 0) {
-               suof_img_hdr = kzalloc(suof_handle->img_table.num_simgs *
-                                      sizeof(img_header), GFP_KERNEL);
+               suof_img_hdr = kcalloc(suof_handle->img_table.num_simgs,
+                                      sizeof(img_header),
+                                      GFP_KERNEL);
                if (!suof_img_hdr)
                        return -ENOMEM;
                suof_handle->img_table.simg_hdr = suof_img_hdr;
index 981e45692695a000bceac10a9f87727be194276b..cdc96f1bb917592dcad692d831a76f8db06251bd 100644 (file)
@@ -970,8 +970,9 @@ static int stm32_hash_export(struct ahash_request *req, void *out)
        while (!(stm32_hash_read(hdev, HASH_SR) & HASH_SR_DATA_INPUT_READY))
                cpu_relax();
 
-       rctx->hw_context = kmalloc(sizeof(u32) * (3 + HASH_CSR_REGISTER_NUMBER),
-                                  GFP_KERNEL);
+       rctx->hw_context = kmalloc_array(3 + HASH_CSR_REGISTER_NUMBER,
+                                        sizeof(u32),
+                                        GFP_KERNEL);
 
        preg = rctx->hw_context;
 
index 7cebf0a6ffbca83201f88a20a00c40924ed3f52f..cf14f099ce4a0d8092e113f49848e1accef63755 100644 (file)
@@ -3393,8 +3393,10 @@ static int talitos_probe(struct platform_device *ofdev)
                }
        }
 
-       priv->chan = devm_kzalloc(dev, sizeof(struct talitos_channel) *
-                                      priv->num_channels, GFP_KERNEL);
+       priv->chan = devm_kcalloc(dev,
+                                 priv->num_channels,
+                                 sizeof(struct talitos_channel),
+                                 GFP_KERNEL);
        if (!priv->chan) {
                dev_err(dev, "failed to allocate channel management space\n");
                err = -ENOMEM;
@@ -3411,9 +3413,10 @@ static int talitos_probe(struct platform_device *ofdev)
                spin_lock_init(&priv->chan[i].head_lock);
                spin_lock_init(&priv->chan[i].tail_lock);
 
-               priv->chan[i].fifo = devm_kzalloc(dev,
-                                               sizeof(struct talitos_request) *
-                                               priv->fifo_len, GFP_KERNEL);
+               priv->chan[i].fifo = devm_kcalloc(dev,
+                                               priv->fifo_len,
+                                               sizeof(struct talitos_request),
+                                               GFP_KERNEL);
                if (!priv->chan[i].fifo) {
                        dev_err(dev, "failed to allocate request fifo %d\n", i);
                        err = -ENOMEM;
index ba190cfa7aa18b54a0caff6143058a6bb022e70c..af6a908dfa7a98ea02e37613a456d5cde84734c0 100644 (file)
@@ -371,7 +371,7 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
 
        /* Why 3?  outhdr + iv + inhdr */
        sg_total = src_nents + dst_nents + 3;
-       sgs = kzalloc_node(sg_total * sizeof(*sgs), GFP_ATOMIC,
+       sgs = kcalloc_node(sg_total, sizeof(*sgs), GFP_ATOMIC,
                                dev_to_node(&vcrypto->vdev->dev));
        if (!sgs)
                return -ENOMEM;
index fe2af6aa88fc2b0cec9a103fcc2ca682f073659a..0b5b3abe054e6427f779beca3098a8d37d15cee3 100644 (file)
@@ -628,14 +628,15 @@ struct devfreq *devfreq_add_device(struct device *dev,
                goto err_dev;
        }
 
-       devfreq->trans_table =  devm_kzalloc(&devfreq->dev,
-                                               sizeof(unsigned int) *
-                                               devfreq->profile->max_state *
-                                               devfreq->profile->max_state,
-                                               GFP_KERNEL);
-       devfreq->time_in_state = devm_kzalloc(&devfreq->dev,
-                                               sizeof(unsigned long) *
+       devfreq->trans_table =
+               devm_kzalloc(&devfreq->dev,
+                            array3_size(sizeof(unsigned int),
+                                        devfreq->profile->max_state,
+                                        devfreq->profile->max_state),
+                            GFP_KERNEL);
+       devfreq->time_in_state = devm_kcalloc(&devfreq->dev,
                                                devfreq->profile->max_state,
+                                               sizeof(unsigned long),
                                                GFP_KERNEL);
        devfreq->last_stat_updated = jiffies;
 
index d96e3dc71cf8ba74fa92078d97c79d434344c949..3cd6a184fe7cfcb01b0bada99d73cac19d9c23b4 100644 (file)
@@ -518,7 +518,7 @@ static int of_get_devfreq_events(struct device_node *np,
        event_ops = exynos_bus_get_ops(np);
 
        count = of_get_child_count(events_np);
-       desc = devm_kzalloc(dev, sizeof(*desc) * count, GFP_KERNEL);
+       desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL);
        if (!desc)
                return -ENOMEM;
        info->num_events = count;
index 7a67b83450928e4aeb02c1c3ef08e4fd71f0b94d..d91cbbe7a48fbe92027389d99542725bffe76831 100644 (file)
@@ -87,7 +87,8 @@ bcom_task_alloc(int bd_count, int bd_size, int priv_size)
 
        /* Init the BDs, if needed */
        if (bd_count) {
-               tsk->cookie = kmalloc(sizeof(void*) * bd_count, GFP_KERNEL);
+               tsk->cookie = kmalloc_array(bd_count, sizeof(void *),
+                                           GFP_KERNEL);
                if (!tsk->cookie)
                        goto error;
 
index b451354735d3d6b80b003f8e6c3ea098d37041e0..08ba8473a284845ecbffab228dded0d3b3b4aaf1 100644 (file)
@@ -38,7 +38,7 @@
  * Each device has a channels list, which runs unlocked but is never modified
  * once the device is registered, it's just setup by the driver.
  *
- * See Documentation/dmaengine.txt for more details
+ * See Documentation/driver-api/dmaengine for more details
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index 7792a9186f9cf35bae71792e5e0783cf53364b05..4fa4c06c9edb9809675ea98a2d058e3c8b5dfa35 100644 (file)
@@ -322,10 +322,10 @@ static int ioat_dma_self_test(struct ioatdma_device *ioat_dma)
        unsigned long tmo;
        unsigned long flags;
 
-       src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
+       src = kzalloc(IOAT_TEST_SIZE, GFP_KERNEL);
        if (!src)
                return -ENOMEM;
-       dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
+       dest = kzalloc(IOAT_TEST_SIZE, GFP_KERNEL);
        if (!dest) {
                kfree(src);
                return -ENOMEM;
index ed76044ce4b92a41bccfd0169df7df66b58841ca..bbff52be4f0ff1a83bb04e12f278fda864411b08 100644 (file)
@@ -910,7 +910,8 @@ static dma_cookie_t idmac_tx_submit(struct dma_async_tx_descriptor *tx)
 /* Called with ichan->chan_mutex held */
 static int idmac_desc_alloc(struct idmac_channel *ichan, int n)
 {
-       struct idmac_tx_desc *desc = vmalloc(n * sizeof(struct idmac_tx_desc));
+       struct idmac_tx_desc *desc =
+               vmalloc(array_size(n, sizeof(struct idmac_tx_desc)));
        struct idmac *idmac = to_idmac(ichan->dma_chan.device);
 
        if (!desc)
index 26b67455208fbd24d172e010fb224c16f2cd1a25..fa31cccbe04faf5fa6a8adb07abf6b48a4a6cdd2 100644 (file)
@@ -848,8 +848,8 @@ static int k3_dma_probe(struct platform_device *op)
                return -ENOMEM;
 
        /* init phy channel */
-       d->phy = devm_kzalloc(&op->dev,
-               d->dma_channels * sizeof(struct k3_dma_phy), GFP_KERNEL);
+       d->phy = devm_kcalloc(&op->dev,
+               d->dma_channels, sizeof(struct k3_dma_phy), GFP_KERNEL);
        if (d->phy == NULL)
                return -ENOMEM;
 
@@ -879,8 +879,8 @@ static int k3_dma_probe(struct platform_device *op)
        d->slave.copy_align = DMAENGINE_ALIGN_8_BYTES;
 
        /* init virtual channel */
-       d->chans = devm_kzalloc(&op->dev,
-               d->dma_requests * sizeof(struct k3_dma_chan), GFP_KERNEL);
+       d->chans = devm_kcalloc(&op->dev,
+               d->dma_requests, sizeof(struct k3_dma_chan), GFP_KERNEL);
        if (d->chans == NULL)
                return -ENOMEM;
 
index 94d7bd7d2880164de11957e105a5f04a1cc8b102..68dd79783b54a0f2f5c1a0e3578b5acaf8933616 100644 (file)
@@ -385,7 +385,8 @@ static int mic_dma_alloc_desc_ring(struct mic_dma_chan *ch)
        if (dma_mapping_error(dev, ch->desc_ring_micpa))
                goto map_error;
 
-       ch->tx_array = vzalloc(MIC_DMA_DESC_RX_SIZE * sizeof(*ch->tx_array));
+       ch->tx_array = vzalloc(array_size(MIC_DMA_DESC_RX_SIZE,
+                                         sizeof(*ch->tx_array)));
        if (!ch->tx_array)
                goto tx_error;
        return 0;
index 1993889003fd11d51d80090daf32737d740a5b4b..969534c1a6c63339b1b5c48ae3568d275f3bb518 100644 (file)
@@ -777,11 +777,11 @@ static int mv_chan_memcpy_self_test(struct mv_xor_chan *mv_chan)
        struct dmaengine_unmap_data *unmap;
        int err = 0;
 
-       src = kmalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL);
+       src = kmalloc(PAGE_SIZE, GFP_KERNEL);
        if (!src)
                return -ENOMEM;
 
-       dest = kzalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL);
+       dest = kzalloc(PAGE_SIZE, GFP_KERNEL);
        if (!dest) {
                kfree(src);
                return -ENOMEM;
index 3548caa9e9339f17208a62066ad055c842491e3b..c6589ccf1b9a3a4c49dcae612d86d08ab5c2ebdd 100644 (file)
@@ -809,8 +809,9 @@ static int mv_xor_v2_probe(struct platform_device *pdev)
        }
 
        /* alloc memory for the SW descriptors */
-       xor_dev->sw_desq = devm_kzalloc(&pdev->dev, sizeof(*sw_desc) *
-                                       MV_XOR_V2_DESC_NUM, GFP_KERNEL);
+       xor_dev->sw_desq = devm_kcalloc(&pdev->dev,
+                                       MV_XOR_V2_DESC_NUM, sizeof(*sw_desc),
+                                       GFP_KERNEL);
        if (!xor_dev->sw_desq) {
                ret = -ENOMEM;
                goto free_hw_desq;
index 6237069001c4fea463d73f943d18b22ed5f9fba3..defcdde4d358b19cc5430de95fb5e9f16ec538ca 100644 (file)
@@ -1866,7 +1866,7 @@ static int dmac_alloc_threads(struct pl330_dmac *pl330)
        int i;
 
        /* Allocate 1 Manager and 'chans' Channel threads */
-       pl330->channels = kzalloc((1 + chans) * sizeof(*thrd),
+       pl330->channels = kcalloc(1 + chans, sizeof(*thrd),
                                        GFP_KERNEL);
        if (!pl330->channels)
                return -ENOMEM;
@@ -2990,7 +2990,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 
        pl330->num_peripherals = num_chan;
 
-       pl330->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
+       pl330->peripherals = kcalloc(num_chan, sizeof(*pch), GFP_KERNEL);
        if (!pl330->peripherals) {
                ret = -ENOMEM;
                goto probe_err2;
index cd92d696bcf98f8a5c762a4ef0117e1682503778..7056fe7513b4f73c98f1b4637161d70b4e9c5349 100644 (file)
@@ -1223,9 +1223,9 @@ static int s3c24xx_dma_probe(struct platform_device *pdev)
        if (IS_ERR(s3cdma->base))
                return PTR_ERR(s3cdma->base);
 
-       s3cdma->phy_chans = devm_kzalloc(&pdev->dev,
-                                             sizeof(struct s3c24xx_dma_phy) *
-                                                       pdata->num_phy_channels,
+       s3cdma->phy_chans = devm_kcalloc(&pdev->dev,
+                                             pdata->num_phy_channels,
+                                             sizeof(struct s3c24xx_dma_phy),
                                              GFP_KERNEL);
        if (!s3cdma->phy_chans)
                return -ENOMEM;
index 12fa48e380cf5daa16f15b24b636349047732f30..6b5626e299b22373fcba4e68f37862f73b9fc627 100644 (file)
@@ -1045,8 +1045,9 @@ EXPORT_SYMBOL(shdma_cleanup);
 
 static int __init shdma_enter(void)
 {
-       shdma_slave_used = kzalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG) *
-                                   sizeof(long), GFP_KERNEL);
+       shdma_slave_used = kcalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG),
+                                  sizeof(long),
+                                  GFP_KERNEL);
        if (!shdma_slave_used)
                return -ENOMEM;
        return 0;
index f14645817ed8026f997eded8ea42d85189447307..c74a88b650396e34cb713e069ffb4640060d94f8 100644 (file)
@@ -471,7 +471,7 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)
        if (ret < 0)
                return ret;
 
-       chan->sw_desc_pool = kzalloc(sizeof(*desc) * ZYNQMP_DMA_NUM_DESCS,
+       chan->sw_desc_pool = kcalloc(ZYNQMP_DMA_NUM_DESCS, sizeof(*desc),
                                     GFP_KERNEL);
        if (!chan->sw_desc_pool)
                return -ENOMEM;
index 2bb695315300d9f9fab6c1b32f8ef85b6486ab05..2571bc7693dfc6e73d6d2726981f150c3bbad908 100644 (file)
@@ -798,8 +798,8 @@ static int zx_dma_probe(struct platform_device *op)
                return -ENOMEM;
 
        /* init phy channel */
-       d->phy = devm_kzalloc(&op->dev,
-               d->dma_channels * sizeof(struct zx_dma_phy), GFP_KERNEL);
+       d->phy = devm_kcalloc(&op->dev,
+               d->dma_channels, sizeof(struct zx_dma_phy), GFP_KERNEL);
        if (!d->phy)
                return -ENOMEM;
 
@@ -834,8 +834,8 @@ static int zx_dma_probe(struct platform_device *op)
        d->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
 
        /* init virtual channel */
-       d->chans = devm_kzalloc(&op->dev,
-               d->dma_requests * sizeof(struct zx_dma_chan), GFP_KERNEL);
+       d->chans = devm_kcalloc(&op->dev,
+               d->dma_requests, sizeof(struct zx_dma_chan), GFP_KERNEL);
        if (!d->chans)
                return -ENOMEM;
 
index 329cb96f886fd136062707324680327a3083b763..18aeabb1d5ee4afdb14051d42adad6121d83cc43 100644 (file)
@@ -3451,7 +3451,7 @@ static int __init amd64_edac_init(void)
        opstate_init();
 
        err = -ENOMEM;
-       ecc_stngs = kzalloc(amd_nb_num() * sizeof(ecc_stngs[0]), GFP_KERNEL);
+       ecc_stngs = kcalloc(amd_nb_num(), sizeof(ecc_stngs[0]), GFP_KERNEL);
        if (!ecc_stngs)
                goto err_free;
 
index 4d0ea3563d47df8b1409d6643bec7b0fa52c7560..8ed4dd9c571bb5294e79cca52e57059d502f1337 100644 (file)
@@ -461,7 +461,7 @@ static struct i7core_dev *alloc_i7core_dev(u8 socket,
        if (!i7core_dev)
                return NULL;
 
-       i7core_dev->pdev = kzalloc(sizeof(*i7core_dev->pdev) * table->n_devs,
+       i7core_dev->pdev = kcalloc(table->n_devs, sizeof(*i7core_dev->pdev),
                                   GFP_KERNEL);
        if (!i7core_dev->pdev) {
                kfree(i7core_dev);
index 8bff5fd1818516d6b4bc81a239136d926aa4ba47..af83ad58819ca3cf7fb37f4d0cb24260c83cb6cb 100644 (file)
@@ -1126,8 +1126,9 @@ int extcon_dev_register(struct extcon_dev *edev)
                char *str;
                struct extcon_cable *cable;
 
-               edev->cables = kzalloc(sizeof(struct extcon_cable) *
-                                      edev->max_supported, GFP_KERNEL);
+               edev->cables = kcalloc(edev->max_supported,
+                                      sizeof(struct extcon_cable),
+                                      GFP_KERNEL);
                if (!edev->cables) {
                        ret = -ENOMEM;
                        goto err_sysfs_alloc;
@@ -1136,7 +1137,7 @@ int extcon_dev_register(struct extcon_dev *edev)
                        cable = &edev->cables[index];
 
                        snprintf(buf, 10, "cable.%d", index);
-                       str = kzalloc(sizeof(char) * (strlen(buf) + 1),
+                       str = kzalloc(strlen(buf) + 1,
                                      GFP_KERNEL);
                        if (!str) {
                                for (index--; index >= 0; index--) {
@@ -1177,15 +1178,17 @@ int extcon_dev_register(struct extcon_dev *edev)
                for (index = 0; edev->mutually_exclusive[index]; index++)
                        ;
 
-               edev->attrs_muex = kzalloc(sizeof(struct attribute *) *
-                                          (index + 1), GFP_KERNEL);
+               edev->attrs_muex = kcalloc(index + 1,
+                                          sizeof(struct attribute *),
+                                          GFP_KERNEL);
                if (!edev->attrs_muex) {
                        ret = -ENOMEM;
                        goto err_muex;
                }
 
-               edev->d_attrs_muex = kzalloc(sizeof(struct device_attribute) *
-                                            index, GFP_KERNEL);
+               edev->d_attrs_muex = kcalloc(index,
+                                            sizeof(struct device_attribute),
+                                            GFP_KERNEL);
                if (!edev->d_attrs_muex) {
                        ret = -ENOMEM;
                        kfree(edev->attrs_muex);
@@ -1194,7 +1197,7 @@ int extcon_dev_register(struct extcon_dev *edev)
 
                for (index = 0; edev->mutually_exclusive[index]; index++) {
                        sprintf(buf, "0x%x", edev->mutually_exclusive[index]);
-                       name = kzalloc(sizeof(char) * (strlen(buf) + 1),
+                       name = kzalloc(strlen(buf) + 1,
                                       GFP_KERNEL);
                        if (!name) {
                                for (index--; index >= 0; index--) {
@@ -1220,8 +1223,9 @@ int extcon_dev_register(struct extcon_dev *edev)
 
        if (edev->max_supported) {
                edev->extcon_dev_type.groups =
-                       kzalloc(sizeof(struct attribute_group *) *
-                               (edev->max_supported + 2), GFP_KERNEL);
+                       kcalloc(edev->max_supported + 2,
+                               sizeof(struct attribute_group *),
+                               GFP_KERNEL);
                if (!edev->extcon_dev_type.groups) {
                        ret = -ENOMEM;
                        goto err_alloc_groups;
index 38c0aa60b2cb1a53da46547e5bc188a87db1f18b..051327a951b1955ad017c70d5d1fdba145c95b0b 100644 (file)
@@ -45,8 +45,8 @@ int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count)
 
        buffer->page_count = 0;
        buffer->page_count_mapped = 0;
-       buffer->pages = kmalloc(page_count * sizeof(buffer->pages[0]),
-                               GFP_KERNEL);
+       buffer->pages = kmalloc_array(page_count, sizeof(buffer->pages[0]),
+                                     GFP_KERNEL);
        if (buffer->pages == NULL)
                return -ENOMEM;
 
index 60e75e6d9104c3db01c8ca36b25b70f02bb70c83..82ba110d9d1ad29600c006dbe2cc350616a099b8 100644 (file)
@@ -1121,7 +1121,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
        max_receive = 1U << (dev->card->max_receive + 1);
        num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive;
 
-       ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL);
+       ptrptr = kmalloc_array(num_packets, sizeof(void *), GFP_KERNEL);
        if (!ptrptr) {
                retval = -ENOMEM;
                goto failed;
index 0d3806c0d43285c1b0fe3c1940ac0b3f3428ab4e..9dff33ea6416f66879ea4de32e8dba6a22e37c01 100644 (file)
@@ -26,7 +26,7 @@ struct scmi_msg_resp_base_attributes {
  * scmi_base_attributes_get() - gets the implementation details
  *     that are associated with the base protocol.
  *
- * @handle - SCMI entity handle
+ * @handle: SCMI entity handle
  *
  * Return: 0 on success, else appropriate SCMI error.
  */
@@ -37,7 +37,7 @@ static int scmi_base_attributes_get(const struct scmi_handle *handle)
        struct scmi_msg_resp_base_attributes *attr_info;
        struct scmi_revision_info *rev = handle->version;
 
-       ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES,
+       ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES,
                                 SCMI_PROTOCOL_BASE, 0, sizeof(*attr_info), &t);
        if (ret)
                return ret;
@@ -49,15 +49,16 @@ static int scmi_base_attributes_get(const struct scmi_handle *handle)
                rev->num_agents = attr_info->num_agents;
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
+
        return ret;
 }
 
 /**
  * scmi_base_vendor_id_get() - gets vendor/subvendor identifier ASCII string.
  *
- * @handle - SCMI entity handle
- * @sub_vendor - specify true if sub-vendor ID is needed
+ * @handle: SCMI entity handle
+ * @sub_vendor: specify true if sub-vendor ID is needed
  *
  * Return: 0 on success, else appropriate SCMI error.
  */
@@ -80,7 +81,7 @@ scmi_base_vendor_id_get(const struct scmi_handle *handle, bool sub_vendor)
                size = ARRAY_SIZE(rev->vendor_id);
        }
 
-       ret = scmi_one_xfer_init(handle, cmd, SCMI_PROTOCOL_BASE, 0, size, &t);
+       ret = scmi_xfer_get_init(handle, cmd, SCMI_PROTOCOL_BASE, 0, size, &t);
        if (ret)
                return ret;
 
@@ -88,7 +89,8 @@ scmi_base_vendor_id_get(const struct scmi_handle *handle, bool sub_vendor)
        if (!ret)
                memcpy(vendor_id, t->rx.buf, size);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
+
        return ret;
 }
 
@@ -97,7 +99,7 @@ scmi_base_vendor_id_get(const struct scmi_handle *handle, bool sub_vendor)
  *     implementation 32-bit version. The format of the version number is
  *     vendor-specific
  *
- * @handle - SCMI entity handle
+ * @handle: SCMI entity handle
  *
  * Return: 0 on success, else appropriate SCMI error.
  */
@@ -109,7 +111,7 @@ scmi_base_implementation_version_get(const struct scmi_handle *handle)
        struct scmi_xfer *t;
        struct scmi_revision_info *rev = handle->version;
 
-       ret = scmi_one_xfer_init(handle, BASE_DISCOVER_IMPLEMENT_VERSION,
+       ret = scmi_xfer_get_init(handle, BASE_DISCOVER_IMPLEMENT_VERSION,
                                 SCMI_PROTOCOL_BASE, 0, sizeof(*impl_ver), &t);
        if (ret)
                return ret;
@@ -120,7 +122,8 @@ scmi_base_implementation_version_get(const struct scmi_handle *handle)
                rev->impl_ver = le32_to_cpu(*impl_ver);
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
+
        return ret;
 }
 
@@ -128,8 +131,8 @@ scmi_base_implementation_version_get(const struct scmi_handle *handle)
  * scmi_base_implementation_list_get() - gets the list of protocols it is
  *     OSPM is allowed to access
  *
- * @handle - SCMI entity handle
- * @protocols_imp - pointer to hold the list of protocol identifiers
+ * @handle: SCMI entity handle
+ * @protocols_imp: pointer to hold the list of protocol identifiers
  *
  * Return: 0 on success, else appropriate SCMI error.
  */
@@ -143,7 +146,7 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle,
        u32 tot_num_ret = 0, loop_num_ret;
        struct device *dev = handle->dev;
 
-       ret = scmi_one_xfer_init(handle, BASE_DISCOVER_LIST_PROTOCOLS,
+       ret = scmi_xfer_get_init(handle, BASE_DISCOVER_LIST_PROTOCOLS,
                                 SCMI_PROTOCOL_BASE, sizeof(*num_skip), 0, &t);
        if (ret)
                return ret;
@@ -172,16 +175,17 @@ static int scmi_base_implementation_list_get(const struct scmi_handle *handle,
                tot_num_ret += loop_num_ret;
        } while (loop_num_ret);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
+
        return ret;
 }
 
 /**
  * scmi_base_discover_agent_get() - discover the name of an agent
  *
- * @handle - SCMI entity handle
- * @id - Agent identifier
- * @name - Agent identifier ASCII string
+ * @handle: SCMI entity handle
+ * @id: Agent identifier
+ * @name: Agent identifier ASCII string
  *
  * An agent id of 0 is reserved to identify the platform itself.
  * Generally operating system is represented as "OSPM"
@@ -194,7 +198,7 @@ static int scmi_base_discover_agent_get(const struct scmi_handle *handle,
        int ret;
        struct scmi_xfer *t;
 
-       ret = scmi_one_xfer_init(handle, BASE_DISCOVER_AGENT,
+       ret = scmi_xfer_get_init(handle, BASE_DISCOVER_AGENT,
                                 SCMI_PROTOCOL_BASE, sizeof(__le32),
                                 SCMI_MAX_STR_SIZE, &t);
        if (ret)
@@ -206,7 +210,8 @@ static int scmi_base_discover_agent_get(const struct scmi_handle *handle,
        if (!ret)
                memcpy(name, t->rx.buf, SCMI_MAX_STR_SIZE);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
+
        return ret;
 }
 
index f2760a596c2872a5baf10d629e53e6d207d2039c..472c88ae1c0f9d37ffae6d094a8500ca85ed3146 100644 (file)
@@ -125,13 +125,13 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol)
        int id, retval;
        struct scmi_device *scmi_dev;
 
-       id = ida_simple_get(&scmi_bus_id, 1, 0, GFP_KERNEL);
-       if (id < 0)
-               return NULL;
-
        scmi_dev = kzalloc(sizeof(*scmi_dev), GFP_KERNEL);
        if (!scmi_dev)
-               goto no_mem;
+               return NULL;
+
+       id = ida_simple_get(&scmi_bus_id, 1, 0, GFP_KERNEL);
+       if (id < 0)
+               goto free_mem;
 
        scmi_dev->id = id;
        scmi_dev->protocol_id = protocol;
@@ -141,13 +141,15 @@ scmi_device_create(struct device_node *np, struct device *parent, int protocol)
        dev_set_name(&scmi_dev->dev, "scmi_dev.%d", id);
 
        retval = device_register(&scmi_dev->dev);
-       if (!retval)
-               return scmi_dev;
+       if (retval)
+               goto put_dev;
 
+       return scmi_dev;
+put_dev:
        put_device(&scmi_dev->dev);
-       kfree(scmi_dev);
-no_mem:
        ida_simple_remove(&scmi_bus_id, id);
+free_mem:
+       kfree(scmi_dev);
        return NULL;
 }
 
@@ -171,9 +173,9 @@ int scmi_protocol_register(int protocol_id, scmi_prot_init_fn_t fn)
        spin_lock(&protocol_lock);
        ret = idr_alloc(&scmi_protocols, fn, protocol_id, protocol_id + 1,
                        GFP_ATOMIC);
+       spin_unlock(&protocol_lock);
        if (ret != protocol_id)
                pr_err("unable to allocate SCMI idr slot, err %d\n", ret);
-       spin_unlock(&protocol_lock);
 
        return ret;
 }
index 2b90606452a2faf1a845b82bfd5bd9ce83b8bd00..e4119eb34986cb5219b648d1b900a23c8686329b 100644 (file)
@@ -77,7 +77,7 @@ static int scmi_clock_protocol_attributes_get(const struct scmi_handle *handle,
        struct scmi_xfer *t;
        struct scmi_msg_resp_clock_protocol_attributes *attr;
 
-       ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES,
+       ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES,
                                 SCMI_PROTOCOL_CLOCK, 0, sizeof(*attr), &t);
        if (ret)
                return ret;
@@ -90,7 +90,7 @@ static int scmi_clock_protocol_attributes_get(const struct scmi_handle *handle,
                ci->max_async_req = attr->max_async_req;
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -101,7 +101,7 @@ static int scmi_clock_attributes_get(const struct scmi_handle *handle,
        struct scmi_xfer *t;
        struct scmi_msg_resp_clock_attributes *attr;
 
-       ret = scmi_one_xfer_init(handle, CLOCK_ATTRIBUTES, SCMI_PROTOCOL_CLOCK,
+       ret = scmi_xfer_get_init(handle, CLOCK_ATTRIBUTES, SCMI_PROTOCOL_CLOCK,
                                 sizeof(clk_id), sizeof(*attr), &t);
        if (ret)
                return ret;
@@ -115,7 +115,7 @@ static int scmi_clock_attributes_get(const struct scmi_handle *handle,
        else
                clk->name[0] = '\0';
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -132,7 +132,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
        struct scmi_msg_clock_describe_rates *clk_desc;
        struct scmi_msg_resp_clock_describe_rates *rlist;
 
-       ret = scmi_one_xfer_init(handle, CLOCK_DESCRIBE_RATES,
+       ret = scmi_xfer_get_init(handle, CLOCK_DESCRIBE_RATES,
                                 SCMI_PROTOCOL_CLOCK, sizeof(*clk_desc), 0, &t);
        if (ret)
                return ret;
@@ -186,7 +186,7 @@ scmi_clock_describe_rates_get(const struct scmi_handle *handle, u32 clk_id,
                clk->list.num_rates = tot_rate_cnt;
 
 err:
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -196,7 +196,7 @@ scmi_clock_rate_get(const struct scmi_handle *handle, u32 clk_id, u64 *value)
        int ret;
        struct scmi_xfer *t;
 
-       ret = scmi_one_xfer_init(handle, CLOCK_RATE_GET, SCMI_PROTOCOL_CLOCK,
+       ret = scmi_xfer_get_init(handle, CLOCK_RATE_GET, SCMI_PROTOCOL_CLOCK,
                                 sizeof(__le32), sizeof(u64), &t);
        if (ret)
                return ret;
@@ -211,7 +211,7 @@ scmi_clock_rate_get(const struct scmi_handle *handle, u32 clk_id, u64 *value)
                *value |= (u64)le32_to_cpu(*(pval + 1)) << 32;
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -222,7 +222,7 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id,
        struct scmi_xfer *t;
        struct scmi_clock_set_rate *cfg;
 
-       ret = scmi_one_xfer_init(handle, CLOCK_RATE_SET, SCMI_PROTOCOL_CLOCK,
+       ret = scmi_xfer_get_init(handle, CLOCK_RATE_SET, SCMI_PROTOCOL_CLOCK,
                                 sizeof(*cfg), 0, &t);
        if (ret)
                return ret;
@@ -235,7 +235,7 @@ static int scmi_clock_rate_set(const struct scmi_handle *handle, u32 clk_id,
 
        ret = scmi_do_xfer(handle, t);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -246,7 +246,7 @@ scmi_clock_config_set(const struct scmi_handle *handle, u32 clk_id, u32 config)
        struct scmi_xfer *t;
        struct scmi_clock_set_config *cfg;
 
-       ret = scmi_one_xfer_init(handle, CLOCK_CONFIG_SET, SCMI_PROTOCOL_CLOCK,
+       ret = scmi_xfer_get_init(handle, CLOCK_CONFIG_SET, SCMI_PROTOCOL_CLOCK,
                                 sizeof(*cfg), 0, &t);
        if (ret)
                return ret;
@@ -257,7 +257,7 @@ scmi_clock_config_set(const struct scmi_handle *handle, u32 clk_id, u32 config)
 
        ret = scmi_do_xfer(handle, t);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
index 0c30234f909856535396851c553f01854951867b..937a930ce87de63d45d7e8d44434efbe62a9d3de 100644 (file)
@@ -7,6 +7,7 @@
  * Copyright (C) 2018 ARM Ltd.
  */
 
+#include <linux/bitfield.h>
 #include <linux/completion.h>
 #include <linux/device.h>
 #include <linux/errno.h>
 #include <linux/scmi_protocol.h>
 #include <linux/types.h>
 
-#define PROTOCOL_REV_MINOR_BITS        16
-#define PROTOCOL_REV_MINOR_MASK        ((1U << PROTOCOL_REV_MINOR_BITS) - 1)
-#define PROTOCOL_REV_MAJOR(x)  ((x) >> PROTOCOL_REV_MINOR_BITS)
-#define PROTOCOL_REV_MINOR(x)  ((x) & PROTOCOL_REV_MINOR_MASK)
+#define PROTOCOL_REV_MINOR_MASK        GENMASK(15, 0)
+#define PROTOCOL_REV_MAJOR_MASK        GENMASK(31, 16)
+#define PROTOCOL_REV_MAJOR(x)  (u16)(FIELD_GET(PROTOCOL_REV_MAJOR_MASK, (x)))
+#define PROTOCOL_REV_MINOR(x)  (u16)(FIELD_GET(PROTOCOL_REV_MINOR_MASK, (x)))
 #define MAX_PROTOCOLS_IMP      16
 #define MAX_OPPS               16
 
@@ -50,8 +51,11 @@ struct scmi_msg_resp_prot_version {
  * @id: The identifier of the command being sent
  * @protocol_id: The identifier of the protocol used to send @id command
  * @seq: The token to identify the message. when a message/command returns,
- *       the platform returns the whole message header unmodified including
- *      the token.
+ *     the platform returns the whole message header unmodified including
+ *     the token
+ * @status: Status of the transfer once it's complete
+ * @poll_completion: Indicate if the transfer needs to be polled for
+ *     completion or interrupt mode is used
  */
 struct scmi_msg_hdr {
        u8 id;
@@ -82,18 +86,16 @@ struct scmi_msg {
  *     buffer for the rx path as we use for the tx path.
  * @done: completion event
  */
-
 struct scmi_xfer {
-       void *con_priv;
        struct scmi_msg_hdr hdr;
        struct scmi_msg tx;
        struct scmi_msg rx;
        struct completion done;
 };
 
-void scmi_one_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
+void scmi_xfer_put(const struct scmi_handle *h, struct scmi_xfer *xfer);
 int scmi_do_xfer(const struct scmi_handle *h, struct scmi_xfer *xfer);
-int scmi_one_xfer_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id,
+int scmi_xfer_get_init(const struct scmi_handle *h, u8 msg_id, u8 prot_id,
                       size_t tx_size, size_t rx_size, struct scmi_xfer **p);
 int scmi_handle_put(const struct scmi_handle *handle);
 struct scmi_handle *scmi_handle_get(struct device *dev);
index 2455be8cbc4f75b1d8ebe12044d341c23bf85331..8f952f2f1a29203f8b7729cbfd10aafeba3cd9f6 100644 (file)
 
 #include "common.h"
 
-#define MSG_ID_SHIFT           0
-#define MSG_ID_MASK            0xff
-#define MSG_TYPE_SHIFT         8
-#define MSG_TYPE_MASK          0x3
-#define MSG_PROTOCOL_ID_SHIFT  10
-#define MSG_PROTOCOL_ID_MASK   0xff
-#define MSG_TOKEN_ID_SHIFT     18
-#define MSG_TOKEN_ID_MASK      0x3ff
-#define MSG_XTRACT_TOKEN(header)       \
-       (((header) >> MSG_TOKEN_ID_SHIFT) & MSG_TOKEN_ID_MASK)
+#define MSG_ID_MASK            GENMASK(7, 0)
+#define MSG_TYPE_MASK          GENMASK(9, 8)
+#define MSG_PROTOCOL_ID_MASK   GENMASK(17, 10)
+#define MSG_TOKEN_ID_MASK      GENMASK(27, 18)
+#define MSG_XTRACT_TOKEN(hdr)  FIELD_GET(MSG_TOKEN_ID_MASK, (hdr))
+#define MSG_TOKEN_MAX          (MSG_XTRACT_TOKEN(MSG_TOKEN_ID_MASK) + 1)
 
 enum scmi_error_codes {
        SCMI_SUCCESS = 0,       /* Success */
@@ -55,7 +51,7 @@ enum scmi_error_codes {
        SCMI_ERR_MAX
 };
 
-/* List of all  SCMI devices active in system */
+/* List of all SCMI devices active in system */
 static LIST_HEAD(scmi_list);
 /* Protection for the entire list */
 static DEFINE_MUTEX(scmi_list_mutex);
@@ -72,7 +68,6 @@ static DEFINE_MUTEX(scmi_list_mutex);
 struct scmi_xfers_info {
        struct scmi_xfer *xfer_block;
        unsigned long *xfer_alloc_table;
-       /* protect transfer allocation */
        spinlock_t xfer_lock;
 };
 
@@ -98,6 +93,7 @@ struct scmi_desc {
  * @payload: Transmit/Receive mailbox channel payload area
  * @dev: Reference to device in the SCMI hierarchy corresponding to this
  *      channel
+ * @handle: Pointer to SCMI entity handle
  */
 struct scmi_chan_info {
        struct mbox_client cl;
@@ -108,7 +104,7 @@ struct scmi_chan_info {
 };
 
 /**
- * struct scmi_info - Structure representing a  SCMI instance
+ * struct scmi_info - Structure representing a SCMI instance
  *
  * @dev: Device pointer
  * @desc: SoC description for this instance
@@ -117,9 +113,9 @@ struct scmi_chan_info {
  *     implementation version and (sub-)vendor identification.
  * @minfo: Message info
  * @tx_idr: IDR object to map protocol id to channel info pointer
- * @protocols_imp: list of protocols implemented, currently maximum of
+ * @protocols_imp: List of protocols implemented, currently maximum of
  *     MAX_PROTOCOLS_IMP elements allocated by the base protocol
- * @node: list head
+ * @node: List head
  * @users: Number of users of this instance
  */
 struct scmi_info {
@@ -225,9 +221,7 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m)
 
        xfer_id = MSG_XTRACT_TOKEN(ioread32(&mem->msg_header));
 
-       /*
-        * Are we even expecting this?
-        */
+       /* Are we even expecting this? */
        if (!test_bit(xfer_id, minfo->xfer_alloc_table)) {
                dev_err(dev, "message for %d is not expected!\n", xfer_id);
                return;
@@ -252,12 +246,14 @@ static void scmi_rx_callback(struct mbox_client *cl, void *m)
  *
  * @hdr: pointer to header containing all the information on message id,
  *     protocol id and sequence id.
+ *
+ * Return: 32-bit packed command header to be sent to the platform.
  */
 static inline u32 pack_scmi_header(struct scmi_msg_hdr *hdr)
 {
-       return ((hdr->id & MSG_ID_MASK) << MSG_ID_SHIFT) |
-          ((hdr->seq & MSG_TOKEN_ID_MASK) << MSG_TOKEN_ID_SHIFT) |
-          ((hdr->protocol_id & MSG_PROTOCOL_ID_MASK) << MSG_PROTOCOL_ID_SHIFT);
+       return FIELD_PREP(MSG_ID_MASK, hdr->id) |
+               FIELD_PREP(MSG_TOKEN_ID_MASK, hdr->seq) |
+               FIELD_PREP(MSG_PROTOCOL_ID_MASK, hdr->protocol_id);
 }
 
 /**
@@ -286,9 +282,9 @@ static void scmi_tx_prepare(struct mbox_client *cl, void *m)
 }
 
 /**
- * scmi_one_xfer_get() - Allocate one message
+ * scmi_xfer_get() - Allocate one message
  *
- * @handle: SCMI entity handle
+ * @handle: Pointer to SCMI entity handle
  *
  * Helper function which is used by various command functions that are
  * exposed to clients of this driver for allocating a message traffic event.
@@ -299,7 +295,7 @@ static void scmi_tx_prepare(struct mbox_client *cl, void *m)
  *
  * Return: 0 if all went fine, else corresponding error.
  */
-static struct scmi_xfer *scmi_one_xfer_get(const struct scmi_handle *handle)
+static struct scmi_xfer *scmi_xfer_get(const struct scmi_handle *handle)
 {
        u16 xfer_id;
        struct scmi_xfer *xfer;
@@ -328,14 +324,14 @@ static struct scmi_xfer *scmi_one_xfer_get(const struct scmi_handle *handle)
 }
 
 /**
- * scmi_one_xfer_put() - Release a message
+ * scmi_xfer_put() - Release a message
  *
- * @minfo: transfer info pointer
- * @xfer: message that was reserved by scmi_one_xfer_get
+ * @handle: Pointer to SCMI entity handle
+ * @xfer: message that was reserved by scmi_xfer_get
  *
  * This holds a spinlock to maintain integrity of internal data structures.
  */
-void scmi_one_xfer_put(const struct scmi_handle *handle, struct scmi_xfer *xfer)
+void scmi_xfer_put(const struct scmi_handle *handle, struct scmi_xfer *xfer)
 {
        unsigned long flags;
        struct scmi_info *info = handle_to_scmi_info(handle);
@@ -378,12 +374,12 @@ static bool scmi_xfer_done_no_timeout(const struct scmi_chan_info *cinfo,
 /**
  * scmi_do_xfer() - Do one transfer
  *
- * @info: Pointer to SCMI entity information
+ * @handle: Pointer to SCMI entity handle
  * @xfer: Transfer to initiate and wait for response
  *
  * Return: -ETIMEDOUT in case of no response, if transmit error,
- *   return corresponding error, else if all goes well,
- *   return 0.
+ *     return corresponding error, else if all goes well,
+ *     return 0.
  */
 int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer)
 {
@@ -440,22 +436,22 @@ int scmi_do_xfer(const struct scmi_handle *handle, struct scmi_xfer *xfer)
 }
 
 /**
- * scmi_one_xfer_init() - Allocate and initialise one message
+ * scmi_xfer_get_init() - Allocate and initialise one message
  *
- * @handle: SCMI entity handle
+ * @handle: Pointer to SCMI entity handle
  * @msg_id: Message identifier
- * @msg_prot_id: Protocol identifier for the message
+ * @prot_id: Protocol identifier for the message
  * @tx_size: transmit message size
  * @rx_size: receive message size
  * @p: pointer to the allocated and initialised message
  *
- * This function allocates the message using @scmi_one_xfer_get and
+ * This function allocates the message using @scmi_xfer_get and
  * initialise the header.
  *
  * Return: 0 if all went fine with @p pointing to message, else
  *     corresponding error.
  */
-int scmi_one_xfer_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id,
+int scmi_xfer_get_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id,
                       size_t tx_size, size_t rx_size, struct scmi_xfer **p)
 {
        int ret;
@@ -468,7 +464,7 @@ int scmi_one_xfer_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id,
            tx_size > info->desc->max_msg_size)
                return -ERANGE;
 
-       xfer = scmi_one_xfer_get(handle);
+       xfer = scmi_xfer_get(handle);
        if (IS_ERR(xfer)) {
                ret = PTR_ERR(xfer);
                dev_err(dev, "failed to get free message slot(%d)\n", ret);
@@ -482,13 +478,16 @@ int scmi_one_xfer_init(const struct scmi_handle *handle, u8 msg_id, u8 prot_id,
        xfer->hdr.poll_completion = false;
 
        *p = xfer;
+
        return 0;
 }
 
 /**
  * scmi_version_get() - command to get the revision of the SCMI entity
  *
- * @handle: Handle to SCMI entity information
+ * @handle: Pointer to SCMI entity handle
+ * @protocol: Protocol identifier for the message
+ * @version: Holds returned version of protocol.
  *
  * Updates the SCMI information in the internal data structure.
  *
@@ -501,7 +500,7 @@ int scmi_version_get(const struct scmi_handle *handle, u8 protocol,
        __le32 *rev_info;
        struct scmi_xfer *t;
 
-       ret = scmi_one_xfer_init(handle, PROTOCOL_VERSION, protocol, 0,
+       ret = scmi_xfer_get_init(handle, PROTOCOL_VERSION, protocol, 0,
                                 sizeof(*version), &t);
        if (ret)
                return ret;
@@ -512,7 +511,7 @@ int scmi_version_get(const struct scmi_handle *handle, u8 protocol,
                *version = le32_to_cpu(*rev_info);
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -540,12 +539,12 @@ scmi_is_protocol_implemented(const struct scmi_handle *handle, u8 prot_id)
 }
 
 /**
- * scmi_handle_get() - Get the  SCMI handle for a device
+ * scmi_handle_get() - Get the SCMI handle for a device
  *
  * @dev: pointer to device for which we want SCMI handle
  *
  * NOTE: The function does not track individual clients of the framework
- * and is expected to be maintained by caller of  SCMI protocol library.
+ * and is expected to be maintained by caller of SCMI protocol library.
  * scmi_handle_put must be balanced with successful scmi_handle_get
  *
  * Return: pointer to handle if successful, NULL on error
@@ -576,7 +575,7 @@ struct scmi_handle *scmi_handle_get(struct device *dev)
  * @handle: handle acquired by scmi_handle_get
  *
  * NOTE: The function does not track individual clients of the framework
- * and is expected to be maintained by caller of  SCMI protocol library.
+ * and is expected to be maintained by caller of SCMI protocol library.
  * scmi_handle_put must be balanced with successful scmi_handle_get
  *
  * Return: 0 is successfully released
@@ -599,7 +598,7 @@ int scmi_handle_put(const struct scmi_handle *handle)
 }
 
 static const struct scmi_desc scmi_generic_desc = {
-       .max_rx_timeout_ms = 30,        /* we may increase this if required */
+       .max_rx_timeout_ms = 30,        /* We may increase this if required */
        .max_msg = 20,          /* Limited by MBOX_TX_QUEUE_LEN */
        .max_msg_size = 128,
 };
@@ -621,9 +620,9 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo)
        struct scmi_xfers_info *info = &sinfo->minfo;
 
        /* Pre-allocated messages, no more than what hdr.seq can support */
-       if (WARN_ON(desc->max_msg >= (MSG_TOKEN_ID_MASK + 1))) {
-               dev_err(dev, "Maximum message of %d exceeds supported %d\n",
-                       desc->max_msg, MSG_TOKEN_ID_MASK + 1);
+       if (WARN_ON(desc->max_msg >= MSG_TOKEN_MAX)) {
+               dev_err(dev, "Maximum message of %d exceeds supported %ld\n",
+                       desc->max_msg, MSG_TOKEN_MAX);
                return -EINVAL;
        }
 
@@ -637,8 +636,6 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo)
        if (!info->xfer_alloc_table)
                return -ENOMEM;
 
-       bitmap_zero(info->xfer_alloc_table, desc->max_msg);
-
        /* Pre-initialize the buffer pointer to pre-allocated buffers */
        for (i = 0, xfer = info->xfer_block; i < desc->max_msg; i++, xfer++) {
                xfer->rx.buf = devm_kcalloc(dev, sizeof(u8), desc->max_msg_size,
@@ -690,11 +687,12 @@ static int scmi_remove(struct platform_device *pdev)
                list_del(&info->node);
        mutex_unlock(&scmi_list_mutex);
 
-       if (!ret) {
-               /* Safe to free channels since no more users */
-               ret = idr_for_each(idr, scmi_mbox_free_channel, idr);
-               idr_destroy(&info->tx_idr);
-       }
+       if (ret)
+               return ret;
+
+       /* Safe to free channels since no more users */
+       ret = idr_for_each(idr, scmi_mbox_free_channel, idr);
+       idr_destroy(&info->tx_idr);
 
        return ret;
 }
@@ -841,7 +839,8 @@ static int scmi_probe(struct platform_device *pdev)
                if (of_property_read_u32(child, "reg", &prot_id))
                        continue;
 
-               prot_id &= MSG_PROTOCOL_ID_MASK;
+               if (!FIELD_FIT(MSG_PROTOCOL_ID_MASK, prot_id))
+                       dev_err(dev, "Out of range protocol %d\n", prot_id);
 
                if (!scmi_is_protocol_implemented(handle, prot_id)) {
                        dev_err(dev, "SCMI protocol %d not implemented\n",
index 987c64d198010962a492919905878b928334fb6d..2a219b1261b1c0f8b88612e7075d8b74a256a9e9 100644 (file)
@@ -115,7 +115,7 @@ static int scmi_perf_attributes_get(const struct scmi_handle *handle,
        struct scmi_xfer *t;
        struct scmi_msg_resp_perf_attributes *attr;
 
-       ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES,
+       ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES,
                                 SCMI_PROTOCOL_PERF, 0, sizeof(*attr), &t);
        if (ret)
                return ret;
@@ -133,7 +133,7 @@ static int scmi_perf_attributes_get(const struct scmi_handle *handle,
                pi->stats_size = le32_to_cpu(attr->stats_size);
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -145,7 +145,7 @@ scmi_perf_domain_attributes_get(const struct scmi_handle *handle, u32 domain,
        struct scmi_xfer *t;
        struct scmi_msg_resp_perf_domain_attributes *attr;
 
-       ret = scmi_one_xfer_init(handle, PERF_DOMAIN_ATTRIBUTES,
+       ret = scmi_xfer_get_init(handle, PERF_DOMAIN_ATTRIBUTES,
                                 SCMI_PROTOCOL_PERF, sizeof(domain),
                                 sizeof(*attr), &t);
        if (ret)
@@ -171,7 +171,7 @@ scmi_perf_domain_attributes_get(const struct scmi_handle *handle, u32 domain,
                memcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -194,7 +194,7 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain,
        struct scmi_msg_perf_describe_levels *dom_info;
        struct scmi_msg_resp_perf_describe_levels *level_info;
 
-       ret = scmi_one_xfer_init(handle, PERF_DESCRIBE_LEVELS,
+       ret = scmi_xfer_get_init(handle, PERF_DESCRIBE_LEVELS,
                                 SCMI_PROTOCOL_PERF, sizeof(*dom_info), 0, &t);
        if (ret)
                return ret;
@@ -237,7 +237,7 @@ scmi_perf_describe_levels_get(const struct scmi_handle *handle, u32 domain,
        } while (num_returned && num_remaining);
 
        perf_dom->opp_count = tot_opp_cnt;
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
 
        sort(perf_dom->opp, tot_opp_cnt, sizeof(*opp), opp_cmp_func, NULL);
        return ret;
@@ -250,7 +250,7 @@ static int scmi_perf_limits_set(const struct scmi_handle *handle, u32 domain,
        struct scmi_xfer *t;
        struct scmi_perf_set_limits *limits;
 
-       ret = scmi_one_xfer_init(handle, PERF_LIMITS_SET, SCMI_PROTOCOL_PERF,
+       ret = scmi_xfer_get_init(handle, PERF_LIMITS_SET, SCMI_PROTOCOL_PERF,
                                 sizeof(*limits), 0, &t);
        if (ret)
                return ret;
@@ -262,7 +262,7 @@ static int scmi_perf_limits_set(const struct scmi_handle *handle, u32 domain,
 
        ret = scmi_do_xfer(handle, t);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -273,7 +273,7 @@ static int scmi_perf_limits_get(const struct scmi_handle *handle, u32 domain,
        struct scmi_xfer *t;
        struct scmi_perf_get_limits *limits;
 
-       ret = scmi_one_xfer_init(handle, PERF_LIMITS_GET, SCMI_PROTOCOL_PERF,
+       ret = scmi_xfer_get_init(handle, PERF_LIMITS_GET, SCMI_PROTOCOL_PERF,
                                 sizeof(__le32), 0, &t);
        if (ret)
                return ret;
@@ -288,7 +288,7 @@ static int scmi_perf_limits_get(const struct scmi_handle *handle, u32 domain,
                *min_perf = le32_to_cpu(limits->min_level);
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -299,7 +299,7 @@ static int scmi_perf_level_set(const struct scmi_handle *handle, u32 domain,
        struct scmi_xfer *t;
        struct scmi_perf_set_level *lvl;
 
-       ret = scmi_one_xfer_init(handle, PERF_LEVEL_SET, SCMI_PROTOCOL_PERF,
+       ret = scmi_xfer_get_init(handle, PERF_LEVEL_SET, SCMI_PROTOCOL_PERF,
                                 sizeof(*lvl), 0, &t);
        if (ret)
                return ret;
@@ -311,7 +311,7 @@ static int scmi_perf_level_set(const struct scmi_handle *handle, u32 domain,
 
        ret = scmi_do_xfer(handle, t);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -321,7 +321,7 @@ static int scmi_perf_level_get(const struct scmi_handle *handle, u32 domain,
        int ret;
        struct scmi_xfer *t;
 
-       ret = scmi_one_xfer_init(handle, PERF_LEVEL_GET, SCMI_PROTOCOL_PERF,
+       ret = scmi_xfer_get_init(handle, PERF_LEVEL_GET, SCMI_PROTOCOL_PERF,
                                 sizeof(u32), sizeof(u32), &t);
        if (ret)
                return ret;
@@ -333,7 +333,7 @@ static int scmi_perf_level_get(const struct scmi_handle *handle, u32 domain,
        if (!ret)
                *level = le32_to_cpu(*(__le32 *)t->rx.buf);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -349,8 +349,8 @@ static int scmi_dev_domain_id(struct device *dev)
        return clkspec.args[0];
 }
 
-static int scmi_dvfs_add_opps_to_device(const struct scmi_handle *handle,
-                                       struct device *dev)
+static int scmi_dvfs_device_opps_add(const struct scmi_handle *handle,
+                                    struct device *dev)
 {
        int idx, ret, domain;
        unsigned long freq;
@@ -383,7 +383,7 @@ static int scmi_dvfs_add_opps_to_device(const struct scmi_handle *handle,
        return 0;
 }
 
-static int scmi_dvfs_get_transition_latency(const struct scmi_handle *handle,
+static int scmi_dvfs_transition_latency_get(const struct scmi_handle *handle,
                                            struct device *dev)
 {
        struct perf_dom_info *dom;
@@ -432,8 +432,8 @@ static struct scmi_perf_ops perf_ops = {
        .level_set = scmi_perf_level_set,
        .level_get = scmi_perf_level_get,
        .device_domain_id = scmi_dev_domain_id,
-       .get_transition_latency = scmi_dvfs_get_transition_latency,
-       .add_opps_to_device = scmi_dvfs_add_opps_to_device,
+       .transition_latency_get = scmi_dvfs_transition_latency_get,
+       .device_opps_add = scmi_dvfs_device_opps_add,
        .freq_set = scmi_dvfs_freq_set,
        .freq_get = scmi_dvfs_freq_get,
 };
index 087c2876cdf238aa9fc81921924f6fb71cbdc6bf..cfa033b05aed5e568b2510e2a7dace5162d13327 100644 (file)
@@ -63,7 +63,7 @@ static int scmi_power_attributes_get(const struct scmi_handle *handle,
        struct scmi_xfer *t;
        struct scmi_msg_resp_power_attributes *attr;
 
-       ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES,
+       ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES,
                                 SCMI_PROTOCOL_POWER, 0, sizeof(*attr), &t);
        if (ret)
                return ret;
@@ -78,7 +78,7 @@ static int scmi_power_attributes_get(const struct scmi_handle *handle,
                pi->stats_size = le32_to_cpu(attr->stats_size);
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -90,7 +90,7 @@ scmi_power_domain_attributes_get(const struct scmi_handle *handle, u32 domain,
        struct scmi_xfer *t;
        struct scmi_msg_resp_power_domain_attributes *attr;
 
-       ret = scmi_one_xfer_init(handle, POWER_DOMAIN_ATTRIBUTES,
+       ret = scmi_xfer_get_init(handle, POWER_DOMAIN_ATTRIBUTES,
                                 SCMI_PROTOCOL_POWER, sizeof(domain),
                                 sizeof(*attr), &t);
        if (ret)
@@ -109,7 +109,7 @@ scmi_power_domain_attributes_get(const struct scmi_handle *handle, u32 domain,
                memcpy(dom_info->name, attr->name, SCMI_MAX_STR_SIZE);
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -120,7 +120,7 @@ scmi_power_state_set(const struct scmi_handle *handle, u32 domain, u32 state)
        struct scmi_xfer *t;
        struct scmi_power_set_state *st;
 
-       ret = scmi_one_xfer_init(handle, POWER_STATE_SET, SCMI_PROTOCOL_POWER,
+       ret = scmi_xfer_get_init(handle, POWER_STATE_SET, SCMI_PROTOCOL_POWER,
                                 sizeof(*st), 0, &t);
        if (ret)
                return ret;
@@ -132,7 +132,7 @@ scmi_power_state_set(const struct scmi_handle *handle, u32 domain, u32 state)
 
        ret = scmi_do_xfer(handle, t);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -142,7 +142,7 @@ scmi_power_state_get(const struct scmi_handle *handle, u32 domain, u32 *state)
        int ret;
        struct scmi_xfer *t;
 
-       ret = scmi_one_xfer_init(handle, POWER_STATE_GET, SCMI_PROTOCOL_POWER,
+       ret = scmi_xfer_get_init(handle, POWER_STATE_GET, SCMI_PROTOCOL_POWER,
                                 sizeof(u32), sizeof(u32), &t);
        if (ret)
                return ret;
@@ -153,7 +153,7 @@ scmi_power_state_get(const struct scmi_handle *handle, u32 domain, u32 *state)
        if (!ret)
                *state = le32_to_cpu(*(__le32 *)t->rx.buf);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
index bbb469fea0ed1cebefb87defb0c34474a8a45b00..27f2092b9882aef307763e214eb74c69f4db2af5 100644 (file)
@@ -79,7 +79,7 @@ static int scmi_sensor_attributes_get(const struct scmi_handle *handle,
        struct scmi_xfer *t;
        struct scmi_msg_resp_sensor_attributes *attr;
 
-       ret = scmi_one_xfer_init(handle, PROTOCOL_ATTRIBUTES,
+       ret = scmi_xfer_get_init(handle, PROTOCOL_ATTRIBUTES,
                                 SCMI_PROTOCOL_SENSOR, 0, sizeof(*attr), &t);
        if (ret)
                return ret;
@@ -95,7 +95,7 @@ static int scmi_sensor_attributes_get(const struct scmi_handle *handle,
                si->reg_size = le32_to_cpu(attr->reg_size);
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -108,7 +108,7 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle,
        struct scmi_xfer *t;
        struct scmi_msg_resp_sensor_description *buf;
 
-       ret = scmi_one_xfer_init(handle, SENSOR_DESCRIPTION_GET,
+       ret = scmi_xfer_get_init(handle, SENSOR_DESCRIPTION_GET,
                                 SCMI_PROTOCOL_SENSOR, sizeof(__le32), 0, &t);
        if (ret)
                return ret;
@@ -150,7 +150,7 @@ static int scmi_sensor_description_get(const struct scmi_handle *handle,
                 */
        } while (num_returned && num_remaining);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -162,7 +162,7 @@ scmi_sensor_configuration_set(const struct scmi_handle *handle, u32 sensor_id)
        struct scmi_xfer *t;
        struct scmi_msg_set_sensor_config *cfg;
 
-       ret = scmi_one_xfer_init(handle, SENSOR_CONFIG_SET,
+       ret = scmi_xfer_get_init(handle, SENSOR_CONFIG_SET,
                                 SCMI_PROTOCOL_SENSOR, sizeof(*cfg), 0, &t);
        if (ret)
                return ret;
@@ -173,7 +173,7 @@ scmi_sensor_configuration_set(const struct scmi_handle *handle, u32 sensor_id)
 
        ret = scmi_do_xfer(handle, t);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -185,7 +185,7 @@ static int scmi_sensor_trip_point_set(const struct scmi_handle *handle,
        struct scmi_xfer *t;
        struct scmi_msg_set_sensor_trip_point *trip;
 
-       ret = scmi_one_xfer_init(handle, SENSOR_TRIP_POINT_SET,
+       ret = scmi_xfer_get_init(handle, SENSOR_TRIP_POINT_SET,
                                 SCMI_PROTOCOL_SENSOR, sizeof(*trip), 0, &t);
        if (ret)
                return ret;
@@ -198,7 +198,7 @@ static int scmi_sensor_trip_point_set(const struct scmi_handle *handle,
 
        ret = scmi_do_xfer(handle, t);
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
@@ -209,7 +209,7 @@ static int scmi_sensor_reading_get(const struct scmi_handle *handle,
        struct scmi_xfer *t;
        struct scmi_msg_sensor_reading_get *sensor;
 
-       ret = scmi_one_xfer_init(handle, SENSOR_READING_GET,
+       ret = scmi_xfer_get_init(handle, SENSOR_READING_GET,
                                 SCMI_PROTOCOL_SENSOR, sizeof(*sensor),
                                 sizeof(u64), &t);
        if (ret)
@@ -227,7 +227,7 @@ static int scmi_sensor_reading_get(const struct scmi_handle *handle,
                *value |= (u64)le32_to_cpu(*(pval + 1)) << 32;
        }
 
-       scmi_one_xfer_put(handle, t);
+       scmi_xfer_put(handle, t);
        return ret;
 }
 
index 6d7a6c0a5e07ab67997a337b7c1f5ac7c1d978a9..c7d06a36b23a5670f4e2ddbe339698e38bce5796 100644 (file)
@@ -890,7 +890,7 @@ static int scpi_alloc_xfer_list(struct device *dev, struct scpi_chan *ch)
        int i;
        struct scpi_xfer *xfers;
 
-       xfers = devm_kzalloc(dev, MAX_SCPI_XFERS * sizeof(*xfers), GFP_KERNEL);
+       xfers = devm_kcalloc(dev, MAX_SCPI_XFERS, sizeof(*xfers), GFP_KERNEL);
        if (!xfers)
                return -ENOMEM;
 
index 0b631e5b5b843f158ea675f0cd86a081fa541729..d25f080fcb0d84d13d18ed9c7dab815cc9e36c0d 100644 (file)
@@ -36,7 +36,7 @@ struct nvram_header {
 
 static char nvram_buf[NVRAM_SPACE];
 static size_t nvram_len;
-static const u32 nvram_sizes[] = {0x8000, 0xF000, 0x10000};
+static const u32 nvram_sizes[] = {0x6000, 0x8000, 0xF000, 0x10000};
 
 static u32 find_nvram_size(void __iomem *end)
 {
index 2f452f1f7c8a09c2f5cd1cdfcf07aa3751b808e0..fb8af5cb7c9bffef3f4446baf2e94045685e6f3e 100644 (file)
@@ -146,7 +146,7 @@ static int create_packet(void *data, size_t length)
        packet_array_size = max(
                        (unsigned int)(allocation_floor / rbu_data.packetsize),
                        (unsigned int)1);
-       invalid_addr_packet_array = kzalloc(packet_array_size * sizeof(void*),
+       invalid_addr_packet_array = kcalloc(packet_array_size, sizeof(void *),
                                                GFP_KERNEL);
 
        if (!invalid_addr_packet_array) {
index 80d1a885def5c2dd8bd15591bcc7c62d9b2e3b8c..b5214c143feedac6f0bd81f4abbe4e60554648dc 100644 (file)
@@ -193,7 +193,7 @@ static __init void reserve_regions(void)
         * uses its own memory map instead.
         */
        memblock_dump_all();
-       memblock_remove(0, (phys_addr_t)ULLONG_MAX);
+       memblock_remove(0, PHYS_ADDR_MAX);
 
        for_each_efi_memory_desc(md) {
                paddr = md->phys_addr;
index 901b9306bf94a1195e35ccc2d869467327009e7d..4938c29b7c5dced7538763a4b1063355ed748deb 100644 (file)
@@ -231,7 +231,7 @@ int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages)
        count = DIV_ROUND_UP(imagesize, PAGE_SIZE);
        sg_count = sg_pages_num(count);
 
-       sg_pages = kzalloc(sg_count * sizeof(*sg_pages), GFP_KERNEL);
+       sg_pages = kcalloc(sg_count, sizeof(*sg_pages), GFP_KERNEL);
        if (!sg_pages)
                return -ENOMEM;
 
index 5a0fa939d70f961a998317cb88c8ee4705e1065f..cfe87b465819f8ef42d0da6a60ca2a2294433ab7 100644 (file)
@@ -28,10 +28,9 @@ static int efi_pstore_close(struct pstore_info *psi)
        return 0;
 }
 
-static inline u64 generic_id(unsigned long timestamp,
-                            unsigned int part, int count)
+static inline u64 generic_id(u64 timestamp, unsigned int part, int count)
 {
-       return ((u64) timestamp * 100 + part) * 1000 + count;
+       return (timestamp * 100 + part) * 1000 + count;
 }
 
 static int efi_pstore_read_func(struct efivar_entry *entry,
@@ -42,7 +41,8 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
        int i;
        int cnt;
        unsigned int part;
-       unsigned long time, size;
+       unsigned long size;
+       u64 time;
 
        if (efi_guidcmp(entry->var.VendorGuid, vendor))
                return 0;
@@ -50,7 +50,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
        for (i = 0; i < DUMP_NAME_LEN; i++)
                name[i] = entry->var.VariableName[i];
 
-       if (sscanf(name, "dump-type%u-%u-%d-%lu-%c",
+       if (sscanf(name, "dump-type%u-%u-%d-%llu-%c",
                   &record->type, &part, &cnt, &time, &data_type) == 5) {
                record->id = generic_id(time, part, cnt);
                record->part = part;
@@ -62,7 +62,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
                else
                        record->compressed = false;
                record->ecc_notice_size = 0;
-       } else if (sscanf(name, "dump-type%u-%u-%d-%lu",
+       } else if (sscanf(name, "dump-type%u-%u-%d-%llu",
                   &record->type, &part, &cnt, &time) == 4) {
                record->id = generic_id(time, part, cnt);
                record->part = part;
@@ -71,7 +71,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry,
                record->time.tv_nsec = 0;
                record->compressed = false;
                record->ecc_notice_size = 0;
-       } else if (sscanf(name, "dump-type%u-%u-%lu",
+       } else if (sscanf(name, "dump-type%u-%u-%llu",
                          &record->type, &part, &time) == 3) {
                /*
                 * Check if an old format,
@@ -250,9 +250,10 @@ static int efi_pstore_write(struct pstore_record *record)
        /* Since we copy the entire length of name, make sure it is wiped. */
        memset(name, 0, sizeof(name));
 
-       snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu-%c",
+       snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lld-%c",
                 record->type, record->part, record->count,
-                record->time.tv_sec, record->compressed ? 'C' : 'D');
+                (long long)record->time.tv_sec,
+                record->compressed ? 'C' : 'D');
 
        for (i = 0; i < DUMP_NAME_LEN; i++)
                efi_name[i] = name[i];
@@ -327,15 +328,15 @@ static int efi_pstore_erase(struct pstore_record *record)
        char name[DUMP_NAME_LEN];
        int ret;
 
-       snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lu",
+       snprintf(name, sizeof(name), "dump-type%u-%u-%d-%lld",
                 record->type, record->part, record->count,
-                record->time.tv_sec);
+                (long long)record->time.tv_sec);
        ret = efi_pstore_erase_name(name);
        if (ret != -ENOENT)
                return ret;
 
-       snprintf(name, sizeof(name), "dump-type%u-%u-%lu",
-               record->type, record->part, record->time.tv_sec);
+       snprintf(name, sizeof(name), "dump-type%u-%u-%lld",
+               record->type, record->part, (long long)record->time.tv_sec);
        ret = efi_pstore_erase_name(name);
 
        return ret;
index f377609ff141bca733bf498babc25f9d215aefad..84a11d0a8023c28fe38de99671ee9142c89f7d30 100644 (file)
@@ -166,7 +166,7 @@ int __init efi_runtime_map_init(struct kobject *efi_kobj)
        if (!efi_enabled(EFI_MEMMAP))
                return 0;
 
-       map_entries = kzalloc(efi.memmap.nr_map * sizeof(entry), GFP_KERNEL);
+       map_entries = kcalloc(efi.memmap.nr_map, sizeof(entry), GFP_KERNEL);
        if (!map_entries) {
                ret = -ENOMEM;
                goto out;
index 5a7d693009ef4482f8db5ce13512aa62bf19be73..e778af766fae3c2c88d20e8f7ae6f47f9114935c 100644 (file)
@@ -603,6 +603,9 @@ static const struct of_device_id qcom_scm_dt_match[] = {
        { .compatible = "qcom,scm-msm8996",
          .data = NULL, /* no clocks */
        },
+       { .compatible = "qcom,scm-ipq4019",
+         .data = NULL, /* no clocks */
+       },
        { .compatible = "qcom,scm",
          .data = (void *)(SCM_HAS_CORE_CLK
                           | SCM_HAS_IFACE_CLK
index 5229036dcfbfc3ca8cb1065d636950e5d9e80a3b..7fa744793bc5c900eb5d6998848aba233bd1875f 100644 (file)
@@ -1,17 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Texas Instruments System Control Interface Protocol Driver
  *
  * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
  *     Nishanth Menon
- *
- * 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 "as is" WITHOUT ANY WARRANTY of any
- * kind, whether express or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #define pr_fmt(fmt) "%s: " fmt, __func__
@@ -1862,9 +1854,9 @@ static int ti_sci_probe(struct platform_device *pdev)
        if (!minfo->xfer_block)
                return -ENOMEM;
 
-       minfo->xfer_alloc_table = devm_kzalloc(dev,
-                                              BITS_TO_LONGS(desc->max_msgs)
-                                              sizeof(unsigned long),
+       minfo->xfer_alloc_table = devm_kcalloc(dev,
+                                              BITS_TO_LONGS(desc->max_msgs),
+                                              sizeof(unsigned long),
                                               GFP_KERNEL);
        if (!minfo->xfer_alloc_table)
                return -ENOMEM;
index 9b611e9e6f6dcddcaa0a9f3d95f9b1dc6965ae87..12bf316b68df768e5a0cca377623d89b30fda118 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: BSD-3-Clause
 /*
  * Texas Instruments System Control Interface (TISCI) Protocol
  *
@@ -6,35 +7,6 @@
  * See: http://processors.wiki.ti.com/index.php/TISCI for details
  *
  * Copyright (C)  2015-2016 Texas Instruments Incorporated - http://www.ti.com/
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *   Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- *
- *   Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the
- *   distribution.
- *
- *   Neither the name of Texas Instruments Incorporated nor the names of
- *   its contributors may 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.
- *
  */
 
 #ifndef __TI_SCI_H
index ffdc1762b580cdd5dcdff5af12372c247abae8fc..d0e65b86dc22fd364403fa45bf8804ddf94f9323 100644 (file)
@@ -48,8 +48,8 @@ static struct sdb_array *__fmc_scan_sdb_tree(struct fmc_device *fmc,
        arr = kzalloc(sizeof(*arr), GFP_KERNEL);
        if (!arr)
                return ERR_PTR(-ENOMEM);
-       arr->record = kzalloc(sizeof(arr->record[0]) * n, GFP_KERNEL);
-       arr->subtree = kzalloc(sizeof(arr->subtree[0]) * n, GFP_KERNEL);
+       arr->record = kcalloc(n, sizeof(arr->record[0]), GFP_KERNEL);
+       arr->subtree = kcalloc(n, sizeof(arr->subtree[0]), GFP_KERNEL);
        if (!arr->record || !arr->subtree) {
                kfree(arr->record);
                kfree(arr->subtree);
index 44c09904daa6adcbd261333986e4c09fbb627fc0..91b90c0cea731778bd524a13d801433e7df0a2ab 100644 (file)
@@ -427,7 +427,7 @@ static int adnp_irq_setup(struct adnp *adnp)
         * is chosen to match the register layout of the hardware in that
         * each segment contains the corresponding bits for all interrupts.
         */
-       adnp->irq_enable = devm_kzalloc(chip->parent, num_regs * 6,
+       adnp->irq_enable = devm_kcalloc(chip->parent, num_regs, 6,
                                        GFP_KERNEL);
        if (!adnp->irq_enable)
                return -ENOMEM;
index 5e89f1c74a3398b6fb8337b63f29f5e4ad4c1264..b31ae16170e77fbfea0bcee1dd4525a859ffe83b 100644 (file)
@@ -897,8 +897,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
 
        /* Allocate a cache of the output registers */
        banks = gpio->config->nr_gpios >> 5;
-       gpio->dcache = devm_kzalloc(&pdev->dev,
-                                   sizeof(u32) * banks, GFP_KERNEL);
+       gpio->dcache = devm_kcalloc(&pdev->dev,
+                                   banks, sizeof(u32), GFP_KERNEL);
        if (!gpio->dcache)
                return -ENOMEM;
 
index eb8369b21e9074d65599c1cafbc37e05a35e12d9..00272fa7cc4faa3d64d3cacbd887b3c0b814aee2 100644 (file)
@@ -601,9 +601,10 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev)
                        GPIO_MAX_BANK_NUM);
                return -ENXIO;
        }
-       kona_gpio->banks = devm_kzalloc(dev,
-                                       kona_gpio->num_bank *
-                                       sizeof(*kona_gpio->banks), GFP_KERNEL);
+       kona_gpio->banks = devm_kcalloc(dev,
+                                       kona_gpio->num_bank,
+                                       sizeof(*kona_gpio->banks),
+                                       GFP_KERNEL);
        if (!kona_gpio->banks)
                return -ENOMEM;
 
index b574ecff7761696d63bd2fc613c07238098fc441..035a454eca43b5534e9b8ef5e60c7d82ad44a0ca 100644 (file)
@@ -198,8 +198,8 @@ static int davinci_gpio_probe(struct platform_device *pdev)
                ngpio = ARCH_NR_GPIOS;
 
        nbank = DIV_ROUND_UP(ngpio, 32);
-       chips = devm_kzalloc(dev,
-                            nbank * sizeof(struct davinci_gpio_controller),
+       chips = devm_kcalloc(dev,
+                            nbank, sizeof(struct davinci_gpio_controller),
                             GFP_KERNEL);
        if (!chips)
                return -ENOMEM;
index 5163839349453115708eea5346d842d6a526ed81..ad6e5b5186691b01ed7cd301acc6a95985c41933 100644 (file)
@@ -321,8 +321,8 @@ static int __init egpio_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, ei);
 
        ei->nchips = pdata->num_chips;
-       ei->chip = devm_kzalloc(&pdev->dev,
-                               sizeof(struct egpio_chip) * ei->nchips,
+       ei->chip = devm_kcalloc(&pdev->dev,
+                               ei->nchips, sizeof(struct egpio_chip),
                                GFP_KERNEL);
        if (!ei->chip) {
                ret = -ENOMEM;
index e2bee27eb526d172be23be709a36be84604d7eac..b23d9a36be1f40e2296a5c9131539e47eeab5bc3 100644 (file)
@@ -443,7 +443,7 @@ static int ioh_gpio_probe(struct pci_dev *pdev,
                goto err_iomap;
        }
 
-       chip_save = kzalloc(sizeof(*chip) * 8, GFP_KERNEL);
+       chip_save = kcalloc(8, sizeof(*chip), GFP_KERNEL);
        if (chip_save == NULL) {
                ret = -ENOMEM;
                goto err_kzalloc;
index d16e9d4a129bdd86874305d3d443b9eed9f9df7f..1306722faa5aa5ff727752f153803200d7f476e8 100644 (file)
@@ -504,16 +504,17 @@ static int thunderx_gpio_probe(struct pci_dev *pdev,
                txgpio->base_msi = (c >> 8) & 0xff;
        }
 
-       txgpio->msix_entries = devm_kzalloc(dev,
-                                         sizeof(struct msix_entry) * ngpio,
+       txgpio->msix_entries = devm_kcalloc(dev,
+                                         ngpio, sizeof(struct msix_entry),
                                          GFP_KERNEL);
        if (!txgpio->msix_entries) {
                err = -ENOMEM;
                goto out;
        }
 
-       txgpio->line_entries = devm_kzalloc(dev,
-                                           sizeof(struct thunderx_line) * ngpio,
+       txgpio->line_entries = devm_kcalloc(dev,
+                                           ngpio,
+                                           sizeof(struct thunderx_line),
                                            GFP_KERNEL);
        if (!txgpio->line_entries) {
                err = -ENOMEM;
index 428e5eb3444f0a6c6679802ed1666c23d6fb35b1..f4c474a9587510ed844ae7ec275b8b73c7695572 100644 (file)
@@ -310,20 +310,20 @@ static int acp_hw_init(void *handle)
                pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false);
        }
 
-       adev->acp.acp_cell = kzalloc(sizeof(struct mfd_cell) * ACP_DEVS,
+       adev->acp.acp_cell = kcalloc(ACP_DEVS, sizeof(struct mfd_cell),
                                                        GFP_KERNEL);
 
        if (adev->acp.acp_cell == NULL)
                return -ENOMEM;
 
-       adev->acp.acp_res = kzalloc(sizeof(struct resource) * 4, GFP_KERNEL);
+       adev->acp.acp_res = kcalloc(4, sizeof(struct resource), GFP_KERNEL);
 
        if (adev->acp.acp_res == NULL) {
                kfree(adev->acp.acp_cell);
                return -ENOMEM;
        }
 
-       i2s_pdata = kzalloc(sizeof(struct i2s_platform_data) * 2, GFP_KERNEL);
+       i2s_pdata = kcalloc(2, sizeof(struct i2s_platform_data), GFP_KERNEL);
        if (i2s_pdata == NULL) {
                kfree(adev->acp.acp_res);
                kfree(adev->acp.acp_cell);
index 8f6f45567bfa16d28602f39ed6f1f922e7e29f7f..305143fcc1ceed0d1231efa742864de460b608d0 100644 (file)
@@ -342,15 +342,12 @@ void get_local_mem_info(struct kgd_dev *kgd,
                        mem_info->local_mem_size_public,
                        mem_info->local_mem_size_private);
 
-       if (amdgpu_emu_mode == 1) {
-               mem_info->mem_clk_max = 100;
-               return;
-       }
-
        if (amdgpu_sriov_vf(adev))
                mem_info->mem_clk_max = adev->clock.default_mclk / 100;
-       else
+       else if (adev->powerplay.pp_funcs)
                mem_info->mem_clk_max = amdgpu_dpm_get_mclk(adev, false) / 100;
+       else
+               mem_info->mem_clk_max = 100;
 }
 
 uint64_t get_gpu_clock_counter(struct kgd_dev *kgd)
@@ -367,13 +364,12 @@ uint32_t get_max_engine_clock_in_mhz(struct kgd_dev *kgd)
        struct amdgpu_device *adev = (struct amdgpu_device *)kgd;
 
        /* the sclk is in quantas of 10kHz */
-       if (amdgpu_emu_mode == 1)
-               return 100;
-
        if (amdgpu_sriov_vf(adev))
                return adev->clock.default_sclk / 100;
-
-       return amdgpu_dpm_get_sclk(adev, false) / 100;
+       else if (adev->powerplay.pp_funcs)
+               return amdgpu_dpm_get_sclk(adev, false) / 100;
+       else
+               return 100;
 }
 
 void get_cu_info(struct kgd_dev *kgd, struct kfd_cu_info *cu_info)
index 0ff36d45a59700162211da3af89091114d2dd0a2..ea79908dac4cbcae178b5398b69aee12f4377ea8 100644 (file)
@@ -407,7 +407,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd,
                (*dump)[i++][1] = RREG32(addr);         \
        } while (0)
 
-       *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
+       *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
        if (*dump == NULL)
                return -ENOMEM;
 
@@ -504,7 +504,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd,
 #undef HQD_N_REGS
 #define HQD_N_REGS (19+4)
 
-       *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
+       *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
        if (*dump == NULL)
                return -ENOMEM;
 
index 6ef9762b4b007beeb9a26c8de0bd2fc6f02fc139..19dd665e7307130c0d7a8993815d249f3809cade 100644 (file)
@@ -395,7 +395,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd,
                (*dump)[i++][1] = RREG32(addr);         \
        } while (0)
 
-       *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
+       *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
        if (*dump == NULL)
                return -ENOMEM;
 
@@ -491,7 +491,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd,
 #undef HQD_N_REGS
 #define HQD_N_REGS (19+4+2+3+7)
 
-       *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
+       *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
        if (*dump == NULL)
                return -ENOMEM;
 
index f0c0d3953f6989496a6beab4da5053808892dd4e..1db60aa5b7f0eab0c012cc41af2181bb678a7813 100644 (file)
@@ -504,7 +504,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd,
                (*dump)[i++][1] = RREG32(addr);         \
        } while (0)
 
-       *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
+       *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
        if (*dump == NULL)
                return -ENOMEM;
 
@@ -606,7 +606,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd,
 #undef HQD_N_REGS
 #define HQD_N_REGS (19+6+7+10)
 
-       *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
+       *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
        if (*dump == NULL)
                return -ENOMEM;
 
index 1bcb2b2473357809e161bb081ce9a362729cd56d..daa06e7c5bb73e2d4073fad2177bf50eee0be006 100644 (file)
@@ -569,7 +569,6 @@ static const struct amdgpu_px_quirk amdgpu_px_quirk_list[] = {
        { 0x1002, 0x6900, 0x1002, 0x0124, AMDGPU_PX_QUIRK_FORCE_ATPX },
        { 0x1002, 0x6900, 0x1028, 0x0812, AMDGPU_PX_QUIRK_FORCE_ATPX },
        { 0x1002, 0x6900, 0x1028, 0x0813, AMDGPU_PX_QUIRK_FORCE_ATPX },
-       { 0x1002, 0x67DF, 0x1028, 0x0774, AMDGPU_PX_QUIRK_FORCE_ATPX },
        { 0, 0, 0, 0, 0 },
 };
 
index 9c1d491d742e095c24b9cff843cb9830c3d67753..82312a7bc6ad5b5a01e232b350f23ac889f47ed7 100644 (file)
@@ -522,6 +522,9 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
        struct amdgpu_bo_list_entry *e;
        struct list_head duplicates;
        unsigned i, tries = 10;
+       struct amdgpu_bo *gds;
+       struct amdgpu_bo *gws;
+       struct amdgpu_bo *oa;
        int r;
 
        INIT_LIST_HEAD(&p->validated);
@@ -652,31 +655,36 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
 
        amdgpu_cs_report_moved_bytes(p->adev, p->bytes_moved,
                                     p->bytes_moved_vis);
+
        if (p->bo_list) {
-               struct amdgpu_bo *gds = p->bo_list->gds_obj;
-               struct amdgpu_bo *gws = p->bo_list->gws_obj;
-               struct amdgpu_bo *oa = p->bo_list->oa_obj;
                struct amdgpu_vm *vm = &fpriv->vm;
                unsigned i;
 
+               gds = p->bo_list->gds_obj;
+               gws = p->bo_list->gws_obj;
+               oa = p->bo_list->oa_obj;
                for (i = 0; i < p->bo_list->num_entries; i++) {
                        struct amdgpu_bo *bo = p->bo_list->array[i].robj;
 
                        p->bo_list->array[i].bo_va = amdgpu_vm_bo_find(vm, bo);
                }
+       } else {
+               gds = p->adev->gds.gds_gfx_bo;
+               gws = p->adev->gds.gws_gfx_bo;
+               oa = p->adev->gds.oa_gfx_bo;
+       }
 
-               if (gds) {
-                       p->job->gds_base = amdgpu_bo_gpu_offset(gds);
-                       p->job->gds_size = amdgpu_bo_size(gds);
-               }
-               if (gws) {
-                       p->job->gws_base = amdgpu_bo_gpu_offset(gws);
-                       p->job->gws_size = amdgpu_bo_size(gws);
-               }
-               if (oa) {
-                       p->job->oa_base = amdgpu_bo_gpu_offset(oa);
-                       p->job->oa_size = amdgpu_bo_size(oa);
-               }
+       if (gds) {
+               p->job->gds_base = amdgpu_bo_gpu_offset(gds);
+               p->job->gds_size = amdgpu_bo_size(gds);
+       }
+       if (gws) {
+               p->job->gws_base = amdgpu_bo_gpu_offset(gws);
+               p->job->gws_size = amdgpu_bo_size(gws);
+       }
+       if (oa) {
+               p->job->oa_base = amdgpu_bo_gpu_offset(oa);
+               p->job->oa_size = amdgpu_bo_size(oa);
        }
 
        if (!r && p->uf_entry.robj) {
index 290e279abf0dcc862b636025ee48d256fb737f02..3317d1536f4fc352247756e3c650d72c9236916b 100644 (file)
@@ -1730,6 +1730,18 @@ static int amdgpu_device_ip_late_set_cg_state(struct amdgpu_device *adev)
                        }
                }
        }
+
+       if (adev->powerplay.pp_feature & PP_GFXOFF_MASK) {
+               /* enable gfx powergating */
+               amdgpu_device_ip_set_powergating_state(adev,
+                                                      AMD_IP_BLOCK_TYPE_GFX,
+                                                      AMD_PG_STATE_GATE);
+               /* enable gfxoff */
+               amdgpu_device_ip_set_powergating_state(adev,
+                                                      AMD_IP_BLOCK_TYPE_SMC,
+                                                      AMD_PG_STATE_GATE);
+       }
+
        return 0;
 }
 
index def1010ac05e43ea8bcf6739310e66b4e6490ec8..77ad59ade85ca79b56d352608e96fde4395ece99 100644 (file)
@@ -452,7 +452,7 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev)
                        ATOM_PPLIB_PhaseSheddingLimits_Record *entry;
 
                        adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries =
-                               kzalloc(psl->ucNumEntries *
+                               kcalloc(psl->ucNumEntries,
                                        sizeof(struct amdgpu_phase_shedding_limits_entry),
                                        GFP_KERNEL);
                        if (!adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) {
index 17d6b9fb6d776791813ada797921690b25c51e60..dd11b7313ca07b960867bb305f3174513b374e9c 100644 (file)
@@ -369,7 +369,8 @@ int amdgpu_gart_init(struct amdgpu_device *adev)
 
 #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
        /* Allocate pages table */
-       adev->gart.pages = vzalloc(sizeof(void *) * adev->gart.num_cpu_pages);
+       adev->gart.pages = vzalloc(array_size(sizeof(void *),
+                                             adev->gart.num_cpu_pages));
        if (adev->gart.pages == NULL)
                return -ENOMEM;
 #endif
index 2c8e27370284d53f3b4a440e637ba93759c7a49c..5fb156a01774ea5d245348f6e4341dfba5ca76aa 100644 (file)
@@ -30,6 +30,7 @@
 #include <drm/drmP.h>
 #include <drm/amdgpu_drm.h>
 #include "amdgpu.h"
+#include "amdgpu_display.h"
 
 void amdgpu_gem_object_free(struct drm_gem_object *gobj)
 {
@@ -235,6 +236,13 @@ int amdgpu_gem_create_ioctl(struct drm_device *dev, void *data,
        /* create a gem object to contain this object in */
        if (args->in.domains & (AMDGPU_GEM_DOMAIN_GDS |
            AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)) {
+               if (flags & AMDGPU_GEM_CREATE_VM_ALWAYS_VALID) {
+                       /* if gds bo is created from user space, it must be
+                        * passed to bo list
+                        */
+                       DRM_ERROR("GDS bo cannot be per-vm-bo\n");
+                       return -EINVAL;
+               }
                flags |= AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
                if (args->in.domains == AMDGPU_GEM_DOMAIN_GDS)
                        size = size << AMDGPU_GDS_SHIFT;
@@ -749,15 +757,16 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
        struct amdgpu_device *adev = dev->dev_private;
        struct drm_gem_object *gobj;
        uint32_t handle;
+       u32 domain;
        int r;
 
        args->pitch = amdgpu_align_pitch(adev, args->width,
                                         DIV_ROUND_UP(args->bpp, 8), 0);
        args->size = (u64)args->pitch * args->height;
        args->size = ALIGN(args->size, PAGE_SIZE);
-
-       r = amdgpu_gem_object_create(adev, args->size, 0,
-                                    AMDGPU_GEM_DOMAIN_VRAM,
+       domain = amdgpu_bo_get_preferred_pin_domain(adev,
+                               amdgpu_display_supported_domains(adev));
+       r = amdgpu_gem_object_create(adev, args->size, 0, domain,
                                     AMDGPU_GEM_CREATE_CPU_ACCESS_REQUIRED,
                                     false, NULL, &gobj);
        if (r)
index 6a9e46ae7f0a460cc47ebf443f6098c7362965d8..5e4e1bd9038379fe62666e44318162adfc544fea 100644 (file)
@@ -703,11 +703,7 @@ int amdgpu_bo_pin_restricted(struct amdgpu_bo *bo, u32 domain,
        /* This assumes only APU display buffers are pinned with (VRAM|GTT).
         * See function amdgpu_display_supported_domains()
         */
-       if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
-               domain = AMDGPU_GEM_DOMAIN_VRAM;
-               if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
-                       domain = AMDGPU_GEM_DOMAIN_GTT;
-       }
+       domain = amdgpu_bo_get_preferred_pin_domain(adev, domain);
 
        if (bo->pin_count) {
                uint32_t mem_type = bo->tbo.mem.mem_type;
@@ -1066,3 +1062,14 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)
 
        return bo->tbo.offset;
 }
+
+uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev,
+                                           uint32_t domain)
+{
+       if (domain == (AMDGPU_GEM_DOMAIN_VRAM | AMDGPU_GEM_DOMAIN_GTT)) {
+               domain = AMDGPU_GEM_DOMAIN_VRAM;
+               if (adev->gmc.real_vram_size <= AMDGPU_SG_THRESHOLD)
+                       domain = AMDGPU_GEM_DOMAIN_GTT;
+       }
+       return domain;
+}
index 540e03fa159f4b6c1025bdbb22e8749af33c2bbd..731748033878b35a32f70a6fe4eda9d0d44835cb 100644 (file)
@@ -289,7 +289,8 @@ int amdgpu_bo_restore_from_shadow(struct amdgpu_device *adev,
                                  struct reservation_object *resv,
                                  struct dma_fence **fence,
                                  bool direct);
-
+uint32_t amdgpu_bo_get_preferred_pin_domain(struct amdgpu_device *adev,
+                                           uint32_t domain);
 
 /*
  * sub allocation
index d167e8ab76d305e0878d2b6ac31357d4ba18520c..e3878256743a22281a7d11b9b9ec21369aeaea09 100644 (file)
@@ -53,7 +53,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
                n -= adev->irq.ih.ring_size;
        n /= size;
 
-       gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL);
+       gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
        if (!gtt_obj) {
                DRM_ERROR("Failed to allocate %d pointers\n", n);
                r = 1;
index 8851bcdfc2609f28a43ac27322bc3ff957a7a942..127e87b470ff4da368c8c1feb0576f0b6cb0c62c 100644 (file)
@@ -49,8 +49,6 @@ static void amdgpu_vcn_idle_work_handler(struct work_struct *work);
 
 int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
 {
-       struct amdgpu_ring *ring;
-       struct drm_sched_rq *rq;
        unsigned long bo_size;
        const char *fw_name;
        const struct common_firmware_header *hdr;
@@ -84,6 +82,7 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
        }
 
        hdr = (const struct common_firmware_header *)adev->vcn.fw->data;
+       adev->vcn.fw_version = le32_to_cpu(hdr->ucode_version);
        family_id = le32_to_cpu(hdr->ucode_version) & 0xff;
        version_major = (le32_to_cpu(hdr->ucode_version) >> 24) & 0xff;
        version_minor = (le32_to_cpu(hdr->ucode_version) >> 8) & 0xff;
@@ -102,24 +101,6 @@ int amdgpu_vcn_sw_init(struct amdgpu_device *adev)
                return r;
        }
 
-       ring = &adev->vcn.ring_dec;
-       rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL];
-       r = drm_sched_entity_init(&ring->sched, &adev->vcn.entity_dec,
-                                 rq, NULL);
-       if (r != 0) {
-               DRM_ERROR("Failed setting up VCN dec run queue.\n");
-               return r;
-       }
-
-       ring = &adev->vcn.ring_enc[0];
-       rq = &ring->sched.sched_rq[DRM_SCHED_PRIORITY_NORMAL];
-       r = drm_sched_entity_init(&ring->sched, &adev->vcn.entity_enc,
-                                 rq, NULL);
-       if (r != 0) {
-               DRM_ERROR("Failed setting up VCN enc run queue.\n");
-               return r;
-       }
-
        return 0;
 }
 
@@ -129,10 +110,6 @@ int amdgpu_vcn_sw_fini(struct amdgpu_device *adev)
 
        kfree(adev->vcn.saved_bo);
 
-       drm_sched_entity_fini(&adev->vcn.ring_dec.sched, &adev->vcn.entity_dec);
-
-       drm_sched_entity_fini(&adev->vcn.ring_enc[0].sched, &adev->vcn.entity_enc);
-
        amdgpu_bo_free_kernel(&adev->vcn.vcpu_bo,
                              &adev->vcn.gpu_addr,
                              (void **)&adev->vcn.cpu_addr);
@@ -278,7 +255,7 @@ int amdgpu_vcn_dec_ring_test_ring(struct amdgpu_ring *ring)
 }
 
 static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
-                                  struct amdgpu_bo *bo, bool direct,
+                                  struct amdgpu_bo *bo,
                                   struct dma_fence **fence)
 {
        struct amdgpu_device *adev = ring->adev;
@@ -306,19 +283,12 @@ static int amdgpu_vcn_dec_send_msg(struct amdgpu_ring *ring,
        }
        ib->length_dw = 16;
 
-       if (direct) {
-               r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f);
-               job->fence = dma_fence_get(f);
-               if (r)
-                       goto err_free;
+       r = amdgpu_ib_schedule(ring, 1, ib, NULL, &f);
+       job->fence = dma_fence_get(f);
+       if (r)
+               goto err_free;
 
-               amdgpu_job_free(job);
-       } else {
-               r = amdgpu_job_submit(job, ring, &adev->vcn.entity_dec,
-                                     AMDGPU_FENCE_OWNER_UNDEFINED, &f);
-               if (r)
-                       goto err_free;
-       }
+       amdgpu_job_free(job);
 
        amdgpu_bo_fence(bo, f, false);
        amdgpu_bo_unreserve(bo);
@@ -370,11 +340,11 @@ static int amdgpu_vcn_dec_get_create_msg(struct amdgpu_ring *ring, uint32_t hand
        for (i = 14; i < 1024; ++i)
                msg[i] = cpu_to_le32(0x0);
 
-       return amdgpu_vcn_dec_send_msg(ring, bo, true, fence);
+       return amdgpu_vcn_dec_send_msg(ring, bo, fence);
 }
 
 static int amdgpu_vcn_dec_get_destroy_msg(struct amdgpu_ring *ring, uint32_t handle,
-                              bool direct, struct dma_fence **fence)
+                              struct dma_fence **fence)
 {
        struct amdgpu_device *adev = ring->adev;
        struct amdgpu_bo *bo = NULL;
@@ -396,7 +366,7 @@ static int amdgpu_vcn_dec_get_destroy_msg(struct amdgpu_ring *ring, uint32_t han
        for (i = 6; i < 1024; ++i)
                msg[i] = cpu_to_le32(0x0);
 
-       return amdgpu_vcn_dec_send_msg(ring, bo, direct, fence);
+       return amdgpu_vcn_dec_send_msg(ring, bo, fence);
 }
 
 int amdgpu_vcn_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout)
@@ -410,7 +380,7 @@ int amdgpu_vcn_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout)
                goto error;
        }
 
-       r = amdgpu_vcn_dec_get_destroy_msg(ring, 1, true, &fence);
+       r = amdgpu_vcn_dec_get_destroy_msg(ring, 1, &fence);
        if (r) {
                DRM_ERROR("amdgpu: failed to get destroy ib (%ld).\n", r);
                goto error;
index 181e6afa984727b42bfa83c3d7e7895c34d718b5..773010b9ff153f89aaa5747df5dc09b07baa8cd7 100644 (file)
@@ -67,8 +67,6 @@ struct amdgpu_vcn {
        struct amdgpu_ring      ring_dec;
        struct amdgpu_ring      ring_enc[AMDGPU_VCN_MAX_ENC_RINGS];
        struct amdgpu_irq_src   irq;
-       struct drm_sched_entity entity_dec;
-       struct drm_sched_entity entity_enc;
        unsigned                num_enc_rings;
 };
 
index ccba88cc8c54227e6a20cd9b84a0234f8f0590e6..b0eb2f537392d192d84d3884bd685f7084e9e220 100644 (file)
@@ -2123,7 +2123,8 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
                        before->last = saddr - 1;
                        before->offset = tmp->offset;
                        before->flags = tmp->flags;
-                       list_add(&before->list, &tmp->list);
+                       before->bo_va = tmp->bo_va;
+                       list_add(&before->list, &tmp->bo_va->invalids);
                }
 
                /* Remember mapping split at the end */
@@ -2133,7 +2134,8 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
                        after->offset = tmp->offset;
                        after->offset += after->start - tmp->start;
                        after->flags = tmp->flags;
-                       list_add(&after->list, &tmp->list);
+                       after->bo_va = tmp->bo_va;
+                       list_add(&after->list, &tmp->bo_va->invalids);
                }
 
                list_del(&tmp->list);
index 69500a8b4e2df89004d0280abb47e186ee4fd72b..e9934de1b9cf8127eb2b770e4301d6ee90c98223 100644 (file)
@@ -1221,7 +1221,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index,
        ectx.abort = false;
        ectx.last_jump = 0;
        if (ws)
-               ectx.ws = kzalloc(4 * ws, GFP_KERNEL);
+               ectx.ws = kcalloc(4, ws, GFP_KERNEL);
        else
                ectx.ws = NULL;
 
index a266dcf5daed2f7d7b335d9c7108623eead51886..7fbad2f5f0bd7bbe76a7518b0c49bbed6e010602 100644 (file)
@@ -5679,8 +5679,9 @@ static int ci_parse_power_table(struct amdgpu_device *adev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct amdgpu_ps),
+                                 GFP_KERNEL);
        if (!adev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
@@ -5927,7 +5928,9 @@ static int ci_dpm_init(struct amdgpu_device *adev)
        ci_set_private_data_variables_based_on_pptable(adev);
 
        adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct amdgpu_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                ci_dpm_fini(adev);
                return -ENOMEM;
index 60608b3df881202651ae8cba2f4f9720c0dd8217..d5ebe566809b22e401f88582a7b73d9caf4faf81 100644 (file)
@@ -64,7 +64,7 @@ static u32 df_v3_6_get_hbm_channel_number(struct amdgpu_device *adev)
        int fb_channel_number;
 
        fb_channel_number = adev->df_funcs->get_fb_channel_number(adev);
-       if (fb_channel_number > ARRAY_SIZE(df_v3_6_channel_number))
+       if (fb_channel_number >= ARRAY_SIZE(df_v3_6_channel_number))
                fb_channel_number = 0;
 
        return df_v3_6_channel_number[fb_channel_number];
index d7530fdfaad51055bb2fe3d8013b4055f8a46173..a69153435ea7ec9ccf4180b70ead070734549688 100644 (file)
@@ -111,6 +111,7 @@ static const struct soc15_reg_golden golden_settings_gc_9_0_vg10[] =
 
 static const struct soc15_reg_golden golden_settings_gc_9_0_vg20[] =
 {
+       SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_DCC_CONFIG, 0x0f000080, 0x04000080),
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_2, 0x0f000000, 0x0a000000),
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmCB_HW_CONTROL_3, 0x30000000, 0x10000000),
        SOC15_REG_GOLDEN_VALUE(GC, 0, mmGB_ADDR_CONFIG, 0xf3e777ff, 0x22014042),
@@ -1837,13 +1838,15 @@ static void gfx_v9_1_parse_ind_reg_list(int *register_list_format,
                                int indirect_offset,
                                int list_size,
                                int *unique_indirect_regs,
-                               int *unique_indirect_reg_count,
+                               int unique_indirect_reg_count,
                                int *indirect_start_offsets,
-                               int *indirect_start_offsets_count)
+                               int *indirect_start_offsets_count,
+                               int max_start_offsets_count)
 {
        int idx;
 
        for (; indirect_offset < list_size; indirect_offset++) {
+               WARN_ON(*indirect_start_offsets_count >= max_start_offsets_count);
                indirect_start_offsets[*indirect_start_offsets_count] = indirect_offset;
                *indirect_start_offsets_count = *indirect_start_offsets_count + 1;
 
@@ -1851,14 +1854,14 @@ static void gfx_v9_1_parse_ind_reg_list(int *register_list_format,
                        indirect_offset += 2;
 
                        /* look for the matching indice */
-                       for (idx = 0; idx < *unique_indirect_reg_count; idx++) {
+                       for (idx = 0; idx < unique_indirect_reg_count; idx++) {
                                if (unique_indirect_regs[idx] ==
                                        register_list_format[indirect_offset] ||
                                        !unique_indirect_regs[idx])
                                        break;
                        }
 
-                       BUG_ON(idx >= *unique_indirect_reg_count);
+                       BUG_ON(idx >= unique_indirect_reg_count);
 
                        if (!unique_indirect_regs[idx])
                                unique_indirect_regs[idx] = register_list_format[indirect_offset];
@@ -1893,9 +1896,10 @@ static int gfx_v9_1_init_rlc_save_restore_list(struct amdgpu_device *adev)
                                    adev->gfx.rlc.reg_list_format_direct_reg_list_length,
                                    adev->gfx.rlc.reg_list_format_size_bytes >> 2,
                                    unique_indirect_regs,
-                                   &unique_indirect_reg_count,
+                                   unique_indirect_reg_count,
                                    indirect_start_offsets,
-                                   &indirect_start_offsets_count);
+                                   &indirect_start_offsets_count,
+                                   ARRAY_SIZE(indirect_start_offsets));
 
        /* enable auto inc in case it is disabled */
        tmp = RREG32(SOC15_REG_OFFSET(GC, 0, mmRLC_SRM_CNTL));
@@ -3404,11 +3408,6 @@ static int gfx_v9_0_late_init(void *handle)
        if (r)
                return r;
 
-       r = amdgpu_device_ip_set_powergating_state(adev, AMD_IP_BLOCK_TYPE_GFX,
-                                                  AMD_PG_STATE_GATE);
-       if (r)
-               return r;
-
        return 0;
 }
 
index 17f7f074cedcc32b39e75c132ccc98932221b51b..7a1e77c93bf1be75b8e25ca96911eb4b59a2a812 100644 (file)
@@ -2727,8 +2727,9 @@ static int kv_parse_power_table(struct amdgpu_device *adev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct amdgpu_ps),
+                                 GFP_KERNEL);
        if (!adev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
index 0c768e388ace5f9f8fc70c500ef09e20ccae9743..727071fee6f64d9148076b1bb1916bf4136b223c 100644 (file)
@@ -47,6 +47,8 @@ MODULE_FIRMWARE("amdgpu/vega20_asd.bin");
 
 #define smnMP1_FIRMWARE_FLAGS 0x3010028
 
+static uint32_t sos_old_versions[] = {1517616, 1510592, 1448594, 1446554};
+
 static int
 psp_v3_1_get_fw_type(struct amdgpu_firmware_info *ucode, enum psp_gfx_fw_type *type)
 {
@@ -210,12 +212,31 @@ static int psp_v3_1_bootloader_load_sysdrv(struct psp_context *psp)
        return ret;
 }
 
+static bool psp_v3_1_match_version(struct amdgpu_device *adev, uint32_t ver)
+{
+       int i;
+
+       if (ver == adev->psp.sos_fw_version)
+               return true;
+
+       /*
+        * Double check if the latest four legacy versions.
+        * If yes, it is still the right version.
+        */
+       for (i = 0; i < sizeof(sos_old_versions) / sizeof(uint32_t); i++) {
+               if (sos_old_versions[i] == adev->psp.sos_fw_version)
+                       return true;
+       }
+
+       return false;
+}
+
 static int psp_v3_1_bootloader_load_sos(struct psp_context *psp)
 {
        int ret;
        unsigned int psp_gfxdrv_command_reg = 0;
        struct amdgpu_device *adev = psp->adev;
-       uint32_t sol_reg;
+       uint32_t sol_reg, ver;
 
        /* Check sOS sign of life register to confirm sys driver and sOS
         * are already been loaded.
@@ -248,6 +269,10 @@ static int psp_v3_1_bootloader_load_sos(struct psp_context *psp)
                           RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_81),
                           0, true);
 
+       ver = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_58);
+       if (!psp_v3_1_match_version(adev, ver))
+               DRM_WARN("SOS version doesn't match\n");
+
        return ret;
 }
 
index b12d7c9d42a058fae99fce9cd3679caf15e71961..5c97a36717264f5ca9bf3924927cd934b2f6d963 100644 (file)
@@ -7242,8 +7242,9 @@ static int si_parse_power_table(struct amdgpu_device *adev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct amdgpu_ps),
+                                 GFP_KERNEL);
        if (!adev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
@@ -7346,7 +7347,9 @@ static int si_dpm_init(struct amdgpu_device *adev)
                return ret;
 
        adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct amdgpu_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                amdgpu_free_extended_power_table(adev);
                return -ENOMEM;
index 68b4a22a88925728d1dd9f4b303601ac73694a42..83f2717fcf81a4077b7e7187ad0c0e2c7abdd046 100644 (file)
@@ -685,6 +685,7 @@ static int soc15_common_early_init(void *handle)
                        AMD_CG_SUPPORT_BIF_MGCG |
                        AMD_CG_SUPPORT_BIF_LS |
                        AMD_CG_SUPPORT_HDP_MGCG |
+                       AMD_CG_SUPPORT_HDP_LS |
                        AMD_CG_SUPPORT_ROM_MGCG |
                        AMD_CG_SUPPORT_VCE_MGCG |
                        AMD_CG_SUPPORT_UVD_MGCG;
index 110b294ebed3e554a9bc44d75a9a30ebcd51e61a..29684c3ea4ef2b6d1586721f0b095dfd961eb989 100644 (file)
@@ -769,14 +769,14 @@ static int vcn_v1_0_stop(struct amdgpu_device *adev)
        return 0;
 }
 
-bool vcn_v1_0_is_idle(void *handle)
+static bool vcn_v1_0_is_idle(void *handle)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
        return (RREG32_SOC15(VCN, 0, mmUVD_STATUS) == 0x2);
 }
 
-int vcn_v1_0_wait_for_idle(void *handle)
+static int vcn_v1_0_wait_for_idle(void *handle)
 {
        struct amdgpu_device *adev = (struct amdgpu_device *)handle;
        int ret = 0;
index f9b9ab90558c92c223050d5c47a8547cb1d1ca06..f9add85157e7355432aab9d0d14728f8906774f9 100644 (file)
@@ -46,6 +46,7 @@
 #include <linux/moduleparam.h>
 #include <linux/version.h>
 #include <linux/types.h>
+#include <linux/pm_runtime.h>
 
 #include <drm/drmP.h>
 #include <drm/drm_atomic.h>
@@ -2095,12 +2096,6 @@ convert_color_depth_from_display_info(const struct drm_connector *connector)
 {
        uint32_t bpc = connector->display_info.bpc;
 
-       /* Limited color depth to 8bit
-        * TODO: Still need to handle deep color
-        */
-       if (bpc > 8)
-               bpc = 8;
-
        switch (bpc) {
        case 0:
                /* Temporary Work around, DRM don't parse color depth for
@@ -2316,27 +2311,22 @@ decide_crtc_timing_for_drm_display_mode(struct drm_display_mode *drm_mode,
        }
 }
 
-static int create_fake_sink(struct amdgpu_dm_connector *aconnector)
+static struct dc_sink *
+create_fake_sink(struct amdgpu_dm_connector *aconnector)
 {
-       struct dc_sink *sink = NULL;
        struct dc_sink_init_data sink_init_data = { 0 };
-
+       struct dc_sink *sink = NULL;
        sink_init_data.link = aconnector->dc_link;
        sink_init_data.sink_signal = aconnector->dc_link->connector_signal;
 
        sink = dc_sink_create(&sink_init_data);
        if (!sink) {
                DRM_ERROR("Failed to create sink!\n");
-               return -ENOMEM;
+               return NULL;
        }
-
        sink->sink_signal = SIGNAL_TYPE_VIRTUAL;
-       aconnector->fake_enable = true;
-
-       aconnector->dc_sink = sink;
-       aconnector->dc_link->local_sink = sink;
 
-       return 0;
+       return sink;
 }
 
 static void set_multisync_trigger_params(
@@ -2399,7 +2389,7 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
        struct dc_stream_state *stream = NULL;
        struct drm_display_mode mode = *drm_mode;
        bool native_mode_found = false;
-
+       struct dc_sink *sink = NULL;
        if (aconnector == NULL) {
                DRM_ERROR("aconnector is NULL!\n");
                return stream;
@@ -2417,15 +2407,18 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
                        return stream;
                }
 
-               if (create_fake_sink(aconnector))
+               sink = create_fake_sink(aconnector);
+               if (!sink)
                        return stream;
+       } else {
+               sink = aconnector->dc_sink;
        }
 
-       stream = dc_create_stream_for_sink(aconnector->dc_sink);
+       stream = dc_create_stream_for_sink(sink);
 
        if (stream == NULL) {
                DRM_ERROR("Failed to create stream for sink!\n");
-               return stream;
+               goto finish;
        }
 
        list_for_each_entry(preferred_mode, &aconnector->base.modes, head) {
@@ -2464,12 +2457,15 @@ create_stream_for_sink(struct amdgpu_dm_connector *aconnector,
        fill_audio_info(
                &stream->audio_info,
                drm_connector,
-               aconnector->dc_sink);
+               sink);
 
        update_stream_signal(stream);
 
        if (dm_state && dm_state->freesync_capable)
                stream->ignore_msa_timing_param = true;
+finish:
+       if (sink && sink->sink_signal == SIGNAL_TYPE_VIRTUAL)
+               dc_sink_release(sink);
 
        return stream;
 }
@@ -2714,6 +2710,9 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector)
        struct dm_connector_state *state =
                to_dm_connector_state(connector->state);
 
+       if (connector->state)
+               __drm_atomic_helper_connector_destroy_state(connector->state);
+
        kfree(state);
 
        state = kzalloc(sizeof(*state), GFP_KERNEL);
@@ -2724,8 +2723,7 @@ void amdgpu_dm_connector_funcs_reset(struct drm_connector *connector)
                state->underscan_hborder = 0;
                state->underscan_vborder = 0;
 
-               connector->state = &state->base;
-               connector->state->connector = connector;
+               __drm_atomic_helper_connector_reset(connector, &state->base);
        }
 }
 
@@ -3083,17 +3081,6 @@ static int dm_plane_helper_prepare_fb(struct drm_plane *plane,
                }
        }
 
-       /* It's a hack for s3 since in 4.9 kernel filter out cursor buffer
-        * prepare and cleanup in drm_atomic_helper_prepare_planes
-        * and drm_atomic_helper_cleanup_planes because fb doens't in s3.
-        * IN 4.10 kernel this code should be removed and amdgpu_device_suspend
-        * code touching fram buffers should be avoided for DC.
-        */
-       if (plane->type == DRM_PLANE_TYPE_CURSOR) {
-               struct amdgpu_crtc *acrtc = to_amdgpu_crtc(new_state->crtc);
-
-               acrtc->cursor_bo = obj;
-       }
        return 0;
 }
 
@@ -4281,6 +4268,8 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
                        if (dm_old_crtc_state->stream)
                                remove_stream(adev, acrtc, dm_old_crtc_state->stream);
 
+                       pm_runtime_get_noresume(dev->dev);
+
                        acrtc->enabled = true;
                        acrtc->hw_mode = new_crtc_state->mode;
                        crtc->hwmode = new_crtc_state->mode;
@@ -4469,6 +4458,16 @@ static void amdgpu_dm_atomic_commit_tail(struct drm_atomic_state *state)
                drm_atomic_helper_wait_for_flip_done(dev, state);
 
        drm_atomic_helper_cleanup_planes(dev, state);
+
+       /* Finally, drop a runtime PM reference for each newly disabled CRTC,
+        * so we can put the GPU into runtime suspend if we're not driving any
+        * displays anymore
+        */
+       pm_runtime_mark_last_busy(dev->dev);
+       for_each_oldnew_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+               if (old_crtc_state->active && !new_crtc_state->active)
+                       pm_runtime_put_autosuspend(dev->dev);
+       }
 }
 
 
index bd449351803fb27dffd4fbbf2ad52e56bc458651..ec304b1a5973d39ed859a8e4a4fbfa5dde414eb3 100644 (file)
@@ -435,7 +435,7 @@ bool dm_helpers_submit_i2c(
                return false;
        }
 
-       msgs = kzalloc(num * sizeof(struct i2c_msg), GFP_KERNEL);
+       msgs = kcalloc(num, sizeof(struct i2c_msg), GFP_KERNEL);
 
        if (!msgs)
                return false;
index 4be21bf5474981a8b954f4b1fb6b5c6a283cc82b..a910f01838ab0dd1a7d395f82b9d542d5abfbbf0 100644 (file)
@@ -555,6 +555,9 @@ static inline int dm_irq_state(struct amdgpu_device *adev,
                return 0;
        }
 
+       if (acrtc->otg_inst == -1)
+               return 0;
+
        irq_source = dal_irq_type + acrtc->otg_inst;
 
        st = (state == AMDGPU_IRQ_STATE_ENABLE);
index 0229c7edb8ad75242b89416e52e39373b0e105fc..5a3346124a0177da27c6d205559a2f363f5aa40d 100644 (file)
@@ -234,6 +234,33 @@ static void pp_to_dc_clock_levels(
        }
 }
 
+static void pp_to_dc_clock_levels_with_latency(
+               const struct pp_clock_levels_with_latency *pp_clks,
+               struct dm_pp_clock_levels_with_latency *clk_level_info,
+               enum dm_pp_clock_type dc_clk_type)
+{
+       uint32_t i;
+
+       if (pp_clks->num_levels > DM_PP_MAX_CLOCK_LEVELS) {
+               DRM_INFO("DM_PPLIB: Warning: %s clock: number of levels %d exceeds maximum of %d!\n",
+                               DC_DECODE_PP_CLOCK_TYPE(dc_clk_type),
+                               pp_clks->num_levels,
+                               DM_PP_MAX_CLOCK_LEVELS);
+
+               clk_level_info->num_levels = DM_PP_MAX_CLOCK_LEVELS;
+       } else
+               clk_level_info->num_levels = pp_clks->num_levels;
+
+       DRM_DEBUG("DM_PPLIB: values for %s clock\n",
+                       DC_DECODE_PP_CLOCK_TYPE(dc_clk_type));
+
+       for (i = 0; i < clk_level_info->num_levels; i++) {
+               DRM_DEBUG("DM_PPLIB:\t %d\n", pp_clks->data[i].clocks_in_khz);
+               clk_level_info->data[i].clocks_in_khz = pp_clks->data[i].clocks_in_khz;
+               clk_level_info->data[i].latency_in_us = pp_clks->data[i].latency_in_us;
+       }
+}
+
 bool dm_pp_get_clock_levels_by_type(
                const struct dc_context *ctx,
                enum dm_pp_clock_type clk_type,
@@ -311,8 +338,22 @@ bool dm_pp_get_clock_levels_by_type_with_latency(
        enum dm_pp_clock_type clk_type,
        struct dm_pp_clock_levels_with_latency *clk_level_info)
 {
-       /* TODO: to be implemented */
-       return false;
+       struct amdgpu_device *adev = ctx->driver_context;
+       void *pp_handle = adev->powerplay.pp_handle;
+       struct pp_clock_levels_with_latency pp_clks = { 0 };
+       const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
+
+       if (!pp_funcs || !pp_funcs->get_clock_by_type_with_latency)
+               return false;
+
+       if (pp_funcs->get_clock_by_type_with_latency(pp_handle,
+                                                    dc_to_pp_clock_type(clk_type),
+                                                    &pp_clks))
+               return false;
+
+       pp_to_dc_clock_levels_with_latency(&pp_clks, clk_level_info, clk_type);
+
+       return true;
 }
 
 bool dm_pp_get_clock_levels_by_type_with_voltage(
index e61dd97d0928ce910420c3ef74fc1bd8e97da42b..f28989860fd81cdc70643421350f167b41183d35 100644 (file)
@@ -449,6 +449,11 @@ static inline unsigned int clamp_ux_dy(
                return min_clamp;
 }
 
+unsigned int dc_fixpt_u3d19(struct fixed31_32 arg)
+{
+       return ux_dy(arg.value, 3, 19);
+}
+
 unsigned int dc_fixpt_u2d19(struct fixed31_32 arg)
 {
        return ux_dy(arg.value, 2, 19);
index 738a818d58d1c5defba2ee3007cb9ee6688b3ee9..0866874ae8c6e325f8744549460f201a9d87e5ca 100644 (file)
@@ -364,7 +364,7 @@ void dm_logger_open(
        entry->type = log_type;
        entry->logger = logger;
 
-       entry->buf = kzalloc(DAL_LOGGER_BUFFER_MAX_SIZE * sizeof(char),
+       entry->buf = kzalloc(DAL_LOGGER_BUFFER_MAX_SIZE,
                             GFP_KERNEL);
 
        entry->buf_offset = 0;
index 217b8f1f7bf62253624219ce10ca36fa7fb1f093..d28e9cf0e961df9c4ea8089a54d21df50c0bb6f1 100644 (file)
@@ -40,7 +40,7 @@ bool dal_vector_construct(
                return false;
        }
 
-       vector->container = kzalloc(struct_size * capacity, GFP_KERNEL);
+       vector->container = kcalloc(capacity, struct_size, GFP_KERNEL);
        if (vector->container == NULL)
                return false;
        vector->capacity = capacity;
@@ -67,7 +67,7 @@ bool dal_vector_presized_costruct(
                return false;
        }
 
-       vector->container = kzalloc(struct_size * count, GFP_KERNEL);
+       vector->container = kcalloc(count, struct_size, GFP_KERNEL);
 
        if (vector->container == NULL)
                return false;
index 7d609c71394bba4049ba7722b912c435cf18b11b..7857cb42b3e62e5603af2408128e4cefb6531a0c 100644 (file)
@@ -1630,17 +1630,42 @@ static enum dc_status read_hpd_rx_irq_data(
        struct dc_link *link,
        union hpd_irq_data *irq_data)
 {
+       static enum dc_status retval;
+
        /* The HW reads 16 bytes from 200h on HPD,
         * but if we get an AUX_DEFER, the HW cannot retry
         * and this causes the CTS tests 4.3.2.1 - 3.2.4 to
         * fail, so we now explicitly read 6 bytes which is
         * the req from the above mentioned test cases.
+        *
+        * For DP 1.4 we need to read those from 2002h range.
         */
-       return core_link_read_dpcd(
-       link,
-       DP_SINK_COUNT,
-       irq_data->raw,
-       sizeof(union hpd_irq_data));
+       if (link->dpcd_caps.dpcd_rev.raw < DPCD_REV_14)
+               retval = core_link_read_dpcd(
+                       link,
+                       DP_SINK_COUNT,
+                       irq_data->raw,
+                       sizeof(union hpd_irq_data));
+       else {
+               /* Read 2 bytes at this location,... */
+               retval = core_link_read_dpcd(
+                       link,
+                       DP_SINK_COUNT_ESI,
+                       irq_data->raw,
+                       2);
+
+               if (retval != DC_OK)
+                       return retval;
+
+               /* ... then read remaining 4 at the other location */
+               retval = core_link_read_dpcd(
+                       link,
+                       DP_LANE0_1_STATUS_ESI,
+                       &irq_data->raw[2],
+                       4);
+       }
+
+       return retval;
 }
 
 static bool allow_hpd_rx_irq(const struct dc_link *link)
@@ -2278,7 +2303,7 @@ static void dp_wa_power_up_0010FA(struct dc_link *link, uint8_t *dpcd_data,
 
 static bool retrieve_link_cap(struct dc_link *link)
 {
-       uint8_t dpcd_data[DP_TRAINING_AUX_RD_INTERVAL - DP_DPCD_REV + 1];
+       uint8_t dpcd_data[DP_ADAPTER_CAP - DP_DPCD_REV + 1];
 
        union down_stream_port_count down_strm_port_count;
        union edp_configuration_cap edp_config_cap;
index 599c7ab6befef229c6ae0f63bce8f1ae8b91d34b..88b09dd758baad980f2c6fdd37d5d152c909227a 100644 (file)
@@ -1079,13 +1079,15 @@ static void get_ss_info_from_atombios(
        if (*ss_entries_num == 0)
                return;
 
-       ss_info = kzalloc(sizeof(struct spread_spectrum_info) * (*ss_entries_num),
+       ss_info = kcalloc(*ss_entries_num,
+                         sizeof(struct spread_spectrum_info),
                          GFP_KERNEL);
        ss_info_cur = ss_info;
        if (ss_info == NULL)
                return;
 
-       ss_data = kzalloc(sizeof(struct spread_spectrum_data) * (*ss_entries_num),
+       ss_data = kcalloc(*ss_entries_num,
+                         sizeof(struct spread_spectrum_data),
                          GFP_KERNEL);
        if (ss_data == NULL)
                goto out_free_info;
index 0a6d483dc046a81b499b7d9df8c4e090d6191eee..c0e813c7ddd41db3a372218e564f0f1d70882b2e 100644 (file)
@@ -72,7 +72,8 @@ static void dce110_update_generic_info_packet(
        uint32_t max_retries = 50;
 
        /*we need turn on clock before programming AFMT block*/
-       REG_UPDATE(AFMT_CNTL, AFMT_AUDIO_CLOCK_EN, 1);
+       if (REG(AFMT_CNTL))
+               REG_UPDATE(AFMT_CNTL, AFMT_AUDIO_CLOCK_EN, 1);
 
        if (REG(AFMT_VBI_PACKET_CONTROL1)) {
                if (packet_index >= 8)
@@ -719,7 +720,8 @@ static void dce110_stream_encoder_update_hdmi_info_packets(
                        const uint32_t *content =
                                (const uint32_t *) &info_frame->avi.sb[0];
                        /*we need turn on clock before programming AFMT block*/
-                       REG_UPDATE(AFMT_CNTL, AFMT_AUDIO_CLOCK_EN, 1);
+                       if (REG(AFMT_CNTL))
+                               REG_UPDATE(AFMT_CNTL, AFMT_AUDIO_CLOCK_EN, 1);
 
                        REG_WRITE(AFMT_AVI_INFO0, content[0]);
 
index 9150d26944508e4a91ec5d16af7cb2d6fa3b589e..e2994d3370448028d86de5d6e11b6cfa8d4acc01 100644 (file)
@@ -121,10 +121,10 @@ static void reset_lb_on_vblank(struct dc_context *ctx)
                frame_count = dm_read_reg(ctx, mmCRTC_STATUS_FRAME_COUNT);
 
 
-               for (retry = 100; retry > 0; retry--) {
+               for (retry = 10000; retry > 0; retry--) {
                        if (frame_count != dm_read_reg(ctx, mmCRTC_STATUS_FRAME_COUNT))
                                break;
-                       msleep(1);
+                       udelay(10);
                }
                if (!retry)
                        dm_error("Frame count did not increase for 100ms.\n");
@@ -147,14 +147,14 @@ static void wait_for_fbc_state_changed(
        uint32_t addr = mmFBC_STATUS;
        uint32_t value;
 
-       while (counter < 10) {
+       while (counter < 1000) {
                value = dm_read_reg(cp110->base.ctx, addr);
                if (get_reg_field_value(
                        value,
                        FBC_STATUS,
                        FBC_ENABLE_STATUS) == enabled)
                        break;
-               msleep(10);
+               udelay(100);
                counter++;
        }
 
index a92fb0aa2ff3b3f727c6d8e4c0bd38c6b42d902f..c29052b6da5a8603bbf8b771dad34e62d5678590 100644 (file)
@@ -1004,9 +1004,9 @@ void dce110_disable_stream(struct pipe_ctx *pipe_ctx, int option)
                /*don't free audio if it is from retrain or internal disable stream*/
                if (option == FREE_ACQUIRED_RESOURCE && dc->caps.dynamic_audio == true) {
                        /*we have to dynamic arbitrate the audio endpoints*/
-                       pipe_ctx->stream_res.audio = NULL;
                        /*we free the resource, need reset is_audio_acquired*/
                        update_audio_usage(&dc->current_state->res_ctx, dc->res_pool, pipe_ctx->stream_res.audio, false);
+                       pipe_ctx->stream_res.audio = NULL;
                }
 
                /* TODO: notify audio driver for if audio modes list changed
index 46a35c7f01df64f9d0aa67482cecd9d2fc3b6603..c69fa4bfab0af125974e18fcc6f9adc798edfd2f 100644 (file)
@@ -132,8 +132,7 @@ void dpp_set_gamut_remap_bypass(struct dcn10_dpp *dpp)
 
 #define IDENTITY_RATIO(ratio) (dc_fixpt_u2d19(ratio) == (1 << 19))
 
-
-bool dpp_get_optimal_number_of_taps(
+static bool dpp_get_optimal_number_of_taps(
                struct dpp *dpp,
                struct scaler_data *scl_data,
                const struct scaling_taps *in_taps)
index 5944a3ba040904e942bce17995a99a3e264745fb..e862cafa6501b78e7601fe9e95ebf7f81b728130 100644 (file)
@@ -1424,12 +1424,8 @@ void dpp1_set_degamma(
                enum ipp_degamma_mode mode);
 
 void dpp1_set_degamma_pwl(struct dpp *dpp_base,
-                                                                const struct pwl_params *params);
+               const struct pwl_params *params);
 
-bool dpp_get_optimal_number_of_taps(
-               struct dpp *dpp,
-               struct scaler_data *scl_data,
-               const struct scaling_taps *in_taps);
 
 void dpp_read_state(struct dpp *dpp_base,
                struct dcn_dpp_state *s);
index 4ddd6273d5a5bc64888c8c4b02fb1caa4b28fd61..f862fd148ccaff5190597a9fc34118299c57122e 100644 (file)
@@ -565,16 +565,16 @@ static void dpp1_dscl_set_manual_ratio_init(
        uint32_t init_int = 0;
 
        REG_SET(SCL_HORZ_FILTER_SCALE_RATIO, 0,
-                       SCL_H_SCALE_RATIO, dc_fixpt_u2d19(data->ratios.horz) << 5);
+                       SCL_H_SCALE_RATIO, dc_fixpt_u3d19(data->ratios.horz) << 5);
 
        REG_SET(SCL_VERT_FILTER_SCALE_RATIO, 0,
-                       SCL_V_SCALE_RATIO, dc_fixpt_u2d19(data->ratios.vert) << 5);
+                       SCL_V_SCALE_RATIO, dc_fixpt_u3d19(data->ratios.vert) << 5);
 
        REG_SET(SCL_HORZ_FILTER_SCALE_RATIO_C, 0,
-                       SCL_H_SCALE_RATIO_C, dc_fixpt_u2d19(data->ratios.horz_c) << 5);
+                       SCL_H_SCALE_RATIO_C, dc_fixpt_u3d19(data->ratios.horz_c) << 5);
 
        REG_SET(SCL_VERT_FILTER_SCALE_RATIO_C, 0,
-                       SCL_V_SCALE_RATIO_C, dc_fixpt_u2d19(data->ratios.vert_c) << 5);
+                       SCL_V_SCALE_RATIO_C, dc_fixpt_u3d19(data->ratios.vert_c) << 5);
 
        /*
         * 0.24 format for fraction, first five bits zeroed
index d2ab78b35a7ae8e267b1ca2e814d719cd90ffe48..c28085be39ff9530730481f98e3c2c800ea167cc 100644 (file)
@@ -396,11 +396,15 @@ bool hubp1_program_surface_flip_and_addr(
                if (address->grph_stereo.right_addr.quad_part == 0)
                        break;
 
-               REG_UPDATE_4(DCSURF_SURFACE_CONTROL,
+               REG_UPDATE_8(DCSURF_SURFACE_CONTROL,
                                PRIMARY_SURFACE_TMZ, address->tmz_surface,
                                PRIMARY_SURFACE_TMZ_C, address->tmz_surface,
                                PRIMARY_META_SURFACE_TMZ, address->tmz_surface,
-                               PRIMARY_META_SURFACE_TMZ_C, address->tmz_surface);
+                               PRIMARY_META_SURFACE_TMZ_C, address->tmz_surface,
+                               SECONDARY_SURFACE_TMZ, address->tmz_surface,
+                               SECONDARY_SURFACE_TMZ_C, address->tmz_surface,
+                               SECONDARY_META_SURFACE_TMZ, address->tmz_surface,
+                               SECONDARY_META_SURFACE_TMZ_C, address->tmz_surface);
 
                if (address->grph_stereo.right_meta_addr.quad_part != 0) {
 
@@ -459,9 +463,11 @@ void hubp1_dcc_control(struct hubp *hubp, bool enable,
        uint32_t dcc_ind_64b_blk = independent_64b_blks ? 1 : 0;
        struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
 
-       REG_UPDATE_2(DCSURF_SURFACE_CONTROL,
+       REG_UPDATE_4(DCSURF_SURFACE_CONTROL,
                        PRIMARY_SURFACE_DCC_EN, dcc_en,
-                       PRIMARY_SURFACE_DCC_IND_64B_BLK, dcc_ind_64b_blk);
+                       PRIMARY_SURFACE_DCC_IND_64B_BLK, dcc_ind_64b_blk,
+                       SECONDARY_SURFACE_DCC_EN, dcc_en,
+                       SECONDARY_SURFACE_DCC_IND_64B_BLK, dcc_ind_64b_blk);
 }
 
 void hubp1_program_surface_config(
index af384034398f0bde6f5db3896eb49bbc599df0fd..d901d5092969d6897022243cea08b6351caaa0f1 100644 (file)
        HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, PRIMARY_META_SURFACE_TMZ_C, mask_sh),\
        HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, PRIMARY_SURFACE_DCC_EN, mask_sh),\
        HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, PRIMARY_SURFACE_DCC_IND_64B_BLK, mask_sh),\
+       HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, SECONDARY_SURFACE_TMZ, mask_sh),\
+       HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, SECONDARY_SURFACE_TMZ_C, mask_sh),\
+       HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, SECONDARY_META_SURFACE_TMZ, mask_sh),\
+       HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, SECONDARY_META_SURFACE_TMZ_C, mask_sh),\
+       HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, SECONDARY_SURFACE_DCC_EN, mask_sh),\
+       HUBP_SF(HUBPREQ0_DCSURF_SURFACE_CONTROL, SECONDARY_SURFACE_DCC_IND_64B_BLK, mask_sh),\
        HUBP_SF(HUBPRET0_HUBPRET_CONTROL, DET_BUF_PLANE1_BASE_ADDRESS, mask_sh),\
        HUBP_SF(HUBPRET0_HUBPRET_CONTROL, CROSSBAR_SRC_CB_B, mask_sh),\
        HUBP_SF(HUBPRET0_HUBPRET_CONTROL, CROSSBAR_SRC_CR_R, mask_sh),\
        type SECONDARY_META_SURFACE_TMZ_C;\
        type PRIMARY_SURFACE_DCC_EN;\
        type PRIMARY_SURFACE_DCC_IND_64B_BLK;\
+       type SECONDARY_SURFACE_DCC_EN;\
+       type SECONDARY_SURFACE_DCC_IND_64B_BLK;\
        type DET_BUF_PLANE1_BASE_ADDRESS;\
        type CROSSBAR_SRC_CB_B;\
        type CROSSBAR_SRC_CR_R;\
index 653b7b2efe2e4b33ac9b96384b6cd9e4a9d709a2..c928ee4cd3826dbd813132cc2b074e4f6b5815c2 100644 (file)
@@ -319,6 +319,10 @@ void enc1_stream_encoder_dp_set_stream_attribute(
                REG_UPDATE(DP_PIXEL_FORMAT, DP_COMPONENT_DEPTH,
                                DP_COMPONENT_PIXEL_DEPTH_12BPC);
                break;
+       case COLOR_DEPTH_161616:
+               REG_UPDATE(DP_PIXEL_FORMAT, DP_COMPONENT_DEPTH,
+                               DP_COMPONENT_PIXEL_DEPTH_16BPC);
+               break;
        default:
                REG_UPDATE(DP_PIXEL_FORMAT, DP_COMPONENT_DEPTH,
                                DP_COMPONENT_PIXEL_DEPTH_6BPC);
index 80038e0e610f4e093502bb1364cac0d7495d8d33..ab5483c0c502cedbe04e83375a04da6799a5c12a 100644 (file)
@@ -98,7 +98,8 @@ struct gpio_service *dal_gpio_service_create(
                        if (number_of_bits) {
                                uint32_t index_of_uint = 0;
 
-                               slot = kzalloc(number_of_uints * sizeof(uint32_t),
+                               slot = kcalloc(number_of_uints,
+                                              sizeof(uint32_t),
                                               GFP_KERNEL);
 
                                if (!slot) {
index bb0d4ebba9f081289a9dc08184f85f57a6fed54a..a981b3e99ab39f0b973ae19437010c31e63466a6 100644 (file)
@@ -496,6 +496,8 @@ static inline int dc_fixpt_ceil(struct fixed31_32 arg)
  * fractional
  */
 
+unsigned int dc_fixpt_u3d19(struct fixed31_32 arg);
+
 unsigned int dc_fixpt_u2d19(struct fixed31_32 arg);
 
 unsigned int dc_fixpt_u0d19(struct fixed31_32 arg);
index 0cd111d5901837cda056f70775febd3f534376d4..eee0dfad696294eb96fca9a4f25e3e9f3db7fe85 100644 (file)
@@ -1274,19 +1274,22 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf,
 
        output_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
 
-       rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
+       rgb_user = kvcalloc(ramp->num_entries + _EXTRA_POINTS,
+                           sizeof(*rgb_user),
                            GFP_KERNEL);
        if (!rgb_user)
                goto rgb_user_alloc_fail;
-       rgb_regamma = kvzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS),
+       rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
+                              sizeof(*rgb_regamma),
                               GFP_KERNEL);
        if (!rgb_regamma)
                goto rgb_regamma_alloc_fail;
-       axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + 3),
+       axix_x = kvcalloc(ramp->num_entries + 3, sizeof(*axix_x),
                          GFP_KERNEL);
        if (!axix_x)
                goto axix_x_alloc_fail;
-       coeff = kvzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL);
+       coeff = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, sizeof(*coeff),
+                        GFP_KERNEL);
        if (!coeff)
                goto coeff_alloc_fail;
 
@@ -1413,13 +1416,15 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
 
        output_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
 
-       rgb_user = kzalloc(sizeof(*rgb_user) * (GAMMA_RGB_256_ENTRIES + _EXTRA_POINTS),
-                       GFP_KERNEL);
+       rgb_user = kcalloc(GAMMA_RGB_256_ENTRIES + _EXTRA_POINTS,
+                          sizeof(*rgb_user),
+                          GFP_KERNEL);
        if (!rgb_user)
                goto rgb_user_alloc_fail;
 
-       rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS),
-                       GFP_KERNEL);
+       rgb_regamma = kcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
+                             sizeof(*rgb_regamma),
+                             GFP_KERNEL);
        if (!rgb_regamma)
                goto rgb_regamma_alloc_fail;
 
@@ -1480,19 +1485,21 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf,
 
        input_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
 
-       rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
+       rgb_user = kvcalloc(ramp->num_entries + _EXTRA_POINTS,
+                           sizeof(*rgb_user),
                            GFP_KERNEL);
        if (!rgb_user)
                goto rgb_user_alloc_fail;
-       curve = kvzalloc(sizeof(*curve) * (MAX_HW_POINTS + _EXTRA_POINTS),
+       curve = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, sizeof(*curve),
                         GFP_KERNEL);
        if (!curve)
                goto curve_alloc_fail;
-       axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + _EXTRA_POINTS),
+       axix_x = kvcalloc(ramp->num_entries + _EXTRA_POINTS, sizeof(*axix_x),
                          GFP_KERNEL);
        if (!axix_x)
                goto axix_x_alloc_fail;
-       coeff = kvzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL);
+       coeff = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, sizeof(*coeff),
+                        GFP_KERNEL);
        if (!coeff)
                goto coeff_alloc_fail;
 
@@ -1569,8 +1576,8 @@ bool  mod_color_calculate_curve(enum dc_transfer_func_predefined trans,
                }
                ret = true;
        } else if (trans == TRANSFER_FUNCTION_PQ) {
-               rgb_regamma = kvzalloc(sizeof(*rgb_regamma) *
-                                      (MAX_HW_POINTS + _EXTRA_POINTS),
+               rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
+                                      sizeof(*rgb_regamma),
                                       GFP_KERNEL);
                if (!rgb_regamma)
                        goto rgb_regamma_alloc_fail;
@@ -1594,8 +1601,8 @@ bool  mod_color_calculate_curve(enum dc_transfer_func_predefined trans,
                kvfree(rgb_regamma);
        } else if (trans == TRANSFER_FUNCTION_SRGB ||
                          trans == TRANSFER_FUNCTION_BT709) {
-               rgb_regamma = kvzalloc(sizeof(*rgb_regamma) *
-                                      (MAX_HW_POINTS + _EXTRA_POINTS),
+               rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
+                                      sizeof(*rgb_regamma),
                                       GFP_KERNEL);
                if (!rgb_regamma)
                        goto rgb_regamma_alloc_fail;
@@ -1638,8 +1645,8 @@ bool  mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
                }
                ret = true;
        } else if (trans == TRANSFER_FUNCTION_PQ) {
-               rgb_degamma = kvzalloc(sizeof(*rgb_degamma) *
-                                      (MAX_HW_POINTS + _EXTRA_POINTS),
+               rgb_degamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
+                                      sizeof(*rgb_degamma),
                                       GFP_KERNEL);
                if (!rgb_degamma)
                        goto rgb_degamma_alloc_fail;
@@ -1658,8 +1665,8 @@ bool  mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans,
                kvfree(rgb_degamma);
        } else if (trans == TRANSFER_FUNCTION_SRGB ||
                          trans == TRANSFER_FUNCTION_BT709) {
-               rgb_degamma = kvzalloc(sizeof(*rgb_degamma) *
-                                      (MAX_HW_POINTS + _EXTRA_POINTS),
+               rgb_degamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
+                                      sizeof(*rgb_degamma),
                                       GFP_KERNEL);
                if (!rgb_degamma)
                        goto rgb_degamma_alloc_fail;
index 27d4003aa2c7689e7e6d33163bbd633dc33aecc6..fa344ceafc17168cfa414264dd8a4c449d268734 100644 (file)
@@ -155,7 +155,8 @@ struct mod_freesync *mod_freesync_create(struct dc *dc)
        if (core_freesync == NULL)
                goto fail_alloc_context;
 
-       core_freesync->map = kzalloc(sizeof(struct freesync_entity) * MOD_FREESYNC_MAX_CONCURRENT_STREAMS,
+       core_freesync->map = kcalloc(MOD_FREESYNC_MAX_CONCURRENT_STREAMS,
+                                       sizeof(struct freesync_entity),
                                        GFP_KERNEL);
 
        if (core_freesync->map == NULL)
index 3f7d47fdc3679ddc1bd9ace2181f165380cd65b9..710852ad03f36d9f3bbeff0edff1278fc5a338e6 100644 (file)
@@ -141,19 +141,17 @@ struct mod_stats *mod_stats_create(struct dc *dc)
                        else
                                core_stats->entries = reg_data;
                }
-               core_stats->time = kzalloc(
-                       sizeof(struct stats_time_cache) *
-                               core_stats->entries,
+               core_stats->time = kcalloc(core_stats->entries,
+                                               sizeof(struct stats_time_cache),
                                                GFP_KERNEL);
 
                if (core_stats->time == NULL)
                        goto fail_construct_time;
 
                core_stats->event_entries = DAL_STATS_EVENT_ENTRIES_DEFAULT;
-               core_stats->events = kzalloc(
-                       sizeof(struct stats_event_cache) *
-                               core_stats->event_entries,
-                                               GFP_KERNEL);
+               core_stats->events = kcalloc(core_stats->event_entries,
+                                            sizeof(struct stats_event_cache),
+                                            GFP_KERNEL);
 
                if (core_stats->events == NULL)
                        goto fail_construct_events;
index 88f7c69df6b9649a75ab48db7aa794c8b9cac3fd..06fac509e987358fc491f6e2e7b48b2d531f8bde 100644 (file)
 /* DF_CS_AON0_DramBaseAddress0 */
 #define DF_CS_UMC_AON0_DramBaseAddress0__AddrRngVal__SHIFT                                             0x0
 #define DF_CS_UMC_AON0_DramBaseAddress0__LgcyMmioHoleEn__SHIFT                                         0x1
-#define DF_CS_UMC_AON0_DramBaseAddress0__IntLvNumChan__SHIFT                                           0x4
-#define DF_CS_UMC_AON0_DramBaseAddress0__IntLvAddrSel__SHIFT                                           0x8
+#define DF_CS_UMC_AON0_DramBaseAddress0__IntLvNumChan__SHIFT                                           0x2
+#define DF_CS_UMC_AON0_DramBaseAddress0__IntLvAddrSel__SHIFT                                           0x9
 #define DF_CS_UMC_AON0_DramBaseAddress0__DramBaseAddr__SHIFT                                           0xc
 #define DF_CS_UMC_AON0_DramBaseAddress0__AddrRngVal_MASK                                               0x00000001L
 #define DF_CS_UMC_AON0_DramBaseAddress0__LgcyMmioHoleEn_MASK                                           0x00000002L
-#define DF_CS_UMC_AON0_DramBaseAddress0__IntLvNumChan_MASK                                             0x000000F0L
-#define DF_CS_UMC_AON0_DramBaseAddress0__IntLvAddrSel_MASK                                             0x00000700L
+#define DF_CS_UMC_AON0_DramBaseAddress0__IntLvNumChan_MASK                                             0x0000003CL
+#define DF_CS_UMC_AON0_DramBaseAddress0__IntLvAddrSel_MASK                                             0x00000E00L
 #define DF_CS_UMC_AON0_DramBaseAddress0__DramBaseAddr_MASK                                             0xFFFFF000L
 
 #endif
index c6c1666ac1201c65a5646eb66aa6a88c2a592509..092d800b703a7627a2b98fdda7be54b5b6f7ff11 100644 (file)
@@ -2026,17 +2026,15 @@ enum atom_smu11_syspll_id {
   SMU11_SYSPLL3_1_ID          = 6,
 };
 
-
 enum atom_smu11_syspll0_clock_id {
-  SMU11_SYSPLL0_SOCCLK_ID   = 0,       //      SOCCLK
-  SMU11_SYSPLL0_MP0CLK_ID   = 1,       //      MP0CLK
-  SMU11_SYSPLL0_DCLK_ID     = 2,       //      DCLK
-  SMU11_SYSPLL0_VCLK_ID     = 3,       //      VCLK
-  SMU11_SYSPLL0_ECLK_ID     = 4,       //      ECLK
+  SMU11_SYSPLL0_ECLK_ID     = 0,       //      ECLK
+  SMU11_SYSPLL0_SOCCLK_ID   = 1,       //      SOCCLK
+  SMU11_SYSPLL0_MP0CLK_ID   = 2,       //      MP0CLK
+  SMU11_SYSPLL0_DCLK_ID     = 3,       //      DCLK
+  SMU11_SYSPLL0_VCLK_ID     = 4,       //      VCLK
   SMU11_SYSPLL0_DCEFCLK_ID  = 5,       //      DCEFCLK
 };
 
-
 enum atom_smu11_syspll1_0_clock_id {
   SMU11_SYSPLL1_0_UCLKA_ID   = 0,       // UCLK_a
 };
index b493369e6d0f9daac4bf28777b6461917937eac9..d567be49c31b8c6e346dba9f65a7dbc955f05db7 100644 (file)
@@ -180,7 +180,6 @@ static int pp_late_init(void *handle)
 {
        struct amdgpu_device *adev = handle;
        struct pp_hwmgr *hwmgr = adev->powerplay.pp_handle;
-       int ret;
 
        if (hwmgr && hwmgr->pm_en) {
                mutex_lock(&hwmgr->smu_lock);
@@ -191,13 +190,6 @@ static int pp_late_init(void *handle)
        if (adev->pm.smu_prv_buffer_size != 0)
                pp_reserve_vram_for_smu(adev);
 
-       if (hwmgr->hwmgr_func->gfx_off_control &&
-           (hwmgr->feature_mask & PP_GFXOFF_MASK)) {
-               ret = hwmgr->hwmgr_func->gfx_off_control(hwmgr, true);
-               if (ret)
-                       pr_err("gfx off enabling failed!\n");
-       }
-
        return 0;
 }
 
@@ -245,7 +237,7 @@ static int pp_set_powergating_state(void *handle,
        }
 
        if (hwmgr->hwmgr_func->enable_per_cu_power_gating == NULL) {
-               pr_info("%s was not implemented.\n", __func__);
+               pr_debug("%s was not implemented.\n", __func__);
                return 0;
        }
 
index 0af13c154328731638a2cc671b08269e5b3596c9..91ffb7bc4ee72512f9a31aebbce9eaec3939d9d7 100644 (file)
@@ -50,7 +50,7 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)
                return 0;
        }
 
-       hwmgr->ps = kzalloc(size * table_entries, GFP_KERNEL);
+       hwmgr->ps = kcalloc(table_entries, size, GFP_KERNEL);
        if (hwmgr->ps == NULL)
                return -ENOMEM;
 
@@ -265,19 +265,18 @@ int psm_adjust_power_state_dynamic(struct pp_hwmgr *hwmgr, bool skip,
        if (skip)
                return 0;
 
-       if (!hwmgr->ps)
-               /*
-                * for vega12/vega20 which does not support power state manager
-                * DAL clock limits should also be honoured
-                */
-               phm_apply_clock_adjust_rules(hwmgr);
-
        phm_pre_display_configuration_changed(hwmgr);
 
        phm_display_configuration_changed(hwmgr);
 
        if (hwmgr->ps)
                power_state_management(hwmgr, new_ps);
+       else
+               /*
+                * for vega12/vega20 which does not support power state manager
+                * DAL clock limits should also be honoured
+                */
+               phm_apply_clock_adjust_rules(hwmgr);
 
        phm_notify_smc_display_config_after_ps_adjustment(hwmgr);
 
index c97b0e5ba43b68395ccf0919900b896ffbea069f..5325661fedffb9480b26fb7b94269a30fb32334a 100644 (file)
@@ -496,7 +496,9 @@ int pp_atomfwctrl_get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, BIOS_CLKI
        uint32_t ix;
 
        parameters.clk_id = id;
+       parameters.syspll_id = 0;
        parameters.command = GET_SMU_CLOCK_INFO_V3_1_GET_CLOCK_FREQ;
+       parameters.dfsdid = 0;
 
        ix = GetIndexIntoMasterCmdTable(getsmuclockinfo);
 
@@ -505,7 +507,7 @@ int pp_atomfwctrl_get_clk_information_by_clkid(struct pp_hwmgr *hwmgr, BIOS_CLKI
                return -EINVAL;
 
        output = (struct atom_get_smu_clock_info_output_parameters_v3_1 *)&parameters;
-       *frequency = output->atom_smu_outputclkfreq.smu_clock_freq_hz / 10000;
+       *frequency = le32_to_cpu(output->atom_smu_outputclkfreq.smu_clock_freq_hz) / 10000;
 
        return 0;
 }
index f0d48b183d22c7fe72bead64356c1fdc49c8a37c..35bd9870ab10811cd46c79adc3d8020267e828cd 100644 (file)
@@ -870,12 +870,6 @@ static int init_over_drive_limits(
        hwmgr->platform_descriptor.maxOverdriveVDDC = 0;
        hwmgr->platform_descriptor.overdriveVDDCStep = 0;
 
-       if (hwmgr->platform_descriptor.overdriveLimit.engineClock == 0 \
-               || hwmgr->platform_descriptor.overdriveLimit.memoryClock == 0) {
-               hwmgr->od_enabled = false;
-               pr_debug("OverDrive feature not support by VBIOS\n");
-       }
-
        return 0;
 }
 
index ce64dfabd34bd0cd40cf194c56156f1630d15098..925e17104f9092cd1f343591a524a906c20d1b80 100644 (file)
@@ -1074,12 +1074,6 @@ static int init_overdrive_limits(struct pp_hwmgr *hwmgr,
                                powerplay_table,
                                (const ATOM_FIRMWARE_INFO_V2_1 *)fw_info);
 
-       if (hwmgr->platform_descriptor.overdriveLimit.engineClock == 0
-               && hwmgr->platform_descriptor.overdriveLimit.memoryClock == 0) {
-               hwmgr->od_enabled = false;
-               pr_debug("OverDrive feature not support by VBIOS\n");
-       }
-
        return result;
 }
 
index 85f84f4d8be570d20e5e50694e33cbf6e53e7288..d4bc83e813896903b33b22fca4dbed1b88b2c159 100644 (file)
@@ -53,8 +53,37 @@ static const unsigned long SMU10_Magic = (unsigned long) PHM_Rv_Magic;
 
 
 static int smu10_display_clock_voltage_request(struct pp_hwmgr *hwmgr,
-               struct pp_display_clock_request *clock_req);
+               struct pp_display_clock_request *clock_req)
+{
+       struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
+       enum amd_pp_clock_type clk_type = clock_req->clock_type;
+       uint32_t clk_freq = clock_req->clock_freq_in_khz / 1000;
+       PPSMC_Msg        msg;
 
+       switch (clk_type) {
+       case amd_pp_dcf_clock:
+               if (clk_freq == smu10_data->dcf_actual_hard_min_freq)
+                       return 0;
+               msg =  PPSMC_MSG_SetHardMinDcefclkByFreq;
+               smu10_data->dcf_actual_hard_min_freq = clk_freq;
+               break;
+       case amd_pp_soc_clock:
+                msg = PPSMC_MSG_SetHardMinSocclkByFreq;
+               break;
+       case amd_pp_f_clock:
+               if (clk_freq == smu10_data->f_actual_hard_min_freq)
+                       return 0;
+               smu10_data->f_actual_hard_min_freq = clk_freq;
+               msg = PPSMC_MSG_SetHardMinFclkByFreq;
+               break;
+       default:
+               pr_info("[DisplayClockVoltageRequest]Invalid Clock Type!");
+               return -EINVAL;
+       }
+       smum_send_msg_to_smc_with_parameter(hwmgr, msg, clk_freq);
+
+       return 0;
+}
 
 static struct smu10_power_state *cast_smu10_ps(struct pp_hw_power_state *hw_ps)
 {
@@ -284,7 +313,7 @@ static int smu10_disable_gfx_off(struct pp_hwmgr *hwmgr)
 
 static int smu10_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
 {
-       return smu10_disable_gfx_off(hwmgr);
+       return 0;
 }
 
 static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)
@@ -299,7 +328,7 @@ static int smu10_enable_gfx_off(struct pp_hwmgr *hwmgr)
 
 static int smu10_enable_dpm_tasks(struct pp_hwmgr *hwmgr)
 {
-       return smu10_enable_gfx_off(hwmgr);
+       return 0;
 }
 
 static int smu10_gfx_off_control(struct pp_hwmgr *hwmgr, bool enable)
@@ -1000,6 +1029,12 @@ static int smu10_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr,
        case amd_pp_soc_clock:
                pclk_vol_table = pinfo->vdd_dep_on_socclk;
                break;
+       case amd_pp_disp_clock:
+               pclk_vol_table = pinfo->vdd_dep_on_dispclk;
+               break;
+       case amd_pp_phy_clock:
+               pclk_vol_table = pinfo->vdd_dep_on_phyclk;
+               break;
        default:
                return -EINVAL;
        }
@@ -1017,39 +1052,7 @@ static int smu10_get_clock_by_type_with_voltage(struct pp_hwmgr *hwmgr,
        return 0;
 }
 
-static int smu10_display_clock_voltage_request(struct pp_hwmgr *hwmgr,
-               struct pp_display_clock_request *clock_req)
-{
-       struct smu10_hwmgr *smu10_data = (struct smu10_hwmgr *)(hwmgr->backend);
-       enum amd_pp_clock_type clk_type = clock_req->clock_type;
-       uint32_t clk_freq = clock_req->clock_freq_in_khz / 1000;
-       PPSMC_Msg        msg;
 
-       switch (clk_type) {
-       case amd_pp_dcf_clock:
-               if (clk_freq == smu10_data->dcf_actual_hard_min_freq)
-                       return 0;
-               msg =  PPSMC_MSG_SetHardMinDcefclkByFreq;
-               smu10_data->dcf_actual_hard_min_freq = clk_freq;
-               break;
-       case amd_pp_soc_clock:
-                msg = PPSMC_MSG_SetHardMinSocclkByFreq;
-               break;
-       case amd_pp_f_clock:
-               if (clk_freq == smu10_data->f_actual_hard_min_freq)
-                       return 0;
-               smu10_data->f_actual_hard_min_freq = clk_freq;
-               msg = PPSMC_MSG_SetHardMinFclkByFreq;
-               break;
-       default:
-               pr_info("[DisplayClockVoltageRequest]Invalid Clock Type!");
-               return -EINVAL;
-       }
-
-       smum_send_msg_to_smc_with_parameter(hwmgr, msg, clk_freq);
-
-       return 0;
-}
 
 static int smu10_get_max_high_clocks(struct pp_hwmgr *hwmgr, struct amd_pp_simple_clock_info *clocks)
 {
@@ -1182,6 +1185,7 @@ static const struct pp_hwmgr_func smu10_hwmgr_funcs = {
        .set_mmhub_powergating_by_smu = smu10_set_mmhub_powergating_by_smu,
        .smus_notify_pwe = smu10_smus_notify_pwe,
        .gfx_off_control = smu10_gfx_off_control,
+       .display_clock_voltage_request = smu10_display_clock_voltage_request,
 };
 
 int smu10_init_function_pointers(struct pp_hwmgr *hwmgr)
index 45e9b8cb169d8f6408b038c1bc1e32935417b54a..f8e866ceda02222a7c59e92a2d63cec1c4ea9dde 100644 (file)
@@ -791,7 +791,8 @@ static int smu7_setup_dpm_tables_v1(struct pp_hwmgr *hwmgr)
                        data->dpm_table.sclk_table.count++;
                }
        }
-
+       if (hwmgr->platform_descriptor.overdriveLimit.engineClock == 0)
+               hwmgr->platform_descriptor.overdriveLimit.engineClock = dep_sclk_table->entries[i-1].clk;
        /* Initialize Mclk DPM table based on allow Mclk values */
        data->dpm_table.mclk_table.count = 0;
        for (i = 0; i < dep_mclk_table->count; i++) {
@@ -806,6 +807,8 @@ static int smu7_setup_dpm_tables_v1(struct pp_hwmgr *hwmgr)
                }
        }
 
+       if (hwmgr->platform_descriptor.overdriveLimit.memoryClock == 0)
+               hwmgr->platform_descriptor.overdriveLimit.memoryClock = dep_mclk_table->entries[i-1].clk;
        return 0;
 }
 
@@ -3752,14 +3755,17 @@ static int smu7_trim_dpm_states(struct pp_hwmgr *hwmgr,
 static int smu7_generate_dpm_level_enable_mask(
                struct pp_hwmgr *hwmgr, const void *input)
 {
-       int result;
+       int result = 0;
        const struct phm_set_power_state_input *states =
                        (const struct phm_set_power_state_input *)input;
        struct smu7_hwmgr *data = (struct smu7_hwmgr *)(hwmgr->backend);
        const struct smu7_power_state *smu7_ps =
                        cast_const_phw_smu7_power_state(states->pnew_state);
 
-       result = smu7_trim_dpm_states(hwmgr, smu7_ps);
+       /*skip the trim if od is enabled*/
+       if (!hwmgr->od_enabled)
+               result = smu7_trim_dpm_states(hwmgr, smu7_ps);
+
        if (result)
                return result;
 
index d156b7bb92ae74a3b9b899f2e3a7907c5b0410f0..05e680d55dbbe06a6c951aa33d599e2dd6584424 100644 (file)
@@ -321,8 +321,12 @@ static int vega10_odn_initial_default_setting(struct pp_hwmgr *hwmgr)
                odn_table->min_vddc = dep_table[0]->entries[0].vddc;
 
        i = od_table[2]->count - 1;
-       od_table[2]->entries[i].clk = hwmgr->platform_descriptor.overdriveLimit.memoryClock;
-       od_table[2]->entries[i].vddc = odn_table->max_vddc;
+       od_table[2]->entries[i].clk = hwmgr->platform_descriptor.overdriveLimit.memoryClock > od_table[2]->entries[i].clk ?
+                                       hwmgr->platform_descriptor.overdriveLimit.memoryClock :
+                                       od_table[2]->entries[i].clk;
+       od_table[2]->entries[i].vddc = odn_table->max_vddc > od_table[2]->entries[i].vddc ?
+                                       odn_table->max_vddc :
+                                       od_table[2]->entries[i].vddc;
 
        return 0;
 }
@@ -1311,6 +1315,9 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr)
        vega10_setup_default_single_dpm_table(hwmgr,
                        dpm_table,
                        dep_gfx_table);
+       if (hwmgr->platform_descriptor.overdriveLimit.engineClock == 0)
+               hwmgr->platform_descriptor.overdriveLimit.engineClock =
+                                       dpm_table->dpm_levels[dpm_table->count-1].value;
        vega10_init_dpm_state(&(dpm_table->dpm_state));
 
        /* Initialize Mclk DPM table based on allow Mclk values */
@@ -1319,6 +1326,10 @@ static int vega10_setup_default_dpm_tables(struct pp_hwmgr *hwmgr)
        vega10_setup_default_single_dpm_table(hwmgr,
                        dpm_table,
                        dep_mclk_table);
+       if (hwmgr->platform_descriptor.overdriveLimit.memoryClock == 0)
+               hwmgr->platform_descriptor.overdriveLimit.memoryClock =
+                                       dpm_table->dpm_levels[dpm_table->count-1].value;
+
        vega10_init_dpm_state(&(dpm_table->dpm_state));
 
        data->dpm_table.eclk_table.count = 0;
index a9efd8554fbc2ffb103643b3a80683966c74f4b2..dbe4b1f66784961ea028b3fcfee564e830617f80 100644 (file)
@@ -1104,7 +1104,7 @@ static int vega10_enable_psm_gc_edc_config(struct pp_hwmgr *hwmgr)
        for (count = 0; count < num_se; count++) {
                data = GRBM_GFX_INDEX__INSTANCE_BROADCAST_WRITES_MASK | GRBM_GFX_INDEX__SH_BROADCAST_WRITES_MASK | ( count << GRBM_GFX_INDEX__SE_INDEX__SHIFT);
                WREG32_SOC15(GC, 0, mmGRBM_GFX_INDEX, data);
-               result |= vega10_program_didt_config_registers(hwmgr, PSMSEEDCStallPatternConfig_Vega10, VEGA10_CONFIGREG_DIDT);
+               result = vega10_program_didt_config_registers(hwmgr, PSMSEEDCStallPatternConfig_Vega10, VEGA10_CONFIGREG_DIDT);
                result |= vega10_program_didt_config_registers(hwmgr, PSMSEEDCStallDelayConfig_Vega10, VEGA10_CONFIGREG_DIDT);
                result |= vega10_program_didt_config_registers(hwmgr, PSMSEEDCCtrlResetConfig_Vega10, VEGA10_CONFIGREG_DIDT);
                result |= vega10_program_didt_config_registers(hwmgr, PSMSEEDCCtrlConfig_Vega10, VEGA10_CONFIGREG_DIDT);
index 0768d259c07c335f51971c634ac2bd41e014f12a..16b1a9cf6cf08219db8b4724cb29a55d8bef68f4 100644 (file)
@@ -267,12 +267,6 @@ static int init_over_drive_limits(
        hwmgr->platform_descriptor.maxOverdriveVDDC = 0;
        hwmgr->platform_descriptor.overdriveVDDCStep = 0;
 
-       if (hwmgr->platform_descriptor.overdriveLimit.engineClock == 0 ||
-               hwmgr->platform_descriptor.overdriveLimit.memoryClock == 0) {
-               hwmgr->od_enabled = false;
-               pr_debug("OverDrive feature not support by VBIOS\n");
-       }
-
        return 0;
 }
 
index 40e1e24f2ff0847d3d9fd65bd2069b28ab9b2c2a..a5808382bdf0333b2124a4ecf0d85c4346814000 100644 (file)
@@ -1633,7 +1633,8 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
                edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions;
                edid[0x7e] = valid_extensions;
 
-               new = kmalloc((valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL);
+               new = kmalloc_array(valid_extensions + 1, EDID_LENGTH,
+                                   GFP_KERNEL);
                if (!new)
                        goto out;
 
index dae18e58e79be6870a7061c07ec6c4f90e0e848b..c92b00d42ecea4ebb6bcf075fac6eb868c9ea0c9 100644 (file)
@@ -47,7 +47,7 @@ int drm_ht_create(struct drm_open_hash *ht, unsigned int order)
        if (size <= PAGE_SIZE / sizeof(*ht->table))
                ht->table = kcalloc(size, sizeof(*ht->table), GFP_KERNEL);
        else
-               ht->table = vzalloc(size*sizeof(*ht->table));
+               ht->table = vzalloc(array_size(size, sizeof(*ht->table)));
        if (!ht->table) {
                DRM_ERROR("Out of memory for hash table\n");
                return -ENOMEM;
index 3c54044214dbb5c1fbfc47efb59bbe0537448f33..d69e4fc1ee7735ede633c0714d6130c5fc366aac 100644 (file)
@@ -80,7 +80,7 @@ static void *agp_remap(unsigned long offset, unsigned long size,
         * page-table instead (that's probably faster anyhow...).
         */
        /* note: use vmalloc() because num_pages could be large... */
-       page_map = vmalloc(num_pages * sizeof(struct page *));
+       page_map = vmalloc(array_size(num_pages, sizeof(struct page *)));
        if (!page_map)
                return NULL;
 
index 7c3030b7e586db7ca245249a028dbfbedb829798..6d29777884f931eab3cde84986823b5341f0df76 100644 (file)
@@ -1723,8 +1723,8 @@ static int exynos_dsi_probe(struct platform_device *pdev)
                return -EPROBE_DEFER;
        }
 
-       dsi->clks = devm_kzalloc(dev,
-                       sizeof(*dsi->clks) * dsi->driver_data->num_clks,
+       dsi->clks = devm_kcalloc(dev,
+                       dsi->driver_data->num_clks, sizeof(*dsi->clks),
                        GFP_KERNEL);
        if (!dsi->clks)
                return -ENOMEM;
index 5ce84025d1cb80e577d47dc1f826fa5acb3e2bf4..6127ef25acd60ec5ec6db92655d364220963fc0b 100644 (file)
@@ -1271,7 +1271,8 @@ static int fimc_probe(struct platform_device *pdev)
 
        /* construct formats/limits array */
        num_formats = ARRAY_SIZE(fimc_formats) + ARRAY_SIZE(fimc_tiled_formats);
-       formats = devm_kzalloc(dev, sizeof(*formats) * num_formats, GFP_KERNEL);
+       formats = devm_kcalloc(dev, num_formats, sizeof(*formats),
+                              GFP_KERNEL);
        if (!formats)
                return -ENOMEM;
 
index e99dd1e4ba652ef493e7bec2e92642f5611ee492..35ac66730563944e83dcb1a6be7ec39999ead086 100644 (file)
@@ -1202,8 +1202,9 @@ static int gsc_probe(struct platform_device *pdev)
        if (!ctx)
                return -ENOMEM;
 
-       formats = devm_kzalloc(dev, sizeof(*formats) *
-                              (ARRAY_SIZE(gsc_formats)), GFP_KERNEL);
+       formats = devm_kcalloc(dev,
+                              ARRAY_SIZE(gsc_formats), sizeof(*formats),
+                              GFP_KERNEL);
        if (!formats)
                return -ENOMEM;
 
index 09c4bc0b1859f7bc8412cc3dfb3806ddaa0d3134..db91932550cf77d6459efab1b5540e7c8501dc38 100644 (file)
@@ -1692,7 +1692,7 @@ static int hdmi_clk_init(struct hdmi_context *hdata)
        if (!count)
                return 0;
 
-       clks = devm_kzalloc(dev, sizeof(*clks) * count, GFP_KERNEL);
+       clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL);
        if (!clks)
                return -ENOMEM;
 
index 7171b7475f589164020722fecf56bf8b56820ca7..237041a3753228bf420029cdbbb26a262f774a9a 100644 (file)
@@ -239,7 +239,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
        if (read_vbt_r10(addr, &vbt))
                return -1;
 
-       gct = kmalloc(sizeof(*gct) * vbt.panel_count, GFP_KERNEL);
+       gct = kmalloc_array(vbt.panel_count, sizeof(*gct), GFP_KERNEL);
        if (!gct)
                return -ENOMEM;
 
index 718ca08f95751af6303f1eb1b651f14cafe3ddc4..b51c05d03f14a1790ba43e70065af6acd74887ef 100644 (file)
@@ -2909,6 +2909,7 @@ static int init_cmd_table(struct intel_gvt *gvt)
                if (info) {
                        gvt_err("%s %s duplicated\n", e->info->name,
                                        info->name);
+                       kfree(e);
                        return -EEXIST;
                }
 
index b46b86892d58f1a39199369ee044d603e3d77eb7..ea7c1c525b8c36f8b57ed6bec9d05d6e13432cce 100644 (file)
@@ -67,7 +67,7 @@
 #define AUX_NATIVE_REPLY_NAK    (0x1 << 4)
 #define AUX_NATIVE_REPLY_DEFER  (0x2 << 4)
 
-#define AUX_BURST_SIZE          16
+#define AUX_BURST_SIZE          20
 
 /* DPCD addresses */
 #define DPCD_REV                       0x000
index 78e55aafc8bca047d42e5f853ed7025af005e96c..23296547da95e8634c3bbaa401225c2d415498d5 100644 (file)
@@ -1585,8 +1585,9 @@ static struct intel_vgpu_mm *intel_vgpu_create_ggtt_mm(struct intel_vgpu *vgpu)
        mm->type = INTEL_GVT_MM_GGTT;
 
        nr_entries = gvt_ggtt_gm_sz(vgpu->gvt) >> I915_GTT_PAGE_SHIFT;
-       mm->ggtt_mm.virtual_ggtt = vzalloc(nr_entries *
-                                       vgpu->gvt->device_info.gtt_entry_size);
+       mm->ggtt_mm.virtual_ggtt =
+               vzalloc(array_size(nr_entries,
+                                  vgpu->gvt->device_info.gtt_entry_size));
        if (!mm->ggtt_mm.virtual_ggtt) {
                vgpu_free_mm(mm);
                return ERR_PTR(-ENOMEM);
index 4b6532fb789a21d55505c0321c98708b5a290e45..bcbc47a88a7006a06107005b0faad5c02820c215 100644 (file)
@@ -903,11 +903,14 @@ static int dp_aux_ch_ctl_mmio_write(struct intel_vgpu *vgpu,
                }
 
                /*
-                * Write request format: (command + address) occupies
-                * 3 bytes, followed by (len + 1) bytes of data.
+                * Write request format: Headr (command + address + size) occupies
+                * 4 bytes, followed by (len + 1) bytes of data. See details at
+                * intel_dp_aux_transfer().
                 */
-               if (WARN_ON((len + 4) > AUX_BURST_SIZE))
+               if ((len + 1 + 4) > AUX_BURST_SIZE) {
+                       gvt_vgpu_err("dp_aux_header: len %d is too large\n", len);
                        return -EINVAL;
+               }
 
                /* unpack data from vreg to buf */
                for (t = 0; t < 4; t++) {
@@ -971,8 +974,10 @@ static int dp_aux_ch_ctl_mmio_write(struct intel_vgpu *vgpu,
                /*
                 * Read reply format: ACK (1 byte) plus (len + 1) bytes of data.
                 */
-               if (WARN_ON((len + 2) > AUX_BURST_SIZE))
+               if ((len + 2) > AUX_BURST_SIZE) {
+                       gvt_vgpu_err("dp_aux_header: len %d is too large\n", len);
                        return -EINVAL;
+               }
 
                /* read from virtual DPCD to vreg */
                /* first 4 bytes: [ACK][addr][addr+1][addr+2] */
index 1466d8769ec9facfc73c9ae4db922d0e09944840..df4e4a07db3d6809fa741e7c19c88e754700734e 100644 (file)
@@ -123,6 +123,12 @@ static int gvt_dma_map_page(struct intel_vgpu *vgpu, unsigned long gfn,
                return -EINVAL;
        }
 
+       if (!pfn_valid(pfn)) {
+               gvt_vgpu_err("pfn 0x%lx is not mem backed\n", pfn);
+               vfio_unpin_pages(mdev_dev(vgpu->vdev.mdev), &gfn, 1);
+               return -EINVAL;
+       }
+
        /* Setup DMA mapping. */
        page = pfn_to_page(pfn);
        *dma_addr = dma_map_page(dev, page, 0, PAGE_SIZE,
@@ -583,6 +589,17 @@ static int intel_vgpu_open(struct mdev_device *mdev)
        return ret;
 }
 
+static void intel_vgpu_release_msi_eventfd_ctx(struct intel_vgpu *vgpu)
+{
+       struct eventfd_ctx *trigger;
+
+       trigger = vgpu->vdev.msi_trigger;
+       if (trigger) {
+               eventfd_ctx_put(trigger);
+               vgpu->vdev.msi_trigger = NULL;
+       }
+}
+
 static void __intel_vgpu_release(struct intel_vgpu *vgpu)
 {
        struct kvmgt_guest_info *info;
@@ -607,6 +624,8 @@ static void __intel_vgpu_release(struct intel_vgpu *vgpu)
        info = (struct kvmgt_guest_info *)vgpu->handle;
        kvmgt_guest_exit(info);
 
+       intel_vgpu_release_msi_eventfd_ctx(vgpu);
+
        vgpu->vdev.kvm = NULL;
        vgpu->handle = 0;
 }
@@ -987,7 +1006,8 @@ static int intel_vgpu_set_msi_trigger(struct intel_vgpu *vgpu,
                        return PTR_ERR(trigger);
                }
                vgpu->vdev.msi_trigger = trigger;
-       }
+       } else if ((flags & VFIO_IRQ_SET_DATA_NONE) && !count)
+               intel_vgpu_release_msi_eventfd_ctx(vgpu);
 
        return 0;
 }
@@ -1592,6 +1612,18 @@ static int kvmgt_inject_msi(unsigned long handle, u32 addr, u16 data)
        info = (struct kvmgt_guest_info *)handle;
        vgpu = info->vgpu;
 
+       /*
+        * When guest is poweroff, msi_trigger is set to NULL, but vgpu's
+        * config and mmio register isn't restored to default during guest
+        * poweroff. If this vgpu is still used in next vm, this vgpu's pipe
+        * may be enabled, then once this vgpu is active, it will get inject
+        * vblank interrupt request. But msi_trigger is null until msi is
+        * enabled by guest. so if msi_trigger is null, success is still
+        * returned and don't inject interrupt into guest.
+        */
+       if (vgpu->vdev.msi_trigger == NULL)
+               return 0;
+
        if (eventfd_signal(vgpu->vdev.msi_trigger, 1) == 1)
                return 0;
 
index e4960aff68bd525ca9c2faca5128f5d00bbbd10d..b31eb36fc102e212218424f890e16b02ff2161ff 100644 (file)
@@ -267,7 +267,7 @@ int intel_vgpu_init_mmio(struct intel_vgpu *vgpu)
 {
        const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;
 
-       vgpu->mmio.vreg = vzalloc(info->mmio_size * 2);
+       vgpu->mmio.vreg = vzalloc(array_size(info->mmio_size, 2));
        if (!vgpu->mmio.vreg)
                return -ENOMEM;
 
index 2e0a02a80fe4d2b2473fcd060329086dc620bd05..572a18c2bfb509a4bbf6dc62056c5fece4b147a0 100644 (file)
@@ -121,7 +121,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
        high_avail = gvt_hidden_sz(gvt) - HOST_HIGH_GM_SIZE;
        num_types = sizeof(vgpu_types) / sizeof(vgpu_types[0]);
 
-       gvt->types = kzalloc(num_types * sizeof(struct intel_vgpu_type),
+       gvt->types = kcalloc(num_types, sizeof(struct intel_vgpu_type),
                             GFP_KERNEL);
        if (!gvt->types)
                return -ENOMEM;
index 0a2070112b66e79360479e53db54da4e0503b58d..3704f4c0c2c970c31b0c6031050b20126e7ae2a9 100644 (file)
@@ -2972,23 +2972,22 @@ i915_gem_find_active_request(struct intel_engine_cs *engine)
        struct i915_request *request, *active = NULL;
        unsigned long flags;
 
-       /* We are called by the error capture and reset at a random
-        * point in time. In particular, note that neither is crucially
-        * ordered with an interrupt. After a hang, the GPU is dead and we
-        * assume that no more writes can happen (we waited long enough for
-        * all writes that were in transaction to be flushed) - adding an
+       /*
+        * We are called by the error capture, reset and to dump engine
+        * state at random points in time. In particular, note that neither is
+        * crucially ordered with an interrupt. After a hang, the GPU is dead
+        * and we assume that no more writes can happen (we waited long enough
+        * for all writes that were in transaction to be flushed) - adding an
         * extra delay for a recent interrupt is pointless. Hence, we do
         * not need an engine->irq_seqno_barrier() before the seqno reads.
+        * At all other times, we must assume the GPU is still running, but
+        * we only care about the snapshot of this moment.
         */
        spin_lock_irqsave(&engine->timeline.lock, flags);
        list_for_each_entry(request, &engine->timeline.requests, link) {
                if (__i915_request_completed(request, request->global_seqno))
                        continue;
 
-               GEM_BUG_ON(request->engine != engine);
-               GEM_BUG_ON(test_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
-                                   &request->fence.flags));
-
                active = request;
                break;
        }
index b98ac0541f190271b71bbd9cdd7b6c690419bf2a..f4a8598a2d392d607e8d17338f1ff251bc7c627b 100644 (file)
@@ -2453,12 +2453,13 @@ void icl_map_plls_to_ports(struct drm_crtc *crtc,
        for_each_new_connector_in_state(old_state, conn, conn_state, i) {
                struct intel_encoder *encoder =
                        to_intel_encoder(conn_state->best_encoder);
-               enum port port = encoder->port;
+               enum port port;
                uint32_t val;
 
                if (conn_state->crtc != crtc)
                        continue;
 
+               port = encoder->port;
                mutex_lock(&dev_priv->dpll_lock);
 
                val = I915_READ(DPCLKA_CFGCR0_ICL);
@@ -2490,11 +2491,12 @@ void icl_unmap_plls_to_ports(struct drm_crtc *crtc,
        for_each_old_connector_in_state(old_state, conn, old_conn_state, i) {
                struct intel_encoder *encoder =
                        to_intel_encoder(old_conn_state->best_encoder);
-               enum port port = encoder->port;
+               enum port port;
 
                if (old_conn_state->crtc != crtc)
                        continue;
 
+               port = encoder->port;
                mutex_lock(&dev_priv->dpll_lock);
                I915_WRITE(DPCLKA_CFGCR0_ICL,
                           I915_READ(DPCLKA_CFGCR0_ICL) |
index ad588d5641988cc22bfef337abd49898b8d5c211..dee3a8e659f1d6c9dbe2040abd6e2ba42020070a 100644 (file)
@@ -3690,11 +3690,6 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
        plane_color_ctl |= glk_plane_color_ctl_alpha(fb->format->format);
 
        if (intel_format_is_yuv(fb->format->format)) {
-               if (fb->format->format == DRM_FORMAT_NV12) {
-                       plane_color_ctl |=
-                               PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;
-                       goto out;
-               }
                if (plane_state->base.color_encoding == DRM_COLOR_YCBCR_BT709)
                        plane_color_ctl |= PLANE_COLOR_CSC_MODE_YUV709_TO_RGB709;
                else
@@ -3703,7 +3698,7 @@ u32 glk_plane_color_ctl(const struct intel_crtc_state *crtc_state,
                if (plane_state->base.color_range == DRM_COLOR_YCBCR_FULL_RANGE)
                        plane_color_ctl |= PLANE_COLOR_YUV_RANGE_CORRECTION_DISABLE;
        }
-out:
+
        return plane_color_ctl;
 }
 
index dde92e4af5d34b7234dbc369e4719237b926a325..8320f0e8e3bef8587b94a908bf87f3eecdf63fc5 100644 (file)
@@ -1679,23 +1679,6 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
        return bpp;
 }
 
-static bool intel_edp_compare_alt_mode(struct drm_display_mode *m1,
-                                      struct drm_display_mode *m2)
-{
-       bool bres = false;
-
-       if (m1 && m2)
-               bres = (m1->hdisplay == m2->hdisplay &&
-                       m1->hsync_start == m2->hsync_start &&
-                       m1->hsync_end == m2->hsync_end &&
-                       m1->htotal == m2->htotal &&
-                       m1->vdisplay == m2->vdisplay &&
-                       m1->vsync_start == m2->vsync_start &&
-                       m1->vsync_end == m2->vsync_end &&
-                       m1->vtotal == m2->vtotal);
-       return bres;
-}
-
 /* Adjust link config limits based on compliance test requests. */
 static void
 intel_dp_adjust_compliance_config(struct intel_dp *intel_dp,
@@ -1860,16 +1843,8 @@ intel_dp_compute_config(struct intel_encoder *encoder,
                pipe_config->has_audio = intel_conn_state->force_audio == HDMI_AUDIO_ON;
 
        if (intel_dp_is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
-               struct drm_display_mode *panel_mode =
-                       intel_connector->panel.alt_fixed_mode;
-               struct drm_display_mode *req_mode = &pipe_config->base.mode;
-
-               if (!intel_edp_compare_alt_mode(req_mode, panel_mode))
-                       panel_mode = intel_connector->panel.fixed_mode;
-
-               drm_mode_debug_printmodeline(panel_mode);
-
-               intel_fixed_panel_mode(panel_mode, adjusted_mode);
+               intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
+                                      adjusted_mode);
 
                if (INTEL_GEN(dev_priv) >= 9) {
                        int ret;
@@ -6159,7 +6134,6 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
        struct drm_i915_private *dev_priv = to_i915(dev);
        struct drm_connector *connector = &intel_connector->base;
        struct drm_display_mode *fixed_mode = NULL;
-       struct drm_display_mode *alt_fixed_mode = NULL;
        struct drm_display_mode *downclock_mode = NULL;
        bool has_dpcd;
        struct drm_display_mode *scan;
@@ -6214,14 +6188,13 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
        }
        intel_connector->edid = edid;
 
-       /* prefer fixed mode from EDID if available, save an alt mode also */
+       /* prefer fixed mode from EDID if available */
        list_for_each_entry(scan, &connector->probed_modes, head) {
                if ((scan->type & DRM_MODE_TYPE_PREFERRED)) {
                        fixed_mode = drm_mode_duplicate(dev, scan);
                        downclock_mode = intel_dp_drrs_init(
                                                intel_connector, fixed_mode);
-               } else if (!alt_fixed_mode) {
-                       alt_fixed_mode = drm_mode_duplicate(dev, scan);
+                       break;
                }
        }
 
@@ -6258,8 +6231,7 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp,
                              pipe_name(pipe));
        }
 
-       intel_panel_init(&intel_connector->panel, fixed_mode, alt_fixed_mode,
-                        downclock_mode);
+       intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode);
        intel_connector->panel.backlight.power = intel_edp_backlight_power;
        intel_panel_setup_backlight(connector, pipe);
 
index d7dbca1aabffbdaeea5eb349e7459e733a0fbeff..0361130500a6f7fc0786b343c2193c1629fbb39f 100644 (file)
@@ -277,7 +277,6 @@ struct intel_encoder {
 
 struct intel_panel {
        struct drm_display_mode *fixed_mode;
-       struct drm_display_mode *alt_fixed_mode;
        struct drm_display_mode *downclock_mode;
 
        /* backlight */
@@ -1850,7 +1849,6 @@ void intel_overlay_reset(struct drm_i915_private *dev_priv);
 /* intel_panel.c */
 int intel_panel_init(struct intel_panel *panel,
                     struct drm_display_mode *fixed_mode,
-                    struct drm_display_mode *alt_fixed_mode,
                     struct drm_display_mode *downclock_mode);
 void intel_panel_fini(struct intel_panel *panel);
 void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
index 51a1d6868b1eac8f69d5db8b9b496fbf38cc4295..cf39ca90d887872ddb2de5e011041f785fda3996 100644 (file)
@@ -1846,7 +1846,7 @@ void intel_dsi_init(struct drm_i915_private *dev_priv)
        connector->display_info.width_mm = fixed_mode->width_mm;
        connector->display_info.height_mm = fixed_mode->height_mm;
 
-       intel_panel_init(&intel_connector->panel, fixed_mode, NULL, NULL);
+       intel_panel_init(&intel_connector->panel, fixed_mode, NULL);
        intel_panel_setup_backlight(connector, INVALID_PIPE);
 
        intel_dsi_add_properties(intel_connector);
index eb0c559b27156c0a49e31d342e865e7e88d1ea15..a70d767313aa10e198338e2e7472592827dfa347 100644 (file)
@@ -536,7 +536,7 @@ void intel_dvo_init(struct drm_i915_private *dev_priv)
                         */
                        intel_panel_init(&intel_connector->panel,
                                         intel_dvo_get_current_mode(intel_encoder),
-                                        NULL, NULL);
+                                        NULL);
                        intel_dvo->panel_wants_dither = true;
                }
 
index 6bfd7e3ed1524f354cb480df708bb4ae364ec060..1590375f31cb7ee5af71006d4eff6f07a66e5d68 100644 (file)
@@ -1114,7 +1114,7 @@ static void print_request(struct drm_printer *m,
                          const char *prefix)
 {
        const char *name = rq->fence.ops->get_timeline_name(&rq->fence);
-       char buf[80];
+       char buf[80] = "";
        int x = 0;
 
        x = print_sched_attr(rq->i915, &rq->sched.attr, buf, x, sizeof(buf));
index 2db5da550a1c1686d98e9d6c2895f1f7dbf6f0e4..0cc6a861bcf83ece9f4a317dd9581dd9741ecf81 100644 (file)
@@ -429,7 +429,7 @@ int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port,
        if (num_downstream == 0)
                return -EINVAL;
 
-       ksv_fifo = kzalloc(num_downstream * DRM_HDCP_KSV_LEN, GFP_KERNEL);
+       ksv_fifo = kcalloc(DRM_HDCP_KSV_LEN, num_downstream, GFP_KERNEL);
        if (!ksv_fifo)
                return -ENOMEM;
 
index e125d16a1aa72dbed9c958213b7039a466b6fbf2..d278f24ba6ae58bf4a704dc57610a53e9b042d25 100644 (file)
@@ -1175,8 +1175,7 @@ void intel_lvds_init(struct drm_i915_private *dev_priv)
 out:
        mutex_unlock(&dev->mode_config.mutex);
 
-       intel_panel_init(&intel_connector->panel, fixed_mode, NULL,
-                        downclock_mode);
+       intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode);
        intel_panel_setup_backlight(connector, INVALID_PIPE);
 
        lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder);
index 41d00b1603e304ff5694cc2bd8ec8daee80bc80c..b443278e569cedb1f9d7fbe36188eb6a9f67fd70 100644 (file)
@@ -1928,13 +1928,11 @@ intel_panel_init_backlight_funcs(struct intel_panel *panel)
 
 int intel_panel_init(struct intel_panel *panel,
                     struct drm_display_mode *fixed_mode,
-                    struct drm_display_mode *alt_fixed_mode,
                     struct drm_display_mode *downclock_mode)
 {
        intel_panel_init_backlight_funcs(panel);
 
        panel->fixed_mode = fixed_mode;
-       panel->alt_fixed_mode = alt_fixed_mode;
        panel->downclock_mode = downclock_mode;
 
        return 0;
@@ -1948,10 +1946,6 @@ void intel_panel_fini(struct intel_panel *panel)
        if (panel->fixed_mode)
                drm_mode_destroy(intel_connector->base.dev, panel->fixed_mode);
 
-       if (panel->alt_fixed_mode)
-               drm_mode_destroy(intel_connector->base.dev,
-                               panel->alt_fixed_mode);
-
        if (panel->downclock_mode)
                drm_mode_destroy(intel_connector->base.dev,
                                panel->downclock_mode);
index b85229e153c421c49ede59f5efd53af8318ed0fe..53aaaa3e6886d9eb472a1eb5b4f61955e12edc4a 100644 (file)
@@ -5150,7 +5150,6 @@ skl_copy_ddb_for_pipe(struct skl_ddb_values *dst,
               sizeof(dst->ddb.uv_plane[pipe]));
        memcpy(dst->ddb.plane[pipe], src->ddb.plane[pipe],
               sizeof(dst->ddb.plane[pipe]));
-       dst->ddb.enabled_slices = src->ddb.enabled_slices;
 }
 
 static void
index f76f2597df5c95b6bc6c9797c52a8246ec6269c0..47bc5b2ddb5602633b86fcb1c2f391b545d597b4 100644 (file)
@@ -137,7 +137,7 @@ static int intel_uncore_check_forcewake_domains(struct drm_i915_private *dev_pri
        if (!IS_ENABLED(CONFIG_DRM_I915_SELFTEST_BROKEN))
                return 0;
 
-       valid = kzalloc(BITS_TO_LONGS(FW_RANGE) * sizeof(*valid),
+       valid = kcalloc(BITS_TO_LONGS(FW_RANGE), sizeof(*valid),
                        GFP_KERNEL);
        if (!valid)
                return -ENOMEM;
index 7a1ad3af08e330c08519f287b600fa425a9b1780..20e956e14c2153fd31a3bfa170416e49e191f7a4 100644 (file)
@@ -98,21 +98,6 @@ static const struct drm_plane_funcs mdp4_plane_funcs = {
                .atomic_destroy_state = drm_atomic_helper_plane_destroy_state,
 };
 
-static int mdp4_plane_prepare_fb(struct drm_plane *plane,
-                                struct drm_plane_state *new_state)
-{
-       struct mdp4_plane *mdp4_plane = to_mdp4_plane(plane);
-       struct mdp4_kms *mdp4_kms = get_kms(plane);
-       struct msm_kms *kms = &mdp4_kms->base.base;
-       struct drm_framebuffer *fb = new_state->fb;
-
-       if (!fb)
-               return 0;
-
-       DBG("%s: prepare: FB[%u]", mdp4_plane->name, fb->base.id);
-       return msm_framebuffer_prepare(fb, kms->aspace);
-}
-
 static void mdp4_plane_cleanup_fb(struct drm_plane *plane,
                                  struct drm_plane_state *old_state)
 {
@@ -152,7 +137,7 @@ static void mdp4_plane_atomic_update(struct drm_plane *plane,
 }
 
 static const struct drm_plane_helper_funcs mdp4_plane_helper_funcs = {
-               .prepare_fb = mdp4_plane_prepare_fb,
+               .prepare_fb = msm_atomic_prepare_fb,
                .cleanup_fb = mdp4_plane_cleanup_fb,
                .atomic_check = mdp4_plane_atomic_check,
                .atomic_update = mdp4_plane_atomic_update,
index 76b96081916f0b9567a8b021d890cd572cad0534..10271359789e2b150c2268ca1500e7379e10b2aa 100644 (file)
@@ -430,6 +430,7 @@ static void mdp5_crtc_atomic_disable(struct drm_crtc *crtc,
        struct mdp5_crtc_state *mdp5_cstate = to_mdp5_crtc_state(crtc->state);
        struct mdp5_kms *mdp5_kms = get_kms(crtc);
        struct device *dev = &mdp5_kms->pdev->dev;
+       unsigned long flags;
 
        DBG("%s", crtc->name);
 
@@ -445,6 +446,14 @@ static void mdp5_crtc_atomic_disable(struct drm_crtc *crtc,
        mdp_irq_unregister(&mdp5_kms->base, &mdp5_crtc->err);
        pm_runtime_put_sync(dev);
 
+       if (crtc->state->event && !crtc->state->active) {
+               WARN_ON(mdp5_crtc->event);
+               spin_lock_irqsave(&mdp5_kms->dev->event_lock, flags);
+               drm_crtc_send_vblank_event(crtc, crtc->state->event);
+               crtc->state->event = NULL;
+               spin_unlock_irqrestore(&mdp5_kms->dev->event_lock, flags);
+       }
+
        mdp5_crtc->enabled = false;
 }
 
index 6d8e3a9a6fc093164adc20e37e7b70db54cfe7bf..6e12e275debae437877f566cefbe4d909e1b7f97 100644 (file)
@@ -70,60 +70,110 @@ static int mdp5_hw_init(struct msm_kms *kms)
        return 0;
 }
 
-struct mdp5_state *mdp5_get_state(struct drm_atomic_state *s)
+/* Global/shared object state funcs */
+
+/*
+ * This is a helper that returns the private state currently in operation.
+ * Note that this would return the "old_state" if called in the atomic check
+ * path, and the "new_state" after the atomic swap has been done.
+ */
+struct mdp5_global_state *
+mdp5_get_existing_global_state(struct mdp5_kms *mdp5_kms)
+{
+       return to_mdp5_global_state(mdp5_kms->glob_state.state);
+}
+
+/*
+ * This acquires the modeset lock set aside for global state, creates
+ * a new duplicated private object state.
+ */
+struct mdp5_global_state *mdp5_get_global_state(struct drm_atomic_state *s)
 {
        struct msm_drm_private *priv = s->dev->dev_private;
        struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
-       struct msm_kms_state *state = to_kms_state(s);
-       struct mdp5_state *new_state;
+       struct drm_private_state *priv_state;
        int ret;
 
-       if (state->state)
-               return state->state;
-
-       ret = drm_modeset_lock(&mdp5_kms->state_lock, s->acquire_ctx);
+       ret = drm_modeset_lock(&mdp5_kms->glob_state_lock, s->acquire_ctx);
        if (ret)
                return ERR_PTR(ret);
 
-       new_state = kmalloc(sizeof(*mdp5_kms->state), GFP_KERNEL);
-       if (!new_state)
-               return ERR_PTR(-ENOMEM);
+       priv_state = drm_atomic_get_private_obj_state(s, &mdp5_kms->glob_state);
+       if (IS_ERR(priv_state))
+               return ERR_CAST(priv_state);
 
-       /* Copy state: */
-       new_state->hwpipe = mdp5_kms->state->hwpipe;
-       new_state->hwmixer = mdp5_kms->state->hwmixer;
-       if (mdp5_kms->smp)
-               new_state->smp = mdp5_kms->state->smp;
+       return to_mdp5_global_state(priv_state);
+}
+
+static struct drm_private_state *
+mdp5_global_duplicate_state(struct drm_private_obj *obj)
+{
+       struct mdp5_global_state *state;
+
+       state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL);
+       if (!state)
+               return NULL;
 
-       state->state = new_state;
+       __drm_atomic_helper_private_obj_duplicate_state(obj, &state->base);
 
-       return new_state;
+       return &state->base;
 }
 
-static void mdp5_swap_state(struct msm_kms *kms, struct drm_atomic_state *state)
+static void mdp5_global_destroy_state(struct drm_private_obj *obj,
+                                     struct drm_private_state *state)
 {
-       struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
-       swap(to_kms_state(state)->state, mdp5_kms->state);
+       struct mdp5_global_state *mdp5_state = to_mdp5_global_state(state);
+
+       kfree(mdp5_state);
+}
+
+static const struct drm_private_state_funcs mdp5_global_state_funcs = {
+       .atomic_duplicate_state = mdp5_global_duplicate_state,
+       .atomic_destroy_state = mdp5_global_destroy_state,
+};
+
+static int mdp5_global_obj_init(struct mdp5_kms *mdp5_kms)
+{
+       struct mdp5_global_state *state;
+
+       drm_modeset_lock_init(&mdp5_kms->glob_state_lock);
+
+       state = kzalloc(sizeof(*state), GFP_KERNEL);
+       if (!state)
+               return -ENOMEM;
+
+       state->mdp5_kms = mdp5_kms;
+
+       drm_atomic_private_obj_init(&mdp5_kms->glob_state,
+                                   &state->base,
+                                   &mdp5_global_state_funcs);
+       return 0;
 }
 
 static void mdp5_prepare_commit(struct msm_kms *kms, struct drm_atomic_state *state)
 {
        struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
        struct device *dev = &mdp5_kms->pdev->dev;
+       struct mdp5_global_state *global_state;
+
+       global_state = mdp5_get_existing_global_state(mdp5_kms);
 
        pm_runtime_get_sync(dev);
 
        if (mdp5_kms->smp)
-               mdp5_smp_prepare_commit(mdp5_kms->smp, &mdp5_kms->state->smp);
+               mdp5_smp_prepare_commit(mdp5_kms->smp, &global_state->smp);
 }
 
 static void mdp5_complete_commit(struct msm_kms *kms, struct drm_atomic_state *state)
 {
        struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(kms));
        struct device *dev = &mdp5_kms->pdev->dev;
+       struct mdp5_global_state *global_state;
+
+       global_state = mdp5_get_existing_global_state(mdp5_kms);
 
        if (mdp5_kms->smp)
-               mdp5_smp_complete_commit(mdp5_kms->smp, &mdp5_kms->state->smp);
+               mdp5_smp_complete_commit(mdp5_kms->smp, &global_state->smp);
 
        pm_runtime_put_sync(dev);
 }
@@ -229,7 +279,6 @@ static const struct mdp_kms_funcs kms_funcs = {
                .irq             = mdp5_irq,
                .enable_vblank   = mdp5_enable_vblank,
                .disable_vblank  = mdp5_disable_vblank,
-               .swap_state      = mdp5_swap_state,
                .prepare_commit  = mdp5_prepare_commit,
                .complete_commit = mdp5_complete_commit,
                .wait_for_crtc_commit_done = mdp5_wait_for_crtc_commit_done,
@@ -727,7 +776,8 @@ static void mdp5_destroy(struct platform_device *pdev)
        if (mdp5_kms->rpm_enabled)
                pm_runtime_disable(&pdev->dev);
 
-       kfree(mdp5_kms->state);
+       drm_atomic_private_obj_fini(&mdp5_kms->glob_state);
+       drm_modeset_lock_fini(&mdp5_kms->glob_state_lock);
 }
 
 static int construct_pipes(struct mdp5_kms *mdp5_kms, int cnt,
@@ -880,12 +930,9 @@ static int mdp5_init(struct platform_device *pdev, struct drm_device *dev)
        mdp5_kms->dev = dev;
        mdp5_kms->pdev = pdev;
 
-       drm_modeset_lock_init(&mdp5_kms->state_lock);
-       mdp5_kms->state = kzalloc(sizeof(*mdp5_kms->state), GFP_KERNEL);
-       if (!mdp5_kms->state) {
-               ret = -ENOMEM;
+       ret = mdp5_global_obj_init(mdp5_kms);
+       if (ret)
                goto fail;
-       }
 
        mdp5_kms->mmio = msm_ioremap(pdev, "mdp_phys", "MDP5");
        if (IS_ERR(mdp5_kms->mmio)) {
index 425a03d213e5f54d1f8660dc3e95dc1549549c82..854dfd30e829256ed4922a1eb05bef4ab7733c1b 100644 (file)
@@ -28,8 +28,6 @@
 #include "mdp5_ctl.h"
 #include "mdp5_smp.h"
 
-struct mdp5_state;
-
 struct mdp5_kms {
        struct mdp_kms base;
 
@@ -49,11 +47,12 @@ struct mdp5_kms {
        struct mdp5_cfg_handler *cfg;
        uint32_t caps;  /* MDP capabilities (MDP_CAP_XXX bits) */
 
-       /**
-        * Global atomic state.  Do not access directly, use mdp5_get_state()
+       /*
+        * Global private object state, Do not access directly, use
+        * mdp5_global_get_state()
         */
-       struct mdp5_state *state;
-       struct drm_modeset_lock state_lock;
+       struct drm_modeset_lock glob_state_lock;
+       struct drm_private_obj glob_state;
 
        struct mdp5_smp *smp;
        struct mdp5_ctl_manager *ctlm;
@@ -81,19 +80,23 @@ struct mdp5_kms {
 };
 #define to_mdp5_kms(x) container_of(x, struct mdp5_kms, base)
 
-/* Global atomic state for tracking resources that are shared across
+/* Global private object state for tracking resources that are shared across
  * multiple kms objects (planes/crtcs/etc).
- *
- * For atomic updates which require modifying global state,
  */
-struct mdp5_state {
+#define to_mdp5_global_state(x) container_of(x, struct mdp5_global_state, base)
+struct mdp5_global_state {
+       struct drm_private_state base;
+
+       struct drm_atomic_state *state;
+       struct mdp5_kms *mdp5_kms;
+
        struct mdp5_hw_pipe_state hwpipe;
        struct mdp5_hw_mixer_state hwmixer;
        struct mdp5_smp_state smp;
 };
 
-struct mdp5_state *__must_check
-mdp5_get_state(struct drm_atomic_state *s);
+struct mdp5_global_state * mdp5_get_existing_global_state(struct mdp5_kms *mdp5_kms);
+struct mdp5_global_state *__must_check mdp5_get_global_state(struct drm_atomic_state *s);
 
 /* Atomic plane state.  Subclasses the base drm_plane_state in order to
  * track assigned hwpipe and hw specific state.
index 8a00991f03c7500df327a383026a14dc494519dd..113e6b569562cc2c2a1ae70bf07a205e559277c7 100644 (file)
@@ -52,14 +52,14 @@ int mdp5_mixer_assign(struct drm_atomic_state *s, struct drm_crtc *crtc,
 {
        struct msm_drm_private *priv = s->dev->dev_private;
        struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
-       struct mdp5_state *state = mdp5_get_state(s);
+       struct mdp5_global_state *global_state = mdp5_get_global_state(s);
        struct mdp5_hw_mixer_state *new_state;
        int i;
 
-       if (IS_ERR(state))
-               return PTR_ERR(state);
+       if (IS_ERR(global_state))
+               return PTR_ERR(global_state);
 
-       new_state = &state->hwmixer;
+       new_state = &global_state->hwmixer;
 
        for (i = 0; i < mdp5_kms->num_hwmixers; i++) {
                struct mdp5_hw_mixer *cur = mdp5_kms->hwmixers[i];
@@ -129,8 +129,8 @@ int mdp5_mixer_assign(struct drm_atomic_state *s, struct drm_crtc *crtc,
 
 void mdp5_mixer_release(struct drm_atomic_state *s, struct mdp5_hw_mixer *mixer)
 {
-       struct mdp5_state *state = mdp5_get_state(s);
-       struct mdp5_hw_mixer_state *new_state = &state->hwmixer;
+       struct mdp5_global_state *global_state = mdp5_get_global_state(s);
+       struct mdp5_hw_mixer_state *new_state = &global_state->hwmixer;
 
        if (!mixer)
                return;
index ff52c49095f906f7f8baa7b44a09292c3509bd1e..1ef26bc631631184493357519207849b58c74bd4 100644 (file)
@@ -24,17 +24,19 @@ int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
 {
        struct msm_drm_private *priv = s->dev->dev_private;
        struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
-       struct mdp5_state *state;
+       struct mdp5_global_state *new_global_state, *old_global_state;
        struct mdp5_hw_pipe_state *old_state, *new_state;
        int i, j;
 
-       state = mdp5_get_state(s);
-       if (IS_ERR(state))
-               return PTR_ERR(state);
+       new_global_state = mdp5_get_global_state(s);
+       if (IS_ERR(new_global_state))
+               return PTR_ERR(new_global_state);
 
-       /* grab old_state after mdp5_get_state(), since now we hold lock: */
-       old_state = &mdp5_kms->state->hwpipe;
-       new_state = &state->hwpipe;
+       /* grab old_state after mdp5_get_global_state(), since now we hold lock: */
+       old_global_state = mdp5_get_existing_global_state(mdp5_kms);
+
+       old_state = &old_global_state->hwpipe;
+       new_state = &new_global_state->hwpipe;
 
        for (i = 0; i < mdp5_kms->num_hwpipes; i++) {
                struct mdp5_hw_pipe *cur = mdp5_kms->hwpipes[i];
@@ -107,7 +109,7 @@ int mdp5_pipe_assign(struct drm_atomic_state *s, struct drm_plane *plane,
                WARN_ON(r_hwpipe);
 
                DBG("%s: alloc SMP blocks", (*hwpipe)->name);
-               ret = mdp5_smp_assign(mdp5_kms->smp, &state->smp,
+               ret = mdp5_smp_assign(mdp5_kms->smp, &new_global_state->smp,
                                (*hwpipe)->pipe, blkcfg);
                if (ret)
                        return -ENOMEM;
@@ -132,7 +134,7 @@ void mdp5_pipe_release(struct drm_atomic_state *s, struct mdp5_hw_pipe *hwpipe)
 {
        struct msm_drm_private *priv = s->dev->dev_private;
        struct mdp5_kms *mdp5_kms = to_mdp5_kms(to_mdp_kms(priv->kms));
-       struct mdp5_state *state = mdp5_get_state(s);
+       struct mdp5_global_state *state = mdp5_get_global_state(s);
        struct mdp5_hw_pipe_state *new_state = &state->hwpipe;
 
        if (!hwpipe)
index a9f31da7d45ad6aeebe67021bb4d8d7532655335..e09bc53a0e6543eb1093dc46c22617fd53647e0b 100644 (file)
@@ -245,20 +245,6 @@ static const struct drm_plane_funcs mdp5_plane_funcs = {
                .atomic_print_state = mdp5_plane_atomic_print_state,
 };
 
-static int mdp5_plane_prepare_fb(struct drm_plane *plane,
-                                struct drm_plane_state *new_state)
-{
-       struct mdp5_kms *mdp5_kms = get_kms(plane);
-       struct msm_kms *kms = &mdp5_kms->base.base;
-       struct drm_framebuffer *fb = new_state->fb;
-
-       if (!new_state->fb)
-               return 0;
-
-       DBG("%s: prepare: FB[%u]", plane->name, fb->base.id);
-       return msm_framebuffer_prepare(fb, kms->aspace);
-}
-
 static void mdp5_plane_cleanup_fb(struct drm_plane *plane,
                                  struct drm_plane_state *old_state)
 {
@@ -543,7 +529,7 @@ static void mdp5_plane_atomic_async_update(struct drm_plane *plane,
 }
 
 static const struct drm_plane_helper_funcs mdp5_plane_helper_funcs = {
-               .prepare_fb = mdp5_plane_prepare_fb,
+               .prepare_fb = msm_atomic_prepare_fb,
                .cleanup_fb = mdp5_plane_cleanup_fb,
                .atomic_check = mdp5_plane_atomic_check,
                .atomic_update = mdp5_plane_atomic_update,
index ae4983d9d0a5e6eaa9fda6e5f332daccd142200f..96c2b828dba4a7cf2934c95a16fa092a6d1c0152 100644 (file)
@@ -340,17 +340,20 @@ void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p)
        struct mdp5_kms *mdp5_kms = get_kms(smp);
        struct mdp5_hw_pipe_state *hwpstate;
        struct mdp5_smp_state *state;
+       struct mdp5_global_state *global_state;
        int total = 0, i, j;
 
        drm_printf(p, "name\tinuse\tplane\n");
        drm_printf(p, "----\t-----\t-----\n");
 
        if (drm_can_sleep())
-               drm_modeset_lock(&mdp5_kms->state_lock, NULL);
+               drm_modeset_lock(&mdp5_kms->glob_state_lock, NULL);
+
+       global_state = mdp5_get_existing_global_state(mdp5_kms);
 
        /* grab these *after* we hold the state_lock */
-       hwpstate = &mdp5_kms->state->hwpipe;
-       state = &mdp5_kms->state->smp;
+       hwpstate = &global_state->hwpipe;
+       state = &global_state->smp;
 
        for (i = 0; i < mdp5_kms->num_hwpipes; i++) {
                struct mdp5_hw_pipe *hwpipe = mdp5_kms->hwpipes[i];
@@ -374,7 +377,7 @@ void mdp5_smp_dump(struct mdp5_smp *smp, struct drm_printer *p)
                        bitmap_weight(state->state, smp->blk_cnt));
 
        if (drm_can_sleep())
-               drm_modeset_unlock(&mdp5_kms->state_lock);
+               drm_modeset_unlock(&mdp5_kms->glob_state_lock);
 }
 
 void mdp5_smp_destroy(struct mdp5_smp *smp)
@@ -384,7 +387,8 @@ void mdp5_smp_destroy(struct mdp5_smp *smp)
 
 struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms, const struct mdp5_smp_block *cfg)
 {
-       struct mdp5_smp_state *state = &mdp5_kms->state->smp;
+       struct mdp5_smp_state *state;
+       struct mdp5_global_state *global_state;
        struct mdp5_smp *smp = NULL;
        int ret;
 
@@ -398,6 +402,9 @@ struct mdp5_smp *mdp5_smp_init(struct mdp5_kms *mdp5_kms, const struct mdp5_smp_
        smp->blk_cnt = cfg->mmb_count;
        smp->blk_size = cfg->mmb_size;
 
+       global_state = mdp5_get_existing_global_state(mdp5_kms);
+       state = &global_state->smp;
+
        /* statically tied MMBs cannot be re-allocated: */
        bitmap_copy(state->state, cfg->reserved_state, smp->blk_cnt);
        memcpy(smp->reserved, cfg->reserved, sizeof(smp->reserved));
index 8baba30d6c659cfde69c52cd69b2adc3203c54a9..2f1a2780658a416bd4e5235f34cf110965bce569 100644 (file)
@@ -1036,7 +1036,6 @@ static int dsi_tx_buf_alloc(struct msm_dsi_host *msm_host, int size)
 
                ret = msm_gem_get_iova(msm_host->tx_gem_obj,
                                priv->kms->aspace, &iova);
-               mutex_unlock(&dev->struct_mutex);
                if (ret) {
                        pr_err("%s: failed to get iova, %d\n", __func__, ret);
                        return ret;
@@ -1067,9 +1066,20 @@ static int dsi_tx_buf_alloc(struct msm_dsi_host *msm_host, int size)
 static void dsi_tx_buf_free(struct msm_dsi_host *msm_host)
 {
        struct drm_device *dev = msm_host->dev;
+       struct msm_drm_private *priv;
 
+       /*
+        * This is possible if we're tearing down before we've had a chance to
+        * fully initialize. A very real possibility if our probe is deferred,
+        * in which case we'll hit msm_dsi_host_destroy() without having run
+        * through the dsi_tx_buf_alloc().
+        */
+       if (!dev)
+               return;
+
+       priv = dev->dev_private;
        if (msm_host->tx_gem_obj) {
-               msm_gem_put_iova(msm_host->tx_gem_obj, 0);
+               msm_gem_put_iova(msm_host->tx_gem_obj, priv->kms->aspace);
                drm_gem_object_put_unlocked(msm_host->tx_gem_obj);
                msm_host->tx_gem_obj = NULL;
        }
index e63dc0fb55f8c79225c1898964c0caa27c2ea6dc..c79659ca570655da77888052fc47a16bc53cf409 100644 (file)
@@ -157,8 +157,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
                hdmi->qfprom_mmio = NULL;
        }
 
-       hdmi->hpd_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_regs[0]) *
-                       config->hpd_reg_cnt, GFP_KERNEL);
+       hdmi->hpd_regs = devm_kcalloc(&pdev->dev,
+                                     config->hpd_reg_cnt,
+                                     sizeof(hdmi->hpd_regs[0]),
+                                     GFP_KERNEL);
        if (!hdmi->hpd_regs) {
                ret = -ENOMEM;
                goto fail;
@@ -178,8 +180,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
                hdmi->hpd_regs[i] = reg;
        }
 
-       hdmi->pwr_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_regs[0]) *
-                       config->pwr_reg_cnt, GFP_KERNEL);
+       hdmi->pwr_regs = devm_kcalloc(&pdev->dev,
+                                     config->pwr_reg_cnt,
+                                     sizeof(hdmi->pwr_regs[0]),
+                                     GFP_KERNEL);
        if (!hdmi->pwr_regs) {
                ret = -ENOMEM;
                goto fail;
@@ -199,8 +203,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
                hdmi->pwr_regs[i] = reg;
        }
 
-       hdmi->hpd_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_clks[0]) *
-                       config->hpd_clk_cnt, GFP_KERNEL);
+       hdmi->hpd_clks = devm_kcalloc(&pdev->dev,
+                                     config->hpd_clk_cnt,
+                                     sizeof(hdmi->hpd_clks[0]),
+                                     GFP_KERNEL);
        if (!hdmi->hpd_clks) {
                ret = -ENOMEM;
                goto fail;
@@ -219,8 +225,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev)
                hdmi->hpd_clks[i] = clk;
        }
 
-       hdmi->pwr_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_clks[0]) *
-                       config->pwr_clk_cnt, GFP_KERNEL);
+       hdmi->pwr_clks = devm_kcalloc(&pdev->dev,
+                                     config->pwr_clk_cnt,
+                                     sizeof(hdmi->pwr_clks[0]),
+                                     GFP_KERNEL);
        if (!hdmi->pwr_clks) {
                ret = -ENOMEM;
                goto fail;
index 5e631392dc851a035bdf8ee19a78deabe9ff3808..4157722d6b4dc897bd46cda2ce27436b2caa368b 100644 (file)
@@ -21,12 +21,12 @@ static int msm_hdmi_phy_resource_init(struct hdmi_phy *phy)
        struct device *dev = &phy->pdev->dev;
        int i, ret;
 
-       phy->regs = devm_kzalloc(dev, sizeof(phy->regs[0]) * cfg->num_regs,
+       phy->regs = devm_kcalloc(dev, cfg->num_regs, sizeof(phy->regs[0]),
                                 GFP_KERNEL);
        if (!phy->regs)
                return -ENOMEM;
 
-       phy->clks = devm_kzalloc(dev, sizeof(phy->clks[0]) * cfg->num_clks,
+       phy->clks = devm_kcalloc(dev, cfg->num_clks, sizeof(phy->clks[0]),
                                 GFP_KERNEL);
        if (!phy->clks)
                return -ENOMEM;
index bf5f8c39f34d2cb2bf53409acf69797bc9a95c75..f0635c3da7f48ad1bdc15c2305fe4d0b1cb48ff1 100644 (file)
  */
 
 #include "msm_drv.h"
-#include "msm_kms.h"
 #include "msm_gem.h"
-#include "msm_fence.h"
-
-struct msm_commit {
-       struct drm_device *dev;
-       struct drm_atomic_state *state;
-       struct work_struct work;
-       uint32_t crtc_mask;
-};
-
-static void commit_worker(struct work_struct *work);
-
-/* block until specified crtcs are no longer pending update, and
- * atomically mark them as pending update
- */
-static int start_atomic(struct msm_drm_private *priv, uint32_t crtc_mask)
-{
-       int ret;
-
-       spin_lock(&priv->pending_crtcs_event.lock);
-       ret = wait_event_interruptible_locked(priv->pending_crtcs_event,
-                       !(priv->pending_crtcs & crtc_mask));
-       if (ret == 0) {
-               DBG("start: %08x", crtc_mask);
-               priv->pending_crtcs |= crtc_mask;
-       }
-       spin_unlock(&priv->pending_crtcs_event.lock);
-
-       return ret;
-}
-
-/* clear specified crtcs (no longer pending update)
- */
-static void end_atomic(struct msm_drm_private *priv, uint32_t crtc_mask)
-{
-       spin_lock(&priv->pending_crtcs_event.lock);
-       DBG("end: %08x", crtc_mask);
-       priv->pending_crtcs &= ~crtc_mask;
-       wake_up_all_locked(&priv->pending_crtcs_event);
-       spin_unlock(&priv->pending_crtcs_event.lock);
-}
-
-static struct msm_commit *commit_init(struct drm_atomic_state *state)
-{
-       struct msm_commit *c = kzalloc(sizeof(*c), GFP_KERNEL);
-
-       if (!c)
-               return NULL;
-
-       c->dev = state->dev;
-       c->state = state;
-
-       INIT_WORK(&c->work, commit_worker);
-
-       return c;
-}
-
-static void commit_destroy(struct msm_commit *c)
-{
-       end_atomic(c->dev->dev_private, c->crtc_mask);
-       kfree(c);
-}
+#include "msm_kms.h"
 
 static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
                struct drm_atomic_state *old_state)
@@ -97,195 +36,48 @@ static void msm_atomic_wait_for_commit_done(struct drm_device *dev,
        }
 }
 
-/* The (potentially) asynchronous part of the commit.  At this point
- * nothing can fail short of armageddon.
- */
-static void complete_commit(struct msm_commit *c, bool async)
+int msm_atomic_prepare_fb(struct drm_plane *plane,
+                         struct drm_plane_state *new_state)
 {
-       struct drm_atomic_state *state = c->state;
-       struct drm_device *dev = state->dev;
-       struct msm_drm_private *priv = dev->dev_private;
+       struct msm_drm_private *priv = plane->dev->dev_private;
        struct msm_kms *kms = priv->kms;
+       struct drm_gem_object *obj;
+       struct msm_gem_object *msm_obj;
+       struct dma_fence *fence;
 
-       drm_atomic_helper_wait_for_fences(dev, state, false);
-
-       kms->funcs->prepare_commit(kms, state);
-
-       drm_atomic_helper_commit_modeset_disables(dev, state);
-
-       drm_atomic_helper_commit_planes(dev, state, 0);
-
-       drm_atomic_helper_commit_modeset_enables(dev, state);
-
-       /* NOTE: _wait_for_vblanks() only waits for vblank on
-        * enabled CRTCs.  So we end up faulting when disabling
-        * due to (potentially) unref'ing the outgoing fb's
-        * before the vblank when the disable has latched.
-        *
-        * But if it did wait on disabled (or newly disabled)
-        * CRTCs, that would be racy (ie. we could have missed
-        * the irq.  We need some way to poll for pipe shut
-        * down.  Or just live with occasionally hitting the
-        * timeout in the CRTC disable path (which really should
-        * not be critical path)
-        */
-
-       msm_atomic_wait_for_commit_done(dev, state);
-
-       drm_atomic_helper_cleanup_planes(dev, state);
+       if (!new_state->fb)
+               return 0;
 
-       kms->funcs->complete_commit(kms, state);
+       obj = msm_framebuffer_bo(new_state->fb, 0);
+       msm_obj = to_msm_bo(obj);
+       fence = reservation_object_get_excl_rcu(msm_obj->resv);
 
-       drm_atomic_state_put(state);
+       drm_atomic_set_fence_for_plane(new_state, fence);
 
-       commit_destroy(c);
-}
-
-static void commit_worker(struct work_struct *work)
-{
-       complete_commit(container_of(work, struct msm_commit, work), true);
+       return msm_framebuffer_prepare(new_state->fb, kms->aspace);
 }
 
-/**
- * drm_atomic_helper_commit - commit validated state object
- * @dev: DRM device
- * @state: the driver state object
- * @nonblock: nonblocking commit
- *
- * This function commits a with drm_atomic_helper_check() pre-validated state
- * object. This can still fail when e.g. the framebuffer reservation fails.
- *
- * RETURNS
- * Zero for success or -errno.
- */
-int msm_atomic_commit(struct drm_device *dev,
-               struct drm_atomic_state *state, bool nonblock)
+void msm_atomic_commit_tail(struct drm_atomic_state *state)
 {
+       struct drm_device *dev = state->dev;
        struct msm_drm_private *priv = dev->dev_private;
-       struct msm_commit *c;
-       struct drm_crtc *crtc;
-       struct drm_crtc_state *crtc_state;
-       struct drm_plane *plane;
-       struct drm_plane_state *old_plane_state, *new_plane_state;
-       int i, ret;
-
-       ret = drm_atomic_helper_prepare_planes(dev, state);
-       if (ret)
-               return ret;
-
-       /*
-        * Note that plane->atomic_async_check() should fail if we need
-        * to re-assign hwpipe or anything that touches global atomic
-        * state, so we'll never go down the async update path in those
-        * cases.
-        */
-       if (state->async_update) {
-               drm_atomic_helper_async_commit(dev, state);
-               drm_atomic_helper_cleanup_planes(dev, state);
-               return 0;
-       }
-
-       c = commit_init(state);
-       if (!c) {
-               ret = -ENOMEM;
-               goto error;
-       }
-
-       /*
-        * Figure out what crtcs we have:
-        */
-       for_each_new_crtc_in_state(state, crtc, crtc_state, i)
-               c->crtc_mask |= drm_crtc_mask(crtc);
-
-       /*
-        * Figure out what fence to wait for:
-        */
-       for_each_oldnew_plane_in_state(state, plane, old_plane_state, new_plane_state, i) {
-               if ((new_plane_state->fb != old_plane_state->fb) && new_plane_state->fb) {
-                       struct drm_gem_object *obj = msm_framebuffer_bo(new_plane_state->fb, 0);
-                       struct msm_gem_object *msm_obj = to_msm_bo(obj);
-                       struct dma_fence *fence = reservation_object_get_excl_rcu(msm_obj->resv);
+       struct msm_kms *kms = priv->kms;
 
-                       drm_atomic_set_fence_for_plane(new_plane_state, fence);
-               }
-       }
+       kms->funcs->prepare_commit(kms, state);
 
-       /*
-        * Wait for pending updates on any of the same crtc's and then
-        * mark our set of crtc's as busy:
-        */
-       ret = start_atomic(dev->dev_private, c->crtc_mask);
-       if (ret)
-               goto err_free;
+       drm_atomic_helper_commit_modeset_disables(dev, state);
 
-       BUG_ON(drm_atomic_helper_swap_state(state, false) < 0);
+       drm_atomic_helper_commit_planes(dev, state, 0);
 
-       /*
-        * This is the point of no return - everything below never fails except
-        * when the hw goes bonghits. Which means we can commit the new state on
-        * the software side now.
-        *
-        * swap driver private state while still holding state_lock
-        */
-       if (to_kms_state(state)->state)
-               priv->kms->funcs->swap_state(priv->kms, state);
+       drm_atomic_helper_commit_modeset_enables(dev, state);
 
-       /*
-        * Everything below can be run asynchronously without the need to grab
-        * any modeset locks at all under one conditions: It must be guaranteed
-        * that the asynchronous work has either been cancelled (if the driver
-        * supports it, which at least requires that the framebuffers get
-        * cleaned up with drm_atomic_helper_cleanup_planes()) or completed
-        * before the new state gets committed on the software side with
-        * drm_atomic_helper_swap_state().
-        *
-        * This scheme allows new atomic state updates to be prepared and
-        * checked in parallel to the asynchronous completion of the previous
-        * update. Which is important since compositors need to figure out the
-        * composition of the next frame right after having submitted the
-        * current layout.
-        */
+       msm_atomic_wait_for_commit_done(dev, state);
 
-       drm_atomic_state_get(state);
-       if (nonblock) {
-               queue_work(priv->atomic_wq, &c->work);
-               return 0;
-       }
+       kms->funcs->complete_commit(kms, state);
 
-       complete_commit(c, false);
+       drm_atomic_helper_wait_for_vblanks(dev, state);
 
-       return 0;
+       drm_atomic_helper_commit_hw_done(state);
 
-err_free:
-       kfree(c);
-error:
        drm_atomic_helper_cleanup_planes(dev, state);
-       return ret;
-}
-
-struct drm_atomic_state *msm_atomic_state_alloc(struct drm_device *dev)
-{
-       struct msm_kms_state *state = kzalloc(sizeof(*state), GFP_KERNEL);
-
-       if (!state || drm_atomic_state_init(dev, &state->base) < 0) {
-               kfree(state);
-               return NULL;
-       }
-
-       return &state->base;
-}
-
-void msm_atomic_state_clear(struct drm_atomic_state *s)
-{
-       struct msm_kms_state *state = to_kms_state(s);
-       drm_atomic_state_default_clear(&state->base);
-       kfree(state->state);
-       state->state = NULL;
-}
-
-void msm_atomic_state_free(struct drm_atomic_state *state)
-{
-       kfree(to_kms_state(state)->state);
-       drm_atomic_state_default_release(state);
-       kfree(state);
 }
index 30cd514d8f7c7ad697b3e3d52b45091375ea097d..021a0b6f9a597b0b22795c1fa18f97e5e14eb2c0 100644 (file)
@@ -41,10 +41,11 @@ static const struct drm_mode_config_funcs mode_config_funcs = {
        .fb_create = msm_framebuffer_create,
        .output_poll_changed = drm_fb_helper_output_poll_changed,
        .atomic_check = drm_atomic_helper_check,
-       .atomic_commit = msm_atomic_commit,
-       .atomic_state_alloc = msm_atomic_state_alloc,
-       .atomic_state_clear = msm_atomic_state_clear,
-       .atomic_state_free = msm_atomic_state_free,
+       .atomic_commit = drm_atomic_helper_commit,
+};
+
+static const struct drm_mode_config_helper_funcs mode_config_helper_funcs = {
+       .atomic_commit_tail = msm_atomic_commit_tail,
 };
 
 #ifdef CONFIG_DRM_MSM_REGISTER_LOGGING
@@ -384,7 +385,6 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
 
        priv->wq = alloc_ordered_workqueue("msm", 0);
        priv->atomic_wq = alloc_ordered_workqueue("msm:atomic", 0);
-       init_waitqueue_head(&priv->pending_crtcs_event);
 
        INIT_LIST_HEAD(&priv->inactive_list);
        INIT_LIST_HEAD(&priv->vblank_ctrl.event_list);
@@ -442,6 +442,7 @@ static int msm_drm_init(struct device *dev, struct drm_driver *drv)
        }
 
        ddev->mode_config.funcs = &mode_config_funcs;
+       ddev->mode_config.helper_private = &mode_config_helper_funcs;
 
        ret = drm_vblank_init(ddev, priv->num_crtcs);
        if (ret < 0) {
index 48ed5b9a8580c023c12d0d7858c3665e6ca8c4eb..b2da1fbf81e0f373c75a4a34ba62e04d8c10f339 100644 (file)
@@ -117,10 +117,6 @@ struct msm_drm_private {
        struct workqueue_struct *wq;
        struct workqueue_struct *atomic_wq;
 
-       /* crtcs pending async atomic updates: */
-       uint32_t pending_crtcs;
-       wait_queue_head_t pending_crtcs_event;
-
        unsigned int num_planes;
        struct drm_plane *planes[16];
 
@@ -160,8 +156,9 @@ struct msm_format {
        uint32_t pixel_format;
 };
 
-int msm_atomic_commit(struct drm_device *dev,
-               struct drm_atomic_state *state, bool nonblock);
+int msm_atomic_prepare_fb(struct drm_plane *plane,
+                         struct drm_plane_state *new_state);
+void msm_atomic_commit_tail(struct drm_atomic_state *state);
 struct drm_atomic_state *msm_atomic_state_alloc(struct drm_device *dev);
 void msm_atomic_state_clear(struct drm_atomic_state *state);
 void msm_atomic_state_free(struct drm_atomic_state *state);
index aaa329dc020ece445a5334329ae8ab34f68c8035..dfd92947de2c88a7b3e0c9e963ba202093215aec 100644 (file)
@@ -40,8 +40,6 @@ struct msm_kms_funcs {
        irqreturn_t (*irq)(struct msm_kms *kms);
        int (*enable_vblank)(struct msm_kms *kms, struct drm_crtc *crtc);
        void (*disable_vblank)(struct msm_kms *kms, struct drm_crtc *crtc);
-       /* swap global atomic state: */
-       void (*swap_state)(struct msm_kms *kms, struct drm_atomic_state *state);
        /* modeset, bracketing atomic_commit(): */
        void (*prepare_commit)(struct msm_kms *kms, struct drm_atomic_state *state);
        void (*complete_commit)(struct msm_kms *kms, struct drm_atomic_state *state);
@@ -80,18 +78,6 @@ struct msm_kms {
        struct msm_gem_address_space *aspace;
 };
 
-/**
- * Subclass of drm_atomic_state, to allow kms backend to have driver
- * private global state.  The kms backend can do whatever it wants
- * with the ->state ptr.  On ->atomic_state_clear() the ->state ptr
- * is kfree'd and set back to NULL.
- */
-struct msm_kms_state {
-       struct drm_atomic_state base;
-       void *state;
-};
-#define to_kms_state(x) container_of(x, struct msm_kms_state, base)
-
 static inline void msm_kms_init(struct msm_kms *kms,
                const struct msm_kms_funcs *funcs)
 {
index 090664899247ac3d38dbb510ffbc4f06c437f707..e721bb2163a066727bd306c8a4dca2f82f5dd2eb 100644 (file)
@@ -141,7 +141,7 @@ nv84_fence_suspend(struct nouveau_drm *drm)
        struct nv84_fence_priv *priv = drm->fence;
        int i;
 
-       priv->suspend = vmalloc(drm->chan.nr * sizeof(u32));
+       priv->suspend = vmalloc(array_size(sizeof(u32), drm->chan.nr));
        if (priv->suspend) {
                for (i = 0; i < drm->chan.nr; i++)
                        priv->suspend[i] = nouveau_bo_rd32(priv->bo, i*4);
index 99d4fd17543c4791b797d31963a1d4950802234d..e84a2e2ff043152b058c519eadfceee4741286e5 100644 (file)
@@ -50,8 +50,8 @@ nvif_fifo_runlists(struct nvif_device *device)
                goto done;
 
        device->runlists = fls64(a->v.runlists.data);
-       device->runlist = kzalloc(sizeof(*device->runlist) *
-                                 device->runlists, GFP_KERNEL);
+       device->runlist = kcalloc(device->runlists, sizeof(*device->runlist),
+                                 GFP_KERNEL);
        if (!device->runlist) {
                ret = -ENOMEM;
                goto done;
index 358ac4f3cf91d75a23d6844c36673d3aad832803..ae08a1ca804484b6329a5712474b158ea6b6d7ea 100644 (file)
@@ -65,12 +65,15 @@ nvif_mmu_init(struct nvif_object *parent, s32 oclass, struct nvif_mmu *mmu)
                goto done;
        mmu->mem = mems[ret].oclass;
 
-       mmu->heap = kmalloc(sizeof(*mmu->heap) * mmu->heap_nr, GFP_KERNEL);
-       mmu->type = kmalloc(sizeof(*mmu->type) * mmu->type_nr, GFP_KERNEL);
+       mmu->heap = kmalloc_array(mmu->heap_nr, sizeof(*mmu->heap),
+                                 GFP_KERNEL);
+       mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
+                                 GFP_KERNEL);
        if (ret = -ENOMEM, !mmu->heap || !mmu->type)
                goto done;
 
-       mmu->kind = kmalloc(sizeof(*mmu->kind) * mmu->kind_nr, GFP_KERNEL);
+       mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind),
+                                 GFP_KERNEL);
        if (!mmu->kind && mmu->kind_nr)
                goto done;
 
index 40adfe9b334b3c45f899f543d161b2a2ee6cdf51..ef3f62840e835d6e64d81c41cbd8d7d44b967abc 100644 (file)
@@ -83,7 +83,7 @@ nvif_object_sclass_get(struct nvif_object *object, struct nvif_sclass **psclass)
                        return ret;
        }
 
-       *psclass = kzalloc(sizeof(**psclass) * args->sclass.count, GFP_KERNEL);
+       *psclass = kcalloc(args->sclass.count, sizeof(**psclass), GFP_KERNEL);
        if (*psclass) {
                for (i = 0; i < args->sclass.count; i++) {
                        (*psclass)[i].oclass = args->sclass.oclass[i].oclass;
index 191832be6c6586dd6f28fc5c83ea07e766fd5cdf..6b9c5776547f762829d5c6517d8d5fd98cfc1eee 100644 (file)
@@ -138,7 +138,8 @@ nvif_vmm_init(struct nvif_mmu *mmu, s32 oclass, u64 addr, u64 size,
        vmm->limit = args->size;
 
        vmm->page_nr = args->page_nr;
-       vmm->page = kmalloc(sizeof(*vmm->page) * vmm->page_nr, GFP_KERNEL);
+       vmm->page = kmalloc_array(vmm->page_nr, sizeof(*vmm->page),
+                                 GFP_KERNEL);
        if (!vmm->page) {
                ret = -ENOMEM;
                goto done;
index 4e8d3fa042df8e383fd5aee7e99ae3b33242927b..006618d77aa46dd6424d1acfeda43ebd28fb5cb9 100644 (file)
@@ -84,7 +84,8 @@ int
 nvkm_event_init(const struct nvkm_event_func *func, int types_nr, int index_nr,
                struct nvkm_event *event)
 {
-       event->refs = kzalloc(sizeof(*event->refs) * index_nr * types_nr,
+       event->refs = kzalloc(array3_size(index_nr, types_nr,
+                                         sizeof(*event->refs)),
                              GFP_KERNEL);
        if (!event->refs)
                return -ENOMEM;
index a99046414a18e3445dc828e61d6c870218272bb9..afccf9721cf0af3c7759cba6d406ac37c6c96d33 100644 (file)
@@ -910,7 +910,7 @@ gk104_fifo_oneinit(struct nvkm_fifo *base)
        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)))
+       if (!(map = kcalloc(fifo->pbdma_nr, sizeof(*map), GFP_KERNEL)))
                return -ENOMEM;
 
        for (i = 0; i < fifo->pbdma_nr; i++)
index 73e463ed55c3556d1ff0813fbc06cb9b9f694493..dea444d48f944162310fced2d6d25944009c3724 100644 (file)
@@ -73,7 +73,8 @@ nvbios_iccsense_parse(struct nvkm_bios *bios, struct nvbios_iccsense *iccsense)
        }
 
        iccsense->nr_entry = cnt;
-       iccsense->rail = kmalloc(sizeof(struct pwr_rail_t) * cnt, GFP_KERNEL);
+       iccsense->rail = kmalloc_array(cnt, sizeof(struct pwr_rail_t),
+                                      GFP_KERNEL);
        if (!iccsense->rail)
                return -ENOMEM;
 
index 920b3d3478030653cfaf775de433ea1e2cd35552..bbfde1cb3a17cb9cff327e539019a60d7b5d1c40 100644 (file)
@@ -171,7 +171,7 @@ gt215_link_train(struct gt215_ram *ram)
                return -ENOSYS;
 
        /* XXX: Multiple partitions? */
-       result = kmalloc(64 * sizeof(u32), GFP_KERNEL);
+       result = kmalloc_array(64, sizeof(u32), GFP_KERNEL);
        if (!result)
                return -ENOMEM;
 
index 39808489f21d02fae71e699c688c12ebde077bcb..92e363dbbc5a6efeba3c28a03f8c3f1e47fa20d6 100644 (file)
@@ -191,9 +191,9 @@ nvkm_mem_new_host(struct nvkm_mmu *mmu, int type, u8 page, u64 size,
        nvkm_memory_ctor(&nvkm_mem_dma, &mem->memory);
        size = ALIGN(size, PAGE_SIZE) >> PAGE_SHIFT;
 
-       if (!(mem->mem = kvmalloc(sizeof(*mem->mem) * size, GFP_KERNEL)))
+       if (!(mem->mem = kvmalloc_array(size, sizeof(*mem->mem), GFP_KERNEL)))
                return -ENOMEM;
-       if (!(mem->dma = kvmalloc(sizeof(*mem->dma) * size, GFP_KERNEL)))
+       if (!(mem->dma = kvmalloc_array(size, sizeof(*mem->dma), GFP_KERNEL)))
                return -ENOMEM;
 
        if (mmu->dma_bits > 32)
index 1c12e58f44c2684b5ce0d84a18e286b55a01235f..de269eb482dd03cc7c2fd8b5a707d1566b1360e5 100644 (file)
@@ -59,7 +59,7 @@ nvkm_vmm_pt_new(const struct nvkm_vmm_desc *desc, bool sparse,
        pgt->sparse = sparse;
 
        if (desc->type == PGD) {
-               pgt->pde = kvzalloc(sizeof(*pgt->pde) * pten, GFP_KERNEL);
+               pgt->pde = kvcalloc(pten, sizeof(*pgt->pde), GFP_KERNEL);
                if (!pgt->pde) {
                        kfree(pgt);
                        return NULL;
index 401c02e9e6b2e2b69e3bcaf35e1e390be09dc0b4..f92fe205550bc9c65df236e97be485fbb428ee87 100644 (file)
@@ -940,8 +940,8 @@ int tiler_map_show(struct seq_file *s, void *arg)
        h_adj = omap_dmm->container_height / ydiv;
        w_adj = omap_dmm->container_width / xdiv;
 
-       map = kmalloc(h_adj * sizeof(*map), GFP_KERNEL);
-       global_map = kmalloc((w_adj + 1) * h_adj, GFP_KERNEL);
+       map = kmalloc_array(h_adj, sizeof(*map), GFP_KERNEL);
+       global_map = kmalloc_array(w_adj + 1, h_adj, GFP_KERNEL);
 
        if (!map || !global_map)
                goto error;
index 0faf042b82e187ace34fa66ffb6affe262a684be..17a53d2079781c00ad743a3c0da9ac271024d589 100644 (file)
@@ -244,7 +244,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
         * DSS, GPU, etc. are not cache coherent:
         */
        if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
-               addrs = kmalloc(npages * sizeof(*addrs), GFP_KERNEL);
+               addrs = kmalloc_array(npages, sizeof(*addrs), GFP_KERNEL);
                if (!addrs) {
                        ret = -ENOMEM;
                        goto free_pages;
@@ -268,7 +268,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
                        }
                }
        } else {
-               addrs = kzalloc(npages * sizeof(*addrs), GFP_KERNEL);
+               addrs = kcalloc(npages, sizeof(*addrs), GFP_KERNEL);
                if (!addrs) {
                        ret = -ENOMEM;
                        goto free_pages;
index 9a6752606079e39356bbb9f2f555a6618be50a68..ca465c0d49fa55e0ded76d7c18b8f0bd2e9e45ed 100644 (file)
@@ -241,7 +241,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
        DRM_DEBUG_DRIVER("%dx%d %d\n", mode_cmd.width,
                         mode_cmd.height, mode_cmd.pitches[0]);
 
-       shadow = vmalloc(mode_cmd.pitches[0] * mode_cmd.height);
+       shadow = vmalloc(array_size(mode_cmd.pitches[0], mode_cmd.height));
        /* TODO: what's the usual response to memory allocation errors? */
        BUG_ON(!shadow);
        DRM_DEBUG_DRIVER("surface0 at gpu offset %lld, mmap_offset %lld (virt %p, shadow %p)\n",
index c5716a0ca3b8b2c4afd3b1f60948127bedc90e0a..771250aed78df56bc78b87043eef1620523e0472 100644 (file)
@@ -200,8 +200,8 @@ int qxl_device_init(struct qxl_device *qdev,
                (~(uint64_t)0) >> (qdev->slot_id_bits + qdev->slot_gen_bits);
 
        qdev->mem_slots =
-               kmalloc(qdev->n_mem_slots * sizeof(struct qxl_memslot),
-                       GFP_KERNEL);
+               kmalloc_array(qdev->n_mem_slots, sizeof(struct qxl_memslot),
+                             GFP_KERNEL);
 
        idr_init(&qdev->release_idr);
        spin_lock_init(&qdev->release_idr_lock);
index 6a2e091aa7b637c2ba19a779e2b7d59e00f7d41b..e55cbeee7a5376bb8008042dd53a160bc6e06f95 100644 (file)
@@ -1176,7 +1176,7 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32
        ectx.abort = false;
        ectx.last_jump = 0;
        if (ws)
-               ectx.ws = kzalloc(4 * ws, GFP_KERNEL);
+               ectx.ws = kcalloc(4, ws, GFP_KERNEL);
        else
                ectx.ws = NULL;
 
index 95652e643da13237cdd471f0c2ed5f47c39db9e3..0aef4937c901a2502133a2c22e2f74735f87ba04 100644 (file)
@@ -2581,7 +2581,9 @@ int btc_dpm_init(struct radeon_device *rdev)
                return ret;
 
        rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct radeon_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                r600_free_extended_power_table(rdev);
                return -ENOMEM;
index 7e1b04dc55937fbd450b46bdbfcc383af043a180..b9302c91827100398591bd0852ca8e0ada7854ed 100644 (file)
@@ -5568,8 +5568,9 @@ static int ci_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
@@ -5770,7 +5771,9 @@ int ci_dpm_init(struct radeon_device *rdev)
        ci_set_private_data_variables_based_on_pptable(rdev);
 
        rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct radeon_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                ci_dpm_fini(rdev);
                return -ENOMEM;
index ae1529b0ef6f41b52ddee28b659f3ea6f2fe85be..f055d6ea3522c6ed94825c5b44de86c2b0446397 100644 (file)
@@ -2660,8 +2660,9 @@ static int kv_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
index 9416e72f86aafcc2bcb8cb126e05641f9fe52f39..0fd8d6ba98287ed55acda0b01dc71222ad491c37 100644 (file)
@@ -3998,8 +3998,9 @@ static int ni_parse_power_table(struct radeon_device *rdev)
                return -EINVAL;
        power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
 
@@ -4075,7 +4076,9 @@ int ni_dpm_init(struct radeon_device *rdev)
                return ret;
 
        rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct radeon_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                r600_free_extended_power_table(rdev);
                return -ENOMEM;
index 31d1b471084468f945d0c8738bf1a47488ebee50..73d4c53481168b1681aa43df7bc85059b22b7397 100644 (file)
@@ -991,7 +991,7 @@ int r600_parse_extended_power_table(struct radeon_device *rdev)
                        ATOM_PPLIB_PhaseSheddingLimits_Record *entry;
 
                        rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries =
-                               kzalloc(psl->ucNumEntries *
+                               kcalloc(psl->ucNumEntries,
                                        sizeof(struct radeon_phase_shedding_limits_entry),
                                        GFP_KERNEL);
                        if (!rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) {
index 4134759a682315c9518b67e29951c7f177dadb1c..f422a8d6aec408d6c7a6568fd7e9d401131c41bb 100644 (file)
@@ -2126,13 +2126,16 @@ static int radeon_atombios_parse_power_table_1_3(struct radeon_device *rdev)
                num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK;
        if (num_modes == 0)
                return state_index;
-       rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * num_modes, GFP_KERNEL);
+       rdev->pm.power_state = kcalloc(num_modes,
+                                      sizeof(struct radeon_power_state),
+                                      GFP_KERNEL);
        if (!rdev->pm.power_state)
                return state_index;
        /* last mode is usually default, array is low to high */
        for (i = 0; i < num_modes; i++) {
                rdev->pm.power_state[state_index].clock_info =
-                       kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
+                       kcalloc(1, sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                if (!rdev->pm.power_state[state_index].clock_info)
                        return state_index;
                rdev->pm.power_state[state_index].num_clock_modes = 1;
@@ -2587,8 +2590,9 @@ static int radeon_atombios_parse_power_table_4_5(struct radeon_device *rdev)
        radeon_atombios_add_pplib_thermal_controller(rdev, &power_info->pplib.sThermalController);
        if (power_info->pplib.ucNumStates == 0)
                return state_index;
-       rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
-                                      power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.power_state = kcalloc(power_info->pplib.ucNumStates,
+                                      sizeof(struct radeon_power_state),
+                                      GFP_KERNEL);
        if (!rdev->pm.power_state)
                return state_index;
        /* first mode is usually default, followed by low to high */
@@ -2603,10 +2607,11 @@ static int radeon_atombios_parse_power_table_4_5(struct radeon_device *rdev)
                         le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset) +
                         (power_state->v1.ucNonClockStateIndex *
                          power_info->pplib.ucNonClockSize));
-               rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct radeon_pm_clock_info) *
-                                                            ((power_info->pplib.ucStateEntrySize - 1) ?
-                                                             (power_info->pplib.ucStateEntrySize - 1) : 1),
-                                                            GFP_KERNEL);
+               rdev->pm.power_state[i].clock_info =
+                       kcalloc((power_info->pplib.ucStateEntrySize - 1) ?
+                               (power_info->pplib.ucStateEntrySize - 1) : 1,
+                               sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                if (!rdev->pm.power_state[i].clock_info)
                        return state_index;
                if (power_info->pplib.ucStateEntrySize - 1) {
@@ -2688,8 +2693,9 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
        if (state_array->ucNumEntries == 0)
                return state_index;
-       rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
-                                      state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.power_state = kcalloc(state_array->ucNumEntries,
+                                      sizeof(struct radeon_power_state),
+                                      GFP_KERNEL);
        if (!rdev->pm.power_state)
                return state_index;
        power_state_offset = (u8 *)state_array->states;
@@ -2699,10 +2705,11 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
                non_clock_array_index = power_state->v2.nonClockInfoIndex;
                non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
                        &non_clock_info_array->nonClockInfo[non_clock_array_index];
-               rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct radeon_pm_clock_info) *
-                                                            (power_state->v2.ucNumDPMLevels ?
-                                                             power_state->v2.ucNumDPMLevels : 1),
-                                                            GFP_KERNEL);
+               rdev->pm.power_state[i].clock_info =
+                       kcalloc(power_state->v2.ucNumDPMLevels ?
+                               power_state->v2.ucNumDPMLevels : 1,
+                               sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                if (!rdev->pm.power_state[i].clock_info)
                        return state_index;
                if (power_state->v2.ucNumDPMLevels) {
@@ -2782,7 +2789,9 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
                rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state), GFP_KERNEL);
                if (rdev->pm.power_state) {
                        rdev->pm.power_state[0].clock_info =
-                               kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
+                               kcalloc(1,
+                                       sizeof(struct radeon_pm_clock_info),
+                                       GFP_KERNEL);
                        if (rdev->pm.power_state[0].clock_info) {
                                /* add the default mode */
                                rdev->pm.power_state[state_index].type =
index 3178ba0c537c1915af3b857aad83efd6371f17ad..60a61d33f6076e6bd81223173495613ec0c0950f 100644 (file)
@@ -2642,13 +2642,16 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev)
        rdev->pm.default_power_state_index = -1;
 
        /* allocate 2 power states */
-       rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL);
+       rdev->pm.power_state = kcalloc(2, sizeof(struct radeon_power_state),
+                                      GFP_KERNEL);
        if (rdev->pm.power_state) {
                /* allocate 1 clock mode per state */
                rdev->pm.power_state[0].clock_info =
-                       kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
+                       kcalloc(1, sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                rdev->pm.power_state[1].clock_info =
-                       kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
+                       kcalloc(1, sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                if (!rdev->pm.power_state[0].clock_info ||
                    !rdev->pm.power_state[1].clock_info)
                        goto pm_failed;
index 0b3ec35515f3b940216df1d48fcd18b57a8779af..1cef155cc933e8a7ac2d014d21580a0990801e12 100644 (file)
@@ -347,13 +347,14 @@ int radeon_gart_init(struct radeon_device *rdev)
        DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n",
                 rdev->gart.num_cpu_pages, rdev->gart.num_gpu_pages);
        /* Allocate pages table */
-       rdev->gart.pages = vzalloc(sizeof(void *) * rdev->gart.num_cpu_pages);
+       rdev->gart.pages = vzalloc(array_size(sizeof(void *),
+                                  rdev->gart.num_cpu_pages));
        if (rdev->gart.pages == NULL) {
                radeon_gart_fini(rdev);
                return -ENOMEM;
        }
-       rdev->gart.pages_entry = vmalloc(sizeof(uint64_t) *
-                                        rdev->gart.num_gpu_pages);
+       rdev->gart.pages_entry = vmalloc(array_size(sizeof(uint64_t),
+                                                   rdev->gart.num_gpu_pages));
        if (rdev->gart.pages_entry == NULL) {
                radeon_gart_fini(rdev);
                return -ENOMEM;
index f5e9abfadb560879ad98e889987e031ac9f1379b..48f4b273e31611f2b026b64bd555e67ff7fc14a4 100644 (file)
@@ -59,7 +59,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
        n = rdev->mc.gtt_size - rdev->gart_pin_size;
        n /= size;
 
-       gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL);
+       gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
        if (!gtt_obj) {
                DRM_ERROR("Failed to allocate %d pointers\n", n);
                r = 1;
index b5e4e09a89961629e8de3ab7c9ed3c03af05545f..694b7b3e97992ac3b88dfeefa186b875e91cae85 100644 (file)
@@ -804,8 +804,9 @@ static int rs780_parse_power_table(struct radeon_device *rdev)
                return -EINVAL;
        power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
 
index d91aa3944593311dbbfa1b3f8cdc06055334b994..6986051fbb892af4f67d2369023213e9d1ea61ab 100644 (file)
@@ -1888,8 +1888,9 @@ static int rv6xx_parse_power_table(struct radeon_device *rdev)
                return -EINVAL;
        power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
 
index cb2a7ec4e2176fa36f5c546eb36bc9eacaa6525e..c765ae7ea8063682b7f40d603769735ee9fb78e5 100644 (file)
@@ -2282,8 +2282,9 @@ int rv7xx_parse_power_table(struct radeon_device *rdev)
                return -EINVAL;
        power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
 
index 90d5b41007bfd295eb531faa96da3fd99dde2693..fea88078cf8ea1f415394f09ec20fcc882c870fa 100644 (file)
@@ -6832,8 +6832,9 @@ static int si_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
@@ -6941,7 +6942,9 @@ int si_dpm_init(struct radeon_device *rdev)
                return ret;
 
        rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct radeon_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                r600_free_extended_power_table(rdev);
                return -ENOMEM;
index fd4804829e46a8f38ffae1a23dd7b674cedb090b..1e4975f3374ce8ba24df5a3f25320b1709dfba47 100644 (file)
@@ -1482,8 +1482,9 @@ static int sumo_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
index 2ef7c4e5e4950805f146bfe614510aa742b817a3..5d317f763eeaa7e813008882a42cc1ca58dc247f 100644 (file)
@@ -1757,8 +1757,9 @@ static int trinity_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
index 2a5b8466d806c2e7a5fe1c3095360f2aca007da0..35dc74883f8373686b95839e8eb7ac750ae78371 100644 (file)
@@ -298,8 +298,9 @@ static int savage_dma_init(drm_savage_private_t * dev_priv)
 
        dev_priv->nr_dma_pages = dev_priv->cmd_dma->size /
            (SAVAGE_DMA_PAGE_SIZE * 4);
-       dev_priv->dma_pages = kmalloc(sizeof(drm_savage_dma_page_t) *
-                                     dev_priv->nr_dma_pages, GFP_KERNEL);
+       dev_priv->dma_pages = kmalloc_array(dev_priv->nr_dma_pages,
+                                           sizeof(drm_savage_dma_page_t),
+                                           GFP_KERNEL);
        if (dev_priv->dma_pages == NULL)
                return -ENOMEM;
 
index df1578d6f42e65f05300eaeef866b698585e5591..44d480768dfe2d202790ee4a3303e55d348af783 100644 (file)
@@ -349,8 +349,13 @@ static bool drm_sched_entity_add_dependency_cb(struct drm_sched_entity *entity)
        struct dma_fence * fence = entity->dependency;
        struct drm_sched_fence *s_fence;
 
-       if (fence->context == entity->fence_context) {
-               /* We can ignore fences from ourself */
+       if (fence->context == entity->fence_context ||
+            fence->context == entity->fence_context + 1) {
+                /*
+                 * Fence is a scheduled/finished fence from a job
+                 * which belongs to the same entity, we can ignore
+                 * fences from ourself
+                 */
                dma_fence_put(entity->dependency);
                return false;
        }
index 7cc935d7b7aaaa36c3767a9c4ae01685037cc1fa..933af1c253878acc64e05da0b6f73eee01fcc5c9 100644 (file)
@@ -389,7 +389,7 @@ static int __igt_reserve(unsigned int count, u64 size)
        if (!order)
                goto err;
 
-       nodes = vzalloc(sizeof(*nodes) * count);
+       nodes = vzalloc(array_size(count, sizeof(*nodes)));
        if (!nodes)
                goto err_order;
 
@@ -579,7 +579,7 @@ static int __igt_insert(unsigned int count, u64 size, bool replace)
        DRM_MM_BUG_ON(!size);
 
        ret = -ENOMEM;
-       nodes = vmalloc(count * sizeof(*nodes));
+       nodes = vmalloc(array_size(count, sizeof(*nodes)));
        if (!nodes)
                goto err;
 
@@ -889,7 +889,7 @@ static int __igt_insert_range(unsigned int count, u64 size, u64 start, u64 end)
         */
 
        ret = -ENOMEM;
-       nodes = vzalloc(count * sizeof(*nodes));
+       nodes = vzalloc(array_size(count, sizeof(*nodes)));
        if (!nodes)
                goto err;
 
@@ -1046,7 +1046,7 @@ static int igt_align(void *ignored)
         * meets our requirements.
         */
 
-       nodes = vzalloc(max_count * sizeof(*nodes));
+       nodes = vzalloc(array_size(max_count, sizeof(*nodes)));
        if (!nodes)
                goto err;
 
@@ -1416,7 +1416,7 @@ static int igt_evict(void *ignored)
         */
 
        ret = -ENOMEM;
-       nodes = vzalloc(size * sizeof(*nodes));
+       nodes = vzalloc(array_size(size, sizeof(*nodes)));
        if (!nodes)
                goto err;
 
@@ -1526,7 +1526,7 @@ static int igt_evict_range(void *ignored)
         */
 
        ret = -ENOMEM;
-       nodes = vzalloc(size * sizeof(*nodes));
+       nodes = vzalloc(array_size(size, sizeof(*nodes)));
        if (!nodes)
                goto err;
 
@@ -1627,11 +1627,11 @@ static int igt_topdown(void *ignored)
         */
 
        ret = -ENOMEM;
-       nodes = vzalloc(count * sizeof(*nodes));
+       nodes = vzalloc(array_size(count, sizeof(*nodes)));
        if (!nodes)
                goto err;
 
-       bitmap = kzalloc(count / BITS_PER_LONG * sizeof(unsigned long),
+       bitmap = kcalloc(count / BITS_PER_LONG, sizeof(unsigned long),
                         GFP_KERNEL);
        if (!bitmap)
                goto err_nodes;
@@ -1741,11 +1741,11 @@ static int igt_bottomup(void *ignored)
         */
 
        ret = -ENOMEM;
-       nodes = vzalloc(count * sizeof(*nodes));
+       nodes = vzalloc(array_size(count, sizeof(*nodes)));
        if (!nodes)
                goto err;
 
-       bitmap = kzalloc(count / BITS_PER_LONG * sizeof(unsigned long),
+       bitmap = kcalloc(count / BITS_PER_LONG, sizeof(unsigned long),
                         GFP_KERNEL);
        if (!bitmap)
                goto err_nodes;
@@ -2098,7 +2098,7 @@ static int igt_color_evict(void *ignored)
         */
 
        ret = -ENOMEM;
-       nodes = vzalloc(total_size * sizeof(*nodes));
+       nodes = vzalloc(array_size(total_size, sizeof(*nodes)));
        if (!nodes)
                goto err;
 
@@ -2199,7 +2199,7 @@ static int igt_color_evict_range(void *ignored)
         */
 
        ret = -ENOMEM;
-       nodes = vzalloc(total_size * sizeof(*nodes));
+       nodes = vzalloc(array_size(total_size, sizeof(*nodes)));
        if (!nodes)
                goto err;
 
index c987c826daa30fcc066ef01cffd5e5dafc86317b..0426d66660d1c549bcc4c249aec60135025575ed 100644 (file)
@@ -2,7 +2,6 @@ config DRM_SHMOBILE
        tristate "DRM Support for SH Mobile"
        depends on DRM && ARM
        depends on ARCH_SHMOBILE || COMPILE_TEST
-       depends on FB_SH_MOBILE_MERAM || !FB_SH_MOBILE_MERAM
        select BACKLIGHT_CLASS_DEVICE
        select BACKLIGHT_LCD_SUPPORT
        select DRM_KMS_HELPER
index e7738939a86dc9f3f8b9c21825f79536f233beb2..40df8887fc1765e3452f5490ccf9fc242f614cbc 100644 (file)
@@ -21,8 +21,6 @@
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_plane_helper.h>
 
-#include <video/sh_mobile_meram.h>
-
 #include "shmob_drm_backlight.h"
 #include "shmob_drm_crtc.h"
 #include "shmob_drm_drv.h"
@@ -47,20 +45,12 @@ static int shmob_drm_clk_on(struct shmob_drm_device *sdev)
                if (ret < 0)
                        return ret;
        }
-#if 0
-       if (sdev->meram_dev && sdev->meram_dev->pdev)
-               pm_runtime_get_sync(&sdev->meram_dev->pdev->dev);
-#endif
 
        return 0;
 }
 
 static void shmob_drm_clk_off(struct shmob_drm_device *sdev)
 {
-#if 0
-       if (sdev->meram_dev && sdev->meram_dev->pdev)
-               pm_runtime_put_sync(&sdev->meram_dev->pdev->dev);
-#endif
        if (sdev->clock)
                clk_disable_unprepare(sdev->clock);
 }
@@ -269,12 +259,6 @@ static void shmob_drm_crtc_stop(struct shmob_drm_crtc *scrtc)
        if (!scrtc->started)
                return;
 
-       /* Disable the MERAM cache. */
-       if (scrtc->cache) {
-               sh_mobile_meram_cache_free(sdev->meram, scrtc->cache);
-               scrtc->cache = NULL;
-       }
-
        /* Stop the LCDC. */
        shmob_drm_crtc_start_stop(scrtc, false);
 
@@ -305,7 +289,6 @@ static void shmob_drm_crtc_compute_base(struct shmob_drm_crtc *scrtc,
 {
        struct drm_crtc *crtc = &scrtc->crtc;
        struct drm_framebuffer *fb = crtc->primary->fb;
-       struct shmob_drm_device *sdev = crtc->dev->dev_private;
        struct drm_gem_cma_object *gem;
        unsigned int bpp;
 
@@ -321,11 +304,6 @@ static void shmob_drm_crtc_compute_base(struct shmob_drm_crtc *scrtc,
                              + y / (bpp == 4 ? 2 : 1) * fb->pitches[1]
                              + x * (bpp == 16 ? 2 : 1);
        }
-
-       if (scrtc->cache)
-               sh_mobile_meram_cache_update(sdev->meram, scrtc->cache,
-                                            scrtc->dma[0], scrtc->dma[1],
-                                            &scrtc->dma[0], &scrtc->dma[1]);
 }
 
 static void shmob_drm_crtc_update_base(struct shmob_drm_crtc *scrtc)
@@ -372,9 +350,7 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
 {
        struct shmob_drm_crtc *scrtc = to_shmob_crtc(crtc);
        struct shmob_drm_device *sdev = crtc->dev->dev_private;
-       const struct sh_mobile_meram_cfg *mdata = sdev->pdata->meram;
        const struct shmob_drm_format_info *format;
-       void *cache;
 
        format = shmob_drm_format_info(crtc->primary->fb->format->format);
        if (format == NULL) {
@@ -386,24 +362,6 @@ static int shmob_drm_crtc_mode_set(struct drm_crtc *crtc,
        scrtc->format = format;
        scrtc->line_size = crtc->primary->fb->pitches[0];
 
-       if (sdev->meram) {
-               /* Enable MERAM cache if configured. We need to de-init
-                * configured ICBs before we can re-initialize them.
-                */
-               if (scrtc->cache) {
-                       sh_mobile_meram_cache_free(sdev->meram, scrtc->cache);
-                       scrtc->cache = NULL;
-               }
-
-               cache = sh_mobile_meram_cache_alloc(sdev->meram, mdata,
-                                                   crtc->primary->fb->pitches[0],
-                                                   adjusted_mode->vdisplay,
-                                                   format->meram,
-                                                   &scrtc->line_size);
-               if (!IS_ERR(cache))
-                       scrtc->cache = cache;
-       }
-
        shmob_drm_crtc_compute_base(scrtc, x, y);
 
        return 0;
index f152973df11c9859d36df6366ad4e34aea213291..c11f421737dc413db9b99579e23b5e2147a51dca 100644 (file)
@@ -28,7 +28,6 @@ struct shmob_drm_crtc {
        int dpms;
 
        const struct shmob_drm_format_info *format;
-       void *cache;
        unsigned long dma[2];
        unsigned int line_size;
        bool started;
index 02ea315ba69ac3a7ec16c5dd2184aaf93f856b74..088a6e55fa29dd3e14f3096a7606d882889c3b52 100644 (file)
@@ -23,7 +23,6 @@
 struct clk;
 struct device;
 struct drm_device;
-struct sh_mobile_meram_info;
 
 struct shmob_drm_device {
        struct device *dev;
@@ -31,7 +30,6 @@ struct shmob_drm_device {
 
        void __iomem *mmio;
        struct clk *clock;
-       struct sh_mobile_meram_info *meram;
        u32 lddckr;
        u32 ldmt1r;
 
index d36919b14da76bacf8b23e8e9a92f8b5fb90c89a..447638581c08037c4b3f3458e23ef710b2cd9a10 100644 (file)
@@ -18,8 +18,6 @@
 #include <drm/drm_gem_cma_helper.h>
 #include <drm/drm_gem_framebuffer_helper.h>
 
-#include <video/sh_mobile_meram.h>
-
 #include "shmob_drm_crtc.h"
 #include "shmob_drm_drv.h"
 #include "shmob_drm_kms.h"
@@ -35,55 +33,46 @@ static const struct shmob_drm_format_info shmob_drm_format_infos[] = {
                .bpp = 16,
                .yuv = false,
                .lddfr = LDDFR_PKF_RGB16,
-               .meram = SH_MOBILE_MERAM_PF_RGB,
        }, {
                .fourcc = DRM_FORMAT_RGB888,
                .bpp = 24,
                .yuv = false,
                .lddfr = LDDFR_PKF_RGB24,
-               .meram = SH_MOBILE_MERAM_PF_RGB,
        }, {
                .fourcc = DRM_FORMAT_ARGB8888,
                .bpp = 32,
                .yuv = false,
                .lddfr = LDDFR_PKF_ARGB32,
-               .meram = SH_MOBILE_MERAM_PF_RGB,
        }, {
                .fourcc = DRM_FORMAT_NV12,
                .bpp = 12,
                .yuv = true,
                .lddfr = LDDFR_CC | LDDFR_YF_420,
-               .meram = SH_MOBILE_MERAM_PF_NV,
        }, {
                .fourcc = DRM_FORMAT_NV21,
                .bpp = 12,
                .yuv = true,
                .lddfr = LDDFR_CC | LDDFR_YF_420,
-               .meram = SH_MOBILE_MERAM_PF_NV,
        }, {
                .fourcc = DRM_FORMAT_NV16,
                .bpp = 16,
                .yuv = true,
                .lddfr = LDDFR_CC | LDDFR_YF_422,
-               .meram = SH_MOBILE_MERAM_PF_NV,
        }, {
                .fourcc = DRM_FORMAT_NV61,
                .bpp = 16,
                .yuv = true,
                .lddfr = LDDFR_CC | LDDFR_YF_422,
-               .meram = SH_MOBILE_MERAM_PF_NV,
        }, {
                .fourcc = DRM_FORMAT_NV24,
                .bpp = 24,
                .yuv = true,
                .lddfr = LDDFR_CC | LDDFR_YF_444,
-               .meram = SH_MOBILE_MERAM_PF_NV24,
        }, {
                .fourcc = DRM_FORMAT_NV42,
                .bpp = 24,
                .yuv = true,
                .lddfr = LDDFR_CC | LDDFR_YF_444,
-               .meram = SH_MOBILE_MERAM_PF_NV24,
        },
 };
 
index 06d5b7caa0265d64b54913fe2bddf84ea8c3bbc1..753e2817dc2c73011a10b4afb3bf987068d83abe 100644 (file)
@@ -24,7 +24,6 @@ struct shmob_drm_format_info {
        unsigned int bpp;
        bool yuv;
        u32 lddfr;
-       unsigned int meram;
 };
 
 const struct shmob_drm_format_info *shmob_drm_format_info(u32 fourcc);
index 97f6e4a3eb0de0e86634cb4c4d9d3c2501b5dfab..1d0359f713ca4223ac8c568d63d3d9dd2f815f0a 100644 (file)
@@ -17,8 +17,6 @@
 #include <drm/drm_fb_cma_helper.h>
 #include <drm/drm_gem_cma_helper.h>
 
-#include <video/sh_mobile_meram.h>
-
 #include "shmob_drm_drv.h"
 #include "shmob_drm_kms.h"
 #include "shmob_drm_plane.h"
index 1ee6855212a0f746cf9985f4150e432f10b61db6..50a1d4216ce782ff2327ce7ad043fe3af9ee8092 100644 (file)
@@ -548,7 +548,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,
        DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id,
                  epd->factored_stage_time);
 
-       buf = kmalloc(fb->width * fb->height, GFP_KERNEL);
+       buf = kmalloc_array(fb->width, fb->height, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
index 06c94e3a5f1521b0759148ede50b85752183e6bc..6e2d1300b457b973e3e6f1e5f072659ed665aaf1 100644 (file)
@@ -348,8 +348,9 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
        if (use_static)
                pages_to_free = static_buf;
        else
-               pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
-                                       GFP_KERNEL);
+               pages_to_free = kmalloc_array(npages_to_free,
+                                             sizeof(struct page *),
+                                             GFP_KERNEL);
        if (!pages_to_free) {
                pr_debug("Failed to allocate memory for pool free operation\n");
                return 0;
@@ -547,7 +548,8 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags,
        unsigned max_cpages = min(count << order, (unsigned)NUM_PAGES_TO_ALLOC);
 
        /* allocate array for page caching change */
-       caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
+       caching_array = kmalloc_array(max_cpages, sizeof(struct page *),
+                                     GFP_KERNEL);
 
        if (!caching_array) {
                pr_debug("Unable to allocate table for new pages\n");
index f63d99c302e44fe2ca5bd9f9ab65e5e89af4c1a8..3f14c1cc078912b65340a58b661d0b96e441718f 100644 (file)
@@ -463,8 +463,9 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
        if (use_static)
                pages_to_free = static_buf;
        else
-               pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
-                                       GFP_KERNEL);
+               pages_to_free = kmalloc_array(npages_to_free,
+                                             sizeof(struct page *),
+                                             GFP_KERNEL);
 
        if (!pages_to_free) {
                pr_debug("%s: Failed to allocate memory for pool free operation\n",
@@ -753,7 +754,8 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool,
                        (unsigned)(PAGE_SIZE/sizeof(struct page *)));
 
        /* allocate array for page caching change */
-       caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
+       caching_array = kmalloc_array(max_cpages, sizeof(struct page *),
+                                     GFP_KERNEL);
 
        if (!caching_array) {
                pr_debug("%s: Unable to allocate table for new pages\n",
index a0c0259355bd1d62997417ff2ca27c0cb5604ce8..1552bf552c942eb3d3c516052c017f7b743c884d 100644 (file)
@@ -3,6 +3,7 @@ config DRM_V3D
        depends on ARCH_BCM || ARCH_BCMSTB || COMPILE_TEST
        depends on DRM
        depends on COMMON_CLK
+       depends on MMU
        select DRM_SCHED
        help
          Choose this option if you have a system that has a Broadcom
index 71d44c357d3534050d0d2f9a0d7f8751845f1d67..1d34619eb3fe3f57402291e7dbd05c4a193c45e1 100644 (file)
@@ -209,7 +209,7 @@ static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val)
 {
        if (vc4_state->dlist_count == vc4_state->dlist_size) {
                u32 new_size = max(4u, vc4_state->dlist_count * 2);
-               u32 *new_dlist = kmalloc(new_size * 4, GFP_KERNEL);
+               u32 *new_dlist = kmalloc_array(new_size, 4, GFP_KERNEL);
 
                if (!new_dlist)
                        return;
index d6e84a589ef1161241950cae10ffe8f0b8323499..345bda4494e19e5ec6c65af3a1c60bb3d6ab9649 100644 (file)
@@ -235,7 +235,7 @@ via_lock_all_dma_pages(drm_via_sg_info_t *vsg,  drm_via_dmablit_t *xfer)
        vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride - 1)) -
                first_pfn + 1;
 
-       vsg->pages = vzalloc(sizeof(struct page *) * vsg->num_pages);
+       vsg->pages = vzalloc(array_size(sizeof(struct page *), vsg->num_pages));
        if (NULL == vsg->pages)
                return -ENOMEM;
        ret = get_user_pages_fast((unsigned long)xfer->mem_addr,
index 29437eabe0957d67893808ed7d668f54770c3fd7..b677e5d524e698234f2af458c73b07cf4a22f116 100644 (file)
@@ -6,7 +6,7 @@ config VGA_ARB
          Some "legacy" VGA devices implemented on PCI typically have the same
          hard-decoded addresses as they did on ISA. When multiple PCI devices
          are accessed at same time they need some kind of coordination. Please
-         see Documentation/vgaarbiter.txt for more details. Select this to
+         see Documentation/gpu/vgaarbiter.rst for more details. Select this to
          enable VGA arbiter.
 
 config VGA_ARB_MAX_GPUS
index 1c5e74cb9279bbbea68b220b233c16cc4403f02e..c61b045557798e073778ba1efcb786f6bc3c946e 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * vgaarb.c: Implements the VGA arbitration. For details refer to
- * Documentation/vgaarbiter.txt
+ * Documentation/gpu/vgaarbiter.rst
  *
  *
  * (C) Copyright 2005 Benjamin Herrenschmidt <benh@kernel.crashing.org>
index 355dc7e4956261e3421f27ca4521d7aac1515ad5..f858cc72011d183fa11892fb152e0d9b705c3059 100644 (file)
@@ -134,8 +134,11 @@ static int open_collection(struct hid_parser *parser, unsigned type)
        }
 
        if (parser->device->maxcollection == parser->device->collection_size) {
-               collection = kmalloc(sizeof(struct hid_collection) *
-                               parser->device->collection_size * 2, GFP_KERNEL);
+               collection = kmalloc(
+                               array3_size(sizeof(struct hid_collection),
+                                           parser->device->collection_size,
+                                           2),
+                               GFP_KERNEL);
                if (collection == NULL) {
                        hid_err(parser->device, "failed to reallocate collection array\n");
                        return -ENOMEM;
@@ -1278,7 +1281,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
        __s32 max = field->logical_maximum;
        __s32 *value;
 
-       value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
+       value = kmalloc_array(count, sizeof(__s32), GFP_ATOMIC);
        if (!value)
                return;
 
index 4f4e7a08a07be5c0a37c129905e89d4e03aa10e0..8469b6964ff64e45f7807641ef8eda8197f8f81f 100644 (file)
@@ -457,7 +457,7 @@ static char *resolv_usage_page(unsigned page, struct seq_file *f) {
        char *buf = NULL;
 
        if (!f) {
-               buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
+               buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC);
                if (!buf)
                        return ERR_PTR(-ENOMEM);
        }
@@ -685,7 +685,7 @@ void hid_dump_report(struct hid_device *hid, int type, u8 *data,
        char *buf;
        unsigned int i;
 
-       buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
+       buf = kmalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC);
 
        if (!buf)
                return;
@@ -1088,7 +1088,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
                goto out;
        }
 
-       if (!(list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_KERNEL))) {
+       if (!(list->hid_debug_buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_KERNEL))) {
                err = -ENOMEM;
                kfree(list);
                goto out;
index 7f965e2314335857df32bb70c5b9472f7620e96d..864a084b6cbaadf425b1cf653c49c1fb3a9c2c6e 100644 (file)
@@ -394,7 +394,8 @@ static int picolcd_set_par(struct fb_info *info)
                return -EINVAL;
 
        o_fb   = fbdata->bitmap;
-       tmp_fb = kmalloc(PICOLCDFB_SIZE*info->var.bits_per_pixel, GFP_KERNEL);
+       tmp_fb = kmalloc_array(PICOLCDFB_SIZE, info->var.bits_per_pixel,
+                              GFP_KERNEL);
        if (!tmp_fb)
                return -ENOMEM;
 
index 25363fc571bcc285a009cffd4fb9ceaf7a28c24f..50af72baa5ca9a6dbf37505cda39fbd4290668c4 100644 (file)
@@ -624,7 +624,8 @@ static int sensor_hub_probe(struct hid_device *hdev,
                ret = -EINVAL;
                goto err_stop_hw;
        }
-       sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt *
+       sd->hid_sensor_hub_client_devs = devm_kcalloc(&hdev->dev,
+                                                     dev_cnt,
                                                      sizeof(struct mfd_cell),
                                                      GFP_KERNEL);
        if (sd->hid_sensor_hub_client_devs == NULL) {
index b39844adea47a333f52079abbefa2ee0186bb13b..4a44e48e08b225a6180ad014604dabc83ce65c2d 100644 (file)
@@ -218,7 +218,7 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
                goto out;
        }
 
-       buf = kmalloc(count * sizeof(__u8), GFP_KERNEL);
+       buf = kmalloc(count, GFP_KERNEL);
        if (!buf) {
                ret = -ENOMEM;
                goto out;
index acc2536c80948522f66873f6e61da1499502066a..2d28cffc14046c94277b1960fa81aaede7cbd637 100644 (file)
@@ -121,9 +121,9 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf,
                        }
                        client_data->hid_dev_count = (unsigned int)*payload;
                        if (!client_data->hid_devices)
-                               client_data->hid_devices = devm_kzalloc(
+                               client_data->hid_devices = devm_kcalloc(
                                                &client_data->cl_device->dev,
-                                               client_data->hid_dev_count *
+                                               client_data->hid_dev_count,
                                                sizeof(struct device_info),
                                                GFP_KERNEL);
                        if (!client_data->hid_devices) {
index 0108c5991a0417679d04a9d048d757d9e3f178f4..e50d8fe4d36c58f3715ba72932a682fc36c75654 100644 (file)
@@ -14,7 +14,7 @@ config USB_HID
 
          You can't use this driver and the HIDBP (Boot Protocol) keyboard
          and mouse drivers at the same time. More information is available:
-         <file:Documentation/input/input.txt>.
+         <file:Documentation/input/input.rst>.
 
          If unsure, say Y.
 
index ee7a37eb159acf41fcb6c40ac685c7f659672b29..c101369b51de88b927fdf2295f3bb664ed415899 100644 (file)
@@ -1363,7 +1363,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev,
        if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL))
                return -ENOMEM;
 
-       leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL);
+       leds = devm_kcalloc(dev, count, sizeof(struct wacom_led), GFP_KERNEL);
        if (!leds) {
                error = -ENOMEM;
                goto err;
@@ -1463,7 +1463,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count)
        struct wacom_group_leds *groups;
        int error;
 
-       groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count,
+       groups = devm_kcalloc(dev, count, sizeof(struct wacom_group_leds),
                              GFP_KERNEL);
        if (!groups)
                return -ENOMEM;
index 9b82549cbbc8e6937c02c289c7f5e5b5d1de2b79..658dc765753bf569a725970690d45260db41df80 100644 (file)
@@ -190,7 +190,7 @@ int hv_synic_alloc(void)
 {
        int cpu;
 
-       hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
+       hv_context.hv_numa_map = kcalloc(nr_node_ids, sizeof(struct cpumask),
                                         GFP_KERNEL);
        if (hv_context.hv_numa_map == NULL) {
                pr_err("Unable to allocate NUMA map\n");
index 3c836c099a8f35e865feae4207a5f8c6d13888bc..be3c8b10b84a9f970f4b582ce9dd1bb2a223143e 100644 (file)
@@ -202,7 +202,7 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
         * First page holds struct hv_ring_buffer, do wraparound mapping for
         * the rest.
         */
-       pages_wraparound = kzalloc(sizeof(struct page *) * (page_cnt * 2 - 1),
+       pages_wraparound = kcalloc(page_cnt * 2 - 1, sizeof(struct page *),
                                   GFP_KERNEL);
        if (!pages_wraparound)
                return -ENOMEM;
index 14a94d90c028a0f77c22e6b0a3f9c3e48da070a4..34e45b97629ed73869baf28edf3acef0376290c5 100644 (file)
@@ -575,8 +575,9 @@ static int read_domain_devices(struct acpi_power_meter_resource *resource)
        if (!pss->package.count)
                goto end;
 
-       resource->domain_devices = kzalloc(sizeof(struct acpi_device *) *
-                                          pss->package.count, GFP_KERNEL);
+       resource->domain_devices = kcalloc(pss->package.count,
+                                          sizeof(struct acpi_device *),
+                                          GFP_KERNEL);
        if (!resource->domain_devices) {
                res = -ENOMEM;
                goto end;
@@ -796,7 +797,7 @@ static int read_capabilities(struct acpi_power_meter_resource *resource)
                        goto error;
                }
 
-               *str = kzalloc(sizeof(u8) * (element->string.length + 1),
+               *str = kcalloc(element->string.length + 1, sizeof(u8),
                               GFP_KERNEL);
                if (!*str) {
                        res = -ENOMEM;
index 693a3d53cab5d9f281c3c66bddab76a60461733f..5e449eac788a1311ee1f3be0c6ba7f91c9415964 100644 (file)
@@ -894,7 +894,7 @@ static int aspeed_create_fan(struct device *dev,
        count = of_property_count_u8_elems(child, "aspeed,fan-tach-ch");
        if (count < 1)
                return -EINVAL;
-       fan_tach_ch = devm_kzalloc(dev, sizeof(*fan_tach_ch) * count,
+       fan_tach_ch = devm_kcalloc(dev, count, sizeof(*fan_tach_ch),
                                   GFP_KERNEL);
        if (!fan_tach_ch)
                return -ENOMEM;
index 72c338eb5fae5a94c5558ebe5aae4530bb649763..10645c9bb7be14abd077bb73418503067eb21157 100644 (file)
@@ -742,7 +742,7 @@ static int __init coretemp_init(void)
                return -ENODEV;
 
        max_packages = topology_max_packages();
-       pkg_devices = kzalloc(max_packages * sizeof(struct platform_device *),
+       pkg_devices = kcalloc(max_packages, sizeof(struct platform_device *),
                              GFP_KERNEL);
        if (!pkg_devices)
                return -ENOMEM;
index 5c9a52599cf68ff8d7dcb181ac3cfdc162ea3d1b..a3974cddef07908abe354f41efda61f7a391f610 100644 (file)
@@ -441,8 +441,8 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data)
                dev_err(dev, "DT properties empty / missing");
                return -ENODEV;
        }
-       gpios = devm_kzalloc(dev,
-                            fan_data->num_gpios * sizeof(struct gpio_desc *),
+       gpios = devm_kcalloc(dev,
+                            fan_data->num_gpios, sizeof(struct gpio_desc *),
                             GFP_KERNEL);
        if (!gpios)
                return -ENOMEM;
@@ -471,8 +471,8 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data)
         * Speed map is in the form <RPM ctrl_val RPM ctrl_val ...>
         * this needs splitting into pairs to create gpio_fan_speed structs
         */
-       speed = devm_kzalloc(dev,
-                       fan_data->num_speed * sizeof(struct gpio_fan_speed),
+       speed = devm_kcalloc(dev,
+                       fan_data->num_speed, sizeof(struct gpio_fan_speed),
                        GFP_KERNEL);
        if (!speed)
                return -ENOMEM;
index 9397d2f0e79ac0710feb06e6f15e3673b9a0fc5f..a4edc43dd0608cf9e529c224033c687b59645a43 100644 (file)
@@ -274,8 +274,9 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev)
                num_ambs += hweight16(data->amb_present[i] & 0x7fff);
 
        /* Set up sysfs stuff */
-       data->attrs = kzalloc(sizeof(*data->attrs) * num_ambs * KNOBS_PER_AMB,
-                               GFP_KERNEL);
+       data->attrs = kzalloc(array3_size(num_ambs, KNOBS_PER_AMB,
+                                         sizeof(*data->attrs)),
+                             GFP_KERNEL);
        if (!data->attrs)
                return -ENOMEM;
        data->num_attrs = 0;
index 21b9c72f16bd7423dda3870b7e6eaf1ee047a6b5..ab72cabf5a9556cf38025683dd5a2bc28112e028 100644 (file)
@@ -387,7 +387,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data)
                return -ENOENT;
        data->num_sensors = err;
 
-       data->sensors = kzalloc(data->num_sensors * sizeof(*data->sensors),
+       data->sensors = kcalloc(data->num_sensors, sizeof(*data->sensors),
                                GFP_KERNEL);
        if (!data->sensors)
                return -ENOMEM;
index 0298745d46e40626de00a1e36474b242f302adcf..f829dadfd5a06b5ec69fe48695ade65f51a370c8 100644 (file)
@@ -326,9 +326,9 @@ static int populate_attr_groups(struct platform_device *pdev)
        of_node_put(opal);
 
        for (type = 0; type < MAX_SENSOR_TYPE; type++) {
-               sensor_groups[type].group.attrs = devm_kzalloc(&pdev->dev,
-                                       sizeof(struct attribute *) *
-                                       (sensor_groups[type].attr_count + 1),
+               sensor_groups[type].group.attrs = devm_kcalloc(&pdev->dev,
+                                       sensor_groups[type].attr_count + 1,
+                                       sizeof(struct attribute *),
                                        GFP_KERNEL);
                if (!sensor_groups[type].group.attrs)
                        return -ENOMEM;
@@ -409,7 +409,8 @@ static int create_device_attrs(struct platform_device *pdev)
        int err = 0;
 
        opal = of_find_node_by_path("/ibm,opal/sensors");
-       sdata = devm_kzalloc(&pdev->dev, pdata->sensors_count * sizeof(*sdata),
+       sdata = devm_kcalloc(&pdev->dev,
+                            pdata->sensors_count, sizeof(*sdata),
                             GFP_KERNEL);
        if (!sdata) {
                err = -ENOMEM;
index 5e5b32a1ec4b7e3480cf4255658f6ec943cda83e..69031a0f7ed2c5ff44df47e102fbd7eacea3a1fc 100644 (file)
@@ -92,8 +92,8 @@ static int iio_hwmon_probe(struct platform_device *pdev)
        while (st->channels[st->num_channels].indio_dev)
                st->num_channels++;
 
-       st->attrs = devm_kzalloc(dev,
-                                sizeof(*st->attrs) * (st->num_channels + 1),
+       st->attrs = devm_kcalloc(dev,
+                                st->num_channels + 1, sizeof(*st->attrs),
                                 GFP_KERNEL);
        if (st->attrs == NULL) {
                ret = -ENOMEM;
index b0bc77bf2cd9b3a92f6c186add19aa34b5a6cc7d..a753464a1a33f5f0d2c6da89581feb330911d15e 100644 (file)
@@ -426,12 +426,12 @@ nct6683_create_attr_group(struct device *dev,
        if (group == NULL)
                return ERR_PTR(-ENOMEM);
 
-       attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
+       attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
                             GFP_KERNEL);
        if (attrs == NULL)
                return ERR_PTR(-ENOMEM);
 
-       su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
+       su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)),
                          GFP_KERNEL);
        if (su == NULL)
                return ERR_PTR(-ENOMEM);
index aebce560bfaf39bbe826ab8cf3a1e2c5fb5895ca..155d4d1d1585af4aa7debc37163072af4979bd02 100644 (file)
@@ -1190,12 +1190,12 @@ nct6775_create_attr_group(struct device *dev,
        if (group == NULL)
                return ERR_PTR(-ENOMEM);
 
-       attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
+       attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
                             GFP_KERNEL);
        if (attrs == NULL)
                return ERR_PTR(-ENOMEM);
 
-       su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
+       su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)),
                               GFP_KERNEL);
        if (su == NULL)
                return ERR_PTR(-ENOMEM);
index f7c47d7994e7f652bba64e6bc2336b6f603c4b94..82c3754e21e337c83b4d7e3a12236da78500f370 100644 (file)
@@ -2176,8 +2176,8 @@ static int pmbus_init_debugfs(struct i2c_client *client,
        }
 
        /* Allocate the max possible entries we need. */
-       entries = devm_kzalloc(data->dev,
-                              sizeof(*entries) * (data->info->pages * 10),
+       entries = devm_kcalloc(data->dev,
+                              data->info->pages * 10, sizeof(*entries),
                               GFP_KERNEL);
        if (!entries)
                return -ENOMEM;
index 70cecb06f93cae04f52f8cd3ff02a3a327d406ef..ae93885fccd81757662f534949b6d0604e51d708 100644 (file)
@@ -454,8 +454,8 @@ static int ucd9000_init_debugfs(struct i2c_client *client,
         */
        if (mid->driver_data == ucd9090 || mid->driver_data == ucd90160 ||
            mid->driver_data == ucd90910) {
-               entries = devm_kzalloc(&client->dev,
-                                      sizeof(*entries) * UCD9000_GPI_COUNT,
+               entries = devm_kcalloc(&client->dev,
+                                      UCD9000_GPI_COUNT, sizeof(*entries),
                                       GFP_KERNEL);
                if (!entries)
                        return -ENOMEM;
index 70cc0d134f3cd75f13ddc45eaaab905eecbaa779..7838af58f92d51639570d4134b3a95e488d91225 100644 (file)
@@ -180,7 +180,7 @@ static int pwm_fan_of_get_cooling_data(struct device *dev,
        }
 
        num = ret;
-       ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
+       ctx->pwm_fan_cooling_levels = devm_kcalloc(dev, num, sizeof(u32),
                                                   GFP_KERNEL);
        if (!ctx->pwm_fan_cooling_levels)
                return -ENOMEM;
index f0f467983960d6b8e23818aac18d235d1988a089..e895d29500eec03d10f5067c55a14602cc60de02 100644 (file)
@@ -1,3 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0
 #
 # Generic HWSPINLOCK framework
 #
index 4074441444fed29128574a1f0a5c1143de857cd7..d16e6a3d38e8028b44b46322ede6a70d76769c96 100644 (file)
@@ -1,18 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Hardware spinlock framework
  *
  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
  *
  * Contact: Ohad Ben-Cohen <ohad@wizery.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.
  */
 
 #define pr_fmt(fmt)    "%s: " fmt, __func__
@@ -71,10 +63,16 @@ static DEFINE_MUTEX(hwspinlock_tree_lock);
  * This function attempts to lock an hwspinlock, and will immediately
  * fail if the hwspinlock is already taken.
  *
- * Upon a successful return from this function, preemption (and possibly
- * interrupts) is disabled, so the caller must not sleep, and is advised to
- * release the hwspinlock as soon as possible. This is required in order to
- * minimize remote cores polling on the hardware interconnect.
+ * Caution: If the mode is HWLOCK_RAW, that means user must protect the routine
+ * of getting hardware lock with mutex or spinlock. Since in some scenarios,
+ * user need some time-consuming or sleepable operations under the hardware
+ * lock, they need one sleepable lock (like mutex) to protect the operations.
+ *
+ * If the mode is not HWLOCK_RAW, upon a successful return from this function,
+ * preemption (and possibly interrupts) is disabled, so the caller must not
+ * sleep, and is advised to release the hwspinlock as soon as possible. This is
+ * required in order to minimize remote cores polling on the hardware
+ * interconnect.
  *
  * The user decides whether local interrupts are disabled or not, and if yes,
  * whether he wants their previous state to be saved. It is up to the user
@@ -106,12 +104,20 @@ int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags)
         *    problems with hwspinlock usage (e.g. scheduler checks like
         *    'scheduling while atomic' etc.)
         */
-       if (mode == HWLOCK_IRQSTATE)
+       switch (mode) {
+       case HWLOCK_IRQSTATE:
                ret = spin_trylock_irqsave(&hwlock->lock, *flags);
-       else if (mode == HWLOCK_IRQ)
+               break;
+       case HWLOCK_IRQ:
                ret = spin_trylock_irq(&hwlock->lock);
-       else
+               break;
+       case HWLOCK_RAW:
+               ret = 1;
+               break;
+       default:
                ret = spin_trylock(&hwlock->lock);
+               break;
+       }
 
        /* is lock already taken by another context on the local cpu ? */
        if (!ret)
@@ -122,12 +128,20 @@ int __hwspin_trylock(struct hwspinlock *hwlock, int mode, unsigned long *flags)
 
        /* if hwlock is already taken, undo spin_trylock_* and exit */
        if (!ret) {
-               if (mode == HWLOCK_IRQSTATE)
+               switch (mode) {
+               case HWLOCK_IRQSTATE:
                        spin_unlock_irqrestore(&hwlock->lock, *flags);
-               else if (mode == HWLOCK_IRQ)
+                       break;
+               case HWLOCK_IRQ:
                        spin_unlock_irq(&hwlock->lock);
-               else
+                       break;
+               case HWLOCK_RAW:
+                       /* Nothing to do */
+                       break;
+               default:
                        spin_unlock(&hwlock->lock);
+                       break;
+               }
 
                return -EBUSY;
        }
@@ -160,9 +174,14 @@ EXPORT_SYMBOL_GPL(__hwspin_trylock);
  * is already taken, the function will busy loop waiting for it to
  * be released, but give up after @timeout msecs have elapsed.
  *
- * Upon a successful return from this function, preemption is disabled
- * (and possibly local interrupts, too), so the caller must not sleep,
- * and is advised to release the hwspinlock as soon as possible.
+ * Caution: If the mode is HWLOCK_RAW, that means user must protect the routine
+ * of getting hardware lock with mutex or spinlock. Since in some scenarios,
+ * user need some time-consuming or sleepable operations under the hardware
+ * lock, they need one sleepable lock (like mutex) to protect the operations.
+ *
+ * If the mode is not HWLOCK_RAW, upon a successful return from this function,
+ * preemption is disabled (and possibly local interrupts, too), so the caller
+ * must not sleep, and is advised to release the hwspinlock as soon as possible.
  * This is required in order to minimize remote cores polling on the
  * hardware interconnect.
  *
@@ -249,12 +268,20 @@ void __hwspin_unlock(struct hwspinlock *hwlock, int mode, unsigned long *flags)
        hwlock->bank->ops->unlock(hwlock);
 
        /* Undo the spin_trylock{_irq, _irqsave} called while locking */
-       if (mode == HWLOCK_IRQSTATE)
+       switch (mode) {
+       case HWLOCK_IRQSTATE:
                spin_unlock_irqrestore(&hwlock->lock, *flags);
-       else if (mode == HWLOCK_IRQ)
+               break;
+       case HWLOCK_IRQ:
                spin_unlock_irq(&hwlock->lock);
-       else
+               break;
+       case HWLOCK_RAW:
+               /* Nothing to do */
+               break;
+       default:
                spin_unlock(&hwlock->lock);
+               break;
+       }
 }
 EXPORT_SYMBOL_GPL(__hwspin_unlock);
 
index d26f78b8f214d226de7bf8c1b523257f2956a7e0..9eb6bd020dc702d38ebb3f9713881d284e9207f7 100644 (file)
@@ -1,18 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Hardware spinlocks internal header
  *
  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
  *
  * Contact: Ohad Ben-Cohen <ohad@wizery.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.
  */
 
 #ifndef __HWSPINLOCK_HWSPINLOCK_H
index d897e5251c36d8fc0b7be6322537695900546189..625844e0abefb314941757881599b8365e11f50d 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * OMAP hardware spinlock driver
  *
@@ -6,15 +7,6 @@
  * Contact: Simon Que <sque@ti.com>
  *          Hari Kanigeri <h-kanigeri2@ti.com>
  *          Ohad Ben-Cohen <ohad@wizery.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.
  */
 
 #include <linux/kernel.h>
index fa6880b8060a050cf2ef01d8a79b762e1cb2272c..6da7447d277dce9931eaca7c791063bfa07c8e55 100644 (file)
@@ -1,15 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2013, The Linux Foundation. All rights reserved.
  * Copyright (c) 2015, Sony Mobile Communications AB
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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/hwspinlock.h>
index cb38e487c6c42b7ed822f6f551e69856ccaf1788..1f625cd68c50365f208203f9e6c571d378e6e59e 100644 (file)
@@ -1,9 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * SIRF hardware spinlock driver
  *
  * Copyright (c) 2015 Cambridge Silicon Radio Limited, a CSR plc group company.
- *
- * Licensed under GPLv2.
  */
 
 #include <linux/kernel.h>
index 638e64ac18f5664f0dbcd94b5b2e80d7c6190f98..dc42bf51f3e6271d97844b3ba4c6a5228a5941ef 100644 (file)
@@ -1,15 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Spreadtrum hardware spinlock driver
  * Copyright (C) 2017 Spreadtrum  - http://www.spreadtrum.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.
  */
 
 #include <linux/bitops.h>
index 0128d8fb905e47e1d4f0dc3bb6ebc21bf8e0ba9f..572ca79d77e8fc34a96df43075315ee977ee8a07 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * u8500 HWSEM driver
  *
  *   Simon Que <sque@ti.com>
  *   Hari Kanigeri <h-kanigeri2@ti.com>
  *   Ohad Ben-Cohen <ohad@wizery.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.
  */
 
 #include <linux/module.h>
index 9b6c55523c5833663a739a6712d29d17c23ade7a..320d29df17e109132edd2277760a3bf03a090265 100644 (file)
@@ -683,8 +683,8 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
        if (drvdata->buffer_depth & 0x80000000)
                return -EINVAL;
 
-       drvdata->buf = devm_kzalloc(dev,
-                                   drvdata->buffer_depth * 4, GFP_KERNEL);
+       drvdata->buf = devm_kcalloc(dev,
+                                   drvdata->buffer_depth, 4, GFP_KERNEL);
        if (!drvdata->buf)
                return -ENOMEM;
 
index a33a92ebe74bf05eb3696d872968f2f8c4ffde4d..6880bee195c8cfe35d947d4f203b6e2fe68a224e 100644 (file)
@@ -71,21 +71,24 @@ static int of_coresight_alloc_memory(struct device *dev,
                        struct coresight_platform_data *pdata)
 {
        /* List of output port on this component */
-       pdata->outports = devm_kzalloc(dev, pdata->nr_outport *
+       pdata->outports = devm_kcalloc(dev,
+                                      pdata->nr_outport,
                                       sizeof(*pdata->outports),
                                       GFP_KERNEL);
        if (!pdata->outports)
                return -ENOMEM;
 
        /* Children connected to this component via @outports */
-       pdata->child_names = devm_kzalloc(dev, pdata->nr_outport *
+       pdata->child_names = devm_kcalloc(dev,
+                                         pdata->nr_outport,
                                          sizeof(*pdata->child_names),
                                          GFP_KERNEL);
        if (!pdata->child_names)
                return -ENOMEM;
 
        /* Port number on the child this component is connected to */
-       pdata->child_ports = devm_kzalloc(dev, pdata->nr_outport *
+       pdata->child_ports = devm_kcalloc(dev,
+                                         pdata->nr_outport,
                                          sizeof(*pdata->child_ports),
                                          GFP_KERNEL);
        if (!pdata->child_ports)
index 3df0efd69ae336035c8f6994ef3230f6cff920f6..4a34f311e1ff4df2cd6cdfcff7ea1662c95a06eb 100644 (file)
@@ -519,9 +519,7 @@ static int bit_doAddress(struct i2c_adapter *i2c_adap, struct i2c_msg *msg)
                        }
                }
        } else {                /* normal 7bit address  */
-               addr = msg->addr << 1;
-               if (flags & I2C_M_RD)
-                       addr |= 1;
+               addr = i2c_8bit_addr_from_msg(msg);
                if (flags & I2C_M_REV_DIR_ADDR)
                        addr ^= 1;
                ret = try_address(i2c_adap, addr, retries);
index e370804ec8bc62d10830eadba8ac93f7af50aedd..883a290f6a4d05f29fc1919f4d68f1d4c089eb6e 100644 (file)
@@ -112,11 +112,8 @@ static int pca_address(struct i2c_algo_pca_data *adap,
                       struct i2c_msg *msg)
 {
        int sta = pca_get_con(adap);
-       int addr;
+       int addr = i2c_8bit_addr_from_msg(msg);
 
-       addr = ((0x7f & msg->addr) << 1);
-       if (msg->flags & I2C_M_RD)
-               addr |= 1;
        DEB2("=== SLAVE ADDRESS %#04x+%c=%#04x\n",
             msg->addr, msg->flags & I2C_M_RD ? 'R' : 'W', addr);
 
index 270d84bfc2c68b526d6b8119afa67f4cb3c37543..5c29a4d397cff2a7860c6511a2fbee820945b4ed 100644 (file)
@@ -291,13 +291,9 @@ static int pcf_readbytes(struct i2c_adapter *i2c_adap, char *buf,
 static int pcf_doAddress(struct i2c_algo_pcf_data *adap,
                         struct i2c_msg *msg)
 {
-       unsigned short flags = msg->flags;
-       unsigned char addr;
+       unsigned char addr = i2c_8bit_addr_from_msg(msg);
 
-       addr = msg->addr << 1;
-       if (flags & I2C_M_RD)
-               addr |= 1;
-       if (flags & I2C_M_REV_DIR_ADDR)
+       if (msg->flags & I2C_M_REV_DIR_ADDR)
                addr ^= 1;
        i2c_outb(adap, addr);
 
index fce9f2ca0570d50cb9a3c336686e19931b04c3ab..4f8df2ec87b1b360d0bfefeb796c065edd348a61 100644 (file)
@@ -943,6 +943,7 @@ config I2C_STM32F4
 config I2C_STM32F7
        tristate "STMicroelectronics STM32F7 I2C support"
        depends on ARCH_STM32 || COMPILE_TEST
+       select I2C_SLAVE
        help
          Enable this option to add support for STM32 I2C controller embedded
          in STM32F7 SoCs.
index 189e34ba050f81fe16844e9a1511d859bf29a165..5a869144a0c5cdc942584153c68570db3892c702 100644 (file)
@@ -94,7 +94,8 @@ obj-$(CONFIG_I2C_SIRF)                += i2c-sirf.o
 obj-$(CONFIG_I2C_SPRD)         += i2c-sprd.o
 obj-$(CONFIG_I2C_ST)           += i2c-st.o
 obj-$(CONFIG_I2C_STM32F4)      += i2c-stm32f4.o
-obj-$(CONFIG_I2C_STM32F7)      += i2c-stm32f7.o
+i2c-stm32f7-drv-objs := i2c-stm32f7.o i2c-stm32.o
+obj-$(CONFIG_I2C_STM32F7)      += i2c-stm32f7-drv.o
 obj-$(CONFIG_I2C_STU300)       += i2c-stu300.o
 obj-$(CONFIG_I2C_SUN6I_P2WI)   += i2c-sun6i-p2wi.o
 obj-$(CONFIG_I2C_SYNQUACER)    += i2c-synquacer.o
index 65e324054970b51aded8091d8f8b5a212fd49bc4..a2f5f992af7aa7e21d70294d302891c08054f4da 100644 (file)
@@ -169,12 +169,12 @@ static int __init amd756_s4882_init(void)
 
        printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n");
        /* Define the 5 virtual adapters and algorithms structures */
-       if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter),
+       if (!(s4882_adapter = kcalloc(5, sizeof(struct i2c_adapter),
                                      GFP_KERNEL))) {
                error = -ENOMEM;
                goto ERROR1;
        }
-       if (!(s4882_algo = kzalloc(5 * sizeof(struct i2c_algorithm),
+       if (!(s4882_algo = kcalloc(5, sizeof(struct i2c_algorithm),
                                   GFP_KERNEL))) {
                error = -ENOMEM;
                goto ERROR2;
index 7d4aeb4465b329847ad145772829ad3e92082159..60e4d0e939a3814ffe142edba612817de7590c48 100644 (file)
@@ -335,13 +335,12 @@ static void aspeed_i2c_do_start(struct aspeed_i2c_bus *bus)
 {
        u32 command = ASPEED_I2CD_M_START_CMD | ASPEED_I2CD_M_TX_CMD;
        struct i2c_msg *msg = &bus->msgs[bus->msgs_index];
-       u8 slave_addr = msg->addr << 1;
+       u8 slave_addr = i2c_8bit_addr_from_msg(msg);
 
        bus->master_state = ASPEED_I2C_MASTER_START;
        bus->buf_index = 0;
 
        if (msg->flags & I2C_M_RD) {
-               slave_addr |= 1;
                command |= ASPEED_I2CD_M_RX_CMD;
                /* Need to let the hardware know to NACK after RX. */
                if (msg->len == 1 && !(msg->flags & I2C_M_RECV_LEN))
index bfd1fdff64a97bd63ac36df280c264fbc598e132..3f3e8b3bf5ff9df550991d18530fe45f41c870d3 100644 (file)
@@ -518,8 +518,16 @@ static irqreturn_t atmel_twi_interrupt(int irq, void *dev_id)
         * the RXRDY interrupt first in order to not keep garbage data in the
         * Receive Holding Register for the next transfer.
         */
-       if (irqstatus & AT91_TWI_RXRDY)
-               at91_twi_read_next_byte(dev);
+       if (irqstatus & AT91_TWI_RXRDY) {
+               /*
+                * Read all available bytes at once by polling RXRDY usable w/
+                * and w/o FIFO. With FIFO enabled we could also read RXFL and
+                * avoid polling RXRDY.
+                */
+               do {
+                       at91_twi_read_next_byte(dev);
+               } while (at91_twi_read(dev, AT91_TWI_SR) & AT91_TWI_RXRDY);
+       }
 
        /*
         * When a NACK condition is detected, the I2C controller sets the NACK,
index 13f07482ec68cedb1e24eb1d92ac6939a394a97f..8e60048a33f8f88b5e10cf48d0cfc3a84f781424 100644 (file)
@@ -351,13 +351,15 @@ static int axxia_i2c_xfer_msg(struct axxia_i2c_dev *idev, struct i2c_msg *msg)
                 *   addr_2: addr[7:0]
                 */
                addr_1 = 0xF0 | ((msg->addr >> 7) & 0x06);
+               if (i2c_m_rd(msg))
+                       addr_1 |= 1;    /* Set the R/nW bit of the address */
                addr_2 = msg->addr & 0xFF;
        } else {
                /* 7-bit address
                 *   addr_1: addr[6:0] | (R/nW)
                 *   addr_2: dont care
                 */
-               addr_1 = (msg->addr << 1) & 0xFF;
+               addr_1 = i2c_8bit_addr_from_msg(msg);
                addr_2 = 0;
        }
 
@@ -365,7 +367,6 @@ static int axxia_i2c_xfer_msg(struct axxia_i2c_dev *idev, struct i2c_msg *msg)
                /* I2C read transfer */
                rx_xfer = i2c_m_recv_len(msg) ? I2C_SMBUS_BLOCK_MAX : msg->len;
                tx_xfer = 0;
-               addr_1 |= 1;    /* Set the R/nW bit of the address */
        } else {
                /* I2C write transfer */
                rx_xfer = 0;
@@ -532,23 +533,23 @@ static int axxia_i2c_probe(struct platform_device *pdev)
        if (idev->bus_clk_rate == 0)
                idev->bus_clk_rate = 100000;    /* default clock rate */
 
+       ret = clk_prepare_enable(idev->i2c_clk);
+       if (ret) {
+               dev_err(&pdev->dev, "failed to enable clock\n");
+               return ret;
+       }
+
        ret = axxia_i2c_init(idev);
        if (ret) {
                dev_err(&pdev->dev, "failed to initialize\n");
-               return ret;
+               goto error_disable_clk;
        }
 
        ret = devm_request_irq(&pdev->dev, irq, axxia_i2c_isr, 0,
                               pdev->name, idev);
        if (ret) {
                dev_err(&pdev->dev, "failed to claim IRQ%d\n", irq);
-               return ret;
-       }
-
-       ret = clk_prepare_enable(idev->i2c_clk);
-       if (ret) {
-               dev_err(&pdev->dev, "failed to enable clock\n");
-               return ret;
+               goto error_disable_clk;
        }
 
        i2c_set_adapdata(&idev->adapter, idev);
@@ -563,12 +564,14 @@ static int axxia_i2c_probe(struct platform_device *pdev)
        platform_set_drvdata(pdev, idev);
 
        ret = i2c_add_adapter(&idev->adapter);
-       if (ret) {
-               clk_disable_unprepare(idev->i2c_clk);
-               return ret;
-       }
+       if (ret)
+               goto error_disable_clk;
 
        return 0;
+
+error_disable_clk:
+       clk_disable_unprepare(idev->i2c_clk);
+       return ret;
 }
 
 static int axxia_i2c_remove(struct platform_device *pdev)
index 27ebd90de43bb781208d66c0e43c29dce1ccd450..48914dfc8ce88ff54246a2f450ef2bc3ae9afe4d 100644 (file)
@@ -149,18 +149,17 @@ u32 i2c_dw_scl_lcnt(u32 ic_clk, u32 tLOW, u32 tf, int offset)
        return ((ic_clk * (tLOW + tf) + 500000) / 1000000) - 1 + offset;
 }
 
-void __i2c_dw_enable(struct dw_i2c_dev *dev, bool enable)
-{
-       dw_writel(dev, enable, DW_IC_ENABLE);
-}
-
-void __i2c_dw_enable_and_wait(struct dw_i2c_dev *dev, bool enable)
+void __i2c_dw_disable(struct dw_i2c_dev *dev)
 {
        int timeout = 100;
 
        do {
-               __i2c_dw_enable(dev, enable);
-               if ((dw_readl(dev, DW_IC_ENABLE_STATUS) & 1) == enable)
+               __i2c_dw_disable_nowait(dev);
+               /*
+                * The enable status register may be unimplemented, but
+                * in that case this test reads zero and exits the loop.
+                */
+               if ((dw_readl(dev, DW_IC_ENABLE_STATUS) & 1) == 0)
                        return;
 
                /*
@@ -171,8 +170,7 @@ void __i2c_dw_enable_and_wait(struct dw_i2c_dev *dev, bool enable)
                usleep_range(25, 250);
        } while (timeout--);
 
-       dev_warn(dev->dev, "timeout in %sabling adapter\n",
-                enable ? "en" : "dis");
+       dev_warn(dev->dev, "timeout in disabling adapter\n");
 }
 
 unsigned long i2c_dw_clk_rate(struct dw_i2c_dev *dev)
@@ -277,7 +275,7 @@ u32 i2c_dw_func(struct i2c_adapter *adap)
 void i2c_dw_disable(struct dw_i2c_dev *dev)
 {
        /* Disable controller */
-       __i2c_dw_enable_and_wait(dev, false);
+       __i2c_dw_disable(dev);
 
        /* Disable all interupts */
        dw_writel(dev, 0, DW_IC_INTR_MASK);
index 8707c76b2fee10b08e7957a137ff89b67ea095fe..d690e648bc015efcd96d63b81c11969e9a6ceaae 100644 (file)
@@ -297,8 +297,6 @@ u32 dw_readl(struct dw_i2c_dev *dev, int offset);
 void dw_writel(struct dw_i2c_dev *dev, u32 b, int offset);
 u32 i2c_dw_scl_hcnt(u32 ic_clk, u32 tSYMBOL, u32 tf, int cond, int offset);
 u32 i2c_dw_scl_lcnt(u32 ic_clk, u32 tLOW, u32 tf, int offset);
-void __i2c_dw_enable(struct dw_i2c_dev *dev, bool enable);
-void __i2c_dw_enable_and_wait(struct dw_i2c_dev *dev, bool enable);
 unsigned long i2c_dw_clk_rate(struct dw_i2c_dev *dev);
 int i2c_dw_prepare_clk(struct dw_i2c_dev *dev, bool prepare);
 int i2c_dw_acquire_lock(struct dw_i2c_dev *dev);
@@ -309,6 +307,18 @@ u32 i2c_dw_func(struct i2c_adapter *adap);
 void i2c_dw_disable(struct dw_i2c_dev *dev);
 void i2c_dw_disable_int(struct dw_i2c_dev *dev);
 
+static inline void __i2c_dw_enable(struct dw_i2c_dev *dev)
+{
+       dw_writel(dev, 1, DW_IC_ENABLE);
+}
+
+static inline void __i2c_dw_disable_nowait(struct dw_i2c_dev *dev)
+{
+       dw_writel(dev, 0, DW_IC_ENABLE);
+}
+
+void __i2c_dw_disable(struct dw_i2c_dev *dev);
+
 extern u32 i2c_dw_read_comp_param(struct dw_i2c_dev *dev);
 extern int i2c_dw_probe(struct dw_i2c_dev *dev);
 #if IS_ENABLED(CONFIG_I2C_DESIGNWARE_SLAVE)
index 0cdba29ae0a9ad25212f21a56acf76f46c1b5213..27436a937492d1afdefe77264bcd1afaf7d91856 100644 (file)
@@ -81,7 +81,7 @@ static int i2c_dw_init_master(struct dw_i2c_dev *dev)
        comp_param1 = dw_readl(dev, DW_IC_COMP_PARAM_1);
 
        /* Disable the adapter */
-       __i2c_dw_enable_and_wait(dev, false);
+       __i2c_dw_disable(dev);
 
        /* Set standard and fast speed deviders for high/low periods */
 
@@ -180,7 +180,7 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
        u32 ic_con, ic_tar = 0;
 
        /* Disable the adapter */
-       __i2c_dw_enable_and_wait(dev, false);
+       __i2c_dw_disable(dev);
 
        /* If the slave address is ten bit address, enable 10BITADDR */
        ic_con = dw_readl(dev, DW_IC_CON);
@@ -209,7 +209,7 @@ static void i2c_dw_xfer_init(struct dw_i2c_dev *dev)
        i2c_dw_disable_int(dev);
 
        /* Enable the adapter */
-       __i2c_dw_enable(dev, true);
+       __i2c_dw_enable(dev);
 
        /* Dummy read to avoid the register getting stuck on Bay Trail */
        dw_readl(dev, DW_IC_ENABLE_STATUS);
@@ -462,7 +462,7 @@ i2c_dw_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num)
         * additional interrupts are a hardware bug or this driver doesn't
         * handle them correctly yet.
         */
-       __i2c_dw_enable(dev, false);
+       __i2c_dw_disable_nowait(dev);
 
        if (dev->msg_err) {
                ret = dev->msg_err;
index d42558d1b002ff6c23466e5cc60c49a7833bb438..8ce2cd36847717f72a6e2057d8a23922591b7050 100644 (file)
@@ -75,7 +75,7 @@ static int i2c_dw_init_slave(struct dw_i2c_dev *dev)
        comp_param1 = dw_readl(dev, DW_IC_COMP_PARAM_1);
 
        /* Disable the adapter. */
-       __i2c_dw_enable_and_wait(dev, false);
+       __i2c_dw_disable(dev);
 
        /* Configure SDA Hold Time if required. */
        reg = dw_readl(dev, DW_IC_COMP_VERSION);
@@ -119,11 +119,11 @@ static int i2c_dw_reg_slave(struct i2c_client *slave)
         * Set slave address in the IC_SAR register,
         * the address to which the DW_apb_i2c responds.
         */
-       __i2c_dw_enable(dev, false);
+       __i2c_dw_disable_nowait(dev);
        dw_writel(dev, slave->addr, DW_IC_SAR);
        dev->slave = slave;
 
-       __i2c_dw_enable(dev, true);
+       __i2c_dw_enable(dev);
 
        dev->cmd_err = 0;
        dev->msg_write_idx = 0;
index f718ee4e3332fe3ced0cf3abff9c59b21f56b99b..3f28317cde3935af5729e7ad7f816a64260ea267 100644 (file)
@@ -360,11 +360,11 @@ static int diolan_usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
                        if (ret < 0)
                                goto abort;
                }
+               ret = diolan_i2c_put_byte_ack(dev,
+                                             i2c_8bit_addr_from_msg(pmsg));
+               if (ret < 0)
+                       goto abort;
                if (pmsg->flags & I2C_M_RD) {
-                       ret =
-                           diolan_i2c_put_byte_ack(dev, (pmsg->addr << 1) | 1);
-                       if (ret < 0)
-                               goto abort;
                        for (j = 0; j < pmsg->len; j++) {
                                u8 byte;
                                bool ack = j < pmsg->len - 1;
@@ -393,9 +393,6 @@ static int diolan_usb_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
                                pmsg->buf[j] = byte;
                        }
                } else {
-                       ret = diolan_i2c_put_byte_ack(dev, pmsg->addr << 1);
-                       if (ret < 0)
-                               goto abort;
                        for (j = 0; j < pmsg->len; j++) {
                                ret = diolan_i2c_put_byte_ack(dev,
                                                              pmsg->buf[j]);
index aa336ba89aa3fe93ca07b224b851881ff98c9d92..5f2bab878b2cd34f88af4cd62ee7ce54b0d02ce4 100644 (file)
@@ -144,8 +144,7 @@ static void efm32_i2c_send_next_msg(struct efm32_i2c_ddata *ddata)
        struct i2c_msg *cur_msg = &ddata->msgs[ddata->current_msg];
 
        efm32_i2c_write32(ddata, REG_CMD, REG_CMD_START);
-       efm32_i2c_write32(ddata, REG_TXDATA, cur_msg->addr << 1 |
-                       (cur_msg->flags & I2C_M_RD ? 1 : 0));
+       efm32_i2c_write32(ddata, REG_TXDATA, i2c_8bit_addr_from_msg(cur_msg));
 }
 
 static void efm32_i2c_send_next_byte(struct efm32_i2c_ddata *ddata)
index bdeab0174fec2099b4572bbe9dea6bd9d32514db..835d54ac2971caffbadfd2ca58481079652e7271 100644 (file)
@@ -414,7 +414,7 @@ static s32 pch_i2c_writebytes(struct i2c_adapter *i2c_adap,
                iowrite32(addr_8_lsb, p + PCH_I2CDR);
        } else {
                /* set 7 bit slave address and R/W bit as 0 */
-               iowrite32(addr << 1, p + PCH_I2CDR);
+               iowrite32(i2c_8bit_addr_from_msg(msgs), p + PCH_I2CDR);
                if (first)
                        pch_i2c_start(adap);
        }
@@ -538,8 +538,7 @@ static s32 pch_i2c_readbytes(struct i2c_adapter *i2c_adap, struct i2c_msg *msgs,
                iowrite32(addr_2_msb | TEN_BIT_ADDR_MASK, p + PCH_I2CDR);
        } else {
                /* 7 address bits + R/W bit */
-               addr = (((addr) << 1) | (I2C_RD));
-               iowrite32(addr, p + PCH_I2CDR);
+               iowrite32(i2c_8bit_addr_from_msg(msgs), p + PCH_I2CDR);
        }
 
        /* check if it is the first message */
index d2e84480fbe96093549666df92a55f4f7196259f..ba9b6ea48a31362951bdc5a50b53fc2b222bf1d7 100644 (file)
@@ -149,7 +149,7 @@ static int __em_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg,
        em_clear_set_bit(priv, 0, I2C_BIT_STT0, I2C_OFS_IICC0);
 
        /* Send slave address and R/W type */
-       writeb((msg->addr << 1) | read, priv->base + I2C_OFS_IIC0);
+       writeb(i2c_8bit_addr_from_msg(msg), priv->base + I2C_OFS_IIC0);
 
        /* Wait for transaction */
        status = em_i2c_wait_for_event(priv);
index 12ec8484e65375cd24cc7b18fcd2fe5a7a458374..de82ad8ff5347cdb7a8ddfc6005619633164ef40 100644 (file)
@@ -707,7 +707,7 @@ static int exynos5_i2c_xfer(struct i2c_adapter *adap,
                        struct i2c_msg *msgs, int num)
 {
        struct exynos5_i2c *i2c = adap->algo_data;
-       int i = 0, ret = 0, stop = 0;
+       int i, ret;
 
        if (i2c->suspended) {
                dev_err(i2c->dev, "HS-I2C is not initialized.\n");
@@ -718,30 +718,15 @@ static int exynos5_i2c_xfer(struct i2c_adapter *adap,
        if (ret)
                return ret;
 
-       for (i = 0; i < num; i++, msgs++) {
-               stop = (i == num - 1);
-
-               ret = exynos5_i2c_xfer_msg(i2c, msgs, stop);
-
-               if (ret < 0)
-                       goto out;
-       }
-
-       if (i == num) {
-               ret = num;
-       } else {
-               /* Only one message, cannot access the device */
-               if (i == 1)
-                       ret = -EREMOTEIO;
-               else
-                       ret = i;
-
-               dev_warn(i2c->dev, "xfer message failed\n");
+       for (i = 0; i < num; ++i) {
+               ret = exynos5_i2c_xfer_msg(i2c, msgs + i, i + 1 == num);
+               if (ret)
+                       break;
        }
 
- out:
        clk_disable(i2c->clk);
-       return ret;
+
+       return ret ?: num;
 }
 
 static u32 exynos5_i2c_func(struct i2c_adapter *adap)
index 58abb3eced58cd39c2940632c366fb14dfd37ccf..005e6e0330c278276a0d602fcfebdc3429218cfd 100644 (file)
@@ -11,7 +11,7 @@
 #include <linux/delay.h>
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
-#include <linux/i2c-gpio.h>
+#include <linux/platform_data/i2c-gpio.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/slab.h>
index bb68957d3da5e6846169ae1b26bfd37f9e6d1caa..061a4bfb03f4d3b1312d862514034ad7e42656ee 100644 (file)
@@ -73,7 +73,6 @@
 #define I2C_OVER_INTR          BIT(0)
 
 #define HIX5I2C_MAX_FREQ       400000          /* 400k */
-#define HIX5I2C_READ_OPERATION 0x01
 
 enum hix5hd2_i2c_state {
        HIX5I2C_STAT_RW_ERR = -1,
@@ -311,12 +310,8 @@ static void hix5hd2_i2c_message_start(struct hix5hd2_i2c_priv *priv, int stop)
        hix5hd2_i2c_clr_all_irq(priv);
        hix5hd2_i2c_enable_irq(priv);
 
-       if (priv->msg->flags & I2C_M_RD)
-               writel_relaxed((priv->msg->addr << 1) | HIX5I2C_READ_OPERATION,
-                              priv->regs + HIX5I2C_TXR);
-       else
-               writel_relaxed(priv->msg->addr << 1,
-                              priv->regs + HIX5I2C_TXR);
+       writel_relaxed(i2c_8bit_addr_from_msg(priv->msg),
+                      priv->regs + HIX5I2C_TXR);
 
        writel_relaxed(I2C_WRITE | I2C_START, priv->regs + HIX5I2C_COM);
        spin_unlock_irqrestore(&priv->lock, flags);
@@ -377,17 +372,7 @@ static int hix5hd2_i2c_xfer(struct i2c_adapter *adap,
                        goto out;
        }
 
-       if (i == num) {
-               ret = num;
-       } else {
-               /* Only one message, cannot access the device */
-               if (i == 1)
-                       ret = -EREMOTEIO;
-               else
-                       ret = i;
-
-               dev_warn(priv->dev, "xfer message failed\n");
-       }
+       ret = num;
 
 out:
        pm_runtime_mark_last_busy(priv->dev);
@@ -471,7 +456,6 @@ static int hix5hd2_i2c_probe(struct platform_device *pdev)
                goto err_clk;
        }
 
-       pm_suspend_ignore_children(&pdev->dev, true);
        pm_runtime_set_autosuspend_delay(priv->dev, MSEC_PER_SEC);
        pm_runtime_use_autosuspend(priv->dev);
        pm_runtime_set_active(priv->dev);
index e0d59e9ff3c6de53b5c94a54fbd21e88713ecd1b..aa726607645ee6c5cb2565d645a45da71982c306 100644 (file)
 
 #if IS_ENABLED(CONFIG_I2C_MUX_GPIO) && defined CONFIG_DMI
 #include <linux/gpio.h>
-#include <linux/i2c-mux-gpio.h>
+#include <linux/platform_data/i2c-mux-gpio.h>
 #endif
 
 /* I801 SMBus address offsets */
@@ -1710,7 +1710,7 @@ static void i801_shutdown(struct pci_dev *dev)
        pci_write_config_byte(dev, SMBHSTCFG, priv->original_hstcfg);
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_SLEEP
 static int i801_suspend(struct device *dev)
 {
        struct pci_dev *pci_dev = to_pci_dev(dev);
@@ -1731,8 +1731,7 @@ static int i801_resume(struct device *dev)
 }
 #endif
 
-static UNIVERSAL_DEV_PM_OPS(i801_pm_ops, i801_suspend,
-                           i801_resume, NULL);
+static SIMPLE_DEV_PM_OPS(i801_pm_ops, i801_suspend, i801_resume);
 
 static struct pci_driver i801_driver = {
        .name           = "i801_smbus",
index 961c5f42d956f11fe1e87b95aaf50339959e7014..6f6e1dfe7ccee3982d4e824215b53ef2e48772ff 100644 (file)
@@ -561,9 +561,6 @@ static int iic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 
        DBG2("%d: iic_xfer, %d msg(s)\n", dev->idx, num);
 
-       if (!num)
-               return 0;
-
        /* Check the sanity of the passed messages.
         * Uhh, generic i2c layer is more suitable place for such code...
         */
index e6da2c7a9a3e60841e7405738f6ea091cc0eea0f..6d975f5221ca0e37410c9d2e770f7d78bfe270b2 100644 (file)
@@ -1,18 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * This is i.MX low power i2c controller driver.
  *
  * Copyright 2016 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * 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.h>
@@ -180,15 +170,13 @@ static int lpi2c_imx_start(struct lpi2c_imx_struct *lpi2c_imx,
                           struct i2c_msg *msgs)
 {
        unsigned int temp;
-       u8 read;
 
        temp = readl(lpi2c_imx->base + LPI2C_MCR);
        temp |= MCR_RRF | MCR_RTF;
        writel(temp, lpi2c_imx->base + LPI2C_MCR);
        writel(0x7f00, lpi2c_imx->base + LPI2C_MSR);
 
-       read = msgs->flags & I2C_M_RD;
-       temp = (msgs->addr << 1 | read) | (GEN_START << 8);
+       temp = i2c_8bit_addr_from_msg(msgs) | (GEN_START << 8);
        writel(temp, lpi2c_imx->base + LPI2C_MTDR);
 
        return lpi2c_imx_bus_busy(lpi2c_imx);
index d7267dd9c7bf1da67c4c326ca53fffd6bc0e0c36..0207e194f84bb4e667d4ebec548987f40caffdd1 100644 (file)
@@ -1,16 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  *     Copyright (C) 2002 Motorola GSG-China
  *
- *     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.
- *
  * Author:
  *     Darius Augulis, Teltonika Inc.
  *
@@ -630,7 +621,7 @@ static int i2c_imx_dma_write(struct imx_i2c_struct *i2c_imx,
         * Write slave address.
         * The first byte must be transmitted by the CPU.
         */
-       imx_i2c_write_reg(msgs->addr << 1, i2c_imx, IMX_I2C_I2DR);
+       imx_i2c_write_reg(i2c_8bit_addr_from_msg(msgs), i2c_imx, IMX_I2C_I2DR);
        reinit_completion(&i2c_imx->dma->cmd_complete);
        time_left = wait_for_completion_timeout(
                                &i2c_imx->dma->cmd_complete,
@@ -760,10 +751,10 @@ static int i2c_imx_write(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs)
        int i, result;
 
        dev_dbg(&i2c_imx->adapter.dev, "<%s> write slave address: addr=0x%x\n",
-               __func__, msgs->addr << 1);
+               __func__, i2c_8bit_addr_from_msg(msgs));
 
        /* write slave address */
-       imx_i2c_write_reg(msgs->addr << 1, i2c_imx, IMX_I2C_I2DR);
+       imx_i2c_write_reg(i2c_8bit_addr_from_msg(msgs), i2c_imx, IMX_I2C_I2DR);
        result = i2c_imx_trx_complete(i2c_imx);
        if (result)
                return result;
@@ -796,10 +787,10 @@ static int i2c_imx_read(struct imx_i2c_struct *i2c_imx, struct i2c_msg *msgs, bo
 
        dev_dbg(&i2c_imx->adapter.dev,
                "<%s> write slave address: addr=0x%x\n",
-               __func__, (msgs->addr << 1) | 0x01);
+               __func__, i2c_8bit_addr_from_msg(msgs));
 
        /* write slave address */
-       imx_i2c_write_reg((msgs->addr << 1) | 0x01, i2c_imx, IMX_I2C_I2DR);
+       imx_i2c_write_reg(i2c_8bit_addr_from_msg(msgs), i2c_imx, IMX_I2C_I2DR);
        result = i2c_imx_trx_complete(i2c_imx);
        if (result)
                return result;
index e879190b5d1d899457ec6dd11b9cc7bd73e61f5b..1c874aaa0447ac891754a69a4cf5539f6ecae113 100644 (file)
@@ -124,15 +124,14 @@ static int kempld_i2c_process(struct kempld_i2c_data *i2c)
                /* 10 bit address? */
                if (i2c->msg->flags & I2C_M_TEN) {
                        addr = 0xf0 | ((i2c->msg->addr >> 7) & 0x6);
+                       /* Set read bit if necessary */
+                       addr |= (i2c->msg->flags & I2C_M_RD) ? 1 : 0;
                        i2c->state = STATE_ADDR10;
                } else {
-                       addr = (i2c->msg->addr << 1);
+                       addr = i2c_8bit_addr_from_msg(i2c->msg);
                        i2c->state = STATE_START;
                }
 
-               /* Set read bit if necessary */
-               addr |= (i2c->msg->flags & I2C_M_RD) ? 1 : 0;
-
                kempld_write8(pld, KEMPLD_I2C_DATA, addr);
                kempld_write8(pld, KEMPLD_I2C_CMD, I2C_CMD_START);
 
index 4c28fa28ce766f2c6e3045857a77588613268a66..745ed43a22d65cba3920aced8aa2f525d5e4e9a9 100644 (file)
 #define MLXCPLD_I2C_VALID_FLAG         (I2C_M_RECV_LEN | I2C_M_RD)
 #define MLXCPLD_I2C_BUS_NUM            1
 #define MLXCPLD_I2C_DATA_REG_SZ                36
+#define MLXCPLD_I2C_DATA_SZ_BIT                BIT(5)
+#define MLXCPLD_I2C_DATA_SZ_MASK       GENMASK(6, 5)
+#define MLXCPLD_I2C_SMBUS_BLK_BIT      BIT(7)
 #define MLXCPLD_I2C_MAX_ADDR_LEN       4
 #define MLXCPLD_I2C_RETR_NUM           2
 #define MLXCPLD_I2C_XFER_TO            500000 /* usec */
 #define MLXCPLD_I2C_POLL_TIME          2000   /* usec */
 
 /* LPC I2C registers */
-#define MLXCPLD_LPCI2C_LPF_REG         0x0
+#define MLXCPLD_LPCI2C_CPBLTY_REG      0x0
 #define MLXCPLD_LPCI2C_CTRL_REG                0x1
 #define MLXCPLD_LPCI2C_HALF_CYC_REG    0x4
 #define MLXCPLD_LPCI2C_I2C_HOLD_REG    0x5
@@ -83,6 +86,7 @@ struct mlxcpld_i2c_priv {
        struct mutex lock;
        struct  mlxcpld_i2c_curr_xfer xfer;
        struct device *dev;
+       bool smbus_block;
 };
 
 static void mlxcpld_i2c_lpc_write_buf(u8 *data, u8 len, u32 addr)
@@ -230,7 +234,7 @@ static void mlxcpld_i2c_set_transf_data(struct mlxcpld_i2c_priv *priv,
         * All upper layers currently are never use transfer with more than
         * 2 messages. Actually, it's also not so relevant in Mellanox systems
         * because of HW limitation. Max size of transfer is not more than 32
-        * bytes in the current x86 LPCI2C bridge.
+        * or 68 bytes in the current x86 LPCI2C bridge.
         */
        priv->xfer.cmd = msgs[num - 1].flags & I2C_M_RD;
 
@@ -295,7 +299,7 @@ static int mlxcpld_i2c_wait_for_free(struct mlxcpld_i2c_priv *priv)
 static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv)
 {
        int status, i, timeout = 0;
-       u8 datalen;
+       u8 datalen, val;
 
        do {
                usleep_range(MLXCPLD_I2C_POLL_TIME / 2, MLXCPLD_I2C_POLL_TIME);
@@ -324,9 +328,22 @@ static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv)
                 * Actual read data len will be always the same as
                 * requested len. 0xff (line pull-up) will be returned
                 * if slave has no data to return. Thus don't read
-                * MLXCPLD_LPCI2C_NUM_DAT_REG reg from CPLD.
+                * MLXCPLD_LPCI2C_NUM_DAT_REG reg from CPLD.  Only in case of
+                * SMBus block read transaction data len can be different,
+                * check this case.
                 */
-               datalen = priv->xfer.data_len;
+               mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_NUM_ADDR_REG, &val,
+                                     1);
+               if (priv->smbus_block && (val & MLXCPLD_I2C_SMBUS_BLK_BIT)) {
+                       mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_NUM_DAT_REG,
+                                             &datalen, 1);
+                       if (unlikely(datalen > (I2C_SMBUS_BLOCK_MAX + 1))) {
+                               dev_err(priv->dev, "Incorrect smbus block read message len\n");
+                               return -E2BIG;
+                       }
+               } else {
+                       datalen = priv->xfer.data_len;
+               }
 
                mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_DATA_REG,
                                      priv->xfer.msg[i].buf, datalen);
@@ -344,12 +361,20 @@ static int mlxcpld_i2c_wait_for_tc(struct mlxcpld_i2c_priv *priv)
 static void mlxcpld_i2c_xfer_msg(struct mlxcpld_i2c_priv *priv)
 {
        int i, len = 0;
-       u8 cmd;
+       u8 cmd, val;
 
        mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_NUM_DAT_REG,
                               &priv->xfer.data_len, 1);
-       mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_NUM_ADDR_REG,
-                              &priv->xfer.addr_width, 1);
+
+       val = priv->xfer.addr_width;
+       /* Notify HW about SMBus block read transaction */
+       if (priv->smbus_block && priv->xfer.msg_num >= 2 &&
+           priv->xfer.msg[1].len == 1 &&
+           (priv->xfer.msg[1].flags & I2C_M_RECV_LEN) &&
+           (priv->xfer.msg[1].flags & I2C_M_RD))
+               val |= MLXCPLD_I2C_SMBUS_BLK_BIT;
+
+       mlxcpld_i2c_write_comm(priv, MLXCPLD_LPCI2C_NUM_ADDR_REG, &val, 1);
 
        for (i = 0; i < priv->xfer.msg_num; i++) {
                if ((priv->xfer.msg[i].flags & I2C_M_RD) != I2C_M_RD) {
@@ -425,7 +450,14 @@ static int mlxcpld_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 
 static u32 mlxcpld_i2c_func(struct i2c_adapter *adap)
 {
-       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_SMBUS_BLOCK_DATA;
+       struct mlxcpld_i2c_priv *priv = i2c_get_adapdata(adap);
+
+       if (priv->smbus_block)
+               return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
+                       I2C_FUNC_SMBUS_I2C_BLOCK | I2C_FUNC_SMBUS_BLOCK_DATA;
+       else
+               return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL |
+                       I2C_FUNC_SMBUS_I2C_BLOCK;
 }
 
 static const struct i2c_algorithm mlxcpld_i2c_algo = {
@@ -440,6 +472,13 @@ static const struct i2c_adapter_quirks mlxcpld_i2c_quirks = {
        .max_comb_1st_msg_len = 4,
 };
 
+static const struct i2c_adapter_quirks mlxcpld_i2c_quirks_ext = {
+       .flags = I2C_AQ_COMB_WRITE_THEN_READ,
+       .max_read_len = MLXCPLD_I2C_DATA_REG_SZ * 2 - MLXCPLD_I2C_MAX_ADDR_LEN,
+       .max_write_len = MLXCPLD_I2C_DATA_REG_SZ * 2,
+       .max_comb_1st_msg_len = 4,
+};
+
 static struct i2c_adapter mlxcpld_i2c_adapter = {
        .owner          = THIS_MODULE,
        .name           = "i2c-mlxcpld",
@@ -454,6 +493,7 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev)
 {
        struct mlxcpld_i2c_priv *priv;
        int err;
+       u8 val;
 
        priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
        if (!priv)
@@ -466,6 +506,16 @@ static int mlxcpld_i2c_probe(struct platform_device *pdev)
 
        /* Register with i2c layer */
        mlxcpld_i2c_adapter.timeout = usecs_to_jiffies(MLXCPLD_I2C_XFER_TO);
+       /* Read capability register */
+       mlxcpld_i2c_read_comm(priv, MLXCPLD_LPCI2C_CPBLTY_REG, &val, 1);
+       /* Check support for extended transaction length */
+       if ((val & MLXCPLD_I2C_DATA_SZ_MASK) == MLXCPLD_I2C_DATA_SZ_BIT)
+               mlxcpld_i2c_adapter.quirks = &mlxcpld_i2c_quirks_ext;
+       /* Check support for smbus block transaction */
+       if (val & MLXCPLD_I2C_SMBUS_BLK_BIT)
+               priv->smbus_block = true;
+       if (pdev->id >= -1)
+               mlxcpld_i2c_adapter.nr = pdev->id;
        priv->adap = mlxcpld_i2c_adapter;
        priv->adap.dev.parent = &pdev->dev;
        priv->base_addr = MLXPLAT_CPLD_LPC_I2C_BASE_ADDR;
index cf23a746cc17efeb2eaa98792b0587887c4152dc..1e57f58fcb00151e9ef274e25e3adf22f2c197b8 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/mm.h>
 #include <linux/module.h>
 #include <linux/of_address.h>
+#include <linux/of_device.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/scatterlist.h>
@@ -734,7 +735,6 @@ static int mtk_i2c_parse_dt(struct device_node *np, struct mtk_i2c *i2c)
 
 static int mtk_i2c_probe(struct platform_device *pdev)
 {
-       const struct of_device_id *of_id;
        int ret = 0;
        struct mtk_i2c *i2c;
        struct clk *clk;
@@ -761,11 +761,7 @@ static int mtk_i2c_probe(struct platform_device *pdev)
 
        init_completion(&i2c->msg_complete);
 
-       of_id = of_match_node(mtk_i2c_of_match, pdev->dev.of_node);
-       if (!of_id)
-               return -EINVAL;
-
-       i2c->dev_comp = of_id->data;
+       i2c->dev_comp = of_device_get_match_data(&pdev->dev);
        i2c->adap.dev.of_node = pdev->dev.of_node;
        i2c->dev = &pdev->dev;
        i2c->adap.dev.parent = &pdev->dev;
index e617bd600794c235030c9f5d0ea0de4b4341f8e9..642c58946d8d261a48cd146ffe7bff65a90ef660 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Freescale MXS I2C bus driver
  *
@@ -7,12 +8,6 @@
  * based on a (non-working) driver which was:
  *
  * Copyright (C) 2009-2010 Freescale Semiconductor, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
  */
 
 #include <linux/slab.h>
@@ -180,9 +175,10 @@ static int mxs_i2c_dma_setup_xfer(struct i2c_adapter *adap,
        struct dma_async_tx_descriptor *desc;
        struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap);
 
+       i2c->addr_data = i2c_8bit_addr_from_msg(msg);
+
        if (msg->flags & I2C_M_RD) {
                i2c->dma_read = true;
-               i2c->addr_data = (msg->addr << 1) | I2C_SMBUS_READ;
 
                /*
                 * SELECT command.
@@ -240,7 +236,6 @@ static int mxs_i2c_dma_setup_xfer(struct i2c_adapter *adap,
                }
        } else {
                i2c->dma_read = false;
-               i2c->addr_data = (msg->addr << 1) | I2C_SMBUS_WRITE;
 
                /*
                 * WRITE command.
@@ -371,7 +366,7 @@ static int mxs_i2c_pio_setup_xfer(struct i2c_adapter *adap,
                        struct i2c_msg *msg, uint32_t flags)
 {
        struct mxs_i2c_dev *i2c = i2c_get_adapdata(adap);
-       uint32_t addr_data = msg->addr << 1;
+       uint32_t addr_data = i2c_8bit_addr_from_msg(msg);
        uint32_t data = 0;
        int i, ret, xlen = 0, xmit = 0;
        uint32_t start;
@@ -411,8 +406,6 @@ static int mxs_i2c_pio_setup_xfer(struct i2c_adapter *adap,
                 */
                BUG_ON(msg->len > 4);
 
-               addr_data |= I2C_SMBUS_READ;
-
                /* SELECT command. */
                mxs_i2c_pio_trigger_write_cmd(i2c, MXS_CMD_I2C_SELECT,
                                              addr_data);
@@ -450,7 +443,6 @@ static int mxs_i2c_pio_setup_xfer(struct i2c_adapter *adap,
                 * fast enough. It is possible to transfer arbitrary amount
                 * of data using PIO write.
                 */
-               addr_data |= I2C_SMBUS_WRITE;
 
                /*
                 * The LSB of data buffer is the first byte blasted across
index 88eda09e73c0b31509427a784c5219655a49c2fb..58a0fbf0e0740dd700fd6b494f7235d6d6522950 100644 (file)
@@ -164,12 +164,12 @@ static int __init nforce2_s4985_init(void)
 
        printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4985\n");
        /* Define the 5 virtual adapters and algorithms structures */
-       s4985_adapter = kzalloc(5 * sizeof(struct i2c_adapter), GFP_KERNEL);
+       s4985_adapter = kcalloc(5, sizeof(struct i2c_adapter), GFP_KERNEL);
        if (!s4985_adapter) {
                error = -ENOMEM;
                goto ERROR1;
        }
-       s4985_algo = kzalloc(5 * sizeof(struct i2c_algorithm), GFP_KERNEL);
+       s4985_algo = kcalloc(5, sizeof(struct i2c_algorithm), GFP_KERNEL);
        if (!s4985_algo) {
                error = -ENOMEM;
                goto ERROR2;
index 3241bb9d6c186985ae11d38c1e7511b6d4aaea1d..f6a1272c58544159ca1402bc173bc04b334b65b9 100644 (file)
@@ -381,7 +381,7 @@ static int nforce2_probe(struct pci_dev *dev, const struct pci_device_id *id)
        int res1, res2;
 
        /* we support 2 SMBus adapters */
-       smbuses = kzalloc(2 * sizeof(struct nforce2_smbus), GFP_KERNEL);
+       smbuses = kcalloc(2, sizeof(struct nforce2_smbus), GFP_KERNEL);
        if (!smbuses)
                return -ENOMEM;
        pci_set_drvdata(dev, smbuses);
index 49c7c0c91486a48321b7711c04166b13dda97001..0ed5a41804dcf8d5d33d043a3d0f8e29b5430e4f 100644 (file)
@@ -1012,8 +1012,6 @@ static int nmk_i2c_probe(struct amba_device *adev, const struct amba_id *id)
                goto err_no_mem;
        }
 
-       pm_suspend_ignore_children(&adev->dev, true);
-
        dev->clk = devm_clk_get(&adev->dev, NULL);
        if (IS_ERR(dev->clk)) {
                dev_err(&adev->dev, "could not get i2c clock\n");
index 45ae3c025bf68064e90923a1b4febfabf0b36e47..88444ef74943dcd64b7bdddff9c47a93e6a4093f 100644 (file)
@@ -21,7 +21,7 @@
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/wait.h>
-#include <linux/i2c-ocores.h>
+#include <linux/platform_data/i2c-ocores.h>
 #include <linux/slab.h>
 #include <linux/io.h>
 #include <linux/log2.h>
@@ -222,10 +222,7 @@ static int ocores_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
        i2c->nmsgs = num;
        i2c->state = STATE_START;
 
-       oc_setreg(i2c, OCI2C_DATA,
-                       (i2c->msg->addr << 1) |
-                       ((i2c->msg->flags & I2C_M_RD) ? 1:0));
-
+       oc_setreg(i2c, OCI2C_DATA, i2c_8bit_addr_from_msg(i2c->msg));
        oc_setreg(i2c, OCI2C_CMD, OCI2C_CMD_START);
 
        if (wait_event_timeout(i2c->wait, (i2c->state == STATE_ERROR) ||
index b9172f08fd05fac32b2d4e40e87615c0691e50fe..65d06a8193074814cb18a0864eaea9cbc3c044de 100644 (file)
@@ -36,7 +36,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/slab.h>
-#include <linux/i2c-omap.h>
+#include <linux/platform_data/i2c-omap.h>
 #include <linux/pm_runtime.h>
 #include <linux/pinctrl/consumer.h>
 
index 0aabb7eca0c552968df67bd39aa81db9de009131..dc2a23f4fb52f354e8914dce6335e09a9d8383a9 100644 (file)
@@ -94,8 +94,6 @@ static int i2c_opal_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
         */
        memset(&req, 0, sizeof(req));
        switch(num) {
-       case 0:
-               return 0;
        case 1:
                req.type = (msgs[0].flags & I2C_M_RD) ?
                        OPAL_I2C_RAW_READ : OPAL_I2C_RAW_WRITE;
@@ -114,8 +112,6 @@ static int i2c_opal_master_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
                req.size = cpu_to_be32(msgs[1].len);
                req.buffer_ra = cpu_to_be64(__pa(msgs[1].buf));
                break;
-       default:
-               return -EOPNOTSUPP;
        }
 
        rc = i2c_opal_send_request(opal_id, &req);
index df1dbc92a0244c4eb989e88826c9f24235f35c7a..55fd5c6f3cca1523715f6f80f5fc061b79304728 100644 (file)
@@ -121,7 +121,7 @@ static int pasemi_i2c_xfer_msg(struct i2c_adapter *adapter,
 
        read = msg->flags & I2C_M_RD ? 1 : 0;
 
-       TXFIFO_WR(smbus, MTXFIFO_START | (msg->addr << 1) | read);
+       TXFIFO_WR(smbus, MTXFIFO_START | i2c_8bit_addr_from_msg(msg));
 
        if (read) {
                TXFIFO_WR(smbus, msg->len | MTXFIFO_READ |
index bc2707ffd4090289d3013f6b7f36f2d2a7b19c30..de3fe6e828cbdcf585aae98989ea418e6c8725fd 100644 (file)
@@ -20,7 +20,7 @@
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
 #include <linux/i2c-algo-pca.h>
-#include <linux/i2c-pca-platform.h>
+#include <linux/platform_data/i2c-pca-platform.h>
 #include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
 #include <linux/io.h>
index a542041df0cd4c95ff8e25340a9c36742eedba8f..6e0e546ef83fcabe595f6591867850b8730b2e14 100644 (file)
@@ -18,7 +18,6 @@
 #include <linux/timer.h>
 #include <linux/completion.h>
 #include <linux/platform_device.h>
-#include <linux/i2c-pnx.h>
 #include <linux/io.h>
 #include <linux/err.h>
 #include <linux/clk.h>
 #define I2C_PNX_SPEED_KHZ_DEFAULT      100
 #define I2C_PNX_REGION_SIZE            0x100
 
+struct i2c_pnx_mif {
+       int                     ret;            /* Return value */
+       int                     mode;           /* Interface mode */
+       struct completion       complete;       /* I/O completion */
+       struct timer_list       timer;          /* Timeout */
+       u8 *                    buf;            /* Data buffer */
+       int                     len;            /* Length of data buffer */
+       int                     order;          /* RX Bytes to order via TX */
+};
+
+struct i2c_pnx_algo_data {
+       void __iomem            *ioaddr;
+       struct i2c_pnx_mif      mif;
+       int                     last;
+       struct clk              *clk;
+       struct i2c_adapter      adapter;
+       int                     irq;
+       u32                     timeout;
+};
+
 enum {
        mstatus_tdi = 0x00000001,
        mstatus_afi = 0x00000002,
index 904dfec7ab96e5492c6563af4a60e01baa150f36..c86c3ae1318f200696f909f7563c8a114ee30995 100644 (file)
  */
 #define TOUT_MIN                       2
 
+/* I2C Frequency Modes */
+#define I2C_STANDARD_FREQ              100000
+#define I2C_FAST_MODE_FREQ             400000
+#define I2C_FAST_MODE_PLUS_FREQ                1000000
+
 /* Default values. Use these if FW query fails */
-#define DEFAULT_CLK_FREQ 100000
+#define DEFAULT_CLK_FREQ I2C_STANDARD_FREQ
 #define DEFAULT_SRC_CLK 20000000
 
 /*
 /* TAG length for DATA READ in RX FIFO  */
 #define READ_RX_TAGS_LEN               2
 
+static unsigned int scl_freq;
+module_param_named(scl_freq, scl_freq, uint, 0444);
+MODULE_PARM_DESC(scl_freq, "SCL frequency override");
+
 /*
  * count: no of blocks
  * pos: current block number
@@ -453,7 +462,7 @@ static void qup_i2c_write_tx_fifo_v1(struct qup_i2c_dev *qup)
 {
        struct qup_i2c_block *blk = &qup->blk;
        struct i2c_msg *msg = qup->msg;
-       u32 addr = msg->addr << 1;
+       u32 addr = i2c_8bit_addr_from_msg(msg);
        u32 qup_tag;
        int idx;
        u32 val;
@@ -1648,6 +1657,12 @@ static void qup_i2c_disable_clocks(struct qup_i2c_dev *qup)
        clk_disable_unprepare(qup->pclk);
 }
 
+static const struct acpi_device_id qup_i2c_acpi_match[] = {
+       { "QCOM8010"},
+       { },
+};
+MODULE_DEVICE_TABLE(acpi, qup_i2c_acpi_match);
+
 static int qup_i2c_probe(struct platform_device *pdev)
 {
        static const int blk_sizes[] = {4, 16, 32};
@@ -1669,10 +1684,15 @@ static int qup_i2c_probe(struct platform_device *pdev)
        init_completion(&qup->xfer);
        platform_set_drvdata(pdev, qup);
 
-       ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
-       if (ret) {
-               dev_notice(qup->dev, "using default clock-frequency %d",
-                       DEFAULT_CLK_FREQ);
+       if (scl_freq) {
+               dev_notice(qup->dev, "Using override frequency of %u\n", scl_freq);
+               clk_freq = scl_freq;
+       } else {
+               ret = device_property_read_u32(qup->dev, "clock-frequency", &clk_freq);
+               if (ret) {
+                       dev_notice(qup->dev, "using default clock-frequency %d",
+                               DEFAULT_CLK_FREQ);
+               }
        }
 
        if (of_device_is_compatible(pdev->dev.of_node, "qcom,i2c-qup-v1.1.1")) {
@@ -1682,7 +1702,10 @@ static int qup_i2c_probe(struct platform_device *pdev)
        } else {
                qup->adap.algo = &qup_i2c_algo_v2;
                is_qup_v1 = false;
-               ret = qup_i2c_req_dma(qup);
+               if (acpi_match_device(qup_i2c_acpi_match, qup->dev))
+                       goto nodma;
+               else
+                       ret = qup_i2c_req_dma(qup);
 
                if (ret == -EPROBE_DEFER)
                        goto fail_dma;
@@ -1691,8 +1714,8 @@ static int qup_i2c_probe(struct platform_device *pdev)
 
                qup->max_xfer_sg_len = (MX_BLOCKS << 1);
                blocks = (MX_DMA_BLOCKS << 1) + 1;
-               qup->btx.sg = devm_kzalloc(&pdev->dev,
-                                          sizeof(*qup->btx.sg) * blocks,
+               qup->btx.sg = devm_kcalloc(&pdev->dev,
+                                          blocks, sizeof(*qup->btx.sg),
                                           GFP_KERNEL);
                if (!qup->btx.sg) {
                        ret = -ENOMEM;
@@ -1700,8 +1723,8 @@ static int qup_i2c_probe(struct platform_device *pdev)
                }
                sg_init_table(qup->btx.sg, blocks);
 
-               qup->brx.sg = devm_kzalloc(&pdev->dev,
-                                          sizeof(*qup->brx.sg) * blocks,
+               qup->brx.sg = devm_kcalloc(&pdev->dev,
+                                          blocks, sizeof(*qup->brx.sg),
                                           GFP_KERNEL);
                if (!qup->brx.sg) {
                        ret = -ENOMEM;
@@ -1734,8 +1757,8 @@ static int qup_i2c_probe(struct platform_device *pdev)
        }
 
 nodma:
-       /* We support frequencies up to FAST Mode (400KHz) */
-       if (!clk_freq || clk_freq > 400000) {
+       /* We support frequencies up to FAST Mode Plus (1MHz) */
+       if (!clk_freq || clk_freq > I2C_FAST_MODE_PLUS_FREQ) {
                dev_err(qup->dev, "clock frequency not supported %d\n",
                        clk_freq);
                return -EINVAL;
@@ -1839,9 +1862,15 @@ static int qup_i2c_probe(struct platform_device *pdev)
        size = QUP_INPUT_FIFO_SIZE(io_mode);
        qup->in_fifo_sz = qup->in_blk_sz * (2 << size);
 
-       fs_div = ((src_clk_freq / clk_freq) / 2) - 3;
        hs_div = 3;
-       qup->clk_ctl = (hs_div << 8) | (fs_div & 0xff);
+       if (clk_freq <= I2C_STANDARD_FREQ) {
+               fs_div = ((src_clk_freq / clk_freq) / 2) - 3;
+               qup->clk_ctl = (hs_div << 8) | (fs_div & 0xff);
+       } else {
+               /* 33%/66% duty cycle */
+               fs_div = ((src_clk_freq / clk_freq) - 6) * 2 / 3;
+               qup->clk_ctl = ((fs_div / 2) << 16) | (hs_div << 8) | (fs_div & 0xff);
+       }
 
        /*
         * Time it takes for a byte to be clocked out on the bus.
@@ -1959,14 +1988,6 @@ static const struct of_device_id qup_i2c_dt_match[] = {
 };
 MODULE_DEVICE_TABLE(of, qup_i2c_dt_match);
 
-#if IS_ENABLED(CONFIG_ACPI)
-static const struct acpi_device_id qup_i2c_acpi_match[] = {
-       { "QCOM8010"},
-       { },
-};
-MODULE_DEVICE_TABLE(acpi, qup_i2c_acpi_match);
-#endif
-
 static struct platform_driver qup_i2c_driver = {
        .probe  = qup_i2c_probe,
        .remove = qup_i2c_remove,
index c6915b835396587d7d39682ef7743e85a191ee6b..5e310efd94464897d9db7becf89294a8b2adc4f6 100644 (file)
@@ -329,7 +329,7 @@ static void rcar_i2c_prepare_msg(struct rcar_i2c_priv *priv)
        if (priv->msgs_left == 1)
                priv->flags |= ID_LAST_MSG;
 
-       rcar_i2c_write(priv, ICMAR, (priv->msg->addr << 1) | read);
+       rcar_i2c_write(priv, ICMAR, i2c_8bit_addr_from_msg(priv->msg));
        /*
         * We don't have a test case but the HW engineers say that the write order
         * of ICMSR and ICMCR depends on whether we issue START or REP_START. Since
@@ -542,6 +542,8 @@ static void rcar_i2c_irq_recv(struct rcar_i2c_priv *priv, u32 msr)
         * If next received data is the _LAST_, go to STOP phase. Might be
         * overwritten by REP START when setting up a new msg. Not elegant
         * but the only stable sequence for REP START I have found so far.
+        * If you want to change this code, make sure sending one transfer with
+        * four messages (WR-RD-WR-RD) works!
         */
        if (priv->pos + 1 >= msg->len)
                rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_STOP);
index 95c2f1ce3cad8b4a115f355609d92a9ae910c140..5f1fca7880b1b28d0c2387b9f7dc414527c23e81 100644 (file)
@@ -167,15 +167,14 @@ static irqreturn_t riic_tdre_isr(int irq, void *data)
                return IRQ_NONE;
 
        if (riic->bytes_left == RIIC_INIT_MSG) {
-               val = !!(riic->msg->flags & I2C_M_RD);
-               if (val)
+               if (riic->msg->flags & I2C_M_RD)
                        /* On read, switch over to receive interrupt */
                        riic_clear_set_bit(riic, ICIER_TIE, ICIER_RIE, RIIC_ICIER);
                else
                        /* On write, initialize length */
                        riic->bytes_left = riic->msg->len;
 
-               val |= (riic->msg->addr << 1);
+               val = i2c_8bit_addr_from_msg(riic->msg);
        } else {
                val = *riic->buf;
                riic->buf++;
index e1a18d989f830771f27614aba820ffc5da5356e6..b8a2728dd4b69cabca0314a70196176c0df12dde 100644 (file)
@@ -1326,8 +1326,6 @@ static int rk3x_i2c_probe(struct platform_device *pdev)
        if (ret < 0)
                goto err_clk_notifier;
 
-       dev_info(&pdev->dev, "Initialized RK3xxx I2C bus at %p\n", i2c->regs);
-
        return 0;
 
 err_clk_notifier:
index 9c0f52b7ff7ec4a04660c4fe2b00d471463531a9..d848cf5152349dde7d828a0ccf2e4389bb49182e 100644 (file)
@@ -62,27 +62,24 @@ static int osif_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs,
 {
        struct osif_priv *priv = adapter->algo_data;
        struct i2c_msg *pmsg;
-       int ret = 0;
-       int i, cmd;
+       int ret;
+       int i;
 
-       for (i = 0; ret >= 0 && i < num; i++) {
+       for (i = 0; i < num; i++) {
                pmsg = &msgs[i];
 
                if (pmsg->flags & I2C_M_RD) {
-                       cmd = OSIFI2C_READ;
-
-                       ret = osif_usb_read(adapter, cmd, pmsg->flags,
-                                           pmsg->addr, pmsg->buf,
-                                           pmsg->len);
+                       ret = osif_usb_read(adapter, OSIFI2C_READ,
+                                           pmsg->flags, pmsg->addr,
+                                           pmsg->buf, pmsg->len);
                        if (ret != pmsg->len) {
                                dev_err(&adapter->dev, "failure reading data\n");
                                return -EREMOTEIO;
                        }
                } else {
-                       cmd = OSIFI2C_WRITE;
-
-                       ret = osif_usb_write(adapter, cmd, pmsg->flags,
-                                            pmsg->addr, pmsg->buf, pmsg->len);
+                       ret = osif_usb_write(adapter, OSIFI2C_WRITE,
+                                            pmsg->flags, pmsg->addr,
+                                            pmsg->buf, pmsg->len);
                        if (ret != pmsg->len) {
                                dev_err(&adapter->dev, "failure writing data\n");
                                return -EREMOTEIO;
index 5d97510ee48bf153cf8e407f1911156a79546d54..9fe2b6951895b6b27984eedeb82c8ec6c34604e7 100644 (file)
@@ -154,8 +154,6 @@ static const struct of_device_id s3c24xx_i2c_match[] = {
        { .compatible = "samsung,s3c2440-i2c", .data = (void *)QUIRK_S3C2440 },
        { .compatible = "samsung,s3c2440-hdmiphy-i2c",
          .data = (void *)(QUIRK_S3C2440 | QUIRK_HDMIPHY | QUIRK_NO_GPIO) },
-       { .compatible = "samsung,exynos5440-i2c",
-         .data = (void *)(QUIRK_S3C2440 | QUIRK_NO_GPIO) },
        { .compatible = "samsung,exynos5-sata-phy-i2c",
          .data = (void *)(QUIRK_S3C2440 | QUIRK_POLL | QUIRK_NO_GPIO) },
        {},
index d856bc211715e5ae466b715881494a1be0916bb5..5fda4188a9e51d6aa33613e0247e462913f7b2c4 100644 (file)
@@ -899,17 +899,6 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
        if (resource_size(res) > 0x17)
                pd->flags |= IIC_FLAG_HAS_ICIC67;
 
-       /* Enable Runtime PM for this device.
-        *
-        * Also tell the Runtime PM core to ignore children
-        * for this device since it is valid for us to suspend
-        * this I2C master driver even though the slave devices
-        * on the I2C bus may not be suspended.
-        *
-        * The state of the I2C hardware bus is unaffected by
-        * the Runtime PM state.
-        */
-       pm_suspend_ignore_children(&dev->dev, true);
        pm_runtime_enable(&dev->dev);
        pm_runtime_get_sync(&dev->dev);
 
diff --git a/drivers/i2c/busses/i2c-stm32.c b/drivers/i2c/busses/i2c-stm32.c
new file mode 100644 (file)
index 0000000..d75fbcb
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * i2c-stm32.c
+ *
+ * Copyright (C) M'boumba Cedric Madianga 2017
+ * Author: M'boumba Cedric Madianga <cedric.madianga@gmail.com>
+ *
+ * License terms:  GNU General Public License (GPL), version 2
+ */
+
+#include "i2c-stm32.h"
+
+/* Functions for DMA support */
+struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
+                                           dma_addr_t phy_addr,
+                                           u32 txdr_offset,
+                                           u32 rxdr_offset)
+{
+       struct stm32_i2c_dma *dma;
+       struct dma_slave_config dma_sconfig;
+       int ret;
+
+       dma = devm_kzalloc(dev, sizeof(*dma), GFP_KERNEL);
+       if (!dma)
+               return NULL;
+
+       /* Request and configure I2C TX dma channel */
+       dma->chan_tx = dma_request_slave_channel(dev, "tx");
+       if (!dma->chan_tx) {
+               dev_dbg(dev, "can't request DMA tx channel\n");
+               ret = -EINVAL;
+               goto fail_al;
+       }
+
+       memset(&dma_sconfig, 0, sizeof(dma_sconfig));
+       dma_sconfig.dst_addr = phy_addr + txdr_offset;
+       dma_sconfig.dst_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
+       dma_sconfig.dst_maxburst = 1;
+       dma_sconfig.direction = DMA_MEM_TO_DEV;
+       ret = dmaengine_slave_config(dma->chan_tx, &dma_sconfig);
+       if (ret < 0) {
+               dev_err(dev, "can't configure tx channel\n");
+               goto fail_tx;
+       }
+
+       /* Request and configure I2C RX dma channel */
+       dma->chan_rx = dma_request_slave_channel(dev, "rx");
+       if (!dma->chan_rx) {
+               dev_err(dev, "can't request DMA rx channel\n");
+               ret = -EINVAL;
+               goto fail_tx;
+       }
+
+       memset(&dma_sconfig, 0, sizeof(dma_sconfig));
+       dma_sconfig.src_addr = phy_addr + rxdr_offset;
+       dma_sconfig.src_addr_width = DMA_SLAVE_BUSWIDTH_1_BYTE;
+       dma_sconfig.src_maxburst = 1;
+       dma_sconfig.direction = DMA_DEV_TO_MEM;
+       ret = dmaengine_slave_config(dma->chan_rx, &dma_sconfig);
+       if (ret < 0) {
+               dev_err(dev, "can't configure rx channel\n");
+               goto fail_rx;
+       }
+
+       init_completion(&dma->dma_complete);
+
+       dev_info(dev, "using %s (tx) and %s (rx) for DMA transfers\n",
+                dma_chan_name(dma->chan_tx), dma_chan_name(dma->chan_rx));
+
+       return dma;
+
+fail_rx:
+       dma_release_channel(dma->chan_rx);
+fail_tx:
+       dma_release_channel(dma->chan_tx);
+fail_al:
+       devm_kfree(dev, dma);
+       dev_info(dev, "can't use DMA\n");
+
+       return NULL;
+}
+
+void stm32_i2c_dma_free(struct stm32_i2c_dma *dma)
+{
+       dma->dma_buf = 0;
+       dma->dma_len = 0;
+
+       dma_release_channel(dma->chan_tx);
+       dma->chan_tx = NULL;
+
+       dma_release_channel(dma->chan_rx);
+       dma->chan_rx = NULL;
+
+       dma->chan_using = NULL;
+}
+
+int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
+                           bool rd_wr, u32 len, u8 *buf,
+                           dma_async_tx_callback callback,
+                           void *dma_async_param)
+{
+       struct dma_async_tx_descriptor *txdesc;
+       struct device *chan_dev;
+       int ret;
+
+       if (rd_wr) {
+               dma->chan_using = dma->chan_rx;
+               dma->dma_transfer_dir = DMA_DEV_TO_MEM;
+               dma->dma_data_dir = DMA_FROM_DEVICE;
+       } else {
+               dma->chan_using = dma->chan_tx;
+               dma->dma_transfer_dir = DMA_MEM_TO_DEV;
+               dma->dma_data_dir = DMA_TO_DEVICE;
+       }
+
+       dma->dma_len = len;
+       chan_dev = dma->chan_using->device->dev;
+
+       dma->dma_buf = dma_map_single(chan_dev, buf, dma->dma_len,
+                                     dma->dma_data_dir);
+       if (dma_mapping_error(chan_dev, dma->dma_buf)) {
+               dev_err(dev, "DMA mapping failed\n");
+               return -EINVAL;
+       }
+
+       txdesc = dmaengine_prep_slave_single(dma->chan_using, dma->dma_buf,
+                                            dma->dma_len,
+                                            dma->dma_transfer_dir,
+                                            DMA_PREP_INTERRUPT);
+       if (!txdesc) {
+               dev_err(dev, "Not able to get desc for DMA xfer\n");
+               ret = -EINVAL;
+               goto err;
+       }
+
+       reinit_completion(&dma->dma_complete);
+
+       txdesc->callback = callback;
+       txdesc->callback_param = dma_async_param;
+       ret = dma_submit_error(dmaengine_submit(txdesc));
+       if (ret < 0) {
+               dev_err(dev, "DMA submit failed\n");
+               goto err;
+       }
+
+       dma_async_issue_pending(dma->chan_using);
+
+       return 0;
+
+err:
+       dma_unmap_single(chan_dev, dma->dma_buf, dma->dma_len,
+                        dma->dma_data_dir);
+       return ret;
+}
index d4f9cef251acf457f1dba743e141dadc7dc59d1b..868755f82f884be35c67aa30edcba5f16057f9f6 100644 (file)
 #ifndef _I2C_STM32_H
 #define _I2C_STM32_H
 
+#include <linux/dma-direction.h>
+#include <linux/dmaengine.h>
+#include <linux/dma-mapping.h>
+
 enum stm32_i2c_speed {
        STM32_I2C_SPEED_STANDARD, /* 100 kHz */
        STM32_I2C_SPEED_FAST, /* 400 kHz */
@@ -18,4 +22,37 @@ enum stm32_i2c_speed {
        STM32_I2C_SPEED_END,
 };
 
+/**
+ * struct stm32_i2c_dma - DMA specific data
+ * @chan_tx: dma channel for TX transfer
+ * @chan_rx: dma channel for RX transfer
+ * @chan_using: dma channel used for the current transfer (TX or RX)
+ * @dma_buf: dma buffer
+ * @dma_len: dma buffer len
+ * @dma_transfer_dir: dma transfer direction indicator
+ * @dma_data_dir: dma transfer mode indicator
+ * @dma_complete: dma transfer completion
+ */
+struct stm32_i2c_dma {
+       struct dma_chan *chan_tx;
+       struct dma_chan *chan_rx;
+       struct dma_chan *chan_using;
+       dma_addr_t dma_buf;
+       unsigned int dma_len;
+       enum dma_transfer_direction dma_transfer_dir;
+       enum dma_data_direction dma_data_dir;
+       struct completion dma_complete;
+};
+
+struct stm32_i2c_dma *stm32_i2c_dma_request(struct device *dev,
+                                           dma_addr_t phy_addr,
+                                           u32 txdr_offset, u32 rxdr_offset);
+
+void stm32_i2c_dma_free(struct stm32_i2c_dma *dma);
+
+int stm32_i2c_prep_dma_xfer(struct device *dev, struct stm32_i2c_dma *dma,
+                           bool rd_wr, u32 len, u8 *buf,
+                           dma_async_tx_callback callback,
+                           void *dma_async_param);
+
 #endif /* _I2C_STM32_H */
index f273e28c39db2ec5f667a6b4fd27d1377f8e31a4..62d023e737d9c2f60a26ea4174e78154dc10e877 100644 (file)
@@ -35,6 +35,9 @@
 /* STM32F7 I2C registers */
 #define STM32F7_I2C_CR1                                0x00
 #define STM32F7_I2C_CR2                                0x04
+#define STM32F7_I2C_OAR1                       0x08
+#define STM32F7_I2C_OAR2                       0x0C
+#define STM32F7_I2C_PECR                       0x20
 #define STM32F7_I2C_TIMINGR                    0x10
 #define STM32F7_I2C_ISR                                0x18
 #define STM32F7_I2C_ICR                                0x1C
 #define STM32F7_I2C_TXDR                       0x28
 
 /* STM32F7 I2C control 1 */
+#define STM32F7_I2C_CR1_PECEN                  BIT(23)
+#define STM32F7_I2C_CR1_SBC                    BIT(16)
+#define STM32F7_I2C_CR1_RXDMAEN                        BIT(15)
+#define STM32F7_I2C_CR1_TXDMAEN                        BIT(14)
 #define STM32F7_I2C_CR1_ANFOFF                 BIT(12)
 #define STM32F7_I2C_CR1_ERRIE                  BIT(7)
 #define STM32F7_I2C_CR1_TCIE                   BIT(6)
                                                | STM32F7_I2C_CR1_NACKIE \
                                                | STM32F7_I2C_CR1_RXIE \
                                                | STM32F7_I2C_CR1_TXIE)
+#define STM32F7_I2C_XFER_IRQ_MASK              (STM32F7_I2C_CR1_TCIE \
+                                               | STM32F7_I2C_CR1_STOPIE \
+                                               | STM32F7_I2C_CR1_NACKIE \
+                                               | STM32F7_I2C_CR1_RXIE \
+                                               | STM32F7_I2C_CR1_TXIE)
 
 /* STM32F7 I2C control 2 */
+#define STM32F7_I2C_CR2_PECBYTE                        BIT(26)
 #define STM32F7_I2C_CR2_RELOAD                 BIT(24)
 #define STM32F7_I2C_CR2_NBYTES_MASK            GENMASK(23, 16)
 #define STM32F7_I2C_CR2_NBYTES(n)              (((n) & 0xff) << 16)
 #define STM32F7_I2C_CR2_NACK                   BIT(15)
 #define STM32F7_I2C_CR2_STOP                   BIT(14)
 #define STM32F7_I2C_CR2_START                  BIT(13)
+#define STM32F7_I2C_CR2_HEAD10R                        BIT(12)
+#define STM32F7_I2C_CR2_ADD10                  BIT(11)
 #define STM32F7_I2C_CR2_RD_WRN                 BIT(10)
+#define STM32F7_I2C_CR2_SADD10_MASK            GENMASK(9, 0)
+#define STM32F7_I2C_CR2_SADD10(n)              (((n) & \
+                                               STM32F7_I2C_CR2_SADD10_MASK))
 #define STM32F7_I2C_CR2_SADD7_MASK             GENMASK(7, 1)
 #define STM32F7_I2C_CR2_SADD7(n)               (((n) & 0x7f) << 1)
 
+/* STM32F7 I2C Own Address 1 */
+#define STM32F7_I2C_OAR1_OA1EN                 BIT(15)
+#define STM32F7_I2C_OAR1_OA1MODE               BIT(10)
+#define STM32F7_I2C_OAR1_OA1_10_MASK           GENMASK(9, 0)
+#define STM32F7_I2C_OAR1_OA1_10(n)             (((n) & \
+                                               STM32F7_I2C_OAR1_OA1_10_MASK))
+#define STM32F7_I2C_OAR1_OA1_7_MASK            GENMASK(7, 1)
+#define STM32F7_I2C_OAR1_OA1_7(n)              (((n) & 0x7f) << 1)
+#define STM32F7_I2C_OAR1_MASK                  (STM32F7_I2C_OAR1_OA1_7_MASK \
+                                               | STM32F7_I2C_OAR1_OA1_10_MASK \
+                                               | STM32F7_I2C_OAR1_OA1EN \
+                                               | STM32F7_I2C_OAR1_OA1MODE)
+
+/* STM32F7 I2C Own Address 2 */
+#define STM32F7_I2C_OAR2_OA2EN                 BIT(15)
+#define STM32F7_I2C_OAR2_OA2MSK_MASK           GENMASK(10, 8)
+#define STM32F7_I2C_OAR2_OA2MSK(n)             (((n) & 0x7) << 8)
+#define STM32F7_I2C_OAR2_OA2_7_MASK            GENMASK(7, 1)
+#define STM32F7_I2C_OAR2_OA2_7(n)              (((n) & 0x7f) << 1)
+#define STM32F7_I2C_OAR2_MASK                  (STM32F7_I2C_OAR2_OA2MSK_MASK \
+                                               | STM32F7_I2C_OAR2_OA2_7_MASK \
+                                               | STM32F7_I2C_OAR2_OA2EN)
+
 /* STM32F7 I2C Interrupt Status */
+#define STM32F7_I2C_ISR_ADDCODE_MASK           GENMASK(23, 17)
+#define STM32F7_I2C_ISR_ADDCODE_GET(n) \
+                               (((n) & STM32F7_I2C_ISR_ADDCODE_MASK) >> 17)
+#define STM32F7_I2C_ISR_DIR                    BIT(16)
 #define STM32F7_I2C_ISR_BUSY                   BIT(15)
+#define STM32F7_I2C_ISR_PECERR                 BIT(11)
 #define STM32F7_I2C_ISR_ARLO                   BIT(9)
 #define STM32F7_I2C_ISR_BERR                   BIT(8)
 #define STM32F7_I2C_ISR_TCR                    BIT(7)
 #define STM32F7_I2C_ISR_TC                     BIT(6)
 #define STM32F7_I2C_ISR_STOPF                  BIT(5)
 #define STM32F7_I2C_ISR_NACKF                  BIT(4)
+#define STM32F7_I2C_ISR_ADDR                   BIT(3)
 #define STM32F7_I2C_ISR_RXNE                   BIT(2)
 #define STM32F7_I2C_ISR_TXIS                   BIT(1)
+#define STM32F7_I2C_ISR_TXE                    BIT(0)
 
 /* STM32F7 I2C Interrupt Clear */
+#define STM32F7_I2C_ICR_PECCF                  BIT(11)
 #define STM32F7_I2C_ICR_ARLOCF                 BIT(9)
 #define STM32F7_I2C_ICR_BERRCF                 BIT(8)
 #define STM32F7_I2C_ICR_STOPCF                 BIT(5)
 #define STM32F7_I2C_ICR_NACKCF                 BIT(4)
+#define STM32F7_I2C_ICR_ADDRCF                 BIT(3)
 
 /* STM32F7 I2C Timing */
 #define STM32F7_I2C_TIMINGR_PRESC(n)           (((n) & 0xf) << 28)
 #define STM32F7_I2C_TIMINGR_SCLL(n)            ((n) & 0xff)
 
 #define STM32F7_I2C_MAX_LEN                    0xff
+#define STM32F7_I2C_DMA_LEN_MIN                        0x16
+#define STM32F7_I2C_MAX_SLAVE                  0x2
 
 #define STM32F7_I2C_DNF_DEFAULT                        0
 #define STM32F7_I2C_DNF_MAX                    16
@@ -159,11 +211,12 @@ struct stm32f7_i2c_setup {
 
 /**
  * struct stm32f7_i2c_timings - private I2C output parameters
- * @prec: Prescaler value
+ * @node: List entry
+ * @presc: Prescaler value
  * @scldel: Data setup time
  * @sdadel: Data hold time
  * @sclh: SCL high period (master mode)
- * @sclh: SCL low period (master mode)
+ * @scll: SCL low period (master mode)
  */
 struct stm32f7_i2c_timings {
        struct list_head node;
@@ -176,18 +229,30 @@ struct stm32f7_i2c_timings {
 
 /**
  * struct stm32f7_i2c_msg - client specific data
- * @addr: 8-bit slave addr, including r/w bit
+ * @addr: 8-bit or 10-bit slave addr, including r/w bit
  * @count: number of bytes to be transferred
  * @buf: data buffer
  * @result: result of the transfer
  * @stop: last I2C msg to be sent, i.e. STOP to be generated
+ * @smbus: boolean to know if the I2C IP is used in SMBus mode
+ * @size: type of SMBus protocol
+ * @read_write: direction of SMBus protocol
+ * SMBus block read and SMBus block write - block read process call protocols
+ * @smbus_buf: buffer to be used for SMBus protocol transfer. It will
+ * contain a maximum of 32 bytes of data + byte command + byte count + PEC
+ * This buffer has to be 32-bit aligned to be compliant with memory address
+ * register in DMA mode.
  */
 struct stm32f7_i2c_msg {
-       u8 addr;
+       u16 addr;
        u32 count;
        u8 *buf;
        int result;
        bool stop;
+       bool smbus;
+       int size;
+       char read_write;
+       u8 smbus_buf[I2C_SMBUS_BLOCK_MAX + 3] __aligned(4);
 };
 
 /**
@@ -204,6 +269,13 @@ struct stm32f7_i2c_msg {
  * @f7_msg: customized i2c msg for driver usage
  * @setup: I2C timing input setup
  * @timing: I2C computed timings
+ * @slave: list of slave devices registered on the I2C bus
+ * @slave_running: slave device currently used
+ * @slave_dir: transfer direction for the current slave device
+ * @master_mode: boolean to know in which mode the I2C is running (master or
+ * slave)
+ * @dma: dma data
+ * @use_dma: boolean to know if dma is used in the current transfer
  */
 struct stm32f7_i2c_dev {
        struct i2c_adapter adap;
@@ -218,6 +290,12 @@ struct stm32f7_i2c_dev {
        struct stm32f7_i2c_msg f7_msg;
        struct stm32f7_i2c_setup setup;
        struct stm32f7_i2c_timings timing;
+       struct i2c_client *slave[STM32F7_I2C_MAX_SLAVE];
+       struct i2c_client *slave_running;
+       u32 slave_dir;
+       bool master_mode;
+       struct stm32_i2c_dma *dma;
+       bool use_dma;
 };
 
 /**
@@ -283,6 +361,11 @@ static inline void stm32f7_i2c_clr_bits(void __iomem *reg, u32 mask)
        writel_relaxed(readl_relaxed(reg) & ~mask, reg);
 }
 
+static void stm32f7_i2c_disable_irq(struct stm32f7_i2c_dev *i2c_dev, u32 mask)
+{
+       stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1, mask);
+}
+
 static int stm32f7_i2c_compute_timing(struct stm32f7_i2c_dev *i2c_dev,
                                      struct stm32f7_i2c_setup *setup,
                                      struct stm32f7_i2c_timings *output)
@@ -524,6 +607,25 @@ static int stm32f7_i2c_setup_timing(struct stm32f7_i2c_dev *i2c_dev,
        return 0;
 }
 
+static void stm32f7_i2c_disable_dma_req(struct stm32f7_i2c_dev *i2c_dev)
+{
+       void __iomem *base = i2c_dev->base;
+       u32 mask = STM32F7_I2C_CR1_RXDMAEN | STM32F7_I2C_CR1_TXDMAEN;
+
+       stm32f7_i2c_clr_bits(base + STM32F7_I2C_CR1, mask);
+}
+
+static void stm32f7_i2c_dma_callback(void *arg)
+{
+       struct stm32f7_i2c_dev *i2c_dev = (struct stm32f7_i2c_dev *)arg;
+       struct stm32_i2c_dma *dma = i2c_dev->dma;
+       struct device *dev = dma->chan_using->device->dev;
+
+       stm32f7_i2c_disable_dma_req(i2c_dev);
+       dma_unmap_single(dev, dma->dma_buf, dma->dma_len, dma->dma_data_dir);
+       complete(&dma->dma_complete);
+}
+
 static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev)
 {
        struct stm32f7_i2c_timings *t = &i2c_dev->timing;
@@ -567,6 +669,9 @@ static void stm32f7_i2c_read_rx_data(struct stm32f7_i2c_dev *i2c_dev)
        if (f7_msg->count) {
                *f7_msg->buf++ = readb_relaxed(base + STM32F7_I2C_RXDR);
                f7_msg->count--;
+       } else {
+               /* Flush RX buffer has no data is expected */
+               readb_relaxed(base + STM32F7_I2C_RXDR);
        }
 }
 
@@ -575,6 +680,9 @@ static void stm32f7_i2c_reload(struct stm32f7_i2c_dev *i2c_dev)
        struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
        u32 cr2;
 
+       if (i2c_dev->use_dma)
+               f7_msg->count -= STM32F7_I2C_MAX_LEN;
+
        cr2 = readl_relaxed(i2c_dev->base + STM32F7_I2C_CR2);
 
        cr2 &= ~STM32F7_I2C_CR2_NBYTES_MASK;
@@ -588,6 +696,43 @@ static void stm32f7_i2c_reload(struct stm32f7_i2c_dev *i2c_dev)
        writel_relaxed(cr2, i2c_dev->base + STM32F7_I2C_CR2);
 }
 
+static void stm32f7_i2c_smbus_reload(struct stm32f7_i2c_dev *i2c_dev)
+{
+       struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
+       u32 cr2;
+       u8 *val;
+
+       /*
+        * For I2C_SMBUS_BLOCK_DATA && I2C_SMBUS_BLOCK_PROC_CALL, the first
+        * data received inform us how many data will follow.
+        */
+       stm32f7_i2c_read_rx_data(i2c_dev);
+
+       /*
+        * Update NBYTES with the value read to continue the transfer
+        */
+       val = f7_msg->buf - sizeof(u8);
+       f7_msg->count = *val;
+       cr2 = readl_relaxed(i2c_dev->base + STM32F7_I2C_CR2);
+       cr2 &= ~(STM32F7_I2C_CR2_NBYTES_MASK | STM32F7_I2C_CR2_RELOAD);
+       cr2 |= STM32F7_I2C_CR2_NBYTES(f7_msg->count);
+       writel_relaxed(cr2, i2c_dev->base + STM32F7_I2C_CR2);
+}
+
+static int stm32f7_i2c_release_bus(struct i2c_adapter *i2c_adap)
+{
+       struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap);
+
+       dev_info(i2c_dev->dev, "Trying to recover bus\n");
+
+       stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1,
+                            STM32F7_I2C_CR1_PE);
+
+       stm32f7_i2c_hw_config(i2c_dev);
+
+       return 0;
+}
+
 static int stm32f7_i2c_wait_free_bus(struct stm32f7_i2c_dev *i2c_dev)
 {
        u32 status;
@@ -597,12 +742,18 @@ static int stm32f7_i2c_wait_free_bus(struct stm32f7_i2c_dev *i2c_dev)
                                         status,
                                         !(status & STM32F7_I2C_ISR_BUSY),
                                         10, 1000);
+       if (!ret)
+               return 0;
+
+       dev_info(i2c_dev->dev, "bus busy\n");
+
+       ret = stm32f7_i2c_release_bus(&i2c_dev->adap);
        if (ret) {
-               dev_dbg(i2c_dev->dev, "bus busy\n");
-               ret = -EBUSY;
+               dev_err(i2c_dev->dev, "Failed to recover the bus (%d)\n", ret);
+               return ret;
        }
 
-       return ret;
+       return -EBUSY;
 }
 
 static void stm32f7_i2c_xfer_msg(struct stm32f7_i2c_dev *i2c_dev,
@@ -611,6 +762,7 @@ static void stm32f7_i2c_xfer_msg(struct stm32f7_i2c_dev *i2c_dev,
        struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
        void __iomem *base = i2c_dev->base;
        u32 cr1, cr2;
+       int ret;
 
        f7_msg->addr = msg->addr;
        f7_msg->buf = msg->buf;
@@ -629,8 +781,15 @@ static void stm32f7_i2c_xfer_msg(struct stm32f7_i2c_dev *i2c_dev,
                cr2 |= STM32F7_I2C_CR2_RD_WRN;
 
        /* Set slave address */
-       cr2 &= ~STM32F7_I2C_CR2_SADD7_MASK;
-       cr2 |= STM32F7_I2C_CR2_SADD7(f7_msg->addr);
+       cr2 &= ~(STM32F7_I2C_CR2_HEAD10R | STM32F7_I2C_CR2_ADD10);
+       if (msg->flags & I2C_M_TEN) {
+               cr2 &= ~STM32F7_I2C_CR2_SADD10_MASK;
+               cr2 |= STM32F7_I2C_CR2_SADD10(f7_msg->addr);
+               cr2 |= STM32F7_I2C_CR2_ADD10;
+       } else {
+               cr2 &= ~STM32F7_I2C_CR2_SADD7_MASK;
+               cr2 |= STM32F7_I2C_CR2_SADD7(f7_msg->addr);
+       }
 
        /* Set nb bytes to transfer and reload if needed */
        cr2 &= ~(STM32F7_I2C_CR2_NBYTES_MASK | STM32F7_I2C_CR2_RELOAD);
@@ -645,16 +804,286 @@ static void stm32f7_i2c_xfer_msg(struct stm32f7_i2c_dev *i2c_dev,
        cr1 |= STM32F7_I2C_CR1_ERRIE | STM32F7_I2C_CR1_TCIE |
                STM32F7_I2C_CR1_STOPIE | STM32F7_I2C_CR1_NACKIE;
 
-       /* Clear TX/RX interrupt */
+       /* Clear DMA req and TX/RX interrupt */
+       cr1 &= ~(STM32F7_I2C_CR1_RXIE | STM32F7_I2C_CR1_TXIE |
+                       STM32F7_I2C_CR1_RXDMAEN | STM32F7_I2C_CR1_TXDMAEN);
+
+       /* Configure DMA or enable RX/TX interrupt */
+       i2c_dev->use_dma = false;
+       if (i2c_dev->dma && f7_msg->count >= STM32F7_I2C_DMA_LEN_MIN) {
+               ret = stm32_i2c_prep_dma_xfer(i2c_dev->dev, i2c_dev->dma,
+                                             msg->flags & I2C_M_RD,
+                                             f7_msg->count, f7_msg->buf,
+                                             stm32f7_i2c_dma_callback,
+                                             i2c_dev);
+               if (!ret)
+                       i2c_dev->use_dma = true;
+               else
+                       dev_warn(i2c_dev->dev, "can't use DMA\n");
+       }
+
+       if (!i2c_dev->use_dma) {
+               if (msg->flags & I2C_M_RD)
+                       cr1 |= STM32F7_I2C_CR1_RXIE;
+               else
+                       cr1 |= STM32F7_I2C_CR1_TXIE;
+       } else {
+               if (msg->flags & I2C_M_RD)
+                       cr1 |= STM32F7_I2C_CR1_RXDMAEN;
+               else
+                       cr1 |= STM32F7_I2C_CR1_TXDMAEN;
+       }
+
+       /* Configure Start/Repeated Start */
+       cr2 |= STM32F7_I2C_CR2_START;
+
+       i2c_dev->master_mode = true;
+
+       /* Write configurations registers */
+       writel_relaxed(cr1, base + STM32F7_I2C_CR1);
+       writel_relaxed(cr2, base + STM32F7_I2C_CR2);
+}
+
+static int stm32f7_i2c_smbus_xfer_msg(struct stm32f7_i2c_dev *i2c_dev,
+                                     unsigned short flags, u8 command,
+                                     union i2c_smbus_data *data)
+{
+       struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
+       struct device *dev = i2c_dev->dev;
+       void __iomem *base = i2c_dev->base;
+       u32 cr1, cr2;
+       int i, ret;
+
+       f7_msg->result = 0;
+       reinit_completion(&i2c_dev->complete);
+
+       cr2 = readl_relaxed(base + STM32F7_I2C_CR2);
+       cr1 = readl_relaxed(base + STM32F7_I2C_CR1);
+
+       /* Set transfer direction */
+       cr2 &= ~STM32F7_I2C_CR2_RD_WRN;
+       if (f7_msg->read_write)
+               cr2 |= STM32F7_I2C_CR2_RD_WRN;
+
+       /* Set slave address */
+       cr2 &= ~(STM32F7_I2C_CR2_ADD10 | STM32F7_I2C_CR2_SADD7_MASK);
+       cr2 |= STM32F7_I2C_CR2_SADD7(f7_msg->addr);
+
+       f7_msg->smbus_buf[0] = command;
+       switch (f7_msg->size) {
+       case I2C_SMBUS_QUICK:
+               f7_msg->stop = true;
+               f7_msg->count = 0;
+               break;
+       case I2C_SMBUS_BYTE:
+               f7_msg->stop = true;
+               f7_msg->count = 1;
+               break;
+       case I2C_SMBUS_BYTE_DATA:
+               if (f7_msg->read_write) {
+                       f7_msg->stop = false;
+                       f7_msg->count = 1;
+                       cr2 &= ~STM32F7_I2C_CR2_RD_WRN;
+               } else {
+                       f7_msg->stop = true;
+                       f7_msg->count = 2;
+                       f7_msg->smbus_buf[1] = data->byte;
+               }
+               break;
+       case I2C_SMBUS_WORD_DATA:
+               if (f7_msg->read_write) {
+                       f7_msg->stop = false;
+                       f7_msg->count = 1;
+                       cr2 &= ~STM32F7_I2C_CR2_RD_WRN;
+               } else {
+                       f7_msg->stop = true;
+                       f7_msg->count = 3;
+                       f7_msg->smbus_buf[1] = data->word & 0xff;
+                       f7_msg->smbus_buf[2] = data->word >> 8;
+               }
+               break;
+       case I2C_SMBUS_BLOCK_DATA:
+               if (f7_msg->read_write) {
+                       f7_msg->stop = false;
+                       f7_msg->count = 1;
+                       cr2 &= ~STM32F7_I2C_CR2_RD_WRN;
+               } else {
+                       f7_msg->stop = true;
+                       if (data->block[0] > I2C_SMBUS_BLOCK_MAX ||
+                           !data->block[0]) {
+                               dev_err(dev, "Invalid block write size %d\n",
+                                       data->block[0]);
+                               return -EINVAL;
+                       }
+                       f7_msg->count = data->block[0] + 2;
+                       for (i = 1; i < f7_msg->count; i++)
+                               f7_msg->smbus_buf[i] = data->block[i - 1];
+               }
+               break;
+       case I2C_SMBUS_PROC_CALL:
+               f7_msg->stop = false;
+               f7_msg->count = 3;
+               f7_msg->smbus_buf[1] = data->word & 0xff;
+               f7_msg->smbus_buf[2] = data->word >> 8;
+               cr2 &= ~STM32F7_I2C_CR2_RD_WRN;
+               f7_msg->read_write = I2C_SMBUS_READ;
+               break;
+       case I2C_SMBUS_BLOCK_PROC_CALL:
+               f7_msg->stop = false;
+               if (data->block[0] > I2C_SMBUS_BLOCK_MAX - 1) {
+                       dev_err(dev, "Invalid block write size %d\n",
+                               data->block[0]);
+                       return -EINVAL;
+               }
+               f7_msg->count = data->block[0] + 2;
+               for (i = 1; i < f7_msg->count; i++)
+                       f7_msg->smbus_buf[i] = data->block[i - 1];
+               cr2 &= ~STM32F7_I2C_CR2_RD_WRN;
+               f7_msg->read_write = I2C_SMBUS_READ;
+               break;
+       default:
+               dev_err(dev, "Unsupported smbus protocol %d\n", f7_msg->size);
+               return -EOPNOTSUPP;
+       }
+
+       f7_msg->buf = f7_msg->smbus_buf;
+
+       /* Configure PEC */
+       if ((flags & I2C_CLIENT_PEC) && f7_msg->size != I2C_SMBUS_QUICK) {
+               cr1 |= STM32F7_I2C_CR1_PECEN;
+               cr2 |= STM32F7_I2C_CR2_PECBYTE;
+               if (!f7_msg->read_write)
+                       f7_msg->count++;
+       } else {
+               cr1 &= ~STM32F7_I2C_CR1_PECEN;
+               cr2 &= ~STM32F7_I2C_CR2_PECBYTE;
+       }
+
+       /* Set number of bytes to be transferred */
+       cr2 &= ~(STM32F7_I2C_CR2_NBYTES_MASK | STM32F7_I2C_CR2_RELOAD);
+       cr2 |= STM32F7_I2C_CR2_NBYTES(f7_msg->count);
+
+       /* Enable NACK, STOP, error and transfer complete interrupts */
+       cr1 |= STM32F7_I2C_CR1_ERRIE | STM32F7_I2C_CR1_TCIE |
+               STM32F7_I2C_CR1_STOPIE | STM32F7_I2C_CR1_NACKIE;
+
+       /* Clear DMA req and TX/RX interrupt */
+       cr1 &= ~(STM32F7_I2C_CR1_RXIE | STM32F7_I2C_CR1_TXIE |
+                       STM32F7_I2C_CR1_RXDMAEN | STM32F7_I2C_CR1_TXDMAEN);
+
+       /* Configure DMA or enable RX/TX interrupt */
+       i2c_dev->use_dma = false;
+       if (i2c_dev->dma && f7_msg->count >= STM32F7_I2C_DMA_LEN_MIN) {
+               ret = stm32_i2c_prep_dma_xfer(i2c_dev->dev, i2c_dev->dma,
+                                             cr2 & STM32F7_I2C_CR2_RD_WRN,
+                                             f7_msg->count, f7_msg->buf,
+                                             stm32f7_i2c_dma_callback,
+                                             i2c_dev);
+               if (!ret)
+                       i2c_dev->use_dma = true;
+               else
+                       dev_warn(i2c_dev->dev, "can't use DMA\n");
+       }
+
+       if (!i2c_dev->use_dma) {
+               if (cr2 & STM32F7_I2C_CR2_RD_WRN)
+                       cr1 |= STM32F7_I2C_CR1_RXIE;
+               else
+                       cr1 |= STM32F7_I2C_CR1_TXIE;
+       } else {
+               if (cr2 & STM32F7_I2C_CR2_RD_WRN)
+                       cr1 |= STM32F7_I2C_CR1_RXDMAEN;
+               else
+                       cr1 |= STM32F7_I2C_CR1_TXDMAEN;
+       }
+
+       /* Set Start bit */
+       cr2 |= STM32F7_I2C_CR2_START;
+
+       i2c_dev->master_mode = true;
+
+       /* Write configurations registers */
+       writel_relaxed(cr1, base + STM32F7_I2C_CR1);
+       writel_relaxed(cr2, base + STM32F7_I2C_CR2);
+
+       return 0;
+}
+
+static void stm32f7_i2c_smbus_rep_start(struct stm32f7_i2c_dev *i2c_dev)
+{
+       struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
+       void __iomem *base = i2c_dev->base;
+       u32 cr1, cr2;
+       int ret;
+
+       cr2 = readl_relaxed(base + STM32F7_I2C_CR2);
+       cr1 = readl_relaxed(base + STM32F7_I2C_CR1);
+
+       /* Set transfer direction */
+       cr2 |= STM32F7_I2C_CR2_RD_WRN;
+
+       switch (f7_msg->size) {
+       case I2C_SMBUS_BYTE_DATA:
+               f7_msg->count = 1;
+               break;
+       case I2C_SMBUS_WORD_DATA:
+       case I2C_SMBUS_PROC_CALL:
+               f7_msg->count = 2;
+               break;
+       case I2C_SMBUS_BLOCK_DATA:
+       case I2C_SMBUS_BLOCK_PROC_CALL:
+               f7_msg->count = 1;
+               cr2 |= STM32F7_I2C_CR2_RELOAD;
+               break;
+       }
+
+       f7_msg->buf = f7_msg->smbus_buf;
+       f7_msg->stop = true;
+
+       /* Add one byte for PEC if needed */
+       if (cr1 & STM32F7_I2C_CR1_PECEN)
+               f7_msg->count++;
+
+       /* Set number of bytes to be transferred */
+       cr2 &= ~(STM32F7_I2C_CR2_NBYTES_MASK);
+       cr2 |= STM32F7_I2C_CR2_NBYTES(f7_msg->count);
+
+       /*
+        * Configure RX/TX interrupt:
+        */
        cr1 &= ~(STM32F7_I2C_CR1_RXIE | STM32F7_I2C_CR1_TXIE);
+       cr1 |= STM32F7_I2C_CR1_RXIE;
 
-       /* Enable RX/TX interrupt according to msg direction */
-       if (msg->flags & I2C_M_RD)
+       /*
+        * Configure DMA or enable RX/TX interrupt:
+        * For I2C_SMBUS_BLOCK_DATA and I2C_SMBUS_BLOCK_PROC_CALL we don't use
+        * dma as we don't know in advance how many data will be received
+        */
+       cr1 &= ~(STM32F7_I2C_CR1_RXIE | STM32F7_I2C_CR1_TXIE |
+                STM32F7_I2C_CR1_RXDMAEN | STM32F7_I2C_CR1_TXDMAEN);
+
+       i2c_dev->use_dma = false;
+       if (i2c_dev->dma && f7_msg->count >= STM32F7_I2C_DMA_LEN_MIN &&
+           f7_msg->size != I2C_SMBUS_BLOCK_DATA &&
+           f7_msg->size != I2C_SMBUS_BLOCK_PROC_CALL) {
+               ret = stm32_i2c_prep_dma_xfer(i2c_dev->dev, i2c_dev->dma,
+                                             cr2 & STM32F7_I2C_CR2_RD_WRN,
+                                             f7_msg->count, f7_msg->buf,
+                                             stm32f7_i2c_dma_callback,
+                                             i2c_dev);
+
+               if (!ret)
+                       i2c_dev->use_dma = true;
+               else
+                       dev_warn(i2c_dev->dev, "can't use DMA\n");
+       }
+
+       if (!i2c_dev->use_dma)
                cr1 |= STM32F7_I2C_CR1_RXIE;
        else
-               cr1 |= STM32F7_I2C_CR1_TXIE;
+               cr1 |= STM32F7_I2C_CR1_RXDMAEN;
 
-       /* Configure Start/Repeated Start */
+       /* Configure Repeated Start */
        cr2 |= STM32F7_I2C_CR2_START;
 
        /* Write configurations registers */
@@ -662,9 +1091,278 @@ static void stm32f7_i2c_xfer_msg(struct stm32f7_i2c_dev *i2c_dev,
        writel_relaxed(cr2, base + STM32F7_I2C_CR2);
 }
 
-static void stm32f7_i2c_disable_irq(struct stm32f7_i2c_dev *i2c_dev, u32 mask)
+static int stm32f7_i2c_smbus_check_pec(struct stm32f7_i2c_dev *i2c_dev)
 {
-       stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1, mask);
+       struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
+       u8 count, internal_pec, received_pec;
+
+       internal_pec = readl_relaxed(i2c_dev->base + STM32F7_I2C_PECR);
+
+       switch (f7_msg->size) {
+       case I2C_SMBUS_BYTE:
+       case I2C_SMBUS_BYTE_DATA:
+               received_pec = f7_msg->smbus_buf[1];
+               break;
+       case I2C_SMBUS_WORD_DATA:
+       case I2C_SMBUS_PROC_CALL:
+               received_pec = f7_msg->smbus_buf[2];
+               break;
+       case I2C_SMBUS_BLOCK_DATA:
+       case I2C_SMBUS_BLOCK_PROC_CALL:
+               count = f7_msg->smbus_buf[0];
+               received_pec = f7_msg->smbus_buf[count];
+               break;
+       default:
+               dev_err(i2c_dev->dev, "Unsupported smbus protocol for PEC\n");
+               return -EINVAL;
+       }
+
+       if (internal_pec != received_pec) {
+               dev_err(i2c_dev->dev, "Bad PEC 0x%02x vs. 0x%02x\n",
+                       internal_pec, received_pec);
+               return -EBADMSG;
+       }
+
+       return 0;
+}
+
+static bool stm32f7_i2c_is_addr_match(struct i2c_client *slave, u32 addcode)
+{
+       u32 addr;
+
+       if (!slave)
+               return false;
+
+       if (slave->flags & I2C_CLIENT_TEN) {
+               /*
+                * For 10-bit addr, addcode = 11110XY with
+                * X = Bit 9 of slave address
+                * Y = Bit 8 of slave address
+                */
+               addr = slave->addr >> 8;
+               addr |= 0x78;
+               if (addr == addcode)
+                       return true;
+       } else {
+               addr = slave->addr & 0x7f;
+               if (addr == addcode)
+                       return true;
+       }
+
+       return false;
+}
+
+static void stm32f7_i2c_slave_start(struct stm32f7_i2c_dev *i2c_dev)
+{
+       struct i2c_client *slave = i2c_dev->slave_running;
+       void __iomem *base = i2c_dev->base;
+       u32 mask;
+       u8 value = 0;
+
+       if (i2c_dev->slave_dir) {
+               /* Notify i2c slave that new read transfer is starting */
+               i2c_slave_event(slave, I2C_SLAVE_READ_REQUESTED, &value);
+
+               /*
+                * Disable slave TX config in case of I2C combined message
+                * (I2C Write followed by I2C Read)
+                */
+               mask = STM32F7_I2C_CR2_RELOAD;
+               stm32f7_i2c_clr_bits(base + STM32F7_I2C_CR2, mask);
+               mask = STM32F7_I2C_CR1_SBC | STM32F7_I2C_CR1_RXIE |
+                      STM32F7_I2C_CR1_TCIE;
+               stm32f7_i2c_clr_bits(base + STM32F7_I2C_CR1, mask);
+
+               /* Enable TX empty, STOP, NACK interrupts */
+               mask =  STM32F7_I2C_CR1_STOPIE | STM32F7_I2C_CR1_NACKIE |
+                       STM32F7_I2C_CR1_TXIE;
+               stm32f7_i2c_set_bits(base + STM32F7_I2C_CR1, mask);
+
+       } else {
+               /* Notify i2c slave that new write transfer is starting */
+               i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value);
+
+               /* Set reload mode to be able to ACK/NACK each received byte */
+               mask = STM32F7_I2C_CR2_RELOAD;
+               stm32f7_i2c_set_bits(base + STM32F7_I2C_CR2, mask);
+
+               /*
+                * Set STOP, NACK, RX empty and transfer complete interrupts.*
+                * Set Slave Byte Control to be able to ACK/NACK each data
+                * byte received
+                */
+               mask =  STM32F7_I2C_CR1_STOPIE | STM32F7_I2C_CR1_NACKIE |
+                       STM32F7_I2C_CR1_SBC | STM32F7_I2C_CR1_RXIE |
+                       STM32F7_I2C_CR1_TCIE;
+               stm32f7_i2c_set_bits(base + STM32F7_I2C_CR1, mask);
+       }
+}
+
+static void stm32f7_i2c_slave_addr(struct stm32f7_i2c_dev *i2c_dev)
+{
+       void __iomem *base = i2c_dev->base;
+       u32 isr, addcode, dir, mask;
+       int i;
+
+       isr = readl_relaxed(i2c_dev->base + STM32F7_I2C_ISR);
+       addcode = STM32F7_I2C_ISR_ADDCODE_GET(isr);
+       dir = isr & STM32F7_I2C_ISR_DIR;
+
+       for (i = 0; i < STM32F7_I2C_MAX_SLAVE; i++) {
+               if (stm32f7_i2c_is_addr_match(i2c_dev->slave[i], addcode)) {
+                       i2c_dev->slave_running = i2c_dev->slave[i];
+                       i2c_dev->slave_dir = dir;
+
+                       /* Start I2C slave processing */
+                       stm32f7_i2c_slave_start(i2c_dev);
+
+                       /* Clear ADDR flag */
+                       mask = STM32F7_I2C_ICR_ADDRCF;
+                       writel_relaxed(mask, base + STM32F7_I2C_ICR);
+                       break;
+               }
+       }
+}
+
+static int stm32f7_i2c_get_slave_id(struct stm32f7_i2c_dev *i2c_dev,
+                                   struct i2c_client *slave, int *id)
+{
+       int i;
+
+       for (i = 0; i < STM32F7_I2C_MAX_SLAVE; i++) {
+               if (i2c_dev->slave[i] == slave) {
+                       *id = i;
+                       return 0;
+               }
+       }
+
+       dev_err(i2c_dev->dev, "Slave 0x%x not registered\n", slave->addr);
+
+       return -ENODEV;
+}
+
+static int stm32f7_i2c_get_free_slave_id(struct stm32f7_i2c_dev *i2c_dev,
+                                        struct i2c_client *slave, int *id)
+{
+       struct device *dev = i2c_dev->dev;
+       int i;
+
+       /*
+        * slave[0] supports 7-bit and 10-bit slave address
+        * slave[1] supports 7-bit slave address only
+        */
+       for (i = 0; i < STM32F7_I2C_MAX_SLAVE; i++) {
+               if (i == 1 && (slave->flags & I2C_CLIENT_PEC))
+                       continue;
+               if (!i2c_dev->slave[i]) {
+                       *id = i;
+                       return 0;
+               }
+       }
+
+       dev_err(dev, "Slave 0x%x could not be registered\n", slave->addr);
+
+       return -EINVAL;
+}
+
+static bool stm32f7_i2c_is_slave_registered(struct stm32f7_i2c_dev *i2c_dev)
+{
+       int i;
+
+       for (i = 0; i < STM32F7_I2C_MAX_SLAVE; i++) {
+               if (i2c_dev->slave[i])
+                       return true;
+       }
+
+       return false;
+}
+
+static bool stm32f7_i2c_is_slave_busy(struct stm32f7_i2c_dev *i2c_dev)
+{
+       int i, busy;
+
+       busy = 0;
+       for (i = 0; i < STM32F7_I2C_MAX_SLAVE; i++) {
+               if (i2c_dev->slave[i])
+                       busy++;
+       }
+
+       return i == busy;
+}
+
+static irqreturn_t stm32f7_i2c_slave_isr_event(struct stm32f7_i2c_dev *i2c_dev)
+{
+       void __iomem *base = i2c_dev->base;
+       u32 cr2, status, mask;
+       u8 val;
+       int ret;
+
+       status = readl_relaxed(i2c_dev->base + STM32F7_I2C_ISR);
+
+       /* Slave transmitter mode */
+       if (status & STM32F7_I2C_ISR_TXIS) {
+               i2c_slave_event(i2c_dev->slave_running,
+                               I2C_SLAVE_READ_PROCESSED,
+                               &val);
+
+               /* Write data byte */
+               writel_relaxed(val, base + STM32F7_I2C_TXDR);
+       }
+
+       /* Transfer Complete Reload for Slave receiver mode */
+       if (status & STM32F7_I2C_ISR_TCR || status & STM32F7_I2C_ISR_RXNE) {
+               /*
+                * Read data byte then set NBYTES to receive next byte or NACK
+                * the current received byte
+                */
+               val = readb_relaxed(i2c_dev->base + STM32F7_I2C_RXDR);
+               ret = i2c_slave_event(i2c_dev->slave_running,
+                                     I2C_SLAVE_WRITE_RECEIVED,
+                                     &val);
+               if (!ret) {
+                       cr2 = readl_relaxed(i2c_dev->base + STM32F7_I2C_CR2);
+                       cr2 |= STM32F7_I2C_CR2_NBYTES(1);
+                       writel_relaxed(cr2, i2c_dev->base + STM32F7_I2C_CR2);
+               } else {
+                       mask = STM32F7_I2C_CR2_NACK;
+                       stm32f7_i2c_set_bits(base + STM32F7_I2C_CR2, mask);
+               }
+       }
+
+       /* NACK received */
+       if (status & STM32F7_I2C_ISR_NACKF) {
+               dev_dbg(i2c_dev->dev, "<%s>: Receive NACK\n", __func__);
+               writel_relaxed(STM32F7_I2C_ICR_NACKCF, base + STM32F7_I2C_ICR);
+       }
+
+       /* STOP received */
+       if (status & STM32F7_I2C_ISR_STOPF) {
+               /* Disable interrupts */
+               stm32f7_i2c_disable_irq(i2c_dev, STM32F7_I2C_XFER_IRQ_MASK);
+
+               if (i2c_dev->slave_dir) {
+                       /*
+                        * Flush TX buffer in order to not used the byte in
+                        * TXDR for the next transfer
+                        */
+                       mask = STM32F7_I2C_ISR_TXE;
+                       stm32f7_i2c_set_bits(base + STM32F7_I2C_ISR, mask);
+               }
+
+               /* Clear STOP flag */
+               writel_relaxed(STM32F7_I2C_ICR_STOPCF, base + STM32F7_I2C_ICR);
+
+               /* Notify i2c slave that a STOP flag has been detected */
+               i2c_slave_event(i2c_dev->slave_running, I2C_SLAVE_STOP, &val);
+
+               i2c_dev->slave_running = NULL;
+       }
+
+       /* Address match received */
+       if (status & STM32F7_I2C_ISR_ADDR)
+               stm32f7_i2c_slave_addr(i2c_dev);
+
+       return IRQ_HANDLED;
 }
 
 static irqreturn_t stm32f7_i2c_isr_event(int irq, void *data)
@@ -673,6 +1371,13 @@ static irqreturn_t stm32f7_i2c_isr_event(int irq, void *data)
        struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
        void __iomem *base = i2c_dev->base;
        u32 status, mask;
+       int ret = IRQ_HANDLED;
+
+       /* Check if the interrupt if for a slave device */
+       if (!i2c_dev->master_mode) {
+               ret = stm32f7_i2c_slave_isr_event(i2c_dev);
+               return ret;
+       }
 
        status = readl_relaxed(i2c_dev->base + STM32F7_I2C_ISR);
 
@@ -694,12 +1399,21 @@ static irqreturn_t stm32f7_i2c_isr_event(int irq, void *data)
        /* STOP detection flag */
        if (status & STM32F7_I2C_ISR_STOPF) {
                /* Disable interrupts */
-               stm32f7_i2c_disable_irq(i2c_dev, STM32F7_I2C_ALL_IRQ_MASK);
+               if (stm32f7_i2c_is_slave_registered(i2c_dev))
+                       mask = STM32F7_I2C_XFER_IRQ_MASK;
+               else
+                       mask = STM32F7_I2C_ALL_IRQ_MASK;
+               stm32f7_i2c_disable_irq(i2c_dev, mask);
 
                /* Clear STOP flag */
                writel_relaxed(STM32F7_I2C_ICR_STOPCF, base + STM32F7_I2C_ICR);
 
-               complete(&i2c_dev->complete);
+               if (i2c_dev->use_dma) {
+                       ret = IRQ_WAKE_THREAD;
+               } else {
+                       i2c_dev->master_mode = false;
+                       complete(&i2c_dev->complete);
+               }
        }
 
        /* Transfer complete */
@@ -707,6 +1421,10 @@ static irqreturn_t stm32f7_i2c_isr_event(int irq, void *data)
                if (f7_msg->stop) {
                        mask = STM32F7_I2C_CR2_STOP;
                        stm32f7_i2c_set_bits(base + STM32F7_I2C_CR2, mask);
+               } else if (i2c_dev->use_dma) {
+                       ret = IRQ_WAKE_THREAD;
+               } else if (f7_msg->smbus) {
+                       stm32f7_i2c_smbus_rep_start(i2c_dev);
                } else {
                        i2c_dev->msg_id++;
                        i2c_dev->msg++;
@@ -714,13 +1432,50 @@ static irqreturn_t stm32f7_i2c_isr_event(int irq, void *data)
                }
        }
 
+       if (status & STM32F7_I2C_ISR_TCR) {
+               if (f7_msg->smbus)
+                       stm32f7_i2c_smbus_reload(i2c_dev);
+               else
+                       stm32f7_i2c_reload(i2c_dev);
+       }
+
+       return ret;
+}
+
+static irqreturn_t stm32f7_i2c_isr_event_thread(int irq, void *data)
+{
+       struct stm32f7_i2c_dev *i2c_dev = data;
+       struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
+       struct stm32_i2c_dma *dma = i2c_dev->dma;
+       u32 status;
+       int ret;
+
        /*
-        * Transfer Complete Reload: 255 data bytes have been transferred
-        * We have to prepare the I2C controller to transfer the remaining
-        * data.
+        * Wait for dma transfer completion before sending next message or
+        * notity the end of xfer to the client
         */
-       if (status & STM32F7_I2C_ISR_TCR)
-               stm32f7_i2c_reload(i2c_dev);
+       ret = wait_for_completion_timeout(&i2c_dev->dma->dma_complete, HZ);
+       if (!ret) {
+               dev_dbg(i2c_dev->dev, "<%s>: Timed out\n", __func__);
+               stm32f7_i2c_disable_dma_req(i2c_dev);
+               dmaengine_terminate_all(dma->chan_using);
+               f7_msg->result = -ETIMEDOUT;
+       }
+
+       status = readl_relaxed(i2c_dev->base + STM32F7_I2C_ISR);
+
+       if (status & STM32F7_I2C_ISR_TC) {
+               if (f7_msg->smbus) {
+                       stm32f7_i2c_smbus_rep_start(i2c_dev);
+               } else {
+                       i2c_dev->msg_id++;
+                       i2c_dev->msg++;
+                       stm32f7_i2c_xfer_msg(i2c_dev, i2c_dev->msg);
+               }
+       } else {
+               i2c_dev->master_mode = false;
+               complete(&i2c_dev->complete);
+       }
 
        return IRQ_HANDLED;
 }
@@ -731,7 +1486,8 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
        struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
        void __iomem *base = i2c_dev->base;
        struct device *dev = i2c_dev->dev;
-       u32 status;
+       struct stm32_i2c_dma *dma = i2c_dev->dma;
+       u32 mask, status;
 
        status = readl_relaxed(i2c_dev->base + STM32F7_I2C_ISR);
 
@@ -739,6 +1495,7 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
        if (status & STM32F7_I2C_ISR_BERR) {
                dev_err(dev, "<%s>: Bus error\n", __func__);
                writel_relaxed(STM32F7_I2C_ICR_BERRCF, base + STM32F7_I2C_ICR);
+               stm32f7_i2c_release_bus(&i2c_dev->adap);
                f7_msg->result = -EIO;
        }
 
@@ -749,8 +1506,26 @@ static irqreturn_t stm32f7_i2c_isr_error(int irq, void *data)
                f7_msg->result = -EAGAIN;
        }
 
-       stm32f7_i2c_disable_irq(i2c_dev, STM32F7_I2C_ALL_IRQ_MASK);
+       if (status & STM32F7_I2C_ISR_PECERR) {
+               dev_err(dev, "<%s>: PEC error in reception\n", __func__);
+               writel_relaxed(STM32F7_I2C_ICR_PECCF, base + STM32F7_I2C_ICR);
+               f7_msg->result = -EINVAL;
+       }
+
+       /* Disable interrupts */
+       if (stm32f7_i2c_is_slave_registered(i2c_dev))
+               mask = STM32F7_I2C_XFER_IRQ_MASK;
+       else
+               mask = STM32F7_I2C_ALL_IRQ_MASK;
+       stm32f7_i2c_disable_irq(i2c_dev, mask);
+
+       /* Disable dma */
+       if (i2c_dev->use_dma) {
+               stm32f7_i2c_disable_dma_req(i2c_dev);
+               dmaengine_terminate_all(dma->chan_using);
+       }
 
+       i2c_dev->master_mode = false;
        complete(&i2c_dev->complete);
 
        return IRQ_HANDLED;
@@ -761,12 +1536,14 @@ static int stm32f7_i2c_xfer(struct i2c_adapter *i2c_adap,
 {
        struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(i2c_adap);
        struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
+       struct stm32_i2c_dma *dma = i2c_dev->dma;
        unsigned long time_left;
        int ret;
 
        i2c_dev->msg = msgs;
        i2c_dev->msg_num = num;
        i2c_dev->msg_id = 0;
+       f7_msg->smbus = false;
 
        ret = clk_enable(i2c_dev->clk);
        if (ret) {
@@ -787,6 +1564,8 @@ static int stm32f7_i2c_xfer(struct i2c_adapter *i2c_adap,
        if (!time_left) {
                dev_dbg(i2c_dev->dev, "Access to slave 0x%x timed out\n",
                        i2c_dev->msg->addr);
+               if (i2c_dev->use_dma)
+                       dmaengine_terminate_all(dma->chan_using);
                ret = -ETIMEDOUT;
        }
 
@@ -796,14 +1575,209 @@ static int stm32f7_i2c_xfer(struct i2c_adapter *i2c_adap,
        return (ret < 0) ? ret : num;
 }
 
+static int stm32f7_i2c_smbus_xfer(struct i2c_adapter *adapter, u16 addr,
+                                 unsigned short flags, char read_write,
+                                 u8 command, int size,
+                                 union i2c_smbus_data *data)
+{
+       struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(adapter);
+       struct stm32f7_i2c_msg *f7_msg = &i2c_dev->f7_msg;
+       struct stm32_i2c_dma *dma = i2c_dev->dma;
+       struct device *dev = i2c_dev->dev;
+       unsigned long timeout;
+       int i, ret;
+
+       f7_msg->addr = addr;
+       f7_msg->size = size;
+       f7_msg->read_write = read_write;
+       f7_msg->smbus = true;
+
+       ret = clk_enable(i2c_dev->clk);
+       if (ret) {
+               dev_err(i2c_dev->dev, "Failed to enable clock\n");
+               return ret;
+       }
+
+       ret = stm32f7_i2c_wait_free_bus(i2c_dev);
+       if (ret)
+               goto clk_free;
+
+       ret = stm32f7_i2c_smbus_xfer_msg(i2c_dev, flags, command, data);
+       if (ret)
+               goto clk_free;
+
+       timeout = wait_for_completion_timeout(&i2c_dev->complete,
+                                             i2c_dev->adap.timeout);
+       ret = f7_msg->result;
+       if (ret)
+               goto clk_free;
+
+       if (!timeout) {
+               dev_dbg(dev, "Access to slave 0x%x timed out\n", f7_msg->addr);
+               if (i2c_dev->use_dma)
+                       dmaengine_terminate_all(dma->chan_using);
+               ret = -ETIMEDOUT;
+               goto clk_free;
+       }
+
+       /* Check PEC */
+       if ((flags & I2C_CLIENT_PEC) && size != I2C_SMBUS_QUICK && read_write) {
+               ret = stm32f7_i2c_smbus_check_pec(i2c_dev);
+               if (ret)
+                       goto clk_free;
+       }
+
+       if (read_write && size != I2C_SMBUS_QUICK) {
+               switch (size) {
+               case I2C_SMBUS_BYTE:
+               case I2C_SMBUS_BYTE_DATA:
+                       data->byte = f7_msg->smbus_buf[0];
+               break;
+               case I2C_SMBUS_WORD_DATA:
+               case I2C_SMBUS_PROC_CALL:
+                       data->word = f7_msg->smbus_buf[0] |
+                               (f7_msg->smbus_buf[1] << 8);
+               break;
+               case I2C_SMBUS_BLOCK_DATA:
+               case I2C_SMBUS_BLOCK_PROC_CALL:
+               for (i = 0; i <= f7_msg->smbus_buf[0]; i++)
+                       data->block[i] = f7_msg->smbus_buf[i];
+               break;
+               default:
+                       dev_err(dev, "Unsupported smbus transaction\n");
+                       ret = -EINVAL;
+               }
+       }
+
+clk_free:
+       clk_disable(i2c_dev->clk);
+       return ret;
+}
+
+static int stm32f7_i2c_reg_slave(struct i2c_client *slave)
+{
+       struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(slave->adapter);
+       void __iomem *base = i2c_dev->base;
+       struct device *dev = i2c_dev->dev;
+       u32 oar1, oar2, mask;
+       int id, ret;
+
+       if (slave->flags & I2C_CLIENT_PEC) {
+               dev_err(dev, "SMBus PEC not supported in slave mode\n");
+               return -EINVAL;
+       }
+
+       if (stm32f7_i2c_is_slave_busy(i2c_dev)) {
+               dev_err(dev, "Too much slave registered\n");
+               return -EBUSY;
+       }
+
+       ret = stm32f7_i2c_get_free_slave_id(i2c_dev, slave, &id);
+       if (ret)
+               return ret;
+
+       if (!(stm32f7_i2c_is_slave_registered(i2c_dev))) {
+               ret = clk_enable(i2c_dev->clk);
+               if (ret) {
+                       dev_err(dev, "Failed to enable clock\n");
+                       return ret;
+               }
+       }
+
+       if (id == 0) {
+               /* Configure Own Address 1 */
+               oar1 = readl_relaxed(i2c_dev->base + STM32F7_I2C_OAR1);
+               oar1 &= ~STM32F7_I2C_OAR1_MASK;
+               if (slave->flags & I2C_CLIENT_TEN) {
+                       oar1 |= STM32F7_I2C_OAR1_OA1_10(slave->addr);
+                       oar1 |= STM32F7_I2C_OAR1_OA1MODE;
+               } else {
+                       oar1 |= STM32F7_I2C_OAR1_OA1_7(slave->addr);
+               }
+               oar1 |= STM32F7_I2C_OAR1_OA1EN;
+               i2c_dev->slave[id] = slave;
+               writel_relaxed(oar1, i2c_dev->base + STM32F7_I2C_OAR1);
+       } else if (id == 1) {
+               /* Configure Own Address 2 */
+               oar2 = readl_relaxed(i2c_dev->base + STM32F7_I2C_OAR2);
+               oar2 &= ~STM32F7_I2C_OAR2_MASK;
+               if (slave->flags & I2C_CLIENT_TEN) {
+                       ret = -EOPNOTSUPP;
+                       goto exit;
+               }
+
+               oar2 |= STM32F7_I2C_OAR2_OA2_7(slave->addr);
+               oar2 |= STM32F7_I2C_OAR2_OA2EN;
+               i2c_dev->slave[id] = slave;
+               writel_relaxed(oar2, i2c_dev->base + STM32F7_I2C_OAR2);
+       } else {
+               ret = -ENODEV;
+               goto exit;
+       }
+
+       /* Enable ACK */
+       stm32f7_i2c_clr_bits(base + STM32F7_I2C_CR2, STM32F7_I2C_CR2_NACK);
+
+       /* Enable Address match interrupt, error interrupt and enable I2C  */
+       mask = STM32F7_I2C_CR1_ADDRIE | STM32F7_I2C_CR1_ERRIE |
+               STM32F7_I2C_CR1_PE;
+       stm32f7_i2c_set_bits(base + STM32F7_I2C_CR1, mask);
+
+       return 0;
+
+exit:
+       if (!(stm32f7_i2c_is_slave_registered(i2c_dev)))
+               clk_disable(i2c_dev->clk);
+
+       return ret;
+}
+
+static int stm32f7_i2c_unreg_slave(struct i2c_client *slave)
+{
+       struct stm32f7_i2c_dev *i2c_dev = i2c_get_adapdata(slave->adapter);
+       void __iomem *base = i2c_dev->base;
+       u32 mask;
+       int id, ret;
+
+       ret = stm32f7_i2c_get_slave_id(i2c_dev, slave, &id);
+       if (ret)
+               return ret;
+
+       WARN_ON(!i2c_dev->slave[id]);
+
+       if (id == 0) {
+               mask = STM32F7_I2C_OAR1_OA1EN;
+               stm32f7_i2c_clr_bits(base + STM32F7_I2C_OAR1, mask);
+       } else {
+               mask = STM32F7_I2C_OAR2_OA2EN;
+               stm32f7_i2c_clr_bits(base + STM32F7_I2C_OAR2, mask);
+       }
+
+       i2c_dev->slave[id] = NULL;
+
+       if (!(stm32f7_i2c_is_slave_registered(i2c_dev))) {
+               stm32f7_i2c_disable_irq(i2c_dev, STM32F7_I2C_ALL_IRQ_MASK);
+               clk_disable(i2c_dev->clk);
+       }
+
+       return 0;
+}
+
 static u32 stm32f7_i2c_func(struct i2c_adapter *adap)
 {
-       return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL;
+       return I2C_FUNC_I2C | I2C_FUNC_10BIT_ADDR | I2C_FUNC_SLAVE |
+               I2C_FUNC_SMBUS_QUICK | I2C_FUNC_SMBUS_BYTE |
+               I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA |
+               I2C_FUNC_SMBUS_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL |
+               I2C_FUNC_SMBUS_PROC_CALL | I2C_FUNC_SMBUS_PEC;
 }
 
 static struct i2c_algorithm stm32f7_i2c_algo = {
        .master_xfer = stm32f7_i2c_xfer,
+       .smbus_xfer = stm32f7_i2c_smbus_xfer,
        .functionality = stm32f7_i2c_func,
+       .reg_slave = stm32f7_i2c_reg_slave,
+       .unreg_slave = stm32f7_i2c_unreg_slave,
 };
 
 static int stm32f7_i2c_probe(struct platform_device *pdev)
@@ -815,6 +1789,7 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
        u32 irq_error, irq_event, clk_rate, rise_time, fall_time;
        struct i2c_adapter *adap;
        struct reset_control *rst;
+       dma_addr_t phy_addr;
        int ret;
 
        i2c_dev = devm_kzalloc(&pdev->dev, sizeof(*i2c_dev), GFP_KERNEL);
@@ -825,6 +1800,7 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
        i2c_dev->base = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(i2c_dev->base))
                return PTR_ERR(i2c_dev->base);
+       phy_addr = (dma_addr_t)res->start;
 
        irq_event = irq_of_parse_and_map(np, 0);
        if (!irq_event) {
@@ -871,8 +1847,11 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
 
        i2c_dev->dev = &pdev->dev;
 
-       ret = devm_request_irq(&pdev->dev, irq_event, stm32f7_i2c_isr_event, 0,
-                              pdev->name, i2c_dev);
+       ret = devm_request_threaded_irq(&pdev->dev, irq_event,
+                                       stm32f7_i2c_isr_event,
+                                       stm32f7_i2c_isr_event_thread,
+                                       IRQF_ONESHOT,
+                                       pdev->name, i2c_dev);
        if (ret) {
                dev_err(&pdev->dev, "Failed to request irq event %i\n",
                        irq_event);
@@ -924,6 +1903,11 @@ static int stm32f7_i2c_probe(struct platform_device *pdev)
 
        init_completion(&i2c_dev->complete);
 
+       /* Init DMA config if supported */
+       i2c_dev->dma = stm32_i2c_dma_request(i2c_dev->dev, phy_addr,
+                                            STM32F7_I2C_TXDR,
+                                            STM32F7_I2C_RXDR);
+
        ret = i2c_add_adapter(adap);
        if (ret)
                goto clk_free;
@@ -946,6 +1930,11 @@ static int stm32f7_i2c_remove(struct platform_device *pdev)
 {
        struct stm32f7_i2c_dev *i2c_dev = platform_get_drvdata(pdev);
 
+       if (i2c_dev->dma) {
+               stm32_i2c_dma_free(i2c_dev->dma);
+               i2c_dev->dma = NULL;
+       }
+
        i2c_del_adapter(&i2c_dev->adap);
 
        clk_unprepare(i2c_dev->clk);
index dc63236b45b21669922a77155bd2c244ec456dde..e866c481bfc325d3c42e733faa88d133b3388f0d 100644 (file)
@@ -602,20 +602,24 @@ static int stu300_send_address(struct stu300_dev *dev,
        u32 val;
        int ret;
 
-       if (msg->flags & I2C_M_TEN)
+       if (msg->flags & I2C_M_TEN) {
                /* This is probably how 10 bit addresses look */
                val = (0xf0 | (((u32) msg->addr & 0x300) >> 7)) &
                        I2C_DR_D_MASK;
-       else
-               val = ((msg->addr << 1) & I2C_DR_D_MASK);
+               if (msg->flags & I2C_M_RD)
+                       /* This is the direction bit */
+                       val |= 0x01;
+       } else {
+               val = i2c_8bit_addr_from_msg(msg);
+       }
 
-       if (msg->flags & I2C_M_RD) {
-               /* This is the direction bit */
-               val |= 0x01;
-               if (resend)
+       if (resend) {
+               if (msg->flags & I2C_M_RD)
                        dev_dbg(&dev->pdev->dev, "read resend\n");
-       } else if (resend)
-               dev_dbg(&dev->pdev->dev, "write resend\n");
+               else
+                       dev_dbg(&dev->pdev->dev, "write resend\n");
+       }
+
        stu300_wr8(val, dev->virtbase + I2C_DR);
 
        /* For 10bit addressing, await 10bit request (EVENT 9) */
index a021f866d8c24e2e6849db042ee64ef0bd44177d..915f5edbab3319212c1e22ae3274ce63de468d18 100644 (file)
@@ -509,7 +509,7 @@ static int synquacer_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs,
 
        dev_dbg(i2c->dev, "calculated timeout %d ms\n", i2c->timeout_ms);
 
-       for (retry = 0; retry < adap->retries; retry++) {
+       for (retry = 0; retry <= adap->retries; retry++) {
                ret = synquacer_i2c_doxfer(i2c, msgs, num);
                if (ret != -EAGAIN)
                        return ret;
index 60292d243e249c60fbc8ef89b0d4714fe6c21772..5fccd1f1bca85d28bcc249fa6b76f4297bf504bb 100644 (file)
@@ -173,7 +173,6 @@ struct tegra_i2c_hw_feature {
  * @msg_buf_remaining: size of unsent data in the message buffer
  * @msg_read: identifies read transfers
  * @bus_clk_rate: current i2c bus clock rate
- * @is_suspended: prevents i2c controller accesses after suspend is called
  */
 struct tegra_i2c_dev {
        struct device *dev;
@@ -194,7 +193,6 @@ struct tegra_i2c_dev {
        int msg_read;
        u32 bus_clk_rate;
        u16 clk_divisor_non_hs_mode;
-       bool is_suspended;
        bool is_multimaster_mode;
        spinlock_t xfer_lock;
 };
@@ -734,9 +732,6 @@ static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
        int i;
        int ret = 0;
 
-       if (i2c_dev->is_suspended)
-               return -EBUSY;
-
        ret = pm_runtime_get_sync(i2c_dev->dev);
        if (ret < 0) {
                dev_err(i2c_dev->dev, "runtime resume failed %d\n", ret);
@@ -1051,37 +1046,9 @@ static int tegra_i2c_remove(struct platform_device *pdev)
 }
 
 #ifdef CONFIG_PM_SLEEP
-static int tegra_i2c_suspend(struct device *dev)
-{
-       struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
-
-       i2c_lock_adapter(&i2c_dev->adapter);
-       i2c_dev->is_suspended = true;
-       i2c_unlock_adapter(&i2c_dev->adapter);
-
-       return 0;
-}
-
-static int tegra_i2c_resume(struct device *dev)
-{
-       struct tegra_i2c_dev *i2c_dev = dev_get_drvdata(dev);
-       int ret;
-
-       i2c_lock_adapter(&i2c_dev->adapter);
-
-       ret = tegra_i2c_init(i2c_dev);
-       if (!ret)
-               i2c_dev->is_suspended = false;
-
-       i2c_unlock_adapter(&i2c_dev->adapter);
-
-       return ret;
-}
-
 static const struct dev_pm_ops tegra_i2c_pm = {
        SET_RUNTIME_PM_OPS(tegra_i2c_runtime_suspend, tegra_i2c_runtime_resume,
                           NULL)
-       SET_SYSTEM_SLEEP_PM_OPS(tegra_i2c_suspend, tegra_i2c_resume)
 };
 #define TEGRA_I2C_PM   (&tegra_i2c_pm)
 #else
index c80527816ad0ab99b52b92b36d1f70bcf867a33f..9a71e50d21f1fbae53ebdb2b1831e7f6067a67b9 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/i2c.h>
 #include <linux/interrupt.h>
 #include <linux/wait.h>
-#include <linux/i2c-xiic.h>
+#include <linux/platform_data/i2c-xiic.h>
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/of.h>
@@ -143,12 +143,6 @@ struct xiic_i2c {
 
 #define XIIC_TX_RX_INTERRUPTS (XIIC_INTR_RX_FULL_MASK | XIIC_TX_INTERRUPTS)
 
-/* The following constants are used with the following macros to specify the
- * operation, a read or write operation.
- */
-#define XIIC_READ_OPERATION  1
-#define XIIC_WRITE_OPERATION 0
-
 /*
  * Tx Fifo upper bit masks.
  */
@@ -415,7 +409,7 @@ static irqreturn_t xiic_process(int irq, void *dev_id)
                clr |= XIIC_INTR_RX_FULL_MASK;
                if (!i2c->rx_msg) {
                        dev_dbg(i2c->adap.dev.parent,
-                               "%s unexpexted RX IRQ\n", __func__);
+                               "%s unexpected RX IRQ\n", __func__);
                        xiic_clear_rx_fifo(i2c);
                        goto out;
                }
@@ -470,7 +464,7 @@ static irqreturn_t xiic_process(int irq, void *dev_id)
 
                if (!i2c->tx_msg) {
                        dev_dbg(i2c->adap.dev.parent,
-                               "%s unexpexted TX IRQ\n", __func__);
+                               "%s unexpected TX IRQ\n", __func__);
                        goto out;
                }
 
@@ -556,8 +550,7 @@ static void xiic_start_recv(struct xiic_i2c *i2c)
        if (!(msg->flags & I2C_M_NOSTART))
                /* write the address */
                xiic_setreg16(i2c, XIIC_DTR_REG_OFFSET,
-                       (msg->addr << 1) | XIIC_READ_OPERATION |
-                       XIIC_TX_DYN_START_MASK);
+                       i2c_8bit_addr_from_msg(msg) | XIIC_TX_DYN_START_MASK);
 
        xiic_irq_clr_en(i2c, XIIC_INTR_BNB_MASK);
 
@@ -585,7 +578,7 @@ static void xiic_start_send(struct xiic_i2c *i2c)
 
        if (!(msg->flags & I2C_M_NOSTART)) {
                /* write the address */
-               u16 data = ((msg->addr << 1) & 0xfe) | XIIC_WRITE_OPERATION |
+               u16 data = i2c_8bit_addr_from_msg(msg) |
                        XIIC_TX_DYN_START_MASK;
                if ((i2c->nmsgs == 1) && msg->len == 0)
                        /* no data and last message -> add STOP */
index eb8913eba0c5c144c7d1b0986f51862bac1887f7..1f41a4f89c08f4c4b2da8cf3f0feb2bd643e9b5e 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/clk.h>
 #include <linux/completion.h>
 #include <linux/i2c.h>
+#include <linux/i2c-smbus.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
 #include <linux/io.h>
@@ -84,6 +85,8 @@ struct xlp9xx_i2c_dev {
        struct device *dev;
        struct i2c_adapter adapter;
        struct completion msg_complete;
+       struct i2c_smbus_alert_setup alert_data;
+       struct i2c_client *ara;
        int irq;
        bool msg_read;
        bool len_recv;
@@ -155,9 +158,30 @@ static void xlp9xx_i2c_fill_tx_fifo(struct xlp9xx_i2c_dev *priv)
        priv->msg_buf += len;
 }
 
+static void xlp9xx_i2c_update_rlen(struct xlp9xx_i2c_dev *priv)
+{
+       u32 val, len;
+
+       /*
+        * Update receive length. Re-read len to get the latest value,
+        * and then add 4 to have a minimum value that can be safely
+        * written. This is to account for the byte read above, the
+        * transfer in progress and any delays in the register I/O
+        */
+       val = xlp9xx_read_i2c_reg(priv, XLP9XX_I2C_CTRL);
+       len = xlp9xx_read_i2c_reg(priv, XLP9XX_I2C_FIFOWCNT) &
+                                 XLP9XX_I2C_FIFO_WCNT_MASK;
+       len = max_t(u32, priv->msg_len, len + 4);
+       if (len >= I2C_SMBUS_BLOCK_MAX + 2)
+               return;
+       val = (val & ~XLP9XX_I2C_CTRL_MCTLEN_MASK) |
+                       (len << XLP9XX_I2C_CTRL_MCTLEN_SHIFT);
+       xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_CTRL, val);
+}
+
 static void xlp9xx_i2c_drain_rx_fifo(struct xlp9xx_i2c_dev *priv)
 {
-       u32 len, i, val;
+       u32 len, i;
        u8 rlen, *buf = priv->msg_buf;
 
        len = xlp9xx_read_i2c_reg(priv, XLP9XX_I2C_FIFOWCNT) &
@@ -167,21 +191,20 @@ static void xlp9xx_i2c_drain_rx_fifo(struct xlp9xx_i2c_dev *priv)
        if (priv->len_recv) {
                /* read length byte */
                rlen = xlp9xx_read_i2c_reg(priv, XLP9XX_I2C_MRXFIFO);
-               *buf++ = rlen;
-               len--;
-
-               if (priv->client_pec)
-                       ++rlen;
-               /* update remaining bytes and message length */
-               priv->msg_buf_remaining = rlen;
-               priv->msg_len = rlen + 1;
+               if (rlen > I2C_SMBUS_BLOCK_MAX || rlen == 0) {
+                       rlen = 0;       /*abort transfer */
+                       priv->msg_buf_remaining = 0;
+                       priv->msg_len = 0;
+               } else {
+                       *buf++ = rlen;
+                       if (priv->client_pec)
+                               ++rlen; /* account for error check byte */
+                       /* update remaining bytes and message length */
+                       priv->msg_buf_remaining = rlen;
+                       priv->msg_len = rlen + 1;
+               }
+               xlp9xx_i2c_update_rlen(priv);
                priv->len_recv = false;
-
-               /* Update transfer length to read only actual data */
-               val = xlp9xx_read_i2c_reg(priv, XLP9XX_I2C_CTRL);
-               val = (val & ~XLP9XX_I2C_CTRL_MCTLEN_MASK) |
-                       ((rlen + 1) << XLP9XX_I2C_CTRL_MCTLEN_SHIFT);
-               xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_CTRL, val);
        } else {
                len = min(priv->msg_buf_remaining, len);
                for (i = 0; i < len; i++, buf++)
@@ -300,10 +323,6 @@ static int xlp9xx_i2c_xfer_msg(struct xlp9xx_i2c_dev *priv, struct i2c_msg *msg,
        xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_MFIFOCTRL,
                             XLP9XX_I2C_MFIFOCTRL_RST);
 
-       /* set FIFO threshold if reading */
-       if (priv->msg_read)
-               xlp9xx_i2c_update_rx_fifo_thres(priv);
-
        /* set slave addr */
        xlp9xx_write_i2c_reg(priv, XLP9XX_I2C_SLAVEADDR,
                             (msg->addr << XLP9XX_I2C_SLAVEADDR_ADDR_SHIFT) |
@@ -322,9 +341,13 @@ static int xlp9xx_i2c_xfer_msg(struct xlp9xx_i2c_dev *priv, struct i2c_msg *msg,
                val &= ~XLP9XX_I2C_CTRL_ADDMODE;
 
        priv->len_recv = msg->flags & I2C_M_RECV_LEN;
-       len = priv->len_recv ? XLP9XX_I2C_FIFO_SIZE : msg->len;
+       len = priv->len_recv ? I2C_SMBUS_BLOCK_MAX + 2 : msg->len;
        priv->client_pec = msg->flags & I2C_CLIENT_PEC;
 
+       /* set FIFO threshold if reading */
+       if (priv->msg_read)
+               xlp9xx_i2c_update_rx_fifo_thres(priv);
+
        /* set data length to be transferred */
        val = (val & ~XLP9XX_I2C_CTRL_MCTLEN_MASK) |
              (len << XLP9XX_I2C_CTRL_MCTLEN_SHIFT);
@@ -378,8 +401,11 @@ static int xlp9xx_i2c_xfer_msg(struct xlp9xx_i2c_dev *priv, struct i2c_msg *msg,
        }
 
        /* update msg->len with actual received length */
-       if (msg->flags & I2C_M_RECV_LEN)
+       if (msg->flags & I2C_M_RECV_LEN) {
+               if (!priv->msg_len)
+                       return -EPROTO;
                msg->len = priv->msg_len;
+       }
        return 0;
 }
 
@@ -447,6 +473,19 @@ static int xlp9xx_i2c_get_frequency(struct platform_device *pdev,
        return 0;
 }
 
+static int xlp9xx_i2c_smbus_setup(struct xlp9xx_i2c_dev *priv,
+                                 struct platform_device *pdev)
+{
+       if (!priv->alert_data.irq)
+               return -EINVAL;
+
+       priv->ara = i2c_setup_smbus_alert(&priv->adapter, &priv->alert_data);
+       if (!priv->ara)
+               return -ENODEV;
+
+       return 0;
+}
+
 static int xlp9xx_i2c_probe(struct platform_device *pdev)
 {
        struct xlp9xx_i2c_dev *priv;
@@ -467,6 +506,10 @@ static int xlp9xx_i2c_probe(struct platform_device *pdev)
                dev_err(&pdev->dev, "invalid irq!\n");
                return priv->irq;
        }
+       /* SMBAlert irq */
+       priv->alert_data.irq = platform_get_irq(pdev, 1);
+       if (priv->alert_data.irq <= 0)
+               priv->alert_data.irq = 0;
 
        xlp9xx_i2c_get_frequency(pdev, priv);
        xlp9xx_i2c_init(priv);
@@ -493,6 +536,10 @@ static int xlp9xx_i2c_probe(struct platform_device *pdev)
        if (err)
                return err;
 
+       err = xlp9xx_i2c_smbus_setup(priv, pdev);
+       if (err)
+               dev_dbg(&pdev->dev, "No active SMBus alert %d\n", err);
+
        platform_set_drvdata(pdev, priv);
        dev_dbg(&pdev->dev, "I2C bus:%d added\n", priv->adapter.nr);
 
index a17f46a95f73d63e0d2a854304994da6e6722afa..31d16ada6e7d9a789240cc62f50a7fcde840bb2e 100644 (file)
@@ -717,10 +717,6 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
        client->adapter = adap;
 
        client->dev.platform_data = info->platform_data;
-
-       if (info->archdata)
-               client->dev.archdata = *info->archdata;
-
        client->flags = info->flags;
        client->addr = info->addr;
 
@@ -746,7 +742,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
        client->dev.parent = &client->adapter->dev;
        client->dev.bus = &i2c_bus_type;
        client->dev.type = &i2c_client_type;
-       client->dev.of_node = info->of_node;
+       client->dev.of_node = of_node_get(info->of_node);
        client->dev.fwnode = info->fwnode;
 
        i2c_dev_set_name(adap, client, info);
@@ -757,7 +753,7 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
                        dev_err(&adap->dev,
                                "Failed to add properties to client %s: %d\n",
                                client->name, status);
-                       goto out_err;
+                       goto out_err_put_of_node;
                }
        }
 
@@ -773,6 +769,8 @@ i2c_new_device(struct i2c_adapter *adap, struct i2c_board_info const *info)
 out_free_props:
        if (info->properties)
                device_remove_properties(&client->dev);
+out_err_put_of_node:
+       of_node_put(info->of_node);
 out_err:
        dev_err(&adap->dev,
                "Failed to register i2c client %s at 0x%02x (%d)\n",
index c405270a98b4f01c89944e91f9dc4bba3b4620c4..6cb7ad608bcd53d9c966752a342562208aa7617e 100644 (file)
 
 #include "i2c-core.h"
 
-static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
-                                                struct device_node *node)
+int of_i2c_get_board_info(struct device *dev, struct device_node *node,
+                         struct i2c_board_info *info)
 {
-       struct i2c_client *client;
-       struct i2c_board_info info = {};
-       struct dev_archdata dev_ad = {};
        u32 addr;
        int ret;
 
-       dev_dbg(&adap->dev, "of_i2c: register %pOF\n", node);
+       memset(info, 0, sizeof(*info));
 
-       if (of_modalias_node(node, info.type, sizeof(info.type)) < 0) {
-               dev_err(&adap->dev, "of_i2c: modalias failure on %pOF\n",
-                       node);
-               return ERR_PTR(-EINVAL);
+       if (of_modalias_node(node, info->type, sizeof(info->type)) < 0) {
+               dev_err(dev, "of_i2c: modalias failure on %pOF\n", node);
+               return -EINVAL;
        }
 
        ret = of_property_read_u32(node, "reg", &addr);
        if (ret) {
-               dev_err(&adap->dev, "of_i2c: invalid reg on %pOF\n", node);
-               return ERR_PTR(ret);
+               dev_err(dev, "of_i2c: invalid reg on %pOF\n", node);
+               return ret;
        }
 
        if (addr & I2C_TEN_BIT_ADDRESS) {
                addr &= ~I2C_TEN_BIT_ADDRESS;
-               info.flags |= I2C_CLIENT_TEN;
+               info->flags |= I2C_CLIENT_TEN;
        }
 
        if (addr & I2C_OWN_SLAVE_ADDRESS) {
                addr &= ~I2C_OWN_SLAVE_ADDRESS;
-               info.flags |= I2C_CLIENT_SLAVE;
+               info->flags |= I2C_CLIENT_SLAVE;
        }
 
-       info.addr = addr;
-       info.archdata = &dev_ad;
-       info.of_node = of_node_get(node);
+       info->addr = addr;
+       info->of_node = node;
 
        if (of_property_read_bool(node, "host-notify"))
-               info.flags |= I2C_CLIENT_HOST_NOTIFY;
+               info->flags |= I2C_CLIENT_HOST_NOTIFY;
 
        if (of_get_property(node, "wakeup-source", NULL))
-               info.flags |= I2C_CLIENT_WAKE;
+               info->flags |= I2C_CLIENT_WAKE;
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(of_i2c_get_board_info);
+
+static struct i2c_client *of_i2c_register_device(struct i2c_adapter *adap,
+                                                struct device_node *node)
+{
+       struct i2c_client *client;
+       struct i2c_board_info info;
+       int ret;
+
+       dev_dbg(&adap->dev, "of_i2c: register %pOF\n", node);
+
+       ret = of_i2c_get_board_info(&adap->dev, node, &info);
+       if (ret)
+               return ERR_PTR(ret);
 
        client = i2c_new_device(adap, &info);
        if (!client) {
                dev_err(&adap->dev, "of_i2c: Failure registering %pOF\n", node);
-               of_node_put(node);
                return ERR_PTR(-EINVAL);
        }
        return client;
index b5aec33002c3a66eb6339077e512516d5460b59e..f3f683041e7f9199ad5799ef5c8fd83f59fc9856 100644 (file)
@@ -466,6 +466,8 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr,
        status = i2c_transfer(adapter, msg, num);
        if (status < 0)
                return status;
+       if (status != num)
+               return -EIO;
 
        /* Check PEC if last message is a read */
        if (i && (msg[num-1].flags & I2C_M_RD)) {
index 1667b6e7674f4a0439befcd544d74753e41d43f3..1aca742fde4aefdf13069324abe7d4a93a0a3006 100644 (file)
@@ -244,7 +244,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
        u8 __user **data_ptrs;
        int i, res;
 
-       data_ptrs = kmalloc(nmsgs * sizeof(u8 __user *), GFP_KERNEL);
+       data_ptrs = kmalloc_array(nmsgs, sizeof(u8 __user *), GFP_KERNEL);
        if (data_ptrs == NULL) {
                kfree(msgs);
                return -ENOMEM;
index 9669ca4937b891063d4cd63e552344d818f5eefa..300ab4b672e4992921b164a40d77d9e426fda305 100644 (file)
@@ -418,7 +418,7 @@ int i2c_mux_add_adapter(struct i2c_mux_core *muxc,
        snprintf(symlink_name, sizeof(symlink_name), "channel-%u", chan_id);
        WARN(sysfs_create_link(&muxc->dev->kobj, &priv->adap.dev.kobj,
                               symlink_name),
-            "can't create symlink for channel %u\n", chan_id);
+            "can't create symlink to channel %u\n", chan_id);
        dev_info(&parent->dev, "Added multiplexed i2c bus %d\n",
                 i2c_adapter_id(&priv->adap));
 
index 4a9ad91c5ba3eaf2d2e396d69e6076c0cdc1ec17..f31ec0861979c89264d5d38e9ebcfe219d66b502 100644 (file)
@@ -338,8 +338,9 @@ static int __init i2c_stub_allocate_banks(int i)
                chip->bank_mask >>= 1;
        }
 
-       chip->bank_words = kzalloc(chip->bank_mask * chip->bank_size *
-                                  sizeof(u16), GFP_KERNEL);
+       chip->bank_words = kcalloc(chip->bank_mask * chip->bank_size,
+                                  sizeof(u16),
+                                  GFP_KERNEL);
        if (!chip->bank_words)
                return -ENOMEM;
 
index 33ce032cb70112e9a3304f789198fbb75602a47c..035032e203276e96b27dd57770f47af98ee5146f 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/of.h>
 #include <linux/pinctrl/consumer.h>
 #include <linux/platform_device.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/sysfs.h>
 
@@ -105,7 +106,7 @@ static int i2c_demux_activate_master(struct i2c_demux_pinctrl_priv *priv, u32 ne
        priv->cur_adap.owner = THIS_MODULE;
        priv->cur_adap.algo = &priv->algo;
        priv->cur_adap.algo_data = priv;
-       priv->cur_adap.dev.parent = priv->dev;
+       priv->cur_adap.dev.parent = &adap->dev;
        priv->cur_adap.class = adap->class;
        priv->cur_adap.retries = adap->retries;
        priv->cur_adap.timeout = adap->timeout;
@@ -254,6 +255,8 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, priv);
 
+       pm_runtime_no_callbacks(&pdev->dev);
+
        /* switch to first parent as active master */
        i2c_demux_activate_master(priv, 0);
 
index 1a9973ede4436d7f583c9c602b5c12e265f680fa..401308e3d036fe54ad172690d9ba5ac0ee54b7e3 100644 (file)
@@ -10,7 +10,7 @@
 
 #include <linux/i2c.h>
 #include <linux/i2c-mux.h>
-#include <linux/i2c-mux-gpio.h>
+#include <linux/platform_data/i2c-mux-gpio.h>
 #include <linux/platform_device.h>
 #include <linux/module.h>
 #include <linux/slab.h>
@@ -88,8 +88,8 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
 
        mux->data.n_values = of_get_child_count(np);
 
-       values = devm_kzalloc(&pdev->dev,
-                             sizeof(*mux->data.values) * mux->data.n_values,
+       values = devm_kcalloc(&pdev->dev,
+                             mux->data.n_values, sizeof(*mux->data.values),
                              GFP_KERNEL);
        if (!values) {
                dev_err(&pdev->dev, "Cannot allocate values array");
@@ -111,8 +111,9 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux,
                return -EINVAL;
        }
 
-       gpios = devm_kzalloc(&pdev->dev,
-                            sizeof(*mux->data.gpios) * mux->data.n_gpios, GFP_KERNEL);
+       gpios = devm_kcalloc(&pdev->dev,
+                            mux->data.n_gpios, sizeof(*mux->data.gpios),
+                            GFP_KERNEL);
        if (!gpios) {
                dev_err(&pdev->dev, "Cannot allocate gpios array");
                return -ENOMEM;
index 311b1cced0c041b6bb019c8b281192de1169479c..a9af93259b19df97c4a60da563ffb2174125b42c 100644 (file)
@@ -206,8 +206,7 @@ static const struct of_device_id ltc4306_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, ltc4306_of_match);
 
-static int ltc4306_probe(struct i2c_client *client,
-                        const struct i2c_device_id *id)
+static int ltc4306_probe(struct i2c_client *client)
 {
        struct i2c_adapter *adap = to_i2c_adapter(client->dev.parent);
        const struct chip_desc *chip;
@@ -221,7 +220,7 @@ static int ltc4306_probe(struct i2c_client *client,
        chip = of_device_get_match_data(&client->dev);
 
        if (!chip)
-               chip = &chips[id->driver_data];
+               chip = &chips[i2c_match_id(ltc4306_id, client)->driver_data];
 
        idle_disc = device_property_read_bool(&client->dev,
                                              "i2c-mux-idle-disconnect");
@@ -310,7 +309,7 @@ static struct i2c_driver ltc4306_driver = {
                .name   = "ltc4306",
                .of_match_table = of_match_ptr(ltc4306_of_match),
        },
-       .probe          = ltc4306_probe,
+       .probe_new      = ltc4306_probe,
        .remove         = ltc4306_remove,
        .id_table       = ltc4306_id,
 };
index 09bafd3e68faf8a5bd600cb0a8fd6464443985f3..fbc748027087dbfd9783a459ccc74a7834d1a480 100644 (file)
@@ -36,6 +36,7 @@
  */
 
 #include <linux/device.h>
+#include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/i2c.h>
 #include <linux/i2c-mux.h>
@@ -373,7 +374,6 @@ static int pca954x_probe(struct i2c_client *client,
        int num, force, class;
        struct i2c_mux_core *muxc;
        struct pca954x *data;
-       const struct of_device_id *match;
        int ret;
 
        if (!i2c_check_functionality(adap, I2C_FUNC_SMBUS_BYTE))
@@ -389,15 +389,19 @@ static int pca954x_probe(struct i2c_client *client,
        i2c_set_clientdata(client, muxc);
        data->client = client;
 
-       /* Get the mux out of reset if a reset GPIO is specified. */
-       gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_LOW);
+       /* Reset the mux if a reset GPIO is specified. */
+       gpio = devm_gpiod_get_optional(&client->dev, "reset", GPIOD_OUT_HIGH);
        if (IS_ERR(gpio))
                return PTR_ERR(gpio);
+       if (gpio) {
+               udelay(1);
+               gpiod_set_value_cansleep(gpio, 0);
+               /* Give the chip some time to recover. */
+               udelay(1);
+       }
 
-       match = of_match_device(of_match_ptr(pca954x_of_match), &client->dev);
-       if (match)
-               data->chip = of_device_get_match_data(&client->dev);
-       else
+       data->chip = of_device_get_match_data(&client->dev);
+       if (!data->chip)
                data->chip = &chips[id->driver_data];
 
        if (data->chip->id.manufacturer_id != I2C_DEVICE_ID_NONE) {
index c948e5a4cb045198cf6ffd61d698f9f759f47059..5653295b01cd35c2a701335f976641fb9946f260 100644 (file)
@@ -124,13 +124,11 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux,
        }
        mux->data.write_only = of_property_read_bool(np, "write-only");
 
-       values = devm_kzalloc(&pdev->dev,
-                             sizeof(*mux->data.values) * mux->data.n_values,
+       values = devm_kcalloc(&pdev->dev,
+                             mux->data.n_values, sizeof(*mux->data.values),
                              GFP_KERNEL);
-       if (!values) {
-               dev_err(&pdev->dev, "Cannot allocate values array");
+       if (!values)
                return -ENOMEM;
-       }
 
        for_each_child_of_node(np, child) {
                of_property_read_u32(child, "reg", values + i);
index 4b5dc0162e67418ab2cb20b67b12f96554a3acec..e52c58c29d9a71fc43818bdef99de45c194e8764 100644 (file)
@@ -1455,7 +1455,7 @@ static int hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id)
        if (info == &hpt36x || info == &hpt374)
                dev2 = pci_get_slot(dev->bus, dev->devfn + 1);
 
-       dyn_info = kzalloc(sizeof(*dyn_info) * (dev2 ? 2 : 1), GFP_KERNEL);
+       dyn_info = kcalloc(dev2 ? 2 : 1, sizeof(*dyn_info), GFP_KERNEL);
        if (dyn_info == NULL) {
                printk(KERN_ERR "%s %s: out of memory!\n",
                        d.name, pci_name(dev));
index 56d7bc228cb31483b71a6a2a7fb2733b915a27e6..416a2f3530711aa556acec93eba46df0ead97a2b 100644 (file)
@@ -985,8 +985,9 @@ static int hwif_init(ide_hwif_t *hwif)
        if (!hwif->sg_max_nents)
                hwif->sg_max_nents = PRD_ENTRIES;
 
-       hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents,
-                                GFP_KERNEL);
+       hwif->sg_table = kmalloc_array(hwif->sg_max_nents,
+                                      sizeof(struct scatterlist),
+                                      GFP_KERNEL);
        if (!hwif->sg_table) {
                printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name);
                goto out;
index 04029d18a6966b131e3621f3f82ce4fdde1d6309..36a64c8ea575dc33bcfe2b300a3c7d8eab165899 100644 (file)
@@ -652,7 +652,7 @@ static int it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
        struct it821x_dev *itdevs;
        int rc;
 
-       itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL);
+       itdevs = kcalloc(2, sizeof(*itdevs), GFP_KERNEL);
        if (itdevs == NULL) {
                printk(KERN_ERR DRV_NAME " %s: out of memory\n", pci_name(dev));
                return -ENOMEM;
index 71a5ee652b796f8666be32d174c466536c6c6244..44b516863c9d4d220f3323ca580d98fbb6f8e772 100644 (file)
@@ -624,8 +624,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev)
        struct at91_adc_state *st = iio_priv(idev);
        int i, ret;
 
-       st->trig = devm_kzalloc(&idev->dev,
-                               st->trigger_number * sizeof(*st->trig),
+       st->trig = devm_kcalloc(&idev->dev,
+                               st->trigger_number, sizeof(*st->trig),
                                GFP_KERNEL);
 
        if (st->trig == NULL) {
@@ -908,7 +908,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st,
        st->registers = &st->caps->registers;
        st->num_channels = st->caps->num_channels;
        st->trigger_number = of_get_child_count(node);
-       st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number *
+       st->trigger_list = devm_kcalloc(&idev->dev,
+                                       st->trigger_number,
                                        sizeof(struct at91_adc_trigger),
                                        GFP_KERNEL);
        if (!st->trigger_list) {
index 375da6491499faca088a0e03f4fa684b6bf14f8b..311c1a89c329eb5599421508e43a7e3625cb821f 100644 (file)
@@ -422,8 +422,8 @@ static int max1027_probe(struct spi_device *spi)
        indio_dev->num_channels = st->info->num_channels;
        indio_dev->available_scan_masks = st->info->available_scan_masks;
 
-       st->buffer = devm_kmalloc(&indio_dev->dev,
-                                 indio_dev->num_channels * 2,
+       st->buffer = devm_kmalloc_array(&indio_dev->dev,
+                                 indio_dev->num_channels, 2,
                                  GFP_KERNEL);
        if (st->buffer == NULL) {
                dev_err(&indio_dev->dev, "Can't allocate buffer\n");
index 7f1848dac9bf06bf75f99d43d242253867d960ef..7fb4f525714a154e706a5e70dfbc0438b6308967 100644 (file)
@@ -1453,8 +1453,10 @@ static int max1363_alloc_scan_masks(struct iio_dev *indio_dev)
        int i;
 
        masks = devm_kzalloc(&indio_dev->dev,
-                       BITS_TO_LONGS(MAX1363_MAX_CHANNELS) * sizeof(long) *
-                       (st->chip_info->num_modes + 1), GFP_KERNEL);
+                       array3_size(BITS_TO_LONGS(MAX1363_MAX_CHANNELS),
+                                   sizeof(long),
+                                   st->chip_info->num_modes + 1),
+                       GFP_KERNEL);
        if (!masks)
                return -ENOMEM;
 
index dc83f8f6c3d359b762ee851de180d8e530aa57bc..e470510e76ea43d287f0eb13c55bcdc1422b7992 100644 (file)
@@ -898,9 +898,10 @@ static int twl6030_gpadc_probe(struct platform_device *pdev)
 
        gpadc = iio_priv(indio_dev);
 
-       gpadc->twl6030_cal_tbl = devm_kzalloc(dev,
-                                       sizeof(*gpadc->twl6030_cal_tbl) *
-                                       pdata->nchannels, GFP_KERNEL);
+       gpadc->twl6030_cal_tbl = devm_kcalloc(dev,
+                                       pdata->nchannels,
+                                       sizeof(*gpadc->twl6030_cal_tbl),
+                                       GFP_KERNEL);
        if (!gpadc->twl6030_cal_tbl)
                return -ENOMEM;
 
index 9234c6a09a932ba353c054638d530323f48430f5..095530c233e412242e83c55bb3085a643c2ba77f 100644 (file)
@@ -536,8 +536,9 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st)
                        st->channel_offstate[reg] = tmp;
        }
 
-       channels = devm_kzalloc(st->dev,
-                       (1 + 2 * num_channels) * sizeof(*channels), GFP_KERNEL);
+       channels = devm_kcalloc(st->dev,
+                       1 + 2 * num_channels, sizeof(*channels),
+                       GFP_KERNEL);
        if (!channels)
                return -ENOMEM;
 
index 36607d52fee065f9e2aa82f14215897e2c5b44b1..76643c5571aa87286bef0eeee0a557f04326ac6b 100644 (file)
@@ -38,7 +38,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
        if (!adis->xfer)
                return -ENOMEM;
 
-       adis->buffer = kzalloc(indio_dev->scan_bytes * 2, GFP_KERNEL);
+       adis->buffer = kcalloc(indio_dev->scan_bytes, 2, GFP_KERNEL);
        if (!adis->buffer)
                return -ENOMEM;
 
index ec98790e2a2839a167e2805f2b1eddd389098375..06ca3f7fcc4455ccc6732304356c53920d43fbc4 100644 (file)
@@ -436,7 +436,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
        }
 
        /* NULL terminated array to save passing size */
-       chans = kzalloc(sizeof(*chans)*(nummaps + 1), GFP_KERNEL);
+       chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
        if (chans == NULL) {
                ret = -ENOMEM;
                goto error_ret;
index 60621ccd67e4feb5b4630b21408fe7b3ed41f46b..e1f44cecdef4c50b984878229f7afb3389c9a7ca 100644 (file)
@@ -281,9 +281,10 @@ static int mux_configure_channel(struct device *dev, struct mux *mux,
                if (!page)
                        return -ENOMEM;
        }
-       child->ext_info_cache = devm_kzalloc(dev,
-                                            sizeof(*child->ext_info_cache) *
-                                            num_ext_info, GFP_KERNEL);
+       child->ext_info_cache = devm_kcalloc(dev,
+                                            num_ext_info,
+                                            sizeof(*child->ext_info_cache),
+                                            GFP_KERNEL);
        if (!child->ext_info_cache)
                return -ENOMEM;
 
index 71a34bee453d8fa4b3f75748e6589cc8f3763633..81d66f56e38f6c407d4ce321192c30db2269ae8a 100644 (file)
@@ -1245,8 +1245,9 @@ int ib_cache_setup_one(struct ib_device *device)
        rwlock_init(&device->cache.lock);
 
        device->cache.ports =
-               kzalloc(sizeof(*device->cache.ports) *
-                       (rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL);
+               kcalloc(rdma_end_port(device) - rdma_start_port(device) + 1,
+                       sizeof(*device->cache.ports),
+                       GFP_KERNEL);
        if (!device->cache.ports)
                return -ENOMEM;
 
index 6813ee717a38e510a406d20fb98cacf75ceb6286..bff10ab141b04fe418cb2f289eb2b12f754fc0ce 100644 (file)
@@ -1855,8 +1855,8 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
 
        rt = &id->route;
        rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
-       rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths,
-                              GFP_KERNEL);
+       rt->path_rec = kmalloc_array(rt->num_paths, sizeof(*rt->path_rec),
+                                    GFP_KERNEL);
        if (!rt->path_rec)
                goto err;
 
index 84f51386e1e30be7558adeb7e93b4eb1deceba9e..6fa4c59dc7a732de600c8ebabd9430d44d9b4dc0 100644 (file)
@@ -336,8 +336,8 @@ static int read_port_immutable(struct ib_device *device)
         * Therefore port_immutable is declared as a 1 based array with
         * potential empty slots at the beginning.
         */
-       device->port_immutable = kzalloc(sizeof(*device->port_immutable)
-                                        * (end_port + 1),
+       device->port_immutable = kcalloc(end_port + 1,
+                                        sizeof(*device->port_immutable),
                                         GFP_KERNEL);
        if (!device->port_immutable)
                return -ENOMEM;
index a0a9ed719031b93bd8d04c4c02368cbd9d7dc44a..a077500f7f320316abd690f7e9c2e814821ac6cd 100644 (file)
@@ -235,8 +235,9 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd             *pd,
 
        if (params->cache) {
                pool->cache_bucket =
-                       kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket,
-                               GFP_KERNEL);
+                       kmalloc_array(IB_FMR_HASH_SIZE,
+                                     sizeof(*pool->cache_bucket),
+                                     GFP_KERNEL);
                if (!pool->cache_bucket) {
                        ret = -ENOMEM;
                        goto out_free_pool;
index da12da1c36f60836fdb287920e7d7e9e582fc2a2..cdb63f3f4de70ac57c0eb761a3bbef42b017f6f4 100644 (file)
@@ -56,14 +56,16 @@ int iwpm_init(u8 nl_client)
        int ret = 0;
        mutex_lock(&iwpm_admin_lock);
        if (atomic_read(&iwpm_admin.refcount) == 0) {
-               iwpm_hash_bucket = kzalloc(IWPM_MAPINFO_HASH_SIZE *
-                                       sizeof(struct hlist_head), GFP_KERNEL);
+               iwpm_hash_bucket = kcalloc(IWPM_MAPINFO_HASH_SIZE,
+                                          sizeof(struct hlist_head),
+                                          GFP_KERNEL);
                if (!iwpm_hash_bucket) {
                        ret = -ENOMEM;
                        goto init_exit;
                }
-               iwpm_reminfo_bucket = kzalloc(IWPM_REMINFO_HASH_SIZE *
-                                       sizeof(struct hlist_head), GFP_KERNEL);
+               iwpm_reminfo_bucket = kcalloc(IWPM_REMINFO_HASH_SIZE,
+                                             sizeof(struct hlist_head),
+                                             GFP_KERNEL);
                if (!iwpm_reminfo_bucket) {
                        kfree(iwpm_hash_bucket);
                        ret = -ENOMEM;
index 2aadf5813a40a10c58a001076f7af910cd720596..182436b92ba93a95ca6e119108c30d50706b7212 100644 (file)
@@ -285,13 +285,15 @@ struct ib_umem *ib_alloc_odp_umem(struct ib_ucontext *context,
        mutex_init(&odp_data->umem_mutex);
        init_completion(&odp_data->notifier_completion);
 
-       odp_data->page_list = vzalloc(pages * sizeof(*odp_data->page_list));
+       odp_data->page_list =
+               vzalloc(array_size(pages, sizeof(*odp_data->page_list)));
        if (!odp_data->page_list) {
                ret = -ENOMEM;
                goto out_odp_data;
        }
 
-       odp_data->dma_list = vzalloc(pages * sizeof(*odp_data->dma_list));
+       odp_data->dma_list =
+               vzalloc(array_size(pages, sizeof(*odp_data->dma_list)));
        if (!odp_data->dma_list) {
                ret = -ENOMEM;
                goto out_page_list;
@@ -371,15 +373,17 @@ int ib_umem_odp_get(struct ib_ucontext *context, struct ib_umem *umem,
        init_completion(&umem->odp_data->notifier_completion);
 
        if (ib_umem_num_pages(umem)) {
-               umem->odp_data->page_list = vzalloc(ib_umem_num_pages(umem) *
-                                           sizeof(*umem->odp_data->page_list));
+               umem->odp_data->page_list =
+                       vzalloc(array_size(sizeof(*umem->odp_data->page_list),
+                                          ib_umem_num_pages(umem)));
                if (!umem->odp_data->page_list) {
                        ret_val = -ENOMEM;
                        goto out_odp_data;
                }
 
-               umem->odp_data->dma_list = vzalloc(ib_umem_num_pages(umem) *
-                                         sizeof(*umem->odp_data->dma_list));
+               umem->odp_data->dma_list =
+                       vzalloc(array_size(sizeof(*umem->odp_data->dma_list),
+                                          ib_umem_num_pages(umem)));
                if (!umem->odp_data->dma_list) {
                        ret_val = -ENOMEM;
                        goto out_page_list;
index 3179a95c6f5eae88fd5edfbcbade7fa09c8f32de..3e90b6a1d9d2d6a203d13d945e9322a9ec154fe8 100644 (file)
@@ -3559,8 +3559,8 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file,
                goto err_uobj;
        }
 
-       flow_attr = kzalloc(sizeof(*flow_attr) + cmd.flow_attr.num_of_specs *
-                           sizeof(union ib_flow_spec), GFP_KERNEL);
+       flow_attr = kzalloc(struct_size(flow_attr, flows,
+                               cmd.flow_attr.num_of_specs), GFP_KERNEL);
        if (!flow_attr) {
                err = -ENOMEM;
                goto err_put;
index 3328acc53c2aeaf892fa4e293e00b26dd96fd998..dcb4bba522ba001acb2e632bd8b184a8193193ea 100644 (file)
@@ -279,7 +279,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain,
        if (!wq->qpid)
                return -ENOMEM;
 
-       wq->rq = kzalloc(depth * sizeof(struct t3_swrq), GFP_KERNEL);
+       wq->rq = kcalloc(depth, sizeof(struct t3_swrq), GFP_KERNEL);
        if (!wq->rq)
                goto err1;
 
@@ -287,7 +287,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain,
        if (!wq->rq_addr)
                goto err2;
 
-       wq->sq = kzalloc(depth * sizeof(struct t3_swsq), GFP_KERNEL);
+       wq->sq = kcalloc(depth, sizeof(struct t3_swsq), GFP_KERNEL);
        if (!wq->sq)
                goto err3;
 
index 44161ca4d2a86d6dd3cdb96404877ef23cb4cb38..a3c3418afd737bae7a97126e23b77539024b8dd8 100644 (file)
@@ -859,8 +859,9 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
        rdev->status_page->cq_size = rdev->lldi.vr->cq.size;
 
        if (c4iw_wr_log) {
-               rdev->wr_log = kzalloc((1 << c4iw_wr_log_size_order) *
-                                      sizeof(*rdev->wr_log), GFP_KERNEL);
+               rdev->wr_log = kcalloc(1 << c4iw_wr_log_size_order,
+                                      sizeof(*rdev->wr_log),
+                                      GFP_KERNEL);
                if (rdev->wr_log) {
                        rdev->wr_log_size = 1 << c4iw_wr_log_size_order;
                        atomic_set(&rdev->wr_log_idx, 0);
@@ -1445,7 +1446,7 @@ static void recover_queues(struct uld_ctx *ctx)
        ctx->dev->db_state = RECOVERY;
        idr_for_each(&ctx->dev->qpidr, count_qps, &count);
 
-       qp_list.qps = kzalloc(count * sizeof *qp_list.qps, GFP_ATOMIC);
+       qp_list.qps = kcalloc(count, sizeof(*qp_list.qps), GFP_ATOMIC);
        if (!qp_list.qps) {
                spin_unlock_irq(&ctx->dev->lock);
                return;
index 5c2cfdea06ad766dbebda9c49792dce27919ceeb..724d23297b355ce02b150663cf6e2ddd5df59885 100644 (file)
@@ -92,8 +92,8 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num,
                alloc->last = 0;
        alloc->max  = num;
        spin_lock_init(&alloc->lock);
-       alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof(long),
-                               GFP_KERNEL);
+       alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long),
+                                    GFP_KERNEL);
        if (!alloc->table)
                return -ENOMEM;
 
index 4106eed1b8fbde8f438875e1502a91b98b37b6a1..aef53305f1c37f2dba46704866d18f799cc7c323 100644 (file)
@@ -216,15 +216,15 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
        }
 
        if (!user) {
-               wq->sq.sw_sq = kzalloc(wq->sq.size * sizeof *wq->sq.sw_sq,
-                                GFP_KERNEL);
+               wq->sq.sw_sq = kcalloc(wq->sq.size, sizeof(*wq->sq.sw_sq),
+                                      GFP_KERNEL);
                if (!wq->sq.sw_sq) {
                        ret = -ENOMEM;
                        goto free_rq_qid;
                }
 
-               wq->rq.sw_rq = kzalloc(wq->rq.size * sizeof *wq->rq.sw_rq,
-                                GFP_KERNEL);
+               wq->rq.sw_rq = kcalloc(wq->rq.size, sizeof(*wq->rq.sw_rq),
+                                      GFP_KERNEL);
                if (!wq->rq.sw_rq) {
                        ret = -ENOMEM;
                        goto free_sw_sq;
index 298e0e3fc0c9feff9dd707fe2837eb576037a0ff..7fb350b87b49a49c9377231caddd09e84b89fa8e 100644 (file)
@@ -1461,7 +1461,8 @@ int sdma_init(struct hfi1_devdata *dd, u8 port)
                if (!sde->descq)
                        goto bail;
                sde->tx_ring =
-                       kvzalloc_node(sizeof(struct sdma_txreq *) * descq_cnt,
+                       kvzalloc_node(array_size(descq_cnt,
+                                                sizeof(struct sdma_txreq *)),
                                      GFP_KERNEL, dd->node);
                if (!sde->tx_ring)
                        goto bail;
index 0e8dad68910ab47a4952b384faa9c501bcf4c48b..a6e11be0ea0fbee763fdf59186efe8e8be019cd5 100644 (file)
@@ -3177,7 +3177,7 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,
        struct device *dev = hr_dev->dev;
        int ret = -EINVAL;
 
-       context = kzalloc(2 * sizeof(*context), GFP_KERNEL);
+       context = kcalloc(2, sizeof(*context), GFP_KERNEL);
        if (!context)
                return -ENOMEM;
 
index d1fe0e7957e3623add18bcd67a18ef72f21c039f..eb26a5f6fc58c21c2cc3545b7047da0889db8e0a 100644 (file)
@@ -144,7 +144,7 @@ static int hns_roce_buddy_init(struct hns_roce_buddy *buddy, int max_order)
                buddy->bits[i] = kcalloc(s, sizeof(long), GFP_KERNEL |
                                         __GFP_NOWARN);
                if (!buddy->bits[i]) {
-                       buddy->bits[i] = vzalloc(s * sizeof(long));
+                       buddy->bits[i] = vzalloc(array_size(s, sizeof(long)));
                        if (!buddy->bits[i])
                                goto err_out_free;
                }
index d604b3d5aa3e4a7d21fc22a9a669b6fd299ec8f7..90a3e2642c2e11bd3f54e3d0e874c212aa3bb401 100644 (file)
@@ -1613,7 +1613,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 
        tun_qp = &ctx->qp[qp_type];
 
-       tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS,
+       tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
+                              sizeof(struct mlx4_ib_buf),
                               GFP_KERNEL);
        if (!tun_qp->ring)
                return -ENOMEM;
index f839bf3b1497a9e1414f9016973822288067765d..4ec519afc45b780812f08ad8acb3fd35f7b16c53 100644 (file)
@@ -302,7 +302,8 @@ static int mlx4_ib_add_gid(const union ib_gid *gid,
                ctx->refcount++;
        }
        if (!ret && hw_update) {
-               gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+               gids = kmalloc_array(MLX4_MAX_PORT_GIDS, sizeof(*gids),
+                                    GFP_ATOMIC);
                if (!gids) {
                        ret = -ENOMEM;
                } else {
@@ -355,7 +356,8 @@ static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context)
        if (!ret && hw_update) {
                int i;
 
-               gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
+               gids = kmalloc_array(MLX4_MAX_PORT_GIDS, sizeof(*gids),
+                                    GFP_ATOMIC);
                if (!gids) {
                        ret = -ENOMEM;
                } else {
@@ -2872,9 +2874,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
                        goto err_counter;
 
                ibdev->ib_uc_qpns_bitmap =
-                       kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
-                               sizeof(long),
-                               GFP_KERNEL);
+                       kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
+                                     sizeof(long),
+                                     GFP_KERNEL);
                if (!ibdev->ib_uc_qpns_bitmap)
                        goto err_steer_qp_release;
 
index cd2c08c4533455f94d7a8d82ce6e51ccf83500b9..3b8045fd23ed67634db1541b4a165a5c820b45fc 100644 (file)
@@ -573,8 +573,8 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
        int i;
 
        qp->sqp_proxy_rcv =
-               kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
-                       GFP_KERNEL);
+               kmalloc_array(qp->rq.wqe_cnt, sizeof(struct mlx4_ib_buf),
+                             GFP_KERNEL);
        if (!qp->sqp_proxy_rcv)
                return -ENOMEM;
        for (i = 0; i < qp->rq.wqe_cnt; i++) {
index 3c7522d025f2b559f638fd2bde05200702488dde..0af7b7905550baddb5084d99293e9a36196eb6b3 100644 (file)
@@ -127,7 +127,7 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq,
                goto err_umem;
        }
 
-       in->pas = kvzalloc(sizeof(*in->pas) * ncont, GFP_KERNEL);
+       in->pas = kvcalloc(ncont, sizeof(*in->pas), GFP_KERNEL);
        if (!in->pas) {
                err = -ENOMEM;
                goto err_umem;
@@ -189,7 +189,7 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq,
        }
 
        mlx5_ib_dbg(dev, "srq->buf.page_shift = %d\n", srq->buf.page_shift);
-       in->pas = kvzalloc(sizeof(*in->pas) * srq->buf.npages, GFP_KERNEL);
+       in->pas = kvcalloc(srq->buf.npages, sizeof(*in->pas), GFP_KERNEL);
        if (!in->pas) {
                err = -ENOMEM;
                goto err_buf;
index b4e0cf4e95cd41ec224c75b72d8ae425d2f83339..aaf10dd5364d44c80b1e9767d0d2a36b8aec0280 100644 (file)
@@ -90,8 +90,8 @@ int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
        alloc->max  = num;
        alloc->mask = mask;
        spin_lock_init(&alloc->lock);
-       alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof (long),
-                              GFP_KERNEL);
+       alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long),
+                                    GFP_KERNEL);
        if (!alloc->table)
                return -ENOMEM;
 
@@ -162,7 +162,8 @@ int mthca_array_init(struct mthca_array *array, int nent)
        int npage = (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE;
        int i;
 
-       array->page_list = kmalloc(npage * sizeof *array->page_list, GFP_KERNEL);
+       array->page_list = kmalloc_array(npage, sizeof(*array->page_list),
+                                        GFP_KERNEL);
        if (!array->page_list)
                return -ENOMEM;
 
@@ -220,7 +221,8 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
                        npages *= 2;
                }
 
-               dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
+               dma_list = kmalloc_array(npages, sizeof(*dma_list),
+                                        GFP_KERNEL);
                if (!dma_list)
                        goto err_free;
 
@@ -231,12 +233,14 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
                npages     = (size + PAGE_SIZE - 1) / PAGE_SIZE;
                shift      = PAGE_SHIFT;
 
-               dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
+               dma_list = kmalloc_array(npages, sizeof(*dma_list),
+                                        GFP_KERNEL);
                if (!dma_list)
                        return -ENOMEM;
 
-               buf->page_list = kmalloc(npages * sizeof *buf->page_list,
-                                        GFP_KERNEL);
+               buf->page_list = kmalloc_array(npages,
+                                              sizeof(*buf->page_list),
+                                              GFP_KERNEL);
                if (!buf->page_list)
                        goto err_out;
 
index 419a2a20c0470b72ac95819730dab7e8d92129cd..83aa47eb81a9274110ddb82101c552da32e299d9 100644 (file)
@@ -565,9 +565,9 @@ int mthca_cmd_use_events(struct mthca_dev *dev)
 {
        int i;
 
-       dev->cmd.context = kmalloc(dev->cmd.max_cmds *
-                                  sizeof (struct mthca_cmd_context),
-                                  GFP_KERNEL);
+       dev->cmd.context = kmalloc_array(dev->cmd.max_cmds,
+                                        sizeof(struct mthca_cmd_context),
+                                        GFP_KERNEL);
        if (!dev->cmd.context)
                return -ENOMEM;
 
index 69020173899397ee5889287ee79f0c3525ab8991..30400ea4808b62d1bdd37cc2fcde48b344230f8c 100644 (file)
@@ -479,15 +479,15 @@ static int mthca_create_eq(struct mthca_dev *dev,
        eq->nent = roundup_pow_of_two(max(nent, 2));
        npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE;
 
-       eq->page_list = kmalloc(npages * sizeof *eq->page_list,
-                               GFP_KERNEL);
+       eq->page_list = kmalloc_array(npages, sizeof(*eq->page_list),
+                                     GFP_KERNEL);
        if (!eq->page_list)
                goto err_out;
 
        for (i = 0; i < npages; ++i)
                eq->page_list[i].buf = NULL;
 
-       dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
+       dma_list = kmalloc_array(npages, sizeof(*dma_list), GFP_KERNEL);
        if (!dma_list)
                goto err_out_free;
 
index 7a31be3c3e733a26b8e139ccd11a0d56601cc7b6..cc9c0c8ccba3c10154035045bb43f230f8e19009 100644 (file)
@@ -712,9 +712,9 @@ int mthca_init_db_tab(struct mthca_dev *dev)
        dev->db_tab->max_group1 = 0;
        dev->db_tab->min_group2 = dev->db_tab->npages - 1;
 
-       dev->db_tab->page = kmalloc(dev->db_tab->npages *
-                                   sizeof *dev->db_tab->page,
-                                   GFP_KERNEL);
+       dev->db_tab->page = kmalloc_array(dev->db_tab->npages,
+                                         sizeof(*dev->db_tab->page),
+                                         GFP_KERNEL);
        if (!dev->db_tab->page) {
                kfree(dev->db_tab);
                return -ENOMEM;
index ed9a989e501b4f7fa4f42431b696c89ccd972776..6686042aafb4065de1372526766ffd9871349e60 100644 (file)
@@ -144,7 +144,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
        buddy->max_order = max_order;
        spin_lock_init(&buddy->lock);
 
-       buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *),
+       buddy->bits = kcalloc(buddy->max_order + 1, sizeof(long *),
                              GFP_KERNEL);
        buddy->num_free = kcalloc((buddy->max_order + 1), sizeof *buddy->num_free,
                                  GFP_KERNEL);
@@ -153,7 +153,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
 
        for (i = 0; i <= buddy->max_order; ++i) {
                s = BITS_TO_LONGS(1 << (buddy->max_order - i));
-               buddy->bits[i] = kmalloc(s * sizeof (long), GFP_KERNEL);
+               buddy->bits[i] = kmalloc_array(s, sizeof(long), GFP_KERNEL);
                if (!buddy->bits[i])
                        goto err_out_free;
                bitmap_zero(buddy->bits[i],
index 15d064479ef6c5347f48ef804aa380a0c5eadb0f..7ea970774839a52e39de4eae89bcc06261012e9c 100644 (file)
@@ -79,7 +79,7 @@ s64 mthca_make_profile(struct mthca_dev *dev,
        struct mthca_resource *profile;
        int i, j;
 
-       profile = kzalloc(MTHCA_RES_NUM * sizeof *profile, GFP_KERNEL);
+       profile = kcalloc(MTHCA_RES_NUM, sizeof(*profile), GFP_KERNEL);
        if (!profile)
                return -ENOMEM;
 
index d21960cd9a49c1f4ad8c5067bc01ba3709f0d073..af1c49d70b899445106df0ff3f0b8107e25415f0 100644 (file)
@@ -1054,8 +1054,8 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
        size = PAGE_ALIGN(qp->send_wqe_offset +
                          (qp->sq.max << qp->sq.wqe_shift));
 
-       qp->wrid = kmalloc((qp->rq.max + qp->sq.max) * sizeof (u64),
-                          GFP_KERNEL);
+       qp->wrid = kmalloc_array(qp->rq.max + qp->sq.max, sizeof(u64),
+                                GFP_KERNEL);
        if (!qp->wrid)
                goto err_out;
 
index d22f970480c0ee7425eee40c87c9fde3112665cb..f79732bc73b4bf95c4d2215fae71a762458462ee 100644 (file)
@@ -155,7 +155,7 @@ static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd,
        if (pd->ibpd.uobject)
                return 0;
 
-       srq->wrid = kmalloc(srq->max * sizeof (u64), GFP_KERNEL);
+       srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL);
        if (!srq->wrid)
                return -ENOMEM;
 
index 21e0ebd39a0555e3114360163d9fd53b84ab2dce..9bdb84dc225cfe9763541f271ccfdabd42e77716 100644 (file)
@@ -878,7 +878,8 @@ int nes_init_mgt_qp(struct nes_device *nesdev, struct net_device *netdev, struct
        int ret;
 
        /* Allocate space the all mgt QPs once */
-       mgtvnic = kzalloc(NES_MGT_QP_COUNT * sizeof(struct nes_vnic_mgt), GFP_KERNEL);
+       mgtvnic = kcalloc(NES_MGT_QP_COUNT, sizeof(struct nes_vnic_mgt),
+                         GFP_KERNEL);
        if (!mgtvnic)
                return -ENOMEM;
 
index 007d5e8a0121eb6485a9666d1e98ee3581b34c0f..61014e2515558241391430cd9b84d11786116ee4 100644 (file)
@@ -904,7 +904,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
                int i;
                struct netdev_hw_addr *ha;
 
-               addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
+               addrs = kmalloc_array(mc_count, ETH_ALEN, GFP_ATOMIC);
                if (!addrs) {
                        set_allmulti(nesdev, nic_active_bit);
                        goto unlock;
index 1040a6e34230d4cf2a4be130e25ef6c808f0c8fd..32f26556c808016f2d6f68f975a502724b714084 100644 (file)
@@ -2254,8 +2254,9 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
                                                                ibmr = ERR_PTR(-ENOMEM);
                                                                goto reg_user_mr_err;
                                                        }
-                                                       root_vpbl.leaf_vpbl = kzalloc(sizeof(*root_vpbl.leaf_vpbl)*1024,
-                                                                       GFP_KERNEL);
+                                                       root_vpbl.leaf_vpbl = kcalloc(1024,
+                                                                                     sizeof(*root_vpbl.leaf_vpbl),
+                                                                                     GFP_KERNEL);
                                                        if (!root_vpbl.leaf_vpbl) {
                                                                ib_umem_release(region);
                                                                pci_free_consistent(nesdev->pcidev, 8192, root_vpbl.pbl_vbase,
index 2c260e1c29d16f425cf2b9d654ff17bc73460e5e..6c136e5017fe7eeebfbc2e7a013cbdcf12978623 100644 (file)
@@ -3096,7 +3096,7 @@ static int ocrdma_create_eqs(struct ocrdma_dev *dev)
        if (!num_eq)
                return -EINVAL;
 
-       dev->eq_tbl = kzalloc(sizeof(struct ocrdma_eq) * num_eq, GFP_KERNEL);
+       dev->eq_tbl = kcalloc(num_eq, sizeof(struct ocrdma_eq), GFP_KERNEL);
        if (!dev->eq_tbl)
                return -ENOMEM;
 
index eb8b6a935016e4bfd8fac97c8bad28ef8a7fa8ce..5962c0ed984781d3a4c023b27adbe5fbb036d7e0 100644 (file)
@@ -221,19 +221,20 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)
 static int ocrdma_alloc_resources(struct ocrdma_dev *dev)
 {
        mutex_init(&dev->dev_lock);
-       dev->cq_tbl = kzalloc(sizeof(struct ocrdma_cq *) *
-                             OCRDMA_MAX_CQ, GFP_KERNEL);
+       dev->cq_tbl = kcalloc(OCRDMA_MAX_CQ, sizeof(struct ocrdma_cq *),
+                             GFP_KERNEL);
        if (!dev->cq_tbl)
                goto alloc_err;
 
        if (dev->attr.max_qp) {
-               dev->qp_tbl = kzalloc(sizeof(struct ocrdma_qp *) *
-                                     OCRDMA_MAX_QP, GFP_KERNEL);
+               dev->qp_tbl = kcalloc(OCRDMA_MAX_QP,
+                                     sizeof(struct ocrdma_qp *),
+                                     GFP_KERNEL);
                if (!dev->qp_tbl)
                        goto alloc_err;
        }
 
-       dev->stag_arr = kzalloc(sizeof(u64) * OCRDMA_MAX_STAG, GFP_KERNEL);
+       dev->stag_arr = kcalloc(OCRDMA_MAX_STAG, sizeof(u64), GFP_KERNEL);
        if (dev->stag_arr == NULL)
                goto alloc_err;
 
index 784ed6b09a469e6526b7049037b248be65786837..82e20fc32890eca3fcc25729f6887fee9399fbad 100644 (file)
@@ -843,8 +843,8 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr)
        void *va;
        dma_addr_t pa;
 
-       mr->pbl_table = kzalloc(sizeof(struct ocrdma_pbl) *
-                               mr->num_pbls, GFP_KERNEL);
+       mr->pbl_table = kcalloc(mr->num_pbls, sizeof(struct ocrdma_pbl),
+                               GFP_KERNEL);
 
        if (!mr->pbl_table)
                return -ENOMEM;
@@ -1323,12 +1323,12 @@ static void ocrdma_set_qp_db(struct ocrdma_dev *dev, struct ocrdma_qp *qp,
 static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp)
 {
        qp->wqe_wr_id_tbl =
-           kzalloc(sizeof(*(qp->wqe_wr_id_tbl)) * qp->sq.max_cnt,
+           kcalloc(qp->sq.max_cnt, sizeof(*(qp->wqe_wr_id_tbl)),
                    GFP_KERNEL);
        if (qp->wqe_wr_id_tbl == NULL)
                return -ENOMEM;
        qp->rqe_wr_id_tbl =
-           kzalloc(sizeof(u64) * qp->rq.max_cnt, GFP_KERNEL);
+           kcalloc(qp->rq.max_cnt, sizeof(u64), GFP_KERNEL);
        if (qp->rqe_wr_id_tbl == NULL)
                return -ENOMEM;
 
@@ -1865,15 +1865,16 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd,
 
        if (udata == NULL) {
                status = -ENOMEM;
-               srq->rqe_wr_id_tbl = kzalloc(sizeof(u64) * srq->rq.max_cnt,
-                           GFP_KERNEL);
+               srq->rqe_wr_id_tbl = kcalloc(srq->rq.max_cnt, sizeof(u64),
+                                            GFP_KERNEL);
                if (srq->rqe_wr_id_tbl == NULL)
                        goto arm_err;
 
                srq->bit_fields_len = (srq->rq.max_cnt / 32) +
                    (srq->rq.max_cnt % 32 ? 1 : 0);
                srq->idx_bit_fields =
-                   kmalloc(srq->bit_fields_len * sizeof(u32), GFP_KERNEL);
+                   kmalloc_array(srq->bit_fields_len, sizeof(u32),
+                                 GFP_KERNEL);
                if (srq->idx_bit_fields == NULL)
                        goto arm_err;
                memset(srq->idx_bit_fields, 0xff,
index f4cb60b658ea7712592fc1e704cce84d50286630..ad22b32bbd9ce92a9769fecc049c0138f2c10fde 100644 (file)
@@ -317,8 +317,8 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
        u16 n_entries;
        int i, rc;
 
-       dev->sgid_tbl = kzalloc(sizeof(union ib_gid) *
-                               QEDR_MAX_SGID, GFP_KERNEL);
+       dev->sgid_tbl = kcalloc(QEDR_MAX_SGID, sizeof(union ib_gid),
+                               GFP_KERNEL);
        if (!dev->sgid_tbl)
                return -ENOMEM;
 
index 710032f1fad7ece2714b271808e50de2c5930c29..f7ac8fc9b531d7550fb0b41233b55e0bec51b4ff 100644 (file)
@@ -1614,7 +1614,7 @@ static int qedr_create_kernel_qp(struct qedr_dev *dev,
        qp->sq.max_wr = min_t(u32, attrs->cap.max_send_wr * dev->wq_multiplier,
                              dev->attr.max_sqe);
 
-       qp->wqe_wr_id = kzalloc(qp->sq.max_wr * sizeof(*qp->wqe_wr_id),
+       qp->wqe_wr_id = kcalloc(qp->sq.max_wr, sizeof(*qp->wqe_wr_id),
                                GFP_KERNEL);
        if (!qp->wqe_wr_id) {
                DP_ERR(dev, "create qp: failed SQ shadow memory allocation\n");
@@ -1632,7 +1632,7 @@ static int qedr_create_kernel_qp(struct qedr_dev *dev,
        qp->rq.max_wr = (u16) max_t(u32, attrs->cap.max_recv_wr, 1);
 
        /* Allocate driver internal RQ array */
-       qp->rqe_wr_id = kzalloc(qp->rq.max_wr * sizeof(*qp->rqe_wr_id),
+       qp->rqe_wr_id = kcalloc(qp->rq.max_wr, sizeof(*qp->rqe_wr_id),
                                GFP_KERNEL);
        if (!qp->rqe_wr_id) {
                DP_ERR(dev,
index 8a15e5c7dd912fc8f7d51c51a98a1d9d9ae8870c..fb1ff59f40bd61a3a20e724d45e996be33fb6b0b 100644 (file)
@@ -2496,15 +2496,16 @@ static void init_6120_cntrnames(struct qib_devdata *dd)
                dd->cspec->cntrnamelen = sizeof(cntr6120names) - 1;
        else
                dd->cspec->cntrnamelen = 1 + s - cntr6120names;
-       dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
-               * sizeof(u64), GFP_KERNEL);
+       dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
+                                        GFP_KERNEL);
 
        for (i = 0, s = (char *)portcntr6120names; s; i++)
                s = strchr(s + 1, '\n');
        dd->cspec->nportcntrs = i - 1;
        dd->cspec->portcntrnamelen = sizeof(portcntr6120names) - 1;
-       dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs
-               * sizeof(u64), GFP_KERNEL);
+       dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs,
+                                            sizeof(u64),
+                                            GFP_KERNEL);
 }
 
 static u32 qib_read_6120cntrs(struct qib_devdata *dd, loff_t pos, char **namep,
index bdff2326731e722c9c7fd1d5f4d863bdbdb133e3..163a57a88742891f88748a4ffdf2cfe15a83b38a 100644 (file)
@@ -3147,15 +3147,16 @@ static void init_7220_cntrnames(struct qib_devdata *dd)
                dd->cspec->cntrnamelen = sizeof(cntr7220names) - 1;
        else
                dd->cspec->cntrnamelen = 1 + s - cntr7220names;
-       dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
-               * sizeof(u64), GFP_KERNEL);
+       dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
+                                        GFP_KERNEL);
 
        for (i = 0, s = (char *)portcntr7220names; s; i++)
                s = strchr(s + 1, '\n');
        dd->cspec->nportcntrs = i - 1;
        dd->cspec->portcntrnamelen = sizeof(portcntr7220names) - 1;
-       dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs
-               * sizeof(u64), GFP_KERNEL);
+       dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs,
+                                            sizeof(u64),
+                                            GFP_KERNEL);
 }
 
 static u32 qib_read_7220cntrs(struct qib_devdata *dd, loff_t pos, char **namep,
index 8414ae44a5185b852899d186e701ec3b023b90ae..bf5e222eed8e61fcc66a7d59e9aed89e603f1c17 100644 (file)
@@ -3648,8 +3648,9 @@ static int qib_do_7322_reset(struct qib_devdata *dd)
 
        if (msix_entries) {
                /* can be up to 512 bytes, too big for stack */
-               msix_vecsave = kmalloc(2 * dd->cspec->num_msix_entries *
-                       sizeof(u64), GFP_KERNEL);
+               msix_vecsave = kmalloc_array(2 * dd->cspec->num_msix_entries,
+                                            sizeof(u64),
+                                            GFP_KERNEL);
        }
 
        /*
@@ -5009,16 +5010,17 @@ static void init_7322_cntrnames(struct qib_devdata *dd)
                dd->cspec->cntrnamelen = sizeof(cntr7322names) - 1;
        else
                dd->cspec->cntrnamelen = 1 + s - cntr7322names;
-       dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
-               * sizeof(u64), GFP_KERNEL);
+       dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
+                                        GFP_KERNEL);
 
        for (i = 0, s = (char *)portcntr7322names; s; i++)
                s = strchr(s + 1, '\n');
        dd->cspec->nportcntrs = i - 1;
        dd->cspec->portcntrnamelen = sizeof(portcntr7322names) - 1;
        for (i = 0; i < dd->num_pports; ++i) {
-               dd->pport[i].cpspec->portcntrs = kmalloc(dd->cspec->nportcntrs
-                       * sizeof(u64), GFP_KERNEL);
+               dd->pport[i].cpspec->portcntrs =
+                       kmalloc_array(dd->cspec->nportcntrs, sizeof(u64),
+                                     GFP_KERNEL);
        }
 }
 
@@ -6412,12 +6414,15 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
        sbufcnt = dd->piobcnt2k + dd->piobcnt4k +
                NUM_VL15_BUFS + BITS_PER_LONG - 1;
        sbufcnt /= BITS_PER_LONG;
-       dd->cspec->sendchkenable = kmalloc(sbufcnt *
-               sizeof(*dd->cspec->sendchkenable), GFP_KERNEL);
-       dd->cspec->sendgrhchk = kmalloc(sbufcnt *
-               sizeof(*dd->cspec->sendgrhchk), GFP_KERNEL);
-       dd->cspec->sendibchk = kmalloc(sbufcnt *
-               sizeof(*dd->cspec->sendibchk), GFP_KERNEL);
+       dd->cspec->sendchkenable =
+               kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendchkenable),
+                             GFP_KERNEL);
+       dd->cspec->sendgrhchk =
+               kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendgrhchk),
+                             GFP_KERNEL);
+       dd->cspec->sendibchk =
+               kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendibchk),
+                             GFP_KERNEL);
        if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk ||
                !dd->cspec->sendibchk) {
                ret = -ENOMEM;
@@ -7290,8 +7295,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev,
                actual_cnt -= dd->num_pports;
 
        tabsize = actual_cnt;
-       dd->cspec->msix_entries = kzalloc(tabsize *
-                       sizeof(struct qib_msix_entry), GFP_KERNEL);
+       dd->cspec->msix_entries = kcalloc(tabsize,
+                                         sizeof(struct qib_msix_entry),
+                                         GFP_KERNEL);
        if (!dd->cspec->msix_entries)
                tabsize = 0;
 
index 0155202897352e4eb52d93883e9806218e9f972f..d7cdc77d630648f16edaba49d421d209d071c398 100644 (file)
@@ -369,11 +369,13 @@ static void init_shadow_tids(struct qib_devdata *dd)
        struct page **pages;
        dma_addr_t *addrs;
 
-       pages = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *));
+       pages = vzalloc(array_size(sizeof(struct page *),
+                                  dd->cfgctxts * dd->rcvtidcnt));
        if (!pages)
                goto bail;
 
-       addrs = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t));
+       addrs = vzalloc(array_size(sizeof(dma_addr_t),
+                                  dd->cfgctxts * dd->rcvtidcnt));
        if (!addrs)
                goto bail_free;
 
@@ -1134,8 +1136,8 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
        if (!qib_cpulist_count) {
                u32 count = num_online_cpus();
 
-               qib_cpulist = kzalloc(BITS_TO_LONGS(count) *
-                                     sizeof(long), GFP_KERNEL);
+               qib_cpulist = kcalloc(BITS_TO_LONGS(count), sizeof(long),
+                                     GFP_KERNEL);
                if (qib_cpulist)
                        qib_cpulist_count = count;
        }
@@ -1673,8 +1675,8 @@ int qib_setup_eagerbufs(struct qib_ctxtdata *rcd)
        size = rcd->rcvegrbuf_size;
        if (!rcd->rcvegrbuf) {
                rcd->rcvegrbuf =
-                       kzalloc_node(chunk * sizeof(rcd->rcvegrbuf[0]),
-                               GFP_KERNEL, rcd->node_id);
+                       kcalloc_node(chunk, sizeof(rcd->rcvegrbuf[0]),
+                                    GFP_KERNEL, rcd->node_id);
                if (!rcd->rcvegrbuf)
                        goto bail;
        }
index 912d8ef043521fadd38a50ffbf4a1c5763cc69fd..bf5136533d4972684e2db3556fa89d355bd6ba0b 100644 (file)
@@ -543,7 +543,7 @@ alloc_res_chunk_list(struct usnic_vnic *vnic,
                /* Do Nothing */
        }
 
-       res_chunk_list = kzalloc(sizeof(*res_chunk_list)*(res_lst_sz+1),
+       res_chunk_list = kcalloc(res_lst_sz + 1, sizeof(*res_chunk_list),
                                        GFP_ATOMIC);
        if (!res_chunk_list)
                return ERR_PTR(-ENOMEM);
index e7b0030254da61930a433b553676a0bf46feef6b..ebe08f348453d57046097fe1b28e20370431ce1d 100644 (file)
@@ -312,7 +312,7 @@ static int usnic_vnic_alloc_res_chunk(struct usnic_vnic *vnic,
        }
 
        chunk->cnt = chunk->free_cnt = cnt;
-       chunk->res = kzalloc(sizeof(*(chunk->res))*cnt, GFP_KERNEL);
+       chunk->res = kcalloc(cnt, sizeof(*(chunk->res)), GFP_KERNEL);
        if (!chunk->res)
                return -ENOMEM;
 
index 40046135c50991fb3af581c4308697ed676ccff4..41183bd665ca1d7a0f6d6cb8d33c7867c58f758e 100644 (file)
@@ -813,7 +813,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
                sz = sizeof(struct rvt_sge) *
                        init_attr->cap.max_send_sge +
                        sizeof(struct rvt_swqe);
-               swq = vzalloc_node(sqsize * sz, rdi->dparms.node);
+               swq = vzalloc_node(array_size(sz, sqsize), rdi->dparms.node);
                if (!swq)
                        return ERR_PTR(-ENOMEM);
 
@@ -836,11 +836,10 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd,
                RCU_INIT_POINTER(qp->next, NULL);
                if (init_attr->qp_type == IB_QPT_RC) {
                        qp->s_ack_queue =
-                               kzalloc_node(
-                                       sizeof(*qp->s_ack_queue) *
-                                        rvt_max_atomic(rdi),
-                                       GFP_KERNEL,
-                                       rdi->dparms.node);
+                               kcalloc_node(rvt_max_atomic(rdi),
+                                            sizeof(*qp->s_ack_queue),
+                                            GFP_KERNEL,
+                                            rdi->dparms.node);
                        if (!qp->s_ack_queue)
                                goto bail_qp;
                }
index 962fbcb57dc7fe3034c83d1e1cb75144aa27ca23..6535d9beb24d29675ec8c6c513909a2ee0e6332d 100644 (file)
@@ -358,7 +358,8 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i
        int ret;
        int i;
 
-       rx->rx_ring = vzalloc(ipoib_recvq_size * sizeof *rx->rx_ring);
+       rx->rx_ring = vzalloc(array_size(ipoib_recvq_size,
+                                        sizeof(*rx->rx_ring)));
        if (!rx->rx_ring)
                return -ENOMEM;
 
@@ -1145,7 +1146,7 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn,
        int ret;
 
        noio_flag = memalloc_noio_save();
-       p->tx_ring = vzalloc(ipoib_sendq_size * sizeof(*p->tx_ring));
+       p->tx_ring = vzalloc(array_size(ipoib_sendq_size, sizeof(*p->tx_ring)));
        if (!p->tx_ring) {
                memalloc_noio_restore(noio_flag);
                ret = -ENOMEM;
@@ -1570,7 +1571,8 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge)
                return;
        }
 
-       priv->cm.srq_ring = vzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring);
+       priv->cm.srq_ring = vzalloc(array_size(ipoib_recvq_size,
+                                              sizeof(*priv->cm.srq_ring)));
        if (!priv->cm.srq_ring) {
                ib_destroy_srq(priv->cm.srq);
                priv->cm.srq = NULL;
index 2ce40a7ff6040b7c2fc73466361a8fdc75f119b9..26cde95bc0f30dcc418a7abb954f730965692cac 100644 (file)
@@ -1526,7 +1526,7 @@ static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv)
                return -ENOMEM;
        set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags);
        size = roundup_pow_of_two(arp_tbl.gc_thresh3);
-       buckets = kzalloc(size * sizeof(*buckets), GFP_KERNEL);
+       buckets = kcalloc(size, sizeof(*buckets), GFP_KERNEL);
        if (!buckets) {
                kfree(htbl);
                return -ENOMEM;
@@ -1704,12 +1704,14 @@ static int ipoib_dev_init_default(struct net_device *dev)
        ipoib_napi_add(dev);
 
        /* Allocate RX/TX "rings" to hold queued skbs */
-       priv->rx_ring = kzalloc(ipoib_recvq_size * sizeof *priv->rx_ring,
-                               GFP_KERNEL);
+       priv->rx_ring = kcalloc(ipoib_recvq_size,
+                                      sizeof(*priv->rx_ring),
+                                      GFP_KERNEL);
        if (!priv->rx_ring)
                goto out;
 
-       priv->tx_ring = vzalloc(ipoib_sendq_size * sizeof *priv->tx_ring);
+       priv->tx_ring = vzalloc(array_size(ipoib_sendq_size,
+                                          sizeof(*priv->tx_ring)));
        if (!priv->tx_ring) {
                pr_warn("%s: failed to allocate TX ring (%d entries)\n",
                        priv->ca->name, ipoib_sendq_size);
index ca858d6bd37af66e5950bfeac041357506a9dd5b..2f6388596f886c262222ec8feefefca23b83b1db 100644 (file)
@@ -258,8 +258,9 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
                goto alloc_login_buf_fail;
 
        iser_conn->num_rx_descs = session->cmds_max;
-       iser_conn->rx_descs = kmalloc(iser_conn->num_rx_descs *
-                               sizeof(struct iser_rx_desc), GFP_KERNEL);
+       iser_conn->rx_descs = kmalloc_array(iser_conn->num_rx_descs,
+                                           sizeof(struct iser_rx_desc),
+                                           GFP_KERNEL);
        if (!iser_conn->rx_descs)
                goto rx_desc_alloc_fail;
 
index f2f9318e1f498db33cd47e45fc591a1274c9a4dc..cccbcf0eb035a31124066c21ae4de7e525055aaf 100644 (file)
@@ -181,8 +181,9 @@ isert_alloc_rx_descriptors(struct isert_conn *isert_conn)
        u64 dma_addr;
        int i, j;
 
-       isert_conn->rx_descs = kzalloc(ISERT_QP_MAX_RECV_DTOS *
-                               sizeof(struct iser_rx_desc), GFP_KERNEL);
+       isert_conn->rx_descs = kcalloc(ISERT_QP_MAX_RECV_DTOS,
+                                      sizeof(struct iser_rx_desc),
+                                      GFP_KERNEL);
        if (!isert_conn->rx_descs)
                return -ENOMEM;
 
index c35d2cd37d708f23fdc020b9f443553eb54b5db7..9786b24b956fcde94acb16608853341216f018a0 100644 (file)
@@ -1035,16 +1035,17 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
 
        for (i = 0; i < target->req_ring_size; ++i) {
                req = &ch->req_ring[i];
-               mr_list = kmalloc(target->mr_per_cmd * sizeof(void *),
-                                 GFP_KERNEL);
+               mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *),
+                                       GFP_KERNEL);
                if (!mr_list)
                        goto out;
                if (srp_dev->use_fast_reg) {
                        req->fr_list = mr_list;
                } else {
                        req->fmr_list = mr_list;
-                       req->map_page = kmalloc(srp_dev->max_pages_per_mr *
-                                               sizeof(void *), GFP_KERNEL);
+                       req->map_page = kmalloc_array(srp_dev->max_pages_per_mr,
+                                                     sizeof(void *),
+                                                     GFP_KERNEL);
                        if (!req->map_page)
                                goto out;
                }
index dfec0e1fac29e9f4e85d17dd4cd66347ec5013a3..3081c629a7f79730e319504fd72fa4e92f66debf 100644 (file)
@@ -720,7 +720,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
        WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx)
                && ioctx_size != sizeof(struct srpt_send_ioctx));
 
-       ring = kmalloc(ring_size * sizeof(ring[0]), GFP_KERNEL);
+       ring = kmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
        if (!ring)
                goto out;
        for (i = 0; i < ring_size; ++i) {
index ff80377987795df3bdd3755e55806499ea54d6d2..c5992cd195a118fdcec03944d9f326bb487bfd42 100644 (file)
@@ -16,7 +16,7 @@ config INPUT
 
          Say N here if you have a headless (no monitor, no keyboard) system.
 
-         More information is available: <file:Documentation/input/input.txt>
+         More information is available: <file:Documentation/input/input.rst>
 
          If unsure, say Y.
 
@@ -144,7 +144,7 @@ config INPUT_JOYDEV
 
          If unsure, say Y.
 
-         More information is available: <file:Documentation/input/joystick.txt>
+         More information is available: <file:Documentation/input/joydev/joystick.rst>
 
          To compile this driver as a module, choose M here: the
          module will be called joydev.
index 9591fc04a8ab203a0b514834c09f40697d0ccc7f..d8f9c6e1fc08b58f8a1dfb75e8d79e27301ed5a6 100644 (file)
@@ -9,7 +9,7 @@ menuconfig INPUT_JOYSTICK
          and the list of supported devices will be displayed. This option
          doesn't affect the kernel.
 
-         Please read the file <file:Documentation/input/joystick.txt> which
+         Please read the file <file:Documentation/input/joydev/joystick.rst> which
          contains more information.
 
 if INPUT_JOYSTICK
@@ -25,7 +25,7 @@ config JOYSTICK_ANALOG
          Flightstick Pro, ThrustMaster FCS, 6 and 8 button gamepads, or
          Saitek Cyborg joysticks.
 
-         Please read the file <file:Documentation/input/joystick.txt> which
+         Please read the file <file:Documentation/input/joydev/joystick.rst> which
          contains more information.
 
          To compile this driver as a module, choose M here: the
@@ -214,7 +214,7 @@ config JOYSTICK_DB9
          gamepad, Sega Saturn gamepad, or a Multisystem -- Atari, Amiga,
          Commodore, Amstrad CPC joystick connected to your parallel port.
          For more information on how to use the driver please read
-         <file:Documentation/input/joystick-parport.txt>.
+         <file:Documentation/input/devices/joystick-parport.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called db9.
@@ -229,7 +229,7 @@ config JOYSTICK_GAMECON
          Sony PlayStation gamepad or a Multisystem -- Atari, Amiga,
          Commodore, Amstrad CPC joystick connected to your parallel port.
          For more information on how to use the driver please read
-         <file:Documentation/input/joystick-parport.txt>.
+         <file:Documentation/input/devices/joystick-parport.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called gamecon.
@@ -241,7 +241,7 @@ config JOYSTICK_TURBOGRAFX
          Say Y here if you have the TurboGraFX interface by Steffen Schwenke,
          and want to use it with Multisystem -- Atari, Amiga, Commodore,
          Amstrad CPC joystick. For more information on how to use the driver
-         please read <file:Documentation/input/joystick-parport.txt>.
+         please read <file:Documentation/input/devices/joystick-parport.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called turbografx.
@@ -287,7 +287,7 @@ config JOYSTICK_XPAD
          and/or "Event interface support" (CONFIG_INPUT_EVDEV) as well.
 
          For information about how to connect the X-Box pad to USB, see
-         <file:Documentation/input/xpad.txt>.
+         <file:Documentation/input/devices/xpad.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called xpad.
@@ -313,7 +313,7 @@ config JOYSTICK_WALKERA0701
          Say Y or M here if you have a Walkera WK-0701 transmitter which is
          supplied with a ready to fly Walkera helicopters such as HM36,
          HM37, HM60 and want to use it via parport as a joystick. More
-         information is available: <file:Documentation/input/walkera0701.txt>
+         information is available: <file:Documentation/input/devices/walkera0701.rst>
 
          To compile this driver as a module, choose M here: the
          module will be called walkera0701.
index 8fde22a021b31351d6d6dc5498b62a86b6e0c537..ab4dbcbcbf50b4ef42450df75446f6d2e35e512d 100644 (file)
@@ -27,6 +27,6 @@ config JOYSTICK_IFORCE_232
          connected to your serial (COM) port.
 
          You will need an additional utility called inputattach, see
-         <file:Documentation/input/joystick.txt>
-         and <file:Documentation/input/ff.txt>.
+         <file:Documentation/input/joydev/joystick.rst>
+         and <file:Documentation/input/ff.rst>.
 
index d1c6e4846a4acd7ab16307f9bc7b56074e8b58dc..7f4dff9a566ffd1a4c2a51fb10169e698b8aa7ff 100644 (file)
@@ -80,7 +80,7 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr
 
        timeout = gameport_time(gameport, 10000); /* 10 ms */
 
-       buf = kmalloc(BUF_SIZE * sizeof(struct joydump), GFP_KERNEL);
+       buf = kmalloc_array(BUF_SIZE, sizeof(struct joydump), GFP_KERNEL);
        if (!buf) {
                printk(KERN_INFO "joydump: no memory for testing\n");
                goto jd_end;
index 36a5b93156ed88b048159f4bc02ddc9d4242b9ef..dce313dc260a13a011aa108d044dc1d0a45252e7 100644 (file)
@@ -3,7 +3,7 @@
  *
  *  Copyright (c) 2008 Peter Popovec
  *
- *  More about driver:  <file:Documentation/input/walkera0701.txt>
+ *  More about driver:  <file:Documentation/input/devices/walkera0701.rst>
  */
 
 /*
index 2b469cc47a78f68bd1fd959c36c9299cca32f1b0..6bd97ffee7618a2e04b7a7667b3724bfac18756f 100644 (file)
@@ -747,4 +747,13 @@ config KEYBOARD_BCM
          To compile this driver as a module, choose M here: the
          module will be called bcm-keypad.
 
+config KEYBOARD_MTK_PMIC
+       tristate "MediaTek PMIC keys support"
+       depends on MFD_MT6397
+       help
+         Say Y here if you want to use the pmic keys (powerkey/homekey).
+
+         To compile this driver as a module, choose M here: the
+         module will be called pmic-keys.
+
 endif
index 8fab920afa588a122f4455e86b04601a4b71c22b..182e92985dbf69f18c783db7b04523fbc5ae56a3 100644 (file)
@@ -40,6 +40,7 @@ obj-$(CONFIG_KEYBOARD_MATRIX)         += matrix_keypad.o
 obj-$(CONFIG_KEYBOARD_MAX7359)         += max7359_keypad.o
 obj-$(CONFIG_KEYBOARD_MCS)             += mcs_touchkey.o
 obj-$(CONFIG_KEYBOARD_MPR121)          += mpr121_touchkey.o
+obj-$(CONFIG_KEYBOARD_MTK_PMIC)        += mtk-pmic-keys.o
 obj-$(CONFIG_KEYBOARD_NEWTON)          += newtonkbd.o
 obj-$(CONFIG_KEYBOARD_NOMADIK)         += nomadik-ske-keypad.o
 obj-$(CONFIG_KEYBOARD_NSPIRE)          += nspire-keypad.o
index 997e3e97f573419c1e3d17429ecffaf5c0f43dba..e319f745771aab2096943478f6867bfd748900e7 100644 (file)
@@ -109,8 +109,8 @@ static int clps711x_keypad_probe(struct platform_device *pdev)
        if (priv->row_count < 1)
                return -EINVAL;
 
-       priv->gpio_data = devm_kzalloc(dev,
-                               sizeof(*priv->gpio_data) * priv->row_count,
+       priv->gpio_data = devm_kcalloc(dev,
+                               priv->row_count, sizeof(*priv->gpio_data),
                                GFP_KERNEL);
        if (!priv->gpio_data)
                return -ENOMEM;
index 41614c185918259d54546a50125601270f3852d7..f51ae09596ef25942ff6bab030be9697c3a0eca7 100644 (file)
@@ -443,9 +443,9 @@ matrix_keypad_parse_dt(struct device *dev)
        of_property_read_u32(np, "col-scan-delay-us",
                                                &pdata->col_scan_delay_us);
 
-       gpios = devm_kzalloc(dev,
-                            sizeof(unsigned int) *
-                               (pdata->num_row_gpios + pdata->num_col_gpios),
+       gpios = devm_kcalloc(dev,
+                            pdata->num_row_gpios + pdata->num_col_gpios,
+                            sizeof(unsigned int),
                             GFP_KERNEL);
        if (!gpios) {
                dev_err(dev, "could not allocate memory for gpios\n");
diff --git a/drivers/input/keyboard/mtk-pmic-keys.c b/drivers/input/keyboard/mtk-pmic-keys.c
new file mode 100644 (file)
index 0000000..02c67a1
--- /dev/null
@@ -0,0 +1,339 @@
+/*
+ * Copyright (C) 2017 MediaTek, Inc.
+ *
+ * Author: Chen Zhong <chen.zhong@mediatek.com>
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/regmap.h>
+#include <linux/mfd/mt6323/registers.h>
+#include <linux/mfd/mt6397/registers.h>
+#include <linux/mfd/mt6397/core.h>
+
+#define MTK_PMIC_PWRKEY_RST_EN_MASK    0x1
+#define MTK_PMIC_PWRKEY_RST_EN_SHIFT   6
+#define MTK_PMIC_HOMEKEY_RST_EN_MASK   0x1
+#define MTK_PMIC_HOMEKEY_RST_EN_SHIFT  5
+#define MTK_PMIC_RST_DU_MASK           0x3
+#define MTK_PMIC_RST_DU_SHIFT          8
+
+#define MTK_PMIC_PWRKEY_RST            \
+       (MTK_PMIC_PWRKEY_RST_EN_MASK << MTK_PMIC_PWRKEY_RST_EN_SHIFT)
+#define MTK_PMIC_HOMEKEY_RST           \
+       (MTK_PMIC_HOMEKEY_RST_EN_MASK << MTK_PMIC_HOMEKEY_RST_EN_SHIFT)
+
+#define MTK_PMIC_PWRKEY_INDEX  0
+#define MTK_PMIC_HOMEKEY_INDEX 1
+#define MTK_PMIC_MAX_KEY_COUNT 2
+
+struct mtk_pmic_keys_regs {
+       u32 deb_reg;
+       u32 deb_mask;
+       u32 intsel_reg;
+       u32 intsel_mask;
+};
+
+#define MTK_PMIC_KEYS_REGS(_deb_reg, _deb_mask,                \
+       _intsel_reg, _intsel_mask)                      \
+{                                                      \
+       .deb_reg                = _deb_reg,             \
+       .deb_mask               = _deb_mask,            \
+       .intsel_reg             = _intsel_reg,          \
+       .intsel_mask            = _intsel_mask,         \
+}
+
+struct mtk_pmic_regs {
+       const struct mtk_pmic_keys_regs keys_regs[MTK_PMIC_MAX_KEY_COUNT];
+       u32 pmic_rst_reg;
+};
+
+static const struct mtk_pmic_regs mt6397_regs = {
+       .keys_regs[MTK_PMIC_PWRKEY_INDEX] =
+               MTK_PMIC_KEYS_REGS(MT6397_CHRSTATUS,
+               0x8, MT6397_INT_RSV, 0x10),
+       .keys_regs[MTK_PMIC_HOMEKEY_INDEX] =
+               MTK_PMIC_KEYS_REGS(MT6397_OCSTATUS2,
+               0x10, MT6397_INT_RSV, 0x8),
+       .pmic_rst_reg = MT6397_TOP_RST_MISC,
+};
+
+static const struct mtk_pmic_regs mt6323_regs = {
+       .keys_regs[MTK_PMIC_PWRKEY_INDEX] =
+               MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS,
+               0x2, MT6323_INT_MISC_CON, 0x10),
+       .keys_regs[MTK_PMIC_HOMEKEY_INDEX] =
+               MTK_PMIC_KEYS_REGS(MT6323_CHRSTATUS,
+               0x4, MT6323_INT_MISC_CON, 0x8),
+       .pmic_rst_reg = MT6323_TOP_RST_MISC,
+};
+
+struct mtk_pmic_keys_info {
+       struct mtk_pmic_keys *keys;
+       const struct mtk_pmic_keys_regs *regs;
+       unsigned int keycode;
+       int irq;
+       bool wakeup:1;
+};
+
+struct mtk_pmic_keys {
+       struct input_dev *input_dev;
+       struct device *dev;
+       struct regmap *regmap;
+       struct mtk_pmic_keys_info keys[MTK_PMIC_MAX_KEY_COUNT];
+};
+
+enum mtk_pmic_keys_lp_mode {
+       LP_DISABLE,
+       LP_ONEKEY,
+       LP_TWOKEY,
+};
+
+static void mtk_pmic_keys_lp_reset_setup(struct mtk_pmic_keys *keys,
+               u32 pmic_rst_reg)
+{
+       int ret;
+       u32 long_press_mode, long_press_debounce;
+
+       ret = of_property_read_u32(keys->dev->of_node,
+               "power-off-time-sec", &long_press_debounce);
+       if (ret)
+               long_press_debounce = 0;
+
+       regmap_update_bits(keys->regmap, pmic_rst_reg,
+                          MTK_PMIC_RST_DU_MASK << MTK_PMIC_RST_DU_SHIFT,
+                          long_press_debounce << MTK_PMIC_RST_DU_SHIFT);
+
+       ret = of_property_read_u32(keys->dev->of_node,
+               "mediatek,long-press-mode", &long_press_mode);
+       if (ret)
+               long_press_mode = LP_DISABLE;
+
+       switch (long_press_mode) {
+       case LP_ONEKEY:
+               regmap_update_bits(keys->regmap, pmic_rst_reg,
+                                  MTK_PMIC_PWRKEY_RST,
+                                  MTK_PMIC_PWRKEY_RST);
+               regmap_update_bits(keys->regmap, pmic_rst_reg,
+                                  MTK_PMIC_HOMEKEY_RST,
+                                  0);
+               break;
+       case LP_TWOKEY:
+               regmap_update_bits(keys->regmap, pmic_rst_reg,
+                                  MTK_PMIC_PWRKEY_RST,
+                                  MTK_PMIC_PWRKEY_RST);
+               regmap_update_bits(keys->regmap, pmic_rst_reg,
+                                  MTK_PMIC_HOMEKEY_RST,
+                                  MTK_PMIC_HOMEKEY_RST);
+               break;
+       case LP_DISABLE:
+               regmap_update_bits(keys->regmap, pmic_rst_reg,
+                                  MTK_PMIC_PWRKEY_RST,
+                                  0);
+               regmap_update_bits(keys->regmap, pmic_rst_reg,
+                                  MTK_PMIC_HOMEKEY_RST,
+                                  0);
+               break;
+       default:
+               break;
+       }
+}
+
+static irqreturn_t mtk_pmic_keys_irq_handler_thread(int irq, void *data)
+{
+       struct mtk_pmic_keys_info *info = data;
+       u32 key_deb, pressed;
+
+       regmap_read(info->keys->regmap, info->regs->deb_reg, &key_deb);
+
+       key_deb &= info->regs->deb_mask;
+
+       pressed = !key_deb;
+
+       input_report_key(info->keys->input_dev, info->keycode, pressed);
+       input_sync(info->keys->input_dev);
+
+       dev_dbg(info->keys->dev, "(%s) key =%d using PMIC\n",
+                pressed ? "pressed" : "released", info->keycode);
+
+       return IRQ_HANDLED;
+}
+
+static int mtk_pmic_key_setup(struct mtk_pmic_keys *keys,
+               struct mtk_pmic_keys_info *info)
+{
+       int ret;
+
+       info->keys = keys;
+
+       ret = regmap_update_bits(keys->regmap, info->regs->intsel_reg,
+                                info->regs->intsel_mask,
+                                info->regs->intsel_mask);
+       if (ret < 0)
+               return ret;
+
+       ret = devm_request_threaded_irq(keys->dev, info->irq, NULL,
+                                       mtk_pmic_keys_irq_handler_thread,
+                                       IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
+                                       "mtk-pmic-keys", info);
+       if (ret) {
+               dev_err(keys->dev, "Failed to request IRQ: %d: %d\n",
+                       info->irq, ret);
+               return ret;
+       }
+
+       input_set_capability(keys->input_dev, EV_KEY, info->keycode);
+
+       return 0;
+}
+
+static int __maybe_unused mtk_pmic_keys_suspend(struct device *dev)
+{
+       struct mtk_pmic_keys *keys = dev_get_drvdata(dev);
+       int index;
+
+       for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) {
+               if (keys->keys[index].wakeup)
+                       enable_irq_wake(keys->keys[index].irq);
+       }
+
+       return 0;
+}
+
+static int __maybe_unused mtk_pmic_keys_resume(struct device *dev)
+{
+       struct mtk_pmic_keys *keys = dev_get_drvdata(dev);
+       int index;
+
+       for (index = 0; index < MTK_PMIC_MAX_KEY_COUNT; index++) {
+               if (keys->keys[index].wakeup)
+                       disable_irq_wake(keys->keys[index].irq);
+       }
+
+       return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(mtk_pmic_keys_pm_ops, mtk_pmic_keys_suspend,
+                       mtk_pmic_keys_resume);
+
+static const struct of_device_id of_mtk_pmic_keys_match_tbl[] = {
+       {
+               .compatible = "mediatek,mt6397-keys",
+               .data = &mt6397_regs,
+       }, {
+               .compatible = "mediatek,mt6323-keys",
+               .data = &mt6323_regs,
+       }, {
+               /* sentinel */
+       }
+};
+MODULE_DEVICE_TABLE(of, of_mtk_pmic_keys_match_tbl);
+
+static int mtk_pmic_keys_probe(struct platform_device *pdev)
+{
+       int error, index = 0;
+       unsigned int keycount;
+       struct mt6397_chip *pmic_chip = dev_get_drvdata(pdev->dev.parent);
+       struct device_node *node = pdev->dev.of_node, *child;
+       struct mtk_pmic_keys *keys;
+       const struct mtk_pmic_regs *mtk_pmic_regs;
+       struct input_dev *input_dev;
+       const struct of_device_id *of_id =
+               of_match_device(of_mtk_pmic_keys_match_tbl, &pdev->dev);
+
+       keys = devm_kzalloc(&pdev->dev, sizeof(*keys), GFP_KERNEL);
+       if (!keys)
+               return -ENOMEM;
+
+       keys->dev = &pdev->dev;
+       keys->regmap = pmic_chip->regmap;
+       mtk_pmic_regs = of_id->data;
+
+       keys->input_dev = input_dev = devm_input_allocate_device(keys->dev);
+       if (!input_dev) {
+               dev_err(keys->dev, "input allocate device fail.\n");
+               return -ENOMEM;
+       }
+
+       input_dev->name = "mtk-pmic-keys";
+       input_dev->id.bustype = BUS_HOST;
+       input_dev->id.vendor = 0x0001;
+       input_dev->id.product = 0x0001;
+       input_dev->id.version = 0x0001;
+
+       keycount = of_get_available_child_count(node);
+       if (keycount > MTK_PMIC_MAX_KEY_COUNT) {
+               dev_err(keys->dev, "too many keys defined (%d)\n", keycount);
+               return -EINVAL;
+       }
+
+       for_each_child_of_node(node, child) {
+               keys->keys[index].regs = &mtk_pmic_regs->keys_regs[index];
+
+               keys->keys[index].irq = platform_get_irq(pdev, index);
+               if (keys->keys[index].irq < 0)
+                       return keys->keys[index].irq;
+
+               error = of_property_read_u32(child,
+                       "linux,keycodes", &keys->keys[index].keycode);
+               if (error) {
+                       dev_err(keys->dev,
+                               "failed to read key:%d linux,keycode property: %d\n",
+                               index, error);
+                       return error;
+               }
+
+               if (of_property_read_bool(child, "wakeup-source"))
+                       keys->keys[index].wakeup = true;
+
+               error = mtk_pmic_key_setup(keys, &keys->keys[index]);
+               if (error)
+                       return error;
+
+               index++;
+       }
+
+       error = input_register_device(input_dev);
+       if (error) {
+               dev_err(&pdev->dev,
+                       "register input device failed (%d)\n", error);
+               return error;
+       }
+
+       mtk_pmic_keys_lp_reset_setup(keys, mtk_pmic_regs->pmic_rst_reg);
+
+       platform_set_drvdata(pdev, keys);
+
+       return 0;
+}
+
+static struct platform_driver pmic_keys_pdrv = {
+       .probe = mtk_pmic_keys_probe,
+       .driver = {
+                  .name = "mtk-pmic-keys",
+                  .of_match_table = of_mtk_pmic_keys_match_tbl,
+                  .pm = &mtk_pmic_keys_pm_ops,
+       },
+};
+
+module_platform_driver(pmic_keys_pdrv);
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("Chen Zhong <chen.zhong@mediatek.com>");
+MODULE_DESCRIPTION("MTK pmic-keys driver v0.1");
index 940d38b08e6b5675c8c5763836b832f0714d4f2a..46406345742b97c06595ab7e3b785ee2a6daca1b 100644 (file)
@@ -337,7 +337,8 @@ static int omap4_keypad_probe(struct platform_device *pdev)
 
        keypad_data->row_shift = get_count_order(keypad_data->cols);
        max_keys = keypad_data->rows << keypad_data->row_shift;
-       keypad_data->keymap = kzalloc(max_keys * sizeof(keypad_data->keymap[0]),
+       keypad_data->keymap = kcalloc(max_keys,
+                                     sizeof(keypad_data->keymap[0]),
                                      GFP_KERNEL);
        if (!keypad_data->keymap) {
                dev_err(&pdev->dev, "Not enough memory for keymap\n");
index 316414465c779b23d8ec4a03b42d634013dca9a8..1fe1aa2adf85d790daf8e1935b8026cf83c846f3 100644 (file)
@@ -281,7 +281,7 @@ samsung_keypad_parse_dt(struct device *dev)
 
        key_count = of_get_child_count(np);
        keymap_data->keymap_size = key_count;
-       keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL);
+       keymap = devm_kcalloc(dev, key_count, sizeof(uint32_t), GFP_KERNEL);
        if (!keymap) {
                dev_err(dev, "could not allocate memory for keymap\n");
                return ERR_PTR(-ENOMEM);
index 8ccefc15c7a4dfcfb03295a681f52620ebf47d4c..8b3a5758451ea21e7d43da670c04da5c5c20a39a 100644 (file)
@@ -170,8 +170,8 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data,
                return -EINVAL;
 
        if (!keymap) {
-               keymap = devm_kzalloc(input_dev->dev.parent,
-                                     max_keys * sizeof(*keymap),
+               keymap = devm_kcalloc(input_dev->dev.parent,
+                                     max_keys, sizeof(*keymap),
                                      GFP_KERNEL);
                if (!keymap) {
                        dev_err(input_dev->dev.parent,
index 572b15fa18c22be816704236882255df3e30c967..c25606e006938743d64498429cf3d0b69768d7fb 100644 (file)
@@ -411,7 +411,7 @@ config INPUT_YEALINK
          usb sound driver, so you might want to enable that as well.
 
          For information about how to use these additional functions, see
-         <file:Documentation/input/yealink.txt>.
+         <file:Documentation/input/devices/yealink.rst>.
 
          To compile this driver as a module, choose M here: the module will be
          called yealink.
@@ -595,7 +595,7 @@ config INPUT_GPIO_ROTARY_ENCODER
        depends on GPIOLIB || COMPILE_TEST
        help
          Say Y here to add support for rotary encoders connected to GPIO lines.
-         Check file:Documentation/input/rotary-encoder.txt for more
+         Check file:Documentation/input/devices/rotary-encoder.rst for more
          information.
 
          To compile this driver as a module, choose M here: the
index 1588aecafff79d8fdb54d80b7fa03a2ee9036f00..30ec77ad32c6efa6a56637246e342bad5b7e93b1 100644 (file)
@@ -7,7 +7,7 @@
  * state machine code inspired by code from Tim Ruetz
  *
  * A generic driver for rotary encoders connected to GPIO lines.
- * See file:Documentation/input/rotary-encoder.txt for more information
+ * See file:Documentation/input/devices/rotary-encoder.rst for more information
  *
  * 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
@@ -283,8 +283,8 @@ static int rotary_encoder_probe(struct platform_device *pdev)
        }
 
        encoder->irq =
-               devm_kzalloc(dev,
-                            sizeof(*encoder->irq) * encoder->gpios->ndescs,
+               devm_kcalloc(dev,
+                            encoder->gpios->ndescs, sizeof(*encoder->irq),
                             GFP_KERNEL);
        if (!encoder->irq)
                return -ENOMEM;
index f27f23f2d99a4bdd42d5ab3f6405a0d14ce52292..566a1e3aa50433fe8d736e81864aa2f98aa0e364 100644 (file)
@@ -129,7 +129,7 @@ config MOUSE_PS2_ELANTECH
 
          This driver exposes some configuration registers via sysfs
          entries. For further information,
-         see <file:Documentation/input/elantech.txt>.
+         see <file:Documentation/input/devices/elantech.rst>.
 
          If unsure, say N.
 
@@ -228,7 +228,7 @@ config MOUSE_APPLETOUCH
          scrolling in X11.
 
          For further information, see
-         <file:Documentation/input/appletouch.txt>.
+         <file:Documentation/input/devices/appletouch.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called appletouch.
@@ -251,7 +251,7 @@ config MOUSE_BCM5974
 
          The interface is currently identical to the appletouch interface,
          for further information, see
-         <file:Documentation/input/appletouch.txt>.
+         <file:Documentation/input/devices/appletouch.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called bcm5974.
index cb5579716dba69e0c85d9556505eff97c7d62fd4..0a6f7ca883e7fe816a82d0dae915ab120e6681e9 100644 (file)
@@ -212,7 +212,7 @@ static void alps_set_abs_params_v7(struct alps_data *priv,
 static void alps_set_abs_params_ss4_v2(struct alps_data *priv,
                                       struct input_dev *dev1);
 
-/* Packet formats are described in Documentation/input/alps.txt */
+/* Packet formats are described in Documentation/input/devices/alps.rst */
 
 static bool alps_is_valid_first_byte(struct alps_data *priv,
                                     unsigned char data)
index f5954981e9ee5bb68002af651557232c673eb30c..7d29053dfb0f06878ff7897b59f52039a299a089 100644 (file)
@@ -636,9 +636,10 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr,
        rdesc->num_registers = bitmap_weight(rdesc->presense_map,
                                                RMI_REG_DESC_PRESENSE_BITS);
 
-       rdesc->registers = devm_kzalloc(&d->dev, rdesc->num_registers *
-                               sizeof(struct rmi_register_desc_item),
-                               GFP_KERNEL);
+       rdesc->registers = devm_kcalloc(&d->dev,
+                                       rdesc->num_registers,
+                                       sizeof(struct rmi_register_desc_item),
+                                       GFP_KERNEL);
        if (!rdesc->registers)
                return -ENOMEM;
 
@@ -1061,7 +1062,7 @@ int rmi_probe_interrupts(struct rmi_driver_data *data)
        data->num_of_irq_regs = (data->irq_count + 7) / 8;
 
        size = BITS_TO_LONGS(data->irq_count) * sizeof(unsigned long);
-       data->irq_memory = devm_kzalloc(dev, size * 4, GFP_KERNEL);
+       data->irq_memory = devm_kcalloc(dev, size, 4, GFP_KERNEL);
        if (!data->irq_memory) {
                dev_err(dev, "Failed to allocate memory for irq masks.\n");
                return -ENOMEM;
index bc5e37f30ac1cf4022ac5a8a17f63fb1793d2ce0..12a233251793c24c754224ae1b379de52db34e7d 100644 (file)
@@ -1190,14 +1190,15 @@ static int rmi_f11_initialize(struct rmi_function *fn)
                f11->sensor.attn_size += f11->sensor.nbr_fingers * 2;
 
        /* allocate the in-kernel tracking buffers */
-       sensor->tracking_pos = devm_kzalloc(&fn->dev,
-                       sizeof(struct input_mt_pos) * sensor->nbr_fingers,
+       sensor->tracking_pos = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers, sizeof(struct input_mt_pos),
+                       GFP_KERNEL);
+       sensor->tracking_slots = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers, sizeof(int), GFP_KERNEL);
+       sensor->objs = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers,
+                       sizeof(struct rmi_2d_sensor_abs_object),
                        GFP_KERNEL);
-       sensor->tracking_slots = devm_kzalloc(&fn->dev,
-                       sizeof(int) * sensor->nbr_fingers, GFP_KERNEL);
-       sensor->objs = devm_kzalloc(&fn->dev,
-                       sizeof(struct rmi_2d_sensor_abs_object)
-                       * sensor->nbr_fingers, GFP_KERNEL);
        if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs)
                return -ENOMEM;
 
index 8b0db086d68a9361e622bd680e021b9251c17562..a3d1aa88f2a9ce27fcd1f89d2f87d58b21686fce 100644 (file)
@@ -502,14 +502,15 @@ static int rmi_f12_probe(struct rmi_function *fn)
        }
 
        /* allocate the in-kernel tracking buffers */
-       sensor->tracking_pos = devm_kzalloc(&fn->dev,
-                       sizeof(struct input_mt_pos) * sensor->nbr_fingers,
+       sensor->tracking_pos = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers, sizeof(struct input_mt_pos),
+                       GFP_KERNEL);
+       sensor->tracking_slots = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers, sizeof(int), GFP_KERNEL);
+       sensor->objs = devm_kcalloc(&fn->dev,
+                       sensor->nbr_fingers,
+                       sizeof(struct rmi_2d_sensor_abs_object),
                        GFP_KERNEL);
-       sensor->tracking_slots = devm_kzalloc(&fn->dev,
-                       sizeof(int) * sensor->nbr_fingers, GFP_KERNEL);
-       sensor->objs = devm_kzalloc(&fn->dev,
-                       sizeof(struct rmi_2d_sensor_abs_object)
-                       * sensor->nbr_fingers, GFP_KERNEL);
        if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs)
                return -ENOMEM;
 
index 5343f2c08f1511bb7381240773a55f4dc50f0bcd..e8a59d1640192b75e6f83db0e2ad355064c19ff9 100644 (file)
@@ -685,7 +685,7 @@ static int rmi_f54_probe(struct rmi_function *fn)
        rx = f54->num_rx_electrodes;
        tx = f54->num_tx_electrodes;
        f54->report_data = devm_kzalloc(&fn->dev,
-                                       sizeof(u16) * tx * rx,
+                                       array3_size(tx, rx, sizeof(u16)),
                                        GFP_KERNEL);
        if (f54->report_data == NULL)
                return -ENOMEM;
index 082defc329a8e2cb8e4f6744d6fb7cba4c51fe5e..33b8c6e7ac0aceaca903af36e624ffdedfd9097a 100644 (file)
@@ -69,7 +69,7 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len)
                buf_size = RMI_SPI_XFER_SIZE_LIMIT;
 
        tmp = rmi_spi->rx_buf;
-       buf = devm_kzalloc(&spi->dev, buf_size * 2,
+       buf = devm_kcalloc(&spi->dev, buf_size, 2,
                                GFP_KERNEL | GFP_DMA);
        if (!buf)
                return -ENOMEM;
@@ -96,9 +96,10 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len)
         * per byte delays.
         */
        tmp = rmi_spi->rx_xfers;
-       xfer_buf = devm_kzalloc(&spi->dev,
-               (rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count)
-               * sizeof(struct spi_transfer), GFP_KERNEL);
+       xfer_buf = devm_kcalloc(&spi->dev,
+               rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count,
+               sizeof(struct spi_transfer),
+               GFP_KERNEL);
        if (!xfer_buf)
                return -ENOMEM;
 
index ca4530eb3378684492cf08a4db631626be104c3d..d90d9f1098ff8ccba4c35d032812f6a62019baa3 100644 (file)
@@ -47,7 +47,7 @@ config SERIO_SERPORT
          Say Y here if you plan to use an input device (mouse, joystick,
          tablet, 6dof) that communicates over the RS232 serial (COM) port.
 
-         More information is available: <file:Documentation/input/input.txt>
+         More information is available: <file:Documentation/input/input.rst>
 
          If unsure, say Y.
 
@@ -78,7 +78,7 @@ config SERIO_PARKBD
          Say Y here if you built a simple parallel port adapter to attach
          an additional AT keyboard, XT keyboard or PS/2 mouse.
 
-         More information is available: <file:Documentation/input/input.txt>
+         More information is available: <file:Documentation/input/input.rst>
 
          If unsure, say N.
 
index fd714ee881f73d897b6d9150697f355bc4dd7f6a..2566b4d8b3428286adb1cc6c4988ffe09d271f34 100644 (file)
@@ -68,7 +68,7 @@
  * The default values correspond to Mainstone II in QVGA mode
  *
  * Please read
- * Documentation/input/input-programming.txt for more details.
+ * Documentation/input/input-programming.rst for more details.
  */
 
 static int abs_x[3] = {150, 4000, 5};
index 8ea77efb2e29496c9c72b4fbdba894eb5a63da66..e055d228bfb94057893a8a080dd7bbc709aeb6bf 100644 (file)
@@ -107,7 +107,6 @@ config IOMMU_PGTABLES_L2
 # AMD IOMMU support
 config AMD_IOMMU
        bool "AMD IOMMU support"
-       select DMA_DIRECT_OPS
        select SWIOTLB
        select PCI_MSI
        select PCI_ATS
index 0cea80be288889ea55ce63e8554cd062097e2a32..596b95c50051dcb75adb67496579af4b501d0ace 100644 (file)
@@ -2596,32 +2596,51 @@ static void *alloc_coherent(struct device *dev, size_t size,
                            unsigned long attrs)
 {
        u64 dma_mask = dev->coherent_dma_mask;
-       struct protection_domain *domain = get_domain(dev);
-       bool is_direct = false;
-       void *virt_addr;
+       struct protection_domain *domain;
+       struct dma_ops_domain *dma_dom;
+       struct page *page;
+
+       domain = get_domain(dev);
+       if (PTR_ERR(domain) == -EINVAL) {
+               page = alloc_pages(flag, get_order(size));
+               *dma_addr = page_to_phys(page);
+               return page_address(page);
+       } else if (IS_ERR(domain))
+               return NULL;
 
-       if (IS_ERR(domain)) {
-               if (PTR_ERR(domain) != -EINVAL)
+       dma_dom   = to_dma_ops_domain(domain);
+       size      = PAGE_ALIGN(size);
+       dma_mask  = dev->coherent_dma_mask;
+       flag     &= ~(__GFP_DMA | __GFP_HIGHMEM | __GFP_DMA32);
+       flag     |= __GFP_ZERO;
+
+       page = alloc_pages(flag | __GFP_NOWARN,  get_order(size));
+       if (!page) {
+               if (!gfpflags_allow_blocking(flag))
                        return NULL;
-               is_direct = true;
-       }
 
-       virt_addr = dma_direct_alloc(dev, size, dma_addr, flag, attrs);
-       if (!virt_addr || is_direct)
-               return virt_addr;
+               page = dma_alloc_from_contiguous(dev, size >> PAGE_SHIFT,
+                                                get_order(size), flag);
+               if (!page)
+                       return NULL;
+       }
 
        if (!dma_mask)
                dma_mask = *dev->dma_mask;
 
-       *dma_addr = __map_single(dev, to_dma_ops_domain(domain),
-                       virt_to_phys(virt_addr), PAGE_ALIGN(size),
-                       DMA_BIDIRECTIONAL, dma_mask);
+       *dma_addr = __map_single(dev, dma_dom, page_to_phys(page),
+                                size, DMA_BIDIRECTIONAL, dma_mask);
+
        if (*dma_addr == AMD_IOMMU_MAPPING_ERROR)
                goto out_free;
-       return virt_addr;
+
+       return page_address(page);
 
 out_free:
-       dma_direct_free(dev, size, virt_addr, *dma_addr, attrs);
+
+       if (!dma_release_from_contiguous(dev, page, size >> PAGE_SHIFT))
+               __free_pages(page, get_order(size));
+
        return NULL;
 }
 
@@ -2632,17 +2651,24 @@ static void free_coherent(struct device *dev, size_t size,
                          void *virt_addr, dma_addr_t dma_addr,
                          unsigned long attrs)
 {
-       struct protection_domain *domain = get_domain(dev);
+       struct protection_domain *domain;
+       struct dma_ops_domain *dma_dom;
+       struct page *page;
 
+       page = virt_to_page(virt_addr);
        size = PAGE_ALIGN(size);
 
-       if (!IS_ERR(domain)) {
-               struct dma_ops_domain *dma_dom = to_dma_ops_domain(domain);
+       domain = get_domain(dev);
+       if (IS_ERR(domain))
+               goto free_mem;
 
-               __unmap_single(dma_dom, dma_addr, size, DMA_BIDIRECTIONAL);
-       }
+       dma_dom = to_dma_ops_domain(domain);
+
+       __unmap_single(dma_dom, dma_addr, size, DMA_BIDIRECTIONAL);
 
-       dma_direct_free(dev, size, virt_addr, dma_addr, attrs);
+free_mem:
+       if (!dma_release_from_contiguous(dev, page, size >> PAGE_SHIFT))
+               __free_pages(page, get_order(size));
 }
 
 /*
index 69e7c60792a8e37130f75b447232d25369888cb8..f7a96bcf94a62e12d40cf38639b84b68bfb52437 100644 (file)
@@ -2082,7 +2082,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       smmu->irqs = devm_kzalloc(dev, sizeof(*smmu->irqs) * num_irqs,
+       smmu->irqs = devm_kcalloc(dev, num_irqs, sizeof(*smmu->irqs),
                                  GFP_KERNEL);
        if (!smmu->irqs) {
                dev_err(dev, "failed to allocate %d irqs\n", num_irqs);
index 4321f7704b239cbdd29560d64d756dd022a8b6d6..75456b5aa825fac7a5f81c8fe366d47618acc1cc 100644 (file)
@@ -1458,7 +1458,7 @@ int dmar_enable_qi(struct intel_iommu *iommu)
 
        qi->desc = page_address(desc_page);
 
-       qi->desc_status = kzalloc(QI_LENGTH * sizeof(int), GFP_ATOMIC);
+       qi->desc_status = kcalloc(QI_LENGTH, sizeof(int), GFP_ATOMIC);
        if (!qi->desc_status) {
                free_page((unsigned long) qi->desc);
                kfree(qi);
index 89e49a429c571d1b5c3eb042dc511500b1527b25..14e4b37224284976a1cb8890e5d13ae5337350cc 100644 (file)
@@ -3189,7 +3189,7 @@ static int copy_translation_tables(struct intel_iommu *iommu)
        /* This is too big for the stack - allocate it from slab */
        ctxt_table_entries = ext ? 512 : 256;
        ret = -ENOMEM;
-       ctxt_tbls = kzalloc(ctxt_table_entries * sizeof(void *), GFP_KERNEL);
+       ctxt_tbls = kcalloc(ctxt_table_entries, sizeof(void *), GFP_KERNEL);
        if (!ctxt_tbls)
                goto out_unmap;
 
@@ -4032,7 +4032,7 @@ static int iommu_suspend(void)
        unsigned long flag;
 
        for_each_active_iommu(iommu, drhd) {
-               iommu->iommu_state = kzalloc(sizeof(u32) * MAX_SR_DMAR_REGS,
+               iommu->iommu_state = kcalloc(MAX_SR_DMAR_REGS, sizeof(u32),
                                                 GFP_ATOMIC);
                if (!iommu->iommu_state)
                        goto nomem;
index c33b7b104e72a85dc0355a3c2d996cddeed29218..af4a8e7fcd27453f160788c93c660f7cf39ff3ab 100644 (file)
@@ -1455,7 +1455,7 @@ static int omap_iommu_add_device(struct device *dev)
        if (num_iommus < 0)
                return 0;
 
-       arch_data = kzalloc((num_iommus + 1) * sizeof(*arch_data), GFP_KERNEL);
+       arch_data = kcalloc(num_iommus + 1, sizeof(*arch_data), GFP_KERNEL);
        if (!arch_data)
                return -ENOMEM;
 
index 0468acfa131fe4d1904260561c8f3052673ae0a6..054cd2c8e9c8a670ee2c4fc23fe9ae3a6f78e41a 100644 (file)
@@ -1135,7 +1135,7 @@ static int rk_iommu_probe(struct platform_device *pdev)
        iommu->dev = dev;
        iommu->num_mmu = 0;
 
-       iommu->bases = devm_kzalloc(dev, sizeof(*iommu->bases) * num_res,
+       iommu->bases = devm_kcalloc(dev, num_res, sizeof(*iommu->bases),
                                    GFP_KERNEL);
        if (!iommu->bases)
                return -ENOMEM;
index 89ec24c6952c5aa078d7aa680a6808de09134d50..a004f6da35f21f0d751eeefce10c65de3a3c08a0 100644 (file)
@@ -465,7 +465,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
        gart->iovmm_base = (dma_addr_t)res_remap->start;
        gart->page_count = (resource_size(res_remap) >> GART_PAGE_SHIFT);
 
-       gart->savedata = vmalloc(sizeof(u32) * gart->page_count);
+       gart->savedata = vmalloc(array_size(sizeof(u32), gart->page_count));
        if (!gart->savedata) {
                dev_err(dev, "failed to allocate context save area\n");
                return -ENOMEM;
index 9b23843dcad4d7bb24851f30f663da84b503310e..a16b320739b4be0feed888eaf962b90a4b9b2690 100644 (file)
@@ -457,8 +457,8 @@ static int tpci200_install(struct tpci200_board *tpci200)
 {
        int res;
 
-       tpci200->slots = kzalloc(
-               TPCI200_NB_SLOT * sizeof(struct tpci200_slot), GFP_KERNEL);
+       tpci200->slots = kcalloc(TPCI200_NB_SLOT, sizeof(struct tpci200_slot),
+                                GFP_KERNEL);
        if (tpci200->slots == NULL)
                return -ENOMEM;
 
index 63d980995d17d0751194f4c64fdbfeaab78be3db..23a3b877f7f1dfe350ef70f26c78efeefdae0060 100644 (file)
@@ -268,7 +268,8 @@ static int alpine_msix_init(struct device_node *node,
                goto err_priv;
        }
 
-       priv->msi_map = kzalloc(sizeof(*priv->msi_map) * BITS_TO_LONGS(priv->num_spis),
+       priv->msi_map = kcalloc(BITS_TO_LONGS(priv->num_spis),
+                               sizeof(*priv->msi_map),
                                GFP_KERNEL);
        if (!priv->msi_map) {
                ret = -ENOMEM;
index 1ff38aff9f29f32f895bc9a1975404a0f0e2ce3f..0f52d44b3f6997c8c9e4e6f6f1a7da7b43d3e7c5 100644 (file)
@@ -361,7 +361,7 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
                break;
        }
 
-       v2m->bm = kzalloc(sizeof(long) * BITS_TO_LONGS(v2m->nr_spis),
+       v2m->bm = kcalloc(BITS_TO_LONGS(v2m->nr_spis), sizeof(long),
                          GFP_KERNEL);
        if (!v2m->bm) {
                ret = -ENOMEM;
index 5416f2b2ac21fab0373cb3e88db8d962e15bafd0..5377d7e2afba62b518671267b5d29c4963c2e5e6 100644 (file)
@@ -1239,7 +1239,7 @@ static int its_vlpi_map(struct irq_data *d, struct its_cmd_info *info)
        if (!its_dev->event_map.vm) {
                struct its_vlpi_map *maps;
 
-               maps = kzalloc(sizeof(*maps) * its_dev->event_map.nr_lpis,
+               maps = kcalloc(its_dev->event_map.nr_lpis, sizeof(*maps),
                               GFP_KERNEL);
                if (!maps) {
                        ret = -ENOMEM;
@@ -1437,7 +1437,7 @@ static int __init its_lpi_init(u32 id_bits)
 {
        lpi_chunks = its_lpi_to_chunk(1UL << id_bits);
 
-       lpi_bitmap = kzalloc(BITS_TO_LONGS(lpi_chunks) * sizeof(long),
+       lpi_bitmap = kcalloc(BITS_TO_LONGS(lpi_chunks), sizeof(long),
                             GFP_KERNEL);
        if (!lpi_bitmap) {
                lpi_chunks = 0;
@@ -1471,7 +1471,8 @@ static unsigned long *its_lpi_alloc_chunks(int nr_irqs, int *base, int *nr_ids)
        if (!nr_chunks)
                goto out;
 
-       bitmap = kzalloc(BITS_TO_LONGS(nr_chunks * IRQS_PER_CHUNK) * sizeof (long),
+       bitmap = kcalloc(BITS_TO_LONGS(nr_chunks * IRQS_PER_CHUNK),
+                        sizeof(long),
                         GFP_ATOMIC);
        if (!bitmap)
                goto out;
@@ -1823,7 +1824,7 @@ static int its_alloc_tables(struct its_node *its)
 
 static int its_alloc_collections(struct its_node *its)
 {
-       its->collections = kzalloc(nr_cpu_ids * sizeof(*its->collections),
+       its->collections = kcalloc(nr_cpu_ids, sizeof(*its->collections),
                                   GFP_KERNEL);
        if (!its->collections)
                return -ENOMEM;
@@ -2124,10 +2125,10 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,
        if (alloc_lpis) {
                lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis);
                if (lpi_map)
-                       col_map = kzalloc(sizeof(*col_map) * nr_lpis,
+                       col_map = kcalloc(nr_lpis, sizeof(*col_map),
                                          GFP_KERNEL);
        } else {
-               col_map = kzalloc(sizeof(*col_map) * nr_ites, GFP_KERNEL);
+               col_map = kcalloc(nr_ites, sizeof(*col_map), GFP_KERNEL);
                nr_lpis = 0;
                lpi_base = 0;
        }
@@ -3183,7 +3184,7 @@ static int its_init_vpe_domain(void)
        its = list_first_entry(&its_nodes, struct its_node, entry);
 
        entries = roundup_pow_of_two(nr_cpu_ids);
-       vpe_proxy.vpes = kzalloc(sizeof(*vpe_proxy.vpes) * entries,
+       vpe_proxy.vpes = kcalloc(entries, sizeof(*vpe_proxy.vpes),
                                 GFP_KERNEL);
        if (!vpe_proxy.vpes) {
                pr_err("ITS: Can't allocate GICv4 proxy device array\n");
@@ -3567,8 +3568,8 @@ static void __init acpi_table_parse_srat_its(void)
        if (count <= 0)
                return;
 
-       its_srat_maps = kmalloc(count * sizeof(struct its_srat_map),
-                               GFP_KERNEL);
+       its_srat_maps = kmalloc_array(count, sizeof(struct its_srat_map),
+                                     GFP_KERNEL);
        if (!its_srat_maps) {
                pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n");
                return;
index 5a67ec084588711c850bce2e5ae6a2c8c9b9f60a..76ea56d779a15825654cdf13573ac263fc14d717 100644 (file)
@@ -1167,7 +1167,7 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node)
        if (!nr_parts)
                goto out_put_node;
 
-       parts = kzalloc(sizeof(*parts) * nr_parts, GFP_KERNEL);
+       parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
        if (WARN_ON(!parts))
                goto out_put_node;
 
@@ -1289,7 +1289,8 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare
        if (of_property_read_u32(node, "#redistributor-regions", &nr_redist_regions))
                nr_redist_regions = 1;
 
-       rdist_regs = kzalloc(sizeof(*rdist_regs) * nr_redist_regions, GFP_KERNEL);
+       rdist_regs = kcalloc(nr_redist_regions, sizeof(*rdist_regs),
+                            GFP_KERNEL);
        if (!rdist_regs) {
                err = -ENOMEM;
                goto out_unmap_dist;
index e80263e16c4c8fe37f7fca956523d1a810567931..d00489a4b54f35f60e0abc0b41a489101d612e15 100644 (file)
@@ -354,7 +354,7 @@ static int pdc_intc_probe(struct platform_device *pdev)
        priv->nr_syswakes = val;
 
        /* Get peripheral IRQ numbers */
-       priv->perip_irqs = devm_kzalloc(&pdev->dev, 4 * priv->nr_perips,
+       priv->perip_irqs = devm_kcalloc(&pdev->dev, 4, priv->nr_perips,
                                        GFP_KERNEL);
        if (!priv->perip_irqs) {
                dev_err(&pdev->dev, "cannot allocate perip IRQ list\n");
index 4e17f7081efc54e28ffe034cf25e6f0f9e00cf9c..3be5c5dba1dab0a503b07dd3274d9eebbeabf5aa 100644 (file)
@@ -191,8 +191,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev)
        gicp->spi_ranges_cnt = ret / 2;
 
        gicp->spi_ranges =
-               devm_kzalloc(&pdev->dev,
-                            gicp->spi_ranges_cnt *
+               devm_kcalloc(&pdev->dev,
+                            gicp->spi_ranges_cnt,
                             sizeof(struct mvebu_gicp_spi_range),
                             GFP_KERNEL);
        if (!gicp->spi_ranges)
@@ -210,8 +210,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev)
                gicp->spi_cnt += gicp->spi_ranges[i].count;
        }
 
-       gicp->spi_bitmap = devm_kzalloc(&pdev->dev,
-                               BITS_TO_LONGS(gicp->spi_cnt) * sizeof(long),
+       gicp->spi_bitmap = devm_kcalloc(&pdev->dev,
+                               BITS_TO_LONGS(gicp->spi_cnt), sizeof(long),
                                GFP_KERNEL);
        if (!gicp->spi_bitmap)
                return -ENOMEM;
index ccd72c2cbc2301a2216952f5b1a3321ff5eedfb6..1f7cc5933cd5edaeb15b94b6e6793b749f050563 100644 (file)
@@ -229,7 +229,7 @@ struct partition_desc *partition_create_desc(struct fwnode_handle *fwnode,
                goto out;
        desc->domain = d;
 
-       desc->bitmap = kzalloc(sizeof(long) * BITS_TO_LONGS(nr_parts),
+       desc->bitmap = kcalloc(BITS_TO_LONGS(nr_parts), sizeof(long),
                               GFP_KERNEL);
        if (WARN_ON(!desc->bitmap))
                goto out;
index ec0e6a8cdb7558433d933868520d8d72e7b28b2b..f6fd57ebe6e6468f3ce98ec90cb1b7de5b9e6bfc 100644 (file)
@@ -1261,7 +1261,7 @@ static int __init s3c_init_intc_of(struct device_node *np,
                        return -ENOMEM;
 
                intc->domain = domain;
-               intc->irqs = kzalloc(sizeof(struct s3c_irq_data) * 32,
+               intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data),
                                     GFP_KERNEL);
                if (!intc->irqs) {
                        kfree(intc);
index baa1ee2bc2ac026ab6d6f950ef5e4c77e1475a24..6e0c2814d0329ace7b109915d58c9805ce2b1e6a 100644 (file)
@@ -1260,7 +1260,7 @@ static int __init capinc_tty_init(void)
        if (capi_ttyminors <= 0)
                capi_ttyminors = CAPINC_NR_PORTS;
 
-       capiminors = kzalloc(sizeof(struct capiminor *) * capi_ttyminors,
+       capiminors = kcalloc(capi_ttyminors, sizeof(struct capiminor *),
                             GFP_KERNEL);
        if (!capiminors)
                return -ENOMEM;
index 7ac51798949d6c7e186914c5dda586c157c9bd1a..ee510f901720d1686524f37bc598bd6e3ee254a0 100644 (file)
@@ -2268,7 +2268,8 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)
        strcpy(card->name, id);
        card->contrnr = contr;
        card->nbchan = profp->nbchannel;
-       card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC);
+       card->bchans = kmalloc_array(card->nbchan, sizeof(capidrv_bchan),
+                                    GFP_ATOMIC);
        if (!card->bchans) {
                printk(KERN_WARNING
                       "capidrv: (%s) Could not allocate bchan-structs.\n", id);
index 56748af78c0425fa248c7954c3f0eb374048f5fb..9cb2ab57fa4af962a4c39cd9300bd352fe6f7043 100644 (file)
@@ -252,7 +252,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag,
                return;
        if (l > 64)
                l = 64; /* arbitrary limit */
-       dbgline = kmalloc(3 * l, GFP_ATOMIC);
+       dbgline = kmalloc_array(3, l, GFP_ATOMIC);
        if (!dbgline)
                return;
        for (i = 0; i < l; i++) {
@@ -272,7 +272,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag,
                        return;
                if (l > 64)
                        l = 64; /* arbitrary limit */
-               dbgline = kmalloc(3 * l, GFP_ATOMIC);
+               dbgline = kmalloc_array(3, l, GFP_ATOMIC);
                if (!dbgline)
                        return;
                data += CAPIMSG_LEN(data);
@@ -1370,7 +1370,7 @@ static void do_connect_req(struct gigaset_capi_ctr *iif,
        cmsg->adr.adrPLCI |= (bcs->channel + 1) << 8;
 
        /* build command table */
-       commands = kzalloc(AT_NUM * (sizeof *commands), GFP_KERNEL);
+       commands = kcalloc(AT_NUM, sizeof(*commands), GFP_KERNEL);
        if (!commands)
                goto oom;
 
index 15482c5de33c1958e06d0666f5c3fb12fcbe0ca7..76b5407b5277b60a76150dbe4cbb89211da4e6d9 100644 (file)
@@ -710,7 +710,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
        cs->mode = M_UNKNOWN;
        cs->mstate = MS_UNINITIALIZED;
 
-       cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
+       cs->bcs = kmalloc_array(channels, sizeof(struct bc_state), GFP_KERNEL);
        cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
        if (!cs->bcs || !cs->inbuf) {
                pr_err("out of memory\n");
@@ -1089,7 +1089,7 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
        drv->owner = owner;
        INIT_LIST_HEAD(&drv->list);
 
-       drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL);
+       drv->cs = kmalloc_array(minors, sizeof(*drv->cs), GFP_KERNEL);
        if (!drv->cs)
                goto error;
 
index 2d75329007f158e31975a1d745e147a75ef8e7e6..b5b389e95edd2681ca6448cc116db2c9faba531a 100644 (file)
@@ -243,7 +243,7 @@ static int command_from_LL(isdn_ctrl *cntrl)
                dev_kfree_skb(bcs->rx_skb);
                gigaset_new_rx_skb(bcs);
 
-               commands = kzalloc(AT_NUM * (sizeof *commands), GFP_ATOMIC);
+               commands = kcalloc(AT_NUM, sizeof(*commands), GFP_ATOMIC);
                if (!commands) {
                        gigaset_free_channel(bcs);
                        dev_err(cs->dev, "ISDN_CMD_DIAL: out of memory\n");
index 5ee5489d3f15bfbf569eccfc3680f2a0fe251d0d..4ac378e489023f19b42eaf95eff35d6a8ef1913d 100644 (file)
@@ -72,7 +72,7 @@ avmcard *b1_alloc_card(int nr_controllers)
        if (!card)
                return NULL;
 
-       cinfo = kzalloc(sizeof(*cinfo) * nr_controllers, GFP_KERNEL);
+       cinfo = kcalloc(nr_controllers, sizeof(*cinfo), GFP_KERNEL);
        if (!cinfo) {
                kfree(card);
                return NULL;
index 3e020ec0f65e075809848790ec535cc615a86065..80ba82f77c63d02c0395fdbb17ed0a5b039100bc 100644 (file)
@@ -27,7 +27,9 @@ FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount)
        int i;
 
        fsm->jumpmatrix =
-               kzalloc(sizeof(FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL);
+               kzalloc(array3_size(sizeof(FSMFNPTR), fsm->state_count,
+                                   fsm->event_count),
+                       GFP_KERNEL);
        if (!fsm->jumpmatrix)
                return -ENOMEM;
 
index 86b82172e9927fbae666ea3f6b04453d45eb7b35..3715fa0343db2aca28368e64c5bd83a19a79dab0 100644 (file)
@@ -1024,7 +1024,7 @@ static unsigned int
        int i;
        unsigned *send;
 
-       if (!(send = kmalloc(cnt * sizeof(unsigned int), GFP_ATOMIC))) {
+       if (!(send = kmalloc_array(cnt, sizeof(unsigned int), GFP_ATOMIC))) {
                printk(KERN_WARNING
                       "HiSax: No memory for hfcd.send\n");
                return (NULL);
index 14dada42874ef7aa709311a5e69f9a526ad5a26b..34d59992839a36abe13151086fb69acc13fe4fd7 100644 (file)
@@ -557,7 +557,8 @@ init_send(struct BCState *bcs)
 {
        int i;
 
-       if (!(bcs->hw.hfc.send = kmalloc(32 * sizeof(unsigned int), GFP_ATOMIC))) {
+       bcs->hw.hfc.send = kmalloc_array(32, sizeof(unsigned int), GFP_ATOMIC);
+       if (!bcs->hw.hfc.send) {
                printk(KERN_WARNING
                       "HiSax: No memory for hfc.send\n");
                return;
index b7f54fa292282c7b3dafc8f5be5763091d5ccf3c..e932a152c405931c05879d00f19cc77060c6edee 100644 (file)
@@ -912,8 +912,10 @@ setstack_tiger(struct PStack *st, struct BCState *bcs)
 void
 inittiger(struct IsdnCardState *cs)
 {
-       if (!(cs->bcs[0].hw.tiger.send = kmalloc(NETJET_DMA_TXSIZE * sizeof(unsigned int),
-                                                GFP_KERNEL | GFP_DMA))) {
+       cs->bcs[0].hw.tiger.send = kmalloc_array(NETJET_DMA_TXSIZE,
+                                                sizeof(unsigned int),
+                                                GFP_KERNEL | GFP_DMA);
+       if (!cs->bcs[0].hw.tiger.send) {
                printk(KERN_WARNING
                       "HiSax: No memory for tiger.send\n");
                return;
@@ -933,8 +935,10 @@ inittiger(struct IsdnCardState *cs)
             cs->hw.njet.base + NETJET_DMA_READ_IRQ);
        outl(virt_to_bus(cs->bcs[0].hw.tiger.s_end),
             cs->hw.njet.base + NETJET_DMA_READ_END);
-       if (!(cs->bcs[0].hw.tiger.rec = kmalloc(NETJET_DMA_RXSIZE * sizeof(unsigned int),
-                                               GFP_KERNEL | GFP_DMA))) {
+       cs->bcs[0].hw.tiger.rec = kmalloc_array(NETJET_DMA_RXSIZE,
+                                               sizeof(unsigned int),
+                                               GFP_KERNEL | GFP_DMA);
+       if (!cs->bcs[0].hw.tiger.rec) {
                printk(KERN_WARNING
                       "HiSax: No memory for tiger.rec\n");
                return;
index 99012c047751944c23fe4fe20670eb24bb2c28da..7f28b967ed1915fe923fd26ee828c77527b309f7 100644 (file)
@@ -340,7 +340,7 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data)
         * Allocate space for the dictionary. This may be more than one page in
         * length.
         */
-       db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
+       db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict)));
        if (!db->dict) {
                bsd_free(db);
                return NULL;
@@ -353,7 +353,8 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data)
        if (!decomp)
                db->lens = NULL;
        else {
-               db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
+               db->lens = vmalloc(array_size(sizeof(db->lens[0]),
+                                             maxmaxcode + 1));
                if (!db->lens) {
                        bsd_free(db);
                        return (NULL);
index 7c6f3f5d9d9a2dc11f7bf2c950b6244b984ef429..7a501dbe7123ea78a56be5b3a6321c46e661294c 100644 (file)
@@ -2070,14 +2070,14 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding)
 
        if ((adding) && (d->rcverr))
                kfree(d->rcverr);
-       if (!(d->rcverr = kzalloc(sizeof(int) * m, GFP_ATOMIC))) {
+       if (!(d->rcverr = kcalloc(m, sizeof(int), GFP_ATOMIC))) {
                printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n");
                return -1;
        }
 
        if ((adding) && (d->rcvcount))
                kfree(d->rcvcount);
-       if (!(d->rcvcount = kzalloc(sizeof(int) * m, GFP_ATOMIC))) {
+       if (!(d->rcvcount = kcalloc(m, sizeof(int), GFP_ATOMIC))) {
                printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n");
                if (!adding)
                        kfree(d->rcverr);
@@ -2089,7 +2089,8 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding)
                        skb_queue_purge(&d->rpqueue[j]);
                kfree(d->rpqueue);
        }
-       if (!(d->rpqueue = kmalloc(sizeof(struct sk_buff_head) * m, GFP_ATOMIC))) {
+       d->rpqueue = kmalloc_array(m, sizeof(struct sk_buff_head), GFP_ATOMIC);
+       if (!d->rpqueue) {
                printk(KERN_WARNING "register_isdn: Could not alloc rpqueue\n");
                if (!adding) {
                        kfree(d->rcvcount);
@@ -2103,7 +2104,8 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding)
 
        if ((adding) && (d->rcv_waitq))
                kfree(d->rcv_waitq);
-       d->rcv_waitq = kmalloc(sizeof(wait_queue_head_t) * 2 * m, GFP_ATOMIC);
+       d->rcv_waitq = kmalloc(array3_size(sizeof(wait_queue_head_t), 2, m),
+                              GFP_ATOMIC);
        if (!d->rcv_waitq) {
                printk(KERN_WARNING "register_isdn: Could not alloc rcv_waitq\n");
                if (!adding) {
index cabcb906e0b564a014d4be7941f40acc7792e131..9a8d08d677a4c2700a583179824028a459481cf0 100644 (file)
@@ -32,8 +32,10 @@ mISDN_FsmNew(struct Fsm *fsm,
 {
        int i;
 
-       fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count *
-                                 fsm->event_count, GFP_KERNEL);
+       fsm->jumpmatrix =
+               kzalloc(array3_size(sizeof(FSMFNPTR), fsm->state_count,
+                                   fsm->event_count),
+                       GFP_KERNEL);
        if (fsm->jumpmatrix == NULL)
                return -ENOMEM;
 
index 853b2d3bdb1731fbd903fe468ddf3f370ac4c156..7ecf080f73ad4602a7a144d743fd721b219f0bb8 100644 (file)
@@ -108,7 +108,7 @@ static int adp5520_led_probe(struct platform_device *pdev)
                return -EFAULT;
        }
 
-       led = devm_kzalloc(&pdev->dev, sizeof(*led) * pdata->num_leds,
+       led = devm_kcalloc(&pdev->dev, pdata->num_leds, sizeof(*led),
                                GFP_KERNEL);
        if (!led)
                return -ENOMEM;
index 90eeedcbf3711b1fc9025918936565c334caff17..8c93d68964c7d9d3e3c1e4c170748b37a58d2ea7 100644 (file)
@@ -171,8 +171,8 @@ static int apu_led_config(struct device *dev, struct apu_led_pdata *apuld)
        int i;
        int err;
 
-       apu_led->pled = devm_kzalloc(dev,
-               sizeof(struct apu_led_priv) * apu_led->num_led_instances,
+       apu_led->pled = devm_kcalloc(dev,
+               apu_led->num_led_instances, sizeof(struct apu_led_priv),
                GFP_KERNEL);
 
        if (!apu_led->pled)
index a4b1c1dcce7fb9284282fb50c1ce624dc30f7d8d..0e4262462cb9d34ca1a6a767b1ad813cd537bcb2 100644 (file)
@@ -237,8 +237,7 @@ static int cr0014114_probe(struct spi_device *spi)
                return -ENODEV;
        }
 
-       priv = devm_kzalloc(&spi->dev,
-                           sizeof(*priv) + sizeof(*priv->leds) * count,
+       priv = devm_kzalloc(&spi->dev, struct_size(priv, leds, count),
                            GFP_KERNEL);
        if (!priv)
                return -ENOMEM;
index f8c7d82c26529aea6e80b5b88d95e232a2cad706..31d4c94e6fd819190dc3c4313dc9acbc8f043b4f 100644 (file)
@@ -113,8 +113,8 @@ static int da9052_led_probe(struct platform_device *pdev)
                goto err;
        }
 
-       led = devm_kzalloc(&pdev->dev,
-                          sizeof(struct da9052_led) * pled->num_leds,
+       led = devm_kcalloc(&pdev->dev,
+                          pled->num_leds, sizeof(struct da9052_led),
                           GFP_KERNEL);
        if (!led) {
                error = -ENOMEM;
index 55c0517fbe03e731de79238fa7e65f07b287d49e..99689b51a73da57609eff47525237a5a4e69caf2 100644 (file)
@@ -533,8 +533,8 @@ static int lp5521_probe(struct i2c_client *client,
        if (!chip)
                return -ENOMEM;
 
-       led = devm_kzalloc(&client->dev,
-                       sizeof(*led) * pdata->num_channels, GFP_KERNEL);
+       led = devm_kcalloc(&client->dev,
+                       pdata->num_channels, sizeof(*led), GFP_KERNEL);
        if (!led)
                return -ENOMEM;
 
index 52b6f529e27802e441cc146fd500092d4032deaf..a2e74feee2b2fa2c2dbb92d29c54a5174ba192c0 100644 (file)
@@ -898,8 +898,8 @@ static int lp5523_probe(struct i2c_client *client,
        if (!chip)
                return -ENOMEM;
 
-       led = devm_kzalloc(&client->dev,
-                       sizeof(*led) * pdata->num_channels, GFP_KERNEL);
+       led = devm_kcalloc(&client->dev,
+                       pdata->num_channels, sizeof(*led), GFP_KERNEL);
        if (!led)
                return -ENOMEM;
 
index 05ffa34fb6ad0dc41f3afc18754a87aacb36a6c6..2a9009fe5545d059d625075eb04a0ed53dbb432e 100644 (file)
@@ -534,8 +534,8 @@ static int lp5562_probe(struct i2c_client *client,
        if (!chip)
                return -ENOMEM;
 
-       led = devm_kzalloc(&client->dev,
-                       sizeof(*led) * pdata->num_channels, GFP_KERNEL);
+       led = devm_kcalloc(&client->dev,
+                       pdata->num_channels, sizeof(*led), GFP_KERNEL);
        if (!led)
                return -ENOMEM;
 
index 5377f22ff994769eba699f93f5cff31cea16bfaf..3d79a63807615a33bb40577195973ee05125ba16 100644 (file)
@@ -560,7 +560,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev,
                return ERR_PTR(-EINVAL);
        }
 
-       cfg = devm_kzalloc(dev, sizeof(*cfg) * num_channels, GFP_KERNEL);
+       cfg = devm_kcalloc(dev, num_channels, sizeof(*cfg), GFP_KERNEL);
        if (!cfg)
                return ERR_PTR(-ENOMEM);
 
index 3adb113cf02e5d781bd395c57e1269a567a7b1d9..4c800b5989a9069c9e7194a1a9ea4817955f709b 100644 (file)
@@ -327,8 +327,8 @@ static int lp8501_probe(struct i2c_client *client,
        if (!chip)
                return -ENOMEM;
 
-       led = devm_kzalloc(&client->dev,
-                       sizeof(*led) * pdata->num_channels, GFP_KERNEL);
+       led = devm_kcalloc(&client->dev,
+                       pdata->num_channels, sizeof(*led), GFP_KERNEL);
        if (!led)
                return -ENOMEM;
 
index a7ff510cbdd06e113ee5e744ea0c1c9eb8c4618e..5ec730a31b6500e4e81d72a3be7ab828454c6a4d 100644 (file)
@@ -128,8 +128,8 @@ static int lt3593_led_probe(struct platform_device *pdev)
        if (!pdata)
                return -EBUSY;
 
-       leds_data = devm_kzalloc(&pdev->dev,
-                       sizeof(struct lt3593_led_data) * pdata->num_leds,
+       leds_data = devm_kcalloc(&pdev->dev,
+                       pdata->num_leds, sizeof(struct lt3593_led_data),
                        GFP_KERNEL);
        if (!leds_data)
                return -ENOMEM;
index 2421cf1049915a6ef52fa55d31b30d0c2e88f406..47ad7de9553c5170d908ef29a76ea34830f95766 100644 (file)
@@ -136,7 +136,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt(
 
        pdata->num_leds = of_get_child_count(parent);
 
-       pdata->led = devm_kzalloc(dev, pdata->num_leds * sizeof(*pdata->led),
+       pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led),
                                  GFP_KERNEL);
        if (!pdata->led) {
                ret = -ENOMEM;
@@ -210,7 +210,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       leds->led = devm_kzalloc(dev, leds->num_leds * sizeof(*leds->led),
+       leds->led = devm_kcalloc(dev, leds->num_leds, sizeof(*leds->led),
                                 GFP_KERNEL);
        if (!leds->led)
                return -ENOMEM;
index 281482e1d50fc2eec96c25ae8b570da03e38c22f..f4721f8065f0fa54fc844343ae95a70b2e3e3222 100644 (file)
@@ -329,8 +329,10 @@ static int mlxcpld_led_config(struct device *dev,
        int i;
        int err;
 
-       cpld->pled = devm_kzalloc(dev, sizeof(struct mlxcpld_led_priv) *
-                                 cpld->num_led_instances, GFP_KERNEL);
+       cpld->pled = devm_kcalloc(dev,
+                                 cpld->num_led_instances,
+                                 sizeof(struct mlxcpld_led_priv),
+                                 GFP_KERNEL);
        if (!cpld->pled)
                return -ENOMEM;
 
index f48b1aed9b4e3b410cf33a6c1e9f31d41058cf38..62fa0de526ee51e0543a546dcac6c4cf4f699f33 100644 (file)
@@ -335,7 +335,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np,
                return ret;
        }
        num_addr = ret;
-       addr = devm_kzalloc(dev, num_addr * sizeof(*addr), GFP_KERNEL);
+       addr = devm_kcalloc(dev, num_addr, sizeof(*addr), GFP_KERNEL);
        if (!addr)
                return -ENOMEM;
 
@@ -355,7 +355,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np,
                return ret;
        }
        num_data = ret;
-       data = devm_kzalloc(dev, num_data * sizeof(*data), GFP_KERNEL);
+       data = devm_kcalloc(dev, num_data, sizeof(*data), GFP_KERNEL);
        if (!data)
                return -ENOMEM;
 
@@ -415,7 +415,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
                if (ret % 3)
                        return -EINVAL;
                num_timers = ret / 3;
-               timers = devm_kzalloc(dev, num_timers * sizeof(*timers),
+               timers = devm_kcalloc(dev, num_timers, sizeof(*timers),
                                      GFP_KERNEL);
                if (!timers)
                        return -ENOMEM;
@@ -444,7 +444,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
                return -ENODEV;
        }
 
-       leds = devm_kzalloc(dev, num_leds * sizeof(*leds), GFP_KERNEL);
+       leds = devm_kcalloc(dev, num_leds, sizeof(*leds), GFP_KERNEL);
        if (!leds)
                return -ENOMEM;
 
@@ -470,8 +470,8 @@ static int netxbig_leds_get_of_pdata(struct device *dev,
                        goto err_node_put;
 
                mode_val =
-                       devm_kzalloc(dev,
-                                    NETXBIG_LED_MODE_NUM * sizeof(*mode_val),
+                       devm_kcalloc(dev,
+                                    NETXBIG_LED_MODE_NUM, sizeof(*mode_val),
                                     GFP_KERNEL);
                if (!mode_val) {
                        ret = -ENOMEM;
@@ -560,8 +560,8 @@ static int netxbig_led_probe(struct platform_device *pdev)
                        return ret;
        }
 
-       leds_data = devm_kzalloc(&pdev->dev,
-                                pdata->num_leds * sizeof(*leds_data),
+       leds_data = devm_kcalloc(&pdev->dev,
+                                pdata->num_leds, sizeof(*leds_data),
                                 GFP_KERNEL);
        if (!leds_data)
                return -ENOMEM;
index 506b75b190e7325a46ac8517dcdcf651c50d7050..14fe5cd43232965c143992da47552818d6182380 100644 (file)
@@ -264,7 +264,7 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata)
        if (!num_leds)
                return -ENODEV;
 
-       leds = devm_kzalloc(dev, num_leds * sizeof(struct ns2_led),
+       leds = devm_kcalloc(dev, num_leds, sizeof(struct ns2_led),
                            GFP_KERNEL);
        if (!leds)
                return -ENOMEM;
@@ -298,8 +298,9 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata)
                }
 
                num_modes = ret / 3;
-               modval = devm_kzalloc(dev,
-                                     num_modes * sizeof(struct ns2_led_modval),
+               modval = devm_kcalloc(dev,
+                                     num_modes,
+                                     sizeof(struct ns2_led_modval),
                                      GFP_KERNEL);
                if (!modval)
                        return -ENOMEM;
index 78183f90820eac0e424315ba75302dac62a48ca7..f51b356d44264dd68918ccbe9ff599e67503f33f 100644 (file)
@@ -390,8 +390,8 @@ pca955x_pdata_of_init(struct i2c_client *client, struct pca955x_chipdef *chip)
        if (!pdata)
                return ERR_PTR(-ENOMEM);
 
-       pdata->leds = devm_kzalloc(&client->dev,
-                                  sizeof(struct pca955x_led) * chip->bits,
+       pdata->leds = devm_kcalloc(&client->dev,
+                                  chip->bits, sizeof(struct pca955x_led),
                                   GFP_KERNEL);
        if (!pdata->leds)
                return ERR_PTR(-ENOMEM);
@@ -494,8 +494,8 @@ static int pca955x_probe(struct i2c_client *client,
        if (!pca955x)
                return -ENOMEM;
 
-       pca955x->leds = devm_kzalloc(&client->dev,
-                       sizeof(*pca955x_led) * chip->bits, GFP_KERNEL);
+       pca955x->leds = devm_kcalloc(&client->dev,
+                       chip->bits, sizeof(*pca955x_led), GFP_KERNEL);
        if (!pca955x->leds)
                return -ENOMEM;
 
index 3bf9a127181927d84f374c1b60cc9373dafad149..5c0908113e388ac9e67e751b496423feb9e73e9f 100644 (file)
@@ -300,8 +300,8 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip)
        if (!count || count > chip->n_leds)
                return ERR_PTR(-ENODEV);
 
-       pca963x_leds = devm_kzalloc(&client->dev,
-                       sizeof(struct led_info) * chip->n_leds, GFP_KERNEL);
+       pca963x_leds = devm_kcalloc(&client->dev,
+                       chip->n_leds, sizeof(struct led_info), GFP_KERNEL);
        if (!pca963x_leds)
                return ERR_PTR(-ENOMEM);
 
@@ -407,7 +407,7 @@ static int pca963x_probe(struct i2c_client *client,
                                                                GFP_KERNEL);
        if (!pca963x_chip)
                return -ENOMEM;
-       pca963x = devm_kzalloc(&client->dev, chip->n_leds * sizeof(*pca963x),
+       pca963x = devm_kcalloc(&client->dev, chip->n_leds, sizeof(*pca963x),
                                                                GFP_KERNEL);
        if (!pca963x)
                return -ENOMEM;
index c12c16fb1b9ce811f3dd7401bfff43eb0f9bc62c..8f343afa4787027d54fa5484a581f0bbd56c37e0 100644 (file)
@@ -697,8 +697,8 @@ tca6507_led_dt_init(struct i2c_client *client)
        if (!count || count > NUM_LEDS)
                return ERR_PTR(-ENODEV);
 
-       tca_leds = devm_kzalloc(&client->dev,
-                       sizeof(struct led_info) * NUM_LEDS, GFP_KERNEL);
+       tca_leds = devm_kcalloc(&client->dev,
+                       NUM_LEDS, sizeof(struct led_info), GFP_KERNEL);
        if (!tca_leds)
                return ERR_PTR(-ENOMEM);
 
index 6a4883e40cc0fa7bbb40756b873ff86c1d94be11..080469d90b408a32de6b403d2db063a5752337e2 100644 (file)
@@ -88,7 +88,7 @@ static void pblk_gc_line_ws(struct work_struct *work)
 
        up(&gc->gc_sem);
 
-       gc_rq->data = vmalloc(gc_rq->nr_secs * geo->csecs);
+       gc_rq->data = vmalloc(array_size(gc_rq->nr_secs, geo->csecs));
        if (!gc_rq->data) {
                pr_err("pblk: could not GC line:%d (%d/%d)\n",
                                        line->id, *line->vsc, gc_rq->nr_secs);
index 491df0fa0835ed3cb6c8519234826284bc129f96..b57f764d6a167021fd00d27a122556019528c198 100644 (file)
@@ -187,7 +187,7 @@ static int pblk_rwb_init(struct pblk *pblk)
 
        nr_entries = pblk_rb_calculate_size(buffer_size);
 
-       entries = vzalloc(nr_entries * sizeof(struct pblk_rb_entry));
+       entries = vzalloc(array_size(nr_entries, sizeof(struct pblk_rb_entry)));
        if (!entries)
                return -ENOMEM;
 
@@ -379,7 +379,7 @@ static int pblk_core_init(struct pblk *pblk)
                return -EINVAL;
        }
 
-       pblk->pad_dist = kzalloc((pblk->min_write_pgs - 1) * sizeof(atomic64_t),
+       pblk->pad_dist = kcalloc(pblk->min_write_pgs - 1, sizeof(atomic64_t),
                                                                GFP_KERNEL);
        if (!pblk->pad_dist)
                return -ENOMEM;
@@ -833,8 +833,8 @@ static int pblk_alloc_line_meta(struct pblk *pblk, struct pblk_line *line)
                goto free_blk_bitmap;
 
 
-       line->chks = kmalloc(lm->blk_per_line * sizeof(struct nvm_chk_meta),
-                                                               GFP_KERNEL);
+       line->chks = kmalloc_array(lm->blk_per_line,
+                                  sizeof(struct nvm_chk_meta), GFP_KERNEL);
        if (!line->chks)
                goto free_erase_bitmap;
 
index 00cd1f20a1962f74c7c5e8abec6b9fec53a61af1..55e9442a99e2bfd664932d50a7a5b5ece9b9c9a8 100644 (file)
@@ -38,7 +38,7 @@ void pblk_rb_data_free(struct pblk_rb *rb)
 /*
  * Initialize ring buffer. The data and metadata buffers must be previously
  * allocated and their size must be a power of two
- * (Documentation/circular-buffers.txt)
+ * (Documentation/core-api/circular-buffers.rst)
  */
 int pblk_rb_init(struct pblk_rb *rb, struct pblk_rb_entry *rb_entry_base,
                 unsigned int power_size, unsigned int power_seg_sz)
index 598342833d0d90ed2b50b58956ebf64ed3101b2a..3a5069183859e8df3c61b951121bc5cb7025c688 100644 (file)
@@ -260,7 +260,7 @@ static int pblk_recov_pad_oob(struct pblk *pblk, struct pblk_line *line,
        if (!pad_rq)
                return -ENOMEM;
 
-       data = vzalloc(pblk->max_write_pgs * geo->csecs);
+       data = vzalloc(array_size(pblk->max_write_pgs, geo->csecs));
        if (!data) {
                ret = -ENOMEM;
                goto free_rq;
index 519376d3534cfa05d623819b4ceb3f5a398e0cf3..4fa9803cd2041c035a0fdaff538b659f25a3327d 100644 (file)
@@ -282,13 +282,13 @@ static int hi6220_mbox_probe(struct platform_device *pdev)
 
        mbox->dev = dev;
        mbox->chan_num = MBOX_CHAN_MAX;
-       mbox->mchan = devm_kzalloc(dev,
-               mbox->chan_num * sizeof(*mbox->mchan), GFP_KERNEL);
+       mbox->mchan = devm_kcalloc(dev,
+               mbox->chan_num, sizeof(*mbox->mchan), GFP_KERNEL);
        if (!mbox->mchan)
                return -ENOMEM;
 
-       mbox->chan = devm_kzalloc(dev,
-               mbox->chan_num * sizeof(*mbox->chan), GFP_KERNEL);
+       mbox->chan = devm_kcalloc(dev,
+               mbox->chan_num, sizeof(*mbox->chan), GFP_KERNEL);
        if (!mbox->chan)
                return -ENOMEM;
 
index 41bcd339b68a1987eb1a62c1a6653c711341e350..779d41262ef0c8d9d7fde683efd7017b9eb1011c 100644 (file)
@@ -442,8 +442,8 @@ static int sti_mbox_probe(struct platform_device *pdev)
        if (!mbox)
                return -ENOMEM;
 
-       chans = devm_kzalloc(&pdev->dev,
-                            sizeof(*chans) * STI_MBOX_CHAN_MAX, GFP_KERNEL);
+       chans = devm_kcalloc(&pdev->dev,
+                            STI_MBOX_CHAN_MAX, sizeof(*chans), GFP_KERNEL);
        if (!chans)
                return -ENOMEM;
 
index 2517038a8452c638aa45a11577cd20ee0dde6a20..e1e2c085e68eee99e3b6b90af1b32f9426dcf51c 100644 (file)
@@ -729,7 +729,7 @@ static int omap_mbox_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       finfoblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*finfoblk),
+       finfoblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*finfoblk),
                                GFP_KERNEL);
        if (!finfoblk)
                return -ENOMEM;
@@ -773,23 +773,23 @@ static int omap_mbox_probe(struct platform_device *pdev)
        if (IS_ERR(mdev->mbox_base))
                return PTR_ERR(mdev->mbox_base);
 
-       mdev->irq_ctx = devm_kzalloc(&pdev->dev, num_users * sizeof(u32),
+       mdev->irq_ctx = devm_kcalloc(&pdev->dev, num_users, sizeof(u32),
                                     GFP_KERNEL);
        if (!mdev->irq_ctx)
                return -ENOMEM;
 
        /* allocate one extra for marking end of list */
-       list = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*list),
+       list = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*list),
                            GFP_KERNEL);
        if (!list)
                return -ENOMEM;
 
-       chnls = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*chnls),
+       chnls = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*chnls),
                             GFP_KERNEL);
        if (!chnls)
                return -ENOMEM;
 
-       mboxblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*mbox),
+       mboxblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*mbox),
                               GFP_KERNEL);
        if (!mboxblk)
                return -ENOMEM;
index fc3c237daef24ec6e96ec30319361a9385a4a891..311e91b1a14f3f24ac2f861d882d38a026281b7b 100644 (file)
@@ -466,7 +466,8 @@ static int __init acpi_pcc_probe(void)
                return -EINVAL;
        }
 
-       pcc_mbox_channels = kzalloc(sizeof(struct mbox_chan) * count, GFP_KERNEL);
+       pcc_mbox_channels = kcalloc(count, sizeof(struct mbox_chan),
+                                   GFP_KERNEL);
        if (!pcc_mbox_channels) {
                pr_err("Could not allocate space for PCC mbox channels\n");
                return -ENOMEM;
index 78753a87ba4d112367d6b4c6691cd9b0f062e575..5d04738c3c8a66e465fbe1efd505a4d5c6d4fb3a 100644 (file)
@@ -568,12 +568,12 @@ static int ti_msgmgr_probe(struct platform_device *pdev)
        }
        inst->num_valid_queues = queue_count;
 
-       qinst = devm_kzalloc(dev, sizeof(*qinst) * queue_count, GFP_KERNEL);
+       qinst = devm_kcalloc(dev, queue_count, sizeof(*qinst), GFP_KERNEL);
        if (!qinst)
                return -ENOMEM;
        inst->qinsts = qinst;
 
-       chans = devm_kzalloc(dev, sizeof(*chans) * queue_count, GFP_KERNEL);
+       chans = devm_kcalloc(dev, queue_count, sizeof(*chans), GFP_KERNEL);
        if (!chans)
                return -ENOMEM;
        inst->chans = chans;
index edff083f7c4e8b78df49d669d4b4d7a5bbd889fd..8b8c123cae66fb5d6c83d709ced6d9cca1d4d157 100644 (file)
@@ -334,6 +334,17 @@ config DM_CACHE_SMQ
          of less memory utilization, improved performance and increased
          adaptability in the face of changing workloads.
 
+config DM_WRITECACHE
+       tristate "Writecache target"
+       depends on BLK_DEV_DM
+       ---help---
+          The writecache target caches writes on persistent memory or SSD.
+          It is intended for databases or other programs that need extremely
+          low commit latency.
+
+          The writecache target doesn't cache reads because reads are supposed
+          to be cached in standard RAM.
+
 config DM_ERA
        tristate "Era target (EXPERIMENTAL)"
        depends on BLK_DEV_DM
index 63255f3ebd97c6cbbb70a5caab97a83a2f7785ca..822f4e8753bc4b197b93a90df936bd0eeeff464a 100644 (file)
@@ -67,6 +67,7 @@ obj-$(CONFIG_DM_ERA)          += dm-era.o
 obj-$(CONFIG_DM_LOG_WRITES)    += dm-log-writes.o
 obj-$(CONFIG_DM_INTEGRITY)     += dm-integrity.o
 obj-$(CONFIG_DM_ZONED)         += dm-zoned.o
+obj-$(CONFIG_DM_WRITECACHE)    += dm-writecache.o
 
 ifeq ($(CONFIG_DM_UEVENT),y)
 dm-mod-objs                    += dm-uevent.o
index 4d200883c505b1162d9c3527ddfe5692a37ae8fb..17bf109c58e9e4206dd055e81a571bfb79236fd4 100644 (file)
@@ -5,7 +5,7 @@ config BCACHE
        Allows a block device to be used as cache for other devices; uses
        a btree for indexing and the layout is optimized for SSDs.
 
-       See Documentation/bcache.txt for details.
+       See Documentation/admin-guide/bcache.rst for details.
 
 config BCACHE_DEBUG
        bool "Bcache debugging"
index 2a0968c04e21f84572089d89c863645db239aa36..547c9eedc2f4fa3e90cde0149e4be4b48fd93fbf 100644 (file)
@@ -18,7 +18,7 @@
  * as keys are inserted we only sort the pages that have not yet been written.
  * When garbage collection is run, we resort the entire node.
  *
- * All configuration is done via sysfs; see Documentation/bcache.txt.
+ * All configuration is done via sysfs; see Documentation/admin-guide/bcache.rst.
  */
 
 #include "bcache.h"
index c334e6666461750e6e2dfe09ec7e9139c22b0da0..1d096742eb41a01444e7c6412951af5440a6fd28 100644 (file)
@@ -18,7 +18,7 @@
  * as keys are inserted we only sort the pages that have not yet been written.
  * When garbage collection is run, we resort the entire node.
  *
- * All configuration is done via sysfs; see Documentation/bcache.txt.
+ * All configuration is done via sysfs; see Documentation/admin-guide/bcache.rst.
  */
 
 #include "bcache.h"
index a31e55bcc4e565263a285febd0b8ebf7a569f05f..fa4058e4320289b11968f754526931f46079408a 100644 (file)
@@ -1715,7 +1715,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb)
        iter_size = (sb->bucket_size / sb->block_size + 1) *
                sizeof(struct btree_iter_set);
 
-       if (!(c->devices = kzalloc(c->nr_uuids * sizeof(void *), GFP_KERNEL)) ||
+       if (!(c->devices = kcalloc(c->nr_uuids, sizeof(void *), GFP_KERNEL)) ||
            mempool_init_slab_pool(&c->search, 32, bch_search_cache) ||
            mempool_init_kmalloc_pool(&c->bio_meta, 2,
                                      sizeof(struct bbio) + sizeof(struct bio_vec) *
@@ -2041,10 +2041,11 @@ static int cache_alloc(struct cache *ca)
            !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) ||
            !init_fifo(&ca->free_inc,   free << 2, GFP_KERNEL) ||
            !init_heap(&ca->heap,       free << 3, GFP_KERNEL) ||
-           !(ca->buckets       = vzalloc(sizeof(struct bucket) *
-                                         ca->sb.nbuckets)) ||
-           !(ca->prio_buckets  = kzalloc(sizeof(uint64_t) * prio_buckets(ca) *
-                                         2, GFP_KERNEL)) ||
+           !(ca->buckets       = vzalloc(array_size(sizeof(struct bucket),
+                                                    ca->sb.nbuckets))) ||
+           !(ca->prio_buckets  = kzalloc(array3_size(sizeof(uint64_t),
+                                                     prio_buckets(ca), 2),
+                                         GFP_KERNEL)) ||
            !(ca->disk_buckets  = alloc_bucket_pages(GFP_KERNEL, ca)))
                return -ENOMEM;
 
index 8ccbc8f3b3af7ff805398fe3ea7ff719f46ec20f..225b15aa03405464726ffcde0620e0a0c40e959f 100644 (file)
@@ -881,7 +881,8 @@ SHOW(__bch_cache)
                uint16_t q[31], *p, *cached;
                ssize_t ret;
 
-               cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t));
+               cached = p = vmalloc(array_size(sizeof(uint16_t),
+                                               ca->sb.nbuckets));
                if (!p)
                        return -ENOMEM;
 
index e794e3662fddf574deffed39cf4d48716a73b747..b5389890bbc334bac78fe16ee03cd76c9aa3c787 100644 (file)
@@ -19,8 +19,8 @@
 
 struct dm_bio_prison {
        spinlock_t lock;
-       mempool_t cell_pool;
        struct rb_root cells;
+       mempool_t cell_pool;
 };
 
 static struct kmem_cache *_cell_cache;
index f866bc97b0326540138cb9ac10d2b45e71d9a3d8..b092cdc8e1ae3405610cb07f95234bb4040b2d2e 100644 (file)
@@ -21,8 +21,8 @@ struct dm_bio_prison_v2 {
        struct workqueue_struct *wq;
 
        spinlock_t lock;
-       mempool_t cell_pool;
        struct rb_root cells;
+       mempool_t cell_pool;
 };
 
 static struct kmem_cache *_cell_cache;
index 4ab23d0075f615f35b9c996ae658a26456313465..1b5b9ad9e492f30357990cf60878e76d03d51066 100644 (file)
@@ -69,7 +69,7 @@ static int space_init(struct entry_space *es, unsigned nr_entries)
                return 0;
        }
 
-       es->begin = vzalloc(sizeof(struct entry) * nr_entries);
+       es->begin = vzalloc(array_size(nr_entries, sizeof(struct entry)));
        if (!es->begin)
                return -ENOMEM;
 
@@ -588,7 +588,7 @@ static int h_init(struct smq_hash_table *ht, struct entry_space *es, unsigned nr
        nr_buckets = roundup_pow_of_two(max(nr_entries / 4u, 16u));
        ht->hash_bits = __ffs(nr_buckets);
 
-       ht->buckets = vmalloc(sizeof(*ht->buckets) * nr_buckets);
+       ht->buckets = vmalloc(array_size(nr_buckets, sizeof(*ht->buckets)));
        if (!ht->buckets)
                return -ENOMEM;
 
index 001c7124824618e7481e273ca33478b65203d5cf..ce14a3d1f609dfe127f6caff75c3a00a6d99254a 100644 (file)
@@ -371,7 +371,13 @@ struct cache_stats {
 
 struct cache {
        struct dm_target *ti;
-       struct dm_target_callbacks callbacks;
+       spinlock_t lock;
+
+       /*
+        * Fields for converting from sectors to blocks.
+        */
+       int sectors_per_block_shift;
+       sector_t sectors_per_block;
 
        struct dm_cache_metadata *cmd;
 
@@ -402,13 +408,11 @@ struct cache {
        dm_cblock_t cache_size;
 
        /*
-        * Fields for converting from sectors to blocks.
+        * Invalidation fields.
         */
-       sector_t sectors_per_block;
-       int sectors_per_block_shift;
+       spinlock_t invalidation_lock;
+       struct list_head invalidation_requests;
 
-       spinlock_t lock;
-       struct bio_list deferred_bios;
        sector_t migration_threshold;
        wait_queue_head_t migration_wait;
        atomic_t nr_allocated_migrations;
@@ -419,13 +423,11 @@ struct cache {
         */
        atomic_t nr_io_migrations;
 
+       struct bio_list deferred_bios;
+
        struct rw_semaphore quiesce_lock;
 
-       /*
-        * cache_size entries, dirty if set
-        */
-       atomic_t nr_dirty;
-       unsigned long *dirty_bitset;
+       struct dm_target_callbacks callbacks;
 
        /*
         * origin_blocks entries, discarded if set.
@@ -442,17 +444,27 @@ struct cache {
        const char **ctr_args;
 
        struct dm_kcopyd_client *copier;
-       struct workqueue_struct *wq;
        struct work_struct deferred_bio_worker;
        struct work_struct migration_worker;
+       struct workqueue_struct *wq;
        struct delayed_work waker;
        struct dm_bio_prison_v2 *prison;
-       struct bio_set bs;
 
-       mempool_t migration_pool;
+       /*
+        * cache_size entries, dirty if set
+        */
+       unsigned long *dirty_bitset;
+       atomic_t nr_dirty;
 
-       struct dm_cache_policy *policy;
        unsigned policy_nr_args;
+       struct dm_cache_policy *policy;
+
+       /*
+        * Cache features such as write-through.
+        */
+       struct cache_features features;
+
+       struct cache_stats stats;
 
        bool need_tick_bio:1;
        bool sized:1;
@@ -461,25 +473,16 @@ struct cache {
        bool loaded_mappings:1;
        bool loaded_discards:1;
 
-       /*
-        * Cache features such as write-through.
-        */
-       struct cache_features features;
-
-       struct cache_stats stats;
+       struct rw_semaphore background_work_lock;
 
-       /*
-        * Invalidation fields.
-        */
-       spinlock_t invalidation_lock;
-       struct list_head invalidation_requests;
+       struct batcher committer;
+       struct work_struct commit_ws;
 
        struct io_tracker tracker;
 
-       struct work_struct commit_ws;
-       struct batcher committer;
+       mempool_t migration_pool;
 
-       struct rw_semaphore background_work_lock;
+       struct bio_set bs;
 };
 
 struct per_bio_data {
index f21c5d21bf1b2541a2ff6618b6b39dc8162daee2..7d480c930eaf0a1f4fe90238d830ea4ee61daebb 100644 (file)
@@ -31,6 +31,9 @@ struct dm_kobject_holder {
 struct mapped_device {
        struct mutex suspend_lock;
 
+       struct mutex table_devices_lock;
+       struct list_head table_devices;
+
        /*
         * The current mapping (struct dm_table *).
         * Use dm_get_live_table{_fast} or take suspend_lock for
@@ -38,17 +41,14 @@ struct mapped_device {
         */
        void __rcu *map;
 
-       struct list_head table_devices;
-       struct mutex table_devices_lock;
-
        unsigned long flags;
 
-       struct request_queue *queue;
-       int numa_node_id;
-
-       enum dm_queue_mode type;
        /* Protect queue and type against concurrent access. */
        struct mutex type_lock;
+       enum dm_queue_mode type;
+
+       int numa_node_id;
+       struct request_queue *queue;
 
        atomic_t holders;
        atomic_t open_count;
@@ -56,21 +56,21 @@ struct mapped_device {
        struct dm_target *immutable_target;
        struct target_type *immutable_target_type;
 
+       char name[16];
        struct gendisk *disk;
        struct dax_device *dax_dev;
-       char name[16];
-
-       void *interface_ptr;
 
        /*
         * A list of ios that arrived while we were suspended.
         */
-       atomic_t pending[2];
-       wait_queue_head_t wait;
        struct work_struct work;
+       wait_queue_head_t wait;
+       atomic_t pending[2];
        spinlock_t deferred_lock;
        struct bio_list deferred;
 
+       void *interface_ptr;
+
        /*
         * Event handling.
         */
@@ -83,17 +83,17 @@ struct mapped_device {
        /* the number of internal suspends */
        unsigned internal_suspend_count;
 
-       /*
-        * Processing queue (flush)
-        */
-       struct workqueue_struct *wq;
-
        /*
         * io objects are allocated from here.
         */
        struct bio_set io_bs;
        struct bio_set bs;
 
+       /*
+        * Processing queue (flush)
+        */
+       struct workqueue_struct *wq;
+
        /*
         * freeze/thaw support require holding onto a super block
         */
@@ -102,11 +102,11 @@ struct mapped_device {
        /* forced geometry settings */
        struct hd_geometry geometry;
 
-       struct block_device *bdev;
-
        /* kobject and completion */
        struct dm_kobject_holder kobj_holder;
 
+       struct block_device *bdev;
+
        /* zero-length flush that will be cloned and submitted to targets */
        struct bio flush_bio;
 
index da02f4d8e4b95b4eefa7c7146ce28e65653e974e..b61b069c33afbafd17af1951f0f5d8fee4ddf9d0 100644 (file)
@@ -139,25 +139,13 @@ struct crypt_config {
        struct dm_dev *dev;
        sector_t start;
 
-       /*
-        * pool for per bio private data, crypto requests,
-        * encryption requeusts/buffer pages and integrity tags
-        */
-       mempool_t req_pool;
-       mempool_t page_pool;
-       mempool_t tag_pool;
-       unsigned tag_pool_max_sectors;
-
        struct percpu_counter n_allocated_pages;
 
-       struct bio_set bs;
-       struct mutex bio_alloc_lock;
-
        struct workqueue_struct *io_queue;
        struct workqueue_struct *crypt_queue;
 
-       struct task_struct *write_thread;
        wait_queue_head_t write_thread_wait;
+       struct task_struct *write_thread;
        struct rb_root write_tree;
 
        char *cipher;
@@ -213,6 +201,18 @@ struct crypt_config {
        unsigned int integrity_iv_size;
        unsigned int on_disk_tag_size;
 
+       /*
+        * pool for per bio private data, crypto requests,
+        * encryption requeusts/buffer pages and integrity tags
+        */
+       unsigned tag_pool_max_sectors;
+       mempool_t tag_pool;
+       mempool_t req_pool;
+       mempool_t page_pool;
+
+       struct bio_set bs;
+       struct mutex bio_alloc_lock;
+
        u8 *authenc_key; /* space for keys in authenc() format (if used) */
        u8 key[0];
 };
@@ -1878,8 +1878,9 @@ static int crypt_alloc_tfms_skcipher(struct crypt_config *cc, char *ciphermode)
        unsigned i;
        int err;
 
-       cc->cipher_tfm.tfms = kzalloc(cc->tfms_count *
-                                     sizeof(struct crypto_skcipher *), GFP_KERNEL);
+       cc->cipher_tfm.tfms = kcalloc(cc->tfms_count,
+                                     sizeof(struct crypto_skcipher *),
+                                     GFP_KERNEL);
        if (!cc->cipher_tfm.tfms)
                return -ENOMEM;
 
index fc68c7aaef8ed0d19d903c27a676c4d373aec279..86438b2f10dd0a92b0e4fbd46eba6e04fff478e6 100644 (file)
@@ -2448,7 +2448,9 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int
        struct scatterlist **sl;
        unsigned i;
 
-       sl = kvmalloc(ic->journal_sections * sizeof(struct scatterlist *), GFP_KERNEL | __GFP_ZERO);
+       sl = kvmalloc_array(ic->journal_sections,
+                           sizeof(struct scatterlist *),
+                           GFP_KERNEL | __GFP_ZERO);
        if (!sl)
                return NULL;
 
@@ -2464,7 +2466,8 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int
 
                n_pages = (end_index - start_index + 1);
 
-               s = kvmalloc(n_pages * sizeof(struct scatterlist), GFP_KERNEL);
+               s = kvmalloc_array(n_pages, sizeof(struct scatterlist),
+                                  GFP_KERNEL);
                if (!s) {
                        dm_integrity_free_journal_scatterlist(ic, sl);
                        return NULL;
@@ -2643,7 +2646,9 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
                                goto bad;
                        }
 
-                       sg = kvmalloc((ic->journal_pages + 1) * sizeof(struct scatterlist), GFP_KERNEL);
+                       sg = kvmalloc_array(ic->journal_pages + 1,
+                                           sizeof(struct scatterlist),
+                                           GFP_KERNEL);
                        if (!sg) {
                                *error = "Unable to allocate sg list";
                                r = -ENOMEM;
@@ -2709,7 +2714,9 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
                                r = -ENOMEM;
                                goto bad;
                        }
-                       ic->sk_requests = kvmalloc(ic->journal_sections * sizeof(struct skcipher_request *), GFP_KERNEL | __GFP_ZERO);
+                       ic->sk_requests = kvmalloc_array(ic->journal_sections,
+                                                        sizeof(struct skcipher_request *),
+                                                        GFP_KERNEL | __GFP_ZERO);
                        if (!ic->sk_requests) {
                                *error = "Unable to allocate sk requests";
                                r = -ENOMEM;
@@ -2743,7 +2750,8 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
                                        r = -ENOMEM;
                                        goto bad;
                                }
-                               section_req->iv = kmalloc(ivsize * 2, GFP_KERNEL);
+                               section_req->iv = kmalloc_array(ivsize, 2,
+                                                               GFP_KERNEL);
                                if (!section_req->iv) {
                                        skcipher_request_free(section_req);
                                        *error = "Unable to allocate iv";
index 5acf77de5945eb33d856b46509e5ed4b6c5e33f7..b810ea77e6b162df29b0f3f57605317000461285 100644 (file)
@@ -1344,7 +1344,8 @@ static int table_load(struct file *filp, struct dm_ioctl *param, size_t param_si
                        goto err_unlock_md_type;
                }
        } else if (!is_valid_type(dm_get_md_type(md), dm_table_get_type(t))) {
-               DMWARN("can't change device type after initial table load.");
+               DMWARN("can't change device type (old=%u vs new=%u) after initial table load.",
+                      dm_get_md_type(md), dm_table_get_type(t));
                r = -EINVAL;
                goto err_unlock_md_type;
        }
index ce7efc7434be39f9533fd9f05aecab5bd57d4d61..3c7547a3c3715f38ed7fa3e265ed5dea8f6183d0 100644 (file)
@@ -45,7 +45,6 @@ struct dm_kcopyd_client {
        struct dm_io_client *io_client;
 
        wait_queue_head_t destroyq;
-       atomic_t nr_jobs;
 
        mempool_t job_pool;
 
@@ -54,6 +53,8 @@ struct dm_kcopyd_client {
 
        struct dm_kcopyd_throttle *throttle;
 
+       atomic_t nr_jobs;
+
 /*
  * We maintain three lists of jobs:
  *
index abf3521b80a8a67fb437c5c38206c6ece726261e..1f760451e6f48fa06e5c217f2224d78d96c7b612 100644 (file)
@@ -63,27 +63,28 @@ struct dm_region_hash {
 
        /* hash table */
        rwlock_t hash_lock;
-       mempool_t region_pool;
        unsigned mask;
        unsigned nr_buckets;
        unsigned prime;
        unsigned shift;
        struct list_head *buckets;
 
+       /*
+        * If there was a flush failure no regions can be marked clean.
+        */
+       int flush_failure;
+
        unsigned max_recovery; /* Max # of regions to recover in parallel */
 
        spinlock_t region_lock;
        atomic_t recovery_in_flight;
-       struct semaphore recovery_count;
        struct list_head clean_regions;
        struct list_head quiesced_regions;
        struct list_head recovered_regions;
        struct list_head failed_recovered_regions;
+       struct semaphore recovery_count;
 
-       /*
-        * If there was a flush failure no regions can be marked clean.
-        */
-       int flush_failure;
+       mempool_t region_pool;
 
        void *context;
        sector_t target_begin;
@@ -202,7 +203,7 @@ struct dm_region_hash *dm_region_hash_create(
        rh->shift = RH_HASH_SHIFT;
        rh->prime = RH_HASH_MULT;
 
-       rh->buckets = vmalloc(nr_buckets * sizeof(*rh->buckets));
+       rh->buckets = vmalloc(array_size(nr_buckets, sizeof(*rh->buckets)));
        if (!rh->buckets) {
                DMERR("unable to allocate region hash bucket memory");
                kfree(rh);
index f745404da72133681ed7c025a41ce05fae1f0859..97de7a7334d4c59a0e051372b57e8538b9182e5a 100644 (file)
@@ -326,8 +326,8 @@ static int init_origin_hash(void)
 {
        int i;
 
-       _origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
-                          GFP_KERNEL);
+       _origins = kmalloc_array(ORIGIN_HASH_SIZE, sizeof(struct list_head),
+                                GFP_KERNEL);
        if (!_origins) {
                DMERR("unable to allocate memory for _origins");
                return -ENOMEM;
@@ -335,8 +335,9 @@ static int init_origin_hash(void)
        for (i = 0; i < ORIGIN_HASH_SIZE; i++)
                INIT_LIST_HEAD(_origins + i);
 
-       _dm_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
-                             GFP_KERNEL);
+       _dm_origins = kmalloc_array(ORIGIN_HASH_SIZE,
+                                   sizeof(struct list_head),
+                                   GFP_KERNEL);
        if (!_dm_origins) {
                DMERR("unable to allocate memory for _dm_origins");
                kfree(_origins);
index 56059fb56e2d255a0e635fdf56f9c6edfa20f0df..21de30b4e2a16051490ce5a2548c3711a3f0284e 100644 (file)
@@ -915,7 +915,9 @@ static int parse_histogram(const char *h, unsigned *n_histogram_entries,
                if (*q == ',')
                        (*n_histogram_entries)++;
 
-       *histogram_boundaries = kmalloc(*n_histogram_entries * sizeof(unsigned long long), GFP_KERNEL);
+       *histogram_boundaries = kmalloc_array(*n_histogram_entries,
+                                             sizeof(unsigned long long),
+                                             GFP_KERNEL);
        if (!*histogram_boundaries)
                return -ENOMEM;
 
index 7924a6a33ddcf1c8f3902a634a11b62421495213..fae35caf367208ab22cbe6900010ee353f52d666 100644 (file)
@@ -114,7 +114,8 @@ static int alloc_region_table(struct dm_target *ti, unsigned nr_paths)
                return -EINVAL;
        }
 
-       sctx->region_table = vmalloc(nr_slots * sizeof(region_table_slot_t));
+       sctx->region_table = vmalloc(array_size(nr_slots,
+                                               sizeof(region_table_slot_t)));
        if (!sctx->region_table) {
                ti->error = "Cannot allocate region table";
                return -ENOMEM;
index caa51dd351b668cef9735b1f64f317faa126ff26..938766794c2ef3b6caf538a0fa787447eadb160c 100644 (file)
@@ -561,7 +561,7 @@ static char **realloc_argv(unsigned *size, char **old_argv)
                new_size = 8;
                gfp = GFP_NOIO;
        }
-       argv = kmalloc(new_size * sizeof(*argv), gfp);
+       argv = kmalloc_array(new_size, sizeof(*argv), gfp);
        if (argv) {
                memcpy(argv, old_argv, *size * sizeof(*argv));
                *size = new_size;
index 5772756c63c1bb79b70da1469d8480e061f5595f..7945238df1c0a67a8e525697f0e419c7594ed1ad 100644 (file)
@@ -240,9 +240,9 @@ struct pool {
        struct dm_bio_prison *prison;
        struct dm_kcopyd_client *copier;
 
+       struct work_struct worker;
        struct workqueue_struct *wq;
        struct throttle throttle;
-       struct work_struct worker;
        struct delayed_work waker;
        struct delayed_work no_space_timeout;
 
@@ -260,7 +260,6 @@ struct pool {
        struct dm_deferred_set *all_io_ds;
 
        struct dm_thin_new_mapping *next_mapping;
-       mempool_t mapping_pool;
 
        process_bio_fn process_bio;
        process_bio_fn process_discard;
@@ -273,6 +272,8 @@ struct pool {
        process_mapping_fn process_prepared_discard_pt2;
 
        struct dm_bio_prison_cell **cell_sort_array;
+
+       mempool_t mapping_pool;
 };
 
 static enum pool_mode get_pool_mode(struct pool *pool);
@@ -2939,7 +2940,9 @@ static struct pool *pool_create(struct mapped_device *pool_md,
                goto bad_mapping_pool;
        }
 
-       pool->cell_sort_array = vmalloc(sizeof(*pool->cell_sort_array) * CELL_SORT_ARRAY_SIZE);
+       pool->cell_sort_array =
+               vmalloc(array_size(CELL_SORT_ARRAY_SIZE,
+                                  sizeof(*pool->cell_sort_array)));
        if (!pool->cell_sort_array) {
                *error = "Error allocating cell sort array";
                err_p = ERR_PTR(-ENOMEM);
index fc893f636a989e996fd8461c95a039f3fadf00bd..12decdbd722d866ed48a0a6a8d8b8f2e0a6aefbc 100644 (file)
@@ -797,8 +797,9 @@ static int verity_alloc_most_once(struct dm_verity *v)
                return -E2BIG;
        }
 
-       v->validated_blocks = kvzalloc(BITS_TO_LONGS(v->data_blocks) *
-                                      sizeof(unsigned long), GFP_KERNEL);
+       v->validated_blocks = kvcalloc(BITS_TO_LONGS(v->data_blocks),
+                                      sizeof(unsigned long),
+                                      GFP_KERNEL);
        if (!v->validated_blocks) {
                ti->error = "failed to allocate bitset for check_at_most_once";
                return -ENOMEM;
diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c
new file mode 100644 (file)
index 0000000..5961c77
--- /dev/null
@@ -0,0 +1,2305 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2018 Red Hat. All rights reserved.
+ *
+ * This file is released under the GPL.
+ */
+
+#include <linux/device-mapper.h>
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/vmalloc.h>
+#include <linux/kthread.h>
+#include <linux/dm-io.h>
+#include <linux/dm-kcopyd.h>
+#include <linux/dax.h>
+#include <linux/pfn_t.h>
+#include <linux/libnvdimm.h>
+
+#define DM_MSG_PREFIX "writecache"
+
+#define HIGH_WATERMARK                 50
+#define LOW_WATERMARK                  45
+#define MAX_WRITEBACK_JOBS             0
+#define ENDIO_LATENCY                  16
+#define WRITEBACK_LATENCY              64
+#define AUTOCOMMIT_BLOCKS_SSD          65536
+#define AUTOCOMMIT_BLOCKS_PMEM         64
+#define AUTOCOMMIT_MSEC                        1000
+
+#define BITMAP_GRANULARITY     65536
+#if BITMAP_GRANULARITY < PAGE_SIZE
+#undef BITMAP_GRANULARITY
+#define BITMAP_GRANULARITY     PAGE_SIZE
+#endif
+
+#if IS_ENABLED(CONFIG_ARCH_HAS_PMEM_API) && IS_ENABLED(CONFIG_DAX_DRIVER)
+#define DM_WRITECACHE_HAS_PMEM
+#endif
+
+#ifdef DM_WRITECACHE_HAS_PMEM
+#define pmem_assign(dest, src)                                 \
+do {                                                           \
+       typeof(dest) uniq = (src);                              \
+       memcpy_flushcache(&(dest), &uniq, sizeof(dest));        \
+} while (0)
+#else
+#define pmem_assign(dest, src) ((dest) = (src))
+#endif
+
+#if defined(__HAVE_ARCH_MEMCPY_MCSAFE) && defined(DM_WRITECACHE_HAS_PMEM)
+#define DM_WRITECACHE_HANDLE_HARDWARE_ERRORS
+#endif
+
+#define MEMORY_SUPERBLOCK_MAGIC                0x23489321
+#define MEMORY_SUPERBLOCK_VERSION      1
+
+struct wc_memory_entry {
+       __le64 original_sector;
+       __le64 seq_count;
+};
+
+struct wc_memory_superblock {
+       union {
+               struct {
+                       __le32 magic;
+                       __le32 version;
+                       __le32 block_size;
+                       __le32 pad;
+                       __le64 n_blocks;
+                       __le64 seq_count;
+               };
+               __le64 padding[8];
+       };
+       struct wc_memory_entry entries[0];
+};
+
+struct wc_entry {
+       struct rb_node rb_node;
+       struct list_head lru;
+       unsigned short wc_list_contiguous;
+       bool write_in_progress
+#if BITS_PER_LONG == 64
+               :1
+#endif
+       ;
+       unsigned long index
+#if BITS_PER_LONG == 64
+               :47
+#endif
+       ;
+#ifdef DM_WRITECACHE_HANDLE_HARDWARE_ERRORS
+       uint64_t original_sector;
+       uint64_t seq_count;
+#endif
+};
+
+#ifdef DM_WRITECACHE_HAS_PMEM
+#define WC_MODE_PMEM(wc)                       ((wc)->pmem_mode)
+#define WC_MODE_FUA(wc)                                ((wc)->writeback_fua)
+#else
+#define WC_MODE_PMEM(wc)                       false
+#define WC_MODE_FUA(wc)                                false
+#endif
+#define WC_MODE_SORT_FREELIST(wc)              (!WC_MODE_PMEM(wc))
+
+struct dm_writecache {
+       struct mutex lock;
+       struct list_head lru;
+       union {
+               struct list_head freelist;
+               struct {
+                       struct rb_root freetree;
+                       struct wc_entry *current_free;
+               };
+       };
+       struct rb_root tree;
+
+       size_t freelist_size;
+       size_t writeback_size;
+       size_t freelist_high_watermark;
+       size_t freelist_low_watermark;
+
+       unsigned uncommitted_blocks;
+       unsigned autocommit_blocks;
+       unsigned max_writeback_jobs;
+
+       int error;
+
+       unsigned long autocommit_jiffies;
+       struct timer_list autocommit_timer;
+       struct wait_queue_head freelist_wait;
+
+       atomic_t bio_in_progress[2];
+       struct wait_queue_head bio_in_progress_wait[2];
+
+       struct dm_target *ti;
+       struct dm_dev *dev;
+       struct dm_dev *ssd_dev;
+       void *memory_map;
+       uint64_t memory_map_size;
+       size_t metadata_sectors;
+       size_t n_blocks;
+       uint64_t seq_count;
+       void *block_start;
+       struct wc_entry *entries;
+       unsigned block_size;
+       unsigned char block_size_bits;
+
+       bool pmem_mode:1;
+       bool writeback_fua:1;
+
+       bool overwrote_committed:1;
+       bool memory_vmapped:1;
+
+       bool high_wm_percent_set:1;
+       bool low_wm_percent_set:1;
+       bool max_writeback_jobs_set:1;
+       bool autocommit_blocks_set:1;
+       bool autocommit_time_set:1;
+       bool writeback_fua_set:1;
+       bool flush_on_suspend:1;
+
+       unsigned writeback_all;
+       struct workqueue_struct *writeback_wq;
+       struct work_struct writeback_work;
+       struct work_struct flush_work;
+
+       struct dm_io_client *dm_io;
+
+       raw_spinlock_t endio_list_lock;
+       struct list_head endio_list;
+       struct task_struct *endio_thread;
+
+       struct task_struct *flush_thread;
+       struct bio_list flush_list;
+
+       struct dm_kcopyd_client *dm_kcopyd;
+       unsigned long *dirty_bitmap;
+       unsigned dirty_bitmap_size;
+
+       struct bio_set bio_set;
+       mempool_t copy_pool;
+};
+
+#define WB_LIST_INLINE         16
+
+struct writeback_struct {
+       struct list_head endio_entry;
+       struct dm_writecache *wc;
+       struct wc_entry **wc_list;
+       unsigned wc_list_n;
+       unsigned page_offset;
+       struct page *page;
+       struct wc_entry *wc_list_inline[WB_LIST_INLINE];
+       struct bio bio;
+};
+
+struct copy_struct {
+       struct list_head endio_entry;
+       struct dm_writecache *wc;
+       struct wc_entry *e;
+       unsigned n_entries;
+       int error;
+};
+
+DECLARE_DM_KCOPYD_THROTTLE_WITH_MODULE_PARM(dm_writecache_throttle,
+                                           "A percentage of time allocated for data copying");
+
+static void wc_lock(struct dm_writecache *wc)
+{
+       mutex_lock(&wc->lock);
+}
+
+static void wc_unlock(struct dm_writecache *wc)
+{
+       mutex_unlock(&wc->lock);
+}
+
+#ifdef DM_WRITECACHE_HAS_PMEM
+static int persistent_memory_claim(struct dm_writecache *wc)
+{
+       int r;
+       loff_t s;
+       long p, da;
+       pfn_t pfn;
+       int id;
+       struct page **pages;
+
+       wc->memory_vmapped = false;
+
+       if (!wc->ssd_dev->dax_dev) {
+               r = -EOPNOTSUPP;
+               goto err1;
+       }
+       s = wc->memory_map_size;
+       p = s >> PAGE_SHIFT;
+       if (!p) {
+               r = -EINVAL;
+               goto err1;
+       }
+       if (p != s >> PAGE_SHIFT) {
+               r = -EOVERFLOW;
+               goto err1;
+       }
+
+       id = dax_read_lock();
+
+       da = dax_direct_access(wc->ssd_dev->dax_dev, 0, p, &wc->memory_map, &pfn);
+       if (da < 0) {
+               wc->memory_map = NULL;
+               r = da;
+               goto err2;
+       }
+       if (!pfn_t_has_page(pfn)) {
+               wc->memory_map = NULL;
+               r = -EOPNOTSUPP;
+               goto err2;
+       }
+       if (da != p) {
+               long i;
+               wc->memory_map = NULL;
+               pages = kvmalloc(p * sizeof(struct page *), GFP_KERNEL);
+               if (!pages) {
+                       r = -ENOMEM;
+                       goto err2;
+               }
+               i = 0;
+               do {
+                       long daa;
+                       void *dummy_addr;
+                       daa = dax_direct_access(wc->ssd_dev->dax_dev, i, p - i,
+                                               &dummy_addr, &pfn);
+                       if (daa <= 0) {
+                               r = daa ? daa : -EINVAL;
+                               goto err3;
+                       }
+                       if (!pfn_t_has_page(pfn)) {
+                               r = -EOPNOTSUPP;
+                               goto err3;
+                       }
+                       while (daa-- && i < p) {
+                               pages[i++] = pfn_t_to_page(pfn);
+                               pfn.val++;
+                       }
+               } while (i < p);
+               wc->memory_map = vmap(pages, p, VM_MAP, PAGE_KERNEL);
+               if (!wc->memory_map) {
+                       r = -ENOMEM;
+                       goto err3;
+               }
+               kvfree(pages);
+               wc->memory_vmapped = true;
+       }
+
+       dax_read_unlock(id);
+       return 0;
+err3:
+       kvfree(pages);
+err2:
+       dax_read_unlock(id);
+err1:
+       return r;
+}
+#else
+static int persistent_memory_claim(struct dm_writecache *wc)
+{
+       BUG();
+}
+#endif
+
+static void persistent_memory_release(struct dm_writecache *wc)
+{
+       if (wc->memory_vmapped)
+               vunmap(wc->memory_map);
+}
+
+static struct page *persistent_memory_page(void *addr)
+{
+       if (is_vmalloc_addr(addr))
+               return vmalloc_to_page(addr);
+       else
+               return virt_to_page(addr);
+}
+
+static unsigned persistent_memory_page_offset(void *addr)
+{
+       return (unsigned long)addr & (PAGE_SIZE - 1);
+}
+
+static void persistent_memory_flush_cache(void *ptr, size_t size)
+{
+       if (is_vmalloc_addr(ptr))
+               flush_kernel_vmap_range(ptr, size);
+}
+
+static void persistent_memory_invalidate_cache(void *ptr, size_t size)
+{
+       if (is_vmalloc_addr(ptr))
+               invalidate_kernel_vmap_range(ptr, size);
+}
+
+static struct wc_memory_superblock *sb(struct dm_writecache *wc)
+{
+       return wc->memory_map;
+}
+
+static struct wc_memory_entry *memory_entry(struct dm_writecache *wc, struct wc_entry *e)
+{
+       if (is_power_of_2(sizeof(struct wc_entry)) && 0)
+               return &sb(wc)->entries[e - wc->entries];
+       else
+               return &sb(wc)->entries[e->index];
+}
+
+static void *memory_data(struct dm_writecache *wc, struct wc_entry *e)
+{
+       return (char *)wc->block_start + (e->index << wc->block_size_bits);
+}
+
+static sector_t cache_sector(struct dm_writecache *wc, struct wc_entry *e)
+{
+       return wc->metadata_sectors +
+               ((sector_t)e->index << (wc->block_size_bits - SECTOR_SHIFT));
+}
+
+static uint64_t read_original_sector(struct dm_writecache *wc, struct wc_entry *e)
+{
+#ifdef DM_WRITECACHE_HANDLE_HARDWARE_ERRORS
+       return e->original_sector;
+#else
+       return le64_to_cpu(memory_entry(wc, e)->original_sector);
+#endif
+}
+
+static uint64_t read_seq_count(struct dm_writecache *wc, struct wc_entry *e)
+{
+#ifdef DM_WRITECACHE_HANDLE_HARDWARE_ERRORS
+       return e->seq_count;
+#else
+       return le64_to_cpu(memory_entry(wc, e)->seq_count);
+#endif
+}
+
+static void clear_seq_count(struct dm_writecache *wc, struct wc_entry *e)
+{
+#ifdef DM_WRITECACHE_HANDLE_HARDWARE_ERRORS
+       e->seq_count = -1;
+#endif
+       pmem_assign(memory_entry(wc, e)->seq_count, cpu_to_le64(-1));
+}
+
+static void write_original_sector_seq_count(struct dm_writecache *wc, struct wc_entry *e,
+                                           uint64_t original_sector, uint64_t seq_count)
+{
+       struct wc_memory_entry me;
+#ifdef DM_WRITECACHE_HANDLE_HARDWARE_ERRORS
+       e->original_sector = original_sector;
+       e->seq_count = seq_count;
+#endif
+       me.original_sector = cpu_to_le64(original_sector);
+       me.seq_count = cpu_to_le64(seq_count);
+       pmem_assign(*memory_entry(wc, e), me);
+}
+
+#define writecache_error(wc, err, msg, arg...)                         \
+do {                                                                   \
+       if (!cmpxchg(&(wc)->error, 0, err))                             \
+               DMERR(msg, ##arg);                                      \
+       wake_up(&(wc)->freelist_wait);                                  \
+} while (0)
+
+#define writecache_has_error(wc)       (unlikely(READ_ONCE((wc)->error)))
+
+static void writecache_flush_all_metadata(struct dm_writecache *wc)
+{
+       if (!WC_MODE_PMEM(wc))
+               memset(wc->dirty_bitmap, -1, wc->dirty_bitmap_size);
+}
+
+static void writecache_flush_region(struct dm_writecache *wc, void *ptr, size_t size)
+{
+       if (!WC_MODE_PMEM(wc))
+               __set_bit(((char *)ptr - (char *)wc->memory_map) / BITMAP_GRANULARITY,
+                         wc->dirty_bitmap);
+}
+
+static void writecache_disk_flush(struct dm_writecache *wc, struct dm_dev *dev);
+
+struct io_notify {
+       struct dm_writecache *wc;
+       struct completion c;
+       atomic_t count;
+};
+
+static void writecache_notify_io(unsigned long error, void *context)
+{
+       struct io_notify *endio = context;
+
+       if (unlikely(error != 0))
+               writecache_error(endio->wc, -EIO, "error writing metadata");
+       BUG_ON(atomic_read(&endio->count) <= 0);
+       if (atomic_dec_and_test(&endio->count))
+               complete(&endio->c);
+}
+
+static void ssd_commit_flushed(struct dm_writecache *wc)
+{
+       struct dm_io_region region;
+       struct dm_io_request req;
+       struct io_notify endio = {
+               wc,
+               COMPLETION_INITIALIZER_ONSTACK(endio.c),
+               ATOMIC_INIT(1),
+       };
+       unsigned bitmap_bits = wc->dirty_bitmap_size * BITS_PER_LONG;
+       unsigned i = 0;
+
+       while (1) {
+               unsigned j;
+               i = find_next_bit(wc->dirty_bitmap, bitmap_bits, i);
+               if (unlikely(i == bitmap_bits))
+                       break;
+               j = find_next_zero_bit(wc->dirty_bitmap, bitmap_bits, i);
+
+               region.bdev = wc->ssd_dev->bdev;
+               region.sector = (sector_t)i * (BITMAP_GRANULARITY >> SECTOR_SHIFT);
+               region.count = (sector_t)(j - i) * (BITMAP_GRANULARITY >> SECTOR_SHIFT);
+
+               if (unlikely(region.sector >= wc->metadata_sectors))
+                       break;
+               if (unlikely(region.sector + region.count > wc->metadata_sectors))
+                       region.count = wc->metadata_sectors - region.sector;
+
+               atomic_inc(&endio.count);
+               req.bi_op = REQ_OP_WRITE;
+               req.bi_op_flags = REQ_SYNC;
+               req.mem.type = DM_IO_VMA;
+               req.mem.ptr.vma = (char *)wc->memory_map + (size_t)i * BITMAP_GRANULARITY;
+               req.client = wc->dm_io;
+               req.notify.fn = writecache_notify_io;
+               req.notify.context = &endio;
+
+               /* writing via async dm-io (implied by notify.fn above) won't return an error */
+               (void) dm_io(&req, 1, &region, NULL);
+               i = j;
+       }
+
+       writecache_notify_io(0, &endio);
+       wait_for_completion_io(&endio.c);
+
+       writecache_disk_flush(wc, wc->ssd_dev);
+
+       memset(wc->dirty_bitmap, 0, wc->dirty_bitmap_size);
+}
+
+static void writecache_commit_flushed(struct dm_writecache *wc)
+{
+       if (WC_MODE_PMEM(wc))
+               wmb();
+       else
+               ssd_commit_flushed(wc);
+}
+
+static void writecache_disk_flush(struct dm_writecache *wc, struct dm_dev *dev)
+{
+       int r;
+       struct dm_io_region region;
+       struct dm_io_request req;
+
+       region.bdev = dev->bdev;
+       region.sector = 0;
+       region.count = 0;
+       req.bi_op = REQ_OP_WRITE;
+       req.bi_op_flags = REQ_PREFLUSH;
+       req.mem.type = DM_IO_KMEM;
+       req.mem.ptr.addr = NULL;
+       req.client = wc->dm_io;
+       req.notify.fn = NULL;
+
+       r = dm_io(&req, 1, &region, NULL);
+       if (unlikely(r))
+               writecache_error(wc, r, "error flushing metadata: %d", r);
+}
+
+static void writecache_wait_for_ios(struct dm_writecache *wc, int direction)
+{
+       wait_event(wc->bio_in_progress_wait[direction],
+                  !atomic_read(&wc->bio_in_progress[direction]));
+}
+
+#define WFE_RETURN_FOLLOWING   1
+#define WFE_LOWEST_SEQ         2
+
+static struct wc_entry *writecache_find_entry(struct dm_writecache *wc,
+                                             uint64_t block, int flags)
+{
+       struct wc_entry *e;
+       struct rb_node *node = wc->tree.rb_node;
+
+       if (unlikely(!node))
+               return NULL;
+
+       while (1) {
+               e = container_of(node, struct wc_entry, rb_node);
+               if (read_original_sector(wc, e) == block)
+                       break;
+               node = (read_original_sector(wc, e) >= block ?
+                       e->rb_node.rb_left : e->rb_node.rb_right);
+               if (unlikely(!node)) {
+                       if (!(flags & WFE_RETURN_FOLLOWING)) {
+                               return NULL;
+                       }
+                       if (read_original_sector(wc, e) >= block) {
+                               break;
+                       } else {
+                               node = rb_next(&e->rb_node);
+                               if (unlikely(!node)) {
+                                       return NULL;
+                               }
+                               e = container_of(node, struct wc_entry, rb_node);
+                               break;
+                       }
+               }
+       }
+
+       while (1) {
+               struct wc_entry *e2;
+               if (flags & WFE_LOWEST_SEQ)
+                       node = rb_prev(&e->rb_node);
+               else
+                       node = rb_next(&e->rb_node);
+               if (!node)
+                       return e;
+               e2 = container_of(node, struct wc_entry, rb_node);
+               if (read_original_sector(wc, e2) != block)
+                       return e;
+               e = e2;
+       }
+}
+
+static void writecache_insert_entry(struct dm_writecache *wc, struct wc_entry *ins)
+{
+       struct wc_entry *e;
+       struct rb_node **node = &wc->tree.rb_node, *parent = NULL;
+
+       while (*node) {
+               e = container_of(*node, struct wc_entry, rb_node);
+               parent = &e->rb_node;
+               if (read_original_sector(wc, e) > read_original_sector(wc, ins))
+                       node = &parent->rb_left;
+               else
+                       node = &parent->rb_right;
+       }
+       rb_link_node(&ins->rb_node, parent, node);
+       rb_insert_color(&ins->rb_node, &wc->tree);
+       list_add(&ins->lru, &wc->lru);
+}
+
+static void writecache_unlink(struct dm_writecache *wc, struct wc_entry *e)
+{
+       list_del(&e->lru);
+       rb_erase(&e->rb_node, &wc->tree);
+}
+
+static void writecache_add_to_freelist(struct dm_writecache *wc, struct wc_entry *e)
+{
+       if (WC_MODE_SORT_FREELIST(wc)) {
+               struct rb_node **node = &wc->freetree.rb_node, *parent = NULL;
+               if (unlikely(!*node))
+                       wc->current_free = e;
+               while (*node) {
+                       parent = *node;
+                       if (&e->rb_node < *node)
+                               node = &parent->rb_left;
+                       else
+                               node = &parent->rb_right;
+               }
+               rb_link_node(&e->rb_node, parent, node);
+               rb_insert_color(&e->rb_node, &wc->freetree);
+       } else {
+               list_add_tail(&e->lru, &wc->freelist);
+       }
+       wc->freelist_size++;
+}
+
+static struct wc_entry *writecache_pop_from_freelist(struct dm_writecache *wc)
+{
+       struct wc_entry *e;
+
+       if (WC_MODE_SORT_FREELIST(wc)) {
+               struct rb_node *next;
+               if (unlikely(!wc->current_free))
+                       return NULL;
+               e = wc->current_free;
+               next = rb_next(&e->rb_node);
+               rb_erase(&e->rb_node, &wc->freetree);
+               if (unlikely(!next))
+                       next = rb_first(&wc->freetree);
+               wc->current_free = next ? container_of(next, struct wc_entry, rb_node) : NULL;
+       } else {
+               if (unlikely(list_empty(&wc->freelist)))
+                       return NULL;
+               e = container_of(wc->freelist.next, struct wc_entry, lru);
+               list_del(&e->lru);
+       }
+       wc->freelist_size--;
+       if (unlikely(wc->freelist_size + wc->writeback_size <= wc->freelist_high_watermark))
+               queue_work(wc->writeback_wq, &wc->writeback_work);
+
+       return e;
+}
+
+static void writecache_free_entry(struct dm_writecache *wc, struct wc_entry *e)
+{
+       writecache_unlink(wc, e);
+       writecache_add_to_freelist(wc, e);
+       clear_seq_count(wc, e);
+       writecache_flush_region(wc, memory_entry(wc, e), sizeof(struct wc_memory_entry));
+       if (unlikely(waitqueue_active(&wc->freelist_wait)))
+               wake_up(&wc->freelist_wait);
+}
+
+static void writecache_wait_on_freelist(struct dm_writecache *wc)
+{
+       DEFINE_WAIT(wait);
+
+       prepare_to_wait(&wc->freelist_wait, &wait, TASK_UNINTERRUPTIBLE);
+       wc_unlock(wc);
+       io_schedule();
+       finish_wait(&wc->freelist_wait, &wait);
+       wc_lock(wc);
+}
+
+static void writecache_poison_lists(struct dm_writecache *wc)
+{
+       /*
+        * Catch incorrect access to these values while the device is suspended.
+        */
+       memset(&wc->tree, -1, sizeof wc->tree);
+       wc->lru.next = LIST_POISON1;
+       wc->lru.prev = LIST_POISON2;
+       wc->freelist.next = LIST_POISON1;
+       wc->freelist.prev = LIST_POISON2;
+}
+
+static void writecache_flush_entry(struct dm_writecache *wc, struct wc_entry *e)
+{
+       writecache_flush_region(wc, memory_entry(wc, e), sizeof(struct wc_memory_entry));
+       if (WC_MODE_PMEM(wc))
+               writecache_flush_region(wc, memory_data(wc, e), wc->block_size);
+}
+
+static bool writecache_entry_is_committed(struct dm_writecache *wc, struct wc_entry *e)
+{
+       return read_seq_count(wc, e) < wc->seq_count;
+}
+
+static void writecache_flush(struct dm_writecache *wc)
+{
+       struct wc_entry *e, *e2;
+       bool need_flush_after_free;
+
+       wc->uncommitted_blocks = 0;
+       del_timer(&wc->autocommit_timer);
+
+       if (list_empty(&wc->lru))
+               return;
+
+       e = container_of(wc->lru.next, struct wc_entry, lru);
+       if (writecache_entry_is_committed(wc, e)) {
+               if (wc->overwrote_committed) {
+                       writecache_wait_for_ios(wc, WRITE);
+                       writecache_disk_flush(wc, wc->ssd_dev);
+                       wc->overwrote_committed = false;
+               }
+               return;
+       }
+       while (1) {
+               writecache_flush_entry(wc, e);
+               if (unlikely(e->lru.next == &wc->lru))
+                       break;
+               e2 = container_of(e->lru.next, struct wc_entry, lru);
+               if (writecache_entry_is_committed(wc, e2))
+                       break;
+               e = e2;
+               cond_resched();
+       }
+       writecache_commit_flushed(wc);
+
+       writecache_wait_for_ios(wc, WRITE);
+
+       wc->seq_count++;
+       pmem_assign(sb(wc)->seq_count, cpu_to_le64(wc->seq_count));
+       writecache_flush_region(wc, &sb(wc)->seq_count, sizeof sb(wc)->seq_count);
+       writecache_commit_flushed(wc);
+
+       wc->overwrote_committed = false;
+
+       need_flush_after_free = false;
+       while (1) {
+               /* Free another committed entry with lower seq-count */
+               struct rb_node *rb_node = rb_prev(&e->rb_node);
+
+               if (rb_node) {
+                       e2 = container_of(rb_node, struct wc_entry, rb_node);
+                       if (read_original_sector(wc, e2) == read_original_sector(wc, e) &&
+                           likely(!e2->write_in_progress)) {
+                               writecache_free_entry(wc, e2);
+                               need_flush_after_free = true;
+                       }
+               }
+               if (unlikely(e->lru.prev == &wc->lru))
+                       break;
+               e = container_of(e->lru.prev, struct wc_entry, lru);
+               cond_resched();
+       }
+
+       if (need_flush_after_free)
+               writecache_commit_flushed(wc);
+}
+
+static void writecache_flush_work(struct work_struct *work)
+{
+       struct dm_writecache *wc = container_of(work, struct dm_writecache, flush_work);
+
+       wc_lock(wc);
+       writecache_flush(wc);
+       wc_unlock(wc);
+}
+
+static void writecache_autocommit_timer(struct timer_list *t)
+{
+       struct dm_writecache *wc = from_timer(wc, t, autocommit_timer);
+       if (!writecache_has_error(wc))
+               queue_work(wc->writeback_wq, &wc->flush_work);
+}
+
+static void writecache_schedule_autocommit(struct dm_writecache *wc)
+{
+       if (!timer_pending(&wc->autocommit_timer))
+               mod_timer(&wc->autocommit_timer, jiffies + wc->autocommit_jiffies);
+}
+
+static void writecache_discard(struct dm_writecache *wc, sector_t start, sector_t end)
+{
+       struct wc_entry *e;
+       bool discarded_something = false;
+
+       e = writecache_find_entry(wc, start, WFE_RETURN_FOLLOWING | WFE_LOWEST_SEQ);
+       if (unlikely(!e))
+               return;
+
+       while (read_original_sector(wc, e) < end) {
+               struct rb_node *node = rb_next(&e->rb_node);
+
+               if (likely(!e->write_in_progress)) {
+                       if (!discarded_something) {
+                               writecache_wait_for_ios(wc, READ);
+                               writecache_wait_for_ios(wc, WRITE);
+                               discarded_something = true;
+                       }
+                       writecache_free_entry(wc, e);
+               }
+
+               if (!node)
+                       break;
+
+               e = container_of(node, struct wc_entry, rb_node);
+       }
+
+       if (discarded_something)
+               writecache_commit_flushed(wc);
+}
+
+static bool writecache_wait_for_writeback(struct dm_writecache *wc)
+{
+       if (wc->writeback_size) {
+               writecache_wait_on_freelist(wc);
+               return true;
+       }
+       return false;
+}
+
+static void writecache_suspend(struct dm_target *ti)
+{
+       struct dm_writecache *wc = ti->private;
+       bool flush_on_suspend;
+
+       del_timer_sync(&wc->autocommit_timer);
+
+       wc_lock(wc);
+       writecache_flush(wc);
+       flush_on_suspend = wc->flush_on_suspend;
+       if (flush_on_suspend) {
+               wc->flush_on_suspend = false;
+               wc->writeback_all++;
+               queue_work(wc->writeback_wq, &wc->writeback_work);
+       }
+       wc_unlock(wc);
+
+       flush_workqueue(wc->writeback_wq);
+
+       wc_lock(wc);
+       if (flush_on_suspend)
+               wc->writeback_all--;
+       while (writecache_wait_for_writeback(wc));
+
+       if (WC_MODE_PMEM(wc))
+               persistent_memory_flush_cache(wc->memory_map, wc->memory_map_size);
+
+       writecache_poison_lists(wc);
+
+       wc_unlock(wc);
+}
+
+static int writecache_alloc_entries(struct dm_writecache *wc)
+{
+       size_t b;
+
+       if (wc->entries)
+               return 0;
+       wc->entries = vmalloc(sizeof(struct wc_entry) * wc->n_blocks);
+       if (!wc->entries)
+               return -ENOMEM;
+       for (b = 0; b < wc->n_blocks; b++) {
+               struct wc_entry *e = &wc->entries[b];
+               e->index = b;
+               e->write_in_progress = false;
+       }
+
+       return 0;
+}
+
+static void writecache_resume(struct dm_target *ti)
+{
+       struct dm_writecache *wc = ti->private;
+       size_t b;
+       bool need_flush = false;
+       __le64 sb_seq_count;
+       int r;
+
+       wc_lock(wc);
+
+       if (WC_MODE_PMEM(wc))
+               persistent_memory_invalidate_cache(wc->memory_map, wc->memory_map_size);
+
+       wc->tree = RB_ROOT;
+       INIT_LIST_HEAD(&wc->lru);
+       if (WC_MODE_SORT_FREELIST(wc)) {
+               wc->freetree = RB_ROOT;
+               wc->current_free = NULL;
+       } else {
+               INIT_LIST_HEAD(&wc->freelist);
+       }
+       wc->freelist_size = 0;
+
+       r = memcpy_mcsafe(&sb_seq_count, &sb(wc)->seq_count, sizeof(uint64_t));
+       if (r) {
+               writecache_error(wc, r, "hardware memory error when reading superblock: %d", r);
+               sb_seq_count = cpu_to_le64(0);
+       }
+       wc->seq_count = le64_to_cpu(sb_seq_count);
+
+#ifdef DM_WRITECACHE_HANDLE_HARDWARE_ERRORS
+       for (b = 0; b < wc->n_blocks; b++) {
+               struct wc_entry *e = &wc->entries[b];
+               struct wc_memory_entry wme;
+               if (writecache_has_error(wc)) {
+                       e->original_sector = -1;
+                       e->seq_count = -1;
+                       continue;
+               }
+               r = memcpy_mcsafe(&wme, memory_entry(wc, e), sizeof(struct wc_memory_entry));
+               if (r) {
+                       writecache_error(wc, r, "hardware memory error when reading metadata entry %lu: %d",
+                                        (unsigned long)b, r);
+                       e->original_sector = -1;
+                       e->seq_count = -1;
+               } else {
+                       e->original_sector = le64_to_cpu(wme.original_sector);
+                       e->seq_count = le64_to_cpu(wme.seq_count);
+               }
+       }
+#endif
+       for (b = 0; b < wc->n_blocks; b++) {
+               struct wc_entry *e = &wc->entries[b];
+               if (!writecache_entry_is_committed(wc, e)) {
+                       if (read_seq_count(wc, e) != -1) {
+erase_this:
+                               clear_seq_count(wc, e);
+                               need_flush = true;
+                       }
+                       writecache_add_to_freelist(wc, e);
+               } else {
+                       struct wc_entry *old;
+
+                       old = writecache_find_entry(wc, read_original_sector(wc, e), 0);
+                       if (!old) {
+                               writecache_insert_entry(wc, e);
+                       } else {
+                               if (read_seq_count(wc, old) == read_seq_count(wc, e)) {
+                                       writecache_error(wc, -EINVAL,
+                                                "two identical entries, position %llu, sector %llu, sequence %llu",
+                                                (unsigned long long)b, (unsigned long long)read_original_sector(wc, e),
+                                                (unsigned long long)read_seq_count(wc, e));
+                               }
+                               if (read_seq_count(wc, old) > read_seq_count(wc, e)) {
+                                       goto erase_this;
+                               } else {
+                                       writecache_free_entry(wc, old);
+                                       writecache_insert_entry(wc, e);
+                                       need_flush = true;
+                               }
+                       }
+               }
+               cond_resched();
+       }
+
+       if (need_flush) {
+               writecache_flush_all_metadata(wc);
+               writecache_commit_flushed(wc);
+       }
+
+       wc_unlock(wc);
+}
+
+static int process_flush_mesg(unsigned argc, char **argv, struct dm_writecache *wc)
+{
+       if (argc != 1)
+               return -EINVAL;
+
+       wc_lock(wc);
+       if (dm_suspended(wc->ti)) {
+               wc_unlock(wc);
+               return -EBUSY;
+       }
+       if (writecache_has_error(wc)) {
+               wc_unlock(wc);
+               return -EIO;
+       }
+
+       writecache_flush(wc);
+       wc->writeback_all++;
+       queue_work(wc->writeback_wq, &wc->writeback_work);
+       wc_unlock(wc);
+
+       flush_workqueue(wc->writeback_wq);
+
+       wc_lock(wc);
+       wc->writeback_all--;
+       if (writecache_has_error(wc)) {
+               wc_unlock(wc);
+               return -EIO;
+       }
+       wc_unlock(wc);
+
+       return 0;
+}
+
+static int process_flush_on_suspend_mesg(unsigned argc, char **argv, struct dm_writecache *wc)
+{
+       if (argc != 1)
+               return -EINVAL;
+
+       wc_lock(wc);
+       wc->flush_on_suspend = true;
+       wc_unlock(wc);
+
+       return 0;
+}
+
+static int writecache_message(struct dm_target *ti, unsigned argc, char **argv,
+                             char *result, unsigned maxlen)
+{
+       int r = -EINVAL;
+       struct dm_writecache *wc = ti->private;
+
+       if (!strcasecmp(argv[0], "flush"))
+               r = process_flush_mesg(argc, argv, wc);
+       else if (!strcasecmp(argv[0], "flush_on_suspend"))
+               r = process_flush_on_suspend_mesg(argc, argv, wc);
+       else
+               DMERR("unrecognised message received: %s", argv[0]);
+
+       return r;
+}
+
+static void bio_copy_block(struct dm_writecache *wc, struct bio *bio, void *data)
+{
+       void *buf;
+       unsigned long flags;
+       unsigned size;
+       int rw = bio_data_dir(bio);
+       unsigned remaining_size = wc->block_size;
+
+       do {
+               struct bio_vec bv = bio_iter_iovec(bio, bio->bi_iter);
+               buf = bvec_kmap_irq(&bv, &flags);
+               size = bv.bv_len;
+               if (unlikely(size > remaining_size))
+                       size = remaining_size;
+
+               if (rw == READ) {
+                       int r;
+                       r = memcpy_mcsafe(buf, data, size);
+                       flush_dcache_page(bio_page(bio));
+                       if (unlikely(r)) {
+                               writecache_error(wc, r, "hardware memory error when reading data: %d", r);
+                               bio->bi_status = BLK_STS_IOERR;
+                       }
+               } else {
+                       flush_dcache_page(bio_page(bio));
+                       memcpy_flushcache(data, buf, size);
+               }
+
+               bvec_kunmap_irq(buf, &flags);
+
+               data = (char *)data + size;
+               remaining_size -= size;
+               bio_advance(bio, size);
+       } while (unlikely(remaining_size));
+}
+
+static int writecache_flush_thread(void *data)
+{
+       struct dm_writecache *wc = data;
+
+       while (1) {
+               struct bio *bio;
+
+               wc_lock(wc);
+               bio = bio_list_pop(&wc->flush_list);
+               if (!bio) {
+                       set_current_state(TASK_INTERRUPTIBLE);
+                       wc_unlock(wc);
+
+                       if (unlikely(kthread_should_stop())) {
+                               set_current_state(TASK_RUNNING);
+                               break;
+                       }
+
+                       schedule();
+                       continue;
+               }
+
+               if (bio_op(bio) == REQ_OP_DISCARD) {
+                       writecache_discard(wc, bio->bi_iter.bi_sector,
+                                          bio_end_sector(bio));
+                       wc_unlock(wc);
+                       bio_set_dev(bio, wc->dev->bdev);
+                       generic_make_request(bio);
+               } else {
+                       writecache_flush(wc);
+                       wc_unlock(wc);
+                       if (writecache_has_error(wc))
+                               bio->bi_status = BLK_STS_IOERR;
+                       bio_endio(bio);
+               }
+       }
+
+       return 0;
+}
+
+static void writecache_offload_bio(struct dm_writecache *wc, struct bio *bio)
+{
+       if (bio_list_empty(&wc->flush_list))
+               wake_up_process(wc->flush_thread);
+       bio_list_add(&wc->flush_list, bio);
+}
+
+static int writecache_map(struct dm_target *ti, struct bio *bio)
+{
+       struct wc_entry *e;
+       struct dm_writecache *wc = ti->private;
+
+       bio->bi_private = NULL;
+
+       wc_lock(wc);
+
+       if (unlikely(bio->bi_opf & REQ_PREFLUSH)) {
+               if (writecache_has_error(wc))
+                       goto unlock_error;
+               if (WC_MODE_PMEM(wc)) {
+                       writecache_flush(wc);
+                       if (writecache_has_error(wc))
+                               goto unlock_error;
+                       goto unlock_submit;
+               } else {
+                       writecache_offload_bio(wc, bio);
+                       goto unlock_return;
+               }
+       }
+
+       bio->bi_iter.bi_sector = dm_target_offset(ti, bio->bi_iter.bi_sector);
+
+       if (unlikely((((unsigned)bio->bi_iter.bi_sector | bio_sectors(bio)) &
+                               (wc->block_size / 512 - 1)) != 0)) {
+               DMERR("I/O is not aligned, sector %llu, size %u, block size %u",
+                     (unsigned long long)bio->bi_iter.bi_sector,
+                     bio->bi_iter.bi_size, wc->block_size);
+               goto unlock_error;
+       }
+
+       if (unlikely(bio_op(bio) == REQ_OP_DISCARD)) {
+               if (writecache_has_error(wc))
+                       goto unlock_error;
+               if (WC_MODE_PMEM(wc)) {
+                       writecache_discard(wc, bio->bi_iter.bi_sector, bio_end_sector(bio));
+                       goto unlock_remap_origin;
+               } else {
+                       writecache_offload_bio(wc, bio);
+                       goto unlock_return;
+               }
+       }
+
+       if (bio_data_dir(bio) == READ) {
+read_next_block:
+               e = writecache_find_entry(wc, bio->bi_iter.bi_sector, WFE_RETURN_FOLLOWING);
+               if (e && read_original_sector(wc, e) == bio->bi_iter.bi_sector) {
+                       if (WC_MODE_PMEM(wc)) {
+                               bio_copy_block(wc, bio, memory_data(wc, e));
+                               if (bio->bi_iter.bi_size)
+                                       goto read_next_block;
+                               goto unlock_submit;
+                       } else {
+                               dm_accept_partial_bio(bio, wc->block_size >> SECTOR_SHIFT);
+                               bio_set_dev(bio, wc->ssd_dev->bdev);
+                               bio->bi_iter.bi_sector = cache_sector(wc, e);
+                               if (!writecache_entry_is_committed(wc, e))
+                                       writecache_wait_for_ios(wc, WRITE);
+                               goto unlock_remap;
+                       }
+               } else {
+                       if (e) {
+                               sector_t next_boundary =
+                                       read_original_sector(wc, e) - bio->bi_iter.bi_sector;
+                               if (next_boundary < bio->bi_iter.bi_size >> SECTOR_SHIFT) {
+                                       dm_accept_partial_bio(bio, next_boundary);
+                               }
+                       }
+                       goto unlock_remap_origin;
+               }
+       } else {
+               do {
+                       if (writecache_has_error(wc))
+                               goto unlock_error;
+                       e = writecache_find_entry(wc, bio->bi_iter.bi_sector, 0);
+                       if (e) {
+                               if (!writecache_entry_is_committed(wc, e))
+                                       goto bio_copy;
+                               if (!WC_MODE_PMEM(wc) && !e->write_in_progress) {
+                                       wc->overwrote_committed = true;
+                                       goto bio_copy;
+                               }
+                       }
+                       e = writecache_pop_from_freelist(wc);
+                       if (unlikely(!e)) {
+                               writecache_wait_on_freelist(wc);
+                               continue;
+                       }
+                       write_original_sector_seq_count(wc, e, bio->bi_iter.bi_sector, wc->seq_count);
+                       writecache_insert_entry(wc, e);
+                       wc->uncommitted_blocks++;
+bio_copy:
+                       if (WC_MODE_PMEM(wc)) {
+                               bio_copy_block(wc, bio, memory_data(wc, e));
+                       } else {
+                               dm_accept_partial_bio(bio, wc->block_size >> SECTOR_SHIFT);
+                               bio_set_dev(bio, wc->ssd_dev->bdev);
+                               bio->bi_iter.bi_sector = cache_sector(wc, e);
+                               if (unlikely(wc->uncommitted_blocks >= wc->autocommit_blocks)) {
+                                       wc->uncommitted_blocks = 0;
+                                       queue_work(wc->writeback_wq, &wc->flush_work);
+                               } else {
+                                       writecache_schedule_autocommit(wc);
+                               }
+                               goto unlock_remap;
+                       }
+               } while (bio->bi_iter.bi_size);
+
+               if (unlikely(wc->uncommitted_blocks >= wc->autocommit_blocks))
+                       writecache_flush(wc);
+               else
+                       writecache_schedule_autocommit(wc);
+               goto unlock_submit;
+       }
+
+unlock_remap_origin:
+       bio_set_dev(bio, wc->dev->bdev);
+       wc_unlock(wc);
+       return DM_MAPIO_REMAPPED;
+
+unlock_remap:
+       /* make sure that writecache_end_io decrements bio_in_progress: */
+       bio->bi_private = (void *)1;
+       atomic_inc(&wc->bio_in_progress[bio_data_dir(bio)]);
+       wc_unlock(wc);
+       return DM_MAPIO_REMAPPED;
+
+unlock_submit:
+       wc_unlock(wc);
+       bio_endio(bio);
+       return DM_MAPIO_SUBMITTED;
+
+unlock_return:
+       wc_unlock(wc);
+       return DM_MAPIO_SUBMITTED;
+
+unlock_error:
+       wc_unlock(wc);
+       bio_io_error(bio);
+       return DM_MAPIO_SUBMITTED;
+}
+
+static int writecache_end_io(struct dm_target *ti, struct bio *bio, blk_status_t *status)
+{
+       struct dm_writecache *wc = ti->private;
+
+       if (bio->bi_private != NULL) {
+               int dir = bio_data_dir(bio);
+               if (atomic_dec_and_test(&wc->bio_in_progress[dir]))
+                       if (unlikely(waitqueue_active(&wc->bio_in_progress_wait[dir])))
+                               wake_up(&wc->bio_in_progress_wait[dir]);
+       }
+       return 0;
+}
+
+static int writecache_iterate_devices(struct dm_target *ti,
+                                     iterate_devices_callout_fn fn, void *data)
+{
+       struct dm_writecache *wc = ti->private;
+
+       return fn(ti, wc->dev, 0, ti->len, data);
+}
+
+static void writecache_io_hints(struct dm_target *ti, struct queue_limits *limits)
+{
+       struct dm_writecache *wc = ti->private;
+
+       if (limits->logical_block_size < wc->block_size)
+               limits->logical_block_size = wc->block_size;
+
+       if (limits->physical_block_size < wc->block_size)
+               limits->physical_block_size = wc->block_size;
+
+       if (limits->io_min < wc->block_size)
+               limits->io_min = wc->block_size;
+}
+
+
+static void writecache_writeback_endio(struct bio *bio)
+{
+       struct writeback_struct *wb = container_of(bio, struct writeback_struct, bio);
+       struct dm_writecache *wc = wb->wc;
+       unsigned long flags;
+
+       raw_spin_lock_irqsave(&wc->endio_list_lock, flags);
+       if (unlikely(list_empty(&wc->endio_list)))
+               wake_up_process(wc->endio_thread);
+       list_add_tail(&wb->endio_entry, &wc->endio_list);
+       raw_spin_unlock_irqrestore(&wc->endio_list_lock, flags);
+}
+
+static void writecache_copy_endio(int read_err, unsigned long write_err, void *ptr)
+{
+       struct copy_struct *c = ptr;
+       struct dm_writecache *wc = c->wc;
+
+       c->error = likely(!(read_err | write_err)) ? 0 : -EIO;
+
+       raw_spin_lock_irq(&wc->endio_list_lock);
+       if (unlikely(list_empty(&wc->endio_list)))
+               wake_up_process(wc->endio_thread);
+       list_add_tail(&c->endio_entry, &wc->endio_list);
+       raw_spin_unlock_irq(&wc->endio_list_lock);
+}
+
+static void __writecache_endio_pmem(struct dm_writecache *wc, struct list_head *list)
+{
+       unsigned i;
+       struct writeback_struct *wb;
+       struct wc_entry *e;
+       unsigned long n_walked = 0;
+
+       do {
+               wb = list_entry(list->next, struct writeback_struct, endio_entry);
+               list_del(&wb->endio_entry);
+
+               if (unlikely(wb->bio.bi_status != BLK_STS_OK))
+                       writecache_error(wc, blk_status_to_errno(wb->bio.bi_status),
+                                       "write error %d", wb->bio.bi_status);
+               i = 0;
+               do {
+                       e = wb->wc_list[i];
+                       BUG_ON(!e->write_in_progress);
+                       e->write_in_progress = false;
+                       INIT_LIST_HEAD(&e->lru);
+                       if (!writecache_has_error(wc))
+                               writecache_free_entry(wc, e);
+                       BUG_ON(!wc->writeback_size);
+                       wc->writeback_size--;
+                       n_walked++;
+                       if (unlikely(n_walked >= ENDIO_LATENCY)) {
+                               writecache_commit_flushed(wc);
+                               wc_unlock(wc);
+                               wc_lock(wc);
+                               n_walked = 0;
+                       }
+               } while (++i < wb->wc_list_n);
+
+               if (wb->wc_list != wb->wc_list_inline)
+                       kfree(wb->wc_list);
+               bio_put(&wb->bio);
+       } while (!list_empty(list));
+}
+
+static void __writecache_endio_ssd(struct dm_writecache *wc, struct list_head *list)
+{
+       struct copy_struct *c;
+       struct wc_entry *e;
+
+       do {
+               c = list_entry(list->next, struct copy_struct, endio_entry);
+               list_del(&c->endio_entry);
+
+               if (unlikely(c->error))
+                       writecache_error(wc, c->error, "copy error");
+
+               e = c->e;
+               do {
+                       BUG_ON(!e->write_in_progress);
+                       e->write_in_progress = false;
+                       INIT_LIST_HEAD(&e->lru);
+                       if (!writecache_has_error(wc))
+                               writecache_free_entry(wc, e);
+
+                       BUG_ON(!wc->writeback_size);
+                       wc->writeback_size--;
+                       e++;
+               } while (--c->n_entries);
+               mempool_free(c, &wc->copy_pool);
+       } while (!list_empty(list));
+}
+
+static int writecache_endio_thread(void *data)
+{
+       struct dm_writecache *wc = data;
+
+       while (1) {
+               struct list_head list;
+
+               raw_spin_lock_irq(&wc->endio_list_lock);
+               if (!list_empty(&wc->endio_list))
+                       goto pop_from_list;
+               set_current_state(TASK_INTERRUPTIBLE);
+               raw_spin_unlock_irq(&wc->endio_list_lock);
+
+               if (unlikely(kthread_should_stop())) {
+                       set_current_state(TASK_RUNNING);
+                       break;
+               }
+
+               schedule();
+
+               continue;
+
+pop_from_list:
+               list = wc->endio_list;
+               list.next->prev = list.prev->next = &list;
+               INIT_LIST_HEAD(&wc->endio_list);
+               raw_spin_unlock_irq(&wc->endio_list_lock);
+
+               if (!WC_MODE_FUA(wc))
+                       writecache_disk_flush(wc, wc->dev);
+
+               wc_lock(wc);
+
+               if (WC_MODE_PMEM(wc)) {
+                       __writecache_endio_pmem(wc, &list);
+               } else {
+                       __writecache_endio_ssd(wc, &list);
+                       writecache_wait_for_ios(wc, READ);
+               }
+
+               writecache_commit_flushed(wc);
+
+               wc_unlock(wc);
+       }
+
+       return 0;
+}
+
+static bool wc_add_block(struct writeback_struct *wb, struct wc_entry *e, gfp_t gfp)
+{
+       struct dm_writecache *wc = wb->wc;
+       unsigned block_size = wc->block_size;
+       void *address = memory_data(wc, e);
+
+       persistent_memory_flush_cache(address, block_size);
+       return bio_add_page(&wb->bio, persistent_memory_page(address),
+                           block_size, persistent_memory_page_offset(address)) != 0;
+}
+
+struct writeback_list {
+       struct list_head list;
+       size_t size;
+};
+
+static void __writeback_throttle(struct dm_writecache *wc, struct writeback_list *wbl)
+{
+       if (unlikely(wc->max_writeback_jobs)) {
+               if (READ_ONCE(wc->writeback_size) - wbl->size >= wc->max_writeback_jobs) {
+                       wc_lock(wc);
+                       while (wc->writeback_size - wbl->size >= wc->max_writeback_jobs)
+                               writecache_wait_on_freelist(wc);
+                       wc_unlock(wc);
+               }
+       }
+       cond_resched();
+}
+
+static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeback_list *wbl)
+{
+       struct wc_entry *e, *f;
+       struct bio *bio;
+       struct writeback_struct *wb;
+       unsigned max_pages;
+
+       while (wbl->size) {
+               wbl->size--;
+               e = container_of(wbl->list.prev, struct wc_entry, lru);
+               list_del(&e->lru);
+
+               max_pages = e->wc_list_contiguous;
+
+               bio = bio_alloc_bioset(GFP_NOIO, max_pages, &wc->bio_set);
+               wb = container_of(bio, struct writeback_struct, bio);
+               wb->wc = wc;
+               wb->bio.bi_end_io = writecache_writeback_endio;
+               bio_set_dev(&wb->bio, wc->dev->bdev);
+               wb->bio.bi_iter.bi_sector = read_original_sector(wc, e);
+               wb->page_offset = PAGE_SIZE;
+               if (max_pages <= WB_LIST_INLINE ||
+                   unlikely(!(wb->wc_list = kmalloc(max_pages * sizeof(struct wc_entry *),
+                                                    GFP_NOIO | __GFP_NORETRY |
+                                                    __GFP_NOMEMALLOC | __GFP_NOWARN)))) {
+                       wb->wc_list = wb->wc_list_inline;
+                       max_pages = WB_LIST_INLINE;
+               }
+
+               BUG_ON(!wc_add_block(wb, e, GFP_NOIO));
+
+               wb->wc_list[0] = e;
+               wb->wc_list_n = 1;
+
+               while (wbl->size && wb->wc_list_n < max_pages) {
+                       f = container_of(wbl->list.prev, struct wc_entry, lru);
+                       if (read_original_sector(wc, f) !=
+                           read_original_sector(wc, e) + (wc->block_size >> SECTOR_SHIFT))
+                               break;
+                       if (!wc_add_block(wb, f, GFP_NOWAIT | __GFP_NOWARN))
+                               break;
+                       wbl->size--;
+                       list_del(&f->lru);
+                       wb->wc_list[wb->wc_list_n++] = f;
+                       e = f;
+               }
+               bio_set_op_attrs(&wb->bio, REQ_OP_WRITE, WC_MODE_FUA(wc) * REQ_FUA);
+               if (writecache_has_error(wc)) {
+                       bio->bi_status = BLK_STS_IOERR;
+                       bio_endio(&wb->bio);
+               } else {
+                       submit_bio(&wb->bio);
+               }
+
+               __writeback_throttle(wc, wbl);
+       }
+}
+
+static void __writecache_writeback_ssd(struct dm_writecache *wc, struct writeback_list *wbl)
+{
+       struct wc_entry *e, *f;
+       struct dm_io_region from, to;
+       struct copy_struct *c;
+
+       while (wbl->size) {
+               unsigned n_sectors;
+
+               wbl->size--;
+               e = container_of(wbl->list.prev, struct wc_entry, lru);
+               list_del(&e->lru);
+
+               n_sectors = e->wc_list_contiguous << (wc->block_size_bits - SECTOR_SHIFT);
+
+               from.bdev = wc->ssd_dev->bdev;
+               from.sector = cache_sector(wc, e);
+               from.count = n_sectors;
+               to.bdev = wc->dev->bdev;
+               to.sector = read_original_sector(wc, e);
+               to.count = n_sectors;
+
+               c = mempool_alloc(&wc->copy_pool, GFP_NOIO);
+               c->wc = wc;
+               c->e = e;
+               c->n_entries = e->wc_list_contiguous;
+
+               while ((n_sectors -= wc->block_size >> SECTOR_SHIFT)) {
+                       wbl->size--;
+                       f = container_of(wbl->list.prev, struct wc_entry, lru);
+                       BUG_ON(f != e + 1);
+                       list_del(&f->lru);
+                       e = f;
+               }
+
+               dm_kcopyd_copy(wc->dm_kcopyd, &from, 1, &to, 0, writecache_copy_endio, c);
+
+               __writeback_throttle(wc, wbl);
+       }
+}
+
+static void writecache_writeback(struct work_struct *work)
+{
+       struct dm_writecache *wc = container_of(work, struct dm_writecache, writeback_work);
+       struct blk_plug plug;
+       struct wc_entry *e, *f, *g;
+       struct rb_node *node, *next_node;
+       struct list_head skipped;
+       struct writeback_list wbl;
+       unsigned long n_walked;
+
+       wc_lock(wc);
+restart:
+       if (writecache_has_error(wc)) {
+               wc_unlock(wc);
+               return;
+       }
+
+       if (unlikely(wc->writeback_all)) {
+               if (writecache_wait_for_writeback(wc))
+                       goto restart;
+       }
+
+       if (wc->overwrote_committed) {
+               writecache_wait_for_ios(wc, WRITE);
+       }
+
+       n_walked = 0;
+       INIT_LIST_HEAD(&skipped);
+       INIT_LIST_HEAD(&wbl.list);
+       wbl.size = 0;
+       while (!list_empty(&wc->lru) &&
+              (wc->writeback_all ||
+               wc->freelist_size + wc->writeback_size <= wc->freelist_low_watermark)) {
+
+               n_walked++;
+               if (unlikely(n_walked > WRITEBACK_LATENCY) &&
+                   likely(!wc->writeback_all) && likely(!dm_suspended(wc->ti))) {
+                       queue_work(wc->writeback_wq, &wc->writeback_work);
+                       break;
+               }
+
+               e = container_of(wc->lru.prev, struct wc_entry, lru);
+               BUG_ON(e->write_in_progress);
+               if (unlikely(!writecache_entry_is_committed(wc, e))) {
+                       writecache_flush(wc);
+               }
+               node = rb_prev(&e->rb_node);
+               if (node) {
+                       f = container_of(node, struct wc_entry, rb_node);
+                       if (unlikely(read_original_sector(wc, f) ==
+                                    read_original_sector(wc, e))) {
+                               BUG_ON(!f->write_in_progress);
+                               list_del(&e->lru);
+                               list_add(&e->lru, &skipped);
+                               cond_resched();
+                               continue;
+                       }
+               }
+               wc->writeback_size++;
+               list_del(&e->lru);
+               list_add(&e->lru, &wbl.list);
+               wbl.size++;
+               e->write_in_progress = true;
+               e->wc_list_contiguous = 1;
+
+               f = e;
+
+               while (1) {
+                       next_node = rb_next(&f->rb_node);
+                       if (unlikely(!next_node))
+                               break;
+                       g = container_of(next_node, struct wc_entry, rb_node);
+                       if (read_original_sector(wc, g) ==
+                           read_original_sector(wc, f)) {
+                               f = g;
+                               continue;
+                       }
+                       if (read_original_sector(wc, g) !=
+                           read_original_sector(wc, f) + (wc->block_size >> SECTOR_SHIFT))
+                               break;
+                       if (unlikely(g->write_in_progress))
+                               break;
+                       if (unlikely(!writecache_entry_is_committed(wc, g)))
+                               break;
+
+                       if (!WC_MODE_PMEM(wc)) {
+                               if (g != f + 1)
+                                       break;
+                       }
+
+                       n_walked++;
+                       //if (unlikely(n_walked > WRITEBACK_LATENCY) && likely(!wc->writeback_all))
+                       //      break;
+
+                       wc->writeback_size++;
+                       list_del(&g->lru);
+                       list_add(&g->lru, &wbl.list);
+                       wbl.size++;
+                       g->write_in_progress = true;
+                       g->wc_list_contiguous = BIO_MAX_PAGES;
+                       f = g;
+                       e->wc_list_contiguous++;
+                       if (unlikely(e->wc_list_contiguous == BIO_MAX_PAGES))
+                               break;
+               }
+               cond_resched();
+       }
+
+       if (!list_empty(&skipped)) {
+               list_splice_tail(&skipped, &wc->lru);
+               /*
+                * If we didn't do any progress, we must wait until some
+                * writeback finishes to avoid burning CPU in a loop
+                */
+               if (unlikely(!wbl.size))
+                       writecache_wait_for_writeback(wc);
+       }
+
+       wc_unlock(wc);
+
+       blk_start_plug(&plug);
+
+       if (WC_MODE_PMEM(wc))
+               __writecache_writeback_pmem(wc, &wbl);
+       else
+               __writecache_writeback_ssd(wc, &wbl);
+
+       blk_finish_plug(&plug);
+
+       if (unlikely(wc->writeback_all)) {
+               wc_lock(wc);
+               while (writecache_wait_for_writeback(wc));
+               wc_unlock(wc);
+       }
+}
+
+static int calculate_memory_size(uint64_t device_size, unsigned block_size,
+                                size_t *n_blocks_p, size_t *n_metadata_blocks_p)
+{
+       uint64_t n_blocks, offset;
+       struct wc_entry e;
+
+       n_blocks = device_size;
+       do_div(n_blocks, block_size + sizeof(struct wc_memory_entry));
+
+       while (1) {
+               if (!n_blocks)
+                       return -ENOSPC;
+               /* Verify the following entries[n_blocks] won't overflow */
+               if (n_blocks >= ((size_t)-sizeof(struct wc_memory_superblock) /
+                                sizeof(struct wc_memory_entry)))
+                       return -EFBIG;
+               offset = offsetof(struct wc_memory_superblock, entries[n_blocks]);
+               offset = (offset + block_size - 1) & ~(uint64_t)(block_size - 1);
+               if (offset + n_blocks * block_size <= device_size)
+                       break;
+               n_blocks--;
+       }
+
+       /* check if the bit field overflows */
+       e.index = n_blocks;
+       if (e.index != n_blocks)
+               return -EFBIG;
+
+       if (n_blocks_p)
+               *n_blocks_p = n_blocks;
+       if (n_metadata_blocks_p)
+               *n_metadata_blocks_p = offset >> __ffs(block_size);
+       return 0;
+}
+
+static int init_memory(struct dm_writecache *wc)
+{
+       size_t b;
+       int r;
+
+       r = calculate_memory_size(wc->memory_map_size, wc->block_size, &wc->n_blocks, NULL);
+       if (r)
+               return r;
+
+       r = writecache_alloc_entries(wc);
+       if (r)
+               return r;
+
+       for (b = 0; b < ARRAY_SIZE(sb(wc)->padding); b++)
+               pmem_assign(sb(wc)->padding[b], cpu_to_le64(0));
+       pmem_assign(sb(wc)->version, cpu_to_le32(MEMORY_SUPERBLOCK_VERSION));
+       pmem_assign(sb(wc)->block_size, cpu_to_le32(wc->block_size));
+       pmem_assign(sb(wc)->n_blocks, cpu_to_le64(wc->n_blocks));
+       pmem_assign(sb(wc)->seq_count, cpu_to_le64(0));
+
+       for (b = 0; b < wc->n_blocks; b++)
+               write_original_sector_seq_count(wc, &wc->entries[b], -1, -1);
+
+       writecache_flush_all_metadata(wc);
+       writecache_commit_flushed(wc);
+       pmem_assign(sb(wc)->magic, cpu_to_le32(MEMORY_SUPERBLOCK_MAGIC));
+       writecache_flush_region(wc, &sb(wc)->magic, sizeof sb(wc)->magic);
+       writecache_commit_flushed(wc);
+
+       return 0;
+}
+
+static void writecache_dtr(struct dm_target *ti)
+{
+       struct dm_writecache *wc = ti->private;
+
+       if (!wc)
+               return;
+
+       if (wc->endio_thread)
+               kthread_stop(wc->endio_thread);
+
+       if (wc->flush_thread)
+               kthread_stop(wc->flush_thread);
+
+       bioset_exit(&wc->bio_set);
+
+       mempool_exit(&wc->copy_pool);
+
+       if (wc->writeback_wq)
+               destroy_workqueue(wc->writeback_wq);
+
+       if (wc->dev)
+               dm_put_device(ti, wc->dev);
+
+       if (wc->ssd_dev)
+               dm_put_device(ti, wc->ssd_dev);
+
+       if (wc->entries)
+               vfree(wc->entries);
+
+       if (wc->memory_map) {
+               if (WC_MODE_PMEM(wc))
+                       persistent_memory_release(wc);
+               else
+                       vfree(wc->memory_map);
+       }
+
+       if (wc->dm_kcopyd)
+               dm_kcopyd_client_destroy(wc->dm_kcopyd);
+
+       if (wc->dm_io)
+               dm_io_client_destroy(wc->dm_io);
+
+       if (wc->dirty_bitmap)
+               vfree(wc->dirty_bitmap);
+
+       kfree(wc);
+}
+
+static int writecache_ctr(struct dm_target *ti, unsigned argc, char **argv)
+{
+       struct dm_writecache *wc;
+       struct dm_arg_set as;
+       const char *string;
+       unsigned opt_params;
+       size_t offset, data_size;
+       int i, r;
+       char dummy;
+       int high_wm_percent = HIGH_WATERMARK;
+       int low_wm_percent = LOW_WATERMARK;
+       uint64_t x;
+       struct wc_memory_superblock s;
+
+       static struct dm_arg _args[] = {
+               {0, 10, "Invalid number of feature args"},
+       };
+
+       as.argc = argc;
+       as.argv = argv;
+
+       wc = kzalloc(sizeof(struct dm_writecache), GFP_KERNEL);
+       if (!wc) {
+               ti->error = "Cannot allocate writecache structure";
+               r = -ENOMEM;
+               goto bad;
+       }
+       ti->private = wc;
+       wc->ti = ti;
+
+       mutex_init(&wc->lock);
+       writecache_poison_lists(wc);
+       init_waitqueue_head(&wc->freelist_wait);
+       timer_setup(&wc->autocommit_timer, writecache_autocommit_timer, 0);
+
+       for (i = 0; i < 2; i++) {
+               atomic_set(&wc->bio_in_progress[i], 0);
+               init_waitqueue_head(&wc->bio_in_progress_wait[i]);
+       }
+
+       wc->dm_io = dm_io_client_create();
+       if (IS_ERR(wc->dm_io)) {
+               r = PTR_ERR(wc->dm_io);
+               ti->error = "Unable to allocate dm-io client";
+               wc->dm_io = NULL;
+               goto bad;
+       }
+
+       wc->writeback_wq = alloc_workqueue("writecache-writeabck", WQ_MEM_RECLAIM, 1);
+       if (!wc->writeback_wq) {
+               r = -ENOMEM;
+               ti->error = "Could not allocate writeback workqueue";
+               goto bad;
+       }
+       INIT_WORK(&wc->writeback_work, writecache_writeback);
+       INIT_WORK(&wc->flush_work, writecache_flush_work);
+
+       raw_spin_lock_init(&wc->endio_list_lock);
+       INIT_LIST_HEAD(&wc->endio_list);
+       wc->endio_thread = kthread_create(writecache_endio_thread, wc, "writecache_endio");
+       if (IS_ERR(wc->endio_thread)) {
+               r = PTR_ERR(wc->endio_thread);
+               wc->endio_thread = NULL;
+               ti->error = "Couldn't spawn endio thread";
+               goto bad;
+       }
+       wake_up_process(wc->endio_thread);
+
+       /*
+        * Parse the mode (pmem or ssd)
+        */
+       string = dm_shift_arg(&as);
+       if (!string)
+               goto bad_arguments;
+
+       if (!strcasecmp(string, "s")) {
+               wc->pmem_mode = false;
+       } else if (!strcasecmp(string, "p")) {
+#ifdef DM_WRITECACHE_HAS_PMEM
+               wc->pmem_mode = true;
+               wc->writeback_fua = true;
+#else
+               /*
+                * If the architecture doesn't support persistent memory or
+                * the kernel doesn't support any DAX drivers, this driver can
+                * only be used in SSD-only mode.
+                */
+               r = -EOPNOTSUPP;
+               ti->error = "Persistent memory or DAX not supported on this system";
+               goto bad;
+#endif
+       } else {
+               goto bad_arguments;
+       }
+
+       if (WC_MODE_PMEM(wc)) {
+               r = bioset_init(&wc->bio_set, BIO_POOL_SIZE,
+                               offsetof(struct writeback_struct, bio),
+                               BIOSET_NEED_BVECS);
+               if (r) {
+                       ti->error = "Could not allocate bio set";
+                       goto bad;
+               }
+       } else {
+               r = mempool_init_kmalloc_pool(&wc->copy_pool, 1, sizeof(struct copy_struct));
+               if (r) {
+                       ti->error = "Could not allocate mempool";
+                       goto bad;
+               }
+       }
+
+       /*
+        * Parse the origin data device
+        */
+       string = dm_shift_arg(&as);
+       if (!string)
+               goto bad_arguments;
+       r = dm_get_device(ti, string, dm_table_get_mode(ti->table), &wc->dev);
+       if (r) {
+               ti->error = "Origin data device lookup failed";
+               goto bad;
+       }
+
+       /*
+        * Parse cache data device (be it pmem or ssd)
+        */
+       string = dm_shift_arg(&as);
+       if (!string)
+               goto bad_arguments;
+
+       r = dm_get_device(ti, string, dm_table_get_mode(ti->table), &wc->ssd_dev);
+       if (r) {
+               ti->error = "Cache data device lookup failed";
+               goto bad;
+       }
+       wc->memory_map_size = i_size_read(wc->ssd_dev->bdev->bd_inode);
+
+       if (WC_MODE_PMEM(wc)) {
+               r = persistent_memory_claim(wc);
+               if (r) {
+                       ti->error = "Unable to map persistent memory for cache";
+                       goto bad;
+               }
+       }
+
+       /*
+        * Parse the cache block size
+        */
+       string = dm_shift_arg(&as);
+       if (!string)
+               goto bad_arguments;
+       if (sscanf(string, "%u%c", &wc->block_size, &dummy) != 1 ||
+           wc->block_size < 512 || wc->block_size > PAGE_SIZE ||
+           (wc->block_size & (wc->block_size - 1))) {
+               r = -EINVAL;
+               ti->error = "Invalid block size";
+               goto bad;
+       }
+       wc->block_size_bits = __ffs(wc->block_size);
+
+       wc->max_writeback_jobs = MAX_WRITEBACK_JOBS;
+       wc->autocommit_blocks = !WC_MODE_PMEM(wc) ? AUTOCOMMIT_BLOCKS_SSD : AUTOCOMMIT_BLOCKS_PMEM;
+       wc->autocommit_jiffies = msecs_to_jiffies(AUTOCOMMIT_MSEC);
+
+       /*
+        * Parse optional arguments
+        */
+       r = dm_read_arg_group(_args, &as, &opt_params, &ti->error);
+       if (r)
+               goto bad;
+
+       while (opt_params) {
+               string = dm_shift_arg(&as), opt_params--;
+               if (!strcasecmp(string, "high_watermark") && opt_params >= 1) {
+                       string = dm_shift_arg(&as), opt_params--;
+                       if (sscanf(string, "%d%c", &high_wm_percent, &dummy) != 1)
+                               goto invalid_optional;
+                       if (high_wm_percent < 0 || high_wm_percent > 100)
+                               goto invalid_optional;
+                       wc->high_wm_percent_set = true;
+               } else if (!strcasecmp(string, "low_watermark") && opt_params >= 1) {
+                       string = dm_shift_arg(&as), opt_params--;
+                       if (sscanf(string, "%d%c", &low_wm_percent, &dummy) != 1)
+                               goto invalid_optional;
+                       if (low_wm_percent < 0 || low_wm_percent > 100)
+                               goto invalid_optional;
+                       wc->low_wm_percent_set = true;
+               } else if (!strcasecmp(string, "writeback_jobs") && opt_params >= 1) {
+                       string = dm_shift_arg(&as), opt_params--;
+                       if (sscanf(string, "%u%c", &wc->max_writeback_jobs, &dummy) != 1)
+                               goto invalid_optional;
+                       wc->max_writeback_jobs_set = true;
+               } else if (!strcasecmp(string, "autocommit_blocks") && opt_params >= 1) {
+                       string = dm_shift_arg(&as), opt_params--;
+                       if (sscanf(string, "%u%c", &wc->autocommit_blocks, &dummy) != 1)
+                               goto invalid_optional;
+                       wc->autocommit_blocks_set = true;
+               } else if (!strcasecmp(string, "autocommit_time") && opt_params >= 1) {
+                       unsigned autocommit_msecs;
+                       string = dm_shift_arg(&as), opt_params--;
+                       if (sscanf(string, "%u%c", &autocommit_msecs, &dummy) != 1)
+                               goto invalid_optional;
+                       if (autocommit_msecs > 3600000)
+                               goto invalid_optional;
+                       wc->autocommit_jiffies = msecs_to_jiffies(autocommit_msecs);
+                       wc->autocommit_time_set = true;
+               } else if (!strcasecmp(string, "fua")) {
+                       if (WC_MODE_PMEM(wc)) {
+                               wc->writeback_fua = true;
+                               wc->writeback_fua_set = true;
+                       } else goto invalid_optional;
+               } else if (!strcasecmp(string, "nofua")) {
+                       if (WC_MODE_PMEM(wc)) {
+                               wc->writeback_fua = false;
+                               wc->writeback_fua_set = true;
+                       } else goto invalid_optional;
+               } else {
+invalid_optional:
+                       r = -EINVAL;
+                       ti->error = "Invalid optional argument";
+                       goto bad;
+               }
+       }
+
+       if (high_wm_percent < low_wm_percent) {
+               r = -EINVAL;
+               ti->error = "High watermark must be greater than or equal to low watermark";
+               goto bad;
+       }
+
+       if (!WC_MODE_PMEM(wc)) {
+               struct dm_io_region region;
+               struct dm_io_request req;
+               size_t n_blocks, n_metadata_blocks;
+               uint64_t n_bitmap_bits;
+
+               bio_list_init(&wc->flush_list);
+               wc->flush_thread = kthread_create(writecache_flush_thread, wc, "dm_writecache_flush");
+               if (IS_ERR(wc->flush_thread)) {
+                       r = PTR_ERR(wc->flush_thread);
+                       wc->flush_thread = NULL;
+                       ti->error = "Couldn't spawn endio thread";
+                       goto bad;
+               }
+               wake_up_process(wc->flush_thread);
+
+               r = calculate_memory_size(wc->memory_map_size, wc->block_size,
+                                         &n_blocks, &n_metadata_blocks);
+               if (r) {
+                       ti->error = "Invalid device size";
+                       goto bad;
+               }
+
+               n_bitmap_bits = (((uint64_t)n_metadata_blocks << wc->block_size_bits) +
+                                BITMAP_GRANULARITY - 1) / BITMAP_GRANULARITY;
+               /* this is limitation of test_bit functions */
+               if (n_bitmap_bits > 1U << 31) {
+                       r = -EFBIG;
+                       ti->error = "Invalid device size";
+                       goto bad;
+               }
+
+               wc->memory_map = vmalloc(n_metadata_blocks << wc->block_size_bits);
+               if (!wc->memory_map) {
+                       r = -ENOMEM;
+                       ti->error = "Unable to allocate memory for metadata";
+                       goto bad;
+               }
+
+               wc->dm_kcopyd = dm_kcopyd_client_create(&dm_kcopyd_throttle);
+               if (IS_ERR(wc->dm_kcopyd)) {
+                       r = PTR_ERR(wc->dm_kcopyd);
+                       ti->error = "Unable to allocate dm-kcopyd client";
+                       wc->dm_kcopyd = NULL;
+                       goto bad;
+               }
+
+               wc->metadata_sectors = n_metadata_blocks << (wc->block_size_bits - SECTOR_SHIFT);
+               wc->dirty_bitmap_size = (n_bitmap_bits + BITS_PER_LONG - 1) /
+                       BITS_PER_LONG * sizeof(unsigned long);
+               wc->dirty_bitmap = vzalloc(wc->dirty_bitmap_size);
+               if (!wc->dirty_bitmap) {
+                       r = -ENOMEM;
+                       ti->error = "Unable to allocate dirty bitmap";
+                       goto bad;
+               }
+
+               region.bdev = wc->ssd_dev->bdev;
+               region.sector = 0;
+               region.count = wc->metadata_sectors;
+               req.bi_op = REQ_OP_READ;
+               req.bi_op_flags = REQ_SYNC;
+               req.mem.type = DM_IO_VMA;
+               req.mem.ptr.vma = (char *)wc->memory_map;
+               req.client = wc->dm_io;
+               req.notify.fn = NULL;
+
+               r = dm_io(&req, 1, &region, NULL);
+               if (r) {
+                       ti->error = "Unable to read metadata";
+                       goto bad;
+               }
+       }
+
+       r = memcpy_mcsafe(&s, sb(wc), sizeof(struct wc_memory_superblock));
+       if (r) {
+               ti->error = "Hardware memory error when reading superblock";
+               goto bad;
+       }
+       if (!le32_to_cpu(s.magic) && !le32_to_cpu(s.version)) {
+               r = init_memory(wc);
+               if (r) {
+                       ti->error = "Unable to initialize device";
+                       goto bad;
+               }
+               r = memcpy_mcsafe(&s, sb(wc), sizeof(struct wc_memory_superblock));
+               if (r) {
+                       ti->error = "Hardware memory error when reading superblock";
+                       goto bad;
+               }
+       }
+
+       if (le32_to_cpu(s.magic) != MEMORY_SUPERBLOCK_MAGIC) {
+               ti->error = "Invalid magic in the superblock";
+               r = -EINVAL;
+               goto bad;
+       }
+
+       if (le32_to_cpu(s.version) != MEMORY_SUPERBLOCK_VERSION) {
+               ti->error = "Invalid version in the superblock";
+               r = -EINVAL;
+               goto bad;
+       }
+
+       if (le32_to_cpu(s.block_size) != wc->block_size) {
+               ti->error = "Block size does not match superblock";
+               r = -EINVAL;
+               goto bad;
+       }
+
+       wc->n_blocks = le64_to_cpu(s.n_blocks);
+
+       offset = wc->n_blocks * sizeof(struct wc_memory_entry);
+       if (offset / sizeof(struct wc_memory_entry) != le64_to_cpu(sb(wc)->n_blocks)) {
+overflow:
+               ti->error = "Overflow in size calculation";
+               r = -EINVAL;
+               goto bad;
+       }
+       offset += sizeof(struct wc_memory_superblock);
+       if (offset < sizeof(struct wc_memory_superblock))
+               goto overflow;
+       offset = (offset + wc->block_size - 1) & ~(size_t)(wc->block_size - 1);
+       data_size = wc->n_blocks * (size_t)wc->block_size;
+       if (!offset || (data_size / wc->block_size != wc->n_blocks) ||
+           (offset + data_size < offset))
+               goto overflow;
+       if (offset + data_size > wc->memory_map_size) {
+               ti->error = "Memory area is too small";
+               r = -EINVAL;
+               goto bad;
+       }
+
+       wc->metadata_sectors = offset >> SECTOR_SHIFT;
+       wc->block_start = (char *)sb(wc) + offset;
+
+       x = (uint64_t)wc->n_blocks * (100 - high_wm_percent);
+       x += 50;
+       do_div(x, 100);
+       wc->freelist_high_watermark = x;
+       x = (uint64_t)wc->n_blocks * (100 - low_wm_percent);
+       x += 50;
+       do_div(x, 100);
+       wc->freelist_low_watermark = x;
+
+       r = writecache_alloc_entries(wc);
+       if (r) {
+               ti->error = "Cannot allocate memory";
+               goto bad;
+       }
+
+       ti->num_flush_bios = 1;
+       ti->flush_supported = true;
+       ti->num_discard_bios = 1;
+
+       if (WC_MODE_PMEM(wc))
+               persistent_memory_flush_cache(wc->memory_map, wc->memory_map_size);
+
+       return 0;
+
+bad_arguments:
+       r = -EINVAL;
+       ti->error = "Bad arguments";
+bad:
+       writecache_dtr(ti);
+       return r;
+}
+
+static void writecache_status(struct dm_target *ti, status_type_t type,
+                             unsigned status_flags, char *result, unsigned maxlen)
+{
+       struct dm_writecache *wc = ti->private;
+       unsigned extra_args;
+       unsigned sz = 0;
+       uint64_t x;
+
+       switch (type) {
+       case STATUSTYPE_INFO:
+               DMEMIT("%ld %llu %llu %llu", writecache_has_error(wc),
+                      (unsigned long long)wc->n_blocks, (unsigned long long)wc->freelist_size,
+                      (unsigned long long)wc->writeback_size);
+               break;
+       case STATUSTYPE_TABLE:
+               DMEMIT("%c %s %s %u ", WC_MODE_PMEM(wc) ? 'p' : 's',
+                               wc->dev->name, wc->ssd_dev->name, wc->block_size);
+               extra_args = 0;
+               if (wc->high_wm_percent_set)
+                       extra_args += 2;
+               if (wc->low_wm_percent_set)
+                       extra_args += 2;
+               if (wc->max_writeback_jobs_set)
+                       extra_args += 2;
+               if (wc->autocommit_blocks_set)
+                       extra_args += 2;
+               if (wc->autocommit_time_set)
+                       extra_args += 2;
+               if (wc->writeback_fua_set)
+                       extra_args++;
+
+               DMEMIT("%u", extra_args);
+               if (wc->high_wm_percent_set) {
+                       x = (uint64_t)wc->freelist_high_watermark * 100;
+                       x += wc->n_blocks / 2;
+                       do_div(x, (size_t)wc->n_blocks);
+                       DMEMIT(" high_watermark %u", 100 - (unsigned)x);
+               }
+               if (wc->low_wm_percent_set) {
+                       x = (uint64_t)wc->freelist_low_watermark * 100;
+                       x += wc->n_blocks / 2;
+                       do_div(x, (size_t)wc->n_blocks);
+                       DMEMIT(" low_watermark %u", 100 - (unsigned)x);
+               }
+               if (wc->max_writeback_jobs_set)
+                       DMEMIT(" writeback_jobs %u", wc->max_writeback_jobs);
+               if (wc->autocommit_blocks_set)
+                       DMEMIT(" autocommit_blocks %u", wc->autocommit_blocks);
+               if (wc->autocommit_time_set)
+                       DMEMIT(" autocommit_time %u", jiffies_to_msecs(wc->autocommit_jiffies));
+               if (wc->writeback_fua_set)
+                       DMEMIT(" %sfua", wc->writeback_fua ? "" : "no");
+               break;
+       }
+}
+
+static struct target_type writecache_target = {
+       .name                   = "writecache",
+       .version                = {1, 0, 0},
+       .module                 = THIS_MODULE,
+       .ctr                    = writecache_ctr,
+       .dtr                    = writecache_dtr,
+       .status                 = writecache_status,
+       .postsuspend            = writecache_suspend,
+       .resume                 = writecache_resume,
+       .message                = writecache_message,
+       .map                    = writecache_map,
+       .end_io                 = writecache_end_io,
+       .iterate_devices        = writecache_iterate_devices,
+       .io_hints               = writecache_io_hints,
+};
+
+static int __init dm_writecache_init(void)
+{
+       int r;
+
+       r = dm_register_target(&writecache_target);
+       if (r < 0) {
+               DMERR("register failed %d", r);
+               return r;
+       }
+
+       return 0;
+}
+
+static void __exit dm_writecache_exit(void)
+{
+       dm_unregister_target(&writecache_target);
+}
+
+module_init(dm_writecache_init);
+module_exit(dm_writecache_exit);
+
+MODULE_DESCRIPTION(DM_NAME " writecache target");
+MODULE_AUTHOR("Mikulas Patocka <dm-devel@redhat.com>");
+MODULE_LICENSE("GPL");
index 30602d15ad9a0eee32330b162ff7838b69cf3055..3c0e45f4dcf5cdf06d79b0c9d107d7455a0b6ad7 100644 (file)
@@ -52,9 +52,9 @@ struct dmz_target {
        struct dmz_reclaim      *reclaim;
 
        /* For chunk work */
-       struct mutex            chunk_lock;
        struct radix_tree_root  chunk_rxtree;
        struct workqueue_struct *chunk_wq;
+       struct mutex            chunk_lock;
 
        /* For cloned BIOs to zones */
        struct bio_set          bio_set;
index 239c7bb3929ba0ac58df67ae9b213ceb62cd7d41..f983c3fdf204169564ad64ee789e9961e3b47bec 100644 (file)
@@ -789,8 +789,8 @@ static int bitmap_storage_alloc(struct bitmap_storage *store,
        num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
        offset = slot_number * num_pages;
 
-       store->filemap = kmalloc(sizeof(struct page *)
-                                * num_pages, GFP_KERNEL);
+       store->filemap = kmalloc_array(num_pages, sizeof(struct page *),
+                                      GFP_KERNEL);
        if (!store->filemap)
                return -ENOMEM;
 
@@ -2117,7 +2117,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 
        pages = DIV_ROUND_UP(chunks, PAGE_COUNTER_RATIO);
 
-       new_bp = kzalloc(pages * sizeof(*new_bp), GFP_KERNEL);
+       new_bp = kcalloc(pages, sizeof(*new_bp), GFP_KERNEL);
        ret = -ENOMEM;
        if (!new_bp) {
                bitmap_file_unmap(&store);
index 79bfbc840385b65ae2a2b23f7c25d8a5f7460171..021cbf9ef1bf9af7c8e805f443862918f38e9162 100644 (file)
@@ -1380,9 +1380,9 @@ static int lock_all_bitmaps(struct mddev *mddev)
        char str[64];
        struct md_cluster_info *cinfo = mddev->cluster_info;
 
-       cinfo->other_bitmap_lockres = kzalloc((mddev->bitmap_info.nodes - 1) *
-                                            sizeof(struct dlm_lock_resource *),
-                                            GFP_KERNEL);
+       cinfo->other_bitmap_lockres =
+               kcalloc(mddev->bitmap_info.nodes - 1,
+                       sizeof(struct dlm_lock_resource *), GFP_KERNEL);
        if (!cinfo->other_bitmap_lockres) {
                pr_err("md: can't alloc mem for other bitmap locks\n");
                return 0;
index f71fcdb9b39c50052b8747a976ce89e0df33a6a1..881487de1e25af5e994c8770e255b74b3864f513 100644 (file)
@@ -399,7 +399,8 @@ static int multipath_run (struct mddev *mddev)
        if (!conf)
                goto out;
 
-       conf->multipaths = kzalloc(sizeof(struct multipath_info)*mddev->raid_disks,
+       conf->multipaths = kcalloc(mddev->raid_disks,
+                                  sizeof(struct multipath_info),
                                   GFP_KERNEL);
        if (!conf->multipaths)
                goto out_free_conf;
index 65ae47a02218744fc99d057b6fba301dd0f83e07..ac1cffd2a09b05f5f5217e579c9e87ea80efce84 100644 (file)
@@ -159,12 +159,14 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf)
        }
 
        err = -ENOMEM;
-       conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
-                               conf->nr_strip_zones, GFP_KERNEL);
+       conf->strip_zone = kcalloc(conf->nr_strip_zones,
+                                  sizeof(struct strip_zone),
+                                  GFP_KERNEL);
        if (!conf->strip_zone)
                goto abort;
-       conf->devlist = kzalloc(sizeof(struct md_rdev*)*
-                               conf->nr_strip_zones*mddev->raid_disks,
+       conf->devlist = kzalloc(array3_size(sizeof(struct md_rdev *),
+                                           conf->nr_strip_zones,
+                                           mddev->raid_disks),
                                GFP_KERNEL);
        if (!conf->devlist)
                goto abort;
index 0b344d0875814e9ba2a78badb4c8eeabad566bda..8e05c1092aef4bb066a62d8f1781c203940291eb 100644 (file)
@@ -126,8 +126,8 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data)
        if (!r1_bio)
                return NULL;
 
-       rps = kmalloc(sizeof(struct resync_pages) * pi->raid_disks,
-                     gfp_flags);
+       rps = kmalloc_array(pi->raid_disks, sizeof(struct resync_pages),
+                           gfp_flags);
        if (!rps)
                goto out_free_r1bio;
 
@@ -2936,9 +2936,9 @@ static struct r1conf *setup_conf(struct mddev *mddev)
        if (!conf->barrier)
                goto abort;
 
-       conf->mirrors = kzalloc(sizeof(struct raid1_info)
-                               * mddev->raid_disks * 2,
-                                GFP_KERNEL);
+       conf->mirrors = kzalloc(array3_size(sizeof(struct raid1_info),
+                                           mddev->raid_disks, 2),
+                               GFP_KERNEL);
        if (!conf->mirrors)
                goto abort;
 
@@ -3241,7 +3241,8 @@ static int raid1_reshape(struct mddev *mddev)
                kfree(newpoolinfo);
                return ret;
        }
-       newmirrors = kzalloc(sizeof(struct raid1_info) * raid_disks * 2,
+       newmirrors = kzalloc(array3_size(sizeof(struct raid1_info),
+                                        raid_disks, 2),
                             GFP_KERNEL);
        if (!newmirrors) {
                kfree(newpoolinfo);
index 1147ae59e3b6e063ad62e4cf90e57cb92b581dd0..478cf446827f469c1d02d6f2918fcb8dd870f893 100644 (file)
@@ -175,7 +175,7 @@ static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data)
                nalloc_rp = nalloc;
        else
                nalloc_rp = nalloc * 2;
-       rps = kmalloc(sizeof(struct resync_pages) * nalloc_rp, gfp_flags);
+       rps = kmalloc_array(nalloc_rp, sizeof(struct resync_pages), gfp_flags);
        if (!rps)
                goto out_free_r10bio;
 
@@ -3688,8 +3688,8 @@ static struct r10conf *setup_conf(struct mddev *mddev)
                goto out;
 
        /* FIXME calc properly */
-       conf->mirrors = kzalloc(sizeof(struct raid10_info)*(mddev->raid_disks +
-                                                           max(0,-mddev->delta_disks)),
+       conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks),
+                               sizeof(struct raid10_info),
                                GFP_KERNEL);
        if (!conf->mirrors)
                goto out;
@@ -4129,11 +4129,10 @@ static int raid10_check_reshape(struct mddev *mddev)
        conf->mirrors_new = NULL;
        if (mddev->delta_disks > 0) {
                /* allocate new 'mirrors' list */
-               conf->mirrors_new = kzalloc(
-                       sizeof(struct raid10_info)
-                       *(mddev->raid_disks +
-                         mddev->delta_disks),
-                       GFP_KERNEL);
+               conf->mirrors_new =
+                       kcalloc(mddev->raid_disks + mddev->delta_disks,
+                               sizeof(struct raid10_info),
+                               GFP_KERNEL);
                if (!conf->mirrors_new)
                        return -ENOMEM;
        }
index 73489446bbcb2e1753268d7589130eb59e5760e5..2031506a0ecd766112330ca5c8e08a7b01f84dfe 100644 (file)
@@ -2396,7 +2396,7 @@ static int resize_stripes(struct r5conf *conf, int newsize)
         * is completely stalled, so now is a good time to resize
         * conf->disks and the scribble region
         */
-       ndisks = kzalloc(newsize * sizeof(struct disk_info), GFP_NOIO);
+       ndisks = kcalloc(newsize, sizeof(struct disk_info), GFP_NOIO);
        if (ndisks) {
                for (i = 0; i < conf->pool_size; i++)
                        ndisks[i] = conf->disks[i];
@@ -6664,9 +6664,9 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt,
        }
        *group_cnt = num_possible_nodes();
        size = sizeof(struct r5worker) * cnt;
-       workers = kzalloc(size * *group_cnt, GFP_NOIO);
-       *worker_groups = kzalloc(sizeof(struct r5worker_group) *
-                               *group_cnt, GFP_NOIO);
+       workers = kcalloc(size, *group_cnt, GFP_NOIO);
+       *worker_groups = kcalloc(*group_cnt, sizeof(struct r5worker_group),
+                                GFP_NOIO);
        if (!*worker_groups || !workers) {
                kfree(workers);
                kfree(*worker_groups);
@@ -6894,8 +6894,9 @@ static struct r5conf *setup_conf(struct mddev *mddev)
                goto abort;
        INIT_LIST_HEAD(&conf->free_list);
        INIT_LIST_HEAD(&conf->pending_list);
-       conf->pending_data = kzalloc(sizeof(struct r5pending_data) *
-               PENDING_IO_MAX, GFP_KERNEL);
+       conf->pending_data = kcalloc(PENDING_IO_MAX,
+                                    sizeof(struct r5pending_data),
+                                    GFP_KERNEL);
        if (!conf->pending_data)
                goto abort;
        for (i = 0; i < PENDING_IO_MAX; i++)
@@ -6944,7 +6945,7 @@ static struct r5conf *setup_conf(struct mddev *mddev)
                conf->previous_raid_disks = mddev->raid_disks - mddev->delta_disks;
        max_disks = max(conf->raid_disks, conf->previous_raid_disks);
 
-       conf->disks = kzalloc(max_disks * sizeof(struct disk_info),
+       conf->disks = kcalloc(max_disks, sizeof(struct disk_info),
                              GFP_KERNEL);
 
        if (!conf->disks)
index 9b64f4f354bf8e837d502038338024003154f81e..abd4c788dffdea26b73acb0bb5191ff78c1a3c5d 100644 (file)
@@ -119,12 +119,14 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
                for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
                        unsigned pixelsz = plane ? 2 : 4;
 
-                       tpg->lines[pat][plane] = vzalloc(max_w * 2 * pixelsz);
+                       tpg->lines[pat][plane] =
+                               vzalloc(array3_size(max_w, 2, pixelsz));
                        if (!tpg->lines[pat][plane])
                                return -ENOMEM;
                        if (plane == 0)
                                continue;
-                       tpg->downsampled_lines[pat][plane] = vzalloc(max_w * 2 * pixelsz);
+                       tpg->downsampled_lines[pat][plane] =
+                               vzalloc(array3_size(max_w, 2, pixelsz));
                        if (!tpg->downsampled_lines[pat][plane])
                                return -ENOMEM;
                }
@@ -132,13 +134,16 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w)
        for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
                unsigned pixelsz = plane ? 2 : 4;
 
-               tpg->contrast_line[plane] = vzalloc(max_w * pixelsz);
+               tpg->contrast_line[plane] =
+                       vzalloc(array_size(pixelsz, max_w));
                if (!tpg->contrast_line[plane])
                        return -ENOMEM;
-               tpg->black_line[plane] = vzalloc(max_w * pixelsz);
+               tpg->black_line[plane] =
+                       vzalloc(array_size(pixelsz, max_w));
                if (!tpg->black_line[plane])
                        return -ENOMEM;
-               tpg->random_line[plane] = vzalloc(max_w * 2 * pixelsz);
+               tpg->random_line[plane] =
+                       vzalloc(array3_size(max_w, 2, pixelsz));
                if (!tpg->random_line[plane])
                        return -ENOMEM;
        }
index cb078d688c708d6880d753fe88fcdebec9f62acc..d548f98c7a67d48052c2a77f2c00e9ebb23f3eb1 100644 (file)
@@ -1417,7 +1417,8 @@ int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
        if (dmxdev->demux->open(dmxdev->demux) < 0)
                return -EUSERS;
 
-       dmxdev->filter = vmalloc(dmxdev->filternum * sizeof(struct dmxdev_filter));
+       dmxdev->filter = vmalloc(array_size(sizeof(struct dmxdev_filter),
+                                           dmxdev->filternum));
        if (!dmxdev->filter)
                return -ENOMEM;
 
index f45091246bdca90d870dc0a10bd35e8fd4d73eea..39a2c6ccf31d7fb10cb284410c27191fb70a76f2 100644 (file)
@@ -1247,12 +1247,14 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
 
        dvbdemux->cnt_storage = NULL;
        dvbdemux->users = 0;
-       dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter));
+       dvbdemux->filter = vmalloc(array_size(sizeof(struct dvb_demux_filter),
+                                             dvbdemux->filternum));
 
        if (!dvbdemux->filter)
                return -ENOMEM;
 
-       dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed));
+       dvbdemux->feed = vmalloc(array_size(sizeof(struct dvb_demux_feed),
+                                           dvbdemux->feednum));
        if (!dvbdemux->feed) {
                vfree(dvbdemux->filter);
                dvbdemux->filter = NULL;
index 4330b6fa4af244062743d088aa042cb12e54510c..d1d471af0636da07da17a59d8fa74e2dcb657857 100644 (file)
@@ -55,7 +55,7 @@ int dvb_ringbuffer_empty(struct dvb_ringbuffer *rbuf)
         * this pairs with smp_store_release() in dvb_ringbuffer_write(),
         * dvb_ringbuffer_write_user(), or dvb_ringbuffer_reset()
         *
-        * for memory barriers also see Documentation/circular-buffers.txt
+        * for memory barriers also see Documentation/core-api/circular-buffers.rst
         */
        return (rbuf->pread == smp_load_acquire(&rbuf->pwrite));
 }
index 55e36a4f521546dadd5c5917b27c61703daa9abc..9ecaa9d0744a48fddb631aa01f5ec5c15993f6d8 100644 (file)
@@ -324,7 +324,7 @@ config DVB_SP8870
          A DVB-T tuner module. Say Y when you want to support this frontend.
 
          This driver needs external firmware. Please use the command
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware sp8870" to
+         "<kerneldir>/scripts/get_dvb_firmware sp8870" to
          download/extract it, and then copy it to /usr/lib/hotplug/firmware
          or /lib/firmware (depending on configuration of firmware hotplug).
 
@@ -336,7 +336,7 @@ config DVB_SP887X
          A DVB-T tuner module. Say Y when you want to support this frontend.
 
          This driver needs external firmware. Please use the command
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to
+         "<kerneldir>/scripts/get_dvb_firmware sp887x" to
          download/extract it, and then copy it to /usr/lib/hotplug/firmware
          or /lib/firmware (depending on configuration of firmware hotplug).
 
@@ -387,8 +387,8 @@ config DVB_TDA1004X
          A DVB-T tuner module. Say Y when you want to support this frontend.
 
          This driver needs external firmware. Please use the commands
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to
+         "<kerneldir>/scripts/get_dvb_firmware tda10045",
+         "<kerneldir>/scripts/get_dvb_firmware tda10046" to
          download/extract them, and then copy them to /usr/lib/hotplug/firmware
          or /lib/firmware (depending on configuration of firmware hotplug).
 
@@ -591,8 +591,8 @@ config DVB_NXT200X
          to support this frontend.
 
          This driver needs external firmware. Please use the commands
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" and
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2004" to
+         "<kerneldir>/scripts/get_dvb_firmware nxt2002" and
+         "<kerneldir>/scripts/get_dvb_firmware nxt2004" to
          download/extract them, and then copy them to /usr/lib/hotplug/firmware
          or /lib/firmware (depending on configuration of firmware hotplug).
 
@@ -604,7 +604,7 @@ config DVB_OR51211
          An ATSC 8VSB tuner module. Say Y when you want to support this frontend.
 
          This driver needs external firmware. Please use the command
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware or51211" to
+         "<kerneldir>/scripts/get_dvb_firmware or51211" to
          download it, and then copy it to /usr/lib/hotplug/firmware
          or /lib/firmware (depending on configuration of firmware hotplug).
 
@@ -617,8 +617,8 @@ config DVB_OR51132
          to support this frontend.
 
          This driver needs external firmware. Please use the commands
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware or51132_vsb" and/or
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware or51132_qam" to
+         "<kerneldir>/scripts/get_dvb_firmware or51132_vsb" and/or
+         "<kerneldir>/scripts/get_dvb_firmware or51132_qam" to
          download firmwares for 8VSB and QAM64/256, respectively. Copy them to
          /usr/lib/hotplug/firmware or /lib/firmware (depending on
          configuration of firmware hotplug).
index d5dfafb4ef13b665a5439c9a68ce72eb69452486..d2b7523a22b5ae74cc2a6f294dfd364002f16650 100644 (file)
@@ -17,7 +17,7 @@
  *  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
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  *
  */
 
index de3ce2786c7248a061a54ac38bc975b9e59d1bd9..5861f346db49b7833601fb725e266e572bb0ad6f 100644 (file)
@@ -17,7 +17,7 @@
  *  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
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  *
  */
 
index 902af482448ea5d2c6a552ae6065369f8f61af47..5a8dbc0b25fb23cba73491565aa7bcb28aa54a09 100644 (file)
@@ -2018,10 +2018,10 @@ static int dib7000pc_detection(struct i2c_adapter *i2c_adap)
        };
        int ret = 0;
 
-       tx = kzalloc(2*sizeof(u8), GFP_KERNEL);
+       tx = kzalloc(2, GFP_KERNEL);
        if (!tx)
                return -ENOMEM;
-       rx = kzalloc(2*sizeof(u8), GFP_KERNEL);
+       rx = kzalloc(2, GFP_KERNEL);
        if (!rx) {
                ret = -ENOMEM;
                goto rx_memory_error;
index 6f35173d2968d9e820badbf6be7f4246441202aa..22eec8f654858e3da776c40cbcafff15a09bae8b 100644 (file)
@@ -4271,12 +4271,12 @@ static int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods,
        u8 new_addr = 0;
        struct i2c_device client = {.adap = host };
 
-       client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
+       client.i2c_write_buffer = kzalloc(4, GFP_KERNEL);
        if (!client.i2c_write_buffer) {
                dprintk("%s: not enough memory\n", __func__);
                return -ENOMEM;
        }
-       client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
+       client.i2c_read_buffer = kzalloc(4, GFP_KERNEL);
        if (!client.i2c_read_buffer) {
                dprintk("%s: not enough memory\n", __func__);
                ret = -ENOMEM;
index f9289f488de7db22a1806f44aedd0cc627e00edd..b8edb55696bb8c4caa9a718adae392673e59fe5d 100644 (file)
@@ -2381,12 +2381,12 @@ int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defaul
        u8 new_addr = 0;
        struct i2c_device client = {.i2c_adap = i2c };
 
-       client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
+       client.i2c_write_buffer = kzalloc(4, GFP_KERNEL);
        if (!client.i2c_write_buffer) {
                dprintk("%s: not enough memory\n", __func__);
                return -ENOMEM;
        }
-       client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
+       client.i2c_read_buffer = kzalloc(4, GFP_KERNEL);
        if (!client.i2c_read_buffer) {
                dprintk("%s: not enough memory\n", __func__);
                ret = -ENOMEM;
index c983f2f85802a0361eb1b36a5e85c3792b8b28c1..30f067fc1f568e2b005a856e13d7fadc488e9cd1 100644 (file)
@@ -6,7 +6,7 @@
 *      under the terms of the GNU General Public License as published by the
 *      Free Software Foundation, version 2.
 *
-* see Documentation/dvb/README.dvb-usb for more information
+* see Documentation/media/dvb-drivers/dvb-usb.rst for more information
 */
 
 #ifndef EDS1547
index 7aa74403648e3a8d6dc94ce18abeac37dee46239..a6cc4952eb744b1b3f6ee6b96f5f2dfcc097c54e 100644 (file)
@@ -27,8 +27,8 @@
  *   ATI HDTV Wonder (NXT2004)
  *
  * This driver needs external firmware. Please use the command
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2002" or
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware nxt2004" to
+ * "<kerneldir>/scripts/get_dvb_firmware nxt2002" or
+ * "<kerneldir>/scripts/get_dvb_firmware nxt2004" to
  * download/extract the appropriate firmware, and then copy it to
  * /usr/lib/hotplug/firmware/ or /lib/firmware/
  * (depending on configuration of firmware hotplug).
index a1b7c301828ffe1f8c8d20ff628ea14d2e8ccef2..b65ba34fd00a9d1e5dc9d4fd7373d97d03c4236a 100644 (file)
@@ -22,7 +22,7 @@
 
 /*
  * This driver needs external firmware. Please use the command
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware or51211" to
+ * "<kerneldir>/scripts/get_dvb_firmware or51211" to
  * download/extract it, and then copy it to /usr/lib/hotplug/firmware
  * or /lib/firmware (depending on configuration of firmware hotplug).
  */
index 9a726f3a4896a2c2403894a0d0ecb6a4b05706d1..1d57a20093fc1157505aa90c8959c2852b31021b 100644 (file)
@@ -21,7 +21,7 @@
 */
 /*
  * This driver needs external firmware. Please use the command
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware alps_tdlb7" to
+ * "<kerneldir>/scripts/get_dvb_firmware alps_tdlb7" to
  * download/extract it, and then copy it to /usr/lib/hotplug/firmware
  * or /lib/firmware (depending on configuration of firmware hotplug).
  */
index f39d566d7d1dfb4733dfa780c97ab6e4a0db06df..57a0d0ae2b48f16429c042b45c34c1a8b78a932e 100644 (file)
@@ -4,7 +4,7 @@
 
 /*
  * This driver needs external firmware. Please use the command
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware sp887x" to
+ * "<kerneldir>/scripts/get_dvb_firmware sp887x" to
  * download/extract it, and then copy it to /usr/lib/hotplug/firmware
  * or /lib/firmware (depending on configuration of firmware hotplug).
  */
index 58e3beff5adcb8a0658c3af8dbff62e190743123..7dcfb4a4b2d0258b81f4223b7b91be74b4c1d7a6 100644 (file)
@@ -21,8 +21,8 @@
    */
 /*
  * This driver needs external firmware. Please use the commands
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10045",
- * "<kerneldir>/Documentation/dvb/get_dvb_firmware tda10046" to
+ * "<kerneldir>/scripts/get_dvb_firmware tda10045",
+ * "<kerneldir>/scripts/get_dvb_firmware tda10046" to
  * download/extract them, and then copy them to /usr/lib/hotplug/firmware
  * or /lib/firmware (depending on configuration of firmware hotplug).
  */
index a59f4fd09df605d3568fea54706da363a6ea92bf..1ed67c08e6991372139285946702e30faf657dae 100644 (file)
@@ -852,7 +852,7 @@ static int tda10071_init(struct dvb_frontend *fe)
                ret = request_firmware(&fw, fw_file, &client->dev);
                if (ret) {
                        dev_err(&client->dev,
-                               "did not find the firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)\n",
+                               "did not find the firmware file '%s' (status %d). You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware\n",
                                fw_file, ret);
                        goto error;
                }
index 96d86d6eb4735915850eefde50e26494d9a49ff8..0871c1ade94c82ed69b5e3eacef23940487ad443 100644 (file)
@@ -6,7 +6,7 @@
 *      under the terms of the GNU General Public License as published by the
 *      Free Software Foundation, version 2.
 *
-* see Documentation/dvb/README.dvb-usb for more information
+* see Documentation/media/dvb-drivers/dvb-usb.rst for more information
 */
 
 #ifndef Z0194A
index 87cba15b2977b7711c710e23da0523702b37b453..008a082cb8ad73f2d433f268013694c5f7f86740 100644 (file)
@@ -1202,7 +1202,7 @@ static const struct v4l2_ctrl_ops max2175_ctrl_ops = {
 
 /*
  * I2S output enable/disable configuration. This is a private control.
- * Refer to Documentation/media/v4l-drivers/max2175 for more details.
+ * Refer to Documentation/media/v4l-drivers/max2175.rst for more details.
  */
 static const struct v4l2_ctrl_config max2175_i2s_en = {
        .ops = &max2175_ctrl_ops,
@@ -1218,7 +1218,7 @@ static const struct v4l2_ctrl_config max2175_i2s_en = {
 
 /*
  * HSLS value control LO freq adjacent location configuration.
- * Refer to Documentation/media/v4l-drivers/max2175 for more details.
+ * Refer to Documentation/media/v4l-drivers/max2175.rst for more details.
  */
 static const struct v4l2_ctrl_config max2175_hsls = {
        .ops = &max2175_ctrl_ops,
@@ -1234,7 +1234,7 @@ static const struct v4l2_ctrl_config max2175_hsls = {
 /*
  * Rx modes below are a set of preset configurations that decides the tuner's
  * sck and sample rate of transmission. They are separate for EU & NA regions.
- * Refer to Documentation/media/v4l-drivers/max2175 for more details.
+ * Refer to Documentation/media/v4l-drivers/max2175.rst for more details.
  */
 static const char * const max2175_ctrl_eu_rx_modes[] = {
        [MAX2175_EU_FM_1_2]     = "EU FM 1.2",
index ff46d2c96cea346d1c73fd0161b3c4cad05f7ee2..5007c9659342dbbd2b2e96c00453bf77163ee0ab 100644 (file)
@@ -373,7 +373,7 @@ static int s5k5baf_fw_parse(struct device *dev, struct s5k5baf_fw **fw,
        data += S5K5BAG_FW_TAG_LEN;
        count -= S5K5BAG_FW_TAG_LEN;
 
-       d = devm_kzalloc(dev, count * sizeof(u16), GFP_KERNEL);
+       d = devm_kcalloc(dev, count, sizeof(u16), GFP_KERNEL);
        if (!d)
                return -ENOMEM;
 
index 4a93f6ded100247ee58d565bb5931b30e647ef8b..bc89e37608cdd7199a8ce8f20427eef1b97ebc1a 100644 (file)
@@ -16,7 +16,7 @@ config VIDEO_BT848
        ---help---
          Support for BT848 based frame grabber/overlay boards. This includes
          the Miro, Hauppauge and STB boards. Please read the material in
-         <file:Documentation/video4linux/bttv/> for more information.
+         <file:Documentation/media/v4l-drivers/bttv.rst> for more information.
 
          To compile this driver as a module, choose M here: the
          module will be called bttv.
index 6a6be0b49f7013e18b696c6e11eec295b90e29e0..74aff6877d9cd860b123109a80943c5ea7187d89 100644 (file)
@@ -256,7 +256,8 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc,
        u32 addr;
 
        /* skip list for window clipping */
-       if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL)))
+       skips = kmalloc_array(ov->nclips, sizeof(*skips),GFP_KERNEL);
+       if (NULL == skips)
                return -ENOMEM;
 
        /* estimate risc mem: worst case is (1.5*clip+1) * lines instructions
index 010f39eafce1b3d9834d5f74dc9799ae0c7b2bcd..a3a7f7065349ce0637705831c9d36ba54c310773 100644 (file)
@@ -152,7 +152,7 @@ static int yuan_mpc718_mt352_reqfw(struct cx18_stream *stream,
 
        if (ret) {
                CX18_ERR("The MPC718 board variant with the MT352 DVB-T demodulator will not work without it\n");
-               CX18_ERR("Run 'linux/Documentation/dvb/get_dvb_firmware mpc718' if you need the firmware\n");
+               CX18_ERR("Run 'linux/scripts/get_dvb_firmware mpc718' if you need the firmware\n");
        }
        return ret;
 }
index a594cfdeca200079337ae198a82a987999f8bcdd..b36f4ce25d22dbe2bde1ada588e5b9a8c517d6bb 100644 (file)
@@ -853,7 +853,7 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
 
                /*
                 * Audio related reset according to
-                * Documentation/video4linux/cx2341x/fw-encoder-api.txt
+                * Documentation/media/v4l-drivers/cx2341x.rst
                 */
                if (atomic_read(&cx->ana_capturing) == 0)
                        cx18_vapi(cx, CX18_CPU_SET_MISC_PARAMETERS, 2,
@@ -861,7 +861,7 @@ int cx18_start_v4l2_encode_stream(struct cx18_stream *s)
 
                /*
                 * Number of lines for Field 1 & Field 2 according to
-                * Documentation/video4linux/cx2341x/fw-encoder-api.txt
+                * Documentation/media/v4l-drivers/cx2341x.rst
                 * Field 1 is 312 for 625 line systems in BT.656
                 * Field 2 is 313 for 625 line systems in BT.656
                 */
index 20b3cb17f97fba925810c37dffdf86e109f95d89..db1e8ff35474a9d3875b1f01d5243d878a3e6cf6 100644 (file)
@@ -95,7 +95,7 @@ static int cx23885_alsa_dma_init(struct cx23885_audio_dev *chip, int nr_pages)
        memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
        buf->nr_pages = nr_pages;
 
-       buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist));
+       buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages));
        if (NULL == buf->sglist)
                goto vzalloc_err;
 
index 3a1c55187b2ab7d55af97ebd3226b6d7b1259e79..9f50748fdf56101ccedc918709dc0b3384acd1de 100644 (file)
@@ -2426,7 +2426,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
 
                ret = request_firmware(&fw, filename, &dev->pci->dev);
                if (ret != 0)
-                       pr_err("did not find the firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems.",
+                       pr_err("did not find the firmware file '%s'. You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware.",
                               filename);
                else
                        altera_init(&netup_config, fw);
index a45bf0331eebf7f8181635e1df6ffe133ed50fde..ef6380651c10b133504e86d51ebe3199db8602c2 100644 (file)
@@ -159,7 +159,7 @@ static int cx25821_alsa_dma_init(struct cx25821_audio_dev *chip, int nr_pages)
        memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
        buf->nr_pages = nr_pages;
 
-       buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist));
+       buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages));
        if (NULL == buf->sglist)
                goto vzalloc_err;
 
index 8a28fda703a20889571c73fbf562fb582cb3606f..e5c3387cd1e855705ef66c59554ee2817479ee23 100644 (file)
@@ -298,7 +298,7 @@ static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages)
        memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
        buf->nr_pages = nr_pages;
 
-       buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist));
+       buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages));
        if (!buf->sglist)
                goto vzalloc_err;
 
index 8e62b8be6529d5f5becb88aefb91b7ea7fa18678..b19058e36853deac8bb5d2d0b17c88eb8416edb3 100644 (file)
@@ -1077,7 +1077,7 @@ static int ivtvfb_init_vidmode(struct ivtv *itv)
 
        /* Allocate the pseudo palette */
        oi->ivtvfb_info.pseudo_palette =
-               kmalloc(sizeof(u32) * 16, GFP_KERNEL|__GFP_NOWARN);
+               kmalloc_array(16, sizeof(u32), GFP_KERNEL|__GFP_NOWARN);
 
        if (!oi->ivtvfb_info.pseudo_palette) {
                IVTVFB_ERR("abort, unable to alloc pseudo palette\n");
index 2e60334ffef57447fff51327e394f22fc640f912..9a50f54231adfcf89197715df7a31e6928b2711e 100644 (file)
@@ -5,7 +5,7 @@ config VIDEO_MEYE
        ---help---
          This is the video4linux driver for the Motion Eye camera found
          in the Vaio Picturebook laptops. Please read the material in
-         <file:Documentation/video4linux/meye.txt> for more information.
+         <file:Documentation/media/v4l-drivers/meye.rst> for more information.
 
          If you say Y or M here, you need to say Y or M to "Sony Laptop
          Extras" in the misc device section.
index dedcdb57342705720a6e3a149904dd7b370b78fc..8001d3e9134e440836fdf39b5b3624fd75b5ebe7 100644 (file)
@@ -1625,7 +1625,7 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
        ret = -ENOMEM;
        meye.mchip_dev = pcidev;
 
-       meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
+       meye.grab_temp = vmalloc(array_size(PAGE_SIZE, MCHIP_NB_PAGES_MJPEG));
        if (!meye.grab_temp)
                goto outvmalloc;
 
index 5708f69622cce894fafcdab77eee4b38300189ec..fda969a85684028e78a889c1d49feeb28aac430c 100644 (file)
@@ -615,7 +615,7 @@ static int pt1_init_tables(struct pt1 *pt1)
        if (!pt1_nr_tables)
                return 0;
 
-       tables = vmalloc(sizeof(struct pt1_table) * pt1_nr_tables);
+       tables = vmalloc(array_size(pt1_nr_tables, sizeof(struct pt1_table)));
        if (tables == NULL)
                return -ENOMEM;
 
index 72311445d13d66bad75f28b01cf8b6025cb9afe3..b90cfde6e3016bb2d63d23dafe8f99da6015b1d9 100644 (file)
@@ -279,7 +279,7 @@ static int saa7134_alsa_dma_init(struct saa7134_dev *dev, int nr_pages)
        memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT);
        dma->nr_pages = nr_pages;
 
-       dma->sglist = vzalloc(dma->nr_pages * sizeof(*dma->sglist));
+       dma->sglist = vzalloc(array_size(sizeof(*dma->sglist), dma->nr_pages));
        if (NULL == dma->sglist)
                goto vzalloc_err;
 
index 7b83151ed6c48dd665a021c43438e61b453f2cce..dfba74dd65212e31cbc7d7f7e6c5873582e62489 100644 (file)
@@ -24,7 +24,7 @@ config DVB_AV7110
          onboard MPEG2 decoder.
 
          This driver needs an external firmware. Please use the script
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware av7110" to
+         "<kerneldir>/scripts/get_dvb_firmware av7110" to
          download/extract it, and then copy it to /usr/lib/hotplug/firmware
          or /lib/firmware (depending on configuration of firmware hotplug).
 
index 5aff26574fe1e4e3708e86115af90955f81ecd25..ec528fae7333bd6943a3a517d9e0e8b68fb21770 100644 (file)
@@ -24,7 +24,7 @@ void av7110_ipack_reset(struct ipack *p)
 int av7110_ipack_init(struct ipack *p, int size,
                      void (*func)(u8 *buf, int size, void *priv))
 {
-       if (!(p->buf = vmalloc(size*sizeof(u8)))) {
+       if (!(p->buf = vmalloc(size))) {
                printk(KERN_WARNING "Couldn't allocate memory for ipack\n");
                return -ENOMEM;
        }
index 58ebc2220d0e9d56a47ff55ea2bf2b41f5a50da0..b05738a95e55e1dc77449e0780fa6a30b019009f 100644 (file)
@@ -2586,8 +2586,10 @@ static int vpfe_probe(struct platform_device *pdev)
 
        pm_runtime_put_sync(&pdev->dev);
 
-       vpfe->sd = devm_kzalloc(&pdev->dev, sizeof(struct v4l2_subdev *) *
-                               ARRAY_SIZE(vpfe->cfg->asd), GFP_KERNEL);
+       vpfe->sd = devm_kcalloc(&pdev->dev,
+                               ARRAY_SIZE(vpfe->cfg->asd),
+                               sizeof(struct v4l2_subdev *),
+                               GFP_KERNEL);
        if (!vpfe->sd) {
                ret = -ENOMEM;
                goto probe_out_v4l2_unregister;
index 9364cdf62f5427542679458df07b800588eb4006..a96f53ce808867f21b6a658532c4264b66704801 100644 (file)
@@ -1528,8 +1528,10 @@ vpif_capture_get_pdata(struct platform_device *pdev)
        if (!pdata)
                return NULL;
        pdata->subdev_info =
-               devm_kzalloc(&pdev->dev, sizeof(*pdata->subdev_info) *
-                            VPIF_CAPTURE_NUM_CHANNELS, GFP_KERNEL);
+               devm_kcalloc(&pdev->dev,
+                            VPIF_CAPTURE_NUM_CHANNELS,
+                            sizeof(*pdata->subdev_info),
+                            GFP_KERNEL);
 
        if (!pdata->subdev_info)
                return NULL;
@@ -1546,9 +1548,9 @@ vpif_capture_get_pdata(struct platform_device *pdev)
 
                sdinfo = &pdata->subdev_info[i];
                chan = &pdata->chan_config[i];
-               chan->inputs = devm_kzalloc(&pdev->dev,
-                                           sizeof(*chan->inputs) *
+               chan->inputs = devm_kcalloc(&pdev->dev,
                                            VPIF_CAPTURE_NUM_CHANNELS,
+                                           sizeof(*chan->inputs),
                                            GFP_KERNEL);
                if (!chan->inputs)
                        return NULL;
index 3cf30007234890f63ac3c63c5a5c27e4dea892cb..6d9f0abb26600534ad29ab83ac5c15686a650e6d 100644 (file)
@@ -12,7 +12,7 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include <linux/i2c.h>
-#include <linux/i2c-gpio.h>
+#include <linux/platform_data/i2c-gpio.h>
 #include <linux/interrupt.h>
 #include <linux/spinlock.h>
 #include <linux/slab.h>
index 4d5a26b4cdda6d851b7b9e3b31178d81a4ea0576..d85ffbfb7c1fde9271f1e42ec28a31b205206a78 100644 (file)
@@ -1021,7 +1021,7 @@ static void pxa_camera_wakeup(struct pxa_camera_dev *pcdev,
  *  - a videobuffer is queued on the pcdev->capture list
  *
  * Please check the "DMA hot chaining timeslice issue" in
- *   Documentation/video4linux/pxa_camera.txt
+ *   Documentation/media/v4l-drivers/pxa_camera.rst
  *
  * Context: should only be called within the dma irq handler
  */
@@ -1443,7 +1443,7 @@ static void pxac_vb2_queue(struct vb2_buffer *vb)
 
 /*
  * Please check the DMA prepared buffer structure in :
- *   Documentation/video4linux/pxa_camera.txt
+ *   Documentation/media/v4l-drivers/pxa_camera.rst
  * Please check also in pxa_camera_check_link_miss() to understand why DMA chain
  * modification while DMA chain is running will work anyway.
  */
index 64df82817de3c4ce7a9314302273320fe5d1bb7b..226f36ef741930ff2ff5240470cbb641edd1a512 100644 (file)
@@ -845,7 +845,7 @@ int msm_csid_subdev_init(struct csid_device *csid,
        while (res->clock[csid->nclocks])
                csid->nclocks++;
 
-       csid->clock = devm_kzalloc(dev, csid->nclocks * sizeof(*csid->clock),
+       csid->clock = devm_kcalloc(dev, csid->nclocks, sizeof(*csid->clock),
                                    GFP_KERNEL);
        if (!csid->clock)
                return -ENOMEM;
@@ -868,8 +868,10 @@ int msm_csid_subdev_init(struct csid_device *csid,
                        continue;
                }
 
-               clock->freq = devm_kzalloc(dev, clock->nfreqs *
-                                          sizeof(*clock->freq), GFP_KERNEL);
+               clock->freq = devm_kcalloc(dev,
+                                          clock->nfreqs,
+                                          sizeof(*clock->freq),
+                                          GFP_KERNEL);
                if (!clock->freq)
                        return -ENOMEM;
 
index 072c6cf053f6a576e906e299d4fe6ab189ff099d..7e61caba6a2dcbfafa23d7a574faa6104e18fb77 100644 (file)
@@ -732,8 +732,9 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
        while (res->clock[csiphy->nclocks])
                csiphy->nclocks++;
 
-       csiphy->clock = devm_kzalloc(dev, csiphy->nclocks *
-                                    sizeof(*csiphy->clock), GFP_KERNEL);
+       csiphy->clock = devm_kcalloc(dev,
+                                    csiphy->nclocks, sizeof(*csiphy->clock),
+                                    GFP_KERNEL);
        if (!csiphy->clock)
                return -ENOMEM;
 
@@ -755,8 +756,10 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy,
                        continue;
                }
 
-               clock->freq = devm_kzalloc(dev, clock->nfreqs *
-                                          sizeof(*clock->freq), GFP_KERNEL);
+               clock->freq = devm_kcalloc(dev,
+                                          clock->nfreqs,
+                                          sizeof(*clock->freq),
+                                          GFP_KERNEL);
                if (!clock->freq)
                        return -ENOMEM;
 
index 24da529397b5ba5ccb71d386e8ce3d4591a83a5b..9d1af9353c1dcde30b0bbe732b14ec28626f9ce8 100644 (file)
@@ -948,7 +948,8 @@ int msm_ispif_subdev_init(struct ispif_device *ispif,
        while (res->clock[ispif->nclocks])
                ispif->nclocks++;
 
-       ispif->clock = devm_kzalloc(dev, ispif->nclocks * sizeof(*ispif->clock),
+       ispif->clock = devm_kcalloc(dev,
+                                   ispif->nclocks, sizeof(*ispif->clock),
                                    GFP_KERNEL);
        if (!ispif->clock)
                return -ENOMEM;
@@ -968,8 +969,10 @@ int msm_ispif_subdev_init(struct ispif_device *ispif,
        while (res->clock_for_reset[ispif->nclocks_for_reset])
                ispif->nclocks_for_reset++;
 
-       ispif->clock_for_reset = devm_kzalloc(dev, ispif->nclocks_for_reset *
-                       sizeof(*ispif->clock_for_reset), GFP_KERNEL);
+       ispif->clock_for_reset = devm_kcalloc(dev,
+                                             ispif->nclocks_for_reset,
+                                             sizeof(*ispif->clock_for_reset),
+                                             GFP_KERNEL);
        if (!ispif->clock_for_reset)
                return -ENOMEM;
 
index 55232a9129503e3dda670a3821d0a0f6390a6f2c..a6329a8a7c4a3ab82457b2573f06c0fc7464c10f 100644 (file)
@@ -2794,7 +2794,7 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res)
        while (res->clock[vfe->nclocks])
                vfe->nclocks++;
 
-       vfe->clock = devm_kzalloc(dev, vfe->nclocks * sizeof(*vfe->clock),
+       vfe->clock = devm_kcalloc(dev, vfe->nclocks, sizeof(*vfe->clock),
                                  GFP_KERNEL);
        if (!vfe->clock)
                return -ENOMEM;
@@ -2817,8 +2817,10 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res)
                        continue;
                }
 
-               clock->freq = devm_kzalloc(dev, clock->nfreqs *
-                                          sizeof(*clock->freq), GFP_KERNEL);
+               clock->freq = devm_kcalloc(dev,
+                                          clock->nfreqs,
+                                          sizeof(*clock->freq),
+                                          GFP_KERNEL);
                if (!clock->freq)
                        return -ENOMEM;
 
index 05f06c98aa64592ceb9c1307af98df9359d05c4c..23fda6207a230330879fba5b3dbb4a3a709e9f99 100644 (file)
@@ -271,7 +271,8 @@ static int camss_of_parse_endpoint_node(struct device *dev,
        lncfg->clk.pol = mipi_csi2->lane_polarities[0];
        lncfg->num_data = mipi_csi2->num_data_lanes;
 
-       lncfg->data = devm_kzalloc(dev, lncfg->num_data * sizeof(*lncfg->data),
+       lncfg->data = devm_kcalloc(dev,
+                                  lncfg->num_data, sizeof(*lncfg->data),
                                   GFP_KERNEL);
        if (!lncfg->data)
                return -ENOMEM;
index 242342fd7eded0a030a01a12ecf5fdea88faa0ef..9897213f261841857b76cd50f94cb83ae6504276 100644 (file)
@@ -1111,7 +1111,7 @@ static void sh_mobile_ceu_put_formats(struct soc_camera_device *icd)
 /*
  * CEU can scale and crop, but we don't want to waste bandwidth and kill the
  * framerate by always requesting the maximum image from the client. See
- * Documentation/video4linux/sh_mobile_ceu_camera.txt for a description of
+ * Documentation/media/v4l-drivers/sh_mobile_ceu_camera.rst for a description of
  * scaling and cropping algorithms and for the meaning of referenced here steps.
  */
 static int sh_mobile_ceu_set_selection(struct soc_camera_device *icd,
index 69f0d8e80bd8dfe6fede68d7d8b25c32bbad3137..66d6136291678cdec5add275d03a1d72213b8213 100644 (file)
@@ -481,7 +481,8 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
                return -ENXIO;
 
        icd->user_formats =
-               vmalloc(fmts * sizeof(struct soc_camera_format_xlate));
+               vmalloc(array_size(fmts,
+                                  sizeof(struct soc_camera_format_xlate)));
        if (!icd->user_formats)
                return -ENOMEM;
 
index f01c3e81324757f2e85c58b14e842cdd5304d1f2..c8bb82fe0b9df628ff11b086bb1e5d54fb582068 100644 (file)
 #include <linux/via-core.h>
 #include <linux/via-gpio.h>
 #include <linux/via_i2c.h>
+
+#ifdef CONFIG_X86
 #include <asm/olpc.h>
+#else
+#define machine_is_olpc(x) 0
+#endif
 
 #include "via-camera.h"
 
index 82ec216f2ad8233ac482f9eeb895a4b7101a5a7a..31db363602e5313e88d253f1fb77b9b06652efd9 100644 (file)
@@ -844,10 +844,10 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
        tpg_init(&dev->tpg, 640, 360);
        if (tpg_alloc(&dev->tpg, MAX_ZOOM * MAX_WIDTH))
                goto free_dev;
-       dev->scaled_line = vzalloc(MAX_ZOOM * MAX_WIDTH);
+       dev->scaled_line = vzalloc(array_size(MAX_WIDTH, MAX_ZOOM));
        if (!dev->scaled_line)
                goto free_dev;
-       dev->blended_line = vzalloc(MAX_ZOOM * MAX_WIDTH);
+       dev->blended_line = vzalloc(array_size(MAX_WIDTH, MAX_ZOOM));
        if (!dev->blended_line)
                goto free_dev;
 
@@ -859,8 +859,9 @@ static int vivid_create_instance(struct platform_device *pdev, int inst)
        /* create a string array containing the names of all the preset timings */
        while (v4l2_dv_timings_presets[dev->query_dv_timings_size].bt.width)
                dev->query_dv_timings_size++;
-       dev->query_dv_timings_qmenu = kmalloc(dev->query_dv_timings_size *
-                                          (sizeof(void *) + 32), GFP_KERNEL);
+       dev->query_dv_timings_qmenu = kmalloc_array(dev->query_dv_timings_size,
+                                                   (sizeof(void *) + 32),
+                                                   GFP_KERNEL);
        if (dev->query_dv_timings_qmenu == NULL)
                goto free_dev;
        for (i = 0; i < dev->query_dv_timings_size; i++) {
index da276a85aa95398a97c1a569ec877fbbba4795d5..36a29e13109ece5a0b0cf7d11d178b91b9334f2c 100644 (file)
@@ -630,7 +630,8 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
        entity->source_pad = num_pads - 1;
 
        /* Allocate and initialize pads. */
-       entity->pads = devm_kzalloc(vsp1->dev, num_pads * sizeof(*entity->pads),
+       entity->pads = devm_kcalloc(vsp1->dev,
+                                   num_pads, sizeof(*entity->pads),
                                    GFP_KERNEL);
        if (entity->pads == NULL)
                return -ENOMEM;
index 6bb28cd49dae90513fb089c355b32511e94df00e..6d95ec1e9a6b4b4450d4c60266c27ac72e807137 100644 (file)
@@ -532,7 +532,7 @@ static int xvip_graph_init(struct xvip_composite_device *xdev)
 
        /* Register the subdevices notifier. */
        num_subdevs = xdev->num_subdevs;
-       subdevs = devm_kzalloc(xdev->dev, sizeof(*subdevs) * num_subdevs,
+       subdevs = devm_kcalloc(xdev->dev, num_subdevs, sizeof(*subdevs),
                               GFP_KERNEL);
        if (subdevs == NULL) {
                ret = -ENOMEM;
index 39b04ad924c0ca4e5b82e37ed829172dde36b848..9b99dfb2d0c6419c0af4c7a1eb284905af612410 100644 (file)
@@ -35,7 +35,7 @@ config RADIO_SI476X
          In order to control your radio card, you will need to use programs
          that are compatible with the Video For Linux 2 API.  Information on
          this API and pointers to "v4l2" programs may be found at
-         <file:Documentation/video4linux/API.html>.
+         <file:Documentation/media/media_uapi.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called radio-si476x.
@@ -75,7 +75,7 @@ config RADIO_MAXIRADIO
          In order to control your radio card, you will need to use programs
          that are compatible with the Video For Linux API.  Information on
          this API and pointers to "v4l" programs may be found at
-         <file:Documentation/video4linux/API.html>.
+         <file:Documentation/media/media_uapi.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called radio-maxiradio.
@@ -93,7 +93,7 @@ config RADIO_SHARK
          In order to control your radio card, you will need to use programs
          that are compatible with the Video For Linux API.  Information on
          this API and pointers to "v4l" programs may be found at
-         <file:Documentation/video4linux/API.html>.
+         <file:Documentation/media/media_uapi.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called radio-shark.
@@ -110,7 +110,7 @@ config RADIO_SHARK2
          In order to control your radio card, you will need to use programs
          that are compatible with the Video For Linux API.  Information on
          this API and pointers to "v4l" programs may be found at
-         <file:Documentation/video4linux/API.html>.
+         <file:Documentation/media/media_uapi.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called radio-shark2.
@@ -217,7 +217,7 @@ config RADIO_WL1273
          In order to control your radio card, you will need to use programs
          that are compatible with the Video For Linux 2 API.  Information on
          this API and pointers to "v4l2" programs may be found at
-         <file:Documentation/video4linux/API.html>.
+         <file:Documentation/media/media_uapi.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called radio-wl1273.
@@ -272,7 +272,7 @@ config RADIO_RTRACK
          been reported to be used by these cards.
 
          More information is contained in the file
-         <file:Documentation/video4linux/radiotrack.txt>.
+         <file:Documentation/media/v4l-drivers/radiotrack.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called radio-aimslab.
index a21172e413a94945de72b08fad35ccae033472d3..6dbb158cd2a0bd99f8f5d2d6a236e7038a09b21c 100644 (file)
@@ -29,7 +29,7 @@ config USB_SI470X
 
          Please have a look at the documentation, especially on how
          to redirect the audio stream from the radio to your sound device:
-         Documentation/video4linux/si470x.txt
+         Documentation/media/v4l-drivers/si470x.rst
 
          Say Y here if you want to connect this type of radio to your
          computer's USB port.
index 2add222ea346de2b41243f68275531fb39a3c986..64b66bbdae7225b225e1463386bc58b8a21c1716 100644 (file)
@@ -12,6 +12,6 @@ config RADIO_WL128X
          In order to control your radio card, you will need to use programs
          that are compatible with the Video For Linux 2 API.  Information on
          this API and pointers to "v4l2" programs may be found at
-         <file:Documentation/video4linux/API.html>.
+         <file:Documentation/media/media_uapi.rst>.
 
 endmenu
index 49265f02e772b471b9c3bbb7b49af03bc2dc21d1..8a93f746862204268c748e0481d7f63009544bde 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/hrtimer.h>
 
 #include <media/rc-core.h>
-#include <linux/platform_data/media/ir-rx51.h>
 
 #define WBUF_LEN 256
 
@@ -31,7 +30,6 @@ struct ir_rx51 {
        struct pwm_device *pwm;
        struct hrtimer timer;
        struct device        *dev;
-       struct ir_rx51_platform_data *pdata;
        wait_queue_head_t     wqueue;
 
        unsigned int    freq;           /* carrier frequency */
@@ -130,10 +128,9 @@ static int ir_rx51_tx(struct rc_dev *dev, unsigned int *buffer,
                ir_rx51->wbuf[count] = -1; /* Insert termination mark */
 
        /*
-        * Adjust latency requirements so the device doesn't go in too
-        * deep sleep states
+        * REVISIT: Adjust latency requirements so the device doesn't go in too
+        * deep sleep states with pm_qos_add_request().
         */
-       ir_rx51->pdata->set_max_mpu_wakeup_lat(ir_rx51->dev, 50);
 
        ir_rx51_on(ir_rx51);
        ir_rx51->wbuf_index = 1;
@@ -146,8 +143,7 @@ static int ir_rx51_tx(struct rc_dev *dev, unsigned int *buffer,
         */
        wait_event_interruptible(ir_rx51->wqueue, ir_rx51->wbuf_index < 0);
 
-       /* We can sleep again */
-       ir_rx51->pdata->set_max_mpu_wakeup_lat(ir_rx51->dev, -1);
+       /* REVISIT: Remove pm_qos constraint, we can sleep again */
 
        return count;
 }
@@ -244,13 +240,6 @@ static int ir_rx51_probe(struct platform_device *dev)
        struct pwm_device *pwm;
        struct rc_dev *rcdev;
 
-       ir_rx51.pdata = dev->dev.platform_data;
-
-       if (!ir_rx51.pdata) {
-               dev_err(&dev->dev, "Platform Data is missing\n");
-               return -ENXIO;
-       }
-
        pwm = pwm_get(&dev->dev, NULL);
        if (IS_ERR(pwm)) {
                int err = PTR_ERR(pwm);
index 964cd7bcdd2c67c102a62feeacdc5b3abccc1a1c..70e1879715901e03e47a36e1710b3675ea31e7b8 100644 (file)
@@ -217,14 +217,14 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets,
        dev->isoc_ctl.isoc_copy = isoc_copy;
        dev->isoc_ctl.num_bufs = num_bufs;
 
-       dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs,  GFP_KERNEL);
+       dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(void *),  GFP_KERNEL);
        if (!dev->isoc_ctl.urb) {
                au0828_isocdbg("cannot alloc memory for usb buffers\n");
                return -ENOMEM;
        }
 
-       dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
-                                             GFP_KERNEL);
+       dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, sizeof(void *),
+                                               GFP_KERNEL);
        if (!dev->isoc_ctl.transfer_buffer) {
                au0828_isocdbg("cannot allocate memory for usb transfer\n");
                kfree(dev->isoc_ctl.urb);
index b51fc372ca25b52a11776fb7e7321905360c0e0d..a771e0a52610c84e492f1bafccfebbfe9f73e7c5 100644 (file)
@@ -663,7 +663,8 @@ static int submit_urbs(struct camera_data *cam)
                if (cam->sbuf[i].data)
                        continue;
                cam->sbuf[i].data =
-                   kmalloc(FRAMES_PER_DESC * FRAME_SIZE_PER_DESC, GFP_KERNEL);
+                   kmalloc_array(FRAME_SIZE_PER_DESC, FRAMES_PER_DESC,
+                                 GFP_KERNEL);
                if (!cam->sbuf[i].data) {
                        while (--i >= 0) {
                                kfree(cam->sbuf[i].data);
index d96236d786d1819e6c3eb0d62d7c6614203b584a..c4a84fb930b63a2c7dab59831d3df6ddded4a99e 100644 (file)
@@ -710,7 +710,7 @@ static int cx231xx_audio_init(struct cx231xx *dev)
        dev_info(dev->dev,
                "audio EndPoint Addr 0x%x, Alternate settings: %i\n",
                adev->end_point_addr, adev->num_alt);
-       adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL);
+       adev->alt_max_pkt_size = kmalloc_array(32, adev->num_alt, GFP_KERNEL);
        if (!adev->alt_max_pkt_size) {
                err = -ENOMEM;
                goto err_free_card;
index 4f43668df15df29275db3c296a747c0cc43fcdb7..53d846dea3d2a3c55a8b058ad4bd7bd283ce8fb3 100644 (file)
@@ -1034,7 +1034,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
                dma_q->partial_buf[i] = 0;
 
        dev->video_mode.isoc_ctl.urb =
-           kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
+           kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
        if (!dev->video_mode.isoc_ctl.urb) {
                dev_err(dev->dev,
                        "cannot alloc memory for usb buffers\n");
@@ -1042,7 +1042,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets,
        }
 
        dev->video_mode.isoc_ctl.transfer_buffer =
-           kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
+           kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
        if (!dev->video_mode.isoc_ctl.transfer_buffer) {
                dev_err(dev->dev,
                        "cannot allocate memory for usbtransfer\n");
@@ -1169,7 +1169,7 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets,
                dma_q->partial_buf[i] = 0;
 
        dev->video_mode.bulk_ctl.urb =
-           kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
+           kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
        if (!dev->video_mode.bulk_ctl.urb) {
                dev_err(dev->dev,
                        "cannot alloc memory for usb buffers\n");
@@ -1177,7 +1177,7 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets,
        }
 
        dev->video_mode.bulk_ctl.transfer_buffer =
-           kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
+           kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
        if (!dev->video_mode.bulk_ctl.transfer_buffer) {
                dev_err(dev->dev,
                        "cannot allocate memory for usbtransfer\n");
index d3bfe8e23b1ffdf656e7a9a582f591a5e458d63e..b621cf1aa96b9606ad933b9cc31ca2ca95567789 100644 (file)
@@ -415,7 +415,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
        for (i = 0; i < 8; i++)
                dma_q->partial_buf[i] = 0;
 
-       dev->vbi_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs,
+       dev->vbi_mode.bulk_ctl.urb = kcalloc(num_bufs, sizeof(void *),
                                             GFP_KERNEL);
        if (!dev->vbi_mode.bulk_ctl.urb) {
                dev_err(dev->dev,
@@ -424,7 +424,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets,
        }
 
        dev->vbi_mode.bulk_ctl.transfer_buffer =
-           kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
+           kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
        if (!dev->vbi_mode.bulk_ctl.transfer_buffer) {
                dev_err(dev->dev,
                        "cannot allocate memory for usbtransfer\n");
index 37053477b84d31787e4575762992066ae83fb4e7..082b8d67244bf2c221b1dcdd77434382e868b01b 100644 (file)
@@ -6,7 +6,7 @@ config DVB_USB_V2
          USB1.1 and USB2.0 DVB devices.
 
          Almost every USB device needs a firmware, please look into
-         <file:Documentation/dvb/README.dvb-usb>.
+         <file:Documentation/media/dvb-drivers/dvb-usb.rst>.
 
          For a complete list of supported USB devices see the LinuxTV DVB Wiki:
          <https://linuxtv.org/wiki/index.php/DVB_USB>
index afdcdbf005e9f7193a27021ae7f03c6dcf78de82..955318ab7f5e31c65b698a68b0a1f3581686966e 100644 (file)
@@ -47,7 +47,7 @@ static int dvb_usbv2_download_firmware(struct dvb_usb_device *d,
        ret = request_firmware(&fw, name, &d->udev->dev);
        if (ret < 0) {
                dev_err(&d->udev->dev,
-                               "%s: Did not find the firmware file '%s'. Please see linux/Documentation/dvb/ for more details on firmware-problems. Status %d\n",
+                               "%s: Did not find the firmware file '%s' (status %d). You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware\n",
                                KBUILD_MODNAME, name, ret);
                goto err;
        }
index 4817dfd3e659baf3be495022c3650d2e8afd123d..9d154fdae45be040218d6bb7497fc81fdd5e5914 100644 (file)
@@ -4,7 +4,7 @@
  *     under the terms of the GNU General Public License as published by the
  *     Free Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "gl861.h"
 
index be26c029546bd3f145ee09f9aa3ceb5ff948b977..0750a975bcb899a4744ebf5229c0ced0dcd00fe9 100644 (file)
@@ -21,7 +21,7 @@
  *
  * LME2510C + M88RS2000
  *
- * For firmware see Documentation/dvb/lmedm04.txt
+ * For firmware see Documentation/media/dvb-drivers/lmedm04.rst
  *
  * I2C addresses:
  * 0xd0 - STV0288      - Demodulator
@@ -49,7 +49,7 @@
  * GNU General Public License for more details.
  *
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  *
  * Known Issues :
  *     LME2510: Non Intel USB chipsets fail to maintain High Speed on
index e9c207205c2fd6faa17c3122bb411841214fd16b..c4ae37c19512ea90035781ca216ccae09fb11670 100644 (file)
@@ -16,7 +16,7 @@
  * under the terms of the GNU General Public License as published by the Free
  * Software Foundation,  version 2.
  * *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #ifndef _DVB_USB_LME2510_H_
 #define _DVB_USB_LME2510_H_
index 67953360fda586db9c1e9d904fc87d48f00df45f..4713ba65e1c228b71c1a4c51ecc015cb58a610ad 100644 (file)
@@ -5,7 +5,7 @@
  *   under the terms of the GNU General Public License as published by the Free
  *   Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 
 #include <linux/vmalloc.h>
index 3e6f5880bd1e39494d626d662382e2353513ad5b..22253d4908eb48c8b8c69341abbe46c4ac867c73 100644 (file)
@@ -5,7 +5,7 @@
  *   under the terms of the GNU General Public License as published by the Free
  *   Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 
 #ifndef _DVB_USB_MXL111SF_H_
index 2651ae277347968204a07bd86b306ecf50e89760..b8a1c62a06826256c981ae841e8f6d273368c85b 100644 (file)
@@ -6,7 +6,7 @@ config DVB_USB
          USB1.1 and USB2.0 DVB devices.
 
          Almost every USB device needs a firmware, please look into
-         <file:Documentation/dvb/README.dvb-usb>.
+         <file:Documentation/media/dvb-drivers/dvb-usb.rst>.
 
          For a complete list of supported USB devices see the LinuxTV DVB Wiki:
          <https://linuxtv.org/wiki/index.php/DVB_USB>
index 540886b3bb29aabb24c68b7d75c33822fa01b6d6..198bd5eadb3f04acc8cd4f9a33d93dfb30c05956 100644 (file)
@@ -11,7 +11,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "dibusb.h"
 
index 544bdf18fb2fe4d4d41dfa67f5e9eeac5b7cc1a1..7fbbc954da16564fff762dfe992d8d6dc381bfc7 100644 (file)
@@ -15,7 +15,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "af9005.h"
 #include "af9005-script.h"
index 9b29ffa9307502431c9c4ce79bb3d759ee1e18bc..f7cdcc8424a821aa872318bc4c423158d0d27441 100644 (file)
@@ -17,7 +17,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "af9005.h"
 /* debug */
index 986763b1b2b32a2688a2f9a75db4392bf2bc2d5e..16e946e01d2caab9eaf68546067b3fb92f18731d 100644 (file)
@@ -15,7 +15,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "af9005.h"
 
index a1eae0fa02edda2e70304bf8016a97632e86a65a..7ae4dc3a968b879cd88f71c516e16ad2e09e99b3 100644 (file)
@@ -15,7 +15,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #ifndef _DVB_USB_AF9005_H_
 #define _DVB_USB_AF9005_H_
index f0d10ac03a374408a33b9f75cc29735902d38447..6321b8e302612080d2e93352975198e6a1430ad4 100644 (file)
@@ -7,7 +7,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "az6027.h"
 
index b70d289dc7389029d194a58d231916d40a45d611..5b51ed7d6243fe8572b126e45fba6cee83587f3e 100644 (file)
@@ -21,7 +21,7 @@
  *   under the terms of the GNU General Public License as published by the Free
  *   Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include <media/tuner.h>
 #include <linux/vmalloc.h>
index bcacb0f220282d9c3537e8847b178d7f0ec71727..fb1b4f2d5f9de6ea0ae53cd922727749390a834d 100644 (file)
@@ -6,7 +6,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 
 #include "dibusb.h"
index a0057641cc86838d80d694ca9511e8547a37e480..408920577716119919e7fc268afbf7de750991cc 100644 (file)
@@ -10,7 +10,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "dibusb.h"
 
index 0c2bc97436d555a1d1c2448998558594f20a4ca1..ec3a20a95b04f7f2cd343dda5dbc9dcf0bc7db70 100644 (file)
@@ -6,7 +6,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 
 #include "dibusb.h"
index 08fb8a3f6e0cc23e87ff150c747361fd5259b1f6..bce8ffe640ca3a953b745a297b17acb098147e27 100644 (file)
@@ -10,7 +10,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "dibusb.h"
 
index 697be2a17adef131b68a2f34a2401b2108174b68..943df579b98bd98a9f506578c13fbb4c855f0ebd 100644 (file)
@@ -6,7 +6,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #ifndef _DVB_USB_DIBUSB_H_
 #define _DVB_USB_DIBUSB_H_
index 475a3c0cdee7f88a9630f337cd9d0aaf59f2e177..49b9d63e5885ab5cc1f2100e96df607d9d428a26 100644 (file)
@@ -9,7 +9,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "digitv.h"
 
index 00f565fe7cc2c0b86f3c4b1b91234a57dd0df331..7e75aae34fb8f351ddfb2ae92820dc0bb68fcc8b 100644 (file)
@@ -7,7 +7,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "dtt200u.h"
 
index 5123707866968222a52f73c5d0f94274f761cdd0..f03d26954517e7563fd78d5c9b21bc5ab8c85110 100644 (file)
@@ -9,7 +9,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "dtt200u.h"
 
index efccc399b1cba7cdb92f59b48b7033fa1619b7d1..ea2a096c1650b6d7c0528eed2a71867bdf1c101e 100644 (file)
@@ -7,7 +7,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #ifndef _DVB_USB_DTT200U_H_
 #define _DVB_USB_DTT200U_H_
index 15c153e49382d0c878e76d53cdd35789672ccdd3..42c207aacbb12ce90e0ea9d4cfce46996dcd93f8 100644 (file)
@@ -90,7 +90,7 @@ int dvb_usb_download_firmware(struct usb_device *udev, struct dvb_usb_device_pro
        const struct firmware *fw = NULL;
 
        if ((ret = request_firmware(&fw, props->firmware, &udev->dev)) != 0) {
-               err("did not find the firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
+               err("did not find the firmware file '%s' (status %d). You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware",
                        props->firmware,ret);
                return ret;
        }
index 84308569e7dc12a7911304fc4c8c2abb72b49082..40ca4eafb137412edd1bb58f24868da5069e017c 100644 (file)
@@ -9,7 +9,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "dvb-usb-common.h"
 
index 346946f35b1a5141dfe4c372747872cfb3d04fee..0d4fdd34a7102790a21d3a1cffcadad165106339 100644 (file)
@@ -11,7 +11,7 @@
  *     under the terms of the GNU General Public License as published by the
  *     Free Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include <media/dvb-usb-ids.h>
 #include "dw2102.h"
@@ -61,9 +61,7 @@
 #define P1100_FIRMWARE  "dvb-usb-p1100.fw"
 #define P7500_FIRMWARE  "dvb-usb-p7500.fw"
 
-#define        err_str "did not find the firmware file. (%s) " \
-               "Please see linux/Documentation/dvb/ for more details " \
-               "on firmware-problems."
+#define        err_str "did not find the firmware file '%s'. You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware"
 
 struct dw2102_state {
        u8 initialized;
index b2830c1575485084ecf8ea0f6c6a83992760f3b9..932f262452ebeedbc7d3abc8c40c9a440b2248a8 100644 (file)
@@ -8,7 +8,7 @@
  * under the terms of the GNU General Public License as published by the Free
  * Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include <linux/init.h>
 #include <linux/string.h>
index 16875945e662d0f303930e9993706564bb75485a..fe799a7ad44bacc66df1fe4a1d5e0f7b33392f06 100644 (file)
@@ -8,7 +8,7 @@
  * under the terms of the GNU General Public License as published by the Free
  * Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "friio.h"
 
index 0f461ca10cb941dc255126bfa5b2ef54bd7f5245..a53af56d035c1037023c0d9ee5241438384a3164 100644 (file)
@@ -8,7 +8,7 @@
  * under the terms of the GNU General Public License as published by the Free
  * Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #ifndef _DVB_USB_FRIIO_H_
 #define _DVB_USB_FRIIO_H_
index 334b9fb981120f7a45898d80897b819bbe6875db..13e96b0aeb0fc400869a0baecc13184b07acdd29 100644 (file)
@@ -12,7 +12,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "gp8psk.h"
 #include "gp8psk-fe.h"
@@ -135,7 +135,7 @@ static int gp8psk_load_bcm4500fw(struct dvb_usb_device *d)
        u8 *buf;
        if ((ret = request_firmware(&fw, bcm4500_firmware,
                                        &d->udev->dev)) != 0) {
-               err("did not find the bcm4500 firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems. (%d)",
+               err("did not find the bcm4500 firmware file '%s' (status %d). You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware",
                        bcm4500_firmware,ret);
                return ret;
        }
index d8975b866deeceda0e3820a7810f5cfc2b7205d6..fd063e385eafae87c1c9f17917529439556f00f6 100644 (file)
@@ -12,7 +12,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #ifndef _DVB_USB_GP8PSK_H_
 #define _DVB_USB_GP8PSK_H_
index 32081c2ce0da8560ab2a6e25ed22d21ce5344e22..51b026fa6bfbde4ff54a5651e3be77608dad786e 100644 (file)
@@ -6,7 +6,7 @@
  *     under the terms of the GNU General Public License as published by the
  *     Free Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 
 #include "m920x.h"
index 1babd334191069d30419e2c07fc25fd04e0931d4..43e0e0fd715b966e9ec44d49542a3e14e913d537 100644 (file)
@@ -7,7 +7,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "dibusb.h"
 
index 946a5ccc8f1a97e8117292810b5d9146bec96d79..61a377e2373d8dfbd5c5e8a50561fff563ed76d1 100644 (file)
@@ -7,7 +7,7 @@
 *      under the terms of the GNU General Public License as published by the Free
 *      Software Foundation, version 2.
 *
-* see Documentation/dvb/README.dvb-usb for more information
+* see Documentation/media/dvb-drivers/dvb-usb.rst for more information
 */
 
 #define DVB_USB_LOG_PREFIX "opera"
@@ -453,7 +453,7 @@ static int opera1_xilinx_load_firmware(struct usb_device *dev,
        info("start downloading fpga firmware %s",filename);
 
        if ((ret = request_firmware(&fw, filename, &dev->dev)) != 0) {
-               err("did not find the firmware file. (%s) Please see linux/Documentation/dvb/ for more details on firmware-problems.",
+               err("did not find the firmware file '%s'. You can use <kernel_dir>/scripts/get_dvb_firmware to get the firmware",
                        filename);
                return ret;
        } else {
index 12de89665d6053a834542c46f9ca1926eba926ab..b4d681151599b3009baad7f5915ac4955205c7ca 100644 (file)
@@ -20,7 +20,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #define DVB_USB_LOG_PREFIX "ttusb2"
 #include "dvb-usb.h"
index 52a63af4089677fe12a787ae1901170df0c6d67f..8b6525e5fb2457af7efbd722f6de9e8a9992e2f2 100644 (file)
@@ -9,7 +9,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #ifndef _DVB_USB_TTUSB2_H_
 #define _DVB_USB_TTUSB2_H_
index 58ad5b4f856c5dd5e1ba0d2a824026dc10cc5e97..920bc67c3bcb5a91eb67ef78e64017cfd42ee84e 100644 (file)
@@ -7,7 +7,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "dibusb.h"
 
index 7ff31baa36825885ca4f600874d9ece5613ba08b..ae48146e005ca27c8412dd2d5cdc577460b39ed4 100644 (file)
@@ -15,7 +15,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  *
  */
 #include "vp702x.h"
index 40de33de90a7aef04ae6cf95153c8177596a16ba..c3529ea59da958ae7e1923656700e00b222c57a4 100644 (file)
@@ -12,7 +12,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "vp702x.h"
 #include <linux/mutex.h>
index 4520ad9c2014a1ed2509646b4a1d71d064a05639..f86040173b8de8b5c7f68fedf1a223660a0e9819 100644 (file)
@@ -9,7 +9,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  *
  */
 #include "vp7045.h"
index 2527b88beb872daf49b82bd42be6d4300d75dec2..e2c8a853055443be76e3eb599abb2dd9be64663e 100644 (file)
@@ -10,7 +10,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #include "vp7045.h"
 
index 66499932ca767f97156bb9bce08e82a0dfc9d8ef..2fdafd8f8cd6272fcb90f9d19d440c14369c7481 100644 (file)
@@ -9,7 +9,7 @@
  *     under the terms of the GNU General Public License as published by the Free
  *     Software Foundation, version 2.
  *
- * see Documentation/dvb/README.dvb-usb for more information
+ * see Documentation/media/dvb-drivers/dvb-usb.rst for more information
  */
 #ifndef _DVB_USB_VP7045_H_
 #define _DVB_USB_VP7045_H_
index 87b4fc48ef09ada7881dd39b1047fc52231f6ec0..24f5b615dc7af78d65b3b41e94bec96633d93145 100644 (file)
@@ -1579,7 +1579,7 @@ int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen)
                        GO7007_FW_NAME);
                return -1;
        }
-       code = kzalloc(codespace * 2, GFP_KERNEL);
+       code = kcalloc(codespace, 2, GFP_KERNEL);
        if (code == NULL)
                goto fw_failed;
 
index ed9bcaf08d5ec46df4b4b21af8fcaefd460dc47f..19c6a0354ce000fa848b4ac154f0a731cd8b6b9c 100644 (file)
@@ -1143,7 +1143,8 @@ static int go7007_usb_probe(struct usb_interface *intf,
        usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
        if (usb->intr_urb == NULL)
                goto allocfail;
-       usb->intr_urb->transfer_buffer = kmalloc(2*sizeof(u16), GFP_KERNEL);
+       usb->intr_urb->transfer_buffer = kmalloc_array(2, sizeof(u16),
+                                                      GFP_KERNEL);
        if (usb->intr_urb->transfer_buffer == NULL)
                goto allocfail;
 
index 5a69016ed75fbb2e9356e9bec2e4b14bb57d1a74..13a00399ced9f21ab26a593aef50401f13b80b6d 100644 (file)
@@ -5,7 +5,5 @@ config USB_M5602
          Say Y here if you want support for cameras based on the
          ALi m5602 connected to various image sensors.
 
-         See <file:Documentation/video4linux/m5602.txt> for more info.
-
          To compile this driver as a module, choose M here: the
          module will be called gspca_m5602.
index 0ae557cd15efb2f32170b6348782cbb5653c2c42..445782919446166d4d8ed525952a5c957996568b 100644 (file)
@@ -363,7 +363,7 @@ static void reg_w_ixbuf(struct gspca_dev *gspca_dev,
        if (len * 2 <= USB_BUF_SZ) {
                p = tmpbuf = gspca_dev->usb_buf;
        } else {
-               p = tmpbuf = kmalloc(len * 2, GFP_KERNEL);
+               p = tmpbuf = kmalloc_array(len, 2, GFP_KERNEL);
                if (!tmpbuf) {
                        pr_err("Out of memory\n");
                        return;
index e0353161ccd6ce9743adcf34f5cb6ecaabeacc2e..a8519da0020bf82e9e15cfd5295cd9b6c02b5405 100644 (file)
@@ -2413,7 +2413,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf,
 
        hdw->control_cnt = CTRLDEF_COUNT;
        hdw->control_cnt += MPEGDEF_COUNT;
-       hdw->controls = kzalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt,
+       hdw->controls = kcalloc(hdw->control_cnt, sizeof(struct pvr2_ctrl),
                                GFP_KERNEL);
        if (!hdw->controls) goto fail;
        hdw->hdw_desc = hdw_desc;
index 21bb20dba82c8df5fbc3ccd42c905c220de602eb..6b651f8b54df0f7a713d34959b08c7bcac0cec39 100644 (file)
@@ -361,7 +361,7 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr,
                   std_cnt);
        if (!std_cnt) return NULL; // paranoia
 
-       stddefs = kzalloc(sizeof(struct v4l2_standard) * std_cnt,
+       stddefs = kcalloc(std_cnt, sizeof(struct v4l2_standard),
                          GFP_KERNEL);
        if (!stddefs)
                return NULL;
index 72bd893c965920e20f1de2e1b9f88a01101f2aca..468f5ccf4ae6c98ad089614a596d62b0508a130b 100644 (file)
@@ -290,8 +290,9 @@ static int stk1160_probe(struct usb_interface *interface,
                return -ENODEV;
 
        /* Alloc an array for all possible max_pkt_size */
-       alt_max_pkt_size = kmalloc(sizeof(alt_max_pkt_size[0]) *
-                       interface->num_altsetting, GFP_KERNEL);
+       alt_max_pkt_size = kmalloc_array(interface->num_altsetting,
+                                        sizeof(alt_max_pkt_size[0]),
+                                        GFP_KERNEL);
        if (alt_max_pkt_size == NULL)
                return -ENOMEM;
 
index 423c03a0638dfbc6bbd69b567b8ebded117cf89d..2811f612820fc1b2c1f6db64fa744daf165f2083 100644 (file)
@@ -439,14 +439,14 @@ int stk1160_alloc_isoc(struct stk1160 *dev)
 
        dev->isoc_ctl.buf = NULL;
        dev->isoc_ctl.max_pkt_size = dev->max_pkt_size;
-       dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
+       dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
        if (!dev->isoc_ctl.urb) {
                stk1160_err("out of memory for urb array\n");
                return -ENOMEM;
        }
 
-       dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
-                                             GFP_KERNEL);
+       dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, sizeof(void *),
+                                               GFP_KERNEL);
        if (!dev->isoc_ctl.transfer_buffer) {
                stk1160_err("out of memory for usb transfers\n");
                kfree(dev->isoc_ctl.urb);
index 22389b56ec24664e2df6e3ed412348941f4035c5..5accb52410720196b24181e18ee0620e68dbc223 100644 (file)
@@ -567,8 +567,9 @@ static int stk_prepare_sio_buffers(struct stk_camera *dev, unsigned n_sbufs)
        if (dev->sio_bufs != NULL)
                pr_err("sio_bufs already allocated\n");
        else {
-               dev->sio_bufs = kzalloc(n_sbufs * sizeof(struct stk_sio_buffer),
-                               GFP_KERNEL);
+               dev->sio_bufs = kcalloc(n_sbufs,
+                                       sizeof(struct stk_sio_buffer),
+                                       GFP_KERNEL);
                if (dev->sio_bufs == NULL)
                        return -ENOMEM;
                for (i = 0; i < n_sbufs; i++) {
index aa85fe31c8353c2a0953808c0a276ff580804a61..96055de6e8ce2815cde4c0087c651f1a0857dd01 100644 (file)
@@ -463,11 +463,12 @@ static int tm6000_alloc_urb_buffers(struct tm6000_core *dev)
        if (dev->urb_buffer)
                return 0;
 
-       dev->urb_buffer = kmalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
+       dev->urb_buffer = kmalloc_array(num_bufs, sizeof(void *), GFP_KERNEL);
        if (!dev->urb_buffer)
                return -ENOMEM;
 
-       dev->urb_dma = kmalloc(sizeof(dma_addr_t *)*num_bufs, GFP_KERNEL);
+       dev->urb_dma = kmalloc_array(num_bufs, sizeof(dma_addr_t *),
+                                    GFP_KERNEL);
        if (!dev->urb_dma)
                return -ENOMEM;
 
@@ -583,12 +584,14 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev)
 
        dev->isoc_ctl.num_bufs = num_bufs;
 
-       dev->isoc_ctl.urb = kmalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
+       dev->isoc_ctl.urb = kmalloc_array(num_bufs, sizeof(void *),
+                                         GFP_KERNEL);
        if (!dev->isoc_ctl.urb)
                return -ENOMEM;
 
-       dev->isoc_ctl.transfer_buffer = kmalloc(sizeof(void *)*num_bufs,
-                                  GFP_KERNEL);
+       dev->isoc_ctl.transfer_buffer = kmalloc_array(num_bufs,
+                                                     sizeof(void *),
+                                                     GFP_KERNEL);
        if (!dev->isoc_ctl.transfer_buffer) {
                kfree(dev->isoc_ctl.urb);
                return -ENOMEM;
index 290254ab06dbb01edac5ddc362b3d89eebf1662d..b205903a3c61ada0ae830f46461fc5ac00d97f22 100644 (file)
@@ -12,9 +12,9 @@ config DVB_TTUSB_DEC
          an external software decoder to watch TV on your computer.
 
          This driver needs external firmware. Please use the commands
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2000t",
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware dec2540t",
-         "<kerneldir>/Documentation/dvb/get_dvb_firmware dec3000s",
+         "<kerneldir>/scripts/get_dvb_firmware dec2000t",
+         "<kerneldir>/scripts/get_dvb_firmware dec2540t",
+         "<kerneldir>/scripts/get_dvb_firmware dec3000s",
          download/extract them, and then copy them to /usr/lib/hotplug/firmware
          or /lib/firmware (depending on configuration of firmware hotplug).
 
index ce79df643c7e01e881e7a90bda6faa26df040cfc..36a9a401718574fc7c8809934e035cc30b4eb546 100644 (file)
@@ -507,7 +507,7 @@ static struct urb *usbtv_setup_iso_transfer(struct usbtv *usbtv)
        ip->pipe = usb_rcvisocpipe(usbtv->udev, USBTV_VIDEO_ENDP);
        ip->interval = 1;
        ip->transfer_flags = URB_ISO_ASAP;
-       ip->transfer_buffer = kzalloc(size * USBTV_ISOC_PACKETS,
+       ip->transfer_buffer = kcalloc(USBTV_ISOC_PACKETS, size,
                                                GFP_KERNEL);
        if (!ip->transfer_buffer) {
                usb_free_urb(ip);
index 0f5954a1fea25a1e55beef6abaa6c35f18a5fc7b..f29d1bef029367f241dbbb1125199ee2d99f2525 100644 (file)
@@ -1492,7 +1492,8 @@ static int usbvision_probe(struct usb_interface *intf,
 
        usbvision->num_alt = uif->num_altsetting;
        PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt);
-       usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL);
+       usbvision->alt_max_pkt_size = kmalloc_array(32, usbvision->num_alt,
+                                                   GFP_KERNEL);
        if (!usbvision->alt_max_pkt_size) {
                ret = -ENOMEM;
                goto err_pkt;
index b28c997a7ab0b67157725393b75ce0abb3c15555..a88b2e51a666cb0f1aa649506addb730ceef9805 100644 (file)
@@ -513,8 +513,8 @@ static int uvc_video_clock_init(struct uvc_streaming *stream)
        spin_lock_init(&clock->lock);
        clock->size = 32;
 
-       clock->samples = kmalloc(clock->size * sizeof(*clock->samples),
-                                GFP_KERNEL);
+       clock->samples = kmalloc_array(clock->size, sizeof(*clock->samples),
+                                      GFP_KERNEL);
        if (clock->samples == NULL)
                return -ENOMEM;
 
index 0f585662881dbb94ca7af8e69b66599eaf57e172..ac429bca70e8a671476224c1575b70b097629ed0 100644 (file)
@@ -6,7 +6,7 @@ config USB_ZR364XX
        ---help---
          Say Y here if you want to connect this type of camera to your
          computer's USB port.
-         See <file:Documentation/video4linux/zr364xx.txt> for more info
+         See <file:Documentation/media/v4l-drivers/zr364xx.rst> for more info
          and list of supported cameras.
 
          To compile this driver as a module, choose M here: the
index 968c2eb08b5aba52e18e66221a09b1f351b73337..127fe6eb91d9832289124a399b03b2d6c88715c3 100644 (file)
@@ -215,8 +215,7 @@ int v4l2_event_subscribe(struct v4l2_fh *fh,
        if (elems < 1)
                elems = 1;
 
-       sev = kvzalloc(sizeof(*sev) + sizeof(struct v4l2_kevent) * elems,
-                      GFP_KERNEL);
+       sev = kvzalloc(struct_size(sev, events, elems), GFP_KERNEL);
        if (!sev)
                return -ENOMEM;
        for (i = 0; i < elems; i++)
index 4ceef217de83529e469fc82c5db4e7bd0078ae81..215b4804ada29a5d8b037c96ad6bc1ebfd968eaa 100644 (file)
@@ -412,9 +412,10 @@ static int v4l2_flash_init_controls(struct v4l2_flash *v4l2_flash,
        struct v4l2_ctrl_config *ctrl_cfg;
        int i, ret, num_ctrls = 0;
 
-       v4l2_flash->ctrls = devm_kzalloc(v4l2_flash->sd.dev,
-                                       sizeof(*v4l2_flash->ctrls) *
-                                       (STROBE_SOURCE + 1), GFP_KERNEL);
+       v4l2_flash->ctrls = devm_kcalloc(v4l2_flash->sd.dev,
+                                       STROBE_SOURCE + 1,
+                                       sizeof(*v4l2_flash->ctrls),
+                                       GFP_KERNEL);
        if (!v4l2_flash->ctrls)
                return -ENOMEM;
 
index 2e5c346f9c303ce27bf53298672135127e08dff3..08929c087e270397f8d013102e6961f19e2f09b4 100644 (file)
@@ -69,7 +69,7 @@ static struct scatterlist *videobuf_vmalloc_to_sg(unsigned char *virt,
        struct page *pg;
        int i;
 
-       sglist = vzalloc(nr_pages * sizeof(*sglist));
+       sglist = vzalloc(array_size(nr_pages, sizeof(*sglist)));
        if (NULL == sglist)
                return NULL;
        sg_init_table(sglist, nr_pages);
@@ -100,7 +100,7 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages,
 
        if (NULL == pages[0])
                return NULL;
-       sglist = vmalloc(nr_pages * sizeof(*sglist));
+       sglist = vmalloc(array_size(nr_pages, sizeof(*sglist)));
        if (NULL == sglist)
                return NULL;
        sg_init_table(sglist, nr_pages);
@@ -175,7 +175,8 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma,
        dma->offset = data & ~PAGE_MASK;
        dma->size = size;
        dma->nr_pages = last-first+1;
-       dma->pages = kmalloc(dma->nr_pages * sizeof(struct page *), GFP_KERNEL);
+       dma->pages = kmalloc_array(dma->nr_pages, sizeof(struct page *),
+                                  GFP_KERNEL);
        if (NULL == dma->pages)
                return -ENOMEM;
 
index 19a0e83f260dba82d41980c43ffc1259feebfbbf..8d731d6c3e541c39dfa908a116806d0f15dad135 100644 (file)
@@ -104,16 +104,6 @@ config MVEBU_DEVBUS
          Armada 370 and Armada XP. This controller allows to handle flash
          devices such as NOR, NAND, SRAM, and FPGA.
 
-config TEGRA20_MC
-       bool "Tegra20 Memory Controller(MC) driver"
-       default y
-       depends on ARCH_TEGRA_2x_SOC
-       help
-         This driver is for the Memory Controller(MC) module available
-         in Tegra20 SoCs, mainly for a address translation fault
-         analysis, especially for IOMMU/GART(Graphics Address
-         Relocation Table) module.
-
 config FSL_CORENET_CF
        tristate "Freescale CoreNet Error Reporting"
        depends on FSL_SOC_BOOKE
index 66f55240830e7343f14e8ceca27901e3acf82862..a01ab3e22f94db6dc81c7032b06adab9ec4bc48e 100644 (file)
@@ -16,7 +16,6 @@ obj-$(CONFIG_OMAP_GPMC)               += omap-gpmc.o
 obj-$(CONFIG_FSL_CORENET_CF)   += fsl-corenet-cf.o
 obj-$(CONFIG_FSL_IFC)          += fsl_ifc.o
 obj-$(CONFIG_MVEBU_DEVBUS)     += mvebu-devbus.o
-obj-$(CONFIG_TEGRA20_MC)       += tegra20-mc.o
 obj-$(CONFIG_JZ4780_NEMC)      += jz4780-nemc.o
 obj-$(CONFIG_MTK_SMI)          += mtk-smi.o
 obj-$(CONFIG_DA8XX_DDRCTL)     += da8xx-ddrctl.o
index e9c1485c32b95c66c670e698557632964a946072..04599eccd60421ba4839c4b23a1f05575bac6eb0 100644 (file)
@@ -176,7 +176,6 @@ struct private_data {
        void __iomem *dmem;
        void __iomem *imem;
        struct device *dev;
-       unsigned int index;
        struct mutex lock;
 };
 
@@ -674,10 +673,8 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct private_data *priv;
-       struct device *dpfe_dev;
        struct init_data init;
        struct resource *res;
-       u32 index;
        int ret;
 
        priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -687,11 +684,6 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)
        mutex_init(&priv->lock);
        platform_set_drvdata(pdev, priv);
 
-       /* Cell index is optional; default to 0 if not present. */
-       ret = of_property_read_u32(dev->of_node, "cell-index", &index);
-       if (ret)
-               index = 0;
-
        res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dpfe-cpu");
        priv->regs = devm_ioremap_resource(dev, res);
        if (IS_ERR(priv->regs)) {
@@ -715,35 +707,20 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)
 
        ret = brcmstb_dpfe_download_firmware(pdev, &init);
        if (ret)
-               goto err;
-
-       dpfe_dev = devm_kzalloc(dev, sizeof(*dpfe_dev), GFP_KERNEL);
-       if (!dpfe_dev) {
-               ret = -ENOMEM;
-               goto err;
-       }
-
-       priv->dev = dpfe_dev;
-       priv->index = index;
+               return ret;
 
-       dpfe_dev->parent = dev;
-       dpfe_dev->groups = dpfe_groups;
-       dpfe_dev->of_node = dev->of_node;
-       dev_set_drvdata(dpfe_dev, priv);
-       dev_set_name(dpfe_dev, "dpfe%u", index);
+       ret = sysfs_create_groups(&pdev->dev.kobj, dpfe_groups);
+       if (!ret)
+               dev_info(dev, "registered.\n");
 
-       ret = device_register(dpfe_dev);
-       if (ret)
-               goto err;
+       return ret;
+}
 
-       dev_info(dev, "registered.\n");
+static int brcmstb_dpfe_remove(struct platform_device *pdev)
+{
+       sysfs_remove_groups(&pdev->dev.kobj, dpfe_groups);
 
        return 0;
-
-err:
-       dev_err(dev, "failed to initialize -- error %d\n", ret);
-
-       return ret;
 }
 
 static const struct of_device_id brcmstb_dpfe_of_match[] = {
@@ -758,6 +735,7 @@ static struct platform_driver brcmstb_dpfe_driver = {
                .of_match_table = brcmstb_dpfe_of_match,
        },
        .probe = brcmstb_dpfe_probe,
+       .remove = brcmstb_dpfe_remove,
        .resume = brcmstb_dpfe_resume,
 };
 
index 568f05ed961a8764a23c0a909d68c384c5afc127..2f5ed7366eec73e16d61e14dd9e2bff502980148 100644 (file)
@@ -126,8 +126,8 @@ const struct lpddr2_timings *of_get_ddr_timings(struct device_node *np_ddr,
                        arr_sz++;
 
        if (arr_sz)
-               timings = devm_kzalloc(dev, sizeof(*timings) * arr_sz,
-                       GFP_KERNEL);
+               timings = devm_kcalloc(dev, arr_sz, sizeof(*timings),
+                                      GFP_KERNEL);
 
        if (!timings)
                goto default_timings;
index 90a66b3f7ae154e24859cc1e56fce312ed9752f8..c215287e80cf3bbff8d452f53bf097fba39148dd 100644 (file)
@@ -2060,8 +2060,8 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
         * timings.
         */
        name = gpmc_cs_get_name(cs);
-       if (name && child->name && of_node_cmp(child->name, name) == 0)
-                       goto no_timings;
+       if (name && of_node_cmp(child->name, name) == 0)
+               goto no_timings;
 
        ret = gpmc_cs_request(cs, resource_size(&res), &base);
        if (ret < 0) {
index ce87a94700342cc190df6fc13fbc33fbf839ebe0..94ab16ba075bce38d7cacdd1bc21288299600d3c 100644 (file)
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 tegra-mc-y := mc.o
 
+tegra-mc-$(CONFIG_ARCH_TEGRA_2x_SOC)  += tegra20.o
 tegra-mc-$(CONFIG_ARCH_TEGRA_3x_SOC)  += tegra30.o
 tegra-mc-$(CONFIG_ARCH_TEGRA_114_SOC) += tegra114.o
 tegra-mc-$(CONFIG_ARCH_TEGRA_124_SOC) += tegra124.o
index a4803ac192bbc86f550d35f4e8eb236c77aeafd6..bb93cc53554e63cc279d58cf44c2733a46c28368 100644 (file)
@@ -7,6 +7,7 @@
  */
 
 #include <linux/clk.h>
+#include <linux/delay.h>
 #include <linux/interrupt.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
 #include "mc.h"
 
 #define MC_INTSTATUS 0x000
-#define  MC_INT_DECERR_MTS (1 << 16)
-#define  MC_INT_SECERR_SEC (1 << 13)
-#define  MC_INT_DECERR_VPR (1 << 12)
-#define  MC_INT_INVALID_APB_ASID_UPDATE (1 << 11)
-#define  MC_INT_INVALID_SMMU_PAGE (1 << 10)
-#define  MC_INT_ARBITRATION_EMEM (1 << 9)
-#define  MC_INT_SECURITY_VIOLATION (1 << 8)
-#define  MC_INT_DECERR_EMEM (1 << 6)
 
 #define MC_INTMASK 0x004
 
@@ -45,6 +38,9 @@
 
 #define MC_ERR_ADR 0x0c
 
+#define MC_DECERR_EMEM_OTHERS_STATUS   0x58
+#define MC_SECURITY_VIOLATION_STATUS   0x74
+
 #define MC_EMEM_ARB_CFG 0x90
 #define  MC_EMEM_ARB_CFG_CYCLES_PER_UPDATE(x)  (((x) & 0x1ff) << 0)
 #define  MC_EMEM_ARB_CFG_CYCLES_PER_UPDATE_MASK        0x1ff
@@ -54,6 +50,9 @@
 #define MC_EMEM_ADR_CFG_EMEM_NUMDEV BIT(0)
 
 static const struct of_device_id tegra_mc_of_match[] = {
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
+       { .compatible = "nvidia,tegra20-mc", .data = &tegra20_mc_soc },
+#endif
 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
        { .compatible = "nvidia,tegra30-mc", .data = &tegra30_mc_soc },
 #endif
@@ -73,6 +72,207 @@ static const struct of_device_id tegra_mc_of_match[] = {
 };
 MODULE_DEVICE_TABLE(of, tegra_mc_of_match);
 
+static int terga_mc_block_dma_common(struct tegra_mc *mc,
+                                    const struct tegra_mc_reset *rst)
+{
+       unsigned long flags;
+       u32 value;
+
+       spin_lock_irqsave(&mc->lock, flags);
+
+       value = mc_readl(mc, rst->control) | BIT(rst->bit);
+       mc_writel(mc, value, rst->control);
+
+       spin_unlock_irqrestore(&mc->lock, flags);
+
+       return 0;
+}
+
+static bool terga_mc_dma_idling_common(struct tegra_mc *mc,
+                                      const struct tegra_mc_reset *rst)
+{
+       return (mc_readl(mc, rst->status) & BIT(rst->bit)) != 0;
+}
+
+static int terga_mc_unblock_dma_common(struct tegra_mc *mc,
+                                      const struct tegra_mc_reset *rst)
+{
+       unsigned long flags;
+       u32 value;
+
+       spin_lock_irqsave(&mc->lock, flags);
+
+       value = mc_readl(mc, rst->control) & ~BIT(rst->bit);
+       mc_writel(mc, value, rst->control);
+
+       spin_unlock_irqrestore(&mc->lock, flags);
+
+       return 0;
+}
+
+static int terga_mc_reset_status_common(struct tegra_mc *mc,
+                                       const struct tegra_mc_reset *rst)
+{
+       return (mc_readl(mc, rst->control) & BIT(rst->bit)) != 0;
+}
+
+const struct tegra_mc_reset_ops terga_mc_reset_ops_common = {
+       .block_dma = terga_mc_block_dma_common,
+       .dma_idling = terga_mc_dma_idling_common,
+       .unblock_dma = terga_mc_unblock_dma_common,
+       .reset_status = terga_mc_reset_status_common,
+};
+
+static inline struct tegra_mc *reset_to_mc(struct reset_controller_dev *rcdev)
+{
+       return container_of(rcdev, struct tegra_mc, reset);
+}
+
+static const struct tegra_mc_reset *tegra_mc_reset_find(struct tegra_mc *mc,
+                                                       unsigned long id)
+{
+       unsigned int i;
+
+       for (i = 0; i < mc->soc->num_resets; i++)
+               if (mc->soc->resets[i].id == id)
+                       return &mc->soc->resets[i];
+
+       return NULL;
+}
+
+static int tegra_mc_hotreset_assert(struct reset_controller_dev *rcdev,
+                                   unsigned long id)
+{
+       struct tegra_mc *mc = reset_to_mc(rcdev);
+       const struct tegra_mc_reset_ops *rst_ops;
+       const struct tegra_mc_reset *rst;
+       int retries = 500;
+       int err;
+
+       rst = tegra_mc_reset_find(mc, id);
+       if (!rst)
+               return -ENODEV;
+
+       rst_ops = mc->soc->reset_ops;
+       if (!rst_ops)
+               return -ENODEV;
+
+       if (rst_ops->block_dma) {
+               /* block clients DMA requests */
+               err = rst_ops->block_dma(mc, rst);
+               if (err) {
+                       dev_err(mc->dev, "Failed to block %s DMA: %d\n",
+                               rst->name, err);
+                       return err;
+               }
+       }
+
+       if (rst_ops->dma_idling) {
+               /* wait for completion of the outstanding DMA requests */
+               while (!rst_ops->dma_idling(mc, rst)) {
+                       if (!retries--) {
+                               dev_err(mc->dev, "Failed to flush %s DMA\n",
+                                       rst->name);
+                               return -EBUSY;
+                       }
+
+                       usleep_range(10, 100);
+               }
+       }
+
+       if (rst_ops->hotreset_assert) {
+               /* clear clients DMA requests sitting before arbitration */
+               err = rst_ops->hotreset_assert(mc, rst);
+               if (err) {
+                       dev_err(mc->dev, "Failed to hot reset %s: %d\n",
+                               rst->name, err);
+                       return err;
+               }
+       }
+
+       return 0;
+}
+
+static int tegra_mc_hotreset_deassert(struct reset_controller_dev *rcdev,
+                                     unsigned long id)
+{
+       struct tegra_mc *mc = reset_to_mc(rcdev);
+       const struct tegra_mc_reset_ops *rst_ops;
+       const struct tegra_mc_reset *rst;
+       int err;
+
+       rst = tegra_mc_reset_find(mc, id);
+       if (!rst)
+               return -ENODEV;
+
+       rst_ops = mc->soc->reset_ops;
+       if (!rst_ops)
+               return -ENODEV;
+
+       if (rst_ops->hotreset_deassert) {
+               /* take out client from hot reset */
+               err = rst_ops->hotreset_deassert(mc, rst);
+               if (err) {
+                       dev_err(mc->dev, "Failed to deassert hot reset %s: %d\n",
+                               rst->name, err);
+                       return err;
+               }
+       }
+
+       if (rst_ops->unblock_dma) {
+               /* allow new DMA requests to proceed to arbitration */
+               err = rst_ops->unblock_dma(mc, rst);
+               if (err) {
+                       dev_err(mc->dev, "Failed to unblock %s DMA : %d\n",
+                               rst->name, err);
+                       return err;
+               }
+       }
+
+       return 0;
+}
+
+static int tegra_mc_hotreset_status(struct reset_controller_dev *rcdev,
+                                   unsigned long id)
+{
+       struct tegra_mc *mc = reset_to_mc(rcdev);
+       const struct tegra_mc_reset_ops *rst_ops;
+       const struct tegra_mc_reset *rst;
+
+       rst = tegra_mc_reset_find(mc, id);
+       if (!rst)
+               return -ENODEV;
+
+       rst_ops = mc->soc->reset_ops;
+       if (!rst_ops)
+               return -ENODEV;
+
+       return rst_ops->reset_status(mc, rst);
+}
+
+static const struct reset_control_ops tegra_mc_reset_ops = {
+       .assert = tegra_mc_hotreset_assert,
+       .deassert = tegra_mc_hotreset_deassert,
+       .status = tegra_mc_hotreset_status,
+};
+
+static int tegra_mc_reset_setup(struct tegra_mc *mc)
+{
+       int err;
+
+       mc->reset.ops = &tegra_mc_reset_ops;
+       mc->reset.owner = THIS_MODULE;
+       mc->reset.of_node = mc->dev->of_node;
+       mc->reset.of_reset_n_cells = 1;
+       mc->reset.nr_resets = mc->soc->num_resets;
+
+       err = reset_controller_register(&mc->reset);
+       if (err < 0)
+               return err;
+
+       return 0;
+}
+
 static int tegra_mc_setup_latency_allowance(struct tegra_mc *mc)
 {
        unsigned long long tick;
@@ -229,6 +429,7 @@ static int tegra_mc_setup_timings(struct tegra_mc *mc)
 static const char *const status_names[32] = {
        [ 1] = "External interrupt",
        [ 6] = "EMEM address decode error",
+       [ 7] = "GART page fault",
        [ 8] = "Security violation",
        [ 9] = "EMEM arbitration error",
        [10] = "Page fault",
@@ -248,12 +449,13 @@ static const char *const error_names[8] = {
 static irqreturn_t tegra_mc_irq(int irq, void *data)
 {
        struct tegra_mc *mc = data;
-       unsigned long status, mask;
+       unsigned long status;
        unsigned int bit;
 
        /* mask all interrupts to avoid flooding */
-       status = mc_readl(mc, MC_INTSTATUS);
-       mask = mc_readl(mc, MC_INTMASK);
+       status = mc_readl(mc, MC_INTSTATUS) & mc->soc->intmask;
+       if (!status)
+               return IRQ_NONE;
 
        for_each_set_bit(bit, &status, 32) {
                const char *error = status_names[bit] ?: "unknown";
@@ -341,12 +543,78 @@ static irqreturn_t tegra_mc_irq(int irq, void *data)
        return IRQ_HANDLED;
 }
 
+static __maybe_unused irqreturn_t tegra20_mc_irq(int irq, void *data)
+{
+       struct tegra_mc *mc = data;
+       unsigned long status;
+       unsigned int bit;
+
+       /* mask all interrupts to avoid flooding */
+       status = mc_readl(mc, MC_INTSTATUS) & mc->soc->intmask;
+       if (!status)
+               return IRQ_NONE;
+
+       for_each_set_bit(bit, &status, 32) {
+               const char *direction = "read", *secure = "";
+               const char *error = status_names[bit];
+               const char *client, *desc;
+               phys_addr_t addr;
+               u32 value, reg;
+               u8 id, type;
+
+               switch (BIT(bit)) {
+               case MC_INT_DECERR_EMEM:
+                       reg = MC_DECERR_EMEM_OTHERS_STATUS;
+                       value = mc_readl(mc, reg);
+
+                       id = value & mc->soc->client_id_mask;
+                       desc = error_names[2];
+
+                       if (value & BIT(31))
+                               direction = "write";
+                       break;
+
+               case MC_INT_INVALID_GART_PAGE:
+                       dev_err_ratelimited(mc->dev, "%s\n", error);
+                       continue;
+
+               case MC_INT_SECURITY_VIOLATION:
+                       reg = MC_SECURITY_VIOLATION_STATUS;
+                       value = mc_readl(mc, reg);
+
+                       id = value & mc->soc->client_id_mask;
+                       type = (value & BIT(30)) ? 4 : 3;
+                       desc = error_names[type];
+                       secure = "secure ";
+
+                       if (value & BIT(31))
+                               direction = "write";
+                       break;
+
+               default:
+                       continue;
+               }
+
+               client = mc->soc->clients[id].name;
+               addr = mc_readl(mc, reg + sizeof(u32));
+
+               dev_err_ratelimited(mc->dev, "%s: %s%s @%pa: %s (%s)\n",
+                                   client, secure, direction, &addr, error,
+                                   desc);
+       }
+
+       /* clear interrupts */
+       mc_writel(mc, status, MC_INTSTATUS);
+
+       return IRQ_HANDLED;
+}
+
 static int tegra_mc_probe(struct platform_device *pdev)
 {
        const struct of_device_id *match;
        struct resource *res;
        struct tegra_mc *mc;
-       u32 value;
+       void *isr;
        int err;
 
        match = of_match_node(tegra_mc_of_match, pdev->dev.of_node);
@@ -358,6 +626,7 @@ static int tegra_mc_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        platform_set_drvdata(pdev, mc);
+       spin_lock_init(&mc->lock);
        mc->soc = match->data;
        mc->dev = &pdev->dev;
 
@@ -369,18 +638,32 @@ static int tegra_mc_probe(struct platform_device *pdev)
        if (IS_ERR(mc->regs))
                return PTR_ERR(mc->regs);
 
-       mc->clk = devm_clk_get(&pdev->dev, "mc");
-       if (IS_ERR(mc->clk)) {
-               dev_err(&pdev->dev, "failed to get MC clock: %ld\n",
-                       PTR_ERR(mc->clk));
-               return PTR_ERR(mc->clk);
-       }
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
+       if (mc->soc == &tegra20_mc_soc) {
+               res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+               mc->regs2 = devm_ioremap_resource(&pdev->dev, res);
+               if (IS_ERR(mc->regs2))
+                       return PTR_ERR(mc->regs2);
 
-       err = tegra_mc_setup_latency_allowance(mc);
-       if (err < 0) {
-               dev_err(&pdev->dev, "failed to setup latency allowance: %d\n",
-                       err);
-               return err;
+               isr = tegra20_mc_irq;
+       } else
+#endif
+       {
+               mc->clk = devm_clk_get(&pdev->dev, "mc");
+               if (IS_ERR(mc->clk)) {
+                       dev_err(&pdev->dev, "failed to get MC clock: %ld\n",
+                               PTR_ERR(mc->clk));
+                       return PTR_ERR(mc->clk);
+               }
+
+               err = tegra_mc_setup_latency_allowance(mc);
+               if (err < 0) {
+                       dev_err(&pdev->dev, "failed to setup latency allowance: %d\n",
+                               err);
+                       return err;
+               }
+
+               isr = tegra_mc_irq;
        }
 
        err = tegra_mc_setup_timings(mc);
@@ -389,13 +672,11 @@ static int tegra_mc_probe(struct platform_device *pdev)
                return err;
        }
 
-       if (IS_ENABLED(CONFIG_TEGRA_IOMMU_SMMU)) {
-               mc->smmu = tegra_smmu_probe(&pdev->dev, mc->soc->smmu, mc);
-               if (IS_ERR(mc->smmu)) {
-                       dev_err(&pdev->dev, "failed to probe SMMU: %ld\n",
-                               PTR_ERR(mc->smmu));
-                       return PTR_ERR(mc->smmu);
-               }
+       err = tegra_mc_reset_setup(mc);
+       if (err < 0) {
+               dev_err(&pdev->dev, "failed to register reset controller: %d\n",
+                       err);
+               return err;
        }
 
        mc->irq = platform_get_irq(pdev, 0);
@@ -404,7 +685,11 @@ static int tegra_mc_probe(struct platform_device *pdev)
                return mc->irq;
        }
 
-       err = devm_request_irq(&pdev->dev, mc->irq, tegra_mc_irq, IRQF_SHARED,
+       WARN(!mc->soc->client_id_mask, "Missing client ID mask for this SoC\n");
+
+       mc_writel(mc, mc->soc->intmask, MC_INTMASK);
+
+       err = devm_request_irq(&pdev->dev, mc->irq, isr, IRQF_SHARED,
                               dev_name(&pdev->dev), mc);
        if (err < 0) {
                dev_err(&pdev->dev, "failed to request IRQ#%u: %d\n", mc->irq,
@@ -412,13 +697,14 @@ static int tegra_mc_probe(struct platform_device *pdev)
                return err;
        }
 
-       WARN(!mc->soc->client_id_mask, "Missing client ID mask for this SoC\n");
-
-       value = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
-               MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
-               MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM;
-
-       mc_writel(mc, value, MC_INTMASK);
+       if (IS_ENABLED(CONFIG_TEGRA_IOMMU_SMMU)) {
+               mc->smmu = tegra_smmu_probe(&pdev->dev, mc->soc->smmu, mc);
+               if (IS_ERR(mc->smmu)) {
+                       dev_err(&pdev->dev, "failed to probe SMMU: %ld\n",
+                               PTR_ERR(mc->smmu));
+                       return PTR_ERR(mc->smmu);
+               }
+       }
 
        return 0;
 }
index ddb16676c3af4d99b59e62b84d77d0bdb30b5158..01065f12ebebe5991a86ba2320d97287f3fbe3b5 100644 (file)
 
 #include <soc/tegra/mc.h>
 
+#define MC_INT_DECERR_MTS (1 << 16)
+#define MC_INT_SECERR_SEC (1 << 13)
+#define MC_INT_DECERR_VPR (1 << 12)
+#define MC_INT_INVALID_APB_ASID_UPDATE (1 << 11)
+#define MC_INT_INVALID_SMMU_PAGE (1 << 10)
+#define MC_INT_ARBITRATION_EMEM (1 << 9)
+#define MC_INT_SECURITY_VIOLATION (1 << 8)
+#define MC_INT_INVALID_GART_PAGE (1 << 7)
+#define MC_INT_DECERR_EMEM (1 << 6)
+
 static inline u32 mc_readl(struct tegra_mc *mc, unsigned long offset)
 {
+       if (mc->regs2 && offset >= 0x24)
+               return readl(mc->regs2 + offset - 0x3c);
+
        return readl(mc->regs + offset);
 }
 
 static inline void mc_writel(struct tegra_mc *mc, u32 value,
                             unsigned long offset)
 {
+       if (mc->regs2 && offset >= 0x24)
+               return writel(value, mc->regs2 + offset - 0x3c);
+
        writel(value, mc->regs + offset);
 }
 
+extern const struct tegra_mc_reset_ops terga_mc_reset_ops_common;
+
+#ifdef CONFIG_ARCH_TEGRA_2x_SOC
+extern const struct tegra_mc_soc tegra20_mc_soc;
+#endif
+
 #ifdef CONFIG_ARCH_TEGRA_3x_SOC
 extern const struct tegra_mc_soc tegra30_mc_soc;
 #endif
index b20e6e3e208e9324978b95af41020a6d4987c69d..6560a5101322daeda8f67b329b90bd0de8cba3b5 100644 (file)
@@ -938,6 +938,34 @@ static const struct tegra_smmu_soc tegra114_smmu_soc = {
        .num_asids = 4,
 };
 
+#define TEGRA114_MC_RESET(_name, _control, _status, _bit)      \
+       {                                                       \
+               .name = #_name,                                 \
+               .id = TEGRA114_MC_RESET_##_name,                \
+               .control = _control,                            \
+               .status = _status,                              \
+               .bit = _bit,                                    \
+       }
+
+static const struct tegra_mc_reset tegra114_mc_resets[] = {
+       TEGRA114_MC_RESET(AVPC,     0x200, 0x204,  1),
+       TEGRA114_MC_RESET(DC,       0x200, 0x204,  2),
+       TEGRA114_MC_RESET(DCB,      0x200, 0x204,  3),
+       TEGRA114_MC_RESET(EPP,      0x200, 0x204,  4),
+       TEGRA114_MC_RESET(2D,       0x200, 0x204,  5),
+       TEGRA114_MC_RESET(HC,       0x200, 0x204,  6),
+       TEGRA114_MC_RESET(HDA,      0x200, 0x204,  7),
+       TEGRA114_MC_RESET(ISP,      0x200, 0x204,  8),
+       TEGRA114_MC_RESET(MPCORE,   0x200, 0x204,  9),
+       TEGRA114_MC_RESET(MPCORELP, 0x200, 0x204, 10),
+       TEGRA114_MC_RESET(MPE,      0x200, 0x204, 11),
+       TEGRA114_MC_RESET(3D,       0x200, 0x204, 12),
+       TEGRA114_MC_RESET(3D2,      0x200, 0x204, 13),
+       TEGRA114_MC_RESET(PPCS,     0x200, 0x204, 14),
+       TEGRA114_MC_RESET(VDE,      0x200, 0x204, 16),
+       TEGRA114_MC_RESET(VI,       0x200, 0x204, 17),
+};
+
 const struct tegra_mc_soc tegra114_mc_soc = {
        .clients = tegra114_mc_clients,
        .num_clients = ARRAY_SIZE(tegra114_mc_clients),
@@ -945,4 +973,9 @@ const struct tegra_mc_soc tegra114_mc_soc = {
        .atom_size = 32,
        .client_id_mask = 0x7f,
        .smmu = &tegra114_smmu_soc,
+       .intmask = MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION |
+                  MC_INT_DECERR_EMEM,
+       .reset_ops = &terga_mc_reset_ops_common,
+       .resets = tegra114_mc_resets,
+       .num_resets = ARRAY_SIZE(tegra114_mc_resets),
 };
index 8b6360eabb8a5aef19d9457c1a7e259edcfbda88..b561a1fe7f46a4e583d69be92f964bf001556095 100644 (file)
@@ -1012,6 +1012,42 @@ static const struct tegra_smmu_group_soc tegra124_groups[] = {
        },
 };
 
+#define TEGRA124_MC_RESET(_name, _control, _status, _bit)      \
+       {                                                       \
+               .name = #_name,                                 \
+               .id = TEGRA124_MC_RESET_##_name,                \
+               .control = _control,                            \
+               .status = _status,                              \
+               .bit = _bit,                                    \
+       }
+
+static const struct tegra_mc_reset tegra124_mc_resets[] = {
+       TEGRA124_MC_RESET(AFI,       0x200, 0x204,  0),
+       TEGRA124_MC_RESET(AVPC,      0x200, 0x204,  1),
+       TEGRA124_MC_RESET(DC,        0x200, 0x204,  2),
+       TEGRA124_MC_RESET(DCB,       0x200, 0x204,  3),
+       TEGRA124_MC_RESET(HC,        0x200, 0x204,  6),
+       TEGRA124_MC_RESET(HDA,       0x200, 0x204,  7),
+       TEGRA124_MC_RESET(ISP2,      0x200, 0x204,  8),
+       TEGRA124_MC_RESET(MPCORE,    0x200, 0x204,  9),
+       TEGRA124_MC_RESET(MPCORELP,  0x200, 0x204, 10),
+       TEGRA124_MC_RESET(MSENC,     0x200, 0x204, 11),
+       TEGRA124_MC_RESET(PPCS,      0x200, 0x204, 14),
+       TEGRA124_MC_RESET(SATA,      0x200, 0x204, 15),
+       TEGRA124_MC_RESET(VDE,       0x200, 0x204, 16),
+       TEGRA124_MC_RESET(VI,        0x200, 0x204, 17),
+       TEGRA124_MC_RESET(VIC,       0x200, 0x204, 18),
+       TEGRA124_MC_RESET(XUSB_HOST, 0x200, 0x204, 19),
+       TEGRA124_MC_RESET(XUSB_DEV,  0x200, 0x204, 20),
+       TEGRA124_MC_RESET(TSEC,      0x200, 0x204, 21),
+       TEGRA124_MC_RESET(SDMMC1,    0x200, 0x204, 22),
+       TEGRA124_MC_RESET(SDMMC2,    0x200, 0x204, 23),
+       TEGRA124_MC_RESET(SDMMC3,    0x200, 0x204, 25),
+       TEGRA124_MC_RESET(SDMMC4,    0x970, 0x974,  0),
+       TEGRA124_MC_RESET(ISP2B,     0x970, 0x974,  1),
+       TEGRA124_MC_RESET(GPU,       0x970, 0x974,  2),
+};
+
 #ifdef CONFIG_ARCH_TEGRA_124_SOC
 static const struct tegra_smmu_soc tegra124_smmu_soc = {
        .clients = tegra124_mc_clients,
@@ -1035,6 +1071,12 @@ const struct tegra_mc_soc tegra124_mc_soc = {
        .smmu = &tegra124_smmu_soc,
        .emem_regs = tegra124_mc_emem_regs,
        .num_emem_regs = ARRAY_SIZE(tegra124_mc_emem_regs),
+       .intmask = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
+                  MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
+                  MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM,
+       .reset_ops = &terga_mc_reset_ops_common,
+       .resets = tegra124_mc_resets,
+       .num_resets = ARRAY_SIZE(tegra124_mc_resets),
 };
 #endif /* CONFIG_ARCH_TEGRA_124_SOC */
 
@@ -1059,5 +1101,11 @@ const struct tegra_mc_soc tegra132_mc_soc = {
        .atom_size = 32,
        .client_id_mask = 0x7f,
        .smmu = &tegra132_smmu_soc,
+       .intmask = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
+                  MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
+                  MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM,
+       .reset_ops = &terga_mc_reset_ops_common,
+       .resets = tegra124_mc_resets,
+       .num_resets = ARRAY_SIZE(tegra124_mc_resets),
 };
 #endif /* CONFIG_ARCH_TEGRA_132_SOC */
diff --git a/drivers/memory/tegra/tegra20.c b/drivers/memory/tegra/tegra20.c
new file mode 100644 (file)
index 0000000..7119e53
--- /dev/null
@@ -0,0 +1,296 @@
+/*
+ * Copyright (C) 2012 NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <dt-bindings/memory/tegra20-mc.h>
+
+#include "mc.h"
+
+static const struct tegra_mc_client tegra20_mc_clients[] = {
+       {
+               .id = 0x00,
+               .name = "display0a",
+       }, {
+               .id = 0x01,
+               .name = "display0ab",
+       }, {
+               .id = 0x02,
+               .name = "display0b",
+       }, {
+               .id = 0x03,
+               .name = "display0bb",
+       }, {
+               .id = 0x04,
+               .name = "display0c",
+       }, {
+               .id = 0x05,
+               .name = "display0cb",
+       }, {
+               .id = 0x06,
+               .name = "display1b",
+       }, {
+               .id = 0x07,
+               .name = "display1bb",
+       }, {
+               .id = 0x08,
+               .name = "eppup",
+       }, {
+               .id = 0x09,
+               .name = "g2pr",
+       }, {
+               .id = 0x0a,
+               .name = "g2sr",
+       }, {
+               .id = 0x0b,
+               .name = "mpeunifbr",
+       }, {
+               .id = 0x0c,
+               .name = "viruv",
+       }, {
+               .id = 0x0d,
+               .name = "avpcarm7r",
+       }, {
+               .id = 0x0e,
+               .name = "displayhc",
+       }, {
+               .id = 0x0f,
+               .name = "displayhcb",
+       }, {
+               .id = 0x10,
+               .name = "fdcdrd",
+       }, {
+               .id = 0x11,
+               .name = "g2dr",
+       }, {
+               .id = 0x12,
+               .name = "host1xdmar",
+       }, {
+               .id = 0x13,
+               .name = "host1xr",
+       }, {
+               .id = 0x14,
+               .name = "idxsrd",
+       }, {
+               .id = 0x15,
+               .name = "mpcorer",
+       }, {
+               .id = 0x16,
+               .name = "mpe_ipred",
+       }, {
+               .id = 0x17,
+               .name = "mpeamemrd",
+       }, {
+               .id = 0x18,
+               .name = "mpecsrd",
+       }, {
+               .id = 0x19,
+               .name = "ppcsahbdmar",
+       }, {
+               .id = 0x1a,
+               .name = "ppcsahbslvr",
+       }, {
+               .id = 0x1b,
+               .name = "texsrd",
+       }, {
+               .id = 0x1c,
+               .name = "vdebsevr",
+       }, {
+               .id = 0x1d,
+               .name = "vdember",
+       }, {
+               .id = 0x1e,
+               .name = "vdemcer",
+       }, {
+               .id = 0x1f,
+               .name = "vdetper",
+       }, {
+               .id = 0x20,
+               .name = "eppu",
+       }, {
+               .id = 0x21,
+               .name = "eppv",
+       }, {
+               .id = 0x22,
+               .name = "eppy",
+       }, {
+               .id = 0x23,
+               .name = "mpeunifbw",
+       }, {
+               .id = 0x24,
+               .name = "viwsb",
+       }, {
+               .id = 0x25,
+               .name = "viwu",
+       }, {
+               .id = 0x26,
+               .name = "viwv",
+       }, {
+               .id = 0x27,
+               .name = "viwy",
+       }, {
+               .id = 0x28,
+               .name = "g2dw",
+       }, {
+               .id = 0x29,
+               .name = "avpcarm7w",
+       }, {
+               .id = 0x2a,
+               .name = "fdcdwr",
+       }, {
+               .id = 0x2b,
+               .name = "host1xw",
+       }, {
+               .id = 0x2c,
+               .name = "ispw",
+       }, {
+               .id = 0x2d,
+               .name = "mpcorew",
+       }, {
+               .id = 0x2e,
+               .name = "mpecswr",
+       }, {
+               .id = 0x2f,
+               .name = "ppcsahbdmaw",
+       }, {
+               .id = 0x30,
+               .name = "ppcsahbslvw",
+       }, {
+               .id = 0x31,
+               .name = "vdebsevw",
+       }, {
+               .id = 0x32,
+               .name = "vdembew",
+       }, {
+               .id = 0x33,
+               .name = "vdetpmw",
+       },
+};
+
+#define TEGRA20_MC_RESET(_name, _control, _status, _reset, _bit)       \
+       {                                                               \
+               .name = #_name,                                         \
+               .id = TEGRA20_MC_RESET_##_name,                         \
+               .control = _control,                                    \
+               .status = _status,                                      \
+               .reset = _reset,                                        \
+               .bit = _bit,                                            \
+       }
+
+static const struct tegra_mc_reset tegra20_mc_resets[] = {
+       TEGRA20_MC_RESET(AVPC,   0x100, 0x140, 0x104,  0),
+       TEGRA20_MC_RESET(DC,     0x100, 0x144, 0x104,  1),
+       TEGRA20_MC_RESET(DCB,    0x100, 0x148, 0x104,  2),
+       TEGRA20_MC_RESET(EPP,    0x100, 0x14c, 0x104,  3),
+       TEGRA20_MC_RESET(2D,     0x100, 0x150, 0x104,  4),
+       TEGRA20_MC_RESET(HC,     0x100, 0x154, 0x104,  5),
+       TEGRA20_MC_RESET(ISP,    0x100, 0x158, 0x104,  6),
+       TEGRA20_MC_RESET(MPCORE, 0x100, 0x15c, 0x104,  7),
+       TEGRA20_MC_RESET(MPEA,   0x100, 0x160, 0x104,  8),
+       TEGRA20_MC_RESET(MPEB,   0x100, 0x164, 0x104,  9),
+       TEGRA20_MC_RESET(MPEC,   0x100, 0x168, 0x104, 10),
+       TEGRA20_MC_RESET(3D,     0x100, 0x16c, 0x104, 11),
+       TEGRA20_MC_RESET(PPCS,   0x100, 0x170, 0x104, 12),
+       TEGRA20_MC_RESET(VDE,    0x100, 0x174, 0x104, 13),
+       TEGRA20_MC_RESET(VI,     0x100, 0x178, 0x104, 14),
+};
+
+static int terga20_mc_hotreset_assert(struct tegra_mc *mc,
+                                     const struct tegra_mc_reset *rst)
+{
+       unsigned long flags;
+       u32 value;
+
+       spin_lock_irqsave(&mc->lock, flags);
+
+       value = mc_readl(mc, rst->reset);
+       mc_writel(mc, value & ~BIT(rst->bit), rst->reset);
+
+       spin_unlock_irqrestore(&mc->lock, flags);
+
+       return 0;
+}
+
+static int terga20_mc_hotreset_deassert(struct tegra_mc *mc,
+                                       const struct tegra_mc_reset *rst)
+{
+       unsigned long flags;
+       u32 value;
+
+       spin_lock_irqsave(&mc->lock, flags);
+
+       value = mc_readl(mc, rst->reset);
+       mc_writel(mc, value | BIT(rst->bit), rst->reset);
+
+       spin_unlock_irqrestore(&mc->lock, flags);
+
+       return 0;
+}
+
+static int terga20_mc_block_dma(struct tegra_mc *mc,
+                               const struct tegra_mc_reset *rst)
+{
+       unsigned long flags;
+       u32 value;
+
+       spin_lock_irqsave(&mc->lock, flags);
+
+       value = mc_readl(mc, rst->control) & ~BIT(rst->bit);
+       mc_writel(mc, value, rst->control);
+
+       spin_unlock_irqrestore(&mc->lock, flags);
+
+       return 0;
+}
+
+static bool terga20_mc_dma_idling(struct tegra_mc *mc,
+                                 const struct tegra_mc_reset *rst)
+{
+       return mc_readl(mc, rst->status) == 0;
+}
+
+static int terga20_mc_reset_status(struct tegra_mc *mc,
+                                  const struct tegra_mc_reset *rst)
+{
+       return (mc_readl(mc, rst->reset) & BIT(rst->bit)) == 0;
+}
+
+static int terga20_mc_unblock_dma(struct tegra_mc *mc,
+                                 const struct tegra_mc_reset *rst)
+{
+       unsigned long flags;
+       u32 value;
+
+       spin_lock_irqsave(&mc->lock, flags);
+
+       value = mc_readl(mc, rst->control) | BIT(rst->bit);
+       mc_writel(mc, value, rst->control);
+
+       spin_unlock_irqrestore(&mc->lock, flags);
+
+       return 0;
+}
+
+const struct tegra_mc_reset_ops terga20_mc_reset_ops = {
+       .hotreset_assert = terga20_mc_hotreset_assert,
+       .hotreset_deassert = terga20_mc_hotreset_deassert,
+       .block_dma = terga20_mc_block_dma,
+       .dma_idling = terga20_mc_dma_idling,
+       .unblock_dma = terga20_mc_unblock_dma,
+       .reset_status = terga20_mc_reset_status,
+};
+
+const struct tegra_mc_soc tegra20_mc_soc = {
+       .clients = tegra20_mc_clients,
+       .num_clients = ARRAY_SIZE(tegra20_mc_clients),
+       .num_address_bits = 32,
+       .client_id_mask = 0x3f,
+       .intmask = MC_INT_SECURITY_VIOLATION | MC_INT_INVALID_GART_PAGE |
+                  MC_INT_DECERR_EMEM,
+       .reset_ops = &terga20_mc_reset_ops,
+       .resets = tegra20_mc_resets,
+       .num_resets = ARRAY_SIZE(tegra20_mc_resets),
+};
index d398bcd3fc5714dc32be85464e11e7cdec88e7a5..d00a771604072656b195c8510e31c96ce850d1bb 100644 (file)
@@ -6,11 +6,6 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/of.h>
-#include <linux/mm.h>
-
-#include <asm/cacheflush.h>
-
 #include <dt-bindings/memory/tegra210-mc.h>
 
 #include "mc.h"
@@ -1085,6 +1080,48 @@ static const struct tegra_smmu_soc tegra210_smmu_soc = {
        .num_asids = 128,
 };
 
+#define TEGRA210_MC_RESET(_name, _control, _status, _bit)      \
+       {                                                       \
+               .name = #_name,                                 \
+               .id = TEGRA210_MC_RESET_##_name,                \
+               .control = _control,                            \
+               .status = _status,                              \
+               .bit = _bit,                                    \
+       }
+
+static const struct tegra_mc_reset tegra210_mc_resets[] = {
+       TEGRA210_MC_RESET(AFI,       0x200, 0x204,  0),
+       TEGRA210_MC_RESET(AVPC,      0x200, 0x204,  1),
+       TEGRA210_MC_RESET(DC,        0x200, 0x204,  2),
+       TEGRA210_MC_RESET(DCB,       0x200, 0x204,  3),
+       TEGRA210_MC_RESET(HC,        0x200, 0x204,  6),
+       TEGRA210_MC_RESET(HDA,       0x200, 0x204,  7),
+       TEGRA210_MC_RESET(ISP2,      0x200, 0x204,  8),
+       TEGRA210_MC_RESET(MPCORE,    0x200, 0x204,  9),
+       TEGRA210_MC_RESET(NVENC,     0x200, 0x204, 11),
+       TEGRA210_MC_RESET(PPCS,      0x200, 0x204, 14),
+       TEGRA210_MC_RESET(SATA,      0x200, 0x204, 15),
+       TEGRA210_MC_RESET(VI,        0x200, 0x204, 17),
+       TEGRA210_MC_RESET(VIC,       0x200, 0x204, 18),
+       TEGRA210_MC_RESET(XUSB_HOST, 0x200, 0x204, 19),
+       TEGRA210_MC_RESET(XUSB_DEV,  0x200, 0x204, 20),
+       TEGRA210_MC_RESET(A9AVP,     0x200, 0x204, 21),
+       TEGRA210_MC_RESET(TSEC,      0x200, 0x204, 22),
+       TEGRA210_MC_RESET(SDMMC1,    0x200, 0x204, 29),
+       TEGRA210_MC_RESET(SDMMC2,    0x200, 0x204, 30),
+       TEGRA210_MC_RESET(SDMMC3,    0x200, 0x204, 31),
+       TEGRA210_MC_RESET(SDMMC4,    0x970, 0x974,  0),
+       TEGRA210_MC_RESET(ISP2B,     0x970, 0x974,  1),
+       TEGRA210_MC_RESET(GPU,       0x970, 0x974,  2),
+       TEGRA210_MC_RESET(NVDEC,     0x970, 0x974,  5),
+       TEGRA210_MC_RESET(APE,       0x970, 0x974,  6),
+       TEGRA210_MC_RESET(SE,        0x970, 0x974,  7),
+       TEGRA210_MC_RESET(NVJPG,     0x970, 0x974,  8),
+       TEGRA210_MC_RESET(AXIAP,     0x970, 0x974, 11),
+       TEGRA210_MC_RESET(ETR,       0x970, 0x974, 12),
+       TEGRA210_MC_RESET(TSECB,     0x970, 0x974, 13),
+};
+
 const struct tegra_mc_soc tegra210_mc_soc = {
        .clients = tegra210_mc_clients,
        .num_clients = ARRAY_SIZE(tegra210_mc_clients),
@@ -1092,4 +1129,10 @@ const struct tegra_mc_soc tegra210_mc_soc = {
        .atom_size = 64,
        .client_id_mask = 0xff,
        .smmu = &tegra210_smmu_soc,
+       .intmask = MC_INT_DECERR_MTS | MC_INT_SECERR_SEC | MC_INT_DECERR_VPR |
+                  MC_INT_INVALID_APB_ASID_UPDATE | MC_INT_INVALID_SMMU_PAGE |
+                  MC_INT_SECURITY_VIOLATION | MC_INT_DECERR_EMEM,
+       .reset_ops = &terga_mc_reset_ops_common,
+       .resets = tegra210_mc_resets,
+       .num_resets = ARRAY_SIZE(tegra210_mc_resets),
 };
index d756c837f23e50cec078a274525d66bb94980bb7..bee5314ed404d5d0af56fb1a542766106ad50b7b 100644 (file)
@@ -960,6 +960,36 @@ static const struct tegra_smmu_soc tegra30_smmu_soc = {
        .num_asids = 4,
 };
 
+#define TEGRA30_MC_RESET(_name, _control, _status, _bit)       \
+       {                                                       \
+               .name = #_name,                                 \
+               .id = TEGRA30_MC_RESET_##_name,                 \
+               .control = _control,                            \
+               .status = _status,                              \
+               .bit = _bit,                                    \
+       }
+
+static const struct tegra_mc_reset tegra30_mc_resets[] = {
+       TEGRA30_MC_RESET(AFI,      0x200, 0x204,  0),
+       TEGRA30_MC_RESET(AVPC,     0x200, 0x204,  1),
+       TEGRA30_MC_RESET(DC,       0x200, 0x204,  2),
+       TEGRA30_MC_RESET(DCB,      0x200, 0x204,  3),
+       TEGRA30_MC_RESET(EPP,      0x200, 0x204,  4),
+       TEGRA30_MC_RESET(2D,       0x200, 0x204,  5),
+       TEGRA30_MC_RESET(HC,       0x200, 0x204,  6),
+       TEGRA30_MC_RESET(HDA,      0x200, 0x204,  7),
+       TEGRA30_MC_RESET(ISP,      0x200, 0x204,  8),
+       TEGRA30_MC_RESET(MPCORE,   0x200, 0x204,  9),
+       TEGRA30_MC_RESET(MPCORELP, 0x200, 0x204, 10),
+       TEGRA30_MC_RESET(MPE,      0x200, 0x204, 11),
+       TEGRA30_MC_RESET(3D,       0x200, 0x204, 12),
+       TEGRA30_MC_RESET(3D2,      0x200, 0x204, 13),
+       TEGRA30_MC_RESET(PPCS,     0x200, 0x204, 14),
+       TEGRA30_MC_RESET(SATA,     0x200, 0x204, 15),
+       TEGRA30_MC_RESET(VDE,      0x200, 0x204, 16),
+       TEGRA30_MC_RESET(VI,       0x200, 0x204, 17),
+};
+
 const struct tegra_mc_soc tegra30_mc_soc = {
        .clients = tegra30_mc_clients,
        .num_clients = ARRAY_SIZE(tegra30_mc_clients),
@@ -967,4 +997,9 @@ const struct tegra_mc_soc tegra30_mc_soc = {
        .atom_size = 16,
        .client_id_mask = 0x7f,
        .smmu = &tegra30_smmu_soc,
+       .intmask = MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION |
+                  MC_INT_DECERR_EMEM,
+       .reset_ops = &terga_mc_reset_ops_common,
+       .resets = tegra30_mc_resets,
+       .num_resets = ARRAY_SIZE(tegra30_mc_resets),
 };
diff --git a/drivers/memory/tegra20-mc.c b/drivers/memory/tegra20-mc.c
deleted file mode 100644 (file)
index cc309a0..0000000
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Tegra20 Memory Controller
- *
- * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <linux/err.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/ratelimit.h>
-#include <linux/platform_device.h>
-#include <linux/interrupt.h>
-#include <linux/io.h>
-
-#define DRV_NAME "tegra20-mc"
-
-#define MC_INTSTATUS                   0x0
-#define MC_INTMASK                     0x4
-
-#define MC_INT_ERR_SHIFT               6
-#define MC_INT_ERR_MASK                        (0x1f << MC_INT_ERR_SHIFT)
-#define MC_INT_DECERR_EMEM             BIT(MC_INT_ERR_SHIFT)
-#define MC_INT_INVALID_GART_PAGE       BIT(MC_INT_ERR_SHIFT + 1)
-#define MC_INT_SECURITY_VIOLATION      BIT(MC_INT_ERR_SHIFT + 2)
-#define MC_INT_ARBITRATION_EMEM                BIT(MC_INT_ERR_SHIFT + 3)
-
-#define MC_GART_ERROR_REQ              0x30
-#define MC_DECERR_EMEM_OTHERS_STATUS   0x58
-#define MC_SECURITY_VIOLATION_STATUS   0x74
-
-#define SECURITY_VIOLATION_TYPE                BIT(30) /* 0=TRUSTZONE, 1=CARVEOUT */
-
-#define MC_CLIENT_ID_MASK              0x3f
-
-#define NUM_MC_REG_BANKS               2
-
-struct tegra20_mc {
-       void __iomem *regs[NUM_MC_REG_BANKS];
-       struct device *dev;
-};
-
-static inline u32 mc_readl(struct tegra20_mc *mc, u32 offs)
-{
-       u32 val = 0;
-
-       if (offs < 0x24)
-               val = readl(mc->regs[0] + offs);
-       else if (offs < 0x400)
-               val = readl(mc->regs[1] + offs - 0x3c);
-
-       return val;
-}
-
-static inline void mc_writel(struct tegra20_mc *mc, u32 val, u32 offs)
-{
-       if (offs < 0x24)
-               writel(val, mc->regs[0] + offs);
-       else if (offs < 0x400)
-               writel(val, mc->regs[1] + offs - 0x3c);
-}
-
-static const char * const tegra20_mc_client[] = {
-       "cbr_display0a",
-       "cbr_display0ab",
-       "cbr_display0b",
-       "cbr_display0bb",
-       "cbr_display0c",
-       "cbr_display0cb",
-       "cbr_display1b",
-       "cbr_display1bb",
-       "cbr_eppup",
-       "cbr_g2pr",
-       "cbr_g2sr",
-       "cbr_mpeunifbr",
-       "cbr_viruv",
-       "csr_avpcarm7r",
-       "csr_displayhc",
-       "csr_displayhcb",
-       "csr_fdcdrd",
-       "csr_g2dr",
-       "csr_host1xdmar",
-       "csr_host1xr",
-       "csr_idxsrd",
-       "csr_mpcorer",
-       "csr_mpe_ipred",
-       "csr_mpeamemrd",
-       "csr_mpecsrd",
-       "csr_ppcsahbdmar",
-       "csr_ppcsahbslvr",
-       "csr_texsrd",
-       "csr_vdebsevr",
-       "csr_vdember",
-       "csr_vdemcer",
-       "csr_vdetper",
-       "cbw_eppu",
-       "cbw_eppv",
-       "cbw_eppy",
-       "cbw_mpeunifbw",
-       "cbw_viwsb",
-       "cbw_viwu",
-       "cbw_viwv",
-       "cbw_viwy",
-       "ccw_g2dw",
-       "csw_avpcarm7w",
-       "csw_fdcdwr",
-       "csw_host1xw",
-       "csw_ispw",
-       "csw_mpcorew",
-       "csw_mpecswr",
-       "csw_ppcsahbdmaw",
-       "csw_ppcsahbslvw",
-       "csw_vdebsevw",
-       "csw_vdembew",
-       "csw_vdetpmw",
-};
-
-static void tegra20_mc_decode(struct tegra20_mc *mc, int n)
-{
-       u32 addr, req;
-       const char *client = "Unknown";
-       int idx, cid;
-       const struct reg_info {
-               u32 offset;
-               u32 write_bit;  /* 0=READ, 1=WRITE */
-               int cid_shift;
-               char *message;
-       } reg[] = {
-               {
-                       .offset = MC_DECERR_EMEM_OTHERS_STATUS,
-                       .write_bit = 31,
-                       .message = "MC_DECERR",
-               },
-               {
-                       .offset = MC_GART_ERROR_REQ,
-                       .cid_shift = 1,
-                       .message = "MC_GART_ERR",
-
-               },
-               {
-                       .offset = MC_SECURITY_VIOLATION_STATUS,
-                       .write_bit = 31,
-                       .message = "MC_SECURITY_ERR",
-               },
-       };
-
-       idx = n - MC_INT_ERR_SHIFT;
-       if ((idx < 0) || (idx >= ARRAY_SIZE(reg))) {
-               dev_err_ratelimited(mc->dev, "Unknown interrupt status %08lx\n",
-                                   BIT(n));
-               return;
-       }
-
-       req = mc_readl(mc, reg[idx].offset);
-       cid = (req >> reg[idx].cid_shift) & MC_CLIENT_ID_MASK;
-       if (cid < ARRAY_SIZE(tegra20_mc_client))
-               client = tegra20_mc_client[cid];
-
-       addr = mc_readl(mc, reg[idx].offset + sizeof(u32));
-
-       dev_err_ratelimited(mc->dev, "%s (0x%08x): 0x%08x %s (%s %s)\n",
-                          reg[idx].message, req, addr, client,
-                          (req & BIT(reg[idx].write_bit)) ? "write" : "read",
-                          (reg[idx].offset == MC_SECURITY_VIOLATION_STATUS) ?
-                          ((req & SECURITY_VIOLATION_TYPE) ?
-                           "carveout" : "trustzone") : "");
-}
-
-static const struct of_device_id tegra20_mc_of_match[] = {
-       { .compatible = "nvidia,tegra20-mc", },
-       {},
-};
-
-static irqreturn_t tegra20_mc_isr(int irq, void *data)
-{
-       u32 stat, mask, bit;
-       struct tegra20_mc *mc = data;
-
-       stat = mc_readl(mc, MC_INTSTATUS);
-       mask = mc_readl(mc, MC_INTMASK);
-       mask &= stat;
-       if (!mask)
-               return IRQ_NONE;
-       while ((bit = ffs(mask)) != 0) {
-               tegra20_mc_decode(mc, bit - 1);
-               mask &= ~BIT(bit - 1);
-       }
-
-       mc_writel(mc, stat, MC_INTSTATUS);
-       return IRQ_HANDLED;
-}
-
-static int tegra20_mc_probe(struct platform_device *pdev)
-{
-       struct resource *irq;
-       struct tegra20_mc *mc;
-       int i, err;
-       u32 intmask;
-
-       mc = devm_kzalloc(&pdev->dev, sizeof(*mc), GFP_KERNEL);
-       if (!mc)
-               return -ENOMEM;
-       mc->dev = &pdev->dev;
-
-       for (i = 0; i < ARRAY_SIZE(mc->regs); i++) {
-               struct resource *res;
-
-               res = platform_get_resource(pdev, IORESOURCE_MEM, i);
-               mc->regs[i] = devm_ioremap_resource(&pdev->dev, res);
-               if (IS_ERR(mc->regs[i]))
-                       return PTR_ERR(mc->regs[i]);
-       }
-
-       irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-       if (!irq)
-               return -ENODEV;
-       err = devm_request_irq(&pdev->dev, irq->start, tegra20_mc_isr,
-                              IRQF_SHARED, dev_name(&pdev->dev), mc);
-       if (err)
-               return -ENODEV;
-
-       platform_set_drvdata(pdev, mc);
-
-       intmask = MC_INT_INVALID_GART_PAGE |
-               MC_INT_DECERR_EMEM | MC_INT_SECURITY_VIOLATION;
-       mc_writel(mc, intmask, MC_INTMASK);
-       return 0;
-}
-
-static struct platform_driver tegra20_mc_driver = {
-       .probe = tegra20_mc_probe,
-       .driver = {
-               .name = DRV_NAME,
-               .of_match_table = tegra20_mc_of_match,
-       },
-};
-module_platform_driver(tegra20_mc_driver);
-
-MODULE_AUTHOR("Hiroshi DOYU <hdoyu@nvidia.com>");
-MODULE_DESCRIPTION("Tegra20 MC driver");
-MODULE_LICENSE("GPL v2");
-MODULE_ALIAS("platform:" DRV_NAME);
index 2744b1b91b57c09ce1278d6e3cef158e09a99ca0..31112f622b884f2577d46caec86b2b63370e81de 100644 (file)
@@ -339,9 +339,6 @@ static int aemif_probe(struct platform_device *pdev)
        struct aemif_platform_data *pdata;
        struct of_dev_auxdata *dev_lookup;
 
-       if (np == NULL)
-               return 0;
-
        aemif = devm_kzalloc(dev, sizeof(*aemif), GFP_KERNEL);
        if (!aemif)
                return -ENOMEM;
@@ -363,8 +360,10 @@ static int aemif_probe(struct platform_device *pdev)
 
        aemif->clk_rate = clk_get_rate(aemif->clk) / MSEC_PER_SEC;
 
-       if (of_device_is_compatible(np, "ti,da850-aemif"))
+       if (np && of_device_is_compatible(np, "ti,da850-aemif"))
                aemif->cs_offset = 2;
+       else if (pdata)
+               aemif->cs_offset = pdata->cs_offset;
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        aemif->base = devm_ioremap_resource(dev, res);
@@ -373,15 +372,23 @@ static int aemif_probe(struct platform_device *pdev)
                goto error;
        }
 
-       /*
-        * For every controller device node, there is a cs device node that
-        * describe the bus configuration parameters. This functions iterate
-        * over these nodes and update the cs data array.
-        */
-       for_each_available_child_of_node(np, child_np) {
-               ret = of_aemif_parse_abus_config(pdev, child_np);
-               if (ret < 0)
-                       goto error;
+       if (np) {
+               /*
+                * For every controller device node, there is a cs device node
+                * that describe the bus configuration parameters. This
+                * functions iterate over these nodes and update the cs data
+                * array.
+                */
+               for_each_available_child_of_node(np, child_np) {
+                       ret = of_aemif_parse_abus_config(pdev, child_np);
+                       if (ret < 0)
+                               goto error;
+               }
+       } else if (pdata && pdata->num_abus_data > 0) {
+               for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) {
+                       aemif->cs_data[i].cs = pdata->abus_data[i].cs;
+                       aemif_get_hw_params(pdev, i);
+               }
        }
 
        for (i = 0; i < aemif->num_cs; i++) {
@@ -394,14 +401,25 @@ static int aemif_probe(struct platform_device *pdev)
        }
 
        /*
-        * Create a child devices explicitly from here to
-        * guarantee that the child will be probed after the AEMIF timing
-        * parameters are set.
+        * Create a child devices explicitly from here to guarantee that the
+        * child will be probed after the AEMIF timing parameters are set.
         */
-       for_each_available_child_of_node(np, child_np) {
-               ret = of_platform_populate(child_np, NULL, dev_lookup, dev);
-               if (ret < 0)
-                       goto error;
+       if (np) {
+               for_each_available_child_of_node(np, child_np) {
+                       ret = of_platform_populate(child_np, NULL,
+                                                  dev_lookup, dev);
+                       if (ret < 0)
+                               goto error;
+               }
+       } else {
+               for (i = 0; i < pdata->num_sub_devices; i++) {
+                       pdata->sub_devices[i].dev.parent = dev;
+                       ret = platform_device_register(&pdata->sub_devices[i]);
+                       if (ret) {
+                               dev_warn(dev, "Error register sub device %s\n",
+                                        pdata->sub_devices[i].name);
+                       }
+               }
        }
 
        return 0;
@@ -422,7 +440,7 @@ static struct platform_driver aemif_driver = {
        .probe = aemif_probe,
        .remove = aemif_remove,
        .driver = {
-               .name = KBUILD_MODNAME,
+               .name = "ti-aemif",
                .of_match_table = of_match_ptr(aemif_of_match),
        },
 };
index a15181fa45f7a7816e29ae961668454564f6a8bd..716fc8ed31d324dc4daa8ad83d730217ae5457f0 100644 (file)
@@ -1201,7 +1201,8 @@ static int msb_read_boot_blocks(struct msb_data *msb)
        dbg_verbose("Start of a scan for the boot blocks");
 
        if (!msb->boot_page) {
-               page = kmalloc(sizeof(struct ms_boot_page)*2, GFP_KERNEL);
+               page = kmalloc_array(2, sizeof(struct ms_boot_page),
+                                    GFP_KERNEL);
                if (!page)
                        return -ENOMEM;
 
@@ -1341,7 +1342,8 @@ static int msb_ftl_initialize(struct msb_data *msb)
        msb->used_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL);
        msb->erased_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL);
        msb->lba_to_pba_table =
-               kmalloc(msb->logical_block_count * sizeof(u16), GFP_KERNEL);
+               kmalloc_array(msb->logical_block_count, sizeof(u16),
+                             GFP_KERNEL);
 
        if (!msb->used_blocks_bitmap || !msb->lba_to_pba_table ||
                                                !msb->erased_blocks_bitmap) {
index 4cbed4d06aa7d9d30726d324cef1dcf532bf1a17..ebc00d47abf5243dee30ec4266e0726836b88883 100644 (file)
@@ -394,7 +394,8 @@ mpt_lan_open(struct net_device *dev)
                                "a moment.\n");
        }
 
-       priv->mpt_txfidx = kmalloc(priv->tx_max_out * sizeof(int), GFP_KERNEL);
+       priv->mpt_txfidx = kmalloc_array(priv->tx_max_out, sizeof(int),
+                                        GFP_KERNEL);
        if (priv->mpt_txfidx == NULL)
                goto out;
        priv->mpt_txfidx_tail = -1;
@@ -408,8 +409,8 @@ mpt_lan_open(struct net_device *dev)
 
        dlprintk((KERN_INFO MYNAM "@lo: Finished initializing SendCtl\n"));
 
-       priv->mpt_rxfidx = kmalloc(priv->max_buckets_out * sizeof(int),
-                                  GFP_KERNEL);
+       priv->mpt_rxfidx = kmalloc_array(priv->max_buckets_out, sizeof(int),
+                                        GFP_KERNEL);
        if (priv->mpt_rxfidx == NULL)
                goto out_SendCtl;
        priv->mpt_rxfidx_tail = -1;
index d9d2cf0d32efc19b1b75f287160630a73ea08ecf..e9fd20dba18d88dc6939c5021c4ed3fb5f020710 100644 (file)
@@ -13,7 +13,6 @@ obj-$(CONFIG_MFD_ASIC3)               += asic3.o tmio_core.o
 obj-$(CONFIG_MFD_BCM590XX)     += bcm590xx.o
 obj-$(CONFIG_MFD_BD9571MWV)    += bd9571mwv.o
 cros_ec_core-objs              := cros_ec.o
-cros_ec_core-$(CONFIG_ACPI)    += cros_ec_acpi_gpe.o
 obj-$(CONFIG_MFD_CROS_EC)      += cros_ec_core.o
 obj-$(CONFIG_MFD_CROS_EC_I2C)  += cros_ec_i2c.o
 obj-$(CONFIG_MFD_CROS_EC_SPI)  += cros_ec_spi.o
index 8ba41073dd89f1cdb210bd015c86979fd5c3a083..8d652b2f9d14f084e22b0db984236f8407f27254 100644 (file)
@@ -2519,11 +2519,10 @@ static ssize_t ab8500_subscribe_write(struct file *file,
        if (!dev_attr[irq_index])
                return -ENOMEM;
 
-       event_name[irq_index] = kmalloc(count, GFP_KERNEL);
+       event_name[irq_index] = kasprintf(GFP_KERNEL, "%lu", user_val);
        if (!event_name[irq_index])
                return -ENOMEM;
 
-       sprintf(event_name[irq_index], "%lu", user_val);
        dev_attr[irq_index]->show = show_irq;
        dev_attr[irq_index]->store = NULL;
        dev_attr[irq_index]->attr.name = event_name[irq_index];
@@ -2660,18 +2659,18 @@ static int ab8500_debug_probe(struct platform_device *plf)
        ab8500 = dev_get_drvdata(plf->dev.parent);
        num_irqs = ab8500->mask_size;
 
-       irq_count = devm_kzalloc(&plf->dev,
-                                sizeof(*irq_count)*num_irqs, GFP_KERNEL);
+       irq_count = devm_kcalloc(&plf->dev,
+                                num_irqs, sizeof(*irq_count), GFP_KERNEL);
        if (!irq_count)
                return -ENOMEM;
 
-       dev_attr = devm_kzalloc(&plf->dev,
-                               sizeof(*dev_attr)*num_irqs, GFP_KERNEL);
+       dev_attr = devm_kcalloc(&plf->dev,
+                               num_irqs, sizeof(*dev_attr), GFP_KERNEL);
        if (!dev_attr)
                return -ENOMEM;
 
-       event_name = devm_kzalloc(&plf->dev,
-                                 sizeof(*event_name)*num_irqs, GFP_KERNEL);
+       event_name = devm_kcalloc(&plf->dev,
+                                 num_irqs, sizeof(*event_name), GFP_KERNEL);
        if (!event_name)
                return -ENOMEM;
 
index 0d3846a4767cba7479f68d7ab4badded7bb3019b..f282d39a5917a9bd1a4777f0e247b2e23024eae1 100644 (file)
@@ -37,15 +37,12 @@ int abx500_register_ops(struct device *dev, struct abx500_ops *ops)
 {
        struct abx500_device_entry *dev_entry;
 
-       dev_entry = devm_kzalloc(dev,
-                                sizeof(struct abx500_device_entry),
-                                GFP_KERNEL);
-       if (!dev_entry) {
-               dev_err(dev, "register_ops kzalloc failed");
+       dev_entry = devm_kzalloc(dev, sizeof(*dev_entry), GFP_KERNEL);
+       if (!dev_entry)
                return -ENOMEM;
-       }
+
        dev_entry->dev = dev;
-       memcpy(&dev_entry->ops, ops, sizeof(struct abx500_ops));
+       memcpy(&dev_entry->ops, ops, sizeof(*ops));
 
        list_add_tail(&dev_entry->list, &abx500_list);
        return 0;
@@ -68,7 +65,7 @@ int abx500_set_register_interruptible(struct device *dev, u8 bank, u8 reg,
        struct abx500_ops *ops;
 
        lookup_ops(dev->parent, &ops);
-       if ((ops != NULL) && (ops->set_register != NULL))
+       if (ops && ops->set_register)
                return ops->set_register(dev, bank, reg, value);
        else
                return -ENOTSUPP;
@@ -81,7 +78,7 @@ int abx500_get_register_interruptible(struct device *dev, u8 bank, u8 reg,
        struct abx500_ops *ops;
 
        lookup_ops(dev->parent, &ops);
-       if ((ops != NULL) && (ops->get_register != NULL))
+       if (ops && ops->get_register)
                return ops->get_register(dev, bank, reg, value);
        else
                return -ENOTSUPP;
@@ -94,7 +91,7 @@ int abx500_get_register_page_interruptible(struct device *dev, u8 bank,
        struct abx500_ops *ops;
 
        lookup_ops(dev->parent, &ops);
-       if ((ops != NULL) && (ops->get_register_page != NULL))
+       if (ops && ops->get_register_page)
                return ops->get_register_page(dev, bank,
                        first_reg, regvals, numregs);
        else
@@ -108,7 +105,7 @@ int abx500_mask_and_set_register_interruptible(struct device *dev, u8 bank,
        struct abx500_ops *ops;
 
        lookup_ops(dev->parent, &ops);
-       if ((ops != NULL) && (ops->mask_and_set_register != NULL))
+       if (ops && ops->mask_and_set_register)
                return ops->mask_and_set_register(dev, bank,
                        reg, bitmask, bitvalues);
        else
@@ -121,7 +118,7 @@ int abx500_get_chip_id(struct device *dev)
        struct abx500_ops *ops;
 
        lookup_ops(dev->parent, &ops);
-       if ((ops != NULL) && (ops->get_chip_id != NULL))
+       if (ops && ops->get_chip_id)
                return ops->get_chip_id(dev);
        else
                return -ENOTSUPP;
@@ -133,7 +130,7 @@ int abx500_event_registers_startup_state_get(struct device *dev, u8 *event)
        struct abx500_ops *ops;
 
        lookup_ops(dev->parent, &ops);
-       if ((ops != NULL) && (ops->event_registers_startup_state_get != NULL))
+       if (ops && ops->event_registers_startup_state_get)
                return ops->event_registers_startup_state_get(dev, event);
        else
                return -ENOTSUPP;
@@ -145,7 +142,7 @@ int abx500_startup_irq_enabled(struct device *dev, unsigned int irq)
        struct abx500_ops *ops;
 
        lookup_ops(dev->parent, &ops);
-       if ((ops != NULL) && (ops->startup_irq_enabled != NULL))
+       if (ops && ops->startup_irq_enabled)
                return ops->startup_irq_enabled(dev, irq);
        else
                return -ENOTSUPP;
index 77875250abe590bb73ba2b52ba3c38c444552579..83f1c5a516d99a974bd399c6fad01a3bcb7a59df 100644 (file)
 #include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/err.h>
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/interrupt.h>
 #include <linux/mfd/core.h>
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
-#include <linux/of_gpio.h>
 #include <linux/pm_runtime.h>
 #include <linux/regmap.h>
 #include <linux/regulator/consumer.h>
@@ -279,7 +278,7 @@ static int arizona_wait_for_boot(struct arizona *arizona)
 static inline void arizona_enable_reset(struct arizona *arizona)
 {
        if (arizona->pdata.reset)
-               gpio_set_value_cansleep(arizona->pdata.reset, 0);
+               gpiod_set_raw_value_cansleep(arizona->pdata.reset, 0);
 }
 
 static void arizona_disable_reset(struct arizona *arizona)
@@ -295,7 +294,7 @@ static void arizona_disable_reset(struct arizona *arizona)
                        break;
                }
 
-               gpio_set_value_cansleep(arizona->pdata.reset, 1);
+               gpiod_set_raw_value_cansleep(arizona->pdata.reset, 1);
                usleep_range(1000, 5000);
        }
 }
@@ -799,14 +798,27 @@ static int arizona_of_get_core_pdata(struct arizona *arizona)
        struct arizona_pdata *pdata = &arizona->pdata;
        int ret, i;
 
-       pdata->reset = of_get_named_gpio(arizona->dev->of_node, "wlf,reset", 0);
-       if (pdata->reset == -EPROBE_DEFER) {
-               return pdata->reset;
-       } else if (pdata->reset < 0) {
-               dev_err(arizona->dev, "Reset GPIO missing/malformed: %d\n",
-                       pdata->reset);
+       /* Handle old non-standard DT binding */
+       pdata->reset = devm_gpiod_get_from_of_node(arizona->dev,
+                                                  arizona->dev->of_node,
+                                                  "wlf,reset", 0,
+                                                  GPIOD_OUT_LOW,
+                                                  "arizona /RESET");
+       if (IS_ERR(pdata->reset)) {
+               ret = PTR_ERR(pdata->reset);
 
-               pdata->reset = 0;
+               /*
+                * Reset missing will be caught when other binding is read
+                * but all other errors imply this binding is in use but has
+                * encountered a problem so should be handled.
+                */
+               if (ret == -EPROBE_DEFER)
+                       return ret;
+               else if (ret != -ENOENT && ret != -ENOSYS)
+                       dev_err(arizona->dev, "Reset GPIO malformed: %d\n",
+                               ret);
+
+               pdata->reset = NULL;
        }
 
        ret = of_property_read_u32_array(arizona->dev->of_node,
@@ -1050,14 +1062,19 @@ int arizona_dev_init(struct arizona *arizona)
                goto err_early;
        }
 
-       if (arizona->pdata.reset) {
+       if (!arizona->pdata.reset) {
                /* Start out with /RESET low to put the chip into reset */
-               ret = devm_gpio_request_one(arizona->dev, arizona->pdata.reset,
-                                           GPIOF_DIR_OUT | GPIOF_INIT_LOW,
-                                           "arizona /RESET");
-               if (ret != 0) {
-                       dev_err(dev, "Failed to request /RESET: %d\n", ret);
-                       goto err_dcvdd;
+               arizona->pdata.reset = devm_gpiod_get(arizona->dev, "reset",
+                                                     GPIOD_OUT_LOW);
+               if (IS_ERR(arizona->pdata.reset)) {
+                       ret = PTR_ERR(arizona->pdata.reset);
+                       if (ret == -EPROBE_DEFER)
+                               goto err_dcvdd;
+
+                       dev_err(arizona->dev,
+                               "Reset GPIO missing/malformed: %d\n", ret);
+
+                       arizona->pdata.reset = NULL;
                }
        }
 
index cf2e25ab294095137a654a00c3e3501467bc9674..1531302a50ec3590ad5dbd204b5417339fbbe619 100644 (file)
@@ -31,6 +31,8 @@
 #include <linux/mfd/ds1wm.h>
 #include <linux/mfd/tmio.h>
 
+#include <linux/mmc/host.h>
+
 enum {
        ASIC3_CLOCK_SPI,
        ASIC3_CLOCK_OWM,
@@ -719,6 +721,7 @@ static void asic3_mmc_clk_div(struct platform_device *pdev, int state)
 
 static struct tmio_mmc_data asic3_mmc_data = {
        .hclk           = 24576000,
+       .ocr_mask       = MMC_VDD_32_33 | MMC_VDD_33_34,
        .set_pwr        = asic3_mmc_pwr,
        .set_clk_div    = asic3_mmc_clk_div,
 };
index 7d77948567d79dc8772850fc10010bd5bc22e716..0adbd2e796fe4ee6867d2fdfa2a4aed2798502cf 100644 (file)
@@ -12,6 +12,7 @@
  */
 
 #include <linux/mfd/syscon/atmel-smc.h>
+#include <linux/string.h>
 
 /**
  * atmel_smc_cs_conf_init - initialize a SMC CS conf
index e94c72c2faa226ea6efed57c1dacfb331895973f..9a2ef3d9b8f85596bcf3df198712c70180e457ca 100644 (file)
@@ -169,131 +169,61 @@ static const struct regmap_access_table axp806_volatile_table = {
        .n_yes_ranges   = ARRAY_SIZE(axp806_volatile_ranges),
 };
 
-static struct resource axp152_pek_resources[] = {
+static const struct resource axp152_pek_resources[] = {
        DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
        DEFINE_RES_IRQ_NAMED(AXP152_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
-static struct resource axp20x_ac_power_supply_resources[] = {
+static const struct resource axp20x_ac_power_supply_resources[] = {
        DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_PLUGIN, "ACIN_PLUGIN"),
        DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_REMOVAL, "ACIN_REMOVAL"),
        DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_ACIN_OVER_V, "ACIN_OVER_V"),
 };
 
-static struct resource axp20x_pek_resources[] = {
-       {
-               .name   = "PEK_DBR",
-               .start  = AXP20X_IRQ_PEK_RIS_EDGE,
-               .end    = AXP20X_IRQ_PEK_RIS_EDGE,
-               .flags  = IORESOURCE_IRQ,
-       }, {
-               .name   = "PEK_DBF",
-               .start  = AXP20X_IRQ_PEK_FAL_EDGE,
-               .end    = AXP20X_IRQ_PEK_FAL_EDGE,
-               .flags  = IORESOURCE_IRQ,
-       },
+static const struct resource axp20x_pek_resources[] = {
+       DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+       DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
-static struct resource axp20x_usb_power_supply_resources[] = {
+static const struct resource axp20x_usb_power_supply_resources[] = {
        DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
        DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
        DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_VALID, "VBUS_VALID"),
        DEFINE_RES_IRQ_NAMED(AXP20X_IRQ_VBUS_NOT_VALID, "VBUS_NOT_VALID"),
 };
 
-static struct resource axp22x_usb_power_supply_resources[] = {
+static const struct resource axp22x_usb_power_supply_resources[] = {
        DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
        DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
 };
 
-static struct resource axp22x_pek_resources[] = {
-       {
-               .name   = "PEK_DBR",
-               .start  = AXP22X_IRQ_PEK_RIS_EDGE,
-               .end    = AXP22X_IRQ_PEK_RIS_EDGE,
-               .flags  = IORESOURCE_IRQ,
-       }, {
-               .name   = "PEK_DBF",
-               .start  = AXP22X_IRQ_PEK_FAL_EDGE,
-               .end    = AXP22X_IRQ_PEK_FAL_EDGE,
-               .flags  = IORESOURCE_IRQ,
-       },
+static const struct resource axp22x_pek_resources[] = {
+       DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+       DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
-static struct resource axp288_power_button_resources[] = {
-       {
-               .name   = "PEK_DBR",
-               .start  = AXP288_IRQ_POKP,
-               .end    = AXP288_IRQ_POKP,
-               .flags  = IORESOURCE_IRQ,
-       },
-       {
-               .name   = "PEK_DBF",
-               .start  = AXP288_IRQ_POKN,
-               .end    = AXP288_IRQ_POKN,
-               .flags  = IORESOURCE_IRQ,
-       },
+static const struct resource axp288_power_button_resources[] = {
+       DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKP, "PEK_DBR"),
+       DEFINE_RES_IRQ_NAMED(AXP288_IRQ_POKN, "PEK_DBF"),
 };
 
-static struct resource axp288_fuel_gauge_resources[] = {
-       {
-               .start = AXP288_IRQ_QWBTU,
-               .end   = AXP288_IRQ_QWBTU,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_WBTU,
-               .end   = AXP288_IRQ_WBTU,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_QWBTO,
-               .end   = AXP288_IRQ_QWBTO,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_WBTO,
-               .end   = AXP288_IRQ_WBTO,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_WL2,
-               .end   = AXP288_IRQ_WL2,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_WL1,
-               .end   = AXP288_IRQ_WL1,
-               .flags = IORESOURCE_IRQ,
-       },
+static const struct resource axp288_fuel_gauge_resources[] = {
+       DEFINE_RES_IRQ(AXP288_IRQ_QWBTU),
+       DEFINE_RES_IRQ(AXP288_IRQ_WBTU),
+       DEFINE_RES_IRQ(AXP288_IRQ_QWBTO),
+       DEFINE_RES_IRQ(AXP288_IRQ_WBTO),
+       DEFINE_RES_IRQ(AXP288_IRQ_WL2),
+       DEFINE_RES_IRQ(AXP288_IRQ_WL1),
 };
 
-static struct resource axp803_pek_resources[] = {
-       {
-               .name   = "PEK_DBR",
-               .start  = AXP803_IRQ_PEK_RIS_EDGE,
-               .end    = AXP803_IRQ_PEK_RIS_EDGE,
-               .flags  = IORESOURCE_IRQ,
-       }, {
-               .name   = "PEK_DBF",
-               .start  = AXP803_IRQ_PEK_FAL_EDGE,
-               .end    = AXP803_IRQ_PEK_FAL_EDGE,
-               .flags  = IORESOURCE_IRQ,
-       },
+static const struct resource axp803_pek_resources[] = {
+       DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+       DEFINE_RES_IRQ_NAMED(AXP803_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
-static struct resource axp809_pek_resources[] = {
-       {
-               .name   = "PEK_DBR",
-               .start  = AXP809_IRQ_PEK_RIS_EDGE,
-               .end    = AXP809_IRQ_PEK_RIS_EDGE,
-               .flags  = IORESOURCE_IRQ,
-       }, {
-               .name   = "PEK_DBF",
-               .start  = AXP809_IRQ_PEK_FAL_EDGE,
-               .end    = AXP809_IRQ_PEK_FAL_EDGE,
-               .flags  = IORESOURCE_IRQ,
-       },
+static const struct resource axp809_pek_resources[] = {
+       DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_RIS_EDGE, "PEK_DBR"),
+       DEFINE_RES_IRQ_NAMED(AXP809_IRQ_PEK_FAL_EDGE, "PEK_DBF"),
 };
 
 static const struct regmap_config axp152_regmap_config = {
@@ -520,11 +450,11 @@ static const struct regmap_irq axp806_regmap_irqs[] = {
        INIT_REGMAP_IRQ(AXP806, DCDCC_V_LOW,            0, 5),
        INIT_REGMAP_IRQ(AXP806, DCDCD_V_LOW,            0, 6),
        INIT_REGMAP_IRQ(AXP806, DCDCE_V_LOW,            0, 7),
-       INIT_REGMAP_IRQ(AXP806, PWROK_LONG,             1, 0),
-       INIT_REGMAP_IRQ(AXP806, PWROK_SHORT,            1, 1),
+       INIT_REGMAP_IRQ(AXP806, POK_LONG,               1, 0),
+       INIT_REGMAP_IRQ(AXP806, POK_SHORT,              1, 1),
        INIT_REGMAP_IRQ(AXP806, WAKEUP,                 1, 4),
-       INIT_REGMAP_IRQ(AXP806, PWROK_FALL,             1, 5),
-       INIT_REGMAP_IRQ(AXP806, PWROK_RISE,             1, 6),
+       INIT_REGMAP_IRQ(AXP806, POK_FALL,               1, 5),
+       INIT_REGMAP_IRQ(AXP806, POK_RISE,               1, 6),
 };
 
 static const struct regmap_irq axp809_regmap_irqs[] = {
@@ -648,7 +578,7 @@ static const struct regmap_irq_chip axp809_regmap_irq_chip = {
        .num_regs               = 5,
 };
 
-static struct mfd_cell axp20x_cells[] = {
+static const struct mfd_cell axp20x_cells[] = {
        {
                .name           = "axp20x-gpio",
                .of_compatible  = "x-powers,axp209-gpio",
@@ -660,6 +590,7 @@ static struct mfd_cell axp20x_cells[] = {
                .name           = "axp20x-regulator",
        }, {
                .name           = "axp20x-adc",
+               .of_compatible  = "x-powers,axp209-adc",
        }, {
                .name           = "axp20x-battery-power-supply",
                .of_compatible  = "x-powers,axp209-battery-power-supply",
@@ -676,7 +607,7 @@ static struct mfd_cell axp20x_cells[] = {
        },
 };
 
-static struct mfd_cell axp221_cells[] = {
+static const struct mfd_cell axp221_cells[] = {
        {
                .name           = "axp221-pek",
                .num_resources  = ARRAY_SIZE(axp22x_pek_resources),
@@ -684,7 +615,8 @@ static struct mfd_cell axp221_cells[] = {
        }, {
                .name           = "axp20x-regulator",
        }, {
-               .name           = "axp22x-adc"
+               .name           = "axp22x-adc",
+               .of_compatible  = "x-powers,axp221-adc",
        }, {
                .name           = "axp20x-ac-power-supply",
                .of_compatible  = "x-powers,axp221-ac-power-supply",
@@ -701,13 +633,14 @@ static struct mfd_cell axp221_cells[] = {
        },
 };
 
-static struct mfd_cell axp223_cells[] = {
+static const struct mfd_cell axp223_cells[] = {
        {
                .name                   = "axp221-pek",
                .num_resources          = ARRAY_SIZE(axp22x_pek_resources),
                .resources              = axp22x_pek_resources,
        }, {
                .name           = "axp22x-adc",
+               .of_compatible  = "x-powers,axp221-adc",
        }, {
                .name           = "axp20x-battery-power-supply",
                .of_compatible  = "x-powers,axp221-battery-power-supply",
@@ -726,7 +659,7 @@ static struct mfd_cell axp223_cells[] = {
        },
 };
 
-static struct mfd_cell axp152_cells[] = {
+static const struct mfd_cell axp152_cells[] = {
        {
                .name                   = "axp20x-pek",
                .num_resources          = ARRAY_SIZE(axp152_pek_resources),
@@ -734,87 +667,30 @@ static struct mfd_cell axp152_cells[] = {
        },
 };
 
-static struct resource axp288_adc_resources[] = {
-       {
-               .name  = "GPADC",
-               .start = AXP288_IRQ_GPADC,
-               .end   = AXP288_IRQ_GPADC,
-               .flags = IORESOURCE_IRQ,
-       },
+static const struct resource axp288_adc_resources[] = {
+       DEFINE_RES_IRQ_NAMED(AXP288_IRQ_GPADC, "GPADC"),
 };
 
-static struct resource axp288_extcon_resources[] = {
-       {
-               .start = AXP288_IRQ_VBUS_FALL,
-               .end   = AXP288_IRQ_VBUS_FALL,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_VBUS_RISE,
-               .end   = AXP288_IRQ_VBUS_RISE,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_MV_CHNG,
-               .end   = AXP288_IRQ_MV_CHNG,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_BC_USB_CHNG,
-               .end   = AXP288_IRQ_BC_USB_CHNG,
-               .flags = IORESOURCE_IRQ,
-       },
+static const struct resource axp288_extcon_resources[] = {
+       DEFINE_RES_IRQ(AXP288_IRQ_VBUS_FALL),
+       DEFINE_RES_IRQ(AXP288_IRQ_VBUS_RISE),
+       DEFINE_RES_IRQ(AXP288_IRQ_MV_CHNG),
+       DEFINE_RES_IRQ(AXP288_IRQ_BC_USB_CHNG),
 };
 
-static struct resource axp288_charger_resources[] = {
-       {
-               .start = AXP288_IRQ_OV,
-               .end   = AXP288_IRQ_OV,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_DONE,
-               .end   = AXP288_IRQ_DONE,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_CHARGING,
-               .end   = AXP288_IRQ_CHARGING,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_SAFE_QUIT,
-               .end   = AXP288_IRQ_SAFE_QUIT,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_SAFE_ENTER,
-               .end   = AXP288_IRQ_SAFE_ENTER,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_QCBTU,
-               .end   = AXP288_IRQ_QCBTU,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_CBTU,
-               .end   = AXP288_IRQ_CBTU,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_QCBTO,
-               .end   = AXP288_IRQ_QCBTO,
-               .flags = IORESOURCE_IRQ,
-       },
-       {
-               .start = AXP288_IRQ_CBTO,
-               .end   = AXP288_IRQ_CBTO,
-               .flags = IORESOURCE_IRQ,
-       },
+static const struct resource axp288_charger_resources[] = {
+       DEFINE_RES_IRQ(AXP288_IRQ_OV),
+       DEFINE_RES_IRQ(AXP288_IRQ_DONE),
+       DEFINE_RES_IRQ(AXP288_IRQ_CHARGING),
+       DEFINE_RES_IRQ(AXP288_IRQ_SAFE_QUIT),
+       DEFINE_RES_IRQ(AXP288_IRQ_SAFE_ENTER),
+       DEFINE_RES_IRQ(AXP288_IRQ_QCBTU),
+       DEFINE_RES_IRQ(AXP288_IRQ_CBTU),
+       DEFINE_RES_IRQ(AXP288_IRQ_QCBTO),
+       DEFINE_RES_IRQ(AXP288_IRQ_CBTO),
 };
 
-static struct mfd_cell axp288_cells[] = {
+static const struct mfd_cell axp288_cells[] = {
        {
                .name = "axp288_adc",
                .num_resources = ARRAY_SIZE(axp288_adc_resources),
@@ -845,7 +721,7 @@ static struct mfd_cell axp288_cells[] = {
        },
 };
 
-static struct mfd_cell axp803_cells[] = {
+static const struct mfd_cell axp803_cells[] = {
        {
                .name                   = "axp221-pek",
                .num_resources          = ARRAY_SIZE(axp803_pek_resources),
@@ -854,14 +730,14 @@ static struct mfd_cell axp803_cells[] = {
        {       .name                   = "axp20x-regulator" },
 };
 
-static struct mfd_cell axp806_cells[] = {
+static const struct mfd_cell axp806_cells[] = {
        {
                .id                     = 2,
                .name                   = "axp20x-regulator",
        },
 };
 
-static struct mfd_cell axp809_cells[] = {
+static const struct mfd_cell axp809_cells[] = {
        {
                .name                   = "axp221-pek",
                .num_resources          = ARRAY_SIZE(axp809_pek_resources),
@@ -872,7 +748,7 @@ static struct mfd_cell axp809_cells[] = {
        },
 };
 
-static struct mfd_cell axp813_cells[] = {
+static const struct mfd_cell axp813_cells[] = {
        {
                .name                   = "axp221-pek",
                .num_resources          = ARRAY_SIZE(axp803_pek_resources),
@@ -882,7 +758,13 @@ static struct mfd_cell axp813_cells[] = {
        }, {
                .name                   = "axp20x-gpio",
                .of_compatible          = "x-powers,axp813-gpio",
-       }
+       }, {
+               .name                   = "axp813-adc",
+               .of_compatible          = "x-powers,axp813-adc",
+       }, {
+               .name           = "axp20x-battery-power-supply",
+               .of_compatible  = "x-powers,axp813-battery-power-supply",
+       },
 };
 
 static struct axp20x_dev *axp20x_pm_power_off;
index 36156a41499c918a61e9ab4f432e64c3ecb36314..65a9757a6d214858c1a7a0f5247bd255770e2d57 100644 (file)
@@ -112,12 +112,16 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
 
        mutex_init(&ec_dev->lock);
 
-       cros_ec_query_all(ec_dev);
+       err = cros_ec_query_all(ec_dev);
+       if (err) {
+               dev_err(dev, "Cannot identify the EC: error %d\n", err);
+               return err;
+       }
 
        if (ec_dev->irq) {
-               err = request_threaded_irq(ec_dev->irq, NULL, ec_irq_thread,
-                                          IRQF_TRIGGER_LOW | IRQF_ONESHOT,
-                                          "chromeos-ec", ec_dev);
+               err = devm_request_threaded_irq(dev, ec_dev->irq, NULL,
+                               ec_irq_thread, IRQF_TRIGGER_LOW | IRQF_ONESHOT,
+                               "chromeos-ec", ec_dev);
                if (err) {
                        dev_err(dev, "Failed to request IRQ %d: %d",
                                ec_dev->irq, err);
@@ -131,7 +135,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
                dev_err(dev,
                        "Failed to register Embedded Controller subdevice %d\n",
                        err);
-               goto fail_mfd;
+               return err;
        }
 
        if (ec_dev->max_passthru) {
@@ -149,7 +153,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
                        dev_err(dev,
                                "Failed to register Power Delivery subdevice %d\n",
                                err);
-                       goto fail_mfd;
+                       return err;
                }
        }
 
@@ -158,7 +162,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
                if (err) {
                        mfd_remove_devices(dev);
                        dev_err(dev, "Failed to register sub-devices\n");
-                       goto fail_mfd;
+                       return err;
                }
        }
 
@@ -173,14 +177,7 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
 
        dev_info(dev, "Chrome EC device registered\n");
 
-       cros_ec_acpi_install_gpe_handler(dev);
-
        return 0;
-
-fail_mfd:
-       if (ec_dev->irq)
-               free_irq(ec_dev->irq, ec_dev);
-       return err;
 }
 EXPORT_SYMBOL(cros_ec_register);
 
@@ -188,11 +185,6 @@ int cros_ec_remove(struct cros_ec_device *ec_dev)
 {
        mfd_remove_devices(ec_dev->dev);
 
-       cros_ec_acpi_remove_gpe_handler();
-
-       if (ec_dev->irq)
-               free_irq(ec_dev->irq, ec_dev);
-
        return 0;
 }
 EXPORT_SYMBOL(cros_ec_remove);
@@ -204,14 +196,9 @@ int cros_ec_suspend(struct cros_ec_device *ec_dev)
        int ret;
        u8 sleep_event;
 
-       if (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) {
-               sleep_event = HOST_SLEEP_EVENT_S3_SUSPEND;
-       } else {
-               sleep_event = HOST_SLEEP_EVENT_S0IX_SUSPEND;
-
-               /* Clearing the GPE status for any pending event */
-               cros_ec_acpi_clear_gpe();
-       }
+       sleep_event = (!IS_ENABLED(CONFIG_ACPI) || pm_suspend_via_firmware()) ?
+                     HOST_SLEEP_EVENT_S3_SUSPEND :
+                     HOST_SLEEP_EVENT_S0IX_SUSPEND;
 
        ret = cros_ec_sleep_event(ec_dev, sleep_event);
        if (ret < 0)
diff --git a/drivers/mfd/cros_ec_acpi_gpe.c b/drivers/mfd/cros_ec_acpi_gpe.c
deleted file mode 100644 (file)
index 56d305d..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * ChromeOS EC multi-function device
- *
- * Copyright (C) 2017 Google, Inc
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
- *
- * The ChromeOS EC multi function device is used to mux all the requests
- * to the EC device for its multiple features: keyboard controller,
- * battery charging and regulator control, firmware update.
- */
-#include <linux/acpi.h>
-
-#define ACPI_LID_DEVICE      "LID0"
-
-static int ec_wake_gpe = -EINVAL;
-
-/*
- * This handler indicates to ACPI core that this GPE should stay enabled for
- * lid to work in suspend to idle path.
- */
-static u32 cros_ec_gpe_handler(acpi_handle gpe_device, u32 gpe_number,
-                              void *data)
-{
-       return ACPI_INTERRUPT_HANDLED | ACPI_REENABLE_GPE;
-}
-
-/*
- * Get ACPI GPE for LID0 device.
- */
-static int cros_ec_get_ec_wake_gpe(struct device *dev)
-{
-       struct acpi_device *cros_acpi_dev;
-       struct acpi_device *adev;
-       acpi_handle handle;
-       acpi_status status;
-       int ret;
-
-       cros_acpi_dev = ACPI_COMPANION(dev);
-
-       if (!cros_acpi_dev || !cros_acpi_dev->parent ||
-          !cros_acpi_dev->parent->handle)
-               return -EINVAL;
-
-       status = acpi_get_handle(cros_acpi_dev->parent->handle, ACPI_LID_DEVICE,
-                                &handle);
-       if (ACPI_FAILURE(status))
-               return -EINVAL;
-
-       ret = acpi_bus_get_device(handle, &adev);
-       if (ret)
-               return ret;
-
-       return adev->wakeup.gpe_number;
-}
-
-int cros_ec_acpi_install_gpe_handler(struct device *dev)
-{
-       acpi_status status;
-
-       ec_wake_gpe = cros_ec_get_ec_wake_gpe(dev);
-
-       if (ec_wake_gpe < 0)
-               return ec_wake_gpe;
-
-       status = acpi_install_gpe_handler(NULL, ec_wake_gpe,
-                                         ACPI_GPE_EDGE_TRIGGERED,
-                                         &cros_ec_gpe_handler, NULL);
-       if (ACPI_FAILURE(status))
-               return -ENODEV;
-
-       dev_info(dev, "Initialized, GPE = 0x%x\n", ec_wake_gpe);
-
-       return 0;
-}
-
-void cros_ec_acpi_remove_gpe_handler(void)
-{
-       acpi_status status;
-
-       if (ec_wake_gpe < 0)
-               return;
-
-       status = acpi_remove_gpe_handler(NULL, ec_wake_gpe,
-                                                &cros_ec_gpe_handler);
-       if (ACPI_FAILURE(status))
-               pr_err("failed to remove gpe handler\n");
-}
-
-void cros_ec_acpi_clear_gpe(void)
-{
-       if (ec_wake_gpe < 0)
-               return;
-
-       acpi_clear_gpe(NULL, ec_wake_gpe);
-}
index eafd06f62a3afb492e1c2ec64526d591703a3a31..306e1fd109bdd8d3724e4ff2070d7c457aef20bb 100644 (file)
@@ -113,10 +113,10 @@ static int cros_ec_check_features(struct cros_ec_dev *ec, int feature)
                        dev_warn(ec->dev, "cannot get EC features: %d/%d\n",
                                 ret, msg->result);
                        memset(ec->features, 0, sizeof(ec->features));
+               } else {
+                       memcpy(ec->features, msg->data, sizeof(ec->features));
                }
 
-               memcpy(ec->features, msg->data, sizeof(ec->features));
-
                dev_dbg(ec->dev, "EC features %08x %08x\n",
                        ec->features[0], ec->features[1]);
 
@@ -262,13 +262,6 @@ static const struct file_operations fops = {
 #endif
 };
 
-static void __remove(struct device *dev)
-{
-       struct cros_ec_dev *ec = container_of(dev, struct cros_ec_dev,
-                                             class_dev);
-       kfree(ec);
-}
-
 static void cros_ec_sensors_register(struct cros_ec_dev *ec)
 {
        /*
@@ -306,13 +299,14 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
        resp = (struct ec_response_motion_sense *)msg->data;
        sensor_num = resp->dump.sensor_count;
        /* Allocate 1 extra sensors in FIFO are needed */
-       sensor_cells = kzalloc(sizeof(struct mfd_cell) * (sensor_num + 1),
+       sensor_cells = kcalloc(sensor_num + 1, sizeof(struct mfd_cell),
                               GFP_KERNEL);
        if (sensor_cells == NULL)
                goto error;
 
-       sensor_platforms = kzalloc(sizeof(struct cros_ec_sensor_platform) *
-                 (sensor_num + 1), GFP_KERNEL);
+       sensor_platforms = kcalloc(sensor_num + 1,
+                                  sizeof(struct cros_ec_sensor_platform),
+                                  GFP_KERNEL);
        if (sensor_platforms == NULL)
                goto error_platforms;
 
@@ -383,12 +377,16 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec)
        kfree(msg);
 }
 
+static const struct mfd_cell cros_ec_rtc_cells[] = {
+       { .name = "cros-ec-rtc" }
+};
+
 static int ec_device_probe(struct platform_device *pdev)
 {
        int retval = -ENOMEM;
        struct device *dev = &pdev->dev;
        struct cros_ec_platform *ec_platform = dev_get_platdata(dev);
-       struct cros_ec_dev *ec = kzalloc(sizeof(*ec), GFP_KERNEL);
+       struct cros_ec_dev *ec = devm_kzalloc(dev, sizeof(*ec), GFP_KERNEL);
 
        if (!ec)
                return retval;
@@ -410,7 +408,6 @@ static int ec_device_probe(struct platform_device *pdev)
        ec->class_dev.devt = MKDEV(ec_major, pdev->id);
        ec->class_dev.class = &cros_class;
        ec->class_dev.parent = dev;
-       ec->class_dev.release = __remove;
 
        retval = dev_set_name(&ec->class_dev, "%s", ec_platform->ec_name);
        if (retval) {
@@ -422,6 +419,18 @@ static int ec_device_probe(struct platform_device *pdev)
        if (cros_ec_check_features(ec, EC_FEATURE_MOTION_SENSE))
                cros_ec_sensors_register(ec);
 
+       /* Check whether this EC instance has RTC host command support */
+       if (cros_ec_check_features(ec, EC_FEATURE_RTC)) {
+               retval = mfd_add_devices(ec->dev, PLATFORM_DEVID_AUTO,
+                                        cros_ec_rtc_cells,
+                                        ARRAY_SIZE(cros_ec_rtc_cells),
+                                        NULL, 0, NULL);
+               if (retval)
+                       dev_err(ec->dev,
+                               "failed to add cros-ec-rtc device: %d\n",
+                               retval);
+       }
+
        /* Take control of the lightbar from the EC. */
        lb_manual_suspend_ctrl(ec, 1);
 
@@ -456,9 +465,17 @@ static int ec_device_remove(struct platform_device *pdev)
        return 0;
 }
 
+static void ec_device_shutdown(struct platform_device *pdev)
+{
+       struct cros_ec_dev *ec = dev_get_drvdata(&pdev->dev);
+
+       /* Be sure to clear up debugfs delayed works */
+       cros_ec_debugfs_remove(ec);
+}
+
 static const struct platform_device_id cros_ec_id[] = {
        { DRV_NAME, 0 },
-       { /* sentinel */ },
+       { /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(platform, cros_ec_id);
 
@@ -466,6 +483,8 @@ static __maybe_unused int ec_device_suspend(struct device *dev)
 {
        struct cros_ec_dev *ec = dev_get_drvdata(dev);
 
+       cros_ec_debugfs_suspend(ec);
+
        lb_suspend(ec);
 
        return 0;
@@ -475,6 +494,8 @@ static __maybe_unused int ec_device_resume(struct device *dev)
 {
        struct cros_ec_dev *ec = dev_get_drvdata(dev);
 
+       cros_ec_debugfs_resume(ec);
+
        lb_resume(ec);
 
        return 0;
@@ -494,6 +515,7 @@ static struct platform_driver cros_ec_dev_driver = {
        },
        .probe = ec_device_probe,
        .remove = ec_device_remove,
+       .shutdown = ec_device_shutdown,
 };
 
 static int __init cros_ec_dev_init(void)
index 9f70de1e4c70567ae9906e59df4b49c798f37b73..ef9b4763356ff2e5def8c8446fb12a874dd9e167 100644 (file)
@@ -13,6 +13,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/acpi.h>
 #include <linux/delay.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -341,14 +342,17 @@ static int cros_ec_i2c_resume(struct device *dev)
 }
 #endif
 
-static SIMPLE_DEV_PM_OPS(cros_ec_i2c_pm_ops, cros_ec_i2c_suspend,
-                         cros_ec_i2c_resume);
+static const struct dev_pm_ops cros_ec_i2c_pm_ops = {
+       SET_LATE_SYSTEM_SLEEP_PM_OPS(cros_ec_i2c_suspend, cros_ec_i2c_resume)
+};
 
+#ifdef CONFIG_OF
 static const struct of_device_id cros_ec_i2c_of_match[] = {
        { .compatible = "google,cros-ec-i2c", },
        { /* sentinel */ },
 };
 MODULE_DEVICE_TABLE(of, cros_ec_i2c_of_match);
+#endif
 
 static const struct i2c_device_id cros_ec_i2c_id[] = {
        { "cros-ec-i2c", 0 },
@@ -356,9 +360,18 @@ static const struct i2c_device_id cros_ec_i2c_id[] = {
 };
 MODULE_DEVICE_TABLE(i2c, cros_ec_i2c_id);
 
+#ifdef CONFIG_ACPI
+static const struct acpi_device_id cros_ec_i2c_acpi_id[] = {
+       { "GOOG0008", 0 },
+       { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(acpi, cros_ec_i2c_acpi_id);
+#endif
+
 static struct i2c_driver cros_ec_driver = {
        .driver = {
                .name   = "cros-ec-i2c",
+               .acpi_match_table = ACPI_PTR(cros_ec_i2c_acpi_id),
                .of_match_table = of_match_ptr(cros_ec_i2c_of_match),
                .pm     = &cros_ec_i2c_pm_ops,
        },
index fe1811523e4a7aac70e0498e7cd70fac55e2046b..9f6105906c093505a718248cdfd12a35da140fcf 100644 (file)
@@ -365,186 +365,69 @@ static int da9062_get_device_type(struct da9062 *chip)
 }
 
 static const struct regmap_range da9061_aa_readable_ranges[] = {
-       {
-               .range_min = DA9062AA_PAGE_CON,
-               .range_max = DA9062AA_STATUS_B,
-       }, {
-               .range_min = DA9062AA_STATUS_D,
-               .range_max = DA9062AA_EVENT_C,
-       }, {
-               .range_min = DA9062AA_IRQ_MASK_A,
-               .range_max = DA9062AA_IRQ_MASK_C,
-       }, {
-               .range_min = DA9062AA_CONTROL_A,
-               .range_max = DA9062AA_GPIO_4,
-       }, {
-               .range_min = DA9062AA_GPIO_WKUP_MODE,
-               .range_max = DA9062AA_GPIO_OUT3_4,
-       }, {
-               .range_min = DA9062AA_BUCK1_CONT,
-               .range_max = DA9062AA_BUCK4_CONT,
-       }, {
-               .range_min = DA9062AA_BUCK3_CONT,
-               .range_max = DA9062AA_BUCK3_CONT,
-       }, {
-               .range_min = DA9062AA_LDO1_CONT,
-               .range_max = DA9062AA_LDO4_CONT,
-       }, {
-               .range_min = DA9062AA_DVC_1,
-               .range_max = DA9062AA_DVC_1,
-       }, {
-               .range_min = DA9062AA_SEQ,
-               .range_max = DA9062AA_ID_4_3,
-       }, {
-               .range_min = DA9062AA_ID_12_11,
-               .range_max = DA9062AA_ID_16_15,
-       }, {
-               .range_min = DA9062AA_ID_22_21,
-               .range_max = DA9062AA_ID_32_31,
-       }, {
-               .range_min = DA9062AA_SEQ_A,
-               .range_max = DA9062AA_WAIT,
-       }, {
-               .range_min = DA9062AA_RESET,
-               .range_max = DA9062AA_BUCK_ILIM_C,
-       }, {
-               .range_min = DA9062AA_BUCK1_CFG,
-               .range_max = DA9062AA_BUCK3_CFG,
-       }, {
-               .range_min = DA9062AA_VBUCK1_A,
-               .range_max = DA9062AA_VBUCK4_A,
-       }, {
-               .range_min = DA9062AA_VBUCK3_A,
-               .range_max = DA9062AA_VBUCK3_A,
-       }, {
-               .range_min = DA9062AA_VLDO1_A,
-               .range_max = DA9062AA_VLDO4_A,
-       }, {
-               .range_min = DA9062AA_VBUCK1_B,
-               .range_max = DA9062AA_VBUCK4_B,
-       }, {
-               .range_min = DA9062AA_VBUCK3_B,
-               .range_max = DA9062AA_VBUCK3_B,
-       }, {
-               .range_min = DA9062AA_VLDO1_B,
-               .range_max = DA9062AA_VLDO4_B,
-       }, {
-               .range_min = DA9062AA_INTERFACE,
-               .range_max = DA9062AA_CONFIG_E,
-       }, {
-               .range_min = DA9062AA_CONFIG_G,
-               .range_max = DA9062AA_CONFIG_K,
-       }, {
-               .range_min = DA9062AA_CONFIG_M,
-               .range_max = DA9062AA_CONFIG_M,
-       }, {
-               .range_min = DA9062AA_GP_ID_0,
-               .range_max = DA9062AA_GP_ID_19,
-       }, {
-               .range_min = DA9062AA_DEVICE_ID,
-               .range_max = DA9062AA_CONFIG_ID,
-       },
+       regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B),
+       regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C),
+       regmap_reg_range(DA9062AA_IRQ_MASK_A, DA9062AA_IRQ_MASK_C),
+       regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_GPIO_4),
+       regmap_reg_range(DA9062AA_GPIO_WKUP_MODE, DA9062AA_GPIO_OUT3_4),
+       regmap_reg_range(DA9062AA_BUCK1_CONT, DA9062AA_BUCK4_CONT),
+       regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT),
+       regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT),
+       regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1),
+       regmap_reg_range(DA9062AA_SEQ, DA9062AA_ID_4_3),
+       regmap_reg_range(DA9062AA_ID_12_11, DA9062AA_ID_16_15),
+       regmap_reg_range(DA9062AA_ID_22_21, DA9062AA_ID_32_31),
+       regmap_reg_range(DA9062AA_SEQ_A, DA9062AA_WAIT),
+       regmap_reg_range(DA9062AA_RESET, DA9062AA_BUCK_ILIM_C),
+       regmap_reg_range(DA9062AA_BUCK1_CFG, DA9062AA_BUCK3_CFG),
+       regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A),
+       regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A),
+       regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A),
+       regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B),
+       regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B),
+       regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B),
+       regmap_reg_range(DA9062AA_INTERFACE, DA9062AA_CONFIG_E),
+       regmap_reg_range(DA9062AA_CONFIG_G, DA9062AA_CONFIG_K),
+       regmap_reg_range(DA9062AA_CONFIG_M, DA9062AA_CONFIG_M),
+       regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19),
+       regmap_reg_range(DA9062AA_DEVICE_ID, DA9062AA_CONFIG_ID),
 };
 
 static const struct regmap_range da9061_aa_writeable_ranges[] = {
-       {
-               .range_min = DA9062AA_PAGE_CON,
-               .range_max = DA9062AA_PAGE_CON,
-       }, {
-               .range_min = DA9062AA_FAULT_LOG,
-               .range_max = DA9062AA_EVENT_C,
-       }, {
-               .range_min = DA9062AA_IRQ_MASK_A,
-               .range_max = DA9062AA_IRQ_MASK_C,
-       }, {
-               .range_min = DA9062AA_CONTROL_A,
-               .range_max = DA9062AA_GPIO_4,
-       }, {
-               .range_min = DA9062AA_GPIO_WKUP_MODE,
-               .range_max = DA9062AA_GPIO_OUT3_4,
-       }, {
-               .range_min = DA9062AA_BUCK1_CONT,
-               .range_max = DA9062AA_BUCK4_CONT,
-       }, {
-               .range_min = DA9062AA_BUCK3_CONT,
-               .range_max = DA9062AA_BUCK3_CONT,
-       }, {
-               .range_min = DA9062AA_LDO1_CONT,
-               .range_max = DA9062AA_LDO4_CONT,
-       }, {
-               .range_min = DA9062AA_DVC_1,
-               .range_max = DA9062AA_DVC_1,
-       }, {
-               .range_min = DA9062AA_SEQ,
-               .range_max = DA9062AA_ID_4_3,
-       }, {
-               .range_min = DA9062AA_ID_12_11,
-               .range_max = DA9062AA_ID_16_15,
-       }, {
-               .range_min = DA9062AA_ID_22_21,
-               .range_max = DA9062AA_ID_32_31,
-       }, {
-               .range_min = DA9062AA_SEQ_A,
-               .range_max = DA9062AA_WAIT,
-       }, {
-               .range_min = DA9062AA_RESET,
-               .range_max = DA9062AA_BUCK_ILIM_C,
-       }, {
-               .range_min = DA9062AA_BUCK1_CFG,
-               .range_max = DA9062AA_BUCK3_CFG,
-       }, {
-               .range_min = DA9062AA_VBUCK1_A,
-               .range_max = DA9062AA_VBUCK4_A,
-       }, {
-               .range_min = DA9062AA_VBUCK3_A,
-               .range_max = DA9062AA_VBUCK3_A,
-       }, {
-               .range_min = DA9062AA_VLDO1_A,
-               .range_max = DA9062AA_VLDO4_A,
-       }, {
-               .range_min = DA9062AA_VBUCK1_B,
-               .range_max = DA9062AA_VBUCK4_B,
-       }, {
-               .range_min = DA9062AA_VBUCK3_B,
-               .range_max = DA9062AA_VBUCK3_B,
-       }, {
-               .range_min = DA9062AA_VLDO1_B,
-               .range_max = DA9062AA_VLDO4_B,
-       }, {
-               .range_min = DA9062AA_GP_ID_0,
-               .range_max = DA9062AA_GP_ID_19,
-       },
+       regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_PAGE_CON),
+       regmap_reg_range(DA9062AA_FAULT_LOG, DA9062AA_EVENT_C),
+       regmap_reg_range(DA9062AA_IRQ_MASK_A, DA9062AA_IRQ_MASK_C),
+       regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_GPIO_4),
+       regmap_reg_range(DA9062AA_GPIO_WKUP_MODE, DA9062AA_GPIO_OUT3_4),
+       regmap_reg_range(DA9062AA_BUCK1_CONT, DA9062AA_BUCK4_CONT),
+       regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT),
+       regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT),
+       regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1),
+       regmap_reg_range(DA9062AA_SEQ, DA9062AA_ID_4_3),
+       regmap_reg_range(DA9062AA_ID_12_11, DA9062AA_ID_16_15),
+       regmap_reg_range(DA9062AA_ID_22_21, DA9062AA_ID_32_31),
+       regmap_reg_range(DA9062AA_SEQ_A, DA9062AA_WAIT),
+       regmap_reg_range(DA9062AA_RESET, DA9062AA_BUCK_ILIM_C),
+       regmap_reg_range(DA9062AA_BUCK1_CFG, DA9062AA_BUCK3_CFG),
+       regmap_reg_range(DA9062AA_VBUCK1_A, DA9062AA_VBUCK4_A),
+       regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A),
+       regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A),
+       regmap_reg_range(DA9062AA_VBUCK1_B, DA9062AA_VBUCK4_B),
+       regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B),
+       regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B),
+       regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19),
 };
 
 static const struct regmap_range da9061_aa_volatile_ranges[] = {
-       {
-               .range_min = DA9062AA_PAGE_CON,
-               .range_max = DA9062AA_STATUS_B,
-       }, {
-               .range_min = DA9062AA_STATUS_D,
-               .range_max = DA9062AA_EVENT_C,
-       }, {
-               .range_min = DA9062AA_CONTROL_A,
-               .range_max = DA9062AA_CONTROL_B,
-       }, {
-               .range_min = DA9062AA_CONTROL_E,
-               .range_max = DA9062AA_CONTROL_F,
-       }, {
-               .range_min = DA9062AA_BUCK1_CONT,
-               .range_max = DA9062AA_BUCK4_CONT,
-       }, {
-               .range_min = DA9062AA_BUCK3_CONT,
-               .range_max = DA9062AA_BUCK3_CONT,
-       }, {
-               .range_min = DA9062AA_LDO1_CONT,
-               .range_max = DA9062AA_LDO4_CONT,
-       }, {
-               .range_min = DA9062AA_DVC_1,
-               .range_max = DA9062AA_DVC_1,
-       }, {
-               .range_min = DA9062AA_SEQ,
-               .range_max = DA9062AA_SEQ,
-       },
+       regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B),
+       regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C),
+       regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_CONTROL_B),
+       regmap_reg_range(DA9062AA_CONTROL_E, DA9062AA_CONTROL_F),
+       regmap_reg_range(DA9062AA_BUCK1_CONT, DA9062AA_BUCK4_CONT),
+       regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT),
+       regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT),
+       regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1),
+       regmap_reg_range(DA9062AA_SEQ, DA9062AA_SEQ),
 };
 
 static const struct regmap_access_table da9061_aa_readable_table = {
@@ -587,186 +470,69 @@ static struct regmap_config da9061_regmap_config = {
 };
 
 static const struct regmap_range da9062_aa_readable_ranges[] = {
-       {
-               .range_min = DA9062AA_PAGE_CON,
-               .range_max = DA9062AA_STATUS_B,
-       }, {
-               .range_min = DA9062AA_STATUS_D,
-               .range_max = DA9062AA_EVENT_C,
-       }, {
-               .range_min = DA9062AA_IRQ_MASK_A,
-               .range_max = DA9062AA_IRQ_MASK_C,
-       }, {
-               .range_min = DA9062AA_CONTROL_A,
-               .range_max = DA9062AA_GPIO_4,
-       }, {
-               .range_min = DA9062AA_GPIO_WKUP_MODE,
-               .range_max = DA9062AA_BUCK4_CONT,
-       }, {
-               .range_min = DA9062AA_BUCK3_CONT,
-               .range_max = DA9062AA_BUCK3_CONT,
-       }, {
-               .range_min = DA9062AA_LDO1_CONT,
-               .range_max = DA9062AA_LDO4_CONT,
-       }, {
-               .range_min = DA9062AA_DVC_1,
-               .range_max = DA9062AA_DVC_1,
-       }, {
-               .range_min = DA9062AA_COUNT_S,
-               .range_max = DA9062AA_SECOND_D,
-       }, {
-               .range_min = DA9062AA_SEQ,
-               .range_max = DA9062AA_ID_4_3,
-       }, {
-               .range_min = DA9062AA_ID_12_11,
-               .range_max = DA9062AA_ID_16_15,
-       }, {
-               .range_min = DA9062AA_ID_22_21,
-               .range_max = DA9062AA_ID_32_31,
-       }, {
-               .range_min = DA9062AA_SEQ_A,
-               .range_max = DA9062AA_BUCK3_CFG,
-       }, {
-               .range_min = DA9062AA_VBUCK2_A,
-               .range_max = DA9062AA_VBUCK4_A,
-       }, {
-               .range_min = DA9062AA_VBUCK3_A,
-               .range_max = DA9062AA_VBUCK3_A,
-       }, {
-               .range_min = DA9062AA_VLDO1_A,
-               .range_max = DA9062AA_VLDO4_A,
-       }, {
-               .range_min = DA9062AA_VBUCK2_B,
-               .range_max = DA9062AA_VBUCK4_B,
-       }, {
-               .range_min = DA9062AA_VBUCK3_B,
-               .range_max = DA9062AA_VBUCK3_B,
-       }, {
-               .range_min = DA9062AA_VLDO1_B,
-               .range_max = DA9062AA_VLDO4_B,
-       }, {
-               .range_min = DA9062AA_BBAT_CONT,
-               .range_max = DA9062AA_BBAT_CONT,
-       }, {
-               .range_min = DA9062AA_INTERFACE,
-               .range_max = DA9062AA_CONFIG_E,
-       }, {
-               .range_min = DA9062AA_CONFIG_G,
-               .range_max = DA9062AA_CONFIG_K,
-       }, {
-               .range_min = DA9062AA_CONFIG_M,
-               .range_max = DA9062AA_CONFIG_M,
-       }, {
-               .range_min = DA9062AA_TRIM_CLDR,
-               .range_max = DA9062AA_GP_ID_19,
-       }, {
-               .range_min = DA9062AA_DEVICE_ID,
-               .range_max = DA9062AA_CONFIG_ID,
-       },
+       regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B),
+       regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C),
+       regmap_reg_range(DA9062AA_IRQ_MASK_A, DA9062AA_IRQ_MASK_C),
+       regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_GPIO_4),
+       regmap_reg_range(DA9062AA_GPIO_WKUP_MODE, DA9062AA_BUCK4_CONT),
+       regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT),
+       regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT),
+       regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1),
+       regmap_reg_range(DA9062AA_COUNT_S, DA9062AA_SECOND_D),
+       regmap_reg_range(DA9062AA_SEQ, DA9062AA_ID_4_3),
+       regmap_reg_range(DA9062AA_ID_12_11, DA9062AA_ID_16_15),
+       regmap_reg_range(DA9062AA_ID_22_21, DA9062AA_ID_32_31),
+       regmap_reg_range(DA9062AA_SEQ_A, DA9062AA_BUCK3_CFG),
+       regmap_reg_range(DA9062AA_VBUCK2_A, DA9062AA_VBUCK4_A),
+       regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A),
+       regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A),
+       regmap_reg_range(DA9062AA_VBUCK2_B, DA9062AA_VBUCK4_B),
+       regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B),
+       regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B),
+       regmap_reg_range(DA9062AA_BBAT_CONT, DA9062AA_BBAT_CONT),
+       regmap_reg_range(DA9062AA_INTERFACE, DA9062AA_CONFIG_E),
+       regmap_reg_range(DA9062AA_CONFIG_G, DA9062AA_CONFIG_K),
+       regmap_reg_range(DA9062AA_CONFIG_M, DA9062AA_CONFIG_M),
+       regmap_reg_range(DA9062AA_TRIM_CLDR, DA9062AA_GP_ID_19),
+       regmap_reg_range(DA9062AA_DEVICE_ID, DA9062AA_CONFIG_ID),
 };
 
 static const struct regmap_range da9062_aa_writeable_ranges[] = {
-       {
-               .range_min = DA9062AA_PAGE_CON,
-               .range_max = DA9062AA_PAGE_CON,
-       }, {
-               .range_min = DA9062AA_FAULT_LOG,
-               .range_max = DA9062AA_EVENT_C,
-       }, {
-               .range_min = DA9062AA_IRQ_MASK_A,
-               .range_max = DA9062AA_IRQ_MASK_C,
-       }, {
-               .range_min = DA9062AA_CONTROL_A,
-               .range_max = DA9062AA_GPIO_4,
-       }, {
-               .range_min = DA9062AA_GPIO_WKUP_MODE,
-               .range_max = DA9062AA_BUCK4_CONT,
-       }, {
-               .range_min = DA9062AA_BUCK3_CONT,
-               .range_max = DA9062AA_BUCK3_CONT,
-       }, {
-               .range_min = DA9062AA_LDO1_CONT,
-               .range_max = DA9062AA_LDO4_CONT,
-       }, {
-               .range_min = DA9062AA_DVC_1,
-               .range_max = DA9062AA_DVC_1,
-       }, {
-               .range_min = DA9062AA_COUNT_S,
-               .range_max = DA9062AA_ALARM_Y,
-       }, {
-               .range_min = DA9062AA_SEQ,
-               .range_max = DA9062AA_ID_4_3,
-       }, {
-               .range_min = DA9062AA_ID_12_11,
-               .range_max = DA9062AA_ID_16_15,
-       }, {
-               .range_min = DA9062AA_ID_22_21,
-               .range_max = DA9062AA_ID_32_31,
-       }, {
-               .range_min = DA9062AA_SEQ_A,
-               .range_max = DA9062AA_BUCK3_CFG,
-       }, {
-               .range_min = DA9062AA_VBUCK2_A,
-               .range_max = DA9062AA_VBUCK4_A,
-       }, {
-               .range_min = DA9062AA_VBUCK3_A,
-               .range_max = DA9062AA_VBUCK3_A,
-       }, {
-               .range_min = DA9062AA_VLDO1_A,
-               .range_max = DA9062AA_VLDO4_A,
-       }, {
-               .range_min = DA9062AA_VBUCK2_B,
-               .range_max = DA9062AA_VBUCK4_B,
-       }, {
-               .range_min = DA9062AA_VBUCK3_B,
-               .range_max = DA9062AA_VBUCK3_B,
-       }, {
-               .range_min = DA9062AA_VLDO1_B,
-               .range_max = DA9062AA_VLDO4_B,
-       }, {
-               .range_min = DA9062AA_BBAT_CONT,
-               .range_max = DA9062AA_BBAT_CONT,
-       }, {
-               .range_min = DA9062AA_GP_ID_0,
-               .range_max = DA9062AA_GP_ID_19,
-       },
+       regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_PAGE_CON),
+       regmap_reg_range(DA9062AA_FAULT_LOG, DA9062AA_EVENT_C),
+       regmap_reg_range(DA9062AA_IRQ_MASK_A, DA9062AA_IRQ_MASK_C),
+       regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_GPIO_4),
+       regmap_reg_range(DA9062AA_GPIO_WKUP_MODE, DA9062AA_BUCK4_CONT),
+       regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT),
+       regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT),
+       regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1),
+       regmap_reg_range(DA9062AA_COUNT_S, DA9062AA_ALARM_Y),
+       regmap_reg_range(DA9062AA_SEQ, DA9062AA_ID_4_3),
+       regmap_reg_range(DA9062AA_ID_12_11, DA9062AA_ID_16_15),
+       regmap_reg_range(DA9062AA_ID_22_21, DA9062AA_ID_32_31),
+       regmap_reg_range(DA9062AA_SEQ_A, DA9062AA_BUCK3_CFG),
+       regmap_reg_range(DA9062AA_VBUCK2_A, DA9062AA_VBUCK4_A),
+       regmap_reg_range(DA9062AA_VBUCK3_A, DA9062AA_VBUCK3_A),
+       regmap_reg_range(DA9062AA_VLDO1_A, DA9062AA_VLDO4_A),
+       regmap_reg_range(DA9062AA_VBUCK2_B, DA9062AA_VBUCK4_B),
+       regmap_reg_range(DA9062AA_VBUCK3_B, DA9062AA_VBUCK3_B),
+       regmap_reg_range(DA9062AA_VLDO1_B, DA9062AA_VLDO4_B),
+       regmap_reg_range(DA9062AA_BBAT_CONT, DA9062AA_BBAT_CONT),
+       regmap_reg_range(DA9062AA_GP_ID_0, DA9062AA_GP_ID_19),
 };
 
 static const struct regmap_range da9062_aa_volatile_ranges[] = {
-       {
-               .range_min = DA9062AA_PAGE_CON,
-               .range_max = DA9062AA_STATUS_B,
-       }, {
-               .range_min = DA9062AA_STATUS_D,
-               .range_max = DA9062AA_EVENT_C,
-       }, {
-               .range_min = DA9062AA_CONTROL_A,
-               .range_max = DA9062AA_CONTROL_B,
-       }, {
-               .range_min = DA9062AA_CONTROL_E,
-               .range_max = DA9062AA_CONTROL_F,
-       }, {
-               .range_min = DA9062AA_BUCK2_CONT,
-               .range_max = DA9062AA_BUCK4_CONT,
-       }, {
-               .range_min = DA9062AA_BUCK3_CONT,
-               .range_max = DA9062AA_BUCK3_CONT,
-       }, {
-               .range_min = DA9062AA_LDO1_CONT,
-               .range_max = DA9062AA_LDO4_CONT,
-       }, {
-               .range_min = DA9062AA_DVC_1,
-               .range_max = DA9062AA_DVC_1,
-       }, {
-               .range_min = DA9062AA_COUNT_S,
-               .range_max = DA9062AA_SECOND_D,
-       }, {
-               .range_min = DA9062AA_SEQ,
-               .range_max = DA9062AA_SEQ,
-       }, {
-               .range_min = DA9062AA_EN_32K,
-               .range_max = DA9062AA_EN_32K,
-       },
+       regmap_reg_range(DA9062AA_PAGE_CON, DA9062AA_STATUS_B),
+       regmap_reg_range(DA9062AA_STATUS_D, DA9062AA_EVENT_C),
+       regmap_reg_range(DA9062AA_CONTROL_A, DA9062AA_CONTROL_B),
+       regmap_reg_range(DA9062AA_CONTROL_E, DA9062AA_CONTROL_F),
+       regmap_reg_range(DA9062AA_BUCK2_CONT, DA9062AA_BUCK4_CONT),
+       regmap_reg_range(DA9062AA_BUCK3_CONT, DA9062AA_BUCK3_CONT),
+       regmap_reg_range(DA9062AA_LDO1_CONT, DA9062AA_LDO4_CONT),
+       regmap_reg_range(DA9062AA_DVC_1, DA9062AA_DVC_1),
+       regmap_reg_range(DA9062AA_COUNT_S, DA9062AA_SECOND_D),
+       regmap_reg_range(DA9062AA_SEQ, DA9062AA_SEQ),
+       regmap_reg_range(DA9062AA_EN_32K, DA9062AA_EN_32K),
 };
 
 static const struct regmap_access_table da9062_aa_readable_table = {
index 3f9eee5f8fb9b60035252aea68d73f122d2d3437..01572b5e79e8f2f96b6a2b9206ccf260eaaea1d9 100644 (file)
@@ -477,12 +477,12 @@ static int htcpld_setup_chips(struct platform_device *pdev)
 
        /* Setup each chip's output GPIOs */
        htcpld->nchips = pdata->num_chip;
-       htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips,
+       htcpld->chip = devm_kcalloc(dev,
+                                   htcpld->nchips,
+                                   sizeof(struct htcpld_chip),
                                    GFP_KERNEL);
-       if (!htcpld->chip) {
-               dev_warn(dev, "Unable to allocate memory for chips\n");
+       if (!htcpld->chip)
                return -ENOMEM;
-       }
 
        /* Add the chips as best we can */
        for (i = 0; i < htcpld->nchips; i++) {
index d1c46de89eb49ac21329fbd3e7c053089fd6edc0..d9ae983095c5447a0a20bcf0636aaf7feee3655d 100644 (file)
@@ -124,6 +124,11 @@ static const struct intel_lpss_platform_info apl_i2c_info = {
        .properties = apl_i2c_properties,
 };
 
+static const struct intel_lpss_platform_info cnl_i2c_info = {
+       .clk_rate = 216000000,
+       .properties = spt_i2c_properties,
+};
+
 static const struct pci_device_id intel_lpss_pci_ids[] = {
        /* BXT A-Step */
        { PCI_VDEVICE(INTEL, 0x0aac), (kernel_ulong_t)&bxt_i2c_info },
@@ -207,13 +212,13 @@ static const struct pci_device_id intel_lpss_pci_ids[] = {
        { PCI_VDEVICE(INTEL, 0x9daa), (kernel_ulong_t)&spt_info },
        { PCI_VDEVICE(INTEL, 0x9dab), (kernel_ulong_t)&spt_info },
        { PCI_VDEVICE(INTEL, 0x9dfb), (kernel_ulong_t)&spt_info },
-       { PCI_VDEVICE(INTEL, 0x9dc5), (kernel_ulong_t)&spt_i2c_info },
-       { PCI_VDEVICE(INTEL, 0x9dc6), (kernel_ulong_t)&spt_i2c_info },
+       { PCI_VDEVICE(INTEL, 0x9dc5), (kernel_ulong_t)&cnl_i2c_info },
+       { PCI_VDEVICE(INTEL, 0x9dc6), (kernel_ulong_t)&cnl_i2c_info },
        { PCI_VDEVICE(INTEL, 0x9dc7), (kernel_ulong_t)&spt_uart_info },
-       { PCI_VDEVICE(INTEL, 0x9de8), (kernel_ulong_t)&spt_i2c_info },
-       { PCI_VDEVICE(INTEL, 0x9de9), (kernel_ulong_t)&spt_i2c_info },
-       { PCI_VDEVICE(INTEL, 0x9dea), (kernel_ulong_t)&spt_i2c_info },
-       { PCI_VDEVICE(INTEL, 0x9deb), (kernel_ulong_t)&spt_i2c_info },
+       { PCI_VDEVICE(INTEL, 0x9de8), (kernel_ulong_t)&cnl_i2c_info },
+       { PCI_VDEVICE(INTEL, 0x9de9), (kernel_ulong_t)&cnl_i2c_info },
+       { PCI_VDEVICE(INTEL, 0x9dea), (kernel_ulong_t)&cnl_i2c_info },
+       { PCI_VDEVICE(INTEL, 0x9deb), (kernel_ulong_t)&cnl_i2c_info },
        /* SPT-H */
        { PCI_VDEVICE(INTEL, 0xa127), (kernel_ulong_t)&spt_uart_info },
        { PCI_VDEVICE(INTEL, 0xa128), (kernel_ulong_t)&spt_uart_info },
@@ -240,10 +245,10 @@ static const struct pci_device_id intel_lpss_pci_ids[] = {
        { PCI_VDEVICE(INTEL, 0xa32b), (kernel_ulong_t)&spt_info },
        { PCI_VDEVICE(INTEL, 0xa37b), (kernel_ulong_t)&spt_info },
        { PCI_VDEVICE(INTEL, 0xa347), (kernel_ulong_t)&spt_uart_info },
-       { PCI_VDEVICE(INTEL, 0xa368), (kernel_ulong_t)&spt_i2c_info },
-       { PCI_VDEVICE(INTEL, 0xa369), (kernel_ulong_t)&spt_i2c_info },
-       { PCI_VDEVICE(INTEL, 0xa36a), (kernel_ulong_t)&spt_i2c_info },
-       { PCI_VDEVICE(INTEL, 0xa36b), (kernel_ulong_t)&spt_i2c_info },
+       { PCI_VDEVICE(INTEL, 0xa368), (kernel_ulong_t)&cnl_i2c_info },
+       { PCI_VDEVICE(INTEL, 0xa369), (kernel_ulong_t)&cnl_i2c_info },
+       { PCI_VDEVICE(INTEL, 0xa36a), (kernel_ulong_t)&cnl_i2c_info },
+       { PCI_VDEVICE(INTEL, 0xa36b), (kernel_ulong_t)&cnl_i2c_info },
        { }
 };
 MODULE_DEVICE_TABLE(pci, intel_lpss_pci_ids);
index 9e545eb6e8b4aa2fe018c5c4b3a622728f0cf713..50bffc3382d77fb008eaa994591cb338fa0b5d01 100644 (file)
@@ -40,8 +40,8 @@
 
 /* Offsets from lpss->priv */
 #define LPSS_PRIV_RESETS               0x04
-#define LPSS_PRIV_RESETS_FUNC          BIT(2)
-#define LPSS_PRIV_RESETS_IDMA          0x3
+#define LPSS_PRIV_RESETS_IDMA          BIT(2)
+#define LPSS_PRIV_RESETS_FUNC          0x3
 
 #define LPSS_PRIV_ACTIVELTR            0x10
 #define LPSS_PRIV_IDLELTR              0x14
@@ -275,11 +275,11 @@ static void intel_lpss_init_dev(const struct intel_lpss *lpss)
 
        intel_lpss_deassert_reset(lpss);
 
+       intel_lpss_set_remap_addr(lpss);
+
        if (!intel_lpss_has_idma(lpss))
                return;
 
-       intel_lpss_set_remap_addr(lpss);
-
        /* Make sure that SPI multiblock DMA transfers are re-enabled */
        if (lpss->type == LPSS_DEV_SPI)
                writel(value, lpss->priv + LPSS_PRIV_SSP_REG);
index ec1f46a6be3a021f67b7098f81ec887a5d2abf7c..317a47ad5bb751dc6b39469fe4945e4beaf8fc87 100644 (file)
@@ -183,10 +183,8 @@ static int cmodio_pci_probe(struct pci_dev *dev,
        int ret;
 
        priv = devm_kzalloc(&dev->dev, sizeof(*priv), GFP_KERNEL);
-       if (!priv) {
-               dev_err(&dev->dev, "unable to allocate private data\n");
+       if (!priv)
                return -ENOMEM;
-       }
 
        pci_set_drvdata(dev, priv);
        priv->pdev = dev;
index 798e44306382e1bb12dc37a3727d74a912846631..f4cd14294b61405273750ee025a01012eeb0bdd2 100644 (file)
@@ -212,10 +212,8 @@ static int jz4740_adc_probe(struct platform_device *pdev)
        int irq_base;
 
        adc = devm_kzalloc(&pdev->dev, sizeof(*adc), GFP_KERNEL);
-       if (!adc) {
-               dev_err(&pdev->dev, "Failed to allocate driver structure\n");
+       if (!adc)
                return -ENOMEM;
-       }
 
        adc->irq = platform_get_irq(pdev, 0);
        if (adc->irq < 0) {
index 2d6e2c39278626d06bd45ed70e73d1a457a835cc..3f554c44752183a917f6229a4bc26ec81a042e00 100644 (file)
@@ -148,10 +148,8 @@ static struct max8997_platform_data *max8997_i2c_parse_dt_pdata(
        struct max8997_platform_data *pd;
 
        pd = devm_kzalloc(dev, sizeof(*pd), GFP_KERNEL);
-       if (!pd) {
-               dev_err(dev, "could not allocate memory for pdata\n");
+       if (!pd)
                return ERR_PTR(-ENOMEM);
-       }
 
        pd->ono = irq_of_parse_and_map(dev->of_node, 1);
 
index c57e407020f11dd19aff3a9dd4b9ba7ce9c7b351..94e3f32ce935717e97f2e938b433f3673c38f22d 100644 (file)
@@ -158,7 +158,7 @@ static int mfd_add_device(struct device *parent, int id,
        if (!pdev)
                goto fail_alloc;
 
-       res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL);
+       res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL);
        if (!res)
                goto fail_device;
 
index d2cc1eabac05b26faaf76d21d6a18cce8ceccd68..5276911caaec27f23e477850d38a324624f80f35 100644 (file)
@@ -173,9 +173,9 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap)
        int ret;
 
        cpcap->irqs = devm_kzalloc(&cpcap->spi->dev,
-                                  sizeof(*cpcap->irqs) *
-                                  CPCAP_NR_IRQ_REG_BANKS *
-                                  cpcap->regmap_conf->val_bits,
+                                  array3_size(sizeof(*cpcap->irqs),
+                                              CPCAP_NR_IRQ_REG_BANKS,
+                                              cpcap->regmap_conf->val_bits),
                                   GFP_KERNEL);
        if (!cpcap->irqs)
                return -ENOMEM;
index 04a601f6aebe500d5491acfbbb4c68d7b56b9a73..77b64bd64df36aab2dd805a5dd2e056003c3c6e7 100644 (file)
@@ -43,6 +43,16 @@ static const struct resource mt6397_rtc_resources[] = {
        },
 };
 
+static const struct resource mt6323_keys_resources[] = {
+       DEFINE_RES_IRQ(MT6323_IRQ_STATUS_PWRKEY),
+       DEFINE_RES_IRQ(MT6323_IRQ_STATUS_FCHRKEY),
+};
+
+static const struct resource mt6397_keys_resources[] = {
+       DEFINE_RES_IRQ(MT6397_IRQ_PWRKEY),
+       DEFINE_RES_IRQ(MT6397_IRQ_HOMEKEY),
+};
+
 static const struct mfd_cell mt6323_devs[] = {
        {
                .name = "mt6323-regulator",
@@ -50,6 +60,11 @@ static const struct mfd_cell mt6323_devs[] = {
        }, {
                .name = "mt6323-led",
                .of_compatible = "mediatek,mt6323-led"
+       }, {
+               .name = "mtk-pmic-keys",
+               .num_resources = ARRAY_SIZE(mt6323_keys_resources),
+               .resources = mt6323_keys_resources,
+               .of_compatible = "mediatek,mt6323-keys"
        },
 };
 
@@ -71,7 +86,12 @@ static const struct mfd_cell mt6397_devs[] = {
        }, {
                .name = "mt6397-pinctrl",
                .of_compatible = "mediatek,mt6397-pinctrl",
-       },
+       }, {
+               .name = "mtk-pmic-keys",
+               .num_resources = ARRAY_SIZE(mt6397_keys_resources),
+               .resources = mt6397_keys_resources,
+               .of_compatible = "mediatek,mt6397-keys"
+       }
 };
 
 static void mt6397_irq_lock(struct irq_data *data)
@@ -289,7 +309,7 @@ static int mt6397_probe(struct platform_device *pdev)
 
                ret = devm_mfd_add_devices(&pdev->dev, -1, mt6323_devs,
                                           ARRAY_SIZE(mt6323_devs), NULL,
-                                          0, NULL);
+                                          0, pmic->irq_domain);
                break;
 
        case MT6397_CID_CODE:
@@ -304,7 +324,7 @@ static int mt6397_probe(struct platform_device *pdev)
 
                ret = devm_mfd_add_devices(&pdev->dev, -1, mt6397_devs,
                                           ARRAY_SIZE(mt6397_devs), NULL,
-                                          0, NULL);
+                                          0, pmic->irq_domain);
                break;
 
        default:
index 7aab376ecb848e1d4a95ed2e76d9782c7c60693a..e11ab12fbdf27228f7d003a542a61321ba3ca30b 100644 (file)
@@ -153,27 +153,6 @@ static const char * const port_modes[] = {
        [OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM]     = "ohci-tll-2pin-dpdm",
 };
 
-/**
- * omap_usbhs_get_dt_port_mode - Get the 'enum usbhs_omap_port_mode'
- * from the port mode string.
- * @mode: The port mode string, usually obtained from device tree.
- *
- * The function returns the 'enum usbhs_omap_port_mode' that matches the
- * provided port mode string as per the port_modes table.
- * If no match is found it returns -ENODEV
- */
-static int omap_usbhs_get_dt_port_mode(const char *mode)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(port_modes); i++) {
-               if (!strcmp(mode, port_modes[i]))
-                       return i;
-       }
-
-       return -ENODEV;
-}
-
 static struct platform_device *omap_usbhs_alloc_child(const char *name,
                        struct resource *res, int num_resources, void *pdata,
                        size_t pdata_size, struct device *dev)
@@ -529,7 +508,8 @@ static int usbhs_omap_get_dt_pdata(struct device *dev,
                if (ret < 0)
                        continue;
 
-               ret = omap_usbhs_get_dt_port_mode(mode);
+               /* get 'enum usbhs_omap_port_mode' from port mode string */
+               ret = match_string(port_modes, ARRAY_SIZE(port_modes), mode);
                if (ret < 0) {
                        dev_warn(dev, "Invalid port%d-mode \"%s\" in device tree\n",
                                        i, mode);
index 44a5d66314c6ec2a494bd0915838c2b72a7f4e6b..446713dbee27aa2852079bf3370562a8a92fcc51 100644 (file)
                                         (x) != OMAP_EHCI_PORT_MODE_PHY)
 
 struct usbtll_omap {
-       int                                     nch;    /* num. of channels */
-       struct clk                              **ch_clk;
-       void __iomem                            *base;
+       void __iomem    *base;
+       int             nch;            /* num. of channels */
+       struct clk      *ch_clk[0];     /* must be the last member */
 };
 
 /*-------------------------------------------------------------------------*/
@@ -216,53 +216,49 @@ static int usbtll_omap_probe(struct platform_device *pdev)
        struct device                           *dev =  &pdev->dev;
        struct resource                         *res;
        struct usbtll_omap                      *tll;
-       int                                     ret = 0;
-       int                                     i, ver;
+       void __iomem                            *base;
+       int                                     i, nch, ver;
 
        dev_dbg(dev, "starting TI HSUSB TLL Controller\n");
 
-       tll = devm_kzalloc(dev, sizeof(struct usbtll_omap), GFP_KERNEL);
-       if (!tll) {
-               dev_err(dev, "Memory allocation failed\n");
-               return -ENOMEM;
-       }
-
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       tll->base = devm_ioremap_resource(dev, res);
-       if (IS_ERR(tll->base))
-               return PTR_ERR(tll->base);
+       base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(base))
+               return PTR_ERR(base);
 
-       platform_set_drvdata(pdev, tll);
        pm_runtime_enable(dev);
        pm_runtime_get_sync(dev);
 
-       ver =  usbtll_read(tll->base, OMAP_USBTLL_REVISION);
+       ver = usbtll_read(base, OMAP_USBTLL_REVISION);
        switch (ver) {
        case OMAP_USBTLL_REV1:
        case OMAP_USBTLL_REV4:
-               tll->nch = OMAP_TLL_CHANNEL_COUNT;
+               nch = OMAP_TLL_CHANNEL_COUNT;
                break;
        case OMAP_USBTLL_REV2:
        case OMAP_USBTLL_REV3:
-               tll->nch = OMAP_REV2_TLL_CHANNEL_COUNT;
+               nch = OMAP_REV2_TLL_CHANNEL_COUNT;
                break;
        default:
-               tll->nch = OMAP_TLL_CHANNEL_COUNT;
-               dev_dbg(dev,
-                "USB TLL Rev : 0x%x not recognized, assuming %d channels\n",
-                       ver, tll->nch);
+               nch = OMAP_TLL_CHANNEL_COUNT;
+               dev_dbg(dev, "rev 0x%x not recognized, assuming %d channels\n",
+                       ver, nch);
                break;
        }
 
-       tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk *) * tll->nch,
-                                               GFP_KERNEL);
-       if (!tll->ch_clk) {
-               ret = -ENOMEM;
-               dev_err(dev, "Couldn't allocate memory for channel clocks\n");
-               goto err_clk_alloc;
+       tll = devm_kzalloc(dev, sizeof(*tll) + sizeof(tll->ch_clk[nch]),
+                          GFP_KERNEL);
+       if (!tll) {
+               pm_runtime_put_sync(dev);
+               pm_runtime_disable(dev);
+               return -ENOMEM;
        }
 
-       for (i = 0; i < tll->nch; i++) {
+       tll->base = base;
+       tll->nch = nch;
+       platform_set_drvdata(pdev, tll);
+
+       for (i = 0; i < nch; i++) {
                char clkname[] = "usb_tll_hs_usb_chx_clk";
 
                snprintf(clkname, sizeof(clkname),
@@ -282,12 +278,6 @@ static int usbtll_omap_probe(struct platform_device *pdev)
        spin_unlock(&tll_lock);
 
        return 0;
-
-err_clk_alloc:
-       pm_runtime_put_sync(dev);
-       pm_runtime_disable(dev);
-
-       return ret;
 }
 
 /**
index f952dff6765f7d18b373e0a6dbb32c3fc103cf01..0d2a88d53eeda51f3adbb4114b819772bd644258 100644 (file)
@@ -242,8 +242,10 @@ static int pcf50633_probe(struct i2c_client *client,
 
        for (i = 0; i < PCF50633_NUM_REGULATORS; i++) {
                pdev = platform_device_alloc("pcf50633-regulator", i);
-               if (!pdev)
-                       return -ENOMEM;
+               if (!pdev) {
+                       ret = -ENOMEM;
+                       goto err2;
+               }
 
                pdev->dev.parent = pcf->dev;
                ret = platform_device_add_data(pdev, &pdata->reg_init_data[i],
@@ -269,6 +271,7 @@ static int pcf50633_probe(struct i2c_client *client,
 
 err:
        platform_device_put(pdev);
+err2:
        for (j = 0; j < i; j++)
                platform_device_put(pcf->regulator_pdev[j]);
 
index 2022bdfa7ab4221a544f3222217678671712bca7..e2e95de649a47c239eeaeb23b522011f442fa640 100644 (file)
@@ -39,6 +39,9 @@
 #define PM8916_SUBTYPE         0x0b
 #define PM8004_SUBTYPE         0x0c
 #define PM8909_SUBTYPE         0x0d
+#define PM8998_SUBTYPE         0x14
+#define PMI8998_SUBTYPE                0x15
+#define PM8005_SUBTYPE         0x18
 
 static const struct of_device_id pmic_spmi_id_table[] = {
        { .compatible = "qcom,spmi-pmic", .data = (void *)COMMON_SUBTYPE },
@@ -55,6 +58,9 @@ static const struct of_device_id pmic_spmi_id_table[] = {
        { .compatible = "qcom,pm8916",    .data = (void *)PM8916_SUBTYPE },
        { .compatible = "qcom,pm8004",    .data = (void *)PM8004_SUBTYPE },
        { .compatible = "qcom,pm8909",    .data = (void *)PM8909_SUBTYPE },
+       { .compatible = "qcom,pm8998",    .data = (void *)PM8998_SUBTYPE },
+       { .compatible = "qcom,pmi8998",   .data = (void *)PMI8998_SUBTYPE },
+       { .compatible = "qcom,pm8005",    .data = (void *)PM8005_SUBTYPE },
        { }
 };
 
index 5c858e784a897874b969d65aca1354397bfb1761..36dcd98977d6da6add1075b19376fe8ab562e936 100644 (file)
@@ -45,7 +45,9 @@
 #define RAVE_SP_DLE                    0x10
 
 #define RAVE_SP_MAX_DATA_SIZE          64
-#define RAVE_SP_CHECKSUM_SIZE          2  /* Worst case scenario on RDU2 */
+#define RAVE_SP_CHECKSUM_8B2C          1
+#define RAVE_SP_CHECKSUM_CCITT         2
+#define RAVE_SP_CHECKSUM_SIZE          RAVE_SP_CHECKSUM_CCITT
 /*
  * We don't store STX, ETX and unescaped bytes, so Rx is only
  * DATA + CSUM
@@ -160,6 +162,8 @@ struct rave_sp_variant {
  * @variant:                   Device variant specific information
  * @event_notifier_list:       Input event notification chain
  *
+ * @part_number_firmware:      Firmware version
+ * @part_number_bootloader:    Bootloader version
  */
 struct rave_sp {
        struct serdev_device *serdev;
@@ -171,8 +175,40 @@ struct rave_sp {
 
        const struct rave_sp_variant *variant;
        struct blocking_notifier_head event_notifier_list;
+
+       const char *part_number_firmware;
+       const char *part_number_bootloader;
 };
 
+struct rave_sp_version {
+       u8     hardware;
+       __le16 major;
+       u8     minor;
+       u8     letter[2];
+} __packed;
+
+struct rave_sp_status {
+       struct rave_sp_version bootloader_version;
+       struct rave_sp_version firmware_version;
+       u16 rdu_eeprom_flag;
+       u16 dds_eeprom_flag;
+       u8  pic_flag;
+       u8  orientation;
+       u32 etc;
+       s16 temp[2];
+       u8  backlight_current[3];
+       u8  dip_switch;
+       u8  host_interrupt;
+       u16 voltage_28;
+       u8  i2c_device_status;
+       u8  power_status;
+       u8  general_status;
+       u8  deprecated1;
+       u8  power_led_status;
+       u8  deprecated2;
+       u8  periph_power_shutoff;
+} __packed;
+
 static bool rave_sp_id_is_event(u8 code)
 {
        return (code & 0xF0) == RAVE_SP_EVNT_BASE;
@@ -275,8 +311,8 @@ static int rave_sp_write(struct rave_sp *sp, const u8 *data, u8 data_size)
 
        length = dest - frame;
 
-       print_hex_dump(KERN_DEBUG, "rave-sp tx: ", DUMP_PREFIX_NONE,
-                      16, 1, frame, length, false);
+       print_hex_dump_debug("rave-sp tx: ", DUMP_PREFIX_NONE,
+                            16, 1, frame, length, false);
 
        return serdev_device_write(sp->serdev, frame, length, HZ);
 }
@@ -415,10 +451,15 @@ static void rave_sp_receive_frame(struct rave_sp *sp,
        const size_t payload_length  = length - checksum_length;
        const u8 *crc_reported       = &data[payload_length];
        struct device *dev           = &sp->serdev->dev;
-       u8 crc_calculated[checksum_length];
+       u8 crc_calculated[RAVE_SP_CHECKSUM_SIZE];
+
+       if (unlikely(checksum_length > sizeof(crc_calculated))) {
+               dev_warn(dev, "Checksum too long, dropping\n");
+               return;
+       }
 
-       print_hex_dump(KERN_DEBUG, "rave-sp rx: ", DUMP_PREFIX_NONE,
-                      16, 1, data, length, false);
+       print_hex_dump_debug("rave-sp rx: ", DUMP_PREFIX_NONE,
+                            16, 1, data, length, false);
 
        if (unlikely(length <= checksum_length)) {
                dev_warn(dev, "Dropping short frame\n");
@@ -512,8 +553,6 @@ static int rave_sp_receive_buf(struct serdev_device *serdev,
                        /* FALLTHROUGH */
 
                case RAVE_SP_EXPECT_ESCAPED_DATA:
-                       deframer->data[deframer->length++] = byte;
-
                        if (deframer->length == sizeof(deframer->data)) {
                                dev_warn(dev, "Bad frame: Too long\n");
                                /*
@@ -528,6 +567,8 @@ static int rave_sp_receive_buf(struct serdev_device *serdev,
                                goto reset_framer;
                        }
 
+                       deframer->data[deframer->length++] = byte;
+
                        /*
                         * We've extracted out special byte, now we
                         * can go back to regular data collecting
@@ -609,6 +650,52 @@ static int rave_sp_default_cmd_translate(enum rave_sp_command command)
        }
 }
 
+static const char *devm_rave_sp_version(struct device *dev,
+                                       struct rave_sp_version *version)
+{
+       /*
+        * NOTE: The format string below uses %02d to display u16
+        * intentionally for the sake of backwards compatibility with
+        * legacy software.
+        */
+       return devm_kasprintf(dev, GFP_KERNEL, "%02d%02d%02d.%c%c\n",
+                             version->hardware,
+                             le16_to_cpu(version->major),
+                             version->minor,
+                             version->letter[0],
+                             version->letter[1]);
+}
+
+static int rave_sp_get_status(struct rave_sp *sp)
+{
+       struct device *dev = &sp->serdev->dev;
+       u8 cmd[] = {
+               [0] = RAVE_SP_CMD_STATUS,
+               [1] = 0
+       };
+       struct rave_sp_status status;
+       const char *version;
+       int ret;
+
+       ret = rave_sp_exec(sp, cmd, sizeof(cmd), &status, sizeof(status));
+       if (ret)
+               return ret;
+
+       version = devm_rave_sp_version(dev, &status.firmware_version);
+       if (!version)
+               return -ENOMEM;
+
+       sp->part_number_firmware = version;
+
+       version = devm_rave_sp_version(dev, &status.bootloader_version);
+       if (!version)
+               return -ENOMEM;
+
+       sp->part_number_bootloader = version;
+
+       return 0;
+}
+
 static const struct rave_sp_checksum rave_sp_checksum_8b2c = {
        .length     = 1,
        .subroutine = csum_8b2c,
@@ -657,6 +744,7 @@ static const struct serdev_device_ops rave_sp_serdev_device_ops = {
 static int rave_sp_probe(struct serdev_device *serdev)
 {
        struct device *dev = &serdev->dev;
+       const char *unknown = "unknown\n";
        struct rave_sp *sp;
        u32 baud;
        int ret;
@@ -689,6 +777,20 @@ static int rave_sp_probe(struct serdev_device *serdev)
 
        serdev_device_set_baudrate(serdev, baud);
 
+       ret = rave_sp_get_status(sp);
+       if (ret) {
+               dev_warn(dev, "Failed to get firmware status: %d\n", ret);
+               sp->part_number_firmware   = unknown;
+               sp->part_number_bootloader = unknown;
+       }
+
+       /*
+        * Those strings already have a \n embedded, so there's no
+        * need to have one in format string.
+        */
+       dev_info(dev, "Firmware version: %s",   sp->part_number_firmware);
+       dev_info(dev, "Bootloader version: %s", sp->part_number_bootloader);
+
        return devm_of_platform_populate(dev);
 }
 
index d12243d5ecb809b064be189d9db9b22e281336e0..fd46de02b7154bddb42bf225e05245d724640b8f 100644 (file)
@@ -258,11 +258,9 @@ static int rc5t583_i2c_probe(struct i2c_client *i2c,
                return -EINVAL;
        }
 
-       rc5t583 = devm_kzalloc(&i2c->dev, sizeof(struct rc5t583), GFP_KERNEL);
-       if (!rc5t583) {
-               dev_err(&i2c->dev, "Memory allocation failed\n");
+       rc5t583 = devm_kzalloc(&i2c->dev, sizeof(*rc5t583), GFP_KERNEL);
+       if (!rc5t583)
                return -ENOMEM;
-       }
 
        rc5t583->dev = &i2c->dev;
        i2c_set_clientdata(i2c, rc5t583);
index e6a3d999a376a68877933b6e3d7b8403e299e1d4..2c5ec93333c32bc5b69b92c79bff2d79117d27d6 100644 (file)
@@ -697,11 +697,9 @@ static int si476x_core_probe(struct i2c_client *client,
        int              cell_num;
 
        core = devm_kzalloc(&client->dev, sizeof(*core), GFP_KERNEL);
-       if (!core) {
-               dev_err(&client->dev,
-                       "failed to allocate 'struct si476x_core'\n");
+       if (!core)
                return -ENOMEM;
-       }
+
        core->client = client;
 
        core->regmap = devm_regmap_init_si476x(core);
index ad774161a22d272eaff29ed10e6681e640ca34fb..2a87b0d2f21ff034ee8f1f7ddd4684b1bb1c300e 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/device.h>
 #include <linux/platform_device.h>
 #include <linux/pci.h>
-#include <linux/i2c-gpio.h>
+#include <linux/platform_data/i2c-gpio.h>
 #include <linux/gpio/machine.h>
 #include <linux/slab.h>
 
@@ -1050,13 +1050,13 @@ static int sm501_register_gpio(struct sm501_devdata *sm)
        spin_lock_init(&gpio->lock);
 
        gpio->regs_res = request_mem_region(iobase, 0x20, "sm501-gpio");
-       if (gpio->regs_res == NULL) {
+       if (!gpio->regs_res) {
                dev_err(sm->dev, "gpio: failed to request region\n");
                return -ENXIO;
        }
 
        gpio->regs = ioremap(iobase, 0x20);
-       if (gpio->regs == NULL) {
+       if (!gpio->regs) {
                dev_err(sm->dev, "gpio: failed to remap registers\n");
                ret = -ENXIO;
                goto err_claimed;
@@ -1358,7 +1358,7 @@ static int sm501_init_dev(struct sm501_devdata *sm)
                        sm501_register_gpio(sm);
        }
 
-       if (pdata && pdata->gpio_i2c != NULL && pdata->gpio_i2c_nr > 0) {
+       if (pdata && pdata->gpio_i2c && pdata->gpio_i2c_nr > 0) {
                if (!sm501_gpio_isregistered(sm))
                        dev_err(sm->dev, "no gpio available for i2c gpio.\n");
                else
@@ -1383,9 +1383,8 @@ static int sm501_plat_probe(struct platform_device *dev)
        struct sm501_devdata *sm;
        int ret;
 
-       sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL);
-       if (sm == NULL) {
-               dev_err(&dev->dev, "no memory for device data\n");
+       sm = kzalloc(sizeof(*sm), GFP_KERNEL);
+       if (!sm) {
                ret = -ENOMEM;
                goto err1;
        }
@@ -1403,8 +1402,7 @@ static int sm501_plat_probe(struct platform_device *dev)
 
        sm->io_res = platform_get_resource(dev, IORESOURCE_MEM, 1);
        sm->mem_res = platform_get_resource(dev, IORESOURCE_MEM, 0);
-
-       if (sm->io_res == NULL || sm->mem_res == NULL) {
+       if (!sm->io_res || !sm->mem_res) {
                dev_err(&dev->dev, "failed to get IO resource\n");
                ret = -ENOENT;
                goto err_res;
@@ -1412,8 +1410,7 @@ static int sm501_plat_probe(struct platform_device *dev)
 
        sm->regs_claim = request_mem_region(sm->io_res->start,
                                            0x100, "sm501");
-
-       if (sm->regs_claim == NULL) {
+       if (!sm->regs_claim) {
                dev_err(&dev->dev, "cannot claim registers\n");
                ret = -EBUSY;
                goto err_res;
@@ -1422,8 +1419,7 @@ static int sm501_plat_probe(struct platform_device *dev)
        platform_set_drvdata(dev, sm);
 
        sm->regs = ioremap(sm->io_res->start, resource_size(sm->io_res));
-
-       if (sm->regs == NULL) {
+       if (!sm->regs) {
                dev_err(&dev->dev, "cannot remap registers\n");
                ret = -EIO;
                goto err_claim;
@@ -1449,7 +1445,7 @@ static void sm501_set_power(struct sm501_devdata *sm, int on)
 {
        struct sm501_platdata *pd = sm->platdata;
 
-       if (pd == NULL)
+       if (!pd)
                return;
 
        if (pd->get_power) {
@@ -1573,9 +1569,8 @@ static int sm501_pci_probe(struct pci_dev *dev,
        struct sm501_devdata *sm;
        int err;
 
-       sm = kzalloc(sizeof(struct sm501_devdata), GFP_KERNEL);
-       if (sm == NULL) {
-               dev_err(&dev->dev, "no memory for device data\n");
+       sm = kzalloc(sizeof(*sm), GFP_KERNEL);
+       if (!sm) {
                err = -ENOMEM;
                goto err1;
        }
@@ -1626,15 +1621,14 @@ static int sm501_pci_probe(struct pci_dev *dev,
 
        sm->regs_claim = request_mem_region(sm->io_res->start,
                                            0x100, "sm501");
-       if (sm->regs_claim == NULL) {
+       if (!sm->regs_claim) {
                dev_err(&dev->dev, "cannot claim registers\n");
                err= -EBUSY;
                goto err3;
        }
 
        sm->regs = pci_ioremap_bar(dev, 1);
-
-       if (sm->regs == NULL) {
+       if (!sm->regs) {
                dev_err(&dev->dev, "cannot remap registers\n");
                err = -EIO;
                goto err4;
index 93a8297de52aab6a54acfbfe511a22b6273de1a1..57b792eb58fd2cd491b81ed3d7385174db26e99b 100644 (file)
@@ -37,12 +37,9 @@ static int smsc_i2c_probe(struct i2c_client *i2c,
        int devid, rev, venid_l, venid_h;
        int ret;
 
-       smsc = devm_kzalloc(&i2c->dev, sizeof(struct smsc),
-                               GFP_KERNEL);
-       if (!smsc) {
-               dev_err(&i2c->dev, "smsc mfd driver memory allocation failed\n");
+       smsc = devm_kzalloc(&i2c->dev, sizeof(*smsc), GFP_KERNEL);
+       if (!smsc)
                return -ENOMEM;
-       }
 
        smsc->regmap = devm_regmap_init_i2c(i2c, &smsc_regmap_config);
        if (IS_ERR(smsc->regmap))
index 56a4782f0569cde0db94bc7d64d49cc997e4bfc7..69df27769c2136e817d3baf575269c59902752ac 100644 (file)
@@ -111,6 +111,9 @@ static const struct mfd_cell sprd_pmic_devs[] = {
        }, {
                .name = "sc27xx-poweroff",
                .of_compatible = "sprd,sc27xx-poweroff",
+       }, {
+               .name = "sc27xx-syscon",
+               .of_compatible = "sprd,sc27xx-syscon",
        },
 };
 
@@ -196,8 +199,9 @@ static int sprd_pmic_probe(struct spi_device *spi)
        ddata->irq_chip.num_irqs = pdata->num_irqs;
        ddata->irq_chip.mask_invert = true;
 
-       ddata->irqs = devm_kzalloc(&spi->dev, sizeof(struct regmap_irq) *
-                                  pdata->num_irqs, GFP_KERNEL);
+       ddata->irqs = devm_kcalloc(&spi->dev,
+                                  pdata->num_irqs, sizeof(struct regmap_irq),
+                                  GFP_KERNEL);
        if (!ddata->irqs)
                return -ENOMEM;
 
index 1d347e5dfa7938151a10d3891f4e36c17bf93fcf..efcd4b980c94c271e585580d26da8035f5318644 100644 (file)
  * Author: Benjamin Gaignard <benjamin.gaignard@st.com>
  */
 
+#include <linux/bitfield.h>
 #include <linux/mfd/stm32-timers.h>
 #include <linux/module.h>
 #include <linux/of_platform.h>
 #include <linux/reset.h>
 
+#define STM32_TIMERS_MAX_REGISTERS     0x3fc
+
+/* DIER register DMA enable bits */
+static const u32 stm32_timers_dier_dmaen[STM32_TIMERS_MAX_DMAS] = {
+       TIM_DIER_CC1DE,
+       TIM_DIER_CC2DE,
+       TIM_DIER_CC3DE,
+       TIM_DIER_CC4DE,
+       TIM_DIER_UIE,
+       TIM_DIER_TDE,
+       TIM_DIER_COMDE
+};
+
+static void stm32_timers_dma_done(void *p)
+{
+       struct stm32_timers_dma *dma = p;
+       struct dma_tx_state state;
+       enum dma_status status;
+
+       status = dmaengine_tx_status(dma->chan, dma->chan->cookie, &state);
+       if (status == DMA_COMPLETE)
+               complete(&dma->completion);
+}
+
+/**
+ * stm32_timers_dma_burst_read - Read from timers registers using DMA.
+ *
+ * Read from STM32 timers registers using DMA on a single event.
+ * @dev: reference to stm32_timers MFD device
+ * @buf: DMA'able destination buffer
+ * @id: stm32_timers_dmas event identifier (ch[1..4], up, trig or com)
+ * @reg: registers start offset for DMA to read from (like CCRx for capture)
+ * @num_reg: number of registers to read upon each DMA request, starting @reg.
+ * @bursts: number of bursts to read (e.g. like two for pwm period capture)
+ * @tmo_ms: timeout (milliseconds)
+ */
+int stm32_timers_dma_burst_read(struct device *dev, u32 *buf,
+                               enum stm32_timers_dmas id, u32 reg,
+                               unsigned int num_reg, unsigned int bursts,
+                               unsigned long tmo_ms)
+{
+       struct stm32_timers *ddata = dev_get_drvdata(dev);
+       unsigned long timeout = msecs_to_jiffies(tmo_ms);
+       struct regmap *regmap = ddata->regmap;
+       struct stm32_timers_dma *dma = &ddata->dma;
+       size_t len = num_reg * bursts * sizeof(u32);
+       struct dma_async_tx_descriptor *desc;
+       struct dma_slave_config config;
+       dma_cookie_t cookie;
+       dma_addr_t dma_buf;
+       u32 dbl, dba;
+       long err;
+       int ret;
+
+       /* Sanity check */
+       if (id < STM32_TIMERS_DMA_CH1 || id >= STM32_TIMERS_MAX_DMAS)
+               return -EINVAL;
+
+       if (!num_reg || !bursts || reg > STM32_TIMERS_MAX_REGISTERS ||
+           (reg + num_reg * sizeof(u32)) > STM32_TIMERS_MAX_REGISTERS)
+               return -EINVAL;
+
+       if (!dma->chans[id])
+               return -ENODEV;
+       mutex_lock(&dma->lock);
+
+       /* Select DMA channel in use */
+       dma->chan = dma->chans[id];
+       dma_buf = dma_map_single(dev, buf, len, DMA_FROM_DEVICE);
+       if (dma_mapping_error(dev, dma_buf)) {
+               ret = -ENOMEM;
+               goto unlock;
+       }
+
+       /* Prepare DMA read from timer registers, using DMA burst mode */
+       memset(&config, 0, sizeof(config));
+       config.src_addr = (dma_addr_t)dma->phys_base + TIM_DMAR;
+       config.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES;
+       ret = dmaengine_slave_config(dma->chan, &config);
+       if (ret)
+               goto unmap;
+
+       desc = dmaengine_prep_slave_single(dma->chan, dma_buf, len,
+                                          DMA_DEV_TO_MEM, DMA_PREP_INTERRUPT);
+       if (!desc) {
+               ret = -EBUSY;
+               goto unmap;
+       }
+
+       desc->callback = stm32_timers_dma_done;
+       desc->callback_param = dma;
+       cookie = dmaengine_submit(desc);
+       ret = dma_submit_error(cookie);
+       if (ret)
+               goto dma_term;
+
+       reinit_completion(&dma->completion);
+       dma_async_issue_pending(dma->chan);
+
+       /* Setup and enable timer DMA burst mode */
+       dbl = FIELD_PREP(TIM_DCR_DBL, bursts - 1);
+       dba = FIELD_PREP(TIM_DCR_DBA, reg >> 2);
+       ret = regmap_write(regmap, TIM_DCR, dbl | dba);
+       if (ret)
+               goto dma_term;
+
+       /* Clear pending flags before enabling DMA request */
+       ret = regmap_write(regmap, TIM_SR, 0);
+       if (ret)
+               goto dcr_clr;
+
+       ret = regmap_update_bits(regmap, TIM_DIER, stm32_timers_dier_dmaen[id],
+                                stm32_timers_dier_dmaen[id]);
+       if (ret)
+               goto dcr_clr;
+
+       err = wait_for_completion_interruptible_timeout(&dma->completion,
+                                                       timeout);
+       if (err == 0)
+               ret = -ETIMEDOUT;
+       else if (err < 0)
+               ret = err;
+
+       regmap_update_bits(regmap, TIM_DIER, stm32_timers_dier_dmaen[id], 0);
+       regmap_write(regmap, TIM_SR, 0);
+dcr_clr:
+       regmap_write(regmap, TIM_DCR, 0);
+dma_term:
+       dmaengine_terminate_all(dma->chan);
+unmap:
+       dma_unmap_single(dev, dma_buf, len, DMA_FROM_DEVICE);
+unlock:
+       dma->chan = NULL;
+       mutex_unlock(&dma->lock);
+
+       return ret;
+}
+EXPORT_SYMBOL_GPL(stm32_timers_dma_burst_read);
+
 static const struct regmap_config stm32_timers_regmap_cfg = {
        .reg_bits = 32,
        .val_bits = 32,
        .reg_stride = sizeof(u32),
-       .max_register = 0x3fc,
+       .max_register = STM32_TIMERS_MAX_REGISTERS,
 };
 
 static void stm32_timers_get_arr_size(struct stm32_timers *ddata)
@@ -27,12 +167,45 @@ static void stm32_timers_get_arr_size(struct stm32_timers *ddata)
        regmap_write(ddata->regmap, TIM_ARR, 0x0);
 }
 
+static void stm32_timers_dma_probe(struct device *dev,
+                                  struct stm32_timers *ddata)
+{
+       int i;
+       char name[4];
+
+       init_completion(&ddata->dma.completion);
+       mutex_init(&ddata->dma.lock);
+
+       /* Optional DMA support: get valid DMA channel(s) or NULL */
+       for (i = STM32_TIMERS_DMA_CH1; i <= STM32_TIMERS_DMA_CH4; i++) {
+               snprintf(name, ARRAY_SIZE(name), "ch%1d", i + 1);
+               ddata->dma.chans[i] = dma_request_slave_channel(dev, name);
+       }
+       ddata->dma.chans[STM32_TIMERS_DMA_UP] =
+               dma_request_slave_channel(dev, "up");
+       ddata->dma.chans[STM32_TIMERS_DMA_TRIG] =
+               dma_request_slave_channel(dev, "trig");
+       ddata->dma.chans[STM32_TIMERS_DMA_COM] =
+               dma_request_slave_channel(dev, "com");
+}
+
+static void stm32_timers_dma_remove(struct device *dev,
+                                   struct stm32_timers *ddata)
+{
+       int i;
+
+       for (i = STM32_TIMERS_DMA_CH1; i < STM32_TIMERS_MAX_DMAS; i++)
+               if (ddata->dma.chans[i])
+                       dma_release_channel(ddata->dma.chans[i]);
+}
+
 static int stm32_timers_probe(struct platform_device *pdev)
 {
        struct device *dev = &pdev->dev;
        struct stm32_timers *ddata;
        struct resource *res;
        void __iomem *mmio;
+       int ret;
 
        ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL);
        if (!ddata)
@@ -43,6 +216,9 @@ static int stm32_timers_probe(struct platform_device *pdev)
        if (IS_ERR(mmio))
                return PTR_ERR(mmio);
 
+       /* Timer physical addr for DMA */
+       ddata->dma.phys_base = res->start;
+
        ddata->regmap = devm_regmap_init_mmio_clk(dev, "int", mmio,
                                                  &stm32_timers_regmap_cfg);
        if (IS_ERR(ddata->regmap))
@@ -54,9 +230,29 @@ static int stm32_timers_probe(struct platform_device *pdev)
 
        stm32_timers_get_arr_size(ddata);
 
+       stm32_timers_dma_probe(dev, ddata);
+
        platform_set_drvdata(pdev, ddata);
 
-       return devm_of_platform_populate(&pdev->dev);
+       ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
+       if (ret)
+               stm32_timers_dma_remove(dev, ddata);
+
+       return ret;
+}
+
+static int stm32_timers_remove(struct platform_device *pdev)
+{
+       struct stm32_timers *ddata = platform_get_drvdata(pdev);
+
+       /*
+        * Don't use devm_ here: enfore of_platform_depopulate() happens before
+        * DMA are released, to avoid race on DMA.
+        */
+       of_platform_depopulate(&pdev->dev);
+       stm32_timers_dma_remove(&pdev->dev, ddata);
+
+       return 0;
 }
 
 static const struct of_device_id stm32_timers_of_match[] = {
@@ -67,6 +263,7 @@ MODULE_DEVICE_TABLE(of, stm32_timers_of_match);
 
 static struct platform_driver stm32_timers_driver = {
        .probe = stm32_timers_probe,
+       .remove = stm32_timers_remove,
        .driver = {
                .name = "stm32-timers",
                .of_match_table = stm32_timers_of_match,
index 7eaa40bc703fdfc0500a7df2905543a2efd806ac..b6d05cd934e66e1ad32b7ec4a41136d65186e8b6 100644 (file)
@@ -106,9 +106,11 @@ static struct syscon *of_syscon_register(struct device_node *np)
                }
        }
 
+       syscon_config.name = of_node_full_name(np);
        syscon_config.reg_stride = reg_io_width;
        syscon_config.val_bits = reg_io_width * 8;
        syscon_config.max_register = resource_size(&res) - reg_io_width;
+       syscon_config.name = of_node_full_name(np);
 
        regmap = regmap_init_mmio(NULL, base, &syscon_config);
        if (IS_ERR(regmap)) {
index 3cd958a31f36692910bd04827260e59c9c8a5799..47012c0899cd36b4ed919ae9b8d8301e6eb17c91 100644 (file)
@@ -169,10 +169,9 @@ static     int ti_tscadc_probe(struct platform_device *pdev)
 
        /* Allocate memory for device */
        tscadc = devm_kzalloc(&pdev->dev, sizeof(*tscadc), GFP_KERNEL);
-       if (!tscadc) {
-               dev_err(&pdev->dev, "failed to allocate memory.\n");
+       if (!tscadc)
                return -ENOMEM;
-       }
+
        tscadc->dev = &pdev->dev;
 
        err = platform_get_irq(pdev, 0);
index cd4a6d7d6750e8dabcb48518afc20518f471bb8c..436e34705af1a1b9e7fb6af8a267f9e674208b26 100644 (file)
@@ -30,8 +30,8 @@
 #include <linux/timb_gpio.h>
 
 #include <linux/i2c.h>
-#include <linux/i2c-ocores.h>
-#include <linux/i2c-xiic.h>
+#include <linux/platform_data/i2c-ocores.h>
+#include <linux/platform_data/i2c-xiic.h>
 
 #include <linux/spi/spi.h>
 #include <linux/spi/xilinx_spi.h>
@@ -707,8 +707,8 @@ static int timb_probe(struct pci_dev *dev,
                goto err_config;
        }
 
-       msix_entries = kzalloc(TIMBERDALE_NR_IRQS * sizeof(*msix_entries),
-               GFP_KERNEL);
+       msix_entries = kcalloc(TIMBERDALE_NR_IRQS, sizeof(*msix_entries),
+                              GFP_KERNEL);
        if (!msix_entries)
                goto err_config;
 
@@ -777,7 +777,7 @@ static int timb_probe(struct pci_dev *dev,
                        &dev->resource[0], msix_entries[0].vector, NULL);
                break;
        default:
-               dev_err(&dev->dev, "Uknown IP setup: %d.%d.%d\n",
+               dev_err(&dev->dev, "Unknown IP setup: %d.%d.%d\n",
                        priv->fw.major, priv->fw.minor, ip_setup);
                err = -ENODEV;
                goto err_mfd;
index d7ec318c40c30f519ed4c6a2608d061ec79d4e9d..f13e4cd06e8916e2da5c4bae75817f6b49acc2df 100644 (file)
@@ -192,10 +192,8 @@ static int tps65090_i2c_probe(struct i2c_client *client,
                irq_base = pdata->irq_base;
 
        tps65090 = devm_kzalloc(&client->dev, sizeof(*tps65090), GFP_KERNEL);
-       if (!tps65090) {
-               dev_err(&client->dev, "mem alloc for tps65090 failed\n");
+       if (!tps65090)
                return -ENOMEM;
-       }
 
        tps65090->dev = &client->dev;
        i2c_set_clientdata(client, tps65090);
index 5628a6b5b19becfb28e060de827cbfaef2c6a19d..b893797827410c25450abd76fa47581c5c09d4df 100644 (file)
@@ -423,10 +423,8 @@ static struct tps6586x_platform_data *tps6586x_parse_dt(struct i2c_client *clien
        struct tps6586x_platform_data *pdata;
 
        pdata = devm_kzalloc(&client->dev, sizeof(*pdata), GFP_KERNEL);
-       if (!pdata) {
-               dev_err(&client->dev, "Memory allocation failed\n");
+       if (!pdata)
                return NULL;
-       }
 
        pdata->num_subdevs = 0;
        pdata->subdevs = NULL;
index 8263605f6d2fa2b76eb36b4f1589eb5dba6b8b0b..bf16cbe6fd8886f8a83c0a8b30530e24ff477007 100644 (file)
@@ -229,7 +229,7 @@ static struct regmap_irq_chip tps65910_irq_chip = {
 static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
                    struct tps65910_platform_data *pdata)
 {
-       int ret = 0;
+       int ret;
        static struct regmap_irq_chip *tps6591x_irqs_chip;
 
        if (!irq) {
@@ -312,14 +312,14 @@ static int tps65910_ck32k_init(struct tps65910 *tps65910,
 static int tps65910_sleepinit(struct tps65910 *tps65910,
                struct tps65910_board *pmic_pdata)
 {
-       struct device *dev = NULL;
-       int ret = 0;
-
-       dev = tps65910->dev;
+       struct device *dev;
+       int ret;
 
        if (!pmic_pdata->en_dev_slp)
                return 0;
 
+       dev = tps65910->dev;
+
        /* enabling SLEEP device state */
        ret = tps65910_reg_set_bits(tps65910, TPS65910_DEVCTRL,
                                DEVCTRL_DEV_SLP_MASK);
@@ -383,7 +383,7 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
        struct tps65910_board *board_info;
        unsigned int prop;
        const struct of_device_id *match;
-       int ret = 0;
+       int ret;
 
        match = of_match_device(tps65910_of_match, &client->dev);
        if (!match) {
@@ -395,10 +395,8 @@ static struct tps65910_board *tps65910_parse_dt(struct i2c_client *client,
 
        board_info = devm_kzalloc(&client->dev, sizeof(*board_info),
                        GFP_KERNEL);
-       if (!board_info) {
-               dev_err(&client->dev, "Failed to allocate pdata\n");
+       if (!board_info)
                return NULL;
-       }
 
        ret = of_property_read_u32(np, "ti,vmbch-threshold", &prop);
        if (!ret)
@@ -462,7 +460,7 @@ static int tps65910_i2c_probe(struct i2c_client *i2c,
        struct tps65910_board *of_pmic_plat_data = NULL;
        struct tps65910_platform_data *init_data;
        unsigned long chip_id = id->driver_data;
-       int ret = 0;
+       int ret;
 
        pmic_plat_data = dev_get_platdata(&i2c->dev);
 
index c0789f81a1c5ac534876e1c30afad78789e24aa0..33591767fb9b53e1579b5feb00ff1b1d3e69629e 100644 (file)
@@ -22,9 +22,8 @@
 #include <linux/gpio.h>
 #include <linux/mfd/tps65910.h>
 
-#define COMP                                   0
-#define COMP1                                  1
-#define COMP2                                  2
+#define COMP1                                  0
+#define COMP2                                  1
 
 /* Comparator 1 voltage selection table in millivolts */
 static const u16 COMP_VSEL_TABLE[] = {
@@ -63,9 +62,6 @@ static int comp_threshold_set(struct tps65910 *tps65910, int id, int voltage)
        int ret;
        u8 index = 0, val;
 
-       if (id == COMP)
-               return 0;
-
        while (curr_voltage < tps_comp.uV_max) {
                curr_voltage = tps_comp.vsel_table[index];
                if (curr_voltage >= voltage)
@@ -78,7 +74,7 @@ static int comp_threshold_set(struct tps65910 *tps65910, int id, int voltage)
                return -EINVAL;
 
        val = index << 1;
-       ret = tps65910->write(tps65910, tps_comp.reg, 1, &val);
+       ret = tps65910_reg_write(tps65910, tps_comp.reg, val);
 
        return ret;
 }
@@ -86,13 +82,10 @@ static int comp_threshold_set(struct tps65910 *tps65910, int id, int voltage)
 static int comp_threshold_get(struct tps65910 *tps65910, int id)
 {
        struct comparator tps_comp = tps_comparators[id];
+       unsigned int val;
        int ret;
-       u8 val;
-
-       if (id == COMP)
-               return 0;
 
-       ret = tps65910->read(tps65910, tps_comp.reg, 1, &val);
+       ret = tps65910_reg_read(tps65910, tps_comp.reg, &val);
        if (ret < 0)
                return ret;
 
index 189efaea054cba87e1b485ad9273ebcd6439938a..a5981a79b29a87f9386049d3bd4f91786fe31da4 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * TPS68470 chip Parent driver
  *
@@ -8,15 +9,6 @@
  *     Tianshu Qiu <tian.shu.qiu@intel.com>
  *     Jian Xu Zheng <jian.xu.zheng@intel.com>
  *     Yuning Pu <yuning.pu@intel.com>
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- * kind, whether express or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #include <linux/acpi.h>
index 0812df3b0d472b287874d43b6544576c7cee0e9f..608c7f77830eea1d79a85c5a6abd6ef85bb23987 100644 (file)
@@ -431,10 +431,8 @@ static int tps80031_probe(struct i2c_client *client,
        }
 
        tps80031 = devm_kzalloc(&client->dev, sizeof(*tps80031), GFP_KERNEL);
-       if (!tps80031) {
-               dev_err(&client->dev, "Malloc failed for tps80031\n");
+       if (!tps80031)
                return -ENOMEM;
-       }
 
        for (i = 0; i < TPS80031_NUM_SLAVES; i++) {
                if (tps80031_slave_address[i] == client->addr)
index d3133a371e277f0bd8f20bcafa648c5f41ebf180..4be3d239da9ec8a2db40eea62f608f6559cff5a3 100644 (file)
@@ -1139,8 +1139,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
        }
 
        num_slaves = twl_get_num_slaves();
-       twl_priv->twl_modules = devm_kzalloc(&client->dev,
-                                        sizeof(struct twl_client) * num_slaves,
+       twl_priv->twl_modules = devm_kcalloc(&client->dev,
+                                        num_slaves,
+                                        sizeof(struct twl_client),
                                         GFP_KERNEL);
        if (!twl_priv->twl_modules) {
                status = -ENOMEM;
@@ -1177,7 +1178,7 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id)
        twl_priv->ready = true;
 
        /* setup clock framework */
-       clocks_init(&pdev->dev, pdata ? pdata->clock : NULL);
+       clocks_init(&client->dev, pdata ? pdata->clock : NULL);
 
        /* read TWL IDCODE Register */
        if (twl_class_is_4030()) {
index e3ec8dfa9f1ec0337a651d9239f6a19399bc163e..e939431ed10c5dab8484e95010385616a86217f8 100644 (file)
@@ -392,10 +392,8 @@ int twl6030_init_irq(struct device *dev, int irq_num)
        nr_irqs = TWL6030_NR_IRQS;
 
        twl6030_irq = devm_kzalloc(dev, sizeof(*twl6030_irq), GFP_KERNEL);
-       if (!twl6030_irq) {
-               dev_err(dev, "twl6030_irq: Memory allocation failed\n");
+       if (!twl6030_irq)
                return -ENOMEM;
-       }
 
        mask[0] = 0xFF;
        mask[1] = 0xFF;
index e6b3c70aeb22cc919e0fef9f0ba8ad04cd3b56fa..e9f61262d583f2ab4160d9887d0bb6684476c9ac 100644 (file)
@@ -59,10 +59,8 @@ static int vprbrd_probe(struct usb_interface *interface,
 
        /* allocate memory for our device state and initialize it */
        vb = kzalloc(sizeof(*vb), GFP_KERNEL);
-       if (vb == NULL) {
-               dev_err(&interface->dev, "Out of memory\n");
+       if (!vb)
                return -ENOMEM;
-       }
 
        mutex_init(&vb->lock);
 
index 953d0790ffd566e967058f7eeb640ff51377cf45..5d5888ee2966818e5b8e266ac41680344011b42b 100644 (file)
@@ -368,9 +368,10 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq)
                goto err;
        }
 
-       wm8994->supplies = devm_kzalloc(wm8994->dev,
-                                       sizeof(struct regulator_bulk_data) *
-                                       wm8994->num_supplies, GFP_KERNEL);
+       wm8994->supplies = devm_kcalloc(wm8994->dev,
+                                       wm8994->num_supplies,
+                                       sizeof(struct regulator_bulk_data),
+                                       GFP_KERNEL);
        if (!wm8994->supplies) {
                ret = -ENOMEM;
                goto err;
index 4141ee52a70b08484c7a50b6960eaeb71848021a..f5a8347f837f26d1af1627ea626f70a16176edd9 100644 (file)
@@ -278,7 +278,7 @@ static int wm97xx_ac97_probe(struct ac97_codec_device *adev)
 
        codec_pdata = &wm97xx->codec_pdata;
        codec_pdata->ac97 = wm97xx->ac97;
-       codec_pdata->batt_pdata = pdata->batt_pdata;
+       codec_pdata->batt_pdata = pdata ? pdata->batt_pdata : NULL;
 
        switch (adev->vendor_id) {
        case WM9705_VENDOR_ID:
index f53e217e963f57acdc6d707d9893da7729c5bad0..ef83a9078646fb5177f2a1da4b28eb03fdae4327 100644 (file)
@@ -304,13 +304,13 @@ static int altera_execute(struct altera_state *astate,
        if (sym_count <= 0)
                goto exit_done;
 
-       vars = kzalloc(sym_count * sizeof(long), GFP_KERNEL);
+       vars = kcalloc(sym_count, sizeof(long), GFP_KERNEL);
 
        if (vars == NULL)
                status = -ENOMEM;
 
        if (status == 0) {
-               var_size = kzalloc(sym_count * sizeof(s32), GFP_KERNEL);
+               var_size = kcalloc(sym_count, sizeof(s32), GFP_KERNEL);
 
                if (var_size == NULL)
                        status = -ENOMEM;
@@ -1136,7 +1136,7 @@ static int altera_execute(struct altera_state *astate,
                                /* Allocate a writable buffer for this array */
                                count = var_size[variable_id];
                                long_tmp = vars[variable_id];
-                               longptr_tmp = kzalloc(count * sizeof(long),
+                               longptr_tmp = kcalloc(count, sizeof(long),
                                                                GFP_KERNEL);
                                vars[variable_id] = (long)longptr_tmp;
 
index f58b4b6c79f22b42e9ab3fefd23c3eca3a7b07df..4644f16606a3bf7c6ce735cb3a587a073299ea15 100644 (file)
@@ -89,7 +89,7 @@ static ssize_t guest_collect_vpd(struct cxl *adapter, struct cxl_afu *afu,
                mod = 0;
        }
 
-       vpd_buf = kzalloc(entries * sizeof(unsigned long *), GFP_KERNEL);
+       vpd_buf = kcalloc(entries, sizeof(unsigned long *), GFP_KERNEL);
        if (!vpd_buf)
                return -ENOMEM;
 
index ec175ea5dfba1d6b16add78ba27f7116c08c7f30..aff181cd0bf26c7c0644aeeab2cde59664002387 100644 (file)
@@ -302,7 +302,7 @@ static int read_adapter_irq_config(struct cxl *adapter, struct device_node *np)
        if (nranges == 0 || (nranges * 2 * sizeof(int)) != len)
                return -EINVAL;
 
-       adapter->guest->irq_avail = kzalloc(nranges * sizeof(struct irq_avail),
+       adapter->guest->irq_avail = kcalloc(nranges, sizeof(struct irq_avail),
                                            GFP_KERNEL);
        if (adapter->guest->irq_avail == NULL)
                return -ENOMEM;
index 33053b0d1fdf65c2d590598cd361b7869e663522..f5cc517d113154106e7cef474782eacaf47b3952 100644 (file)
@@ -532,6 +532,45 @@ static int at24_get_pdata(struct device *dev, struct at24_platform_data *pdata)
        return 0;
 }
 
+static void at24_remove_dummy_clients(struct at24_data *at24)
+{
+       int i;
+
+       for (i = 1; i < at24->num_addresses; i++)
+               i2c_unregister_device(at24->client[i].client);
+}
+
+static int at24_make_dummy_client(struct at24_data *at24, unsigned int index,
+                                 struct regmap_config *regmap_config)
+{
+       struct i2c_client *base_client, *dummy_client;
+       unsigned short int addr;
+       struct regmap *regmap;
+       struct device *dev;
+
+       base_client = at24->client[0].client;
+       dev = &base_client->dev;
+       addr = base_client->addr + index;
+
+       dummy_client = i2c_new_dummy(base_client->adapter,
+                                    base_client->addr + index);
+       if (!dummy_client) {
+               dev_err(dev, "address 0x%02x unavailable\n", addr);
+               return -EADDRINUSE;
+       }
+
+       regmap = devm_regmap_init_i2c(dummy_client, regmap_config);
+       if (IS_ERR(regmap)) {
+               i2c_unregister_device(dummy_client);
+               return PTR_ERR(regmap);
+       }
+
+       at24->client[index].client = dummy_client;
+       at24->client[index].regmap = regmap;
+
+       return 0;
+}
+
 static unsigned int at24_get_offset_adj(u8 flags, unsigned int byte_len)
 {
        if (flags & AT24_FLAG_MAC) {
@@ -637,20 +676,10 @@ static int at24_probe(struct i2c_client *client)
 
        /* use dummy devices for multiple-address chips */
        for (i = 1; i < num_addresses; i++) {
-               at24->client[i].client = i2c_new_dummy(client->adapter,
-                                                      client->addr + i);
-               if (!at24->client[i].client) {
-                       dev_err(dev, "address 0x%02x unavailable\n",
-                               client->addr + i);
-                       err = -EADDRINUSE;
-                       goto err_clients;
-               }
-               at24->client[i].regmap = devm_regmap_init_i2c(
-                                               at24->client[i].client,
-                                               &regmap_config);
-               if (IS_ERR(at24->client[i].regmap)) {
-                       err = PTR_ERR(at24->client[i].regmap);
-                       goto err_clients;
+               err = at24_make_dummy_client(at24, i, &regmap_config);
+               if (err) {
+                       at24_remove_dummy_clients(at24);
+                       return err;
                }
        }
 
@@ -685,7 +714,7 @@ static int at24_probe(struct i2c_client *client)
        nvmem_config.word_size = 1;
        nvmem_config.size = pdata.byte_len;
 
-       at24->nvmem = nvmem_register(&nvmem_config);
+       at24->nvmem = devm_nvmem_register(dev, &nvmem_config);
        if (IS_ERR(at24->nvmem)) {
                err = PTR_ERR(at24->nvmem);
                goto err_clients;
@@ -702,10 +731,7 @@ static int at24_probe(struct i2c_client *client)
        return 0;
 
 err_clients:
-       for (i = 1; i < num_addresses; i++)
-               if (at24->client[i].client)
-                       i2c_unregister_device(at24->client[i].client);
-
+       at24_remove_dummy_clients(at24);
        pm_runtime_disable(dev);
 
        return err;
@@ -714,15 +740,10 @@ static int at24_probe(struct i2c_client *client)
 static int at24_remove(struct i2c_client *client)
 {
        struct at24_data *at24;
-       int i;
 
        at24 = i2c_get_clientdata(client);
 
-       nvmem_unregister(at24->nvmem);
-
-       for (i = 1; i < at24->num_addresses; i++)
-               i2c_unregister_device(at24->client[i].client);
-
+       at24_remove_dummy_clients(at24);
        pm_runtime_disable(&client->dev);
        pm_runtime_set_suspended(&client->dev);
 
index 34a5a41578d719a04c5bcf317da0d101cd2f2531..59dc24bb70eca2d357db7dd3a1198a6f6a18f04a 100644 (file)
@@ -964,7 +964,7 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf,
        if (colon_ch != NULL) {
                csraddr_len = colon_ch - buf;
                csraddr_str =
-                       kmalloc(sizeof(char)*(csraddr_len + 1), GFP_KERNEL);
+                       kmalloc(csraddr_len + 1, GFP_KERNEL);
                if (csraddr_str == NULL) {
                        ret = -ENOMEM;
                        goto free_buf;
index b7f8d35c17a93e5b4245f49c63e53d98aac6ea06..656449cb4476beb1acae3783c4cde265657ae8b1 100644 (file)
@@ -1048,15 +1048,16 @@ static int setup_ddcb_queue(struct genwqe_dev *cd, struct ddcb_queue *queue)
                        "[%s] **err: could not allocate DDCB **\n", __func__);
                return -ENOMEM;
        }
-       queue->ddcb_req = kzalloc(sizeof(struct ddcb_requ *) *
-                                 queue->ddcb_max, GFP_KERNEL);
+       queue->ddcb_req = kcalloc(queue->ddcb_max, sizeof(struct ddcb_requ *),
+                                 GFP_KERNEL);
        if (!queue->ddcb_req) {
                rc = -ENOMEM;
                goto free_ddcbs;
        }
 
-       queue->ddcb_waitqs = kzalloc(sizeof(wait_queue_head_t) *
-                                    queue->ddcb_max, GFP_KERNEL);
+       queue->ddcb_waitqs = kcalloc(queue->ddcb_max,
+                                    sizeof(wait_queue_head_t),
+                                    GFP_KERNEL);
        if (!queue->ddcb_waitqs) {
                rc = -ENOMEM;
                goto free_requs;
index 0c775d6fcf590d1b1691926d144237ff02c960e1..83fc748a91a70d7e71f9f315a703d31ef49d47ea 100644 (file)
@@ -416,7 +416,8 @@ xpc_setup_ch_structures(struct xpc_partition *part)
         * memory.
         */
        DBUG_ON(part->channels != NULL);
-       part->channels = kzalloc(sizeof(struct xpc_channel) * XPC_MAX_NCHANNELS,
+       part->channels = kcalloc(XPC_MAX_NCHANNELS,
+                                sizeof(struct xpc_channel),
                                 GFP_KERNEL);
        if (part->channels == NULL) {
                dev_err(xpc_chan, "can't get memory for channels\n");
@@ -905,8 +906,9 @@ xpc_setup_partitions(void)
        short partid;
        struct xpc_partition *part;
 
-       xpc_partitions = kzalloc(sizeof(struct xpc_partition) *
-                                xp_max_npartitions, GFP_KERNEL);
+       xpc_partitions = kcalloc(xp_max_npartitions,
+                                sizeof(struct xpc_partition),
+                                GFP_KERNEL);
        if (xpc_partitions == NULL) {
                dev_err(xpc_part, "can't get memory for partition structure\n");
                return -ENOMEM;
index 6956f7e7d43921ec80f5e450a471429bc21f55fc..7284413dabfd54af9c4fe3a5cb89ec00380b3918 100644 (file)
@@ -425,7 +425,7 @@ xpc_discovery(void)
        if (remote_rp == NULL)
                return;
 
-       discovered_nasids = kzalloc(sizeof(long) * xpc_nasid_mask_nlongs,
+       discovered_nasids = kcalloc(xpc_nasid_mask_nlongs, sizeof(long),
                                    GFP_KERNEL);
        if (discovered_nasids == NULL) {
                kfree(remote_rp_base);
index 216d5c756236cd43f42c2abc8b731f976f2f6b92..44d750d98bc8ca4e7b67ace83785c4006d95816e 100644 (file)
@@ -520,8 +520,9 @@ xpnet_init(void)
 
        dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME);
 
-       xpnet_broadcast_partitions = kzalloc(BITS_TO_LONGS(xp_max_npartitions) *
-                                            sizeof(long), GFP_KERNEL);
+       xpnet_broadcast_partitions = kcalloc(BITS_TO_LONGS(xp_max_npartitions),
+                                            sizeof(long),
+                                            GFP_KERNEL);
        if (xpnet_broadcast_partitions == NULL)
                return -ENOMEM;
 
index fc0415771c0087264436d1ba434eccae8ef78dff..c5dc6095686a28490e06f97e659e44d8a04971aa 100644 (file)
@@ -185,7 +185,7 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
         * after the reserved blocks from the dt are processed.
         */
        nblocks = (np) ? of_get_available_child_count(np) + 1 : 1;
-       rblocks = kzalloc((nblocks) * sizeof(*rblocks), GFP_KERNEL);
+       rblocks = kcalloc(nblocks, sizeof(*rblocks), GFP_KERNEL);
        if (!rblocks)
                return -ENOMEM;
 
@@ -264,8 +264,8 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res)
        list_sort(NULL, &reserve_list, sram_reserve_cmp);
 
        if (exports) {
-               sram->partition = devm_kzalloc(sram->dev,
-                                      exports * sizeof(*sram->partition),
+               sram->partition = devm_kcalloc(sram->dev,
+                                      exports, sizeof(*sram->partition),
                                       GFP_KERNEL);
                if (!sram->partition) {
                        ret = -ENOMEM;
index 0339538c182d20ea6489407e505aff66b0dfec79..b4d7774cfe073c8651825d43e909fb7d974b390b 100644 (file)
@@ -449,12 +449,14 @@ static int qp_alloc_ppn_set(void *prod_q,
                return VMCI_ERROR_ALREADY_EXISTS;
 
        produce_ppns =
-           kmalloc(num_produce_pages * sizeof(*produce_ppns), GFP_KERNEL);
+           kmalloc_array(num_produce_pages, sizeof(*produce_ppns),
+                         GFP_KERNEL);
        if (!produce_ppns)
                return VMCI_ERROR_NO_MEM;
 
        consume_ppns =
-           kmalloc(num_consume_pages * sizeof(*consume_ppns), GFP_KERNEL);
+           kmalloc_array(num_consume_pages, sizeof(*consume_ppns),
+                         GFP_KERNEL);
        if (!consume_ppns) {
                kfree(produce_ppns);
                return VMCI_ERROR_NO_MEM;
index f3a7c8ece4bef74c0cd29ea28361157d44ed418e..88347ce78f23feee0b1b2f1f191c0891ce563358 100644 (file)
@@ -797,8 +797,10 @@ static int sdhci_omap_config_iodelay_pinctrl_state(struct sdhci_omap_host
        if (!(omap_host->flags & SDHCI_OMAP_REQUIRE_IODELAY))
                return 0;
 
-       pinctrl_state = devm_kzalloc(dev, sizeof(*pinctrl_state) *
-                                    (MMC_TIMING_MMC_HS200 + 1), GFP_KERNEL);
+       pinctrl_state = devm_kcalloc(dev,
+                                    MMC_TIMING_MMC_HS200 + 1,
+                                    sizeof(*pinctrl_state),
+                                    GFP_KERNEL);
        if (!pinctrl_state)
                return -ENOMEM;
 
index 90575deff0ae5d3c699ba65558c69650cc1d652a..fc15ec58230a0d8fdfa6a0ad8d34206ee2c95ec3 100644 (file)
@@ -55,7 +55,7 @@ static int create_mtd_partitions(struct mtd_info *master,
        int retries = 10;
        struct mtd_partition *ar7_parts;
 
-       ar7_parts = kzalloc(sizeof(*ar7_parts) * AR7_PARTS, GFP_KERNEL);
+       ar7_parts = kcalloc(AR7_PARTS, sizeof(*ar7_parts), GFP_KERNEL);
        if (!ar7_parts)
                return -ENOMEM;
        ar7_parts[0].name = "loader";
index 0f93d223935295c760506acc895f6a77ab7865b8..fc424b185b083de74fe354b27775137e51094e45 100644 (file)
@@ -110,7 +110,7 @@ static int bcm47xxpart_parse(struct mtd_info *master,
                blocksize = 0x1000;
 
        /* Alloc */
-       parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
+       parts = kcalloc(BCM47XXPART_MAX_PARTS, sizeof(struct mtd_partition),
                        GFP_KERNEL);
        if (!parts)
                return -ENOMEM;
index f5695be14499855a2a54071004e8107c3289f680..6e8e7b1bb34b65a4196c7979aa8d1ca10a9f2f07 100644 (file)
@@ -608,8 +608,9 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
        mtd->size = devsize * cfi->numchips;
 
        mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
-       mtd->eraseregions = kzalloc(sizeof(struct mtd_erase_region_info)
-                       * mtd->numeraseregions, GFP_KERNEL);
+       mtd->eraseregions = kcalloc(mtd->numeraseregions,
+                                   sizeof(struct mtd_erase_region_info),
+                                   GFP_KERNEL);
        if (!mtd->eraseregions)
                goto setup_err;
 
@@ -758,7 +759,9 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd,
                newcfi = kmalloc(sizeof(struct cfi_private) + numvirtchips * sizeof(struct flchip), GFP_KERNEL);
                if (!newcfi)
                        return -ENOMEM;
-               shared = kmalloc(sizeof(struct flchip_shared) * cfi->numchips, GFP_KERNEL);
+               shared = kmalloc_array(cfi->numchips,
+                                      sizeof(struct flchip_shared),
+                                      GFP_KERNEL);
                if (!shared) {
                        kfree(newcfi);
                        return -ENOMEM;
index 7c889eca9ab0b1288270e2a7efaa50e7da7138a5..a0c655628d6d5283fd9b5cd8234b8b09857d9c75 100644 (file)
@@ -692,8 +692,9 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
        mtd->size = devsize * cfi->numchips;
 
        mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
-       mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
-                                   * mtd->numeraseregions, GFP_KERNEL);
+       mtd->eraseregions = kmalloc_array(mtd->numeraseregions,
+                                         sizeof(struct mtd_erase_region_info),
+                                         GFP_KERNEL);
        if (!mtd->eraseregions)
                goto setup_err;
 
@@ -2635,7 +2636,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs,
         * first check the locking status of all sectors and save
         * it for future use.
         */
-       sect = kzalloc(MAX_SECTORS * sizeof(struct ppb_lock), GFP_KERNEL);
+       sect = kcalloc(MAX_SECTORS, sizeof(struct ppb_lock), GFP_KERNEL);
        if (!sect)
                return -ENOMEM;
 
index 7b7658a05036d59c46ea7ca8e5db9322e59792aa..35aa72b720a6246871325250242b99485ed70d7b 100644 (file)
@@ -184,8 +184,9 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
        mtd->size = devsize * cfi->numchips;
 
        mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
-       mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
-                       * mtd->numeraseregions, GFP_KERNEL);
+       mtd->eraseregions = kmalloc_array(mtd->numeraseregions,
+                                         sizeof(struct mtd_erase_region_info),
+                                         GFP_KERNEL);
        if (!mtd->eraseregions) {
                kfree(cfi->cmdset_priv);
                kfree(mtd);
index 802d8f159e9020e325c0d61026243a0a8d634e0c..512bd4c2eec0b3a31f8dcd5d1a201c780a6fafcf 100644 (file)
@@ -1827,7 +1827,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev)
        mtd->dev.parent = dev;
        bbt_nbpages = DIV_ROUND_UP(docg3->max_block + 1,
                                   8 * DOC_LAYOUT_PAGE_SIZE);
-       docg3->bbt = kzalloc(bbt_nbpages * DOC_LAYOUT_PAGE_SIZE, GFP_KERNEL);
+       docg3->bbt = kcalloc(DOC_LAYOUT_PAGE_SIZE, bbt_nbpages, GFP_KERNEL);
        if (!docg3->bbt)
                goto nomem3;
 
@@ -1993,7 +1993,7 @@ static int __init docg3_probe(struct platform_device *pdev)
        base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
 
        ret = -ENOMEM;
-       cascade = devm_kzalloc(dev, sizeof(*cascade) * DOC_MAX_NBFLOORS,
+       cascade = devm_kcalloc(dev, DOC_MAX_NBFLOORS, sizeof(*cascade),
                               GFP_KERNEL);
        if (!cascade)
                return ret;
index ef6ad2551d574c5037767b1ff9fdf37300f3490c..2578f27914ef50cff03b05a49a4ddcae7cbefa58 100644 (file)
@@ -201,15 +201,16 @@ static int build_maps(partition_t *part)
     /* Set up erase unit maps */
     part->DataUnits = le16_to_cpu(part->header.NumEraseUnits) -
        part->header.NumTransferUnits;
-    part->EUNInfo = kmalloc(part->DataUnits * sizeof(struct eun_info_t),
-                           GFP_KERNEL);
+    part->EUNInfo = kmalloc_array(part->DataUnits, sizeof(struct eun_info_t),
+                                  GFP_KERNEL);
     if (!part->EUNInfo)
            goto out;
     for (i = 0; i < part->DataUnits; i++)
        part->EUNInfo[i].Offset = 0xffffffff;
     part->XferInfo =
-       kmalloc(part->header.NumTransferUnits * sizeof(struct xfer_info_t),
-               GFP_KERNEL);
+       kmalloc_array(part->header.NumTransferUnits,
+                      sizeof(struct xfer_info_t),
+                      GFP_KERNEL);
     if (!part->XferInfo)
            goto out_EUNInfo;
 
@@ -262,15 +263,15 @@ static int build_maps(partition_t *part)
 
     /* Set up virtual page map */
     blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize;
-    part->VirtualBlockMap = vmalloc(blocks * sizeof(uint32_t));
+    part->VirtualBlockMap = vmalloc(array_size(blocks, sizeof(uint32_t)));
     if (!part->VirtualBlockMap)
            goto out_XferInfo;
 
     memset(part->VirtualBlockMap, 0xff, blocks * sizeof(uint32_t));
     part->BlocksPerUnit = (1 << header.EraseUnitSize) >> header.BlockSize;
 
-    part->bam_cache = kmalloc(part->BlocksPerUnit * sizeof(uint32_t),
-                             GFP_KERNEL);
+    part->bam_cache = kmalloc_array(part->BlocksPerUnit, sizeof(uint32_t),
+                                    GFP_KERNEL);
     if (!part->bam_cache)
            goto out_VirtualBlockMap;
 
index 2d598412972dcd3f6350fae3d9c9b8481811824b..10d977e9709d5cb01b2150a1480f77c60ea32f96 100644 (file)
@@ -270,7 +270,8 @@ static int find_boot_record(struct INFTLrecord *inftl)
                inftl->nb_blocks = ip->lastUnit + 1;
 
                /* Memory alloc */
-               inftl->PUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL);
+               inftl->PUtable = kmalloc_array(inftl->nb_blocks, sizeof(u16),
+                                              GFP_KERNEL);
                if (!inftl->PUtable) {
                        printk(KERN_WARNING "INFTL: allocation of PUtable "
                                "failed (%zd bytes)\n",
@@ -278,7 +279,8 @@ static int find_boot_record(struct INFTLrecord *inftl)
                        return -ENOMEM;
                }
 
-               inftl->VUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL);
+               inftl->VUtable = kmalloc_array(inftl->nb_blocks, sizeof(u16),
+                                              GFP_KERNEL);
                if (!inftl->VUtable) {
                        kfree(inftl->PUtable);
                        printk(KERN_WARNING "INFTL: allocation of VUtable "
index 5c5ba3c7c79d5ffa8a1d545e68fec32feae291dd..b13557fe52bd0b3d4589eeb7ae7c890bf69eca77 100644 (file)
@@ -78,7 +78,7 @@ struct mtd_info *lpddr_cmdset(struct map_info *map)
        mtd->erasesize = 1 << lpddr->qinfo->UniformBlockSizeShift;
        mtd->writesize = 1 << lpddr->qinfo->BufSizeShift;
 
-       shared = kmalloc(sizeof(struct flchip_shared) * lpddr->numchips,
+       shared = kmalloc_array(lpddr->numchips, sizeof(struct flchip_shared),
                                                GFP_KERNEL);
        if (!shared) {
                kfree(lpddr);
index 527b1682381f4ed68714f8a2f5694884f3332acc..4129535b8e46f34e8891c3d86f0c6fb5160f6095 100644 (file)
@@ -124,7 +124,7 @@ static const char * const *of_get_probes(struct device_node *dp)
        if (count < 0)
                return part_probe_types_def;
 
-       res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
+       res = kcalloc(count + 1, sizeof(*res), GFP_KERNEL);
        if (!res)
                return NULL;
 
@@ -197,7 +197,7 @@ static int of_flash_probe(struct platform_device *dev)
 
        dev_set_drvdata(&dev->dev, info);
 
-       mtd_list = kzalloc(sizeof(*mtd_list) * count, GFP_KERNEL);
+       mtd_list = kcalloc(count, sizeof(*mtd_list), GFP_KERNEL);
        if (!mtd_list)
                goto err_flash_remove;
 
index 6b223cfe92b7ac0e789a03364648744dd4a136fd..c5d4b6589488c10dd59496b3d214a7cff66b2eeb 100644 (file)
@@ -629,15 +629,15 @@ static int vmu_connect(struct maple_device *mdev)
        * Not sure there are actually any multi-partition devices in the
        * real world, but the hardware supports them, so, so will we
        */
-       card->parts = kmalloc(sizeof(struct vmupart) * card->partitions,
-               GFP_KERNEL);
+       card->parts = kmalloc_array(card->partitions, sizeof(struct vmupart),
+                                   GFP_KERNEL);
        if (!card->parts) {
                error = -ENOMEM;
                goto fail_partitions;
        }
 
-       card->mtd = kmalloc(sizeof(struct mtd_info) * card->partitions,
-               GFP_KERNEL);
+       card->mtd = kmalloc_array(card->partitions, sizeof(struct mtd_info),
+                                 GFP_KERNEL);
        if (!card->mtd) {
                error = -ENOMEM;
                goto fail_mtd_info;
index 6b86d1a73cf2bb73084e4a8def0feb8ae79400e7..cbc5925e6440746f7ad158bb6b24daf4a3e0267d 100644 (file)
@@ -778,8 +778,9 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[],       /* subdevices to c
                concat->mtd.erasesize = max_erasesize;
                concat->mtd.numeraseregions = num_erase_region;
                concat->mtd.eraseregions = erase_region_p =
-                   kmalloc(num_erase_region *
-                           sizeof (struct mtd_erase_region_info), GFP_KERNEL);
+                   kmalloc_array(num_erase_region,
+                                 sizeof(struct mtd_erase_region_info),
+                                 GFP_KERNEL);
                if (!erase_region_p) {
                        kfree(concat);
                        printk
index 9f25111fd55934973be421aca4ca63e41dc74da3..e078fc41aa61222c56cd334fe3d6711e8f8b70d8 100644 (file)
@@ -330,8 +330,10 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
        }
 
        /* oops_page_used is a bit field */
-       cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages,
-                       BITS_PER_LONG) * sizeof(unsigned long));
+       cxt->oops_page_used =
+               vmalloc(array_size(sizeof(unsigned long),
+                                  DIV_ROUND_UP(mtdoops_pages,
+                                               BITS_PER_LONG)));
        if (!cxt->oops_page_used) {
                printk(KERN_ERR "mtdoops: could not allocate page array\n");
                return;
index 7161f8a17f6204b59412eb7a04604993990f58d4..d9dcb2d051b4b0393f7a1c0a68769dfc29c52dda 100644 (file)
@@ -1317,11 +1317,11 @@ static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks,
        for (i = 0; i < MTDSWAP_TREE_CNT; i++)
                d->trees[i].root = RB_ROOT;
 
-       d->page_data = vmalloc(sizeof(int)*pages);
+       d->page_data = vmalloc(array_size(pages, sizeof(int)));
        if (!d->page_data)
                goto page_data_fail;
 
-       d->revmap = vmalloc(sizeof(int)*blocks);
+       d->revmap = vmalloc(array_size(blocks, sizeof(int)));
        if (!d->revmap)
                goto revmap_fail;
 
@@ -1340,7 +1340,7 @@ static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks,
        if (!d->page_buf)
                goto page_buf_fail;
 
-       d->oob_buf = kmalloc(2 * mtd->oobavail, GFP_KERNEL);
+       d->oob_buf = kmalloc_array(2, mtd->oobavail, GFP_KERNEL);
        if (!d->oob_buf)
                goto oob_buf_fail;
 
index b7105192cb12cb475970314ed6b375ab6e5cc4c0..4ca4b194e7d724411de9ad2fbc43fbb7a338cb39 100644 (file)
@@ -3721,8 +3721,10 @@ static int onenand_probe(struct mtd_info *mtd)
                this->dies = ONENAND_IS_DDP(this) ? 2 : 1;
                /* Maximum possible erase regions */
                mtd->numeraseregions = this->dies << 1;
-               mtd->eraseregions = kzalloc(sizeof(struct mtd_erase_region_info)
-                                       * (this->dies << 1), GFP_KERNEL);
+               mtd->eraseregions =
+                       kcalloc(this->dies << 1,
+                               sizeof(struct mtd_erase_region_info),
+                               GFP_KERNEL);
                if (!mtd->eraseregions)
                        return -ENOMEM;
        }
index 7255a0d943740f5104ab6094e7f8417fcd104df0..cd12e5abafdefb7641d8b7f2238f2e4f41d92308 100644 (file)
@@ -545,7 +545,7 @@ static struct davinci_nand_pdata
                        return ERR_PTR(-ENOMEM);
                if (!of_property_read_u32(pdev->dev.of_node,
                        "ti,davinci-chipselect", &prop))
-                       pdev->id = prop;
+                       pdata->core_chipsel = prop;
                else
                        return ERR_PTR(-EINVAL);
 
@@ -627,7 +627,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
                return -ENODEV;
 
        /* which external chipselect will we be managing? */
-       if (pdev->id < 0 || pdev->id > 3)
+       if (pdata->core_chipsel < 0 || pdata->core_chipsel > 3)
                return -ENODEV;
 
        info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
@@ -683,7 +683,7 @@ static int nand_davinci_probe(struct platform_device *pdev)
        info->ioaddr            = (uint32_t __force) vaddr;
 
        info->current_cs        = info->ioaddr;
-       info->core_chipsel      = pdev->id;
+       info->core_chipsel      = pdata->core_chipsel;
        info->mask_chipsel      = pdata->mask_chipsel;
 
        /* use nandboot-capable ALE/CLE masks by default */
index 7f11b68f6db15e92fa4627f379d4504d7a2284ab..b7387ace567a4b249b14ad2ae5f28a2db53e442f 100644 (file)
@@ -186,7 +186,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd)
        }
 
        nbc->eccmask = kmalloc(eccbytes, GFP_KERNEL);
-       nbc->errloc = kmalloc(t*sizeof(*nbc->errloc), GFP_KERNEL);
+       nbc->errloc = kmalloc_array(t, sizeof(*nbc->errloc), GFP_KERNEL);
        if (!nbc->eccmask || !nbc->errloc)
                goto fail;
        /*
index e027c6f9d3275fc285ada7b2022ff64433f6724c..f8edacde49ab5e20370d0cbb283ffa850e1990ef 100644 (file)
@@ -565,8 +565,9 @@ static int __init alloc_device(struct nandsim *ns)
                        err = -EINVAL;
                        goto err_close;
                }
-               ns->pages_written = vzalloc(BITS_TO_LONGS(ns->geom.pgnum) *
-                                           sizeof(unsigned long));
+               ns->pages_written =
+                       vzalloc(array_size(sizeof(unsigned long),
+                                          BITS_TO_LONGS(ns->geom.pgnum)));
                if (!ns->pages_written) {
                        NS_ERR("alloc_device: unable to allocate pages written array\n");
                        err = -ENOMEM;
@@ -582,7 +583,7 @@ static int __init alloc_device(struct nandsim *ns)
                return 0;
        }
 
-       ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem));
+       ns->pages = vmalloc(array_size(sizeof(union ns_mem), ns->geom.pgnum));
        if (!ns->pages) {
                NS_ERR("alloc_device: unable to allocate page array\n");
                return -ENOMEM;
index b554fb6e609c39ec7530a133b793f8eaec66ff41..6a5519f0ff2587d580acd09019a6ecfa8d6a9b21 100644 (file)
@@ -2510,8 +2510,8 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc)
        if (!nandc->regs)
                return -ENOMEM;
 
-       nandc->reg_read_buf = devm_kzalloc(nandc->dev,
-                               MAX_REG_RD * sizeof(*nandc->reg_read_buf),
+       nandc->reg_read_buf = devm_kcalloc(nandc->dev,
+                               MAX_REG_RD, sizeof(*nandc->reg_read_buf),
                                GFP_KERNEL);
        if (!nandc->reg_read_buf)
                return -ENOMEM;
index 1bc0458063d8e300388d7ebf38ff6ea3c7067012..19661c5d3220a4533794a1906388dc38a8a919ca 100644 (file)
@@ -1038,7 +1038,7 @@ static int s3c24xx_nand_probe_dt(struct platform_device *pdev)
        if (!pdata->nr_sets)
                return 0;
 
-       sets = devm_kzalloc(&pdev->dev, sizeof(*sets) * pdata->nr_sets,
+       sets = devm_kcalloc(&pdev->dev, pdata->nr_sets, sizeof(*sets),
                            GFP_KERNEL);
        if (!sets)
                return -ENOMEM;
index 6281da3dadaca4a8b50cd4da57ec060b381b9b6e..27184e3874dbbd7775e7a40691c4e4f54409fc6f 100644 (file)
@@ -199,13 +199,16 @@ device is already correct.
                nftl->lastEUN = nftl->nb_blocks - 1;
 
                /* memory alloc */
-               nftl->EUNtable = kmalloc(nftl->nb_blocks * sizeof(u16), GFP_KERNEL);
+               nftl->EUNtable = kmalloc_array(nftl->nb_blocks, sizeof(u16),
+                                              GFP_KERNEL);
                if (!nftl->EUNtable) {
                        printk(KERN_NOTICE "NFTL: allocation of EUNtable failed\n");
                        return -ENOMEM;
                }
 
-               nftl->ReplUnitTable = kmalloc(nftl->nb_blocks * sizeof(u16), GFP_KERNEL);
+               nftl->ReplUnitTable = kmalloc_array(nftl->nb_blocks,
+                                                   sizeof(u16),
+                                                   GFP_KERNEL);
                if (!nftl->ReplUnitTable) {
                        kfree(nftl->EUNtable);
                        printk(KERN_NOTICE "NFTL: allocation of ReplUnitTable failed\n");
index 615f8c173162cb2a7e48301f365fbbfc667db81c..6b21a92d3622a10da833b6357b58d9e5b0c2e668 100644 (file)
@@ -71,7 +71,7 @@ static int parse_fixed_partitions(struct mtd_info *master,
        if (nr_parts == 0)
                return 0;
 
-       parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL);
+       parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
        if (!parts)
                return -ENOMEM;
 
@@ -177,7 +177,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master,
 
        nr_parts = plen / sizeof(part[0]);
 
-       parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL);
+       parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
        if (!parts)
                return -ENOMEM;
 
index df360a75e1eb1ac20d258465dab88cd51a8571d4..17ac33599783d0c943a902fe7e69d3a94f2444e1 100644 (file)
@@ -62,7 +62,7 @@ static int parser_trx_parse(struct mtd_info *mtd,
        uint8_t curr_part = 0, i = 0;
        int err;
 
-       parts = kzalloc(sizeof(struct mtd_partition) * TRX_PARSER_MAX_PARTS,
+       parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition),
                        GFP_KERNEL);
        if (!parts)
                return -ENOMEM;
index 8893dc82a5c85b2d0711c58b65faf98a301e334a..e5ea6127ab5a58f6ebfea5ad2278a67bd068977c 100644 (file)
@@ -362,8 +362,9 @@ static int sharpsl_parse_mtd_partitions(struct mtd_info *master,
                return err;
        }
 
-       sharpsl_nand_parts = kzalloc(sizeof(*sharpsl_nand_parts) *
-                                    SHARPSL_NAND_PARTS, GFP_KERNEL);
+       sharpsl_nand_parts = kcalloc(SHARPSL_NAND_PARTS,
+                                    sizeof(*sharpsl_nand_parts),
+                                    GFP_KERNEL);
        if (!sharpsl_nand_parts)
                return -ENOMEM;
 
index df27f24ce0fa7ce5c2ee65eb9f83da28bd8b9b56..94720f2ca9a8a21a132d96f0a36687a7cd0bfe94 100644 (file)
@@ -189,7 +189,8 @@ static int scan_header(struct partition *part)
        if (!part->blocks)
                goto err;
 
-       part->sector_map = vmalloc(part->sector_count * sizeof(u_long));
+       part->sector_map = vmalloc(array_size(sizeof(u_long),
+                                             part->sector_count));
        if (!part->sector_map) {
                printk(KERN_ERR PREFIX "'%s': unable to allocate memory for "
                        "sector map", part->mbd.mtd->name);
index 79636349df965a4c67c1db5feeb2ac3f159bbdeb..f3bd86e136033d80e791fc996f0d9516d5e54d48 100644 (file)
@@ -82,7 +82,7 @@ static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
 
 
        /* Create array of pointers to the attributes */
-       attributes = kzalloc(sizeof(struct attribute *) * (NUM_ATTRIBUTES + 1),
+       attributes = kcalloc(NUM_ATTRIBUTES + 1, sizeof(struct attribute *),
                                                                GFP_KERNEL);
        if (!attributes)
                goto error3;
@@ -750,7 +750,7 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num)
        dbg("initializing zone %d", zone_num);
 
        /* Allocate memory for FTL table */
-       zone->lba_to_phys_table = kmalloc(ftl->max_lba * 2, GFP_KERNEL);
+       zone->lba_to_phys_table = kmalloc_array(ftl->max_lba, 2, GFP_KERNEL);
 
        if (!zone->lba_to_phys_table)
                return -ENOMEM;
@@ -1137,7 +1137,7 @@ static void sm_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
                goto error2;
 
        /* Allocate zone array, it will be initialized on demand */
-       ftl->zones = kzalloc(sizeof(struct ftl_zone) * ftl->zone_count,
+       ftl->zones = kcalloc(ftl->zone_count, sizeof(struct ftl_zone),
                                                                GFP_KERNEL);
        if (!ftl->zones)
                goto error3;
index 95f0bf95f09577702f16d49383fb119647e579ca..7a1e54546f4aa839a5822a75eddd4d43c9d5a01e 100644 (file)
@@ -332,8 +332,9 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
                                (long)ssfdc->sectors;
 
        /* Allocate logical block map */
-       ssfdc->logic_block_map = kmalloc(sizeof(ssfdc->logic_block_map[0]) *
-                                        ssfdc->map_len, GFP_KERNEL);
+       ssfdc->logic_block_map =
+               kmalloc_array(ssfdc->map_len,
+                             sizeof(ssfdc->logic_block_map[0]), GFP_KERNEL);
        if (!ssfdc->logic_block_map)
                goto out_err;
        memset(ssfdc->logic_block_map, 0xff, sizeof(ssfdc->logic_block_map[0]) *
index bc303cac9f437e557a71f71d716f90f49d496c48..75687369bc20c9112e5579bb89366b37ed50e76b 100644 (file)
@@ -127,7 +127,7 @@ static int crosstest(void)
        unsigned char *pp1, *pp2, *pp3, *pp4;
 
        pr_info("crosstest\n");
-       pp1 = kzalloc(pgsize * 4, GFP_KERNEL);
+       pp1 = kcalloc(pgsize, 4, GFP_KERNEL);
        if (!pp1)
                return -ENOMEM;
        pp2 = pp1 + pgsize;
index e509f8aa9a7eea21db08004a8eca1608880ac7d1..0fe1217f94b937a76f4fdf5842642e761ea95eb4 100644 (file)
@@ -199,7 +199,7 @@ static int __init mtd_stresstest_init(void)
        err = -ENOMEM;
        readbuf = vmalloc(bufsize);
        writebuf = vmalloc(bufsize);
-       offsets = kmalloc(ebcnt * sizeof(int), GFP_KERNEL);
+       offsets = kmalloc_array(ebcnt, sizeof(int), GFP_KERNEL);
        if (!readbuf || !writebuf || !offsets)
                goto out;
        for (i = 0; i < ebcnt; i++)
index edb1c8362faa1d910fe6ca742ab5a84efb78474f..b98481b69314d94d3a1f205ba804491d3235638c 100644 (file)
@@ -1536,11 +1536,11 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
 
        num_volumes = ubi->vtbl_slots + UBI_INT_VOL_COUNT;
 
-       scan_eba = kmalloc(sizeof(*scan_eba) * num_volumes, GFP_KERNEL);
+       scan_eba = kmalloc_array(num_volumes, sizeof(*scan_eba), GFP_KERNEL);
        if (!scan_eba)
                return -ENOMEM;
 
-       fm_eba = kmalloc(sizeof(*fm_eba) * num_volumes, GFP_KERNEL);
+       fm_eba = kmalloc_array(num_volumes, sizeof(*fm_eba), GFP_KERNEL);
        if (!fm_eba) {
                kfree(scan_eba);
                return -ENOMEM;
@@ -1551,15 +1551,17 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
                if (!vol)
                        continue;
 
-               scan_eba[i] = kmalloc(vol->reserved_pebs * sizeof(**scan_eba),
-                                     GFP_KERNEL);
+               scan_eba[i] = kmalloc_array(vol->reserved_pebs,
+                                           sizeof(**scan_eba),
+                                           GFP_KERNEL);
                if (!scan_eba[i]) {
                        ret = -ENOMEM;
                        goto out_free;
                }
 
-               fm_eba[i] = kmalloc(vol->reserved_pebs * sizeof(**fm_eba),
-                                   GFP_KERNEL);
+               fm_eba[i] = kmalloc_array(vol->reserved_pebs,
+                                         sizeof(**fm_eba),
+                                         GFP_KERNEL);
                if (!fm_eba[i]) {
                        ret = -ENOMEM;
                        goto out_free;
index f66b3b22f32870ca1e70d9097d89c77af7cc6a33..6f2ac865ff05e78391a59725a86a2643a0019a23 100644 (file)
@@ -1592,7 +1592,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai)
        sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num);
 
        err = -ENOMEM;
-       ubi->lookuptbl = kzalloc(ubi->peb_count * sizeof(void *), GFP_KERNEL);
+       ubi->lookuptbl = kcalloc(ubi->peb_count, sizeof(void *), GFP_KERNEL);
        if (!ubi->lookuptbl)
                return err;
 
index bd53a71f6b000802f352d42a586466cb498c91b2..63e3844c5becf5e973e10fa2aa533f668ac8e30b 100644 (file)
@@ -2418,7 +2418,7 @@ struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev,
        struct list_head  *iter;
 
        if (start_dev == end_dev) {
-               tags = kzalloc(sizeof(*tags) * (level + 1), GFP_ATOMIC);
+               tags = kcalloc(level + 1, sizeof(*tags), GFP_ATOMIC);
                if (!tags)
                        return ERR_PTR(-ENOMEM);
                tags[level].vlan_proto = VLAN_N_VID;
index 2d3046afa80dc87b98037b4c97e9cc85933bde79..7eec1d9f86a0538f737df0bddce7bfd0b039e362 100644 (file)
@@ -1057,7 +1057,7 @@ static int grcan_open(struct net_device *dev)
                return err;
        }
 
-       priv->echo_skb = kzalloc(dma->tx.size * sizeof(*priv->echo_skb),
+       priv->echo_skb = kcalloc(dma->tx.size, sizeof(*priv->echo_skb),
                                 GFP_KERNEL);
        if (!priv->echo_skb) {
                err = -ENOMEM;
@@ -1066,7 +1066,7 @@ static int grcan_open(struct net_device *dev)
        priv->can.echo_skb_max = dma->tx.size;
        priv->can.echo_skb = priv->echo_skb;
 
-       priv->txdlc = kzalloc(dma->tx.size * sizeof(*priv->txdlc), GFP_KERNEL);
+       priv->txdlc = kcalloc(dma->tx.size, sizeof(*priv->txdlc), GFP_KERNEL);
        if (!priv->txdlc) {
                err = -ENOMEM;
                goto exit_free_echo_skb;
index 89d60d8e467c955b56e739b6075702c90b12b470..aa97dbc797b6be339e911a9c34d55778040fdad4 100644 (file)
@@ -703,7 +703,7 @@ static int __init slcan_init(void)
        pr_info("slcan: serial line CAN interface driver\n");
        pr_info("slcan: %d dynamic interface channels.\n", maxdev);
 
-       slcan_devs = kzalloc(sizeof(struct net_device *)*maxdev, GFP_KERNEL);
+       slcan_devs = kcalloc(maxdev, sizeof(struct net_device *), GFP_KERNEL);
        if (!slcan_devs)
                return -ENOMEM;
 
index 5e010b1592f7a6b18c9aa4dcc42de24d27e12c4d..d93c790bfbe8d5c37de8183f3527962e72e6e175 100644 (file)
@@ -2044,14 +2044,14 @@ static int b53_switch_init(struct b53_device *dev)
                }
        }
 
-       dev->ports = devm_kzalloc(dev->dev,
-                                 sizeof(struct b53_port) * dev->num_ports,
+       dev->ports = devm_kcalloc(dev->dev,
+                                 dev->num_ports, sizeof(struct b53_port),
                                  GFP_KERNEL);
        if (!dev->ports)
                return -ENOMEM;
 
-       dev->vlans = devm_kzalloc(dev->dev,
-                                 sizeof(struct b53_vlan) * dev->num_vlans,
+       dev->vlans = devm_kcalloc(dev->dev,
+                                 dev->num_vlans, sizeof(struct b53_vlan),
                                  GFP_KERNEL);
        if (!dev->vlans)
                return -ENOMEM;
index 060cb18fa65963d15ae56cc41164b78d8f0180ed..521607bc43937f0954fb20414c5b1002123c244d 100644 (file)
@@ -838,8 +838,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf)
                return;
        }
 
-       strings_buf = devm_kzalloc(&adapter->pdev->dev,
-                                  strings_num * ETH_GSTRING_LEN,
+       strings_buf = devm_kcalloc(&adapter->pdev->dev,
+                                  ETH_GSTRING_LEN, strings_num,
                                   GFP_ATOMIC);
        if (!strings_buf) {
                netif_err(adapter, drv, netdev,
@@ -847,8 +847,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf)
                return;
        }
 
-       data_buf = devm_kzalloc(&adapter->pdev->dev,
-                               strings_num * sizeof(u64),
+       data_buf = devm_kcalloc(&adapter->pdev->dev,
+                               strings_num, sizeof(u64),
                                GFP_ATOMIC);
        if (!data_buf) {
                netif_err(adapter, drv, netdev,
index 12a6a93d221bb85a30af80741d18c89c85412cc5..b56d84c7df46e2a2b985263b32dc54132ad27b2d 100644 (file)
@@ -551,13 +551,13 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int
        if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp);
        dev->ml_priv = lp;
        lp->name = chipname;
-       lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE,
-                                                 GFP_DMA | GFP_KERNEL);
+       lp->rx_buffs = (unsigned long)kmalloc_array(RX_RING_SIZE, PKT_BUF_SZ,
+                                                   GFP_DMA | GFP_KERNEL);
        if (!lp->rx_buffs)
                goto out_lp;
        if (lance_need_isa_bounce_buffers) {
-               lp->tx_bounce_buffs = kmalloc(PKT_BUF_SZ*TX_RING_SIZE,
-                                                 GFP_DMA | GFP_KERNEL);
+               lp->tx_bounce_buffs = kmalloc_array(TX_RING_SIZE, PKT_BUF_SZ,
+                                                   GFP_DMA | GFP_KERNEL);
                if (!lp->tx_bounce_buffs)
                        goto out_rx;
        } else
index cfe86a20c899dd3bf58e5780e138b9bd7056daf5..28e9ae1a193b40405a80e60abc6ccd2f1d8e1bc8 100644 (file)
@@ -209,8 +209,8 @@ static int atl1c_get_eeprom(struct net_device *netdev,
        first_dword = eeprom->offset >> 2;
        last_dword = (eeprom->offset + eeprom->len - 1) >> 2;
 
-       eeprom_buff = kmalloc(sizeof(u32) *
-                       (last_dword - first_dword + 1), GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32),
+                                   GFP_KERNEL);
        if (eeprom_buff == NULL)
                return -ENOMEM;
 
index cb489e7e8374b5247cf1d431903b04ea81f2474a..282ebdde47699789404c2848124de1386ec50f5a 100644 (file)
@@ -236,8 +236,8 @@ static int atl1e_get_eeprom(struct net_device *netdev,
        first_dword = eeprom->offset >> 2;
        last_dword = (eeprom->offset + eeprom->len - 1) >> 2;
 
-       eeprom_buff = kmalloc(sizeof(u32) *
-                       (last_dword - first_dword + 1), GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32),
+                                   GFP_KERNEL);
        if (eeprom_buff == NULL)
                return -ENOMEM;
 
index db4bcc51023adf546ed0e8a9c8d075beec048faf..bb41becb66099389216192c761541ad1fd51790d 100644 (file)
@@ -1941,8 +1941,8 @@ static int atl2_get_eeprom(struct net_device *netdev,
        first_dword = eeprom->offset >> 2;
        last_dword = (eeprom->offset + eeprom->len - 1) >> 2;
 
-       eeprom_buff = kmalloc(sizeof(u32) * (last_dword - first_dword + 1),
-               GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32),
+                                   GFP_KERNEL);
        if (!eeprom_buff)
                return -ENOMEM;
 
index 14a59e51db675cbac20854408aac30ff09397b25..897302adc38ec16869609cccf6ddc8ee9941a3c7 100644 (file)
@@ -2150,7 +2150,7 @@ static int bcm_enetsw_open(struct net_device *dev)
        priv->tx_desc_alloc_size = size;
        priv->tx_desc_cpu = p;
 
-       priv->tx_skb = kzalloc(sizeof(struct sk_buff *) * priv->tx_ring_size,
+       priv->tx_skb = kcalloc(priv->tx_ring_size, sizeof(struct sk_buff *),
                               GFP_KERNEL);
        if (!priv->tx_skb) {
                dev_err(kdev, "cannot allocate rx skb queue\n");
@@ -2164,7 +2164,7 @@ static int bcm_enetsw_open(struct net_device *dev)
        spin_lock_init(&priv->tx_lock);
 
        /* init & fill rx ring with skbs */
-       priv->rx_skb = kzalloc(sizeof(struct sk_buff *) * priv->rx_ring_size,
+       priv->rx_skb = kcalloc(priv->rx_ring_size, sizeof(struct sk_buff *),
                               GFP_KERNEL);
        if (!priv->rx_skb) {
                dev_err(kdev, "cannot allocate rx skb queue\n");
index 3853296d78c14e3d5645fb0597948fe8e11851f5..122fdb80a789982b00137053fb879179c424e5a9 100644 (file)
@@ -778,7 +778,7 @@ bnx2_alloc_rx_mem(struct bnx2 *bp)
                int j;
 
                rxr->rx_buf_ring =
-                       vzalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring);
+                       vzalloc(array_size(SW_RXBD_RING_SIZE, bp->rx_max_ring));
                if (!rxr->rx_buf_ring)
                        return -ENOMEM;
 
@@ -794,8 +794,9 @@ bnx2_alloc_rx_mem(struct bnx2 *bp)
                }
 
                if (bp->rx_pg_ring_size) {
-                       rxr->rx_pg_ring = vzalloc(SW_RXPG_RING_SIZE *
-                                                 bp->rx_max_pg_ring);
+                       rxr->rx_pg_ring =
+                               vzalloc(array_size(SW_RXPG_RING_SIZE,
+                                                  bp->rx_max_pg_ring));
                        if (!rxr->rx_pg_ring)
                                return -ENOMEM;
 
@@ -2666,7 +2667,7 @@ bnx2_alloc_bad_rbuf(struct bnx2 *bp)
        u32 good_mbuf_cnt;
        u32 val;
 
-       good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL);
+       good_mbuf = kmalloc_array(512, sizeof(u16), GFP_KERNEL);
        if (!good_mbuf)
                return -ENOMEM;
 
index ffa7959f6b31e3c3b691fadb7ae05ad3b1f2a270..dc77bfded8652d7d200a123838cf8e07b5201ff8 100644 (file)
@@ -571,7 +571,7 @@ int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf,
        else
                set_bit(RAMROD_COMP_WAIT, &mcast.ramrod_flags);
        if (mc_num) {
-               mc = kzalloc(mc_num * sizeof(struct bnx2x_mcast_list_elem),
+               mc = kcalloc(mc_num, sizeof(struct bnx2x_mcast_list_elem),
                             GFP_KERNEL);
                if (!mc) {
                        BNX2X_ERR("Cannot Configure multicasts due to lack of memory\n");
@@ -1253,8 +1253,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param,
           num_vfs_param, iov->nr_virtfn);
 
        /* allocate the vf array */
-       bp->vfdb->vfs = kzalloc(sizeof(struct bnx2x_virtf) *
-                               BNX2X_NR_VIRTFN(bp), GFP_KERNEL);
+       bp->vfdb->vfs = kcalloc(BNX2X_NR_VIRTFN(bp),
+                               sizeof(struct bnx2x_virtf),
+                               GFP_KERNEL);
        if (!bp->vfdb->vfs) {
                BNX2X_ERR("failed to allocate vf array\n");
                err = -ENOMEM;
@@ -1278,9 +1279,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param,
        }
 
        /* allocate the queue arrays for all VFs */
-       bp->vfdb->vfqs = kzalloc(
-               BNX2X_MAX_NUM_VF_QUEUES * sizeof(struct bnx2x_vf_queue),
-               GFP_KERNEL);
+       bp->vfdb->vfqs = kcalloc(BNX2X_MAX_NUM_VF_QUEUES,
+                                sizeof(struct bnx2x_vf_queue),
+                                GFP_KERNEL);
 
        if (!bp->vfdb->vfqs) {
                BNX2X_ERR("failed to allocate vf queue array\n");
index 38f635cf840844b6a92a20587a9fcf7f9382b016..05d4059059062463ee8fa38d16a9a708f96cb411 100644 (file)
@@ -444,8 +444,8 @@ static int bnxt_vf_reps_create(struct bnxt *bp)
                return -ENOMEM;
 
        /* storage for cfa_code to vf-idx mapping */
-       cfa_code_map = kmalloc(sizeof(*bp->cfa_code_map) * MAX_CFA_CODE,
-                              GFP_KERNEL);
+       cfa_code_map = kmalloc_array(MAX_CFA_CODE, sizeof(*bp->cfa_code_map),
+                                    GFP_KERNEL);
        if (!cfa_code_map) {
                rc = -ENOMEM;
                goto err;
index 8bc126a156e80a1d18366a4b6cc3bd8cd2764954..30273a7717e2df797890da57e229ce31e9d957e2 100644 (file)
@@ -660,7 +660,7 @@ static int cnic_init_id_tbl(struct cnic_id_tbl *id_tbl, u32 size, u32 start_id,
        id_tbl->max = size;
        id_tbl->next = next;
        spin_lock_init(&id_tbl->lock);
-       id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL);
+       id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL);
        if (!id_tbl->table)
                return -ENOMEM;
 
@@ -1255,13 +1255,13 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev)
                        cp->fcoe_init_cid = 0x10;
        }
 
-       cp->iscsi_tbl = kzalloc(sizeof(struct cnic_iscsi) * MAX_ISCSI_TBL_SZ,
+       cp->iscsi_tbl = kcalloc(MAX_ISCSI_TBL_SZ, sizeof(struct cnic_iscsi),
                                GFP_KERNEL);
        if (!cp->iscsi_tbl)
                goto error;
 
-       cp->ctx_tbl = kzalloc(sizeof(struct cnic_context) *
-                               cp->max_cid_space, GFP_KERNEL);
+       cp->ctx_tbl = kcalloc(cp->max_cid_space, sizeof(struct cnic_context),
+                             GFP_KERNEL);
        if (!cp->ctx_tbl)
                goto error;
 
@@ -4100,7 +4100,7 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev)
        struct cnic_local *cp = dev->cnic_priv;
        u32 port_id;
 
-       cp->csk_tbl = kzalloc(sizeof(struct cnic_sock) * MAX_CM_SK_TBL_SZ,
+       cp->csk_tbl = kcalloc(MAX_CM_SK_TBL_SZ, sizeof(struct cnic_sock),
                              GFP_KERNEL);
        if (!cp->csk_tbl)
                return -ENOMEM;
index 9f59b1270a7c68da3086d22db2930d041cbaaec8..3be87efdc93d6347da8417ddcd101ed90cc12d8c 100644 (file)
@@ -8631,8 +8631,9 @@ static int tg3_mem_tx_acquire(struct tg3 *tp)
                tnapi++;
 
        for (i = 0; i < tp->txq_cnt; i++, tnapi++) {
-               tnapi->tx_buffers = kzalloc(sizeof(struct tg3_tx_ring_info) *
-                                           TG3_TX_RING_SIZE, GFP_KERNEL);
+               tnapi->tx_buffers = kcalloc(TG3_TX_RING_SIZE,
+                                           sizeof(struct tg3_tx_ring_info),
+                                           GFP_KERNEL);
                if (!tnapi->tx_buffers)
                        goto err_out;
 
index 69cc3e0119d6a63073c7d2f4ef6e84c7503f30ac..ea5f32ea308a94b26d590ed838eae79fbf51897a 100644 (file)
@@ -3141,7 +3141,7 @@ bnad_set_rx_ucast_fltr(struct bnad *bnad)
        if (uc_count > bna_attr(&bnad->bna)->num_ucmac)
                goto mode_default;
 
-       mac_list = kzalloc(uc_count * ETH_ALEN, GFP_ATOMIC);
+       mac_list = kcalloc(ETH_ALEN, uc_count, GFP_ATOMIC);
        if (mac_list == NULL)
                goto mode_default;
 
@@ -3182,7 +3182,7 @@ bnad_set_rx_mcast_fltr(struct bnad *bnad)
        if (mc_count > bna_attr(&bnad->bna)->num_mcmac)
                goto mode_allmulti;
 
-       mac_list = kzalloc((mc_count + 1) * ETH_ALEN, GFP_ATOMIC);
+       mac_list = kcalloc(mc_count + 1, ETH_ALEN, GFP_ATOMIC);
 
        if (mac_list == NULL)
                goto mode_allmulti;
index 2bd7c638b178d5801bf2f3e4525e02734454ff6d..2c63afff138239aa51c0656c85fd712a759d7093 100644 (file)
@@ -739,7 +739,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev)
 
        netdev_dbg(priv->dev, "mtu [%d] bfsize [%d]\n", dev->mtu, bfsize);
 
-       priv->rx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_RX_RING_SZ,
+       priv->rx_skbuff = kcalloc(DMA_RX_RING_SZ, sizeof(struct sk_buff *),
                                  GFP_KERNEL);
        if (!priv->rx_skbuff)
                return -ENOMEM;
@@ -752,7 +752,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev)
        if (!priv->dma_rx)
                goto err_dma_rx;
 
-       priv->tx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_TX_RING_SZ,
+       priv->tx_skbuff = kcalloc(DMA_TX_RING_SZ, sizeof(struct sk_buff *),
                                  GFP_KERNEL);
        if (!priv->tx_skbuff)
                goto err_tx_skb;
index f044718cea52bd2fe0e524e84a619f173b4726d5..a71dbb7ab6af67ccbd9c3347328608be3145a8f9 100644 (file)
@@ -281,13 +281,12 @@ int octeon_init_droq(struct octeon_device *oct,
                droq->max_count);
 
        droq->recv_buf_list = (struct octeon_recv_buffer *)
-                             vzalloc_node(droq->max_count *
-                                               OCT_DROQ_RECVBUF_SIZE,
-                                               numa_node);
+             vzalloc_node(array_size(droq->max_count, OCT_DROQ_RECVBUF_SIZE),
+                          numa_node);
        if (!droq->recv_buf_list)
                droq->recv_buf_list = (struct octeon_recv_buffer *)
-                                     vzalloc(droq->max_count *
-                                               OCT_DROQ_RECVBUF_SIZE);
+                     vzalloc(array_size(droq->max_count,
+                                        OCT_DROQ_RECVBUF_SIZE));
        if (!droq->recv_buf_list) {
                dev_err(&oct->pci_dev->dev, "Output queue recv buf list alloc failed\n");
                goto init_droq_fail;
index b1270355b0b14febe970a7b3cc37fe60cbb3861f..1f2e75da28f833c2f6973670fa5d113184b606fc 100644 (file)
@@ -98,8 +98,9 @@ int octeon_init_instr_queue(struct octeon_device *oct,
        iq->request_list = vmalloc_node((sizeof(*iq->request_list) * num_descs),
                                               numa_node);
        if (!iq->request_list)
-               iq->request_list = vmalloc(sizeof(*iq->request_list) *
-                                                 num_descs);
+               iq->request_list =
+                       vmalloc(array_size(num_descs,
+                                          sizeof(*iq->request_list)));
        if (!iq->request_list) {
                lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma);
                dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n",
index 448d1fafc8270eeb8fe0ef37bd0f0cb7530abc96..f4d81765221ea583b327f97879bc8ae3c705259a 100644 (file)
@@ -325,6 +325,8 @@ struct nicvf {
        struct tasklet_struct   qs_err_task;
        struct work_struct      reset_task;
        struct nicvf_work       rx_mode_work;
+       /* spinlock to protect workqueue arguments from concurrent access */
+       spinlock_t              rx_mode_wq_lock;
 
        /* PTP timestamp */
        struct cavium_ptp       *ptp_clock;
index 7135db45927e59a56e231f172544ce10d76665d5..135766c4296b737c7ffbf34026d61e3f0cf9d13d 100644 (file)
@@ -1923,17 +1923,12 @@ static int nicvf_ioctl(struct net_device *netdev, struct ifreq *req, int cmd)
        }
 }
 
-static void nicvf_set_rx_mode_task(struct work_struct *work_arg)
+static void __nicvf_set_rx_mode_task(u8 mode, struct xcast_addr_list *mc_addrs,
+                                    struct nicvf *nic)
 {
-       struct nicvf_work *vf_work = container_of(work_arg, struct nicvf_work,
-                                                 work.work);
-       struct nicvf *nic = container_of(vf_work, struct nicvf, rx_mode_work);
        union nic_mbx mbx = {};
        int idx;
 
-       if (!vf_work)
-               return;
-
        /* From the inside of VM code flow we have only 128 bits memory
         * available to send message to host's PF, so send all mc addrs
         * one by one, starting from flush command in case if kernel
@@ -1944,7 +1939,7 @@ static void nicvf_set_rx_mode_task(struct work_struct *work_arg)
        mbx.xcast.msg = NIC_MBOX_MSG_RESET_XCAST;
        nicvf_send_msg_to_pf(nic, &mbx);
 
-       if (vf_work->mode & BGX_XCAST_MCAST_FILTER) {
+       if (mode & BGX_XCAST_MCAST_FILTER) {
                /* once enabling filtering, we need to signal to PF to add
                 * its' own LMAC to the filter to accept packets for it.
                 */
@@ -1954,23 +1949,46 @@ static void nicvf_set_rx_mode_task(struct work_struct *work_arg)
        }
 
        /* check if we have any specific MACs to be added to PF DMAC filter */
-       if (vf_work->mc) {
+       if (mc_addrs) {
                /* now go through kernel list of MACs and add them one by one */
-               for (idx = 0; idx < vf_work->mc->count; idx++) {
+               for (idx = 0; idx < mc_addrs->count; idx++) {
                        mbx.xcast.msg = NIC_MBOX_MSG_ADD_MCAST;
-                       mbx.xcast.data.mac = vf_work->mc->mc[idx];
+                       mbx.xcast.data.mac = mc_addrs->mc[idx];
                        nicvf_send_msg_to_pf(nic, &mbx);
                }
-               kfree(vf_work->mc);
+               kfree(mc_addrs);
        }
 
        /* and finally set rx mode for PF accordingly */
        mbx.xcast.msg = NIC_MBOX_MSG_SET_XCAST;
-       mbx.xcast.data.mode = vf_work->mode;
+       mbx.xcast.data.mode = mode;
 
        nicvf_send_msg_to_pf(nic, &mbx);
 }
 
+static void nicvf_set_rx_mode_task(struct work_struct *work_arg)
+{
+       struct nicvf_work *vf_work = container_of(work_arg, struct nicvf_work,
+                                                 work.work);
+       struct nicvf *nic = container_of(vf_work, struct nicvf, rx_mode_work);
+       u8 mode;
+       struct xcast_addr_list *mc;
+
+       if (!vf_work)
+               return;
+
+       /* Save message data locally to prevent them from
+        * being overwritten by next ndo_set_rx_mode call().
+        */
+       spin_lock(&nic->rx_mode_wq_lock);
+       mode = vf_work->mode;
+       mc = vf_work->mc;
+       vf_work->mc = NULL;
+       spin_unlock(&nic->rx_mode_wq_lock);
+
+       __nicvf_set_rx_mode_task(mode, mc, nic);
+}
+
 static void nicvf_set_rx_mode(struct net_device *netdev)
 {
        struct nicvf *nic = netdev_priv(netdev);
@@ -2004,9 +2022,12 @@ static void nicvf_set_rx_mode(struct net_device *netdev)
                        }
                }
        }
+       spin_lock(&nic->rx_mode_wq_lock);
+       kfree(nic->rx_mode_work.mc);
        nic->rx_mode_work.mc = mc_list;
        nic->rx_mode_work.mode = mode;
-       queue_delayed_work(nicvf_rx_mode_wq, &nic->rx_mode_work.work, 2 * HZ);
+       queue_delayed_work(nicvf_rx_mode_wq, &nic->rx_mode_work.work, 0);
+       spin_unlock(&nic->rx_mode_wq_lock);
 }
 
 static const struct net_device_ops nicvf_netdev_ops = {
@@ -2163,6 +2184,7 @@ static int nicvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        INIT_WORK(&nic->reset_task, nicvf_reset_task);
 
        INIT_DELAYED_WORK(&nic->rx_mode_work.work, nicvf_set_rx_mode_task);
+       spin_lock_init(&nic->rx_mode_wq_lock);
 
        err = register_netdev(netdev);
        if (err) {
index d42704d0748434d92eb17c74b0b0530aaa50f536..187a249ff2d1d2fd4201a4e74b9459cbeb3a4b52 100644 (file)
@@ -292,8 +292,8 @@ static int  nicvf_init_rbdr(struct nicvf *nic, struct rbdr *rbdr,
                rbdr->is_xdp = true;
        }
        rbdr->pgcnt = roundup_pow_of_two(rbdr->pgcnt);
-       rbdr->pgcache = kzalloc(sizeof(*rbdr->pgcache) *
-                               rbdr->pgcnt, GFP_KERNEL);
+       rbdr->pgcache = kcalloc(rbdr->pgcnt, sizeof(*rbdr->pgcache),
+                               GFP_KERNEL);
        if (!rbdr->pgcache)
                return -ENOMEM;
        rbdr->pgidx = 0;
index 2edfdbdaae4849a4007f0904d63ca612c100dcf9..7b795edd9d3a9543271d29acf0cc35d760a6b065 100644 (file)
@@ -3362,10 +3362,17 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        err = sysfs_create_group(&adapter->port[0]->dev.kobj,
                                 &cxgb3_attr_group);
+       if (err) {
+               dev_err(&pdev->dev, "cannot create sysfs group\n");
+               goto out_close_led;
+       }
 
        print_port_info(adapter, ai);
        return 0;
 
+out_close_led:
+       t3_set_reg_field(adapter, A_T3DBG_GPIO_EN, F_GPIO0_OUT_VAL, 0);
+
 out_free_dev:
        iounmap(adapter->regs);
        for (i = ai->nports0 + ai->nports1 - 1; i >= 0; --i)
index 290039026ecee8015d15ea5eaab8b6f7d95d02af..5701272aa7f7974d8213f66a7c6102ffc3a9a593 100644 (file)
@@ -304,7 +304,7 @@ struct clip_tbl *t4_init_clip_tbl(unsigned int clipt_start,
        for (i = 0; i < ctbl->clipt_size; ++i)
                INIT_LIST_HEAD(&ctbl->hash_list[i]);
 
-       cl_list = kvzalloc(clipt_size*sizeof(struct clip_entry), GFP_KERNEL);
+       cl_list = kvcalloc(clipt_size, sizeof(struct clip_entry), GFP_KERNEL);
        if (!cl_list) {
                kvfree(ctbl);
                return NULL;
index 251d5bdc972f3daf0b6e3f241797ea966eb1ab5f..c301aaf79d647d2c0f2a1b08ebc1823d6079377f 100644 (file)
@@ -873,7 +873,7 @@ static int cctrl_tbl_show(struct seq_file *seq, void *v)
        u16 (*incr)[NCCTRL_WIN];
        struct adapter *adap = seq->private;
 
-       incr = kmalloc(sizeof(*incr) * NMTUS, GFP_KERNEL);
+       incr = kmalloc_array(NMTUS, sizeof(*incr), GFP_KERNEL);
        if (!incr)
                return -ENOMEM;
 
index 35cb3ae4f7b672069423275707943733e6a5d5fa..dd04a2f89ce62db6ea9bca433023d9aac4b10e23 100644 (file)
@@ -713,7 +713,7 @@ int cxgb4_write_rss(const struct port_info *pi, const u16 *queues)
        const struct sge_eth_rxq *rxq;
 
        rxq = &adapter->sge.ethrxq[pi->first_qset];
-       rss = kmalloc(pi->rss_size * sizeof(u16), GFP_KERNEL);
+       rss = kmalloc_array(pi->rss_size, sizeof(u16), GFP_KERNEL);
        if (!rss)
                return -ENOMEM;
 
@@ -4972,8 +4972,8 @@ static int enable_msix(struct adapter *adap)
                max_ingq += (MAX_OFLD_QSETS * adap->num_uld);
        if (is_offload(adap))
                max_ingq += (MAX_OFLD_QSETS * adap->num_ofld_uld);
-       entries = kmalloc(sizeof(*entries) * (max_ingq + 1),
-                         GFP_KERNEL);
+       entries = kmalloc_array(max_ingq + 1, sizeof(*entries),
+                               GFP_KERNEL);
        if (!entries)
                return -ENOMEM;
 
@@ -5646,8 +5646,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
                adapter->params.offload = 0;
        }
 
-       adapter->mps_encap = kvzalloc(sizeof(struct mps_encap_entry) *
-                                         adapter->params.arch.mps_tcam_size,
+       adapter->mps_encap = kvcalloc(adapter->params.arch.mps_tcam_size,
+                                     sizeof(struct mps_encap_entry),
                                      GFP_KERNEL);
        if (!adapter->mps_encap)
                dev_warn(&pdev->dev, "could not allocate MPS Encap entries, continuing\n");
index ab174bcfbfb09b415504da31c9965f47f853a8ef..18eb2aedd4cb0a2659a479f7f50c62f13f32c78d 100644 (file)
@@ -457,7 +457,8 @@ struct cxgb4_tc_u32_table *cxgb4_init_tc_u32(struct adapter *adap)
                unsigned int bmap_size;
 
                bmap_size = BITS_TO_LONGS(max_tids);
-               link->tid_map = kvzalloc(sizeof(unsigned long) * bmap_size, GFP_KERNEL);
+               link->tid_map = kvcalloc(bmap_size, sizeof(unsigned long),
+                                        GFP_KERNEL);
                if (!link->tid_map)
                        goto out_no_mem;
                bitmap_zero(link->tid_map, max_tids);
index a95cde0fadf77345d808cf65f8d9e33ba095c24e..4bc211093c98e3564e628a7ccbdacbadbd1c040d 100644 (file)
@@ -561,13 +561,13 @@ int t4_uld_mem_alloc(struct adapter *adap)
        if (!adap->uld)
                return -ENOMEM;
 
-       s->uld_rxq_info = kzalloc(CXGB4_ULD_MAX *
+       s->uld_rxq_info = kcalloc(CXGB4_ULD_MAX,
                                  sizeof(struct sge_uld_rxq_info *),
                                  GFP_KERNEL);
        if (!s->uld_rxq_info)
                goto err_uld;
 
-       s->uld_txq_info = kzalloc(CXGB4_TX_MAX *
+       s->uld_txq_info = kcalloc(CXGB4_TX_MAX,
                                  sizeof(struct sge_uld_txq_info *),
                                  GFP_KERNEL);
        if (!s->uld_txq_info)
index 7a271feec5e74063df88bdba9209008aea35aef0..395e2a0e8d7f6235a36ae9ec73ebd5141b2f24ce 100644 (file)
@@ -699,7 +699,7 @@ static void *alloc_ring(struct device *dev, size_t nelem, size_t elem_size,
        if (!p)
                return NULL;
        if (sw_size) {
-               s = kzalloc_node(nelem * sw_size, GFP_KERNEL, node);
+               s = kcalloc_node(sw_size, nelem, GFP_KERNEL, node);
 
                if (!s) {
                        dma_free_coherent(dev, len, p, *phys);
index ff9eb45f67f8962e7830bb84636862e8db7e8d1d..6d7404f66f84af7322c6b58def8cbff94958ca12 100644 (file)
@@ -910,8 +910,8 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)
        }
 
        /* Allocate a mapping to page look-up index */
-       geth->freeq_pages = kzalloc(pages * sizeof(*geth->freeq_pages),
-                                  GFP_KERNEL);
+       geth->freeq_pages = kcalloc(pages, sizeof(*geth->freeq_pages),
+                                   GFP_KERNEL);
        if (!geth->freeq_pages)
                goto err_freeq;
        geth->num_freeq_pages = pages;
index 00a57273b753660f07abff48b6fc49e775710b07..60da0499ad66c4db3b6b830259c3d9dbdecc7884 100644 (file)
@@ -1141,7 +1141,8 @@ static int ethoc_probe(struct platform_device *pdev)
        dev_dbg(&pdev->dev, "ethoc: num_tx: %d num_rx: %d\n",
                priv->num_tx, priv->num_rx);
 
-       priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void *), GFP_KERNEL);
+       priv->vma = devm_kcalloc(&pdev->dev, num_bd, sizeof(void *),
+                                GFP_KERNEL);
        if (!priv->vma) {
                ret = -ENOMEM;
                goto free;
index fd43f98ddbe74bedec6c53c3467e622b7480acc8..5f4e1ffa7b95fe4f8d2bb6447764951c51fffc67 100644 (file)
@@ -664,7 +664,7 @@ static struct dpaa_fq *dpaa_fq_alloc(struct device *dev,
        struct dpaa_fq *dpaa_fq;
        int i;
 
-       dpaa_fq = devm_kzalloc(dev, sizeof(*dpaa_fq) * count,
+       dpaa_fq = devm_kcalloc(dev, count, sizeof(*dpaa_fq),
                               GFP_KERNEL);
        if (!dpaa_fq)
                return NULL;
index a96b838cffcebc62e21043f65dbfb9265cf16d79..42fca3208c0bac2e7a72f3f82d3350b85b6d9398 100644 (file)
@@ -2253,9 +2253,9 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth)
        /* Init Tx bds */
        for (j = 0; j < ug_info->numQueuesTx; j++) {
                /* Setup the skbuff rings */
-               ugeth->tx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) *
-                                             ugeth->ug_info->bdRingLenTx[j],
-                                             GFP_KERNEL);
+               ugeth->tx_skbuff[j] =
+                       kmalloc_array(ugeth->ug_info->bdRingLenTx[j],
+                                     sizeof(struct sk_buff *), GFP_KERNEL);
 
                if (ugeth->tx_skbuff[j] == NULL) {
                        if (netif_msg_ifup(ugeth))
@@ -2326,9 +2326,9 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth)
        /* Init Rx bds */
        for (j = 0; j < ug_info->numQueuesRx; j++) {
                /* Setup the skbuff rings */
-               ugeth->rx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) *
-                                             ugeth->ug_info->bdRingLenRx[j],
-                                             GFP_KERNEL);
+               ugeth->rx_skbuff[j] =
+                       kmalloc_array(ugeth->ug_info->bdRingLenRx[j],
+                                     sizeof(struct sk_buff *), GFP_KERNEL);
 
                if (ugeth->rx_skbuff[j] == NULL) {
                        if (netif_msg_ifup(ugeth))
index 85e1d14514fc880f70304c300bae62711ef110d0..0ce07f6eb1e6247eb84361f3012d53fbb1a4d443 100644 (file)
@@ -1406,8 +1406,8 @@ static int hns_dsaf_init(struct dsaf_device *dsaf_dev)
                return ret;
 
        /* malloc mem for tcam mac key(vlan+mac) */
-       priv->soft_mac_tbl = vzalloc(sizeof(*priv->soft_mac_tbl)
-                 * DSAF_TCAM_SUM);
+       priv->soft_mac_tbl = vzalloc(array_size(DSAF_TCAM_SUM,
+                                               sizeof(*priv->soft_mac_tbl)));
        if (!priv->soft_mac_tbl) {
                ret = -ENOMEM;
                goto remove_hw;
index 1ccb6443d2edb0531adf3f730ec5603158c91d98..ef9ef703d13a0e0efff11404afb41532f571283f 100644 (file)
@@ -2197,7 +2197,8 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv)
                return -EINVAL;
        }
 
-       priv->ring_data = kzalloc(h->q_num * sizeof(*priv->ring_data) * 2,
+       priv->ring_data = kzalloc(array3_size(h->q_num,
+                                             sizeof(*priv->ring_data), 2),
                                  GFP_KERNEL);
        if (!priv->ring_data)
                return -ENOMEM;
index f2b31d278bc9b9bb45080e6a044d304472f86e81..25a73bb2e642dde42ae59f10369e7d3fefcb53f7 100644 (file)
@@ -2846,8 +2846,10 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv)
        struct pci_dev *pdev = h->pdev;
        int i, ret;
 
-       priv->ring_data =  devm_kzalloc(&pdev->dev, h->kinfo.num_tqps *
-                                       sizeof(*priv->ring_data) * 2,
+       priv->ring_data =  devm_kzalloc(&pdev->dev,
+                                       array3_size(h->kinfo.num_tqps,
+                                                   sizeof(*priv->ring_data),
+                                                   2),
                                        GFP_KERNEL);
        if (!priv->ring_data)
                return -ENOMEM;
index 28a81ac97af5d27bdb51be136df095db9f5799bf..4d09ea786b35fee607ecb6ea45b148458b98e374 100644 (file)
@@ -753,11 +753,12 @@ static int init_cmdq(struct hinic_cmdq *cmdq, struct hinic_wq *wq,
 
        spin_lock_init(&cmdq->cmdq_lock);
 
-       cmdq->done = vzalloc(wq->q_depth * sizeof(*cmdq->done));
+       cmdq->done = vzalloc(array_size(sizeof(*cmdq->done), wq->q_depth));
        if (!cmdq->done)
                return -ENOMEM;
 
-       cmdq->errcode = vzalloc(wq->q_depth * sizeof(*cmdq->errcode));
+       cmdq->errcode = vzalloc(array_size(sizeof(*cmdq->errcode),
+                                          wq->q_depth));
        if (!cmdq->errcode) {
                err = -ENOMEM;
                goto err_errcode;
index c1b51edaaf62560447c4753145091d9d2a238e84..525d8b89187b9b92eec16f2c33bc33c7524a3e4e 100644 (file)
@@ -171,7 +171,7 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool)
 {
        int i;
 
-       pool->free_map = kmalloc(sizeof(u16) * pool->size, GFP_KERNEL);
+       pool->free_map = kmalloc_array(pool->size, sizeof(u16), GFP_KERNEL);
 
        if (!pool->free_map)
                return -1;
index 14d287bed33c4e65100d04458af127cdc6bfa0d5..1ab613eb5796420c217d66287f72592c5875a55d 100644 (file)
@@ -33,7 +33,7 @@ config E100
          to identify the adapter.
 
          More specific information on configuring the driver is in
-         <file:Documentation/networking/e100.txt>.
+         <file:Documentation/networking/e100.rst>.
 
          To compile this driver as a module, choose M here. The module
          will be called e100.
@@ -49,7 +49,7 @@ config E1000
          <http://support.intel.com>
 
          More specific information on configuring the driver is in
-         <file:Documentation/networking/e1000.txt>.
+         <file:Documentation/networking/e1000.rst>.
 
          To compile this driver as a module, choose M here. The module
          will be called e1000.
@@ -94,7 +94,7 @@ config IGB
          <http://support.intel.com>
 
          More specific information on configuring the driver is in
-         <file:Documentation/networking/e1000.txt>.
+         <file:Documentation/networking/e1000.rst>.
 
          To compile this driver as a module, choose M here. The module
          will be called igb.
@@ -130,7 +130,7 @@ config IGBVF
          <http://support.intel.com>
 
          More specific information on configuring the driver is in
-         <file:Documentation/networking/e1000.txt>.
+         <file:Documentation/networking/e1000.rst>.
 
          To compile this driver as a module, choose M here. The module
          will be called igbvf.
index 5d365a986bb08a05893bb46430f09bc7004e8f23..bdb3f8e65ed470e314bf6b4f9b3b3b4e41b93e0f 100644 (file)
@@ -435,8 +435,8 @@ static int e1000_get_eeprom(struct net_device *netdev,
        first_word = eeprom->offset >> 1;
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
 
-       eeprom_buff = kmalloc(sizeof(u16) *
-                       (last_word - first_word + 1), GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
+                                   GFP_KERNEL);
        if (!eeprom_buff)
                return -ENOMEM;
 
index e084cb734eb1e7534da82c8ae729b4ae360bac20..02ebf208f48b27fcacc432c58945b3a936e6d266 100644 (file)
@@ -509,8 +509,8 @@ static int e1000_get_eeprom(struct net_device *netdev,
        first_word = eeprom->offset >> 1;
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
 
-       eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
-                             GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
+                                   GFP_KERNEL);
        if (!eeprom_buff)
                return -ENOMEM;
 
index acf1e8b52b8e793d23b029c5985069e955e1177d..3ba0c90e7055b14a666566279fb7a58728da7427 100644 (file)
@@ -3312,7 +3312,7 @@ static int e1000e_write_mc_addr_list(struct net_device *netdev)
                return 0;
        }
 
-       mta_list = kzalloc(netdev_mc_count(netdev) * ETH_ALEN, GFP_ATOMIC);
+       mta_list = kcalloc(netdev_mc_count(netdev), ETH_ALEN, GFP_ATOMIC);
        if (!mta_list)
                return -ENOMEM;
 
index 7657daa27298dac290859c105640873e4b5f08d7..4895dd83dd082dd71017803feac647bd1fc649d3 100644 (file)
@@ -558,7 +558,7 @@ static int fm10k_set_ringparam(struct net_device *netdev,
 
        /* allocate temporary buffer to store rings in */
        i = max_t(int, interface->num_tx_queues, interface->num_rx_queues);
-       temp_ring = vmalloc(i * sizeof(struct fm10k_ring));
+       temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
 
        if (!temp_ring) {
                err = -ENOMEM;
index 2d798499d35e5278d8fa80aa751de56a3bb983c2..f92f7918112de063700f12de3462a482999c8bb3 100644 (file)
@@ -736,8 +736,8 @@ static int igb_get_eeprom(struct net_device *netdev,
        first_word = eeprom->offset >> 1;
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
 
-       eeprom_buff = kmalloc(sizeof(u16) *
-                       (last_word - first_word + 1), GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
+                                   GFP_KERNEL);
        if (!eeprom_buff)
                return -ENOMEM;
 
@@ -902,11 +902,11 @@ static int igb_set_ringparam(struct net_device *netdev,
        }
 
        if (adapter->num_tx_queues > adapter->num_rx_queues)
-               temp_ring = vmalloc(adapter->num_tx_queues *
-                                   sizeof(struct igb_ring));
+               temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
+                                              adapter->num_tx_queues));
        else
-               temp_ring = vmalloc(adapter->num_rx_queues *
-                                   sizeof(struct igb_ring));
+               temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
+                                              adapter->num_rx_queues));
 
        if (!temp_ring) {
                err = -ENOMEM;
@@ -3245,8 +3245,8 @@ static int igb_get_module_eeprom(struct net_device *netdev,
        first_word = ee->offset >> 1;
        last_word = (ee->offset + ee->len - 1) >> 1;
 
-       dataword = kmalloc(sizeof(u16) * (last_word - first_word + 1),
-                          GFP_KERNEL);
+       dataword = kmalloc_array(last_word - first_word + 1, sizeof(u16),
+                                GFP_KERNEL);
        if (!dataword)
                return -ENOMEM;
 
index c33821d2afb3fee2f69294d3871631f267e19343..f707709969acfee137d30b698304dfd99f7c45e7 100644 (file)
@@ -3763,8 +3763,9 @@ static int igb_sw_init(struct igb_adapter *adapter)
        /* Assume MSI-X interrupts, will be checked during IRQ allocation */
        adapter->flags |= IGB_FLAG_HAS_MSIX;
 
-       adapter->mac_table = kzalloc(sizeof(struct igb_mac_addr) *
-                                    hw->mac.rar_entry_count, GFP_ATOMIC);
+       adapter->mac_table = kcalloc(hw->mac.rar_entry_count,
+                                    sizeof(struct igb_mac_addr),
+                                    GFP_ATOMIC);
        if (!adapter->mac_table)
                return -ENOMEM;
 
@@ -4752,7 +4753,7 @@ static int igb_write_mc_addr_list(struct net_device *netdev)
                return 0;
        }
 
-       mta_list = kzalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
+       mta_list = kcalloc(netdev_mc_count(netdev), 6, GFP_ATOMIC);
        if (!mta_list)
                return -ENOMEM;
 
index 43744bf0fc1cf0f4de4e9bcbcdd85008531259e4..c8c93ac436d4c8c1729c833411a415805d3cde73 100644 (file)
@@ -375,8 +375,9 @@ ixgb_get_eeprom(struct net_device *netdev,
        first_word = eeprom->offset >> 1;
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
 
-       eeprom_buff = kmalloc(sizeof(__le16) *
-                       (last_word - first_word + 1), GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_word - first_word + 1,
+                                   sizeof(__le16),
+                                   GFP_KERNEL);
        if (!eeprom_buff)
                return -ENOMEM;
 
index 62f2173bc20ed43b5268f7705c03c38f57aac0f8..43664adf7a3c120d024889ac59f42e2da5d5b1ae 100644 (file)
@@ -1093,8 +1093,9 @@ ixgb_set_multi(struct net_device *netdev)
                rctl |= IXGB_RCTL_MPE;
                IXGB_WRITE_REG(hw, RCTL, rctl);
        } else {
-               u8 *mta = kmalloc(IXGB_MAX_NUM_MULTICAST_ADDRESSES *
-                             ETH_ALEN, GFP_ATOMIC);
+               u8 *mta = kmalloc_array(ETH_ALEN,
+                                       IXGB_MAX_NUM_MULTICAST_ADDRESSES,
+                                       GFP_ATOMIC);
                u8 *addr;
                if (!mta)
                        goto alloc_failed;
index fc534e91c6b247ebc79c47c470445eebe20d3b48..144d5fe6b94477def970671ab94cd1fb77711bdb 100644 (file)
@@ -760,9 +760,9 @@ struct ixgbe_adapter {
 #define IXGBE_RSS_KEY_SIZE     40  /* size of RSS Hash Key in bytes */
        u32 *rss_key;
 
-#ifdef CONFIG_XFRM
+#ifdef CONFIG_XFRM_OFFLOAD
        struct ixgbe_ipsec *ipsec;
-#endif /* CONFIG_XFRM */
+#endif /* CONFIG_XFRM_OFFLOAD */
 };
 
 static inline u8 ixgbe_max_rss_indices(struct ixgbe_adapter *adapter)
index bdd179c29ea4ce5cb49fd4ea0b7d96436f5c82cc..bd1ba88ec1d562fbb114a8fc75077edab634ff89 100644 (file)
@@ -901,7 +901,7 @@ static int ixgbe_get_eeprom(struct net_device *netdev,
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
        eeprom_len = last_word - first_word + 1;
 
-       eeprom_buff = kmalloc(sizeof(u16) * eeprom_len, GFP_KERNEL);
+       eeprom_buff = kmalloc_array(eeprom_len, sizeof(u16), GFP_KERNEL);
        if (!eeprom_buff)
                return -ENOMEM;
 
@@ -1063,7 +1063,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
        /* allocate temporary buffer to store rings in */
        i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues,
                  adapter->num_rx_queues);
-       temp_ring = vmalloc(i * sizeof(struct ixgbe_ring));
+       temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
 
        if (!temp_ring) {
                err = -ENOMEM;
index 344a1f213a5f5e150c86777a343cc96cc641c58e..c116f459945d62455843d4e9262971630dd45099 100644 (file)
@@ -158,7 +158,16 @@ static void ixgbe_ipsec_stop_data(struct ixgbe_adapter *adapter)
        reg |= IXGBE_SECRXCTRL_RX_DIS;
        IXGBE_WRITE_REG(hw, IXGBE_SECRXCTRL, reg);
 
-       IXGBE_WRITE_FLUSH(hw);
+       /* If both Tx and Rx are ready there are no packets
+        * that we need to flush so the loopback configuration
+        * below is not necessary.
+        */
+       t_rdy = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT) &
+               IXGBE_SECTXSTAT_SECTX_RDY;
+       r_rdy = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT) &
+               IXGBE_SECRXSTAT_SECRX_RDY;
+       if (t_rdy && r_rdy)
+               return;
 
        /* If the tx fifo doesn't have link, but still has data,
         * we can't clear the tx sec block.  Set the MAC loopback
@@ -185,7 +194,7 @@ static void ixgbe_ipsec_stop_data(struct ixgbe_adapter *adapter)
                        IXGBE_SECTXSTAT_SECTX_RDY;
                r_rdy = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT) &
                        IXGBE_SECRXSTAT_SECRX_RDY;
-       } while (!t_rdy && !r_rdy && limit--);
+       } while (!(t_rdy && r_rdy) && limit--);
 
        /* undo loopback if we played with it earlier */
        if (!link) {
@@ -966,10 +975,22 @@ void ixgbe_ipsec_rx(struct ixgbe_ring *rx_ring,
  **/
 void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter)
 {
+       struct ixgbe_hw *hw = &adapter->hw;
        struct ixgbe_ipsec *ipsec;
+       u32 t_dis, r_dis;
        size_t size;
 
-       if (adapter->hw.mac.type == ixgbe_mac_82598EB)
+       if (hw->mac.type == ixgbe_mac_82598EB)
+               return;
+
+       /* If there is no support for either Tx or Rx offload
+        * we should not be advertising support for IPsec.
+        */
+       t_dis = IXGBE_READ_REG(hw, IXGBE_SECTXSTAT) &
+               IXGBE_SECTXSTAT_SECTX_OFF_DIS;
+       r_dis = IXGBE_READ_REG(hw, IXGBE_SECRXSTAT) &
+               IXGBE_SECRXSTAT_SECRX_OFF_DIS;
+       if (t_dis || r_dis)
                return;
 
        ipsec = kzalloc(sizeof(*ipsec), GFP_KERNEL);
@@ -1001,13 +1022,6 @@ void ixgbe_init_ipsec_offload(struct ixgbe_adapter *adapter)
 
        adapter->netdev->xfrmdev_ops = &ixgbe_xfrmdev_ops;
 
-#define IXGBE_ESP_FEATURES     (NETIF_F_HW_ESP | \
-                                NETIF_F_HW_ESP_TX_CSUM | \
-                                NETIF_F_GSO_ESP)
-
-       adapter->netdev->features |= IXGBE_ESP_FEATURES;
-       adapter->netdev->hw_enc_features |= IXGBE_ESP_FEATURES;
-
        return;
 
 err2:
index 893a9206e718611250196fb6459d80d73d58cd64..d361f570ca37be6a8df4cd2e2c7a806cee8b1a54 100644 (file)
@@ -593,6 +593,14 @@ static bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)
        }
 
 #endif
+       /* To support macvlan offload we have to use num_tc to
+        * restrict the queues that can be used by the device.
+        * By doing this we can avoid reporting a false number of
+        * queues.
+        */
+       if (vmdq_i > 1)
+               netdev_set_num_tc(adapter->netdev, 1);
+
        /* populate TC0 for use by pool 0 */
        netdev_set_tc_queue(adapter->netdev, 0,
                            adapter->num_rx_queues_per_pool, 0);
index 4929f726559850622a54ae1281c530c0b2c5095e..3e87dbbc90246dba3a59e3f8ccded5885b441ae2 100644 (file)
@@ -6034,8 +6034,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter,
        for (i = 1; i < IXGBE_MAX_LINK_HANDLE; i++)
                adapter->jump_tables[i] = NULL;
 
-       adapter->mac_table = kzalloc(sizeof(struct ixgbe_mac_addr) *
-                                    hw->mac.num_rar_entries,
+       adapter->mac_table = kcalloc(hw->mac.num_rar_entries,
+                                    sizeof(struct ixgbe_mac_addr),
                                     GFP_ATOMIC);
        if (!adapter->mac_table)
                return -ENOMEM;
@@ -6117,6 +6117,7 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter,
 #ifdef CONFIG_IXGBE_DCB
        ixgbe_init_dcb(adapter);
 #endif
+       ixgbe_init_ipsec_offload(adapter);
 
        /* default flow control settings */
        hw->fc.requested_mode = ixgbe_fc_full;
@@ -8822,14 +8823,6 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)
        } else {
                netdev_reset_tc(dev);
 
-               /* To support macvlan offload we have to use num_tc to
-                * restrict the queues that can be used by the device.
-                * By doing this we can avoid reporting a false number of
-                * queues.
-                */
-               if (!tc && adapter->num_rx_pools > 1)
-                       netdev_set_num_tc(dev, 1);
-
                if (adapter->hw.mac.type == ixgbe_mac_82598EB)
                        adapter->hw.fc.requested_mode = adapter->last_lfc_mode;
 
@@ -9904,7 +9897,7 @@ ixgbe_features_check(struct sk_buff *skb, struct net_device *dev,
         * the TSO, so it's the exception.
         */
        if (skb->encapsulation && !(features & NETIF_F_TSO_MANGLEID)) {
-#ifdef CONFIG_XFRM
+#ifdef CONFIG_XFRM_OFFLOAD
                if (!skb->sp)
 #endif
                        features &= ~NETIF_F_TSO;
@@ -10437,6 +10430,14 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
        if (hw->mac.type >= ixgbe_mac_82599EB)
                netdev->features |= NETIF_F_SCTP_CRC;
 
+#ifdef CONFIG_XFRM_OFFLOAD
+#define IXGBE_ESP_FEATURES     (NETIF_F_HW_ESP | \
+                                NETIF_F_HW_ESP_TX_CSUM | \
+                                NETIF_F_GSO_ESP)
+
+       if (adapter->ipsec)
+               netdev->features |= IXGBE_ESP_FEATURES;
+#endif
        /* copy netdev features into list of user selectable features */
        netdev->hw_features |= netdev->features |
                               NETIF_F_HW_VLAN_CTAG_FILTER |
@@ -10499,8 +10500,6 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                                         NETIF_F_FCOE_MTU;
        }
 #endif /* IXGBE_FCOE */
-       ixgbe_init_ipsec_offload(adapter);
-
        if (adapter->flags2 & IXGBE_FLAG2_RSC_CAPABLE)
                netdev->hw_features |= NETIF_F_LRO;
        if (adapter->flags2 & IXGBE_FLAG2_RSC_ENABLED)
index e8ed37749ab1c91be3223a9ff727cd33ca21a046..44cfb2021145b9be9284c3862c52abf5c5ba6f82 100644 (file)
@@ -599,13 +599,15 @@ struct ixgbe_nvm_version {
 #define IXGBE_SECTXCTRL_STORE_FORWARD   0x00000004
 
 #define IXGBE_SECTXSTAT_SECTX_RDY       0x00000001
-#define IXGBE_SECTXSTAT_ECC_TXERR       0x00000002
+#define IXGBE_SECTXSTAT_SECTX_OFF_DIS   0x00000002
+#define IXGBE_SECTXSTAT_ECC_TXERR       0x00000004
 
 #define IXGBE_SECRXCTRL_SECRX_DIS       0x00000001
 #define IXGBE_SECRXCTRL_RX_DIS          0x00000002
 
 #define IXGBE_SECRXSTAT_SECRX_RDY       0x00000001
-#define IXGBE_SECRXSTAT_ECC_RXERR       0x00000002
+#define IXGBE_SECRXSTAT_SECRX_OFF_DIS   0x00000002
+#define IXGBE_SECRXSTAT_ECC_RXERR       0x00000004
 
 /* LinkSec (MacSec) Registers */
 #define IXGBE_LSECTXCAP         0x08A00
index e7813d76527cc4ff5e1b28a94f96a8682ecf5e3a..631c91046f3975f429d042b3c567201c6fe93973 100644 (file)
@@ -282,8 +282,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
        }
 
        if (new_tx_count != adapter->tx_ring_count) {
-               tx_ring = vmalloc((adapter->num_tx_queues +
-                                  adapter->num_xdp_queues) * sizeof(*tx_ring));
+               tx_ring = vmalloc(array_size(sizeof(*tx_ring),
+                                            adapter->num_tx_queues +
+                                               adapter->num_xdp_queues));
                if (!tx_ring) {
                        err = -ENOMEM;
                        goto clear_reset;
@@ -327,7 +328,8 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
        }
 
        if (new_rx_count != adapter->rx_ring_count) {
-               rx_ring = vmalloc(adapter->num_rx_queues * sizeof(*rx_ring));
+               rx_ring = vmalloc(array_size(sizeof(*rx_ring),
+                                            adapter->num_rx_queues));
                if (!rx_ring) {
                        err = -ENOMEM;
                        goto clear_reset;
index 8a165842fa8558123e611507cd39a00d9c534f86..06ff185eb1882ee6e6425baed1e35eca38d6bd2f 100644 (file)
@@ -589,8 +589,9 @@ jme_setup_tx_resources(struct jme_adapter *jme)
        atomic_set(&txring->next_to_clean, 0);
        atomic_set(&txring->nr_free, jme->tx_ring_size);
 
-       txring->bufinf          = kzalloc(sizeof(struct jme_buffer_info) *
-                                       jme->tx_ring_size, GFP_ATOMIC);
+       txring->bufinf          = kcalloc(jme->tx_ring_size,
+                                               sizeof(struct jme_buffer_info),
+                                               GFP_ATOMIC);
        if (unlikely(!(txring->bufinf)))
                goto err_free_txring;
 
@@ -838,8 +839,9 @@ jme_setup_rx_resources(struct jme_adapter *jme)
        rxring->next_to_use     = 0;
        atomic_set(&rxring->next_to_clean, 0);
 
-       rxring->bufinf          = kzalloc(sizeof(struct jme_buffer_info) *
-                                       jme->rx_ring_size, GFP_ATOMIC);
+       rxring->bufinf          = kcalloc(jme->rx_ring_size,
+                                               sizeof(struct jme_buffer_info),
+                                               GFP_ATOMIC);
        if (unlikely(!(rxring->bufinf)))
                goto err_free_rxring;
 
index 6dabd983e7e0fff578cda18e529a8510f13452c9..4bdf2505954271071007a748be8b901fee12fcef 100644 (file)
@@ -185,8 +185,8 @@ int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask,
        bitmap->avail = num - reserved_top - reserved_bot;
        bitmap->effective_len = bitmap->avail;
        spin_lock_init(&bitmap->lock);
-       bitmap->table = kzalloc(BITS_TO_LONGS(bitmap->max) *
-                               sizeof(long), GFP_KERNEL);
+       bitmap->table = kcalloc(BITS_TO_LONGS(bitmap->max), sizeof(long),
+                               GFP_KERNEL);
        if (!bitmap->table)
                return -ENOMEM;
 
index 6a9086dc1e92771fc454a1f0452b5f622c5f348c..e65bc3c95630a184309e3fad5ce77080d457b750 100644 (file)
@@ -2377,20 +2377,23 @@ int mlx4_multi_func_init(struct mlx4_dev *dev)
                struct mlx4_vf_admin_state *vf_admin;
 
                priv->mfunc.master.slave_state =
-                       kzalloc(dev->num_slaves *
-                               sizeof(struct mlx4_slave_state), GFP_KERNEL);
+                       kcalloc(dev->num_slaves,
+                               sizeof(struct mlx4_slave_state),
+                               GFP_KERNEL);
                if (!priv->mfunc.master.slave_state)
                        goto err_comm;
 
                priv->mfunc.master.vf_admin =
-                       kzalloc(dev->num_slaves *
-                               sizeof(struct mlx4_vf_admin_state), GFP_KERNEL);
+                       kcalloc(dev->num_slaves,
+                               sizeof(struct mlx4_vf_admin_state),
+                               GFP_KERNEL);
                if (!priv->mfunc.master.vf_admin)
                        goto err_comm_admin;
 
                priv->mfunc.master.vf_oper =
-                       kzalloc(dev->num_slaves *
-                               sizeof(struct mlx4_vf_oper_state), GFP_KERNEL);
+                       kcalloc(dev->num_slaves,
+                               sizeof(struct mlx4_vf_oper_state),
+                               GFP_KERNEL);
                if (!priv->mfunc.master.vf_oper)
                        goto err_comm_oper;
 
@@ -2636,9 +2639,9 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev)
        int i;
        int err = 0;
 
-       priv->cmd.context = kmalloc(priv->cmd.max_cmds *
-                                  sizeof(struct mlx4_cmd_context),
-                                  GFP_KERNEL);
+       priv->cmd.context = kmalloc_array(priv->cmd.max_cmds,
+                                         sizeof(struct mlx4_cmd_context),
+                                         GFP_KERNEL);
        if (!priv->cmd.context)
                return -ENOMEM;
 
index 9670b33fc9b1ffd64a160bb1186af2f47419ab38..65eb06e017e401237842503bc3aabad3780c1a2e 100644 (file)
@@ -2229,13 +2229,15 @@ static int mlx4_en_copy_priv(struct mlx4_en_priv *dst,
                if (!dst->tx_ring_num[t])
                        continue;
 
-               dst->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) *
-                                         MAX_TX_RINGS, GFP_KERNEL);
+               dst->tx_ring[t] = kcalloc(MAX_TX_RINGS,
+                                         sizeof(struct mlx4_en_tx_ring *),
+                                         GFP_KERNEL);
                if (!dst->tx_ring[t])
                        goto err_free_tx;
 
-               dst->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) *
-                                       MAX_TX_RINGS, GFP_KERNEL);
+               dst->tx_cq[t] = kcalloc(MAX_TX_RINGS,
+                                       sizeof(struct mlx4_en_cq *),
+                                       GFP_KERNEL);
                if (!dst->tx_cq[t]) {
                        kfree(dst->tx_ring[t]);
                        goto err_free_tx;
@@ -3320,14 +3322,16 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port,
                if (!priv->tx_ring_num[t])
                        continue;
 
-               priv->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) *
-                                          MAX_TX_RINGS, GFP_KERNEL);
+               priv->tx_ring[t] = kcalloc(MAX_TX_RINGS,
+                                          sizeof(struct mlx4_en_tx_ring *),
+                                          GFP_KERNEL);
                if (!priv->tx_ring[t]) {
                        err = -ENOMEM;
                        goto out;
                }
-               priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) *
-                                        MAX_TX_RINGS, GFP_KERNEL);
+               priv->tx_cq[t] = kcalloc(MAX_TX_RINGS,
+                                        sizeof(struct mlx4_en_cq *),
+                                        GFP_KERNEL);
                if (!priv->tx_cq[t]) {
                        err = -ENOMEM;
                        goto out;
index 6f57c052053e24e3ee2bde0e70ddd94c2edb7883..1f3372c1802ed0185cdb4f8ef309479549ceb3db 100644 (file)
@@ -1211,8 +1211,9 @@ int mlx4_init_eq_table(struct mlx4_dev *dev)
        }
 
        priv->eq_table.irq_names =
-               kmalloc(MLX4_IRQNAME_SIZE * (dev->caps.num_comp_vectors + 1),
-                       GFP_KERNEL);
+               kmalloc_array(MLX4_IRQNAME_SIZE,
+                             (dev->caps.num_comp_vectors + 1),
+                             GFP_KERNEL);
        if (!priv->eq_table.irq_names) {
                err = -ENOMEM;
                goto err_out_clr_int;
index 5342bd8a3d0bfaa9e76bb9b6943790606c97b181..7262c6310650e0516bb8dbe08c8dd6038814f503 100644 (file)
@@ -408,7 +408,7 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table,
                return -EINVAL;
        num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk;
 
-       table->icm      = kvzalloc(num_icm * sizeof(*table->icm), GFP_KERNEL);
+       table->icm      = kvcalloc(num_icm, sizeof(*table->icm), GFP_KERNEL);
        if (!table->icm)
                return -ENOMEM;
        table->virt     = virt;
index 0a30d81aab3ba3c94754a54e69e5051e2d562233..872014702fc1b0def72197f9e1b505849a5c72da 100644 (file)
@@ -2982,7 +2982,8 @@ static int mlx4_init_steering(struct mlx4_dev *dev)
        int num_entries = dev->caps.num_ports;
        int i, j;
 
-       priv->steer = kzalloc(sizeof(struct mlx4_steer) * num_entries, GFP_KERNEL);
+       priv->steer = kcalloc(num_entries, sizeof(struct mlx4_steer),
+                             GFP_KERNEL);
        if (!priv->steer)
                return -ENOMEM;
 
@@ -3103,7 +3104,7 @@ static u64 mlx4_enable_sriov(struct mlx4_dev *dev, struct pci_dev *pdev,
                }
        }
 
-       dev->dev_vfs = kzalloc(total_vfs * sizeof(*dev->dev_vfs), GFP_KERNEL);
+       dev->dev_vfs = kcalloc(total_vfs, sizeof(*dev->dev_vfs), GFP_KERNEL);
        if (NULL == dev->dev_vfs) {
                mlx4_err(dev, "Failed to allocate memory for VFs\n");
                goto disable_sriov;
index 29e50f787349c986cdb8b954c783b54efeab770f..7b1b5ac986d0779db320ad986c13defa5db82949 100644 (file)
@@ -487,7 +487,7 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
        int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev);
 
        priv->mfunc.master.res_tracker.slave_list =
-               kzalloc(dev->num_slaves * sizeof(struct slave_list),
+               kcalloc(dev->num_slaves, sizeof(struct slave_list),
                        GFP_KERNEL);
        if (!priv->mfunc.master.res_tracker.slave_list)
                return -ENOMEM;
@@ -507,19 +507,21 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev)
        for (i = 0; i < MLX4_NUM_OF_RESOURCE_TYPE; i++) {
                struct resource_allocator *res_alloc =
                        &priv->mfunc.master.res_tracker.res_alloc[i];
-               res_alloc->quota = kmalloc((dev->persist->num_vfs + 1) *
-                                          sizeof(int), GFP_KERNEL);
-               res_alloc->guaranteed = kmalloc((dev->persist->num_vfs + 1) *
-                                               sizeof(int), GFP_KERNEL);
+               res_alloc->quota = kmalloc_array(dev->persist->num_vfs + 1,
+                                                sizeof(int),
+                                                GFP_KERNEL);
+               res_alloc->guaranteed = kmalloc_array(dev->persist->num_vfs + 1,
+                                                     sizeof(int),
+                                                     GFP_KERNEL);
                if (i == RES_MAC || i == RES_VLAN)
-                       res_alloc->allocated = kzalloc(MLX4_MAX_PORTS *
-                                                      (dev->persist->num_vfs
-                                                      + 1) *
-                                                      sizeof(int), GFP_KERNEL);
+                       res_alloc->allocated =
+                               kcalloc(MLX4_MAX_PORTS *
+                                               (dev->persist->num_vfs + 1),
+                                       sizeof(int), GFP_KERNEL);
                else
-                       res_alloc->allocated = kzalloc((dev->persist->
-                                                       num_vfs + 1) *
-                                                      sizeof(int), GFP_KERNEL);
+                       res_alloc->allocated =
+                               kcalloc(dev->persist->num_vfs + 1,
+                                       sizeof(int), GFP_KERNEL);
                /* Reduce the sink counter */
                if (i == RES_COUNTER)
                        res_alloc->res_free = dev->caps.max_counters - 1;
index 89c96a0f708e780d13062415f7f5e1e023343654..56c1b6f5593e053d4629b15635bacf1ece9d6a88 100644 (file)
@@ -352,7 +352,7 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq,
 {
        int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq);
 
-       rq->mpwqe.info = kzalloc_node(wq_sz * sizeof(*rq->mpwqe.info),
+       rq->mpwqe.info = kcalloc_node(wq_sz, sizeof(*rq->mpwqe.info),
                                      GFP_KERNEL, cpu_to_node(c->cpu));
        if (!rq->mpwqe.info)
                return -ENOMEM;
@@ -448,7 +448,7 @@ static int mlx5e_init_di_list(struct mlx5e_rq *rq,
 {
        int len = wq_sz << rq->wqe.info.log_num_frags;
 
-       rq->wqe.di = kvzalloc_node(len * sizeof(*rq->wqe.di),
+       rq->wqe.di = kvzalloc_node(array_size(len, sizeof(*rq->wqe.di)),
                                   GFP_KERNEL, cpu_to_node(cpu));
        if (!rq->wqe.di)
                return -ENOMEM;
@@ -563,8 +563,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c,
 
                rq->wqe.info = rqp->frags_info;
                rq->wqe.frags =
-                       kvzalloc_node((wq_sz << rq->wqe.info.log_num_frags) *
-                                     sizeof(*rq->wqe.frags),
+                       kvzalloc_node(array_size(sizeof(*rq->wqe.frags),
+                                       (wq_sz << rq->wqe.info.log_num_frags)),
                                      GFP_KERNEL, cpu_to_node(c->cpu));
                if (!rq->wqe.frags) {
                        err = -ENOMEM;
@@ -972,7 +972,7 @@ static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa)
 {
        int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
 
-       sq->db.di = kzalloc_node(sizeof(*sq->db.di) * wq_sz,
+       sq->db.di = kcalloc_node(wq_sz, sizeof(*sq->db.di),
                                     GFP_KERNEL, numa);
        if (!sq->db.di) {
                mlx5e_free_xdpsq_db(sq);
@@ -1031,7 +1031,7 @@ static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa)
 {
        u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
 
-       sq->db.ico_wqe = kzalloc_node(sizeof(*sq->db.ico_wqe) * wq_sz,
+       sq->db.ico_wqe = kcalloc_node(wq_sz, sizeof(*sq->db.ico_wqe),
                                      GFP_KERNEL, numa);
        if (!sq->db.ico_wqe)
                return -ENOMEM;
@@ -1086,9 +1086,9 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa)
        int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
        int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
 
-       sq->db.dma_fifo = kzalloc_node(df_sz * sizeof(*sq->db.dma_fifo),
+       sq->db.dma_fifo = kcalloc_node(df_sz, sizeof(*sq->db.dma_fifo),
                                           GFP_KERNEL, numa);
-       sq->db.wqe_info = kzalloc_node(wq_sz * sizeof(*sq->db.wqe_info),
+       sq->db.wqe_info = kcalloc_node(wq_sz, sizeof(*sq->db.wqe_info),
                                           GFP_KERNEL, numa);
        if (!sq->db.dma_fifo || !sq->db.wqe_info) {
                mlx5e_free_txqsq_db(sq);
index 4138a770ed5713bf25e100754f3b693e5e212827..8ca1d1949d930d46d0cf7c386383e060640ff792 100644 (file)
@@ -549,15 +549,17 @@ static int mlx5_fpga_conn_create_qp(struct mlx5_fpga_conn *conn,
        if (err)
                goto out;
 
-       conn->qp.rq.bufs = kvzalloc(sizeof(conn->qp.rq.bufs[0]) *
-                                   conn->qp.rq.size, GFP_KERNEL);
+       conn->qp.rq.bufs = kvcalloc(conn->qp.rq.size,
+                                   sizeof(conn->qp.rq.bufs[0]),
+                                   GFP_KERNEL);
        if (!conn->qp.rq.bufs) {
                err = -ENOMEM;
                goto err_wq;
        }
 
-       conn->qp.sq.bufs = kvzalloc(sizeof(conn->qp.sq.bufs[0]) *
-                                   conn->qp.sq.size, GFP_KERNEL);
+       conn->qp.sq.bufs = kvcalloc(conn->qp.sq.size,
+                                   sizeof(conn->qp.sq.bufs[0]),
+                                   GFP_KERNEL);
        if (!conn->qp.sq.bufs) {
                err = -ENOMEM;
                goto err_rq_bufs;
index a0433b48e8331d9eb2f892c172effc1313d0bd7c..5645a4facad2f3e5cc1a4a48553e6f83142e72dc 100644 (file)
@@ -381,7 +381,7 @@ int mlx5_fpga_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters,
 
        count = mlx5_fpga_ipsec_counters_count(mdev);
 
-       data = kzalloc(sizeof(*data) * count * 2, GFP_KERNEL);
+       data = kzalloc(array3_size(sizeof(*data), count, 2), GFP_KERNEL);
        if (!data) {
                ret = -ENOMEM;
                goto out;
index 857035583ccdd156c7913c001c1509e0cde044bb..1e062e6b2587eb7217fbeca7260844ee7c2b465a 100644 (file)
@@ -394,8 +394,9 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock)
        int i;
 
        clock->ptp_info.pin_config =
-                       kzalloc(sizeof(*clock->ptp_info.pin_config) *
-                               clock->ptp_info.n_pins, GFP_KERNEL);
+                       kcalloc(clock->ptp_info.n_pins,
+                               sizeof(*clock->ptp_info.pin_config),
+                               GFP_KERNEL);
        if (!clock->ptp_info.pin_config)
                return -ENOMEM;
        clock->ptp_info.enable = mlx5_ptp_enable;
index 91262b0573e395c982bc97186f9b699a2cf0bbd0..cad603c35271bac2de3303713f9a1f181931f214 100644 (file)
@@ -740,7 +740,8 @@ int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port)
        mlxsw_sp_port->root_qdisc->prio_bitmap = 0xff;
        mlxsw_sp_port->root_qdisc->tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS;
 
-       mlxsw_sp_qdisc = kzalloc(sizeof(*mlxsw_sp_qdisc) * IEEE_8021QAZ_MAX_TCS,
+       mlxsw_sp_qdisc = kcalloc(IEEE_8021QAZ_MAX_TCS,
+                                sizeof(*mlxsw_sp_qdisc),
                                 GFP_KERNEL);
        if (!mlxsw_sp_qdisc)
                goto err_tclass_qdiscs_init;
index 77b2adb293415a9de16caaabbd203b397cd12a4a..6aaaf3d9ba31d9538d9307caa0450a848bf6b091 100644 (file)
@@ -4756,12 +4756,6 @@ static void mlxsw_sp_rt6_destroy(struct mlxsw_sp_rt6 *mlxsw_sp_rt6)
        kfree(mlxsw_sp_rt6);
 }
 
-static bool mlxsw_sp_fib6_rt_can_mp(const struct fib6_info *rt)
-{
-       /* RTF_CACHE routes are ignored */
-       return (rt->fib6_flags & (RTF_GATEWAY | RTF_ADDRCONF)) == RTF_GATEWAY;
-}
-
 static struct fib6_info *
 mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry)
 {
@@ -4771,11 +4765,11 @@ mlxsw_sp_fib6_entry_rt(const struct mlxsw_sp_fib6_entry *fib6_entry)
 
 static struct mlxsw_sp_fib6_entry *
 mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,
-                                const struct fib6_info *nrt, bool replace)
+                                const struct fib6_info *nrt, bool append)
 {
        struct mlxsw_sp_fib6_entry *fib6_entry;
 
-       if (!mlxsw_sp_fib6_rt_can_mp(nrt) || replace)
+       if (!append)
                return NULL;
 
        list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) {
@@ -4790,8 +4784,7 @@ mlxsw_sp_fib6_node_mp_entry_find(const struct mlxsw_sp_fib_node *fib_node,
                        break;
                if (rt->fib6_metric < nrt->fib6_metric)
                        continue;
-               if (rt->fib6_metric == nrt->fib6_metric &&
-                   mlxsw_sp_fib6_rt_can_mp(rt))
+               if (rt->fib6_metric == nrt->fib6_metric)
                        return fib6_entry;
                if (rt->fib6_metric > nrt->fib6_metric)
                        break;
@@ -5170,7 +5163,7 @@ static struct mlxsw_sp_fib6_entry *
 mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node,
                              const struct fib6_info *nrt, bool replace)
 {
-       struct mlxsw_sp_fib6_entry *fib6_entry, *fallback = NULL;
+       struct mlxsw_sp_fib6_entry *fib6_entry;
 
        list_for_each_entry(fib6_entry, &fib_node->entry_list, common.list) {
                struct fib6_info *rt = mlxsw_sp_fib6_entry_rt(fib6_entry);
@@ -5179,18 +5172,13 @@ mlxsw_sp_fib6_node_entry_find(const struct mlxsw_sp_fib_node *fib_node,
                        continue;
                if (rt->fib6_table->tb6_id != nrt->fib6_table->tb6_id)
                        break;
-               if (replace && rt->fib6_metric == nrt->fib6_metric) {
-                       if (mlxsw_sp_fib6_rt_can_mp(rt) ==
-                           mlxsw_sp_fib6_rt_can_mp(nrt))
-                               return fib6_entry;
-                       if (mlxsw_sp_fib6_rt_can_mp(nrt))
-                               fallback = fallback ?: fib6_entry;
-               }
+               if (replace && rt->fib6_metric == nrt->fib6_metric)
+                       return fib6_entry;
                if (rt->fib6_metric > nrt->fib6_metric)
-                       return fallback ?: fib6_entry;
+                       return fib6_entry;
        }
 
-       return fallback;
+       return NULL;
 }
 
 static int
@@ -5316,7 +5304,8 @@ static void mlxsw_sp_fib6_entry_replace(struct mlxsw_sp *mlxsw_sp,
 }
 
 static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
-                                   struct fib6_info *rt, bool replace)
+                                   struct fib6_info *rt, bool replace,
+                                   bool append)
 {
        struct mlxsw_sp_fib6_entry *fib6_entry;
        struct mlxsw_sp_fib_node *fib_node;
@@ -5342,7 +5331,7 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
        /* Before creating a new entry, try to append route to an existing
         * multipath entry.
         */
-       fib6_entry = mlxsw_sp_fib6_node_mp_entry_find(fib_node, rt, replace);
+       fib6_entry = mlxsw_sp_fib6_node_mp_entry_find(fib_node, rt, append);
        if (fib6_entry) {
                err = mlxsw_sp_fib6_entry_nexthop_add(mlxsw_sp, fib6_entry, rt);
                if (err)
@@ -5350,6 +5339,14 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
                return 0;
        }
 
+       /* We received an append event, yet did not find any route to
+        * append to.
+        */
+       if (WARN_ON(append)) {
+               err = -EINVAL;
+               goto err_fib6_entry_append;
+       }
+
        fib6_entry = mlxsw_sp_fib6_entry_create(mlxsw_sp, fib_node, rt);
        if (IS_ERR(fib6_entry)) {
                err = PTR_ERR(fib6_entry);
@@ -5367,6 +5364,7 @@ static int mlxsw_sp_router_fib6_add(struct mlxsw_sp *mlxsw_sp,
 err_fib6_node_entry_link:
        mlxsw_sp_fib6_entry_destroy(mlxsw_sp, fib6_entry);
 err_fib6_entry_create:
+err_fib6_entry_append:
 err_fib6_entry_nexthop_add:
        mlxsw_sp_fib_node_put(mlxsw_sp, fib_node);
        return err;
@@ -5717,7 +5715,7 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
        struct mlxsw_sp_fib_event_work *fib_work =
                container_of(work, struct mlxsw_sp_fib_event_work, work);
        struct mlxsw_sp *mlxsw_sp = fib_work->mlxsw_sp;
-       bool replace;
+       bool replace, append;
        int err;
 
        rtnl_lock();
@@ -5728,8 +5726,10 @@ static void mlxsw_sp_router_fib6_event_work(struct work_struct *work)
        case FIB_EVENT_ENTRY_APPEND: /* fall through */
        case FIB_EVENT_ENTRY_ADD:
                replace = fib_work->event == FIB_EVENT_ENTRY_REPLACE;
+               append = fib_work->event == FIB_EVENT_ENTRY_APPEND;
                err = mlxsw_sp_router_fib6_add(mlxsw_sp,
-                                              fib_work->fen6_info.rt, replace);
+                                              fib_work->fen6_info.rt, replace,
+                                              append);
                if (err)
                        mlxsw_sp_router_fib_abort(mlxsw_sp);
                mlxsw_sp_rt6_release(fib_work->fen6_info.rt);
index e97652c40d13a40fad9bb71e2c554b9d3933bef5..eea5666a86b2ae341524710e678d4caf5776a18b 100644 (file)
@@ -1018,8 +1018,10 @@ mlxsw_sp_port_vlan_bridge_join(struct mlxsw_sp_port_vlan *mlxsw_sp_port_vlan,
        int err;
 
        /* No need to continue if only VLAN flags were changed */
-       if (mlxsw_sp_port_vlan->bridge_port)
+       if (mlxsw_sp_port_vlan->bridge_port) {
+               mlxsw_sp_port_vlan_put(mlxsw_sp_port_vlan);
                return 0;
+       }
 
        err = mlxsw_sp_port_vlan_fid_join(mlxsw_sp_port_vlan, bridge_port);
        if (err)
index 52207508744cafbf8243533b35ab99d9e70567d0..b72d1bd11296bba36c83e1252fcfa0a397ee5c84 100644 (file)
@@ -4372,7 +4372,7 @@ static void ksz_update_timer(struct ksz_timer_info *info)
  */
 static int ksz_alloc_soft_desc(struct ksz_desc_info *desc_info, int transmit)
 {
-       desc_info->ring = kzalloc(sizeof(struct ksz_desc) * desc_info->alloc,
+       desc_info->ring = kcalloc(desc_info->alloc, sizeof(struct ksz_desc),
                                  GFP_KERNEL);
        if (!desc_info->ring)
                return 1;
index 2e4effa9fe456d4c0e8029136bf99cffad407dd2..b34055ac476f72191ca498ad11808f47fedac767 100644 (file)
@@ -507,15 +507,15 @@ static int moxart_mac_probe(struct platform_device *pdev)
                goto init_fail;
        }
 
-       priv->tx_buf_base = kmalloc(priv->tx_buf_size * TX_DESC_NUM,
-                                   GFP_ATOMIC);
+       priv->tx_buf_base = kmalloc_array(priv->tx_buf_size, TX_DESC_NUM,
+                                         GFP_ATOMIC);
        if (!priv->tx_buf_base) {
                ret = -ENOMEM;
                goto init_fail;
        }
 
-       priv->rx_buf_base = kmalloc(priv->rx_buf_size * RX_DESC_NUM,
-                                   GFP_ATOMIC);
+       priv->rx_buf_base = kmalloc_array(priv->rx_buf_size, RX_DESC_NUM,
+                                         GFP_ATOMIC);
        if (!priv->rx_buf_base) {
                ret = -ENOMEM;
                goto init_fail;
index c60da9e8bf143ceadace9e08dc2033a359f47253..358ed6118881567c960a56fc876aebf8f5259ba9 100644 (file)
@@ -2220,22 +2220,22 @@ __vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph,
        channel->length = length;
        channel->vp_id = vp_id;
 
-       channel->work_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
+       channel->work_arr = kcalloc(length, sizeof(void *), GFP_KERNEL);
        if (channel->work_arr == NULL)
                goto exit1;
 
-       channel->free_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
+       channel->free_arr = kcalloc(length, sizeof(void *), GFP_KERNEL);
        if (channel->free_arr == NULL)
                goto exit1;
        channel->free_ptr = length;
 
-       channel->reserve_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
+       channel->reserve_arr = kcalloc(length, sizeof(void *), GFP_KERNEL);
        if (channel->reserve_arr == NULL)
                goto exit1;
        channel->reserve_ptr = length;
        channel->reserve_top = 0;
 
-       channel->orig_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
+       channel->orig_arr = kcalloc(length, sizeof(void *), GFP_KERNEL);
        if (channel->orig_arr == NULL)
                goto exit1;
 
@@ -2565,7 +2565,7 @@ __vxge_hw_mempool_grow(struct vxge_hw_mempool *mempool, u32 num_allocate,
                 * allocate new memblock and its private part at once.
                 * This helps to minimize memory usage a lot. */
                mempool->memblocks_priv_arr[i] =
-                               vzalloc(mempool->items_priv_size * n_items);
+                       vzalloc(array_size(mempool->items_priv_size, n_items));
                if (mempool->memblocks_priv_arr[i] == NULL) {
                        status = VXGE_HW_ERR_OUT_OF_MEMORY;
                        goto exit;
@@ -2665,7 +2665,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh,
 
        /* allocate array of memblocks */
        mempool->memblocks_arr =
-               vzalloc(sizeof(void *) * mempool->memblocks_max);
+               vzalloc(array_size(sizeof(void *), mempool->memblocks_max));
        if (mempool->memblocks_arr == NULL) {
                __vxge_hw_mempool_destroy(mempool);
                status = VXGE_HW_ERR_OUT_OF_MEMORY;
@@ -2675,7 +2675,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh,
 
        /* allocate array of private parts of items per memblocks */
        mempool->memblocks_priv_arr =
-               vzalloc(sizeof(void *) * mempool->memblocks_max);
+               vzalloc(array_size(sizeof(void *), mempool->memblocks_max));
        if (mempool->memblocks_priv_arr == NULL) {
                __vxge_hw_mempool_destroy(mempool);
                status = VXGE_HW_ERR_OUT_OF_MEMORY;
@@ -2685,8 +2685,8 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh,
 
        /* allocate array of memblocks DMA objects */
        mempool->memblocks_dma_arr =
-               vzalloc(sizeof(struct vxge_hw_mempool_dma) *
-                       mempool->memblocks_max);
+               vzalloc(array_size(sizeof(struct vxge_hw_mempool_dma),
+                                  mempool->memblocks_max));
        if (mempool->memblocks_dma_arr == NULL) {
                __vxge_hw_mempool_destroy(mempool);
                status = VXGE_HW_ERR_OUT_OF_MEMORY;
@@ -2695,7 +2695,8 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh,
        }
 
        /* allocate hash array of items */
-       mempool->items_arr = vzalloc(sizeof(void *) * mempool->items_max);
+       mempool->items_arr = vzalloc(array_size(sizeof(void *),
+                                               mempool->items_max));
        if (mempool->items_arr == NULL) {
                __vxge_hw_mempool_destroy(mempool);
                status = VXGE_HW_ERR_OUT_OF_MEMORY;
index a8918bb7c8020807924e0bcf2a9b8c90afc03aa3..5ae3fa82909f8eb8c64565f1e5ac330d70573bee 100644 (file)
@@ -3429,8 +3429,8 @@ static int vxge_device_register(struct __vxge_hw_device *hldev,
        vxge_initialize_ethtool_ops(ndev);
 
        /* Allocate memory for vpath */
-       vdev->vpaths = kzalloc((sizeof(struct vxge_vpath)) *
-                               no_of_vpath, GFP_KERNEL);
+       vdev->vpaths = kcalloc(no_of_vpath, sizeof(struct vxge_vpath),
+                              GFP_KERNEL);
        if (!vdev->vpaths) {
                vxge_debug_init(VXGE_ERR,
                        "%s: vpath memory allocation failed",
index 1561c2724c26aee622bf8a5b4d32a607bd0de47f..b84a6c2d387ba6866a54d34d3007ac889363153a 100644 (file)
@@ -590,7 +590,7 @@ nfp_abm_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id)
        alink->id = id;
        alink->parent = TC_H_ROOT;
        alink->total_queues = alink->vnic->max_rx_rings;
-       alink->qdiscs = kvzalloc(sizeof(*alink->qdiscs) * alink->total_queues,
+       alink->qdiscs = kvcalloc(alink->total_queues, sizeof(*alink->qdiscs),
                                 GFP_KERNEL);
        if (!alink->qdiscs) {
                err = -ENOMEM;
index 19cfa162ac6556868c5115f0cf83a2dd03bdbd15..1decf3a1cad34cf8b8bbe50ae2fe268fc9775049 100644 (file)
@@ -455,6 +455,7 @@ static int nfp_flower_vnic_alloc(struct nfp_app *app, struct nfp_net *nn,
 
        eth_hw_addr_random(nn->dp.netdev);
        netif_keep_dst(nn->dp.netdev);
+       nn->vnic_no_name = true;
 
        return 0;
 
index 21668aa435e815508d59b65620e6ecb7574dea46..93fb809f50d1a7b0b6577c6a76ac0610e6797735 100644 (file)
@@ -417,7 +417,8 @@ int nfp_flower_metadata_init(struct nfp_app *app)
 
        /* Init ring buffer and unallocated stats_ids. */
        priv->stats_ids.free_list.buf =
-               vmalloc(NFP_FL_STATS_ENTRY_RS * NFP_FL_STATS_ELEM_RS);
+               vmalloc(array_size(NFP_FL_STATS_ELEM_RS,
+                                  NFP_FL_STATS_ENTRY_RS));
        if (!priv->stats_ids.free_list.buf)
                goto err_free_last_used;
 
index ec524d97869d6fdf12160eda47aa4043aa4fedeb..78afe75129ab5b7a852d5bffa40f5daa9b1c76d1 100644 (file)
@@ -381,6 +381,8 @@ nfp_tun_neigh_event_handler(struct notifier_block *nb, unsigned long event,
        err = PTR_ERR_OR_ZERO(rt);
        if (err)
                return NOTIFY_DONE;
+
+       ip_rt_put(rt);
 #else
        return NOTIFY_DONE;
 #endif
index 57cb035dcc6dc82afd7d0826e541c4b49e7745ac..2a71a9ffd095a87e19c4546fc0838dafd7cbb28e 100644 (file)
@@ -590,6 +590,8 @@ struct nfp_net_dp {
  * @vnic_list:         Entry on device vNIC list
  * @pdev:              Backpointer to PCI device
  * @app:               APP handle if available
+ * @vnic_no_name:      For non-port PF vNIC make ndo_get_phys_port_name return
+ *                     -EOPNOTSUPP to keep backwards compatibility (set by app)
  * @port:              Pointer to nfp_port structure if vNIC is a port
  * @app_priv:          APP private data for this vNIC
  */
@@ -663,6 +665,8 @@ struct nfp_net {
        struct pci_dev *pdev;
        struct nfp_app *app;
 
+       bool vnic_no_name;
+
        struct nfp_port *port;
 
        void *app_priv;
index 75110c8d6a9034ff049d9ff8cf5e9105618fcb76..d4c27f849f9bbfae5d2d9e795fe28a000839bc07 100644 (file)
@@ -3121,7 +3121,7 @@ static void nfp_net_stat64(struct net_device *netdev,
        struct nfp_net *nn = netdev_priv(netdev);
        int r;
 
-       for (r = 0; r < nn->dp.num_r_vecs; r++) {
+       for (r = 0; r < nn->max_r_vecs; r++) {
                struct nfp_net_r_vector *r_vec = &nn->r_vecs[r];
                u64 data[3];
                unsigned int start;
@@ -3286,7 +3286,7 @@ nfp_net_get_phys_port_name(struct net_device *netdev, char *name, size_t len)
        if (nn->port)
                return nfp_port_get_phys_port_name(netdev, name, len);
 
-       if (nn->dp.is_vf)
+       if (nn->dp.is_vf || nn->vnic_no_name)
                return -EOPNOTSUPP;
 
        n = snprintf(name, len, "n%d", nn->id);
index 2dd89dba9311ae6ec97377874f01d439729a2a67..d32af598da9081cbacfa6af9b16cb8d7f957ed50 100644 (file)
@@ -98,21 +98,18 @@ struct nfp_resource {
 
 static int nfp_cpp_resource_find(struct nfp_cpp *cpp, struct nfp_resource *res)
 {
-       char name_pad[NFP_RESOURCE_ENTRY_NAME_SZ] = {};
        struct nfp_resource_entry entry;
        u32 cpp_id, key;
        int ret, i;
 
        cpp_id = NFP_CPP_ID(NFP_RESOURCE_TBL_TARGET, 3, 0);  /* Atomic read */
 
-       strncpy(name_pad, res->name, sizeof(name_pad));
-
        /* Search for a matching entry */
-       if (!memcmp(name_pad, NFP_RESOURCE_TBL_NAME "\0\0\0\0\0\0\0\0", 8)) {
+       if (!strcmp(res->name, NFP_RESOURCE_TBL_NAME)) {
                nfp_err(cpp, "Grabbing device lock not supported\n");
                return -EOPNOTSUPP;
        }
-       key = crc32_posix(name_pad, sizeof(name_pad));
+       key = crc32_posix(res->name, NFP_RESOURCE_ENTRY_NAME_SZ);
 
        for (i = 0; i < NFP_RESOURCE_TBL_ENTRIES; i++) {
                u64 addr = NFP_RESOURCE_TBL_BASE +
index b092894dd1287bc7fe00a438ecdd7041f2bed2fe..09f674ec0f9e061930d96d1c772641e89ad3c651 100644 (file)
@@ -247,9 +247,8 @@ static int nixge_hw_dma_bd_init(struct net_device *ndev)
        if (!priv->tx_bd_v)
                goto out;
 
-       priv->tx_skb = devm_kzalloc(ndev->dev.parent,
-                                   sizeof(*priv->tx_skb) *
-                                   TX_BD_NUM,
+       priv->tx_skb = devm_kcalloc(ndev->dev.parent,
+                                   TX_BD_NUM, sizeof(*priv->tx_skb),
                                    GFP_KERNEL);
        if (!priv->tx_skb)
                goto out;
index 66c665d0b92647cfc531eebb4dd2b4486a851b13..7cbd0174459ceabb43fd1cabe96aece2dce92d27 100644 (file)
@@ -4630,8 +4630,10 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri
                                               ring->tx_pending),
                                               &ring_addr, GFP_ATOMIC);
        }
-       rx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->rx_pending, GFP_KERNEL);
-       tx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->tx_pending, GFP_KERNEL);
+       rx_skbuff = kmalloc_array(ring->rx_pending, sizeof(struct nv_skb_map),
+                                 GFP_KERNEL);
+       tx_skbuff = kmalloc_array(ring->tx_pending, sizeof(struct nv_skb_map),
+                                 GFP_KERNEL);
        if (!rxtx_ring || !rx_skbuff || !tx_skbuff) {
                /* fall back to old rings */
                if (!nv_optimized(np)) {
index 7cd494611a74027a9b2867dabc9073c1d1235662..34a1581eda95578b6350eeedf3c7372e4388953a 100644 (file)
@@ -2178,7 +2178,7 @@ static void pch_gbe_set_multi(struct net_device *netdev)
 
        if (mc_count >= PCH_GBE_MAR_ENTRIES)
                return;
-       mta_list = kmalloc(mc_count * ETH_ALEN, GFP_ATOMIC);
+       mta_list = kmalloc_array(ETH_ALEN, mc_count, GFP_ATOMIC);
        if (!mta_list)
                return;
 
index 07a2eb3781b12a307b71849e38d8cbcb6edf1a1e..8a31a02c9f47f7ec9c328cbbacb8088b07c90ab8 100644 (file)
@@ -390,8 +390,9 @@ static int pasemi_mac_setup_rx_resources(const struct net_device *dev)
        spin_lock_init(&ring->lock);
 
        ring->size = RX_RING_SIZE;
-       ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) *
-                                 RX_RING_SIZE, GFP_KERNEL);
+       ring->ring_info = kcalloc(RX_RING_SIZE,
+                                 sizeof(struct pasemi_mac_buffer),
+                                 GFP_KERNEL);
 
        if (!ring->ring_info)
                goto out_ring_info;
@@ -473,8 +474,9 @@ pasemi_mac_setup_tx_resources(const struct net_device *dev)
        spin_lock_init(&ring->lock);
 
        ring->size = TX_RING_SIZE;
-       ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) *
-                                 TX_RING_SIZE, GFP_KERNEL);
+       ring->ring_info = kcalloc(TX_RING_SIZE,
+                                 sizeof(struct pasemi_mac_buffer),
+                                 GFP_KERNEL);
        if (!ring->ring_info)
                goto out_ring_info;
 
index b9ec460dd996efac5835854c1329c217be356833..a14e484890299565ee8fdac8851ed9d7f3e90437 100644 (file)
@@ -6617,7 +6617,8 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn,
 
        /* Read no. of modules and allocate memory for their pointers */
        meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset);
-       meta->modules = kzalloc(meta->modules_num * sizeof(char *), GFP_KERNEL);
+       meta->modules = kcalloc(meta->modules_num, sizeof(char *),
+                               GFP_KERNEL);
        if (!meta->modules)
                return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
 
@@ -6645,7 +6646,7 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn,
 
        /* Read number of formats and allocate memory for all formats */
        meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset);
-       meta->formats = kzalloc(meta->formats_num *
+       meta->formats = kcalloc(meta->formats_num,
                                sizeof(struct mcp_trace_format),
                                GFP_KERNEL);
        if (!meta->formats)
index b285edc8d6a10ae48e522b1619443934a84176dc..329781cda77fbecc88328ea95f00e39d4be5db9b 100644 (file)
@@ -814,26 +814,26 @@ static int qed_alloc_qm_data(struct qed_hwfn *p_hwfn)
        if (rc)
                goto alloc_err;
 
-       qm_info->qm_pq_params = kzalloc(sizeof(*qm_info->qm_pq_params) *
-                                       qed_init_qm_get_num_pqs(p_hwfn),
+       qm_info->qm_pq_params = kcalloc(qed_init_qm_get_num_pqs(p_hwfn),
+                                       sizeof(*qm_info->qm_pq_params),
                                        GFP_KERNEL);
        if (!qm_info->qm_pq_params)
                goto alloc_err;
 
-       qm_info->qm_vport_params = kzalloc(sizeof(*qm_info->qm_vport_params) *
-                                          qed_init_qm_get_num_vports(p_hwfn),
+       qm_info->qm_vport_params = kcalloc(qed_init_qm_get_num_vports(p_hwfn),
+                                          sizeof(*qm_info->qm_vport_params),
                                           GFP_KERNEL);
        if (!qm_info->qm_vport_params)
                goto alloc_err;
 
-       qm_info->qm_port_params = kzalloc(sizeof(*qm_info->qm_port_params) *
-                                         p_hwfn->cdev->num_ports_in_engine,
+       qm_info->qm_port_params = kcalloc(p_hwfn->cdev->num_ports_in_engine,
+                                         sizeof(*qm_info->qm_port_params),
                                          GFP_KERNEL);
        if (!qm_info->qm_port_params)
                goto alloc_err;
 
-       qm_info->wfq_data = kzalloc(sizeof(*qm_info->wfq_data) *
-                                   qed_init_qm_get_num_vports(p_hwfn),
+       qm_info->wfq_data = kcalloc(qed_init_qm_get_num_vports(p_hwfn),
+                                   sizeof(*qm_info->wfq_data),
                                    GFP_KERNEL);
        if (!qm_info->wfq_data)
                goto alloc_err;
index 3bb76da6baa27f0a548b9d15c37754cbef5444d8..d9ab5add27a8bf06af92247b60158e6de2e316be 100644 (file)
@@ -149,12 +149,12 @@ int qed_init_alloc(struct qed_hwfn *p_hwfn)
        if (IS_VF(p_hwfn->cdev))
                return 0;
 
-       rt_data->b_valid = kzalloc(sizeof(bool) * RUNTIME_ARRAY_SIZE,
+       rt_data->b_valid = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(bool),
                                   GFP_KERNEL);
        if (!rt_data->b_valid)
                return -ENOMEM;
 
-       rt_data->init_val = kzalloc(sizeof(u32) * RUNTIME_ARRAY_SIZE,
+       rt_data->init_val = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(u32),
                                    GFP_KERNEL);
        if (!rt_data->init_val) {
                kfree(rt_data->b_valid);
index 1f6ac848109dbab62121ca32d38ae3a453e29352..99973e10b17977561be6536fee84cf2901622c3e 100644 (file)
@@ -98,7 +98,7 @@ int qed_l2_alloc(struct qed_hwfn *p_hwfn)
                p_l2_info->queues = max_t(u8, rx, tx);
        }
 
-       pp_qids = kzalloc(sizeof(unsigned long *) * p_l2_info->queues,
+       pp_qids = kcalloc(p_l2_info->queues, sizeof(unsigned long *),
                          GFP_KERNEL);
        if (!pp_qids)
                return -ENOMEM;
@@ -2435,7 +2435,7 @@ static int qed_update_vport(struct qed_dev *cdev,
        if (!cdev)
                return -ENODEV;
 
-       rss = vzalloc(sizeof(*rss) * cdev->num_hwfns);
+       rss = vzalloc(array_size(sizeof(*rss), cdev->num_hwfns));
        if (!rss)
                return -ENOMEM;
 
index 6f9927d1a50197f2484aab1e03450febef52bd6a..4e0b443c9519d67bc3b888ddf3b341c93291e328 100644 (file)
@@ -2578,9 +2578,9 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn)
                goto err0;
        }
 
-       nvm_info->image_att = kmalloc(nvm_info->num_images *
-                                     sizeof(struct bist_nvm_image_att),
-                                     GFP_KERNEL);
+       nvm_info->image_att = kmalloc_array(nvm_info->num_images,
+                                           sizeof(struct bist_nvm_image_att),
+                                           GFP_KERNEL);
        if (!nvm_info->image_att) {
                rc = -ENOMEM;
                goto err0;
index e9e088d9c81504f07fffe33d3891d17640c65904..b823bfe2ea4d6a6851699ef225265dbd333b0143 100644 (file)
@@ -342,8 +342,9 @@ int qede_alloc_arfs(struct qede_dev *edev)
        for (i = 0; i <= QEDE_RFS_FLW_MASK; i++)
                INIT_HLIST_HEAD(QEDE_ARFS_BUCKET_HEAD(edev, i));
 
-       edev->arfs->arfs_fltr_bmap = vzalloc(BITS_TO_LONGS(QEDE_RFS_MAX_FLTR) *
-                                            sizeof(long));
+       edev->arfs->arfs_fltr_bmap =
+               vzalloc(array_size(sizeof(long),
+                                  BITS_TO_LONGS(QEDE_RFS_MAX_FLTR)));
        if (!edev->arfs->arfs_fltr_bmap) {
                vfree(edev->arfs);
                edev->arfs = NULL;
index 97c146e7698a61c19e4a5065be9a9e29659b1082..569d54ededeca2e6472a3f8502e91c45be8e5232 100644 (file)
@@ -386,8 +386,9 @@ int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter)
        }
 
        /* setup interrupt mapping table for fw */
-       ahw->intr_tbl = vzalloc(num_msix *
-                               sizeof(struct qlcnic_intrpt_config));
+       ahw->intr_tbl =
+               vzalloc(array_size(num_msix,
+                                  sizeof(struct qlcnic_intrpt_config)));
        if (!ahw->intr_tbl)
                return -ENOMEM;
 
index 1b5f7d57b6f8fed6a8b232adfdee76b2cbaff13f..2d38d1ac2aae58fd210030c7b143011f76b921cc 100644 (file)
@@ -916,8 +916,9 @@ int qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *adapter, int op_type)
        if (qlcnic_check_multi_tx(adapter) &&
            !ahw->diag_test &&
            (adapter->flags & QLCNIC_MSIX_ENABLED)) {
-               ahw->intr_tbl = vzalloc(ahw->num_msix *
-                                       sizeof(struct qlcnic_intrpt_config));
+               ahw->intr_tbl =
+                       vzalloc(array_size(sizeof(struct qlcnic_intrpt_config),
+                                          ahw->num_msix));
                if (!ahw->intr_tbl)
                        return -ENOMEM;
 
@@ -1025,15 +1026,17 @@ int qlcnic_init_pci_info(struct qlcnic_adapter *adapter)
 
        act_pci_func = ahw->total_nic_func;
 
-       adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) *
-                                act_pci_func, GFP_KERNEL);
+       adapter->npars = kcalloc(act_pci_func,
+                                sizeof(struct qlcnic_npar_info),
+                                GFP_KERNEL);
        if (!adapter->npars) {
                ret = -ENOMEM;
                goto err_pci_info;
        }
 
-       adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) *
-                               QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL);
+       adapter->eswitch = kcalloc(QLCNIC_NIU_MAX_XG_PORTS,
+                                  sizeof(struct qlcnic_eswitch),
+                                  GFP_KERNEL);
        if (!adapter->eswitch) {
                ret = -ENOMEM;
                goto err_npars;
index c58180f408448e9a86a7ce40c6fb286063a6afb0..0c744b9c6e0adf96f91d6aba6c7cda34b208c7fe 100644 (file)
@@ -157,8 +157,8 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs)
        adapter->ahw->sriov = sriov;
        sriov->num_vfs = num_vfs;
        bc = &sriov->bc;
-       sriov->vf_info = kzalloc(sizeof(struct qlcnic_vf_info) *
-                                num_vfs, GFP_KERNEL);
+       sriov->vf_info = kcalloc(num_vfs, sizeof(struct qlcnic_vf_info),
+                                GFP_KERNEL);
        if (!sriov->vf_info) {
                err = -ENOMEM;
                goto qlcnic_free_sriov;
@@ -450,7 +450,7 @@ static int qlcnic_sriov_set_guest_vlan_mode(struct qlcnic_adapter *adapter,
                return 0;
 
        num_vlans = sriov->num_allowed_vlans;
-       sriov->allowed_vlans = kzalloc(sizeof(u16) * num_vlans, GFP_KERNEL);
+       sriov->allowed_vlans = kcalloc(num_vlans, sizeof(u16), GFP_KERNEL);
        if (!sriov->allowed_vlans)
                return -ENOMEM;
 
@@ -706,7 +706,7 @@ static inline int qlcnic_sriov_alloc_bc_trans(struct qlcnic_bc_trans **trans)
 static inline int qlcnic_sriov_alloc_bc_msg(struct qlcnic_bc_hdr **hdr,
                                            u32 size)
 {
-       *hdr = kzalloc(sizeof(struct qlcnic_bc_hdr) * size, GFP_ATOMIC);
+       *hdr = kcalloc(size, sizeof(struct qlcnic_bc_hdr), GFP_ATOMIC);
        if (!*hdr)
                return -ENOMEM;
 
index 70de062b72a15f45972079149f5c414d4d035283..353f1c129af1e247e1a8ddaa6d316edfc285682d 100644 (file)
@@ -2810,7 +2810,8 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev,
                goto pci_alloc_err;
 
        tx_ring->q =
-           kmalloc(tx_ring->wq_len * sizeof(struct tx_ring_desc), GFP_KERNEL);
+           kmalloc_array(tx_ring->wq_len, sizeof(struct tx_ring_desc),
+                         GFP_KERNEL);
        if (tx_ring->q == NULL)
                goto err;
 
index e78e5db394589674e981bc802a09bdf918c3183c..c694e3428dfc4706a0b4652271211b1145d8110e 100644 (file)
@@ -384,6 +384,7 @@ int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt)
                }
 
                sgmii_pdev = of_find_device_by_node(np);
+               of_node_put(np);
                if (!sgmii_pdev) {
                        dev_err(&pdev->dev, "invalid internal-phy property\n");
                        return -ENODEV;
index d90a7b1f4088623ccd664d136389482b242a3456..23f0785c0573ec72fea3db10dfdf353c41341ee8 100644 (file)
@@ -4984,7 +4984,8 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx)
                net_dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
        }
 
-       table->entry = vzalloc(HUNT_FILTER_TBL_ROWS * sizeof(*table->entry));
+       table->entry = vzalloc(array_size(HUNT_FILTER_TBL_ROWS,
+                                         sizeof(*table->entry)));
        if (!table->entry) {
                rc = -ENOMEM;
                goto fail;
index 494884f6af4afd1510a17111d6c311820f139b0c..411a2f419447c8a78e66a4b68d3ac8a152a3d284 100644 (file)
@@ -2755,7 +2755,8 @@ int ef4_farch_filter_table_probe(struct ef4_nic *efx)
                                             GFP_KERNEL);
                if (!table->used_bitmap)
                        goto fail;
-               table->spec = vzalloc(table->size * sizeof(*table->spec));
+               table->spec = vzalloc(array_size(sizeof(*table->spec),
+                                                table->size));
                if (!table->spec)
                        goto fail;
        }
index c72adf8b52eac62fd31cf16f3dbae15ee1404381..8edf20967c82c583bb59ace5f1f9c30dcfd1530d 100644 (file)
@@ -2826,7 +2826,8 @@ int efx_farch_filter_table_probe(struct efx_nic *efx)
                                             GFP_KERNEL);
                if (!table->used_bitmap)
                        goto fail;
-               table->spec = vzalloc(table->size * sizeof(*table->spec));
+               table->spec = vzalloc(array_size(sizeof(*table->spec),
+                                                table->size));
                if (!table->spec)
                        goto fail;
        }
index ce8071fc90c473162061643638f01c16378d7360..e080d3e7c582ff7df2a2fe0ecf6074ac4a306470 100644 (file)
@@ -973,7 +973,7 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
                goto err;
        }
 
-       dring->desc = kzalloc(DESC_NUM * sizeof(*dring->desc), GFP_KERNEL);
+       dring->desc = kcalloc(DESC_NUM, sizeof(*dring->desc), GFP_KERNEL);
        if (!dring->desc) {
                ret = -ENOMEM;
                goto err;
index 4ff231df73225dc449b21c7c1f312666b2a957fd..c5979569fd60f28fbf67b72f0c03cd613355d9cc 100644 (file)
@@ -334,9 +334,10 @@ static int meson8b_dwmac_probe(struct platform_device *pdev)
 
        dwmac->data = (const struct meson8b_dwmac_data *)
                of_device_get_match_data(&pdev->dev);
-       if (!dwmac->data)
-               return -EINVAL;
-
+       if (!dwmac->data) {
+               ret = -EINVAL;
+               goto err_remove_config_dt;
+       }
        res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
        dwmac->regs = devm_ioremap_resource(&pdev->dev, res);
        if (IS_ERR(dwmac->regs)) {
index 14770fc8865e8022d06fc0e05b7aa27feab2117d..1f50e83cafb2c14d2d783ac471a562801424265b 100644 (file)
@@ -252,13 +252,8 @@ int stmmac_hwif_init(struct stmmac_priv *priv)
                                return ret;
                }
 
-               /* Run quirks, if needed */
-               if (entry->quirks) {
-                       ret = entry->quirks(priv);
-                       if (ret)
-                               return ret;
-               }
-
+               /* Save quirks, if needed for posterior use */
+               priv->hwif_quirks = entry->quirks;
                return 0;
        }
 
index 025efbf6145cca6ce55b63a654cb5ec78d0d7fa9..76649adf8fb0639e66094cb29f83ed58f124bf2c 100644 (file)
@@ -129,6 +129,7 @@ struct stmmac_priv {
        struct net_device *dev;
        struct device *device;
        struct mac_device_info *hw;
+       int (*hwif_quirks)(struct stmmac_priv *priv);
        struct mutex lock;
 
        /* RX Queue */
index 11fb7c777d89b6b1e86b9aa1a83c8345a664fb23..e79b0d7b388a16d524917b0dfed1b4dd2f079c2f 100644 (file)
@@ -3182,17 +3182,22 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
 
 static void stmmac_rx_vlan(struct net_device *dev, struct sk_buff *skb)
 {
-       struct ethhdr *ehdr;
+       struct vlan_ethhdr *veth;
+       __be16 vlan_proto;
        u16 vlanid;
 
-       if ((dev->features & NETIF_F_HW_VLAN_CTAG_RX) ==
-           NETIF_F_HW_VLAN_CTAG_RX &&
-           !__vlan_get_tag(skb, &vlanid)) {
+       veth = (struct vlan_ethhdr *)skb->data;
+       vlan_proto = veth->h_vlan_proto;
+
+       if ((vlan_proto == htons(ETH_P_8021Q) &&
+            dev->features & NETIF_F_HW_VLAN_CTAG_RX) ||
+           (vlan_proto == htons(ETH_P_8021AD) &&
+            dev->features & NETIF_F_HW_VLAN_STAG_RX)) {
                /* pop the vlan tag */
-               ehdr = (struct ethhdr *)skb->data;
-               memmove(skb->data + VLAN_HLEN, ehdr, ETH_ALEN * 2);
+               vlanid = ntohs(veth->h_vlan_TCI);
+               memmove(skb->data + VLAN_HLEN, veth, ETH_ALEN * 2);
                skb_pull(skb, VLAN_HLEN);
-               __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlanid);
+               __vlan_hwaccel_put_tag(skb, vlan_proto, vlanid);
        }
 }
 
@@ -4130,6 +4135,13 @@ static int stmmac_hw_init(struct stmmac_priv *priv)
        if (priv->dma_cap.tsoen)
                dev_info(priv->device, "TSO supported\n");
 
+       /* Run HW quirks, if any */
+       if (priv->hwif_quirks) {
+               ret = priv->hwif_quirks(priv);
+               if (ret)
+                       return ret;
+       }
+
        return 0;
 }
 
@@ -4235,7 +4247,7 @@ int stmmac_dvr_probe(struct device *device,
        ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
 #ifdef STMMAC_VLAN_TAG_USED
        /* Both mac100 and gmac support receive VLAN tag detection */
-       ndev->features |= NETIF_F_HW_VLAN_CTAG_RX;
+       ndev->features |= NETIF_F_HW_VLAN_CTAG_RX | NETIF_F_HW_VLAN_STAG_RX;
 #endif
        priv->msg_enable = netif_msg_init(debug, default_msg_level);
 
index 881c94b73e2ff387a3f7ce5e5c3aebf3006ac102..2258cd8cc84413f22c19a9339a3b6193427c464e 100644 (file)
@@ -277,8 +277,8 @@ static int tc_init(struct stmmac_priv *priv)
 
        /* Reserve one last filter which lets all pass */
        priv->tc_entries_max = count;
-       priv->tc_entries = devm_kzalloc(priv->device,
-                       sizeof(*priv->tc_entries) * count, GFP_KERNEL);
+       priv->tc_entries = devm_kcalloc(priv->device,
+                       count, sizeof(*priv->tc_entries), GFP_KERNEL);
        if (!priv->tc_entries)
                return -ENOMEM;
 
index 534596ce00d3ee9f63e08c38c27ae5e52357e679..358edab9e72eeee18b9c17d74e66f2de92d5cc87 100644 (file)
@@ -2740,8 +2740,9 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
        }
        data->active_slave = prop;
 
-       data->slave_data = devm_kzalloc(&pdev->dev, data->slaves
-                                       * sizeof(struct cpsw_slave_data),
+       data->slave_data = devm_kcalloc(&pdev->dev,
+                                       data->slaves,
+                                       sizeof(struct cpsw_slave_data),
                                        GFP_KERNEL);
        if (!data->slave_data)
                return -ENOMEM;
@@ -3045,8 +3046,8 @@ static int cpsw_probe(struct platform_device *pdev)
 
        memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
 
-       cpsw->slaves = devm_kzalloc(&pdev->dev,
-                                   sizeof(struct cpsw_slave) * data->slaves,
+       cpsw->slaves = devm_kcalloc(&pdev->dev,
+                                   data->slaves, sizeof(struct cpsw_slave),
                                    GFP_KERNEL);
        if (!cpsw->slaves) {
                ret = -ENOMEM;
index 6e455a27a8de4021b9daf6549bb0222dbb17cfb4..72b98e27c9920b3c4342e0e8a5f3eef8476439f4 100644 (file)
@@ -3285,8 +3285,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
        gbe_dev->et_stats = xgbe10_et_stats;
        gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats);
 
-       gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
-                                        gbe_dev->num_et_stats * sizeof(u64),
+       gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev,
+                                        gbe_dev->num_et_stats, sizeof(u64),
                                         GFP_KERNEL);
        if (!gbe_dev->hw_stats) {
                dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
@@ -3294,8 +3294,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev,
        }
 
        gbe_dev->hw_stats_prev =
-               devm_kzalloc(gbe_dev->dev,
-                            gbe_dev->num_et_stats * sizeof(u32),
+               devm_kcalloc(gbe_dev->dev,
+                            gbe_dev->num_et_stats, sizeof(u32),
                             GFP_KERNEL);
        if (!gbe_dev->hw_stats_prev) {
                dev_err(gbe_dev->dev,
@@ -3405,8 +3405,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
        gbe_dev->et_stats = gbe13_et_stats;
        gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats);
 
-       gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
-                                        gbe_dev->num_et_stats * sizeof(u64),
+       gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev,
+                                        gbe_dev->num_et_stats, sizeof(u64),
                                         GFP_KERNEL);
        if (!gbe_dev->hw_stats) {
                dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
@@ -3414,8 +3414,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev,
        }
 
        gbe_dev->hw_stats_prev =
-               devm_kzalloc(gbe_dev->dev,
-                            gbe_dev->num_et_stats * sizeof(u32),
+               devm_kcalloc(gbe_dev->dev,
+                            gbe_dev->num_et_stats, sizeof(u32),
                             GFP_KERNEL);
        if (!gbe_dev->hw_stats_prev) {
                dev_err(gbe_dev->dev,
@@ -3477,8 +3477,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
                gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
                                        GBENU_ET_STATS_PORT_SIZE;
 
-       gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
-                                        gbe_dev->num_et_stats * sizeof(u64),
+       gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev,
+                                        gbe_dev->num_et_stats, sizeof(u64),
                                         GFP_KERNEL);
        if (!gbe_dev->hw_stats) {
                dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
@@ -3486,8 +3486,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev,
        }
 
        gbe_dev->hw_stats_prev =
-               devm_kzalloc(gbe_dev->dev,
-                            gbe_dev->num_et_stats * sizeof(u32),
+               devm_kcalloc(gbe_dev->dev,
+                            gbe_dev->num_et_stats, sizeof(u32),
                             GFP_KERNEL);
        if (!gbe_dev->hw_stats_prev) {
                dev_err(gbe_dev->dev,
index eed18f88bdff7f6b253aa02ffaa05a2a859f84a7..302079e22b06c7c9992d2f7e2b01b817cccf5906 100644 (file)
@@ -2320,8 +2320,9 @@ static struct net_device *gelic_wl_alloc(struct gelic_card *card)
        pr_debug("%s: wl=%p port=%p\n", __func__, wl, port);
 
        /* allocate scan list */
-       wl->networks = kzalloc(sizeof(struct gelic_wl_scan_info) *
-                              GELIC_WL_BSS_MAX_ENT, GFP_KERNEL);
+       wl->networks = kcalloc(GELIC_WL_BSS_MAX_ENT,
+                              sizeof(struct gelic_wl_scan_info),
+                              GFP_KERNEL);
 
        if (!wl->networks)
                goto fail_bss;
index 69e31ceccfae4d90a56f6e49312112ec372d1d48..2a0c06e0f730c35e5e7d40d9d9893bf36cf9c6fa 100644 (file)
  * @phy_node:          pointer to the PHY device node
  * @mii_bus:           pointer to the MII bus
  * @last_link:         last link status
- * @has_mdio:          indicates whether MDIO is included in the HW
  */
 struct net_local {
 
@@ -144,7 +143,6 @@ struct net_local {
        struct mii_bus *mii_bus;
 
        int last_link;
-       bool has_mdio;
 };
 
 
@@ -863,14 +861,14 @@ static int xemaclite_mdio_setup(struct net_local *lp, struct device *dev)
        bus->write = xemaclite_mdio_write;
        bus->parent = dev;
 
-       lp->mii_bus = bus;
-
        rc = of_mdiobus_register(bus, np);
        if (rc) {
                dev_err(dev, "Failed to register mdio bus.\n");
                goto err_register;
        }
 
+       lp->mii_bus = bus;
+
        return 0;
 
 err_register:
@@ -1145,9 +1143,7 @@ static int xemaclite_of_probe(struct platform_device *ofdev)
        xemaclite_update_address(lp, ndev->dev_addr);
 
        lp->phy_node = of_parse_phandle(ofdev->dev.of_node, "phy-handle", 0);
-       rc = xemaclite_mdio_setup(lp, &ofdev->dev);
-       if (rc)
-               dev_warn(&ofdev->dev, "error registering MDIO bus\n");
+       xemaclite_mdio_setup(lp, &ofdev->dev);
 
        dev_info(dev, "MAC address is now %pM\n", ndev->dev_addr);
 
@@ -1191,7 +1187,7 @@ static int xemaclite_of_remove(struct platform_device *of_dev)
        struct net_local *lp = netdev_priv(ndev);
 
        /* Un-register the mii_bus, if configured */
-       if (lp->has_mdio) {
+       if (lp->mii_bus) {
                mdiobus_unregister(lp->mii_bus);
                mdiobus_free(lp->mii_bus);
                lp->mii_bus = NULL;
index f38e32a7ec9c979ac4524c31e09da375a6e0606c..ec629a730005273924c40ace6977ad7fedecc315 100644 (file)
@@ -742,11 +742,13 @@ static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize)
 {
        int i;
 
-       gtp->addr_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL);
+       gtp->addr_hash = kmalloc_array(hsize, sizeof(struct hlist_head),
+                                      GFP_KERNEL);
        if (gtp->addr_hash == NULL)
                return -ENOMEM;
 
-       gtp->tid_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL);
+       gtp->tid_hash = kmalloc_array(hsize, sizeof(struct hlist_head),
+                                     GFP_KERNEL);
        if (gtp->tid_hash == NULL)
                goto err1;
 
index f411164880799a4ac57a3de8469cd6f4d848dce7..029206e4da3b3719084ccdc4cbc7486313237cff 100644 (file)
@@ -1583,7 +1583,7 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                        return -EPERM;
                }
 
-               image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
+               image = kmalloc_array(EEPROM_WORDS, sizeof(u32), GFP_KERNEL);
                if (!image)
                        return -ENOMEM;
 
index 23a2d145813ab9fb449a4dd3f7fc1a934bcd9137..0765d5f61714e6a1a8679802cb079ea45053a2f2 100644 (file)
@@ -2,6 +2,5 @@ config HYPERV_NET
        tristate "Microsoft Hyper-V virtual network driver"
        depends on HYPERV
        select UCS2_STRING
-       select FAILOVER
        help
          Select this option to enable the Hyper-V virtual network driver.
index 23304aca25f95d69ef7f6ede3a0c2df45cd805be..1a924b867b0742b0aa3e5a15f4da3e6885173e74 100644 (file)
@@ -901,6 +901,8 @@ struct net_device_context {
        struct hv_device *device_ctx;
        /* netvsc_device */
        struct netvsc_device __rcu *nvdev;
+       /* list of netvsc net_devices */
+       struct list_head list;
        /* reconfigure work */
        struct delayed_work dwork;
        /* last reconfig time */
@@ -931,8 +933,6 @@ struct net_device_context {
        u32 vf_alloc;
        /* Serial number of the VF to team with */
        u32 vf_serial;
-
-       struct failover *failover;
 };
 
 /* Per channel data */
@@ -1277,17 +1277,17 @@ struct ndis_lsov2_offload {
 
 struct ndis_ipsecv2_offload {
        u32     encap;
-       u16     ip6;
-       u16     ip4opt;
-       u16     ip6ext;
-       u16     ah;
-       u16     esp;
-       u16     ah_esp;
-       u16     xport;
-       u16     tun;
-       u16     xport_tun;
-       u16     lso;
-       u16     extseq;
+       u     ip6;
+       u     ip4opt;
+       u     ip6ext;
+       u     ah;
+       u     esp;
+       u     ah_esp;
+       u     xport;
+       u     tun;
+       u     xport_tun;
+       u     lso;
+       u     extseq;
        u32     udp_esp;
        u32     auth;
        u32     crypto;
@@ -1295,8 +1295,8 @@ struct ndis_ipsecv2_offload {
 };
 
 struct ndis_rsc_offload {
-       u16     ip4;
-       u16     ip6;
+       u     ip4;
+       u     ip6;
 };
 
 struct ndis_encap_offload {
index 7b18a8c267c2b88d2c5e84bfa87da9691883c154..fe2256bf1d137fea6b76c5e3a564b191e2b5da7c 100644 (file)
@@ -42,7 +42,6 @@
 #include <net/pkt_sched.h>
 #include <net/checksum.h>
 #include <net/ip6_checksum.h>
-#include <net/failover.h>
 
 #include "hyperv_net.h"
 
@@ -68,6 +67,8 @@ static int debug = -1;
 module_param(debug, int, 0444);
 MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
 
+static LIST_HEAD(netvsc_dev_list);
+
 static void netvsc_change_rx_flags(struct net_device *net, int change)
 {
        struct net_device_context *ndev_ctx = netdev_priv(net);
@@ -1780,6 +1781,36 @@ static void netvsc_link_change(struct work_struct *w)
        rtnl_unlock();
 }
 
+static struct net_device *get_netvsc_bymac(const u8 *mac)
+{
+       struct net_device_context *ndev_ctx;
+
+       list_for_each_entry(ndev_ctx, &netvsc_dev_list, list) {
+               struct net_device *dev = hv_get_drvdata(ndev_ctx->device_ctx);
+
+               if (ether_addr_equal(mac, dev->perm_addr))
+                       return dev;
+       }
+
+       return NULL;
+}
+
+static struct net_device *get_netvsc_byref(struct net_device *vf_netdev)
+{
+       struct net_device_context *net_device_ctx;
+       struct net_device *dev;
+
+       dev = netdev_master_upper_dev_get(vf_netdev);
+       if (!dev || dev->netdev_ops != &device_ops)
+               return NULL;    /* not a netvsc device */
+
+       net_device_ctx = netdev_priv(dev);
+       if (!rtnl_dereference(net_device_ctx->nvdev))
+               return NULL;    /* device is removed */
+
+       return dev;
+}
+
 /* Called when VF is injecting data into network stack.
  * Change the associated network device from VF to netvsc.
  * note: already called with rcu_read_lock
@@ -1802,6 +1833,46 @@ static rx_handler_result_t netvsc_vf_handle_frame(struct sk_buff **pskb)
        return RX_HANDLER_ANOTHER;
 }
 
+static int netvsc_vf_join(struct net_device *vf_netdev,
+                         struct net_device *ndev)
+{
+       struct net_device_context *ndev_ctx = netdev_priv(ndev);
+       int ret;
+
+       ret = netdev_rx_handler_register(vf_netdev,
+                                        netvsc_vf_handle_frame, ndev);
+       if (ret != 0) {
+               netdev_err(vf_netdev,
+                          "can not register netvsc VF receive handler (err = %d)\n",
+                          ret);
+               goto rx_handler_failed;
+       }
+
+       ret = netdev_master_upper_dev_link(vf_netdev, ndev,
+                                          NULL, NULL, NULL);
+       if (ret != 0) {
+               netdev_err(vf_netdev,
+                          "can not set master device %s (err = %d)\n",
+                          ndev->name, ret);
+               goto upper_link_failed;
+       }
+
+       /* set slave flag before open to prevent IPv6 addrconf */
+       vf_netdev->flags |= IFF_SLAVE;
+
+       schedule_delayed_work(&ndev_ctx->vf_takeover, VF_TAKEOVER_INT);
+
+       call_netdevice_notifiers(NETDEV_JOIN, vf_netdev);
+
+       netdev_info(vf_netdev, "joined to %s\n", ndev->name);
+       return 0;
+
+upper_link_failed:
+       netdev_rx_handler_unregister(vf_netdev);
+rx_handler_failed:
+       return ret;
+}
+
 static void __netvsc_vf_setup(struct net_device *ndev,
                              struct net_device *vf_netdev)
 {
@@ -1852,95 +1923,104 @@ static void netvsc_vf_setup(struct work_struct *w)
        rtnl_unlock();
 }
 
-static int netvsc_pre_register_vf(struct net_device *vf_netdev,
-                                 struct net_device *ndev)
+static int netvsc_register_vf(struct net_device *vf_netdev)
 {
+       struct net_device *ndev;
        struct net_device_context *net_device_ctx;
        struct netvsc_device *netvsc_dev;
+       int ret;
+
+       if (vf_netdev->addr_len != ETH_ALEN)
+               return NOTIFY_DONE;
+
+       /*
+        * We will use the MAC address to locate the synthetic interface to
+        * associate with the VF interface. If we don't find a matching
+        * synthetic interface, move on.
+        */
+       ndev = get_netvsc_bymac(vf_netdev->perm_addr);
+       if (!ndev)
+               return NOTIFY_DONE;
 
        net_device_ctx = netdev_priv(ndev);
        netvsc_dev = rtnl_dereference(net_device_ctx->nvdev);
        if (!netvsc_dev || rtnl_dereference(net_device_ctx->vf_netdev))
-               return -ENODEV;
-
-       return 0;
-}
+               return NOTIFY_DONE;
 
-static int netvsc_register_vf(struct net_device *vf_netdev,
-                             struct net_device *ndev)
-{
-       struct net_device_context *ndev_ctx = netdev_priv(ndev);
-
-       /* set slave flag before open to prevent IPv6 addrconf */
-       vf_netdev->flags |= IFF_SLAVE;
-
-       schedule_delayed_work(&ndev_ctx->vf_takeover, VF_TAKEOVER_INT);
+       /* if syntihetic interface is a different namespace,
+        * then move the VF to that namespace; join will be
+        * done again in that context.
+        */
+       if (!net_eq(dev_net(ndev), dev_net(vf_netdev))) {
+               ret = dev_change_net_namespace(vf_netdev,
+                                              dev_net(ndev), "eth%d");
+               if (ret)
+                       netdev_err(vf_netdev,
+                                  "could not move to same namespace as %s: %d\n",
+                                  ndev->name, ret);
+               else
+                       netdev_info(vf_netdev,
+                                   "VF moved to namespace with: %s\n",
+                                   ndev->name);
+               return NOTIFY_DONE;
+       }
 
-       call_netdevice_notifiers(NETDEV_JOIN, vf_netdev);
+       netdev_info(ndev, "VF registering: %s\n", vf_netdev->name);
 
-       netdev_info(vf_netdev, "joined to %s\n", ndev->name);
+       if (netvsc_vf_join(vf_netdev, ndev) != 0)
+               return NOTIFY_DONE;
 
        dev_hold(vf_netdev);
-       rcu_assign_pointer(ndev_ctx->vf_netdev, vf_netdev);
-
-       return 0;
+       rcu_assign_pointer(net_device_ctx->vf_netdev, vf_netdev);
+       return NOTIFY_OK;
 }
 
 /* VF up/down change detected, schedule to change data path */
-static int netvsc_vf_changed(struct net_device *vf_netdev,
-                            struct net_device *ndev)
+static int netvsc_vf_changed(struct net_device *vf_netdev)
 {
        struct net_device_context *net_device_ctx;
        struct netvsc_device *netvsc_dev;
+       struct net_device *ndev;
        bool vf_is_up = netif_running(vf_netdev);
 
+       ndev = get_netvsc_byref(vf_netdev);
+       if (!ndev)
+               return NOTIFY_DONE;
+
        net_device_ctx = netdev_priv(ndev);
        netvsc_dev = rtnl_dereference(net_device_ctx->nvdev);
        if (!netvsc_dev)
-               return -ENODEV;
+               return NOTIFY_DONE;
 
        netvsc_switch_datapath(ndev, vf_is_up);
        netdev_info(ndev, "Data path switched %s VF: %s\n",
                    vf_is_up ? "to" : "from", vf_netdev->name);
 
-       return 0;
+       return NOTIFY_OK;
 }
 
-static int netvsc_pre_unregister_vf(struct net_device *vf_netdev,
-                                   struct net_device *ndev)
+static int netvsc_unregister_vf(struct net_device *vf_netdev)
 {
+       struct net_device *ndev;
        struct net_device_context *net_device_ctx;
 
-       net_device_ctx = netdev_priv(ndev);
-       cancel_delayed_work_sync(&net_device_ctx->vf_takeover);
-
-       return 0;
-}
-
-static int netvsc_unregister_vf(struct net_device *vf_netdev,
-                               struct net_device *ndev)
-{
-       struct net_device_context *net_device_ctx;
+       ndev = get_netvsc_byref(vf_netdev);
+       if (!ndev)
+               return NOTIFY_DONE;
 
        net_device_ctx = netdev_priv(ndev);
+       cancel_delayed_work_sync(&net_device_ctx->vf_takeover);
 
        netdev_info(ndev, "VF unregistering: %s\n", vf_netdev->name);
 
+       netdev_rx_handler_unregister(vf_netdev);
+       netdev_upper_dev_unlink(vf_netdev, ndev);
        RCU_INIT_POINTER(net_device_ctx->vf_netdev, NULL);
        dev_put(vf_netdev);
 
-       return 0;
+       return NOTIFY_OK;
 }
 
-static struct failover_ops netvsc_failover_ops = {
-       .slave_pre_register     = netvsc_pre_register_vf,
-       .slave_register         = netvsc_register_vf,
-       .slave_pre_unregister   = netvsc_pre_unregister_vf,
-       .slave_unregister       = netvsc_unregister_vf,
-       .slave_link_change      = netvsc_vf_changed,
-       .slave_handle_frame     = netvsc_vf_handle_frame,
-};
-
 static int netvsc_probe(struct hv_device *dev,
                        const struct hv_vmbus_device_id *dev_id)
 {
@@ -2024,23 +2104,19 @@ static int netvsc_probe(struct hv_device *dev,
        else
                net->max_mtu = ETH_DATA_LEN;
 
-       ret = register_netdev(net);
+       rtnl_lock();
+       ret = register_netdevice(net);
        if (ret != 0) {
                pr_err("Unable to register netdev.\n");
                goto register_failed;
        }
 
-       net_device_ctx->failover = failover_register(net, &netvsc_failover_ops);
-       if (IS_ERR(net_device_ctx->failover)) {
-               ret = PTR_ERR(net_device_ctx->failover);
-               goto err_failover;
-       }
-
-       return ret;
+       list_add(&net_device_ctx->list, &netvsc_dev_list);
+       rtnl_unlock();
+       return 0;
 
-err_failover:
-       unregister_netdev(net);
 register_failed:
+       rtnl_unlock();
        rndis_filter_device_remove(dev, nvdev);
 rndis_failed:
        free_percpu(net_device_ctx->vf_stats);
@@ -2080,14 +2156,13 @@ static int netvsc_remove(struct hv_device *dev)
        rtnl_lock();
        vf_netdev = rtnl_dereference(ndev_ctx->vf_netdev);
        if (vf_netdev)
-               failover_slave_unregister(vf_netdev);
+               netvsc_unregister_vf(vf_netdev);
 
        if (nvdev)
                rndis_filter_device_remove(dev, nvdev);
 
        unregister_netdevice(net);
-
-       failover_unregister(ndev_ctx->failover);
+       list_del(&ndev_ctx->list);
 
        rtnl_unlock();
        rcu_read_unlock();
@@ -2115,8 +2190,54 @@ static struct  hv_driver netvsc_drv = {
        .remove = netvsc_remove,
 };
 
+/*
+ * On Hyper-V, every VF interface is matched with a corresponding
+ * synthetic interface. The synthetic interface is presented first
+ * to the guest. When the corresponding VF instance is registered,
+ * we will take care of switching the data path.
+ */
+static int netvsc_netdev_event(struct notifier_block *this,
+                              unsigned long event, void *ptr)
+{
+       struct net_device *event_dev = netdev_notifier_info_to_dev(ptr);
+
+       /* Skip our own events */
+       if (event_dev->netdev_ops == &device_ops)
+               return NOTIFY_DONE;
+
+       /* Avoid non-Ethernet type devices */
+       if (event_dev->type != ARPHRD_ETHER)
+               return NOTIFY_DONE;
+
+       /* Avoid Vlan dev with same MAC registering as VF */
+       if (is_vlan_dev(event_dev))
+               return NOTIFY_DONE;
+
+       /* Avoid Bonding master dev with same MAC registering as VF */
+       if ((event_dev->priv_flags & IFF_BONDING) &&
+           (event_dev->flags & IFF_MASTER))
+               return NOTIFY_DONE;
+
+       switch (event) {
+       case NETDEV_REGISTER:
+               return netvsc_register_vf(event_dev);
+       case NETDEV_UNREGISTER:
+               return netvsc_unregister_vf(event_dev);
+       case NETDEV_UP:
+       case NETDEV_DOWN:
+               return netvsc_vf_changed(event_dev);
+       default:
+               return NOTIFY_DONE;
+       }
+}
+
+static struct notifier_block netvsc_netdev_notifier = {
+       .notifier_call = netvsc_netdev_event,
+};
+
 static void __exit netvsc_drv_exit(void)
 {
+       unregister_netdevice_notifier(&netvsc_netdev_notifier);
        vmbus_driver_unregister(&netvsc_drv);
 }
 
@@ -2135,6 +2256,7 @@ static int __init netvsc_drv_init(void)
        if (ret)
                return ret;
 
+       register_netdevice_notifier(&netvsc_netdev_notifier);
        return 0;
 }
 
index a6c87793d899f325b11768a0f7334ede655a7807..79e9b103188b4d7dc0f2a256bdf8ba885035cca9 100644 (file)
@@ -1097,8 +1097,9 @@ static struct dp83640_clock *dp83640_clock_get_bus(struct mii_bus *bus)
        if (!clock)
                goto out;
 
-       clock->caps.pin_config = kzalloc(sizeof(struct ptp_pin_desc) *
-                                        DP83640_N_PINS, GFP_KERNEL);
+       clock->caps.pin_config = kcalloc(DP83640_N_PINS,
+                                        sizeof(struct ptp_pin_desc),
+                                        GFP_KERNEL);
        if (!clock->caps.pin_config) {
                kfree(clock);
                clock = NULL;
index 4e4c8daf44c308285201ecc051bc4e535e03036e..33265747bf3994c668cfcb2a8f7f3d9f768d370a 100644 (file)
 #include <linux/platform_device.h>
 #include <linux/mdio-bitbang.h>
 #include <linux/mdio-gpio.h>
-#include <linux/gpio.h>
 #include <linux/gpio/consumer.h>
-
-#include <linux/of_gpio.h>
 #include <linux/of_mdio.h>
 
 struct mdio_gpio_info {
index 39ecad25b20128bbcebf69d5baa7b37223ba3432..491efc1bf5c4894a3c3a8b8d67d236f68205efa4 100644 (file)
@@ -128,9 +128,9 @@ int phy_led_triggers_register(struct phy_device *phy)
        if (err)
                goto out_free_link;
 
-       phy->phy_led_triggers = devm_kzalloc(&phy->mdio.dev,
-                                           sizeof(struct phy_led_trigger) *
-                                                  phy->phy_num_led_triggers,
+       phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev,
+                                           phy->phy_num_led_triggers,
+                                           sizeof(struct phy_led_trigger),
                                            GFP_KERNEL);
        if (!phy->phy_led_triggers) {
                err = -ENOMEM;
index a9b759add187ad3033849c402b4854f2dfb2b074..61fedb23d3cfa72ccba6fbdcdff0f8de40786ce7 100644 (file)
@@ -406,7 +406,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
  * Allocate space for the dictionary. This may be more than one page in
  * length.
  */
-    db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
+    db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict)));
     if (!db->dict)
       {
        bsd_free (db);
@@ -425,7 +425,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
  */
     else
       {
-        db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
+        db->lens = vmalloc(array_size(sizeof(db->lens[0]), (maxmaxcode + 1)));
        if (!db->lens)
          {
            bsd_free (db);
index 157b67c1bf8eca013489495f62dca56771b5683a..67ffe74747a15720613295ab544aa62c071989f2 100644 (file)
@@ -648,7 +648,7 @@ static int __init pptp_init_module(void)
        int err = 0;
        pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n");
 
-       callid_sock = vzalloc((MAX_CALLID + 1) * sizeof(void *));
+       callid_sock = vzalloc(array_size(sizeof(void *), (MAX_CALLID + 1)));
        if (!callid_sock)
                return -ENOMEM;
 
index 8940417c30e547556d1f02c459ffad7b348ae6bf..b008266e91eab6cfc8fb8e009f1940ef97211e55 100644 (file)
@@ -1307,7 +1307,7 @@ static int __init slip_init(void)
        printk(KERN_INFO "SLIP linefill/keepalive option.\n");
 #endif
 
-       slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev,
+       slip_devs = kcalloc(slip_maxdev, sizeof(struct net_device *),
                                                                GFP_KERNEL);
        if (!slip_devs)
                return -ENOMEM;
index 8863fa02350084ea5deea072900cdcf6d8e69b54..b070959737ffe744f08683926a486c66ee08bb4a 100644 (file)
@@ -280,7 +280,7 @@ static int __team_options_register(struct team *team,
        struct team_option **dst_opts;
        int err;
 
-       dst_opts = kzalloc(sizeof(struct team_option *) * option_count,
+       dst_opts = kcalloc(option_count, sizeof(struct team_option *),
                           GFP_KERNEL);
        if (!dst_opts)
                return -ENOMEM;
@@ -791,7 +791,8 @@ static int team_queue_override_init(struct team *team)
 
        if (!queue_cnt)
                return 0;
-       listarr = kmalloc(sizeof(struct list_head) * queue_cnt, GFP_KERNEL);
+       listarr = kmalloc_array(queue_cnt, sizeof(struct list_head),
+                               GFP_KERNEL);
        if (!listarr)
                return -ENOMEM;
        team->qom_lists = listarr;
index f4d7362eb325618254aebf2130757da0fb888472..e95dd12edec473198125c18c1cec6bc7d32ec368 100644 (file)
@@ -640,8 +640,8 @@ int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
        first_word = eeprom->offset >> 1;
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
 
-       eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
-                             GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
+                                   GFP_KERNEL);
        if (!eeprom_buff)
                return -ENOMEM;
 
@@ -680,8 +680,8 @@ int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
        first_word = eeprom->offset >> 1;
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
 
-       eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
-                             GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
+                                   GFP_KERNEL);
        if (!eeprom_buff)
                return -ENOMEM;
 
index a6ef75907ae91ef0cf13d8b04cadaed99b31b969..9e8ad372f4190eed1d4e92891193d325c44fb47f 100644 (file)
@@ -599,8 +599,8 @@ ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom,
 
        first_word = eeprom->offset >> 1;
        last_word = (eeprom->offset + eeprom->len - 1) >> 1;
-       eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
-                             GFP_KERNEL);
+       eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
+                                   GFP_KERNEL);
        if (!eeprom_buff)
                return -ENOMEM;
 
index 309b88acd3d0b6ca1528dde7b27a23926f9be952..06b4d290784dad95f893b63da62d26e020fc060a 100644 (file)
@@ -1661,7 +1661,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message)
        }
 
        if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) {
-               u32 *filter_mask = kzalloc(sizeof(u32) * 32, GFP_KERNEL);
+               u32 *filter_mask = kcalloc(32, sizeof(u32), GFP_KERNEL);
                u32 command[2];
                u32 offset[2];
                u32 crc[4];
index d9eea8cfe6cb9a3bf8d0d4ce9198af9bccf9c757..770aa624147f170abd330d7820bc995ef9a712e6 100644 (file)
@@ -1323,8 +1323,8 @@ static int build_dma_sg(const struct sk_buff *skb, struct urb *urb)
                return 0;
 
        /* reserve one for zero packet */
-       urb->sg = kmalloc((num_sgs + 1) * sizeof(struct scatterlist),
-                         GFP_ATOMIC);
+       urb->sg = kmalloc_array(num_sgs + 1, sizeof(struct scatterlist),
+                               GFP_ATOMIC);
        if (!urb->sg)
                return -ENOMEM;
 
index 1619ee3070b6213cb9b9cc65e8fb146a2894ebdf..b6c9a2af37328d1037c3b0ba761256092556167e 100644 (file)
@@ -2552,17 +2552,17 @@ static int virtnet_find_vqs(struct virtnet_info *vi)
                    virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ);
 
        /* Allocate space for find_vqs parameters */
-       vqs = kzalloc(total_vqs * sizeof(*vqs), GFP_KERNEL);
+       vqs = kcalloc(total_vqs, sizeof(*vqs), GFP_KERNEL);
        if (!vqs)
                goto err_vq;
-       callbacks = kmalloc(total_vqs * sizeof(*callbacks), GFP_KERNEL);
+       callbacks = kmalloc_array(total_vqs, sizeof(*callbacks), GFP_KERNEL);
        if (!callbacks)
                goto err_callback;
-       names = kmalloc(total_vqs * sizeof(*names), GFP_KERNEL);
+       names = kmalloc_array(total_vqs, sizeof(*names), GFP_KERNEL);
        if (!names)
                goto err_names;
        if (!vi->big_packets || vi->mergeable_rx_bufs) {
-               ctx = kzalloc(total_vqs * sizeof(*ctx), GFP_KERNEL);
+               ctx = kcalloc(total_vqs, sizeof(*ctx), GFP_KERNEL);
                if (!ctx)
                        goto err_ctx;
        } else {
@@ -2626,10 +2626,10 @@ static int virtnet_alloc_queues(struct virtnet_info *vi)
        vi->ctrl = kzalloc(sizeof(*vi->ctrl), GFP_KERNEL);
        if (!vi->ctrl)
                goto err_ctrl;
-       vi->sq = kzalloc(sizeof(*vi->sq) * vi->max_queue_pairs, GFP_KERNEL);
+       vi->sq = kcalloc(vi->max_queue_pairs, sizeof(*vi->sq), GFP_KERNEL);
        if (!vi->sq)
                goto err_sq;
-       vi->rq = kzalloc(sizeof(*vi->rq) * vi->max_queue_pairs, GFP_KERNEL);
+       vi->rq = kcalloc(vi->max_queue_pairs, sizeof(*vi->rq), GFP_KERNEL);
        if (!vi->rq)
                goto err_rq;
 
index 4205dfd19da3b768cf13e0bd2dabfbf70142bcd9..9b09c9d0d0fb860d6788d751e967af538fc7e3f0 100644 (file)
@@ -198,12 +198,14 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
                goto free_tx_bd;
        }
 
-       priv->rx_skbuff = kzalloc(priv->rx_ring_size * sizeof(*priv->rx_skbuff),
+       priv->rx_skbuff = kcalloc(priv->rx_ring_size,
+                                 sizeof(*priv->rx_skbuff),
                                  GFP_KERNEL);
        if (!priv->rx_skbuff)
                goto free_ucc_pram;
 
-       priv->tx_skbuff = kzalloc(priv->tx_ring_size * sizeof(*priv->tx_skbuff),
+       priv->tx_skbuff = kcalloc(priv->tx_ring_size,
+                                 sizeof(*priv->tx_skbuff),
                                  GFP_KERNEL);
        if (!priv->tx_skbuff)
                goto free_rx_skbuff;
index bd23f6940488566b5962720572952543a0fde9ad..c72d8af122a28e19048c40f7072b4a9064d43e0b 100644 (file)
@@ -582,7 +582,7 @@ int ath10k_htt_rx_alloc(struct ath10k_htt *htt)
        }
 
        htt->rx_ring.netbufs_ring =
-               kzalloc(htt->rx_ring.size * sizeof(struct sk_buff *),
+               kcalloc(htt->rx_ring.size, sizeof(struct sk_buff *),
                        GFP_KERNEL);
        if (!htt->rx_ring.netbufs_ring)
                goto err_netbuf;
index 2e34a1fc5ba684c5006da61a97657f11791f18d9..8c49a26fc57120bfa22acc0e435a2bf1b07004e8 100644 (file)
@@ -155,7 +155,7 @@ ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr,
        const void **tb;
        int ret;
 
-       tb = kzalloc(sizeof(*tb) * WMI_TLV_TAG_MAX, gfp);
+       tb = kcalloc(WMI_TLV_TAG_MAX, sizeof(*tb), gfp);
        if (!tb)
                return ERR_PTR(-ENOMEM);
 
index 3513bbec463982fee6ac403d3c5fac379999fba3..e01faf641288fbac6e7412c18025fac5537c52c9 100644 (file)
@@ -931,7 +931,7 @@ static int open_file_eeprom(struct inode *inode, struct file *file)
 
        /* Create buffer and read in eeprom */
 
-       buf = vmalloc(eesize * 2);
+       buf = vmalloc(array_size(eesize, 2));
        if (!buf) {
                ret = -ENOMEM;
                goto err;
index 641b13a279e18a0a681f87ee1965184cc97a1070..b1b8bc3268309ecff781d981a7563a5c024aa0ac 100644 (file)
@@ -890,7 +890,8 @@ ath5k_hw_rfregs_init(struct ath5k_hw *ah,
         * ah->ah_rf_banks based on ah->ah_rf_banks_size
         * we set above */
        if (ah->ah_rf_banks == NULL) {
-               ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size,
+               ah->ah_rf_banks = kmalloc_array(ah->ah_rf_banks_size,
+                                                               sizeof(u32),
                                                                GFP_KERNEL);
                if (ah->ah_rf_banks == NULL) {
                        ATH5K_ERR(ah, "out of memory\n");
index 2ba8cf3f38afd4fa98c9038d43b8e4b838691114..0687697d5e2db5ed2e9c2567ae8189e85f9f711f 100644 (file)
@@ -1041,7 +1041,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy,
 
                n_channels = request->n_channels;
 
-               channels = kzalloc(n_channels * sizeof(u16), GFP_KERNEL);
+               channels = kcalloc(n_channels, sizeof(u16), GFP_KERNEL);
                if (channels == NULL) {
                        ath6kl_warn("failed to set scan channels, scan all channels");
                        n_channels = 0;
index 6343cc91953e8090e753a7e26e74cf5339ee6b1c..34e1009402846c854b22d9d32c4f70e21465b518 100644 (file)
@@ -925,7 +925,7 @@ int ar9003_paprd_create_curve(struct ath_hw *ah,
 
        memset(caldata->pa_table[chain], 0, sizeof(caldata->pa_table[chain]));
 
-       buf = kmalloc(2 * 48 * sizeof(u32), GFP_KERNEL);
+       buf = kmalloc_array(2 * 48, sizeof(u32), GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
index 6b37036b2d361fcef5e5b3f724a76cd79a4ac759..e60bea4604e4104dbcc837ddf23ecd890a299e2e 100644 (file)
@@ -127,13 +127,13 @@ void ath9k_hw_read_array(struct ath_hw *ah, u32 array[][2], int size)
        u32 *tmp_reg_list, *tmp_data;
        int i;
 
-       tmp_reg_list = kmalloc(size * sizeof(u32), GFP_KERNEL);
+       tmp_reg_list = kmalloc_array(size, sizeof(u32), GFP_KERNEL);
        if (!tmp_reg_list) {
                dev_err(ah->dev, "%s: tmp_reg_list: alloc filed\n", __func__);
                return;
        }
 
-       tmp_data = kmalloc(size * sizeof(u32), GFP_KERNEL);
+       tmp_data = kmalloc_array(size, sizeof(u32), GFP_KERNEL);
        if (!tmp_data) {
                dev_err(ah->dev, "%s tmp_data: alloc filed\n", __func__);
                goto error_tmp_data;
index 29e93c953d939b310a393f7cee3e380dd426904d..7f1bdea742b8ae88ab84508f502d2f49295f2187 100644 (file)
@@ -1958,7 +1958,7 @@ static int carl9170_parse_eeprom(struct ar9170 *ar)
        if (!bands)
                return -EINVAL;
 
-       ar->survey = kzalloc(sizeof(struct survey_info) * chans, GFP_KERNEL);
+       ar->survey = kcalloc(chans, sizeof(struct survey_info), GFP_KERNEL);
        if (!ar->survey)
                return -ENOMEM;
        ar->num_channels = chans;
@@ -1988,8 +1988,9 @@ int carl9170_register(struct ar9170 *ar)
        if (WARN_ON(ar->mem_bitmap))
                return -EINVAL;
 
-       ar->mem_bitmap = kzalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG) *
-                                sizeof(unsigned long), GFP_KERNEL);
+       ar->mem_bitmap = kcalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG),
+                                sizeof(unsigned long),
+                                GFP_KERNEL);
 
        if (!ar->mem_bitmap)
                return -ENOMEM;
index f2a2f41e3c96b2807a8f2d81d0ce157f68c7200a..44ab080d651823d0bd841c376f9103b1b67e12c7 100644 (file)
@@ -1518,7 +1518,7 @@ static int b43_nphy_load_samples(struct b43_wldev *dev,
        u16 i;
        u32 *data;
 
-       data = kzalloc(len * sizeof(u32), GFP_KERNEL);
+       data = kcalloc(len, sizeof(u32), GFP_KERNEL);
        if (!data) {
                b43err(dev->wl, "allocation for samples loading failed\n");
                return -ENOMEM;
index f1e3dad576292ef5b8e2f03a01a8c185c927a101..55f411925960e9cc954de38ae2a834a4ab140c60 100644 (file)
@@ -3300,8 +3300,8 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev)
 
        if ((phy->type == B43legacy_PHYTYPE_B) ||
            (phy->type == B43legacy_PHYTYPE_G)) {
-               phy->_lo_pairs = kzalloc(sizeof(struct b43legacy_lopair)
-                                        * B43legacy_LO_COUNT,
+               phy->_lo_pairs = kcalloc(B43legacy_LO_COUNT,
+                                        sizeof(struct b43legacy_lopair),
                                         GFP_KERNEL);
                if (!phy->_lo_pairs)
                        return -ENOMEM;
index 49d37ad969586e2471c61fefd6091e635d825192..c40ba8855cd53ee6ad058af2d71bcb6bdae3f114 100644 (file)
@@ -1486,8 +1486,9 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr)
                (struct brcmf_commonring **)if_msgbuf->commonrings;
        msgbuf->flowrings = (struct brcmf_commonring **)if_msgbuf->flowrings;
        msgbuf->max_flowrings = if_msgbuf->max_flowrings;
-       msgbuf->flowring_dma_handle = kzalloc(msgbuf->max_flowrings *
-               sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL);
+       msgbuf->flowring_dma_handle =
+               kcalloc(msgbuf->max_flowrings,
+                       sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL);
        if (!msgbuf->flowring_dma_handle)
                goto fail;
 
index 4b2149b483626074816caaeeaf76be79a0741278..3e9c4f2f5dd12673e8c96e6dcacbea50cf7bc45e 100644 (file)
@@ -1058,7 +1058,7 @@ static s32 brcmf_p2p_act_frm_search(struct brcmf_p2p_info *p2p, u16 channel)
                channel_cnt = AF_PEER_SEARCH_CNT;
        else
                channel_cnt = SOCIAL_CHAN_CNT;
-       default_chan_list = kzalloc(channel_cnt * sizeof(*default_chan_list),
+       default_chan_list = kcalloc(channel_cnt, sizeof(*default_chan_list),
                                    GFP_KERNEL);
        if (default_chan_list == NULL) {
                brcmf_err("channel list allocation failed\n");
index 0a14942b821671ea9de11f30a4cba34a4fa50537..7d4e8f589fdc4e38328f710afb9c12a09e98dfc6 100644 (file)
@@ -507,7 +507,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid)
        wlc->hw->wlc = wlc;
 
        wlc->hw->bandstate[0] =
-               kzalloc(sizeof(struct brcms_hw_band) * MAXBANDS, GFP_ATOMIC);
+               kcalloc(MAXBANDS, sizeof(struct brcms_hw_band), GFP_ATOMIC);
        if (wlc->hw->bandstate[0] == NULL) {
                *err = 1006;
                goto fail;
@@ -521,7 +521,8 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid)
        }
 
        wlc->modulecb =
-               kzalloc(sizeof(struct modulecb) * BRCMS_MAXMODULES, GFP_ATOMIC);
+               kcalloc(BRCMS_MAXMODULES, sizeof(struct modulecb),
+                       GFP_ATOMIC);
        if (wlc->modulecb == NULL) {
                *err = 1009;
                goto fail;
@@ -553,7 +554,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid)
        }
 
        wlc->bandstate[0] =
-               kzalloc(sizeof(struct brcms_band)*MAXBANDS, GFP_ATOMIC);
+               kcalloc(MAXBANDS, sizeof(struct brcms_band), GFP_ATOMIC);
        if (wlc->bandstate[0] == NULL) {
                *err = 1025;
                goto fail;
index 9d830d27b22926a73fea9ab681c50a8dfb5951d4..9fb0d9fbd93958e11b4eca19428c280a198f5628 100644 (file)
@@ -1387,7 +1387,7 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi,
        s16 *ptr;
        struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy;
 
-       ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC);
+       ptr = kmalloc_array(131, sizeof(s16), GFP_ATOMIC);
        if (NULL == ptr)
                return false;
        if (module == 2) {
@@ -2670,7 +2670,7 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi,
        u16 *values_to_save;
        struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy;
 
-       values_to_save = kmalloc(sizeof(u16) * 20, GFP_ATOMIC);
+       values_to_save = kmalloc_array(20, sizeof(u16), GFP_ATOMIC);
        if (NULL == values_to_save)
                return;
 
@@ -3678,11 +3678,11 @@ wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels,
        u16 *phy_c32;
        phy_c21 = 0;
        phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0;
-       ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC);
+       ptr = kmalloc_array(131, sizeof(s16), GFP_ATOMIC);
        if (NULL == ptr)
                return;
 
-       phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC);
+       phy_c32 = kmalloc_array(20, sizeof(u16), GFP_ATOMIC);
        if (NULL == phy_c32) {
                kfree(ptr);
                return;
index 7e01981bc5c8bf70475712c0942aa8cfe36c7c94..1a187557982e6c2d63f9c37e37229cf375ffd135 100644 (file)
@@ -23032,7 +23032,7 @@ wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cordic_iq *tone_buf,
        u16 t;
        u32 *data_buf = NULL;
 
-       data_buf = kmalloc(sizeof(u32) * num_samps, GFP_ATOMIC);
+       data_buf = kmalloc_array(num_samps, sizeof(u32), GFP_ATOMIC);
        if (data_buf == NULL)
                return;
 
@@ -23074,7 +23074,8 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val,
                tbl_len = (phy_bw << 1);
        }
 
-       tone_buf = kmalloc(sizeof(struct cordic_iq) * tbl_len, GFP_ATOMIC);
+       tone_buf = kmalloc_array(tbl_len, sizeof(struct cordic_iq),
+                                GFP_ATOMIC);
        if (tone_buf == NULL)
                return 0;
 
index ce0fbf83285f4b8448c9cdd9a8a289373ad52aa0..72046e182745dc72d00462285c4d8e55d42a74e5 100644 (file)
@@ -7127,7 +7127,7 @@ static int airo_get_aplist(struct net_device *dev,
        int i;
        int loseSync = capable(CAP_NET_ADMIN) ? 1: -1;
 
-       qual = kmalloc(IW_MAX_AP * sizeof(*qual), GFP_KERNEL);
+       qual = kmalloc_array(IW_MAX_AP, sizeof(*qual), GFP_KERNEL);
        if (!qual)
                return -ENOMEM;
 
index 7c4f550a1475d24dd87a6c075b8ff423a250243b..b8fd3cc90634d116af789caeae309444fffae42b 100644 (file)
@@ -3445,8 +3445,9 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
        dma_addr_t p;
 
        priv->msg_buffers =
-           kmalloc(IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet),
-                   GFP_KERNEL);
+           kmalloc_array(IPW_COMMAND_POOL_SIZE,
+                         sizeof(struct ipw2100_tx_packet),
+                         GFP_KERNEL);
        if (!priv->msg_buffers)
                return -ENOMEM;
 
@@ -4587,9 +4588,9 @@ static int ipw2100_rx_allocate(struct ipw2100_priv *priv)
        /*
         * allocate packets
         */
-       priv->rx_buffers = kmalloc(RX_QUEUE_LENGTH *
-                                  sizeof(struct ipw2100_rx_packet),
-                                  GFP_KERNEL);
+       priv->rx_buffers = kmalloc_array(RX_QUEUE_LENGTH,
+                                        sizeof(struct ipw2100_rx_packet),
+                                        GFP_KERNEL);
        if (!priv->rx_buffers) {
                IPW_DEBUG_INFO("can't allocate rx packet buffer table\n");
 
index f26beeb6c5ffe671a5b32394a14e15d454eed049..8a858f7e36f445374843b3090638f23ef28357be 100644 (file)
@@ -3208,13 +3208,13 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len)
 
        IPW_DEBUG_TRACE("<< :\n");
 
-       virts = kmalloc(sizeof(void *) * CB_NUMBER_OF_ELEMENTS_SMALL,
-                       GFP_KERNEL);
+       virts = kmalloc_array(CB_NUMBER_OF_ELEMENTS_SMALL, sizeof(void *),
+                             GFP_KERNEL);
        if (!virts)
                return -ENOMEM;
 
-       phys = kmalloc(sizeof(dma_addr_t) * CB_NUMBER_OF_ELEMENTS_SMALL,
-                       GFP_KERNEL);
+       phys = kmalloc_array(CB_NUMBER_OF_ELEMENTS_SMALL, sizeof(dma_addr_t),
+                            GFP_KERNEL);
        if (!phys) {
                kfree(virts);
                return -ENOMEM;
@@ -3782,7 +3782,7 @@ static int ipw_queue_tx_init(struct ipw_priv *priv,
 {
        struct pci_dev *dev = priv->pci_dev;
 
-       q->txb = kmalloc(sizeof(q->txb[0]) * count, GFP_KERNEL);
+       q->txb = kmalloc_array(count, sizeof(q->txb[0]), GFP_KERNEL);
        if (!q->txb) {
                IPW_ERROR("vmalloc for auxiliary BD structures failed\n");
                return -ENOMEM;
index 063e19ced7c86ec40f05054690f9d16d3fdb4b4a..6514baf799fef58b98a56d468641e72f8cde0888 100644 (file)
@@ -922,7 +922,7 @@ il_init_channel_map(struct il_priv *il)
        D_EEPROM("Parsing data for %d channels.\n", il->channel_count);
 
        il->channel_info =
-           kzalloc(sizeof(struct il_channel_info) * il->channel_count,
+           kcalloc(il->channel_count, sizeof(struct il_channel_info),
                    GFP_KERNEL);
        if (!il->channel_info) {
                IL_ERR("Could not allocate channel_info\n");
@@ -3041,9 +3041,9 @@ il_tx_queue_init(struct il_priv *il, u32 txq_id)
        }
 
        txq->meta =
-           kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL);
+           kcalloc(actual_slots, sizeof(struct il_cmd_meta), GFP_KERNEL);
        txq->cmd =
-           kzalloc(sizeof(struct il_device_cmd *) * actual_slots, GFP_KERNEL);
+           kcalloc(actual_slots, sizeof(struct il_device_cmd *), GFP_KERNEL);
 
        if (!txq->meta || !txq->cmd)
                goto out_free_arrays;
@@ -3455,7 +3455,7 @@ il_init_geos(struct il_priv *il)
        }
 
        channels =
-           kzalloc(sizeof(struct ieee80211_channel) * il->channel_count,
+           kcalloc(il->channel_count, sizeof(struct ieee80211_channel),
                    GFP_KERNEL);
        if (!channels)
                return -ENOMEM;
@@ -4654,8 +4654,9 @@ il_alloc_txq_mem(struct il_priv *il)
 {
        if (!il->txq)
                il->txq =
-                   kzalloc(sizeof(struct il_tx_queue) *
-                           il->cfg->num_of_queues, GFP_KERNEL);
+                   kcalloc(il->cfg->num_of_queues,
+                           sizeof(struct il_tx_queue),
+                           GFP_KERNEL);
        if (!il->txq) {
                IL_ERR("Not enough memory for txq\n");
                return -ENOMEM;
index 4b3753d78d03dfa3983e3e2991e8fa4106fcbeea..11ecdf63b7325b22f49402b10f2b1ca654c1fb36 100644 (file)
@@ -564,7 +564,7 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
        else
                blacklist_len = IWL_SCAN_MAX_BLACKLIST_LEN;
 
-       blacklist = kzalloc(sizeof(*blacklist) * blacklist_len, GFP_KERNEL);
+       blacklist = kcalloc(blacklist_len, sizeof(*blacklist), GFP_KERNEL);
        if (!blacklist)
                return -ENOMEM;
 
index de8a099a938636f77f0b47105e4903fe89ec0c5e..da8c30f10d92398c6ca2064e449f8e98f9cc2f94 100644 (file)
@@ -271,8 +271,9 @@ static void prism2_info_scanresults(local_info_t *local, unsigned char *buf,
        left -= 4;
 
        new_count = left / sizeof(struct hfa384x_scan_result);
-       results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result),
-                         GFP_ATOMIC);
+       results = kmalloc_array(new_count,
+                               sizeof(struct hfa384x_hostscan_result),
+                               GFP_ATOMIC);
        if (results == NULL)
                return;
 
index c1bc0a6ef300fd4ab73e5971fe66e582e47a0a89..1ca9731d9b14b181117fc6a6ad28b40e97cb35e6 100644 (file)
@@ -513,8 +513,8 @@ static int prism2_ioctl_giwaplist(struct net_device *dev,
                return -EOPNOTSUPP;
        }
 
-       addr = kmalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL);
-       qual = kmalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL);
+       addr = kmalloc_array(IW_MAX_AP, sizeof(struct sockaddr), GFP_KERNEL);
+       qual = kmalloc_array(IW_MAX_AP, sizeof(struct iw_quality), GFP_KERNEL);
        if (addr == NULL || qual == NULL) {
                kfree(addr);
                kfree(qual);
index d4c73d39336fce1e1d8cc3563fc534bd8e2da140..de2ef95c386c5baf1946ad29a74a168943ed2408 100644 (file)
@@ -161,8 +161,9 @@ static int p54_generate_band(struct ieee80211_hw *dev,
        if (!tmp)
                goto err_out;
 
-       tmp->channels = kzalloc(sizeof(struct ieee80211_channel) *
-                               list->band_channel_num[band], GFP_KERNEL);
+       tmp->channels = kcalloc(list->band_channel_num[band],
+                               sizeof(struct ieee80211_channel),
+                               GFP_KERNEL);
        if (!tmp->channels)
                goto err_out;
 
@@ -344,7 +345,7 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
                goto free;
        }
        priv->chan_num = max_channel_num;
-       priv->survey = kzalloc(sizeof(struct survey_info) * max_channel_num,
+       priv->survey = kcalloc(max_channel_num, sizeof(struct survey_info),
                               GFP_KERNEL);
        if (!priv->survey) {
                ret = -ENOMEM;
@@ -352,8 +353,9 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev)
        }
 
        list->max_entries = max_channel_num;
-       list->channels = kzalloc(sizeof(struct p54_channel_entry) *
-                                max_channel_num, GFP_KERNEL);
+       list->channels = kcalloc(max_channel_num,
+                                sizeof(struct p54_channel_entry),
+                                GFP_KERNEL);
        if (!list->channels) {
                ret = -ENOMEM;
                goto free;
index 6528ed5b9b1d23b10246fc6e30c9c162fc61b6a9..6d57e1cbcc0799bc8c8cae13a5b1348a5b41f62c 100644 (file)
@@ -244,7 +244,7 @@ mgt_init(islpci_private *priv)
        /* Alloc the cache */
        for (i = 0; i < OID_NUM_LAST; i++) {
                if (isl_oid[i].flags & OID_FLAG_CACHED) {
-                       priv->mib[i] = kzalloc(isl_oid[i].size *
+                       priv->mib[i] = kcalloc(isl_oid[i].size,
                                               (isl_oid[i].range + 1),
                                               GFP_KERNEL);
                        if (!priv->mib[i])
index 9825bfd42abc7542df38a939315348a7d46f4ddf..18e819d964f1cdadf7616dd70321bce6c6bf43e3 100644 (file)
@@ -3572,11 +3572,14 @@ static int __init init_mac80211_hwsim(void)
        hwsim_wq = alloc_workqueue("hwsim_wq", 0, 0);
        if (!hwsim_wq)
                return -ENOMEM;
-       rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
+
+       err = rhashtable_init(&hwsim_radios_rht, &hwsim_rht_params);
+       if (err)
+               goto out_free_wq;
 
        err = register_pernet_device(&hwsim_net_ops);
        if (err)
-               return err;
+               goto out_free_rht;
 
        err = platform_driver_register(&mac80211_hwsim_driver);
        if (err)
@@ -3701,6 +3704,10 @@ static int __init init_mac80211_hwsim(void)
        platform_driver_unregister(&mac80211_hwsim_driver);
 out_unregister_pernet:
        unregister_pernet_device(&hwsim_net_ops);
+out_free_rht:
+       rhashtable_destroy(&hwsim_radios_rht);
+out_free_wq:
+       destroy_workqueue(hwsim_wq);
        return err;
 }
 module_init(init_mac80211_hwsim);
index 1edcddaf7b4b61455d29dc6a1cad2bacf85dc08b..7ab44cd32a9d506b9dcef96c1f81c359123356dd 100644 (file)
@@ -399,8 +399,8 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta,
 
        new_node->win_size = win_size;
 
-       new_node->rx_reorder_ptr = kzalloc(sizeof(void *) * win_size,
-                                       GFP_KERNEL);
+       new_node->rx_reorder_ptr = kcalloc(win_size, sizeof(void *),
+                                          GFP_KERNEL);
        if (!new_node->rx_reorder_ptr) {
                kfree((u8 *) new_node);
                mwifiex_dbg(priv->adapter, ERROR,
index a67e2d66ac9d0de731539b5635096fa5c3f49832..4b5ae9098504bd6b28e83625aa40bda5a02d6c61 100644 (file)
@@ -4242,8 +4242,8 @@ int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter)
         * additional active scan request for hidden SSIDs on passive channels.
         */
        adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a);
-       adapter->chan_stats = vmalloc(sizeof(*adapter->chan_stats) *
-                                     adapter->num_in_chan_stats);
+       adapter->chan_stats = vmalloc(array_size(sizeof(*adapter->chan_stats),
+                                                adapter->num_in_chan_stats));
 
        if (!adapter->chan_stats)
                return -ENOMEM;
index 47d2dcc3f28fb0cb10f6e84ed1aca0a086d5601e..dfdcbc4f141af6dbbcfe144965e1642a7916fdfb 100644 (file)
@@ -2106,15 +2106,16 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter)
                return -ENOMEM;
 
        /* Allocate skb pointer buffers */
-       card->mpa_rx.skb_arr = kzalloc((sizeof(void *)) *
-                                      card->mp_agg_pkt_limit, GFP_KERNEL);
+       card->mpa_rx.skb_arr = kcalloc(card->mp_agg_pkt_limit, sizeof(void *),
+                                      GFP_KERNEL);
        if (!card->mpa_rx.skb_arr) {
                kfree(card->mp_regs);
                return -ENOMEM;
        }
 
-       card->mpa_rx.len_arr = kzalloc(sizeof(*card->mpa_rx.len_arr) *
-                                      card->mp_agg_pkt_limit, GFP_KERNEL);
+       card->mpa_rx.len_arr = kcalloc(card->mp_agg_pkt_limit,
+                                      sizeof(*card->mpa_rx.len_arr),
+                                      GFP_KERNEL);
        if (!card->mpa_rx.len_arr) {
                kfree(card->mp_regs);
                kfree(card->mpa_rx.skb_arr);
index fcd079a967823928533452249249de7e0e7e6f91..d62e34e7eadfe9dfce468dad87bf630c4d82c3f3 100644 (file)
@@ -181,7 +181,7 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband,
        if (!chanlist)
                return -ENOMEM;
 
-       msband->chan = devm_kzalloc(dev->dev, n_chan * sizeof(*msband->chan),
+       msband->chan = devm_kcalloc(dev->dev, n_chan, sizeof(*msband->chan),
                                    GFP_KERNEL);
        if (!msband->chan)
                return -ENOMEM;
index 5eb143667539929ed7d0440f14fb6df991915131..c5d94a95e21a4abfabeeeca9fe2f19a780e25c3e 100644 (file)
@@ -1216,7 +1216,7 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac,
                                return -EINVAL;
                        }
 
-                       limits = kzalloc(sizeof(*limits) * rec->n_limits,
+                       limits = kcalloc(rec->n_limits, sizeof(*limits),
                                         GFP_KERNEL);
                        if (!limits)
                                return -ENOMEM;
index 0eee479583b86dcbebfcba02d8abe5ff946af2dd..acc399b5574e021de4e9767be7c18937b14caf69 100644 (file)
@@ -397,7 +397,7 @@ static ssize_t rt2x00debug_read_crypto_stats(struct file *file,
        if (*offset)
                return 0;
 
-       data = kzalloc((1 + CIPHER_MAX) * MAX_LINE_LENGTH, GFP_KERNEL);
+       data = kcalloc(1 + CIPHER_MAX, MAX_LINE_LENGTH, GFP_KERNEL);
        if (!data)
                return -ENOMEM;
 
index fd13d4ef53b80fa173d6a1c1d8c2fd95ee4da533..9729e51fce381232d2bb18b4aa3f6b32a0daa610 100644 (file)
@@ -258,8 +258,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
        }
 
        /* allocate memory for efuse_tbl and efuse_word */
-       efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE] *
-                           sizeof(u8), GFP_ATOMIC);
+       efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE],
+                           GFP_ATOMIC);
        if (!efuse_tbl)
                return;
        efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC);
index ce3103bb8ebbd12a97874549141d6200c915f00b..f9faffc498bcbd2d94cad365814955f9b1347759 100644 (file)
@@ -1048,7 +1048,7 @@ int rtl_usb_probe(struct usb_interface *intf,
        }
        rtlpriv = hw->priv;
        rtlpriv->hw = hw;
-       rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
+       rtlpriv->usb_data = kcalloc(RTL_USB_MAX_RX_COUNT, sizeof(u32),
                                    GFP_KERNEL);
        if (!rtlpriv->usb_data)
                return -ENOMEM;
index 5153d2cfd9915ebfe911f830f309deff20d10f97..7c31b63b8258a6db067192f5b677a27fbafdaa43 100644 (file)
@@ -154,7 +154,7 @@ int cw1200_queue_stats_init(struct cw1200_queue_stats *stats,
        spin_lock_init(&stats->lock);
        init_waitqueue_head(&stats->wait_link_id_empty);
 
-       stats->link_map_cache = kzalloc(sizeof(int) * map_capacity,
+       stats->link_map_cache = kcalloc(map_capacity, sizeof(int),
                                        GFP_KERNEL);
        if (!stats->link_map_cache)
                return -ENOMEM;
@@ -181,13 +181,13 @@ int cw1200_queue_init(struct cw1200_queue *queue,
        spin_lock_init(&queue->lock);
        timer_setup(&queue->gc, cw1200_queue_gc, 0);
 
-       queue->pool = kzalloc(sizeof(struct cw1200_queue_item) * capacity,
-                       GFP_KERNEL);
+       queue->pool = kcalloc(capacity, sizeof(struct cw1200_queue_item),
+                             GFP_KERNEL);
        if (!queue->pool)
                return -ENOMEM;
 
-       queue->link_map_cache = kzalloc(sizeof(int) * stats->map_capacity,
-                       GFP_KERNEL);
+       queue->link_map_cache = kcalloc(stats->map_capacity, sizeof(int),
+                                       GFP_KERNEL);
        if (!queue->link_map_cache) {
                kfree(queue->pool);
                queue->pool = NULL;
index cc2ce60f4f097d93b09317801cda2376d8b880f0..67213f11acbd2e11f0ed85fee5d77003c20fae55 100644 (file)
@@ -230,9 +230,9 @@ void cw1200_scan_work(struct work_struct *work)
                        scan.type = WSM_SCAN_TYPE_BACKGROUND;
                        scan.flags = WSM_SCAN_FLAG_FORCE_BACKGROUND;
                }
-               scan.ch = kzalloc(
-                       sizeof(struct wsm_scan_ch) * (it - priv->scan.curr),
-                       GFP_KERNEL);
+               scan.ch = kcalloc(it - priv->scan.curr,
+                                 sizeof(struct wsm_scan_ch),
+                                 GFP_KERNEL);
                if (!scan.ch) {
                        priv->scan.status = -ENOMEM;
                        goto fail;
index b01b44a5d16ead6b9dddc71c198f28d385027621..1f6d9f357e57de8d733e86de73ac90b64cf3ffd5 100644 (file)
@@ -732,7 +732,8 @@ static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon,
 
        /* Alloc memory for full beacon write at once. */
        num_cmds = 1 + zd_chip_is_zd1211b(&mac->chip) + full_len;
-       ioreqs = kmalloc(num_cmds * sizeof(struct zd_ioreq32), GFP_KERNEL);
+       ioreqs = kmalloc_array(num_cmds, sizeof(struct zd_ioreq32),
+                              GFP_KERNEL);
        if (!ioreqs) {
                r = -ENOMEM;
                goto out_nofree;
index e1aef253601eb85a3e9776521bfcc897d6ec64e0..cd51492ae6c2dfae7bf9cef66b3206b8d126dbee 100644 (file)
@@ -977,8 +977,8 @@ static void connect(struct backend_info *be)
        }
 
        /* Use the number of queues requested by the frontend */
-       be->vif->queues = vzalloc(requested_num_queues *
-                                 sizeof(struct xenvif_queue));
+       be->vif->queues = vzalloc(array_size(requested_num_queues,
+                                            sizeof(struct xenvif_queue)));
        if (!be->vif->queues) {
                xenbus_dev_fatal(dev, -ENOMEM,
                                 "allocating queues");
index 679da1abd73c31ebb9b6f0650ee64e53fbe65116..922ce0abf5cf105a5394285b07356ebcad055d78 100644 (file)
@@ -239,7 +239,7 @@ static void rx_refill_timeout(struct timer_list *t)
 static int netfront_tx_slot_available(struct netfront_queue *queue)
 {
        return (queue->tx.req_prod_pvt - queue->tx.rsp_cons) <
-               (NET_TX_RING_SIZE - MAX_SKB_FRAGS - 2);
+               (NET_TX_RING_SIZE - XEN_NETIF_NR_SLOTS_MIN - 1);
 }
 
 static void xennet_maybe_wake_tx(struct netfront_queue *queue)
@@ -790,7 +790,7 @@ static int xennet_get_responses(struct netfront_queue *queue,
        RING_IDX cons = queue->rx.rsp_cons;
        struct sk_buff *skb = xennet_get_rx_skb(queue, cons);
        grant_ref_t ref = xennet_get_rx_ref(queue, cons);
-       int max = MAX_SKB_FRAGS + (rx->status <= RX_COPY_THRESHOLD);
+       int max = XEN_NETIF_NR_SLOTS_MIN + (rx->status <= RX_COPY_THRESHOLD);
        int slots = 1;
        int err = 0;
        unsigned long ret;
index c4da50e07bbcbe2318a27f55c5e49baf5f3c077b..d8d70dd830b07fe6254e1e5d52e12045a4ea64f4 100644 (file)
@@ -259,8 +259,8 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev,
                /* Add 1 to the length to inclue the length byte itself */
                len++;
 
-               *fw_vsc_cfg = devm_kmalloc(dev,
-                                          len * sizeof(**fw_vsc_cfg),
+               *fw_vsc_cfg = devm_kmalloc_array(dev,
+                                          len, sizeof(**fw_vsc_cfg),
                                           GFP_KERNEL);
 
                r = device_property_read_u8_array(dev, FDP_DP_FW_VSC_CFG_NAME,
index 3cfa468762393dd058d4699e57bf97020ab8400f..efb214fc545a231514ac1309033beb9579c6014a 100644 (file)
@@ -592,12 +592,12 @@ static int ndev_init_isr(struct amd_ntb_dev *ndev,
        ndev->db_mask = ndev->db_valid_mask;
 
        /* Try to set up msix irq */
-       ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec),
+       ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec),
                                 GFP_KERNEL, node);
        if (!ndev->vec)
                goto err_msix_vec_alloc;
 
-       ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix),
+       ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix),
                                  GFP_KERNEL, node);
        if (!ndev->msix)
                goto err_msix_alloc;
index 8d98872d0983b7109a3579ac9c3982d30efa96d8..dbe72f116017ab305a0a1f19276155700f69211e 100644 (file)
@@ -1401,7 +1401,7 @@ static int idt_ntb_peer_mw_clear_trans(struct ntb_dev *ntb, int pidx,
  *                          5. Doorbell operations
  *
  *    Doorbell functionality of IDT PCIe-switches is pretty unusual. First of
- * all there is global doorbell register which state can by changed by any
+ * all there is global doorbell register which state can be changed by any
  * NT-function of the IDT device in accordance with global permissions. These
  * permissions configs are not supported by NTB API, so it must be done by
  * either BIOS or EEPROM settings. In the same way the state of the global
index 1b434568d2ade66a2fd1d040b68cbbbf7e902e25..4ff22af967c658464558c60dd0b9d3e9c8f10285 100644 (file)
@@ -1 +1,2 @@
 obj-$(CONFIG_NTB_INTEL) += ntb_hw_intel.o
+ntb_hw_intel-y := ntb_hw_gen1.o ntb_hw_gen3.o
similarity index 74%
rename from drivers/ntb/hw/intel/ntb_hw_intel.c
rename to drivers/ntb/hw/intel/ntb_hw_gen1.c
index 156b45cd4a198b9d1f1b50bebc33f4384953e89c..6aa57322727916bd5bc1c8e5ab13f286f8fd1b1d 100644 (file)
@@ -45,9 +45,6 @@
  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * Intel PCIe NTB Linux driver
- *
- * Contact Information:
- * Jon Mason <jon.mason@intel.com>
  */
 
 #include <linux/debugfs.h>
@@ -61,6 +58,8 @@
 #include <linux/ntb.h>
 
 #include "ntb_hw_intel.h"
+#include "ntb_hw_gen1.h"
+#include "ntb_hw_gen3.h"
 
 #define NTB_NAME       "ntb_hw_intel"
 #define NTB_DESC       "Intel(R) PCI-E Non-Transparent Bridge Driver"
@@ -80,14 +79,7 @@ static const struct intel_ntb_alt_reg xeon_sec_reg;
 static const struct intel_ntb_alt_reg xeon_b2b_reg;
 static const struct intel_ntb_xlat_reg xeon_pri_xlat;
 static const struct intel_ntb_xlat_reg xeon_sec_xlat;
-static struct intel_b2b_addr xeon_b2b_usd_addr;
-static struct intel_b2b_addr xeon_b2b_dsd_addr;
-static const struct intel_ntb_reg skx_reg;
-static const struct intel_ntb_alt_reg skx_pri_reg;
-static const struct intel_ntb_alt_reg skx_b2b_reg;
-static const struct intel_ntb_xlat_reg skx_sec_xlat;
 static const struct ntb_dev_ops intel_ntb_ops;
-static const struct ntb_dev_ops intel_ntb3_ops;
 
 static const struct file_operations intel_ntb_debugfs_info;
 static struct dentry *debugfs_dir;
@@ -146,68 +138,8 @@ module_param_named(xeon_b2b_dsd_bar5_addr32,
 MODULE_PARM_DESC(xeon_b2b_dsd_bar5_addr32,
                 "XEON B2B DSD split-BAR 5 32-bit address");
 
-static inline enum ntb_topo xeon_ppd_topo(struct intel_ntb_dev *ndev, u8 ppd);
-static int xeon_init_isr(struct intel_ntb_dev *ndev);
-
-#ifndef ioread64
-#ifdef readq
-#define ioread64 readq
-#else
-#define ioread64 _ioread64
-static inline u64 _ioread64(void __iomem *mmio)
-{
-       u64 low, high;
-
-       low = ioread32(mmio);
-       high = ioread32(mmio + sizeof(u32));
-       return low | (high << 32);
-}
-#endif
-#endif
-
-#ifndef iowrite64
-#ifdef writeq
-#define iowrite64 writeq
-#else
-#define iowrite64 _iowrite64
-static inline void _iowrite64(u64 val, void __iomem *mmio)
-{
-       iowrite32(val, mmio);
-       iowrite32(val >> 32, mmio + sizeof(u32));
-}
-#endif
-#endif
-
-static inline int pdev_is_xeon(struct pci_dev *pdev)
-{
-       switch (pdev->device) {
-       case PCI_DEVICE_ID_INTEL_NTB_SS_JSF:
-       case PCI_DEVICE_ID_INTEL_NTB_SS_SNB:
-       case PCI_DEVICE_ID_INTEL_NTB_SS_IVT:
-       case PCI_DEVICE_ID_INTEL_NTB_SS_HSX:
-       case PCI_DEVICE_ID_INTEL_NTB_SS_BDX:
-       case PCI_DEVICE_ID_INTEL_NTB_PS_JSF:
-       case PCI_DEVICE_ID_INTEL_NTB_PS_SNB:
-       case PCI_DEVICE_ID_INTEL_NTB_PS_IVT:
-       case PCI_DEVICE_ID_INTEL_NTB_PS_HSX:
-       case PCI_DEVICE_ID_INTEL_NTB_PS_BDX:
-       case PCI_DEVICE_ID_INTEL_NTB_B2B_JSF:
-       case PCI_DEVICE_ID_INTEL_NTB_B2B_SNB:
-       case PCI_DEVICE_ID_INTEL_NTB_B2B_IVT:
-       case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX:
-       case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX:
-               return 1;
-       }
-       return 0;
-}
-
-static inline int pdev_is_skx_xeon(struct pci_dev *pdev)
-{
-       if (pdev->device == PCI_DEVICE_ID_INTEL_NTB_B2B_SKX)
-               return 1;
 
-       return 0;
-}
+static int xeon_init_isr(struct intel_ntb_dev *ndev);
 
 static inline void ndev_reset_unsafe_flags(struct intel_ntb_dev *ndev)
 {
@@ -241,7 +173,7 @@ static inline int ndev_ignore_unsafe(struct intel_ntb_dev *ndev,
        return !!flag;
 }
 
-static int ndev_mw_to_bar(struct intel_ntb_dev *ndev, int idx)
+int ndev_mw_to_bar(struct intel_ntb_dev *ndev, int idx)
 {
        if (idx < 0 || idx >= ndev->mw_count)
                return -EINVAL;
@@ -268,7 +200,7 @@ static inline int ndev_db_addr(struct intel_ntb_dev *ndev,
        return 0;
 }
 
-static inline u64 ndev_db_read(struct intel_ntb_dev *ndev,
+u64 ndev_db_read(struct intel_ntb_dev *ndev,
                               void __iomem *mmio)
 {
        if (ndev_is_unsafe(ndev, NTB_UNSAFE_DB))
@@ -277,7 +209,7 @@ static inline u64 ndev_db_read(struct intel_ntb_dev *ndev,
        return ndev->reg->db_ioread(mmio);
 }
 
-static inline int ndev_db_write(struct intel_ntb_dev *ndev, u64 db_bits,
+int ndev_db_write(struct intel_ntb_dev *ndev, u64 db_bits,
                                void __iomem *mmio)
 {
        if (ndev_is_unsafe(ndev, NTB_UNSAFE_DB))
@@ -429,7 +361,7 @@ static irqreturn_t ndev_irq_isr(int irq, void *dev)
        return ndev_interrupt(ndev, irq - ndev->ntb.pdev->irq);
 }
 
-static int ndev_init_isr(struct intel_ntb_dev *ndev,
+int ndev_init_isr(struct intel_ntb_dev *ndev,
                         int msix_min, int msix_max,
                         int msix_shift, int total_shift)
 {
@@ -448,12 +380,12 @@ static int ndev_init_isr(struct intel_ntb_dev *ndev,
 
        /* Try to set up msix irq */
 
-       ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec),
+       ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec),
                                 GFP_KERNEL, node);
        if (!ndev->vec)
                goto err_msix_vec_alloc;
 
-       ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix),
+       ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix),
                                  GFP_KERNEL, node);
        if (!ndev->msix)
                goto err_msix_alloc;
@@ -557,169 +489,6 @@ static void ndev_deinit_isr(struct intel_ntb_dev *ndev)
        }
 }
 
-static ssize_t ndev_ntb3_debugfs_read(struct file *filp, char __user *ubuf,
-                                     size_t count, loff_t *offp)
-{
-       struct intel_ntb_dev *ndev;
-       void __iomem *mmio;
-       char *buf;
-       size_t buf_size;
-       ssize_t ret, off;
-       union { u64 v64; u32 v32; u16 v16; } u;
-
-       ndev = filp->private_data;
-       mmio = ndev->self_mmio;
-
-       buf_size = min(count, 0x800ul);
-
-       buf = kmalloc(buf_size, GFP_KERNEL);
-       if (!buf)
-               return -ENOMEM;
-
-       off = 0;
-
-       off += scnprintf(buf + off, buf_size - off,
-                        "NTB Device Information:\n");
-
-       off += scnprintf(buf + off, buf_size - off,
-                        "Connection Topology -\t%s\n",
-                        ntb_topo_string(ndev->ntb.topo));
-
-       off += scnprintf(buf + off, buf_size - off,
-                        "NTB CTL -\t\t%#06x\n", ndev->ntb_ctl);
-       off += scnprintf(buf + off, buf_size - off,
-                        "LNK STA -\t\t%#06x\n", ndev->lnk_sta);
-
-       if (!ndev->reg->link_is_up(ndev))
-               off += scnprintf(buf + off, buf_size - off,
-                                "Link Status -\t\tDown\n");
-       else {
-               off += scnprintf(buf + off, buf_size - off,
-                                "Link Status -\t\tUp\n");
-               off += scnprintf(buf + off, buf_size - off,
-                                "Link Speed -\t\tPCI-E Gen %u\n",
-                                NTB_LNK_STA_SPEED(ndev->lnk_sta));
-               off += scnprintf(buf + off, buf_size - off,
-                                "Link Width -\t\tx%u\n",
-                                NTB_LNK_STA_WIDTH(ndev->lnk_sta));
-       }
-
-       off += scnprintf(buf + off, buf_size - off,
-                        "Memory Window Count -\t%u\n", ndev->mw_count);
-       off += scnprintf(buf + off, buf_size - off,
-                        "Scratchpad Count -\t%u\n", ndev->spad_count);
-       off += scnprintf(buf + off, buf_size - off,
-                        "Doorbell Count -\t%u\n", ndev->db_count);
-       off += scnprintf(buf + off, buf_size - off,
-                        "Doorbell Vector Count -\t%u\n", ndev->db_vec_count);
-       off += scnprintf(buf + off, buf_size - off,
-                        "Doorbell Vector Shift -\t%u\n", ndev->db_vec_shift);
-
-       off += scnprintf(buf + off, buf_size - off,
-                        "Doorbell Valid Mask -\t%#llx\n", ndev->db_valid_mask);
-       off += scnprintf(buf + off, buf_size - off,
-                        "Doorbell Link Mask -\t%#llx\n", ndev->db_link_mask);
-       off += scnprintf(buf + off, buf_size - off,
-                        "Doorbell Mask Cached -\t%#llx\n", ndev->db_mask);
-
-       u.v64 = ndev_db_read(ndev, mmio + ndev->self_reg->db_mask);
-       off += scnprintf(buf + off, buf_size - off,
-                        "Doorbell Mask -\t\t%#llx\n", u.v64);
-
-       u.v64 = ndev_db_read(ndev, mmio + ndev->self_reg->db_bell);
-       off += scnprintf(buf + off, buf_size - off,
-                        "Doorbell Bell -\t\t%#llx\n", u.v64);
-
-       off += scnprintf(buf + off, buf_size - off,
-                        "\nNTB Incoming XLAT:\n");
-
-       u.v64 = ioread64(mmio + SKX_IMBAR1XBASE_OFFSET);
-       off += scnprintf(buf + off, buf_size - off,
-                        "IMBAR1XBASE -\t\t%#018llx\n", u.v64);
-
-       u.v64 = ioread64(mmio + SKX_IMBAR2XBASE_OFFSET);
-       off += scnprintf(buf + off, buf_size - off,
-                        "IMBAR2XBASE -\t\t%#018llx\n", u.v64);
-
-       u.v64 = ioread64(mmio + SKX_IMBAR1XLMT_OFFSET);
-       off += scnprintf(buf + off, buf_size - off,
-                        "IMBAR1XLMT -\t\t\t%#018llx\n", u.v64);
-
-       u.v64 = ioread64(mmio + SKX_IMBAR2XLMT_OFFSET);
-       off += scnprintf(buf + off, buf_size - off,
-                        "IMBAR2XLMT -\t\t\t%#018llx\n", u.v64);
-
-       if (ntb_topo_is_b2b(ndev->ntb.topo)) {
-               off += scnprintf(buf + off, buf_size - off,
-                                "\nNTB Outgoing B2B XLAT:\n");
-
-               u.v64 = ioread64(mmio + SKX_EMBAR1XBASE_OFFSET);
-               off += scnprintf(buf + off, buf_size - off,
-                                "EMBAR1XBASE -\t\t%#018llx\n", u.v64);
-
-               u.v64 = ioread64(mmio + SKX_EMBAR2XBASE_OFFSET);
-               off += scnprintf(buf + off, buf_size - off,
-                                "EMBAR2XBASE -\t\t%#018llx\n", u.v64);
-
-               u.v64 = ioread64(mmio + SKX_EMBAR1XLMT_OFFSET);
-               off += scnprintf(buf + off, buf_size - off,
-                                "EMBAR1XLMT -\t\t%#018llx\n", u.v64);
-
-               u.v64 = ioread64(mmio + SKX_EMBAR2XLMT_OFFSET);
-               off += scnprintf(buf + off, buf_size - off,
-                                "EMBAR2XLMT -\t\t%#018llx\n", u.v64);
-
-               off += scnprintf(buf + off, buf_size - off,
-                                "\nNTB Secondary BAR:\n");
-
-               u.v64 = ioread64(mmio + SKX_EMBAR0_OFFSET);
-               off += scnprintf(buf + off, buf_size - off,
-                                "EMBAR0 -\t\t%#018llx\n", u.v64);
-
-               u.v64 = ioread64(mmio + SKX_EMBAR1_OFFSET);
-               off += scnprintf(buf + off, buf_size - off,
-                                "EMBAR1 -\t\t%#018llx\n", u.v64);
-
-               u.v64 = ioread64(mmio + SKX_EMBAR2_OFFSET);
-               off += scnprintf(buf + off, buf_size - off,
-                                "EMBAR2 -\t\t%#018llx\n", u.v64);
-       }
-
-       off += scnprintf(buf + off, buf_size - off,
-                        "\nNTB Statistics:\n");
-
-       u.v16 = ioread16(mmio + SKX_USMEMMISS_OFFSET);
-       off += scnprintf(buf + off, buf_size - off,
-                        "Upstream Memory Miss -\t%u\n", u.v16);
-
-       off += scnprintf(buf + off, buf_size - off,
-                        "\nNTB Hardware Errors:\n");
-
-       if (!pci_read_config_word(ndev->ntb.pdev,
-                                 SKX_DEVSTS_OFFSET, &u.v16))
-               off += scnprintf(buf + off, buf_size - off,
-                                "DEVSTS -\t\t%#06x\n", u.v16);
-
-       if (!pci_read_config_word(ndev->ntb.pdev,
-                                 SKX_LINK_STATUS_OFFSET, &u.v16))
-               off += scnprintf(buf + off, buf_size - off,
-                                "LNKSTS -\t\t%#06x\n", u.v16);
-
-       if (!pci_read_config_dword(ndev->ntb.pdev,
-                                  SKX_UNCERRSTS_OFFSET, &u.v32))
-               off += scnprintf(buf + off, buf_size - off,
-                                "UNCERRSTS -\t\t%#06x\n", u.v32);
-
-       if (!pci_read_config_dword(ndev->ntb.pdev,
-                                  SKX_CORERRSTS_OFFSET, &u.v32))
-               off += scnprintf(buf + off, buf_size - off,
-                                "CORERRSTS -\t\t%#06x\n", u.v32);
-
-       ret = simple_read_from_buffer(ubuf, count, offp, buf, off);
-       kfree(buf);
-       return ret;
-}
-
 static ssize_t ndev_ntb_debugfs_read(struct file *filp, char __user *ubuf,
                                     size_t count, loff_t *offp)
 {
@@ -879,7 +648,7 @@ static ssize_t ndev_ntb_debugfs_read(struct file *filp, char __user *ubuf,
                                 "LMT45 -\t\t\t%#018llx\n", u.v64);
        }
 
-       if (pdev_is_xeon(pdev)) {
+       if (pdev_is_gen1(pdev)) {
                if (ntb_topo_is_b2b(ndev->ntb.topo)) {
                        off += scnprintf(buf + off, buf_size - off,
                                         "\nNTB Outgoing B2B XLAT:\n");
@@ -991,9 +760,9 @@ static ssize_t ndev_debugfs_read(struct file *filp, char __user *ubuf,
 {
        struct intel_ntb_dev *ndev = filp->private_data;
 
-       if (pdev_is_xeon(ndev->ntb.pdev))
+       if (pdev_is_gen1(ndev->ntb.pdev))
                return ndev_ntb_debugfs_read(filp, ubuf, count, offp);
-       else if (pdev_is_skx_xeon(ndev->ntb.pdev))
+       else if (pdev_is_gen3(ndev->ntb.pdev))
                return ndev_ntb3_debugfs_read(filp, ubuf, count, offp);
 
        return -ENXIO;
@@ -1023,7 +792,7 @@ static void ndev_deinit_debugfs(struct intel_ntb_dev *ndev)
        debugfs_remove_recursive(ndev->debugfs_dir);
 }
 
-static int intel_ntb_mw_count(struct ntb_dev *ntb, int pidx)
+int intel_ntb_mw_count(struct ntb_dev *ntb, int pidx)
 {
        if (pidx != NTB_DEF_PEER_IDX)
                return -EINVAL;
@@ -1031,10 +800,10 @@ static int intel_ntb_mw_count(struct ntb_dev *ntb, int pidx)
        return ntb_ndev(ntb)->mw_count;
 }
 
-static int intel_ntb_mw_get_align(struct ntb_dev *ntb, int pidx, int idx,
-                                 resource_size_t *addr_align,
-                                 resource_size_t *size_align,
-                                 resource_size_t *size_max)
+int intel_ntb_mw_get_align(struct ntb_dev *ntb, int pidx, int idx,
+                          resource_size_t *addr_align,
+                          resource_size_t *size_align,
+                          resource_size_t *size_max)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
        resource_size_t bar_size, mw_size;
@@ -1170,9 +939,8 @@ static int intel_ntb_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
        return 0;
 }
 
-static u64 intel_ntb_link_is_up(struct ntb_dev *ntb,
-                               enum ntb_speed *speed,
-                               enum ntb_width *width)
+u64 intel_ntb_link_is_up(struct ntb_dev *ntb, enum ntb_speed *speed,
+                        enum ntb_width *width)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1224,7 +992,7 @@ static int intel_ntb_link_enable(struct ntb_dev *ntb,
        return 0;
 }
 
-static int intel_ntb_link_disable(struct ntb_dev *ntb)
+int intel_ntb_link_disable(struct ntb_dev *ntb)
 {
        struct intel_ntb_dev *ndev;
        u32 ntb_cntl;
@@ -1248,14 +1016,14 @@ static int intel_ntb_link_disable(struct ntb_dev *ntb)
        return 0;
 }
 
-static int intel_ntb_peer_mw_count(struct ntb_dev *ntb)
+int intel_ntb_peer_mw_count(struct ntb_dev *ntb)
 {
        /* Numbers of inbound and outbound memory windows match */
        return ntb_ndev(ntb)->mw_count;
 }
 
-static int intel_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx,
-                                    phys_addr_t *base, resource_size_t *size)
+int intel_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx,
+                              phys_addr_t *base, resource_size_t *size)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
        int bar;
@@ -1283,12 +1051,12 @@ static int intel_ntb_db_is_unsafe(struct ntb_dev *ntb)
        return ndev_ignore_unsafe(ntb_ndev(ntb), NTB_UNSAFE_DB);
 }
 
-static u64 intel_ntb_db_valid_mask(struct ntb_dev *ntb)
+u64 intel_ntb_db_valid_mask(struct ntb_dev *ntb)
 {
        return ntb_ndev(ntb)->db_valid_mask;
 }
 
-static int intel_ntb_db_vector_count(struct ntb_dev *ntb)
+int intel_ntb_db_vector_count(struct ntb_dev *ntb)
 {
        struct intel_ntb_dev *ndev;
 
@@ -1297,7 +1065,7 @@ static int intel_ntb_db_vector_count(struct ntb_dev *ntb)
        return ndev->db_vec_count;
 }
 
-static u64 intel_ntb_db_vector_mask(struct ntb_dev *ntb, int db_vector)
+u64 intel_ntb_db_vector_mask(struct ntb_dev *ntb, int db_vector)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1325,7 +1093,7 @@ static int intel_ntb_db_clear(struct ntb_dev *ntb, u64 db_bits)
                             ndev->self_reg->db_bell);
 }
 
-static int intel_ntb_db_set_mask(struct ntb_dev *ntb, u64 db_bits)
+int intel_ntb_db_set_mask(struct ntb_dev *ntb, u64 db_bits)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1334,7 +1102,7 @@ static int intel_ntb_db_set_mask(struct ntb_dev *ntb, u64 db_bits)
                                ndev->self_reg->db_mask);
 }
 
-static int intel_ntb_db_clear_mask(struct ntb_dev *ntb, u64 db_bits)
+int intel_ntb_db_clear_mask(struct ntb_dev *ntb, u64 db_bits)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1343,9 +1111,8 @@ static int intel_ntb_db_clear_mask(struct ntb_dev *ntb, u64 db_bits)
                                  ndev->self_reg->db_mask);
 }
 
-static int intel_ntb_peer_db_addr(struct ntb_dev *ntb,
-                                 phys_addr_t *db_addr,
-                                 resource_size_t *db_size)
+int intel_ntb_peer_db_addr(struct ntb_dev *ntb, phys_addr_t *db_addr,
+                          resource_size_t *db_size)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1362,12 +1129,12 @@ static int intel_ntb_peer_db_set(struct ntb_dev *ntb, u64 db_bits)
                             ndev->peer_reg->db_bell);
 }
 
-static int intel_ntb_spad_is_unsafe(struct ntb_dev *ntb)
+int intel_ntb_spad_is_unsafe(struct ntb_dev *ntb)
 {
        return ndev_ignore_unsafe(ntb_ndev(ntb), NTB_UNSAFE_SPAD);
 }
 
-static int intel_ntb_spad_count(struct ntb_dev *ntb)
+int intel_ntb_spad_count(struct ntb_dev *ntb)
 {
        struct intel_ntb_dev *ndev;
 
@@ -1376,7 +1143,7 @@ static int intel_ntb_spad_count(struct ntb_dev *ntb)
        return ndev->spad_count;
 }
 
-static u32 intel_ntb_spad_read(struct ntb_dev *ntb, int idx)
+u32 intel_ntb_spad_read(struct ntb_dev *ntb, int idx)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1385,8 +1152,7 @@ static u32 intel_ntb_spad_read(struct ntb_dev *ntb, int idx)
                              ndev->self_reg->spad);
 }
 
-static int intel_ntb_spad_write(struct ntb_dev *ntb,
-                               int idx, u32 val)
+int intel_ntb_spad_write(struct ntb_dev *ntb, int idx, u32 val)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1395,8 +1161,8 @@ static int intel_ntb_spad_write(struct ntb_dev *ntb,
                               ndev->self_reg->spad);
 }
 
-static int intel_ntb_peer_spad_addr(struct ntb_dev *ntb, int pidx, int sidx,
-                                   phys_addr_t *spad_addr)
+int intel_ntb_peer_spad_addr(struct ntb_dev *ntb, int pidx, int sidx,
+                            phys_addr_t *spad_addr)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1404,7 +1170,7 @@ static int intel_ntb_peer_spad_addr(struct ntb_dev *ntb, int pidx, int sidx,
                              ndev->peer_reg->spad);
 }
 
-static u32 intel_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx)
+u32 intel_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1413,8 +1179,8 @@ static u32 intel_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx)
                              ndev->peer_reg->spad);
 }
 
-static int intel_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx,
-                                    int sidx, u32 val)
+int intel_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx, int sidx,
+                             u32 val)
 {
        struct intel_ntb_dev *ndev = ntb_ndev(ntb);
 
@@ -1423,336 +1189,6 @@ static int intel_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx,
                               ndev->peer_reg->spad);
 }
 
-/* Skylake Xeon NTB */
-
-static int skx_poll_link(struct intel_ntb_dev *ndev)
-{
-       u16 reg_val;
-       int rc;
-
-       ndev->reg->db_iowrite(ndev->db_link_mask,
-                             ndev->self_mmio +
-                             ndev->self_reg->db_clear);
-
-       rc = pci_read_config_word(ndev->ntb.pdev,
-                                 SKX_LINK_STATUS_OFFSET, &reg_val);
-       if (rc)
-               return 0;
-
-       if (reg_val == ndev->lnk_sta)
-               return 0;
-
-       ndev->lnk_sta = reg_val;
-
-       return 1;
-}
-
-static u64 skx_db_ioread(void __iomem *mmio)
-{
-       return ioread64(mmio);
-}
-
-static void skx_db_iowrite(u64 bits, void __iomem *mmio)
-{
-       iowrite64(bits, mmio);
-}
-
-static int skx_init_isr(struct intel_ntb_dev *ndev)
-{
-       int i;
-
-       /*
-        * The MSIX vectors and the interrupt status bits are not lined up
-        * on Skylake. By default the link status bit is bit 32, however it
-        * is by default MSIX vector0. We need to fixup to line them up.
-        * The vectors at reset is 1-32,0. We need to reprogram to 0-32.
-        */
-
-       for (i = 0; i < SKX_DB_MSIX_VECTOR_COUNT; i++)
-               iowrite8(i, ndev->self_mmio + SKX_INTVEC_OFFSET + i);
-
-       /* move link status down one as workaround */
-       if (ndev->hwerr_flags & NTB_HWERR_MSIX_VECTOR32_BAD) {
-               iowrite8(SKX_DB_MSIX_VECTOR_COUNT - 2,
-                        ndev->self_mmio + SKX_INTVEC_OFFSET +
-                        (SKX_DB_MSIX_VECTOR_COUNT - 1));
-       }
-
-       return ndev_init_isr(ndev, SKX_DB_MSIX_VECTOR_COUNT,
-                            SKX_DB_MSIX_VECTOR_COUNT,
-                            SKX_DB_MSIX_VECTOR_SHIFT,
-                            SKX_DB_TOTAL_SHIFT);
-}
-
-static int skx_setup_b2b_mw(struct intel_ntb_dev *ndev,
-                           const struct intel_b2b_addr *addr,
-                           const struct intel_b2b_addr *peer_addr)
-{
-       struct pci_dev *pdev;
-       void __iomem *mmio;
-       phys_addr_t bar_addr;
-
-       pdev = ndev->ntb.pdev;
-       mmio = ndev->self_mmio;
-
-       /* setup incoming bar limits == base addrs (zero length windows) */
-       bar_addr = addr->bar2_addr64;
-       iowrite64(bar_addr, mmio + SKX_IMBAR1XLMT_OFFSET);
-       bar_addr = ioread64(mmio + SKX_IMBAR1XLMT_OFFSET);
-       dev_dbg(&pdev->dev, "IMBAR1XLMT %#018llx\n", bar_addr);
-
-       bar_addr = addr->bar4_addr64;
-       iowrite64(bar_addr, mmio + SKX_IMBAR2XLMT_OFFSET);
-       bar_addr = ioread64(mmio + SKX_IMBAR2XLMT_OFFSET);
-       dev_dbg(&pdev->dev, "IMBAR2XLMT %#018llx\n", bar_addr);
-
-       /* zero incoming translation addrs */
-       iowrite64(0, mmio + SKX_IMBAR1XBASE_OFFSET);
-       iowrite64(0, mmio + SKX_IMBAR2XBASE_OFFSET);
-
-       ndev->peer_mmio = ndev->self_mmio;
-
-       return 0;
-}
-
-static int skx_init_ntb(struct intel_ntb_dev *ndev)
-{
-       int rc;
-
-
-       ndev->mw_count = XEON_MW_COUNT;
-       ndev->spad_count = SKX_SPAD_COUNT;
-       ndev->db_count = SKX_DB_COUNT;
-       ndev->db_link_mask = SKX_DB_LINK_BIT;
-
-       /* DB fixup for using 31 right now */
-       if (ndev->hwerr_flags & NTB_HWERR_MSIX_VECTOR32_BAD)
-               ndev->db_link_mask |= BIT_ULL(31);
-
-       switch (ndev->ntb.topo) {
-       case NTB_TOPO_B2B_USD:
-       case NTB_TOPO_B2B_DSD:
-               ndev->self_reg = &skx_pri_reg;
-               ndev->peer_reg = &skx_b2b_reg;
-               ndev->xlat_reg = &skx_sec_xlat;
-
-               if (ndev->ntb.topo == NTB_TOPO_B2B_USD) {
-                       rc = skx_setup_b2b_mw(ndev,
-                                             &xeon_b2b_dsd_addr,
-                                             &xeon_b2b_usd_addr);
-               } else {
-                       rc = skx_setup_b2b_mw(ndev,
-                                             &xeon_b2b_usd_addr,
-                                             &xeon_b2b_dsd_addr);
-               }
-
-               if (rc)
-                       return rc;
-
-               /* Enable Bus Master and Memory Space on the secondary side */
-               iowrite16(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER,
-                         ndev->self_mmio + SKX_SPCICMD_OFFSET);
-
-               break;
-
-       default:
-               return -EINVAL;
-       }
-
-       ndev->db_valid_mask = BIT_ULL(ndev->db_count) - 1;
-
-       ndev->reg->db_iowrite(ndev->db_valid_mask,
-                             ndev->self_mmio +
-                             ndev->self_reg->db_mask);
-
-       return 0;
-}
-
-static int skx_init_dev(struct intel_ntb_dev *ndev)
-{
-       struct pci_dev *pdev;
-       u8 ppd;
-       int rc;
-
-       pdev = ndev->ntb.pdev;
-
-       ndev->reg = &skx_reg;
-
-       rc = pci_read_config_byte(pdev, XEON_PPD_OFFSET, &ppd);
-       if (rc)
-               return -EIO;
-
-       ndev->ntb.topo = xeon_ppd_topo(ndev, ppd);
-       dev_dbg(&pdev->dev, "ppd %#x topo %s\n", ppd,
-               ntb_topo_string(ndev->ntb.topo));
-       if (ndev->ntb.topo == NTB_TOPO_NONE)
-               return -EINVAL;
-
-       if (pdev_is_skx_xeon(pdev))
-               ndev->hwerr_flags |= NTB_HWERR_MSIX_VECTOR32_BAD;
-
-       rc = skx_init_ntb(ndev);
-       if (rc)
-               return rc;
-
-       return skx_init_isr(ndev);
-}
-
-static int intel_ntb3_link_enable(struct ntb_dev *ntb,
-                                 enum ntb_speed max_speed,
-                                 enum ntb_width max_width)
-{
-       struct intel_ntb_dev *ndev;
-       u32 ntb_ctl;
-
-       ndev = container_of(ntb, struct intel_ntb_dev, ntb);
-
-       dev_dbg(&ntb->pdev->dev,
-               "Enabling link with max_speed %d max_width %d\n",
-               max_speed, max_width);
-
-       if (max_speed != NTB_SPEED_AUTO)
-               dev_dbg(&ntb->pdev->dev, "ignoring max_speed %d\n", max_speed);
-       if (max_width != NTB_WIDTH_AUTO)
-               dev_dbg(&ntb->pdev->dev, "ignoring max_width %d\n", max_width);
-
-       ntb_ctl = ioread32(ndev->self_mmio + ndev->reg->ntb_ctl);
-       ntb_ctl &= ~(NTB_CTL_DISABLE | NTB_CTL_CFG_LOCK);
-       ntb_ctl |= NTB_CTL_P2S_BAR2_SNOOP | NTB_CTL_S2P_BAR2_SNOOP;
-       ntb_ctl |= NTB_CTL_P2S_BAR4_SNOOP | NTB_CTL_S2P_BAR4_SNOOP;
-       iowrite32(ntb_ctl, ndev->self_mmio + ndev->reg->ntb_ctl);
-
-       return 0;
-}
-static int intel_ntb3_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
-                                  dma_addr_t addr, resource_size_t size)
-{
-       struct intel_ntb_dev *ndev = ntb_ndev(ntb);
-       unsigned long xlat_reg, limit_reg;
-       resource_size_t bar_size, mw_size;
-       void __iomem *mmio;
-       u64 base, limit, reg_val;
-       int bar;
-
-       if (pidx != NTB_DEF_PEER_IDX)
-               return -EINVAL;
-
-       if (idx >= ndev->b2b_idx && !ndev->b2b_off)
-               idx += 1;
-
-       bar = ndev_mw_to_bar(ndev, idx);
-       if (bar < 0)
-               return bar;
-
-       bar_size = pci_resource_len(ndev->ntb.pdev, bar);
-
-       if (idx == ndev->b2b_idx)
-               mw_size = bar_size - ndev->b2b_off;
-       else
-               mw_size = bar_size;
-
-       /* hardware requires that addr is aligned to bar size */
-       if (addr & (bar_size - 1))
-               return -EINVAL;
-
-       /* make sure the range fits in the usable mw size */
-       if (size > mw_size)
-               return -EINVAL;
-
-       mmio = ndev->self_mmio;
-       xlat_reg = ndev->xlat_reg->bar2_xlat + (idx * 0x10);
-       limit_reg = ndev->xlat_reg->bar2_limit + (idx * 0x10);
-       base = pci_resource_start(ndev->ntb.pdev, bar);
-
-       /* Set the limit if supported, if size is not mw_size */
-       if (limit_reg && size != mw_size)
-               limit = base + size;
-       else
-               limit = base + mw_size;
-
-       /* set and verify setting the translation address */
-       iowrite64(addr, mmio + xlat_reg);
-       reg_val = ioread64(mmio + xlat_reg);
-       if (reg_val != addr) {
-               iowrite64(0, mmio + xlat_reg);
-               return -EIO;
-       }
-
-       dev_dbg(&ntb->pdev->dev, "BAR %d IMBARXBASE: %#Lx\n", bar, reg_val);
-
-       /* set and verify setting the limit */
-       iowrite64(limit, mmio + limit_reg);
-       reg_val = ioread64(mmio + limit_reg);
-       if (reg_val != limit) {
-               iowrite64(base, mmio + limit_reg);
-               iowrite64(0, mmio + xlat_reg);
-               return -EIO;
-       }
-
-       dev_dbg(&ntb->pdev->dev, "BAR %d IMBARXLMT: %#Lx\n", bar, reg_val);
-
-       /* setup the EP */
-       limit_reg = ndev->xlat_reg->bar2_limit + (idx * 0x10) + 0x4000;
-       base = ioread64(mmio + SKX_EMBAR1_OFFSET + (8 * idx));
-       base &= ~0xf;
-
-       if (limit_reg && size != mw_size)
-               limit = base + size;
-       else
-               limit = base + mw_size;
-
-       /* set and verify setting the limit */
-       iowrite64(limit, mmio + limit_reg);
-       reg_val = ioread64(mmio + limit_reg);
-       if (reg_val != limit) {
-               iowrite64(base, mmio + limit_reg);
-               iowrite64(0, mmio + xlat_reg);
-               return -EIO;
-       }
-
-       dev_dbg(&ntb->pdev->dev, "BAR %d EMBARXLMT: %#Lx\n", bar, reg_val);
-
-       return 0;
-}
-
-static int intel_ntb3_peer_db_set(struct ntb_dev *ntb, u64 db_bits)
-{
-       struct intel_ntb_dev *ndev = ntb_ndev(ntb);
-       int bit;
-
-       if (db_bits & ~ndev->db_valid_mask)
-               return -EINVAL;
-
-       while (db_bits) {
-               bit = __ffs(db_bits);
-               iowrite32(1, ndev->peer_mmio +
-                               ndev->peer_reg->db_bell + (bit * 4));
-               db_bits &= db_bits - 1;
-       }
-
-       return 0;
-}
-
-static u64 intel_ntb3_db_read(struct ntb_dev *ntb)
-{
-       struct intel_ntb_dev *ndev = ntb_ndev(ntb);
-
-       return ndev_db_read(ndev,
-                           ndev->self_mmio +
-                           ndev->self_reg->db_clear);
-}
-
-static int intel_ntb3_db_clear(struct ntb_dev *ntb, u64 db_bits)
-{
-       struct intel_ntb_dev *ndev = ntb_ndev(ntb);
-
-       return ndev_db_write(ndev, db_bits,
-                            ndev->self_mmio +
-                            ndev->self_reg->db_clear);
-}
-
-/* XEON */
-
 static u64 xeon_db_ioread(void __iomem *mmio)
 {
        return (u64)ioread16(mmio);
@@ -1785,7 +1221,7 @@ static int xeon_poll_link(struct intel_ntb_dev *ndev)
        return 1;
 }
 
-static int xeon_link_is_up(struct intel_ntb_dev *ndev)
+int xeon_link_is_up(struct intel_ntb_dev *ndev)
 {
        if (ndev->ntb.topo == NTB_TOPO_SEC)
                return 1;
@@ -1793,7 +1229,7 @@ static int xeon_link_is_up(struct intel_ntb_dev *ndev)
        return NTB_LNK_STA_ACTIVE(ndev->lnk_sta);
 }
 
-static inline enum ntb_topo xeon_ppd_topo(struct intel_ntb_dev *ndev, u8 ppd)
+enum ntb_topo xeon_ppd_topo(struct intel_ntb_dev *ndev, u8 ppd)
 {
        switch (ppd & XEON_PPD_TOPO_MASK) {
        case XEON_PPD_TOPO_B2B_USD:
@@ -2410,7 +1846,7 @@ static int intel_ntb_pci_probe(struct pci_dev *pdev,
 
        node = dev_to_node(&pdev->dev);
 
-       if (pdev_is_xeon(pdev)) {
+       if (pdev_is_gen1(pdev)) {
                ndev = kzalloc_node(sizeof(*ndev), GFP_KERNEL, node);
                if (!ndev) {
                        rc = -ENOMEM;
@@ -2427,7 +1863,7 @@ static int intel_ntb_pci_probe(struct pci_dev *pdev,
                if (rc)
                        goto err_init_dev;
 
-       } else if (pdev_is_skx_xeon(pdev)) {
+       } else if (pdev_is_gen3(pdev)) {
                ndev = kzalloc_node(sizeof(*ndev), GFP_KERNEL, node);
                if (!ndev) {
                        rc = -ENOMEM;
@@ -2441,7 +1877,7 @@ static int intel_ntb_pci_probe(struct pci_dev *pdev,
                if (rc)
                        goto err_init_pci;
 
-               rc = skx_init_dev(ndev);
+               rc = gen3_init_dev(ndev);
                if (rc)
                        goto err_init_dev;
 
@@ -2466,7 +1902,7 @@ static int intel_ntb_pci_probe(struct pci_dev *pdev,
 
 err_register:
        ndev_deinit_debugfs(ndev);
-       if (pdev_is_xeon(pdev) || pdev_is_skx_xeon(pdev))
+       if (pdev_is_gen1(pdev) || pdev_is_gen3(pdev))
                xeon_deinit_dev(ndev);
 err_init_dev:
        intel_ntb_deinit_pci(ndev);
@@ -2482,7 +1918,7 @@ static void intel_ntb_pci_remove(struct pci_dev *pdev)
 
        ntb_unregister_device(&ndev->ntb);
        ndev_deinit_debugfs(ndev);
-       if (pdev_is_xeon(pdev) || pdev_is_skx_xeon(pdev))
+       if (pdev_is_gen1(pdev) || pdev_is_gen3(pdev))
                xeon_deinit_dev(ndev);
        intel_ntb_deinit_pci(ndev);
        kfree(ndev);
@@ -2537,50 +1973,20 @@ static const struct intel_ntb_xlat_reg xeon_sec_xlat = {
        .bar2_xlat              = XEON_SBAR23XLAT_OFFSET,
 };
 
-static struct intel_b2b_addr xeon_b2b_usd_addr = {
+struct intel_b2b_addr xeon_b2b_usd_addr = {
        .bar2_addr64            = XEON_B2B_BAR2_ADDR64,
        .bar4_addr64            = XEON_B2B_BAR4_ADDR64,
        .bar4_addr32            = XEON_B2B_BAR4_ADDR32,
        .bar5_addr32            = XEON_B2B_BAR5_ADDR32,
 };
 
-static struct intel_b2b_addr xeon_b2b_dsd_addr = {
+struct intel_b2b_addr xeon_b2b_dsd_addr = {
        .bar2_addr64            = XEON_B2B_BAR2_ADDR64,
        .bar4_addr64            = XEON_B2B_BAR4_ADDR64,
        .bar4_addr32            = XEON_B2B_BAR4_ADDR32,
        .bar5_addr32            = XEON_B2B_BAR5_ADDR32,
 };
 
-static const struct intel_ntb_reg skx_reg = {
-       .poll_link              = skx_poll_link,
-       .link_is_up             = xeon_link_is_up,
-       .db_ioread              = skx_db_ioread,
-       .db_iowrite             = skx_db_iowrite,
-       .db_size                = sizeof(u32),
-       .ntb_ctl                = SKX_NTBCNTL_OFFSET,
-       .mw_bar                 = {2, 4},
-};
-
-static const struct intel_ntb_alt_reg skx_pri_reg = {
-       .db_bell                = SKX_EM_DOORBELL_OFFSET,
-       .db_clear               = SKX_IM_INT_STATUS_OFFSET,
-       .db_mask                = SKX_IM_INT_DISABLE_OFFSET,
-       .spad                   = SKX_IM_SPAD_OFFSET,
-};
-
-static const struct intel_ntb_alt_reg skx_b2b_reg = {
-       .db_bell                = SKX_IM_DOORBELL_OFFSET,
-       .db_clear               = SKX_EM_INT_STATUS_OFFSET,
-       .db_mask                = SKX_EM_INT_DISABLE_OFFSET,
-       .spad                   = SKX_B2B_SPAD_OFFSET,
-};
-
-static const struct intel_ntb_xlat_reg skx_sec_xlat = {
-/*     .bar0_base              = SKX_EMBAR0_OFFSET, */
-       .bar2_limit             = SKX_IMBAR1XLMT_OFFSET,
-       .bar2_xlat              = SKX_IMBAR1XBASE_OFFSET,
-};
-
 /* operations for primary side of local ntb */
 static const struct ntb_dev_ops intel_ntb_ops = {
        .mw_count               = intel_ntb_mw_count,
@@ -2610,33 +2016,6 @@ static const struct ntb_dev_ops intel_ntb_ops = {
        .peer_spad_write        = intel_ntb_peer_spad_write,
 };
 
-static const struct ntb_dev_ops intel_ntb3_ops = {
-       .mw_count               = intel_ntb_mw_count,
-       .mw_get_align           = intel_ntb_mw_get_align,
-       .mw_set_trans           = intel_ntb3_mw_set_trans,
-       .peer_mw_count          = intel_ntb_peer_mw_count,
-       .peer_mw_get_addr       = intel_ntb_peer_mw_get_addr,
-       .link_is_up             = intel_ntb_link_is_up,
-       .link_enable            = intel_ntb3_link_enable,
-       .link_disable           = intel_ntb_link_disable,
-       .db_valid_mask          = intel_ntb_db_valid_mask,
-       .db_vector_count        = intel_ntb_db_vector_count,
-       .db_vector_mask         = intel_ntb_db_vector_mask,
-       .db_read                = intel_ntb3_db_read,
-       .db_clear               = intel_ntb3_db_clear,
-       .db_set_mask            = intel_ntb_db_set_mask,
-       .db_clear_mask          = intel_ntb_db_clear_mask,
-       .peer_db_addr           = intel_ntb_peer_db_addr,
-       .peer_db_set            = intel_ntb3_peer_db_set,
-       .spad_is_unsafe         = intel_ntb_spad_is_unsafe,
-       .spad_count             = intel_ntb_spad_count,
-       .spad_read              = intel_ntb_spad_read,
-       .spad_write             = intel_ntb_spad_write,
-       .peer_spad_addr         = intel_ntb_peer_spad_addr,
-       .peer_spad_read         = intel_ntb_peer_spad_read,
-       .peer_spad_write        = intel_ntb_peer_spad_write,
-};
-
 static const struct file_operations intel_ntb_debugfs_info = {
        .owner = THIS_MODULE,
        .open = simple_open,
diff --git a/drivers/ntb/hw/intel/ntb_hw_gen1.h b/drivers/ntb/hw/intel/ntb_hw_gen1.h
new file mode 100644 (file)
index 0000000..ad8ec14
--- /dev/null
@@ -0,0 +1,182 @@
+/*
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ *   redistributing this file, you may do so under either license.
+ *
+ *   GPL LICENSE SUMMARY
+ *
+ *   Copyright(c) 2012-2017 Intel Corporation. All rights reserved.
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of version 2 of the GNU General Public License as
+ *   published by the Free Software Foundation.
+ *
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2012-2017 Intel Corporation. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copy
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may 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.
+ */
+
+#ifndef _NTB_INTEL_GEN1_H_
+#define _NTB_INTEL_GEN1_H_
+
+#include "ntb_hw_intel.h"
+
+/* Intel Gen1 Xeon hardware */
+#define XEON_PBAR23LMT_OFFSET          0x0000
+#define XEON_PBAR45LMT_OFFSET          0x0008
+#define XEON_PBAR4LMT_OFFSET           0x0008
+#define XEON_PBAR5LMT_OFFSET           0x000c
+#define XEON_PBAR23XLAT_OFFSET         0x0010
+#define XEON_PBAR45XLAT_OFFSET         0x0018
+#define XEON_PBAR4XLAT_OFFSET          0x0018
+#define XEON_PBAR5XLAT_OFFSET          0x001c
+#define XEON_SBAR23LMT_OFFSET          0x0020
+#define XEON_SBAR45LMT_OFFSET          0x0028
+#define XEON_SBAR4LMT_OFFSET           0x0028
+#define XEON_SBAR5LMT_OFFSET           0x002c
+#define XEON_SBAR23XLAT_OFFSET         0x0030
+#define XEON_SBAR45XLAT_OFFSET         0x0038
+#define XEON_SBAR4XLAT_OFFSET          0x0038
+#define XEON_SBAR5XLAT_OFFSET          0x003c
+#define XEON_SBAR0BASE_OFFSET          0x0040
+#define XEON_SBAR23BASE_OFFSET         0x0048
+#define XEON_SBAR45BASE_OFFSET         0x0050
+#define XEON_SBAR4BASE_OFFSET          0x0050
+#define XEON_SBAR5BASE_OFFSET          0x0054
+#define XEON_SBDF_OFFSET               0x005c
+#define XEON_NTBCNTL_OFFSET            0x0058
+#define XEON_PDOORBELL_OFFSET          0x0060
+#define XEON_PDBMSK_OFFSET             0x0062
+#define XEON_SDOORBELL_OFFSET          0x0064
+#define XEON_SDBMSK_OFFSET             0x0066
+#define XEON_USMEMMISS_OFFSET          0x0070
+#define XEON_SPAD_OFFSET               0x0080
+#define XEON_PBAR23SZ_OFFSET           0x00d0
+#define XEON_PBAR45SZ_OFFSET           0x00d1
+#define XEON_PBAR4SZ_OFFSET            0x00d1
+#define XEON_SBAR23SZ_OFFSET           0x00d2
+#define XEON_SBAR45SZ_OFFSET           0x00d3
+#define XEON_SBAR4SZ_OFFSET            0x00d3
+#define XEON_PPD_OFFSET                        0x00d4
+#define XEON_PBAR5SZ_OFFSET            0x00d5
+#define XEON_SBAR5SZ_OFFSET            0x00d6
+#define XEON_WCCNTRL_OFFSET            0x00e0
+#define XEON_UNCERRSTS_OFFSET          0x014c
+#define XEON_CORERRSTS_OFFSET          0x0158
+#define XEON_LINK_STATUS_OFFSET                0x01a2
+#define XEON_SPCICMD_OFFSET            0x0504
+#define XEON_DEVCTRL_OFFSET            0x0598
+#define XEON_DEVSTS_OFFSET             0x059a
+#define XEON_SLINK_STATUS_OFFSET       0x05a2
+#define XEON_B2B_SPAD_OFFSET           0x0100
+#define XEON_B2B_DOORBELL_OFFSET       0x0140
+#define XEON_B2B_XLAT_OFFSETL          0x0144
+#define XEON_B2B_XLAT_OFFSETU          0x0148
+#define XEON_PPD_CONN_MASK             0x03
+#define XEON_PPD_CONN_TRANSPARENT      0x00
+#define XEON_PPD_CONN_B2B              0x01
+#define XEON_PPD_CONN_RP               0x02
+#define XEON_PPD_DEV_MASK              0x10
+#define XEON_PPD_DEV_USD               0x00
+#define XEON_PPD_DEV_DSD               0x10
+#define XEON_PPD_SPLIT_BAR_MASK                0x40
+
+#define XEON_PPD_TOPO_MASK     (XEON_PPD_CONN_MASK | XEON_PPD_DEV_MASK)
+#define XEON_PPD_TOPO_PRI_USD  (XEON_PPD_CONN_RP | XEON_PPD_DEV_USD)
+#define XEON_PPD_TOPO_PRI_DSD  (XEON_PPD_CONN_RP | XEON_PPD_DEV_DSD)
+#define XEON_PPD_TOPO_SEC_USD  (XEON_PPD_CONN_TRANSPARENT | XEON_PPD_DEV_USD)
+#define XEON_PPD_TOPO_SEC_DSD  (XEON_PPD_CONN_TRANSPARENT | XEON_PPD_DEV_DSD)
+#define XEON_PPD_TOPO_B2B_USD  (XEON_PPD_CONN_B2B | XEON_PPD_DEV_USD)
+#define XEON_PPD_TOPO_B2B_DSD  (XEON_PPD_CONN_B2B | XEON_PPD_DEV_DSD)
+
+#define XEON_MW_COUNT                  2
+#define HSX_SPLIT_BAR_MW_COUNT         3
+#define XEON_DB_COUNT                  15
+#define XEON_DB_LINK                   15
+#define XEON_DB_LINK_BIT                       BIT_ULL(XEON_DB_LINK)
+#define XEON_DB_MSIX_VECTOR_COUNT      4
+#define XEON_DB_MSIX_VECTOR_SHIFT      5
+#define XEON_DB_TOTAL_SHIFT            16
+#define XEON_SPAD_COUNT                        16
+
+/* Use the following addresses for translation between b2b ntb devices in case
+ * the hardware default values are not reliable. */
+#define XEON_B2B_BAR0_ADDR     0x1000000000000000ull
+#define XEON_B2B_BAR2_ADDR64   0x2000000000000000ull
+#define XEON_B2B_BAR4_ADDR64   0x4000000000000000ull
+#define XEON_B2B_BAR4_ADDR32   0x20000000u
+#define XEON_B2B_BAR5_ADDR32   0x40000000u
+
+/* The peer ntb secondary config space is 32KB fixed size */
+#define XEON_B2B_MIN_SIZE              0x8000
+
+/* flags to indicate hardware errata */
+#define NTB_HWERR_SDOORBELL_LOCKUP     BIT_ULL(0)
+#define NTB_HWERR_SB01BASE_LOCKUP      BIT_ULL(1)
+#define NTB_HWERR_B2BDOORBELL_BIT14    BIT_ULL(2)
+#define NTB_HWERR_MSIX_VECTOR32_BAD    BIT_ULL(3)
+
+extern struct intel_b2b_addr xeon_b2b_usd_addr;
+extern struct intel_b2b_addr xeon_b2b_dsd_addr;
+
+int ndev_init_isr(struct intel_ntb_dev *ndev, int msix_min, int msix_max,
+               int msix_shift, int total_shift);
+enum ntb_topo xeon_ppd_topo(struct intel_ntb_dev *ndev, u8 ppd);
+u64 ndev_db_read(struct intel_ntb_dev *ndev, void __iomem *mmio);
+int ndev_db_write(struct intel_ntb_dev *ndev, u64 db_bits,
+                               void __iomem *mmio);
+int ndev_mw_to_bar(struct intel_ntb_dev *ndev, int idx);
+int intel_ntb_mw_count(struct ntb_dev *ntb, int pidx);
+int intel_ntb_mw_get_align(struct ntb_dev *ntb, int pidx, int idx,
+               resource_size_t *addr_align, resource_size_t *size_align,
+               resource_size_t *size_max);
+int intel_ntb_peer_mw_count(struct ntb_dev *ntb);
+int intel_ntb_peer_mw_get_addr(struct ntb_dev *ntb, int idx,
+               phys_addr_t *base, resource_size_t *size);
+u64 intel_ntb_link_is_up(struct ntb_dev *ntb, enum ntb_speed *speed,
+               enum ntb_width *width);
+int intel_ntb_link_disable(struct ntb_dev *ntb);
+u64 intel_ntb_db_valid_mask(struct ntb_dev *ntb);
+int intel_ntb_db_vector_count(struct ntb_dev *ntb);
+u64 intel_ntb_db_vector_mask(struct ntb_dev *ntb, int db_vector);
+int intel_ntb_db_set_mask(struct ntb_dev *ntb, u64 db_bits);
+int intel_ntb_db_clear_mask(struct ntb_dev *ntb, u64 db_bits);
+int intel_ntb_peer_db_addr(struct ntb_dev *ntb, phys_addr_t *db_addr,
+               resource_size_t *db_size);
+int intel_ntb_spad_is_unsafe(struct ntb_dev *ntb);
+int intel_ntb_spad_count(struct ntb_dev *ntb);
+u32 intel_ntb_spad_read(struct ntb_dev *ntb, int idx);
+int intel_ntb_spad_write(struct ntb_dev *ntb, int idx, u32 val);
+u32 intel_ntb_peer_spad_read(struct ntb_dev *ntb, int pidx, int sidx);
+int intel_ntb_peer_spad_write(struct ntb_dev *ntb, int pidx, int sidx,
+               u32 val);
+int intel_ntb_peer_spad_addr(struct ntb_dev *ntb, int pidx, int sidx,
+                                   phys_addr_t *spad_addr);
+int xeon_link_is_up(struct intel_ntb_dev *ndev);
+
+#endif
diff --git a/drivers/ntb/hw/intel/ntb_hw_gen3.c b/drivers/ntb/hw/intel/ntb_hw_gen3.c
new file mode 100644 (file)
index 0000000..b3fa247
--- /dev/null
@@ -0,0 +1,597 @@
+/*
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ *   redistributing this file, you may do so under either license.
+ *
+ *   GPL LICENSE SUMMARY
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of version 2 of the GNU General Public License as
+ *   published by the Free Software Foundation.
+ *
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2017 Intel Corporation. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copy
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may 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.
+ *
+ * Intel PCIe GEN3 NTB Linux driver
+ *
+ */
+
+#include <linux/debugfs.h>
+#include <linux/delay.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/pci.h>
+#include <linux/random.h>
+#include <linux/slab.h>
+#include <linux/ntb.h>
+
+#include "ntb_hw_intel.h"
+#include "ntb_hw_gen1.h"
+#include "ntb_hw_gen3.h"
+
+static int gen3_poll_link(struct intel_ntb_dev *ndev);
+
+static const struct intel_ntb_reg gen3_reg = {
+       .poll_link              = gen3_poll_link,
+       .link_is_up             = xeon_link_is_up,
+       .db_ioread              = gen3_db_ioread,
+       .db_iowrite             = gen3_db_iowrite,
+       .db_size                = sizeof(u32),
+       .ntb_ctl                = GEN3_NTBCNTL_OFFSET,
+       .mw_bar                 = {2, 4},
+};
+
+static const struct intel_ntb_alt_reg gen3_pri_reg = {
+       .db_bell                = GEN3_EM_DOORBELL_OFFSET,
+       .db_clear               = GEN3_IM_INT_STATUS_OFFSET,
+       .db_mask                = GEN3_IM_INT_DISABLE_OFFSET,
+       .spad                   = GEN3_IM_SPAD_OFFSET,
+};
+
+static const struct intel_ntb_alt_reg gen3_b2b_reg = {
+       .db_bell                = GEN3_IM_DOORBELL_OFFSET,
+       .db_clear               = GEN3_EM_INT_STATUS_OFFSET,
+       .db_mask                = GEN3_EM_INT_DISABLE_OFFSET,
+       .spad                   = GEN3_B2B_SPAD_OFFSET,
+};
+
+static const struct intel_ntb_xlat_reg gen3_sec_xlat = {
+/*     .bar0_base              = GEN3_EMBAR0_OFFSET, */
+       .bar2_limit             = GEN3_IMBAR1XLMT_OFFSET,
+       .bar2_xlat              = GEN3_IMBAR1XBASE_OFFSET,
+};
+
+static int gen3_poll_link(struct intel_ntb_dev *ndev)
+{
+       u16 reg_val;
+       int rc;
+
+       ndev->reg->db_iowrite(ndev->db_link_mask,
+                             ndev->self_mmio +
+                             ndev->self_reg->db_clear);
+
+       rc = pci_read_config_word(ndev->ntb.pdev,
+                                 GEN3_LINK_STATUS_OFFSET, &reg_val);
+       if (rc)
+               return 0;
+
+       if (reg_val == ndev->lnk_sta)
+               return 0;
+
+       ndev->lnk_sta = reg_val;
+
+       return 1;
+}
+
+static int gen3_init_isr(struct intel_ntb_dev *ndev)
+{
+       int i;
+
+       /*
+        * The MSIX vectors and the interrupt status bits are not lined up
+        * on Skylake. By default the link status bit is bit 32, however it
+        * is by default MSIX vector0. We need to fixup to line them up.
+        * The vectors at reset is 1-32,0. We need to reprogram to 0-32.
+        */
+
+       for (i = 0; i < GEN3_DB_MSIX_VECTOR_COUNT; i++)
+               iowrite8(i, ndev->self_mmio + GEN3_INTVEC_OFFSET + i);
+
+       /* move link status down one as workaround */
+       if (ndev->hwerr_flags & NTB_HWERR_MSIX_VECTOR32_BAD) {
+               iowrite8(GEN3_DB_MSIX_VECTOR_COUNT - 2,
+                        ndev->self_mmio + GEN3_INTVEC_OFFSET +
+                        (GEN3_DB_MSIX_VECTOR_COUNT - 1));
+       }
+
+       return ndev_init_isr(ndev, GEN3_DB_MSIX_VECTOR_COUNT,
+                            GEN3_DB_MSIX_VECTOR_COUNT,
+                            GEN3_DB_MSIX_VECTOR_SHIFT,
+                            GEN3_DB_TOTAL_SHIFT);
+}
+
+static int gen3_setup_b2b_mw(struct intel_ntb_dev *ndev,
+                           const struct intel_b2b_addr *addr,
+                           const struct intel_b2b_addr *peer_addr)
+{
+       struct pci_dev *pdev;
+       void __iomem *mmio;
+       phys_addr_t bar_addr;
+
+       pdev = ndev->ntb.pdev;
+       mmio = ndev->self_mmio;
+
+       /* setup incoming bar limits == base addrs (zero length windows) */
+       bar_addr = addr->bar2_addr64;
+       iowrite64(bar_addr, mmio + GEN3_IMBAR1XLMT_OFFSET);
+       bar_addr = ioread64(mmio + GEN3_IMBAR1XLMT_OFFSET);
+       dev_dbg(&pdev->dev, "IMBAR1XLMT %#018llx\n", bar_addr);
+
+       bar_addr = addr->bar4_addr64;
+       iowrite64(bar_addr, mmio + GEN3_IMBAR2XLMT_OFFSET);
+       bar_addr = ioread64(mmio + GEN3_IMBAR2XLMT_OFFSET);
+       dev_dbg(&pdev->dev, "IMBAR2XLMT %#018llx\n", bar_addr);
+
+       /* zero incoming translation addrs */
+       iowrite64(0, mmio + GEN3_IMBAR1XBASE_OFFSET);
+       iowrite64(0, mmio + GEN3_IMBAR2XBASE_OFFSET);
+
+       ndev->peer_mmio = ndev->self_mmio;
+
+       return 0;
+}
+
+static int gen3_init_ntb(struct intel_ntb_dev *ndev)
+{
+       int rc;
+
+
+       ndev->mw_count = XEON_MW_COUNT;
+       ndev->spad_count = GEN3_SPAD_COUNT;
+       ndev->db_count = GEN3_DB_COUNT;
+       ndev->db_link_mask = GEN3_DB_LINK_BIT;
+
+       /* DB fixup for using 31 right now */
+       if (ndev->hwerr_flags & NTB_HWERR_MSIX_VECTOR32_BAD)
+               ndev->db_link_mask |= BIT_ULL(31);
+
+       switch (ndev->ntb.topo) {
+       case NTB_TOPO_B2B_USD:
+       case NTB_TOPO_B2B_DSD:
+               ndev->self_reg = &gen3_pri_reg;
+               ndev->peer_reg = &gen3_b2b_reg;
+               ndev->xlat_reg = &gen3_sec_xlat;
+
+               if (ndev->ntb.topo == NTB_TOPO_B2B_USD) {
+                       rc = gen3_setup_b2b_mw(ndev,
+                                             &xeon_b2b_dsd_addr,
+                                             &xeon_b2b_usd_addr);
+               } else {
+                       rc = gen3_setup_b2b_mw(ndev,
+                                             &xeon_b2b_usd_addr,
+                                             &xeon_b2b_dsd_addr);
+               }
+
+               if (rc)
+                       return rc;
+
+               /* Enable Bus Master and Memory Space on the secondary side */
+               iowrite16(PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER,
+                         ndev->self_mmio + GEN3_SPCICMD_OFFSET);
+
+               break;
+
+       default:
+               return -EINVAL;
+       }
+
+       ndev->db_valid_mask = BIT_ULL(ndev->db_count) - 1;
+
+       ndev->reg->db_iowrite(ndev->db_valid_mask,
+                             ndev->self_mmio +
+                             ndev->self_reg->db_mask);
+
+       return 0;
+}
+
+int gen3_init_dev(struct intel_ntb_dev *ndev)
+{
+       struct pci_dev *pdev;
+       u8 ppd;
+       int rc;
+
+       pdev = ndev->ntb.pdev;
+
+       ndev->reg = &gen3_reg;
+
+       rc = pci_read_config_byte(pdev, XEON_PPD_OFFSET, &ppd);
+       if (rc)
+               return -EIO;
+
+       ndev->ntb.topo = xeon_ppd_topo(ndev, ppd);
+       dev_dbg(&pdev->dev, "ppd %#x topo %s\n", ppd,
+               ntb_topo_string(ndev->ntb.topo));
+       if (ndev->ntb.topo == NTB_TOPO_NONE)
+               return -EINVAL;
+
+       ndev->hwerr_flags |= NTB_HWERR_MSIX_VECTOR32_BAD;
+
+       rc = gen3_init_ntb(ndev);
+       if (rc)
+               return rc;
+
+       return gen3_init_isr(ndev);
+}
+
+ssize_t ndev_ntb3_debugfs_read(struct file *filp, char __user *ubuf,
+                                     size_t count, loff_t *offp)
+{
+       struct intel_ntb_dev *ndev;
+       void __iomem *mmio;
+       char *buf;
+       size_t buf_size;
+       ssize_t ret, off;
+       union { u64 v64; u32 v32; u16 v16; } u;
+
+       ndev = filp->private_data;
+       mmio = ndev->self_mmio;
+
+       buf_size = min(count, 0x800ul);
+
+       buf = kmalloc(buf_size, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+
+       off = 0;
+
+       off += scnprintf(buf + off, buf_size - off,
+                        "NTB Device Information:\n");
+
+       off += scnprintf(buf + off, buf_size - off,
+                        "Connection Topology -\t%s\n",
+                        ntb_topo_string(ndev->ntb.topo));
+
+       off += scnprintf(buf + off, buf_size - off,
+                        "NTB CTL -\t\t%#06x\n", ndev->ntb_ctl);
+       off += scnprintf(buf + off, buf_size - off,
+                        "LNK STA -\t\t%#06x\n", ndev->lnk_sta);
+
+       if (!ndev->reg->link_is_up(ndev))
+               off += scnprintf(buf + off, buf_size - off,
+                                "Link Status -\t\tDown\n");
+       else {
+               off += scnprintf(buf + off, buf_size - off,
+                                "Link Status -\t\tUp\n");
+               off += scnprintf(buf + off, buf_size - off,
+                                "Link Speed -\t\tPCI-E Gen %u\n",
+                                NTB_LNK_STA_SPEED(ndev->lnk_sta));
+               off += scnprintf(buf + off, buf_size - off,
+                                "Link Width -\t\tx%u\n",
+                                NTB_LNK_STA_WIDTH(ndev->lnk_sta));
+       }
+
+       off += scnprintf(buf + off, buf_size - off,
+                        "Memory Window Count -\t%u\n", ndev->mw_count);
+       off += scnprintf(buf + off, buf_size - off,
+                        "Scratchpad Count -\t%u\n", ndev->spad_count);
+       off += scnprintf(buf + off, buf_size - off,
+                        "Doorbell Count -\t%u\n", ndev->db_count);
+       off += scnprintf(buf + off, buf_size - off,
+                        "Doorbell Vector Count -\t%u\n", ndev->db_vec_count);
+       off += scnprintf(buf + off, buf_size - off,
+                        "Doorbell Vector Shift -\t%u\n", ndev->db_vec_shift);
+
+       off += scnprintf(buf + off, buf_size - off,
+                        "Doorbell Valid Mask -\t%#llx\n", ndev->db_valid_mask);
+       off += scnprintf(buf + off, buf_size - off,
+                        "Doorbell Link Mask -\t%#llx\n", ndev->db_link_mask);
+       off += scnprintf(buf + off, buf_size - off,
+                        "Doorbell Mask Cached -\t%#llx\n", ndev->db_mask);
+
+       u.v64 = ndev_db_read(ndev, mmio + ndev->self_reg->db_mask);
+       off += scnprintf(buf + off, buf_size - off,
+                        "Doorbell Mask -\t\t%#llx\n", u.v64);
+
+       u.v64 = ndev_db_read(ndev, mmio + ndev->self_reg->db_bell);
+       off += scnprintf(buf + off, buf_size - off,
+                        "Doorbell Bell -\t\t%#llx\n", u.v64);
+
+       off += scnprintf(buf + off, buf_size - off,
+                        "\nNTB Incoming XLAT:\n");
+
+       u.v64 = ioread64(mmio + GEN3_IMBAR1XBASE_OFFSET);
+       off += scnprintf(buf + off, buf_size - off,
+                        "IMBAR1XBASE -\t\t%#018llx\n", u.v64);
+
+       u.v64 = ioread64(mmio + GEN3_IMBAR2XBASE_OFFSET);
+       off += scnprintf(buf + off, buf_size - off,
+                        "IMBAR2XBASE -\t\t%#018llx\n", u.v64);
+
+       u.v64 = ioread64(mmio + GEN3_IMBAR1XLMT_OFFSET);
+       off += scnprintf(buf + off, buf_size - off,
+                        "IMBAR1XLMT -\t\t\t%#018llx\n", u.v64);
+
+       u.v64 = ioread64(mmio + GEN3_IMBAR2XLMT_OFFSET);
+       off += scnprintf(buf + off, buf_size - off,
+                        "IMBAR2XLMT -\t\t\t%#018llx\n", u.v64);
+
+       if (ntb_topo_is_b2b(ndev->ntb.topo)) {
+               off += scnprintf(buf + off, buf_size - off,
+                                "\nNTB Outgoing B2B XLAT:\n");
+
+               u.v64 = ioread64(mmio + GEN3_EMBAR1XBASE_OFFSET);
+               off += scnprintf(buf + off, buf_size - off,
+                                "EMBAR1XBASE -\t\t%#018llx\n", u.v64);
+
+               u.v64 = ioread64(mmio + GEN3_EMBAR2XBASE_OFFSET);
+               off += scnprintf(buf + off, buf_size - off,
+                                "EMBAR2XBASE -\t\t%#018llx\n", u.v64);
+
+               u.v64 = ioread64(mmio + GEN3_EMBAR1XLMT_OFFSET);
+               off += scnprintf(buf + off, buf_size - off,
+                                "EMBAR1XLMT -\t\t%#018llx\n", u.v64);
+
+               u.v64 = ioread64(mmio + GEN3_EMBAR2XLMT_OFFSET);
+               off += scnprintf(buf + off, buf_size - off,
+                                "EMBAR2XLMT -\t\t%#018llx\n", u.v64);
+
+               off += scnprintf(buf + off, buf_size - off,
+                                "\nNTB Secondary BAR:\n");
+
+               u.v64 = ioread64(mmio + GEN3_EMBAR0_OFFSET);
+               off += scnprintf(buf + off, buf_size - off,
+                                "EMBAR0 -\t\t%#018llx\n", u.v64);
+
+               u.v64 = ioread64(mmio + GEN3_EMBAR1_OFFSET);
+               off += scnprintf(buf + off, buf_size - off,
+                                "EMBAR1 -\t\t%#018llx\n", u.v64);
+
+               u.v64 = ioread64(mmio + GEN3_EMBAR2_OFFSET);
+               off += scnprintf(buf + off, buf_size - off,
+                                "EMBAR2 -\t\t%#018llx\n", u.v64);
+       }
+
+       off += scnprintf(buf + off, buf_size - off,
+                        "\nNTB Statistics:\n");
+
+       u.v16 = ioread16(mmio + GEN3_USMEMMISS_OFFSET);
+       off += scnprintf(buf + off, buf_size - off,
+                        "Upstream Memory Miss -\t%u\n", u.v16);
+
+       off += scnprintf(buf + off, buf_size - off,
+                        "\nNTB Hardware Errors:\n");
+
+       if (!pci_read_config_word(ndev->ntb.pdev,
+                                 GEN3_DEVSTS_OFFSET, &u.v16))
+               off += scnprintf(buf + off, buf_size - off,
+                                "DEVSTS -\t\t%#06x\n", u.v16);
+
+       if (!pci_read_config_word(ndev->ntb.pdev,
+                                 GEN3_LINK_STATUS_OFFSET, &u.v16))
+               off += scnprintf(buf + off, buf_size - off,
+                                "LNKSTS -\t\t%#06x\n", u.v16);
+
+       if (!pci_read_config_dword(ndev->ntb.pdev,
+                                  GEN3_UNCERRSTS_OFFSET, &u.v32))
+               off += scnprintf(buf + off, buf_size - off,
+                                "UNCERRSTS -\t\t%#06x\n", u.v32);
+
+       if (!pci_read_config_dword(ndev->ntb.pdev,
+                                  GEN3_CORERRSTS_OFFSET, &u.v32))
+               off += scnprintf(buf + off, buf_size - off,
+                                "CORERRSTS -\t\t%#06x\n", u.v32);
+
+       ret = simple_read_from_buffer(ubuf, count, offp, buf, off);
+       kfree(buf);
+       return ret;
+}
+
+static int intel_ntb3_link_enable(struct ntb_dev *ntb,
+                                 enum ntb_speed max_speed,
+                                 enum ntb_width max_width)
+{
+       struct intel_ntb_dev *ndev;
+       u32 ntb_ctl;
+
+       ndev = container_of(ntb, struct intel_ntb_dev, ntb);
+
+       dev_dbg(&ntb->pdev->dev,
+               "Enabling link with max_speed %d max_width %d\n",
+               max_speed, max_width);
+
+       if (max_speed != NTB_SPEED_AUTO)
+               dev_dbg(&ntb->pdev->dev, "ignoring max_speed %d\n", max_speed);
+       if (max_width != NTB_WIDTH_AUTO)
+               dev_dbg(&ntb->pdev->dev, "ignoring max_width %d\n", max_width);
+
+       ntb_ctl = ioread32(ndev->self_mmio + ndev->reg->ntb_ctl);
+       ntb_ctl &= ~(NTB_CTL_DISABLE | NTB_CTL_CFG_LOCK);
+       ntb_ctl |= NTB_CTL_P2S_BAR2_SNOOP | NTB_CTL_S2P_BAR2_SNOOP;
+       ntb_ctl |= NTB_CTL_P2S_BAR4_SNOOP | NTB_CTL_S2P_BAR4_SNOOP;
+       iowrite32(ntb_ctl, ndev->self_mmio + ndev->reg->ntb_ctl);
+
+       return 0;
+}
+static int intel_ntb3_mw_set_trans(struct ntb_dev *ntb, int pidx, int idx,
+                                  dma_addr_t addr, resource_size_t size)
+{
+       struct intel_ntb_dev *ndev = ntb_ndev(ntb);
+       unsigned long xlat_reg, limit_reg;
+       resource_size_t bar_size, mw_size;
+       void __iomem *mmio;
+       u64 base, limit, reg_val;
+       int bar;
+
+       if (pidx != NTB_DEF_PEER_IDX)
+               return -EINVAL;
+
+       if (idx >= ndev->b2b_idx && !ndev->b2b_off)
+               idx += 1;
+
+       bar = ndev_mw_to_bar(ndev, idx);
+       if (bar < 0)
+               return bar;
+
+       bar_size = pci_resource_len(ndev->ntb.pdev, bar);
+
+       if (idx == ndev->b2b_idx)
+               mw_size = bar_size - ndev->b2b_off;
+       else
+               mw_size = bar_size;
+
+       /* hardware requires that addr is aligned to bar size */
+       if (addr & (bar_size - 1))
+               return -EINVAL;
+
+       /* make sure the range fits in the usable mw size */
+       if (size > mw_size)
+               return -EINVAL;
+
+       mmio = ndev->self_mmio;
+       xlat_reg = ndev->xlat_reg->bar2_xlat + (idx * 0x10);
+       limit_reg = ndev->xlat_reg->bar2_limit + (idx * 0x10);
+       base = pci_resource_start(ndev->ntb.pdev, bar);
+
+       /* Set the limit if supported, if size is not mw_size */
+       if (limit_reg && size != mw_size)
+               limit = base + size;
+       else
+               limit = base + mw_size;
+
+       /* set and verify setting the translation address */
+       iowrite64(addr, mmio + xlat_reg);
+       reg_val = ioread64(mmio + xlat_reg);
+       if (reg_val != addr) {
+               iowrite64(0, mmio + xlat_reg);
+               return -EIO;
+       }
+
+       dev_dbg(&ntb->pdev->dev, "BAR %d IMBARXBASE: %#Lx\n", bar, reg_val);
+
+       /* set and verify setting the limit */
+       iowrite64(limit, mmio + limit_reg);
+       reg_val = ioread64(mmio + limit_reg);
+       if (reg_val != limit) {
+               iowrite64(base, mmio + limit_reg);
+               iowrite64(0, mmio + xlat_reg);
+               return -EIO;
+       }
+
+       dev_dbg(&ntb->pdev->dev, "BAR %d IMBARXLMT: %#Lx\n", bar, reg_val);
+
+       /* setup the EP */
+       limit_reg = ndev->xlat_reg->bar2_limit + (idx * 0x10) + 0x4000;
+       base = ioread64(mmio + GEN3_EMBAR1_OFFSET + (8 * idx));
+       base &= ~0xf;
+
+       if (limit_reg && size != mw_size)
+               limit = base + size;
+       else
+               limit = base + mw_size;
+
+       /* set and verify setting the limit */
+       iowrite64(limit, mmio + limit_reg);
+       reg_val = ioread64(mmio + limit_reg);
+       if (reg_val != limit) {
+               iowrite64(base, mmio + limit_reg);
+               iowrite64(0, mmio + xlat_reg);
+               return -EIO;
+       }
+
+       dev_dbg(&ntb->pdev->dev, "BAR %d EMBARXLMT: %#Lx\n", bar, reg_val);
+
+       return 0;
+}
+
+static int intel_ntb3_peer_db_set(struct ntb_dev *ntb, u64 db_bits)
+{
+       struct intel_ntb_dev *ndev = ntb_ndev(ntb);
+       int bit;
+
+       if (db_bits & ~ndev->db_valid_mask)
+               return -EINVAL;
+
+       while (db_bits) {
+               bit = __ffs(db_bits);
+               iowrite32(1, ndev->peer_mmio +
+                               ndev->peer_reg->db_bell + (bit * 4));
+               db_bits &= db_bits - 1;
+       }
+
+       return 0;
+}
+
+static u64 intel_ntb3_db_read(struct ntb_dev *ntb)
+{
+       struct intel_ntb_dev *ndev = ntb_ndev(ntb);
+
+       return ndev_db_read(ndev,
+                           ndev->self_mmio +
+                           ndev->self_reg->db_clear);
+}
+
+static int intel_ntb3_db_clear(struct ntb_dev *ntb, u64 db_bits)
+{
+       struct intel_ntb_dev *ndev = ntb_ndev(ntb);
+
+       return ndev_db_write(ndev, db_bits,
+                            ndev->self_mmio +
+                            ndev->self_reg->db_clear);
+}
+
+const struct ntb_dev_ops intel_ntb3_ops = {
+       .mw_count               = intel_ntb_mw_count,
+       .mw_get_align           = intel_ntb_mw_get_align,
+       .mw_set_trans           = intel_ntb3_mw_set_trans,
+       .peer_mw_count          = intel_ntb_peer_mw_count,
+       .peer_mw_get_addr       = intel_ntb_peer_mw_get_addr,
+       .link_is_up             = intel_ntb_link_is_up,
+       .link_enable            = intel_ntb3_link_enable,
+       .link_disable           = intel_ntb_link_disable,
+       .db_valid_mask          = intel_ntb_db_valid_mask,
+       .db_vector_count        = intel_ntb_db_vector_count,
+       .db_vector_mask         = intel_ntb_db_vector_mask,
+       .db_read                = intel_ntb3_db_read,
+       .db_clear               = intel_ntb3_db_clear,
+       .db_set_mask            = intel_ntb_db_set_mask,
+       .db_clear_mask          = intel_ntb_db_clear_mask,
+       .peer_db_addr           = intel_ntb_peer_db_addr,
+       .peer_db_set            = intel_ntb3_peer_db_set,
+       .spad_is_unsafe         = intel_ntb_spad_is_unsafe,
+       .spad_count             = intel_ntb_spad_count,
+       .spad_read              = intel_ntb_spad_read,
+       .spad_write             = intel_ntb_spad_write,
+       .peer_spad_addr         = intel_ntb_peer_spad_addr,
+       .peer_spad_read         = intel_ntb_peer_spad_read,
+       .peer_spad_write        = intel_ntb_peer_spad_write,
+};
+
diff --git a/drivers/ntb/hw/intel/ntb_hw_gen3.h b/drivers/ntb/hw/intel/ntb_hw_gen3.h
new file mode 100644 (file)
index 0000000..75fb86c
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * This file is provided under a dual BSD/GPLv2 license.  When using or
+ *   redistributing this file, you may do so under either license.
+ *
+ *   GPL LICENSE SUMMARY
+ *
+ *   Copyright(c) 2012-2017 Intel Corporation. All rights reserved.
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of version 2 of the GNU General Public License as
+ *   published by the Free Software Foundation.
+ *
+ *   BSD LICENSE
+ *
+ *   Copyright(c) 2012-2017 Intel Corporation. All rights reserved.
+ *
+ *   Redistribution and use in source and binary forms, with or without
+ *   modification, are permitted provided that the following conditions
+ *   are met:
+ *
+ *     * Redistributions of source code must retain the above copyright
+ *       notice, this list of conditions and the following disclaimer.
+ *     * Redistributions in binary form must reproduce the above copy
+ *       notice, this list of conditions and the following disclaimer in
+ *       the documentation and/or other materials provided with the
+ *       distribution.
+ *     * Neither the name of Intel Corporation nor the names of its
+ *       contributors may 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.
+ */
+
+#ifndef _NTB_INTEL_GEN3_H_
+#define _NTB_INTEL_GEN3_H_
+
+#include "ntb_hw_intel.h"
+
+/* Intel Skylake Xeon hardware */
+#define GEN3_IMBAR1SZ_OFFSET           0x00d0
+#define GEN3_IMBAR2SZ_OFFSET           0x00d1
+#define GEN3_EMBAR1SZ_OFFSET           0x00d2
+#define GEN3_EMBAR2SZ_OFFSET           0x00d3
+#define GEN3_DEVCTRL_OFFSET            0x0098
+#define GEN3_DEVSTS_OFFSET             0x009a
+#define GEN3_UNCERRSTS_OFFSET          0x014c
+#define GEN3_CORERRSTS_OFFSET          0x0158
+#define GEN3_LINK_STATUS_OFFSET                0x01a2
+
+#define GEN3_NTBCNTL_OFFSET            0x0000
+#define GEN3_IMBAR1XBASE_OFFSET                0x0010          /* SBAR2XLAT */
+#define GEN3_IMBAR1XLMT_OFFSET         0x0018          /* SBAR2LMT */
+#define GEN3_IMBAR2XBASE_OFFSET                0x0020          /* SBAR4XLAT */
+#define GEN3_IMBAR2XLMT_OFFSET         0x0028          /* SBAR4LMT */
+#define GEN3_IM_INT_STATUS_OFFSET      0x0040
+#define GEN3_IM_INT_DISABLE_OFFSET     0x0048
+#define GEN3_IM_SPAD_OFFSET            0x0080          /* SPAD */
+#define GEN3_USMEMMISS_OFFSET          0x0070
+#define GEN3_INTVEC_OFFSET             0x00d0
+#define GEN3_IM_DOORBELL_OFFSET                0x0100          /* SDOORBELL0 */
+#define GEN3_B2B_SPAD_OFFSET           0x0180          /* B2B SPAD */
+#define GEN3_EMBAR0XBASE_OFFSET                0x4008          /* B2B_XLAT */
+#define GEN3_EMBAR1XBASE_OFFSET                0x4010          /* PBAR2XLAT */
+#define GEN3_EMBAR1XLMT_OFFSET         0x4018          /* PBAR2LMT */
+#define GEN3_EMBAR2XBASE_OFFSET                0x4020          /* PBAR4XLAT */
+#define GEN3_EMBAR2XLMT_OFFSET         0x4028          /* PBAR4LMT */
+#define GEN3_EM_INT_STATUS_OFFSET      0x4040
+#define GEN3_EM_INT_DISABLE_OFFSET     0x4048
+#define GEN3_EM_SPAD_OFFSET            0x4080          /* remote SPAD */
+#define GEN3_EM_DOORBELL_OFFSET                0x4100          /* PDOORBELL0 */
+#define GEN3_SPCICMD_OFFSET            0x4504          /* SPCICMD */
+#define GEN3_EMBAR0_OFFSET             0x4510          /* SBAR0BASE */
+#define GEN3_EMBAR1_OFFSET             0x4518          /* SBAR23BASE */
+#define GEN3_EMBAR2_OFFSET             0x4520          /* SBAR45BASE */
+
+#define GEN3_DB_COUNT                  32
+#define GEN3_DB_LINK                   32
+#define GEN3_DB_LINK_BIT               BIT_ULL(GEN3_DB_LINK)
+#define GEN3_DB_MSIX_VECTOR_COUNT      33
+#define GEN3_DB_MSIX_VECTOR_SHIFT      1
+#define GEN3_DB_TOTAL_SHIFT            33
+#define GEN3_SPAD_COUNT                        16
+
+static inline u64 gen3_db_ioread(void __iomem *mmio)
+{
+       return ioread64(mmio);
+}
+
+static inline void gen3_db_iowrite(u64 bits, void __iomem *mmio)
+{
+       iowrite64(bits, mmio);
+}
+
+ssize_t ndev_ntb3_debugfs_read(struct file *filp, char __user *ubuf,
+                                     size_t count, loff_t *offp);
+int gen3_init_dev(struct intel_ntb_dev *ndev);
+
+extern const struct ntb_dev_ops intel_ntb3_ops;
+
+#endif
index 4415aa7ea775ea6feb00593d6ae6d882519b5272..c49ff8970ce3dec1e7d87af3cd1c70a33292898c 100644 (file)
@@ -54,6 +54,7 @@
 #include <linux/ntb.h>
 #include <linux/pci.h>
 
+/* PCI device IDs */
 #define PCI_DEVICE_ID_INTEL_NTB_B2B_JSF        0x3725
 #define PCI_DEVICE_ID_INTEL_NTB_PS_JSF 0x3726
 #define PCI_DEVICE_ID_INTEL_NTB_SS_JSF 0x3727
 #define PCI_DEVICE_ID_INTEL_NTB_SS_BDX 0x6F0F
 #define PCI_DEVICE_ID_INTEL_NTB_B2B_SKX        0x201C
 
-/* Intel Xeon hardware */
-
-#define XEON_PBAR23LMT_OFFSET          0x0000
-#define XEON_PBAR45LMT_OFFSET          0x0008
-#define XEON_PBAR4LMT_OFFSET           0x0008
-#define XEON_PBAR5LMT_OFFSET           0x000c
-#define XEON_PBAR23XLAT_OFFSET         0x0010
-#define XEON_PBAR45XLAT_OFFSET         0x0018
-#define XEON_PBAR4XLAT_OFFSET          0x0018
-#define XEON_PBAR5XLAT_OFFSET          0x001c
-#define XEON_SBAR23LMT_OFFSET          0x0020
-#define XEON_SBAR45LMT_OFFSET          0x0028
-#define XEON_SBAR4LMT_OFFSET           0x0028
-#define XEON_SBAR5LMT_OFFSET           0x002c
-#define XEON_SBAR23XLAT_OFFSET         0x0030
-#define XEON_SBAR45XLAT_OFFSET         0x0038
-#define XEON_SBAR4XLAT_OFFSET          0x0038
-#define XEON_SBAR5XLAT_OFFSET          0x003c
-#define XEON_SBAR0BASE_OFFSET          0x0040
-#define XEON_SBAR23BASE_OFFSET         0x0048
-#define XEON_SBAR45BASE_OFFSET         0x0050
-#define XEON_SBAR4BASE_OFFSET          0x0050
-#define XEON_SBAR5BASE_OFFSET          0x0054
-#define XEON_SBDF_OFFSET               0x005c
-#define XEON_NTBCNTL_OFFSET            0x0058
-#define XEON_PDOORBELL_OFFSET          0x0060
-#define XEON_PDBMSK_OFFSET             0x0062
-#define XEON_SDOORBELL_OFFSET          0x0064
-#define XEON_SDBMSK_OFFSET             0x0066
-#define XEON_USMEMMISS_OFFSET          0x0070
-#define XEON_SPAD_OFFSET               0x0080
-#define XEON_PBAR23SZ_OFFSET           0x00d0
-#define XEON_PBAR45SZ_OFFSET           0x00d1
-#define XEON_PBAR4SZ_OFFSET            0x00d1
-#define XEON_SBAR23SZ_OFFSET           0x00d2
-#define XEON_SBAR45SZ_OFFSET           0x00d3
-#define XEON_SBAR4SZ_OFFSET            0x00d3
-#define XEON_PPD_OFFSET                        0x00d4
-#define XEON_PBAR5SZ_OFFSET            0x00d5
-#define XEON_SBAR5SZ_OFFSET            0x00d6
-#define XEON_WCCNTRL_OFFSET            0x00e0
-#define XEON_UNCERRSTS_OFFSET          0x014c
-#define XEON_CORERRSTS_OFFSET          0x0158
-#define XEON_LINK_STATUS_OFFSET                0x01a2
-#define XEON_SPCICMD_OFFSET            0x0504
-#define XEON_DEVCTRL_OFFSET            0x0598
-#define XEON_DEVSTS_OFFSET             0x059a
-#define XEON_SLINK_STATUS_OFFSET       0x05a2
-#define XEON_B2B_SPAD_OFFSET           0x0100
-#define XEON_B2B_DOORBELL_OFFSET       0x0140
-#define XEON_B2B_XLAT_OFFSETL          0x0144
-#define XEON_B2B_XLAT_OFFSETU          0x0148
-#define XEON_PPD_CONN_MASK             0x03
-#define XEON_PPD_CONN_TRANSPARENT      0x00
-#define XEON_PPD_CONN_B2B              0x01
-#define XEON_PPD_CONN_RP               0x02
-#define XEON_PPD_DEV_MASK              0x10
-#define XEON_PPD_DEV_USD               0x00
-#define XEON_PPD_DEV_DSD               0x10
-#define XEON_PPD_SPLIT_BAR_MASK                0x40
-
-#define XEON_PPD_TOPO_MASK     (XEON_PPD_CONN_MASK | XEON_PPD_DEV_MASK)
-#define XEON_PPD_TOPO_PRI_USD  (XEON_PPD_CONN_RP | XEON_PPD_DEV_USD)
-#define XEON_PPD_TOPO_PRI_DSD  (XEON_PPD_CONN_RP | XEON_PPD_DEV_DSD)
-#define XEON_PPD_TOPO_SEC_USD  (XEON_PPD_CONN_TRANSPARENT | XEON_PPD_DEV_USD)
-#define XEON_PPD_TOPO_SEC_DSD  (XEON_PPD_CONN_TRANSPARENT | XEON_PPD_DEV_DSD)
-#define XEON_PPD_TOPO_B2B_USD  (XEON_PPD_CONN_B2B | XEON_PPD_DEV_USD)
-#define XEON_PPD_TOPO_B2B_DSD  (XEON_PPD_CONN_B2B | XEON_PPD_DEV_DSD)
-
-#define XEON_MW_COUNT                  2
-#define HSX_SPLIT_BAR_MW_COUNT         3
-#define XEON_DB_COUNT                  15
-#define XEON_DB_LINK                   15
-#define XEON_DB_LINK_BIT                       BIT_ULL(XEON_DB_LINK)
-#define XEON_DB_MSIX_VECTOR_COUNT      4
-#define XEON_DB_MSIX_VECTOR_SHIFT      5
-#define XEON_DB_TOTAL_SHIFT            16
-#define XEON_SPAD_COUNT                        16
-
-/* Intel Skylake Xeon hardware */
-#define SKX_IMBAR1SZ_OFFSET            0x00d0
-#define SKX_IMBAR2SZ_OFFSET            0x00d1
-#define SKX_EMBAR1SZ_OFFSET            0x00d2
-#define SKX_EMBAR2SZ_OFFSET            0x00d3
-#define SKX_DEVCTRL_OFFSET             0x0098
-#define SKX_DEVSTS_OFFSET              0x009a
-#define SKX_UNCERRSTS_OFFSET           0x014c
-#define SKX_CORERRSTS_OFFSET           0x0158
-#define SKX_LINK_STATUS_OFFSET         0x01a2
-
-#define SKX_NTBCNTL_OFFSET             0x0000
-#define SKX_IMBAR1XBASE_OFFSET         0x0010          /* SBAR2XLAT */
-#define SKX_IMBAR1XLMT_OFFSET          0x0018          /* SBAR2LMT */
-#define SKX_IMBAR2XBASE_OFFSET         0x0020          /* SBAR4XLAT */
-#define SKX_IMBAR2XLMT_OFFSET          0x0028          /* SBAR4LMT */
-#define SKX_IM_INT_STATUS_OFFSET       0x0040
-#define SKX_IM_INT_DISABLE_OFFSET      0x0048
-#define SKX_IM_SPAD_OFFSET             0x0080          /* SPAD */
-#define SKX_USMEMMISS_OFFSET           0x0070
-#define SKX_INTVEC_OFFSET              0x00d0
-#define SKX_IM_DOORBELL_OFFSET         0x0100          /* SDOORBELL0 */
-#define SKX_B2B_SPAD_OFFSET            0x0180          /* B2B SPAD */
-#define SKX_EMBAR0XBASE_OFFSET         0x4008          /* B2B_XLAT */
-#define SKX_EMBAR1XBASE_OFFSET         0x4010          /* PBAR2XLAT */
-#define SKX_EMBAR1XLMT_OFFSET          0x4018          /* PBAR2LMT */
-#define SKX_EMBAR2XBASE_OFFSET         0x4020          /* PBAR4XLAT */
-#define SKX_EMBAR2XLMT_OFFSET          0x4028          /* PBAR4LMT */
-#define SKX_EM_INT_STATUS_OFFSET       0x4040
-#define SKX_EM_INT_DISABLE_OFFSET      0x4048
-#define SKX_EM_SPAD_OFFSET             0x4080          /* remote SPAD */
-#define SKX_EM_DOORBELL_OFFSET         0x4100          /* PDOORBELL0 */
-#define SKX_SPCICMD_OFFSET             0x4504          /* SPCICMD */
-#define SKX_EMBAR0_OFFSET              0x4510          /* SBAR0BASE */
-#define SKX_EMBAR1_OFFSET              0x4518          /* SBAR23BASE */
-#define SKX_EMBAR2_OFFSET              0x4520          /* SBAR45BASE */
-
-#define SKX_DB_COUNT                   32
-#define SKX_DB_LINK                    32
-#define SKX_DB_LINK_BIT                        BIT_ULL(SKX_DB_LINK)
-#define SKX_DB_MSIX_VECTOR_COUNT       33
-#define SKX_DB_MSIX_VECTOR_SHIFT       1
-#define SKX_DB_TOTAL_SHIFT             33
-#define SKX_SPAD_COUNT                 16
-
 /* Ntb control and link status */
-
 #define NTB_CTL_CFG_LOCK               BIT(0)
 #define NTB_CTL_DISABLE                        BIT(1)
 #define NTB_CTL_S2P_BAR2_SNOOP         BIT(2)
 #define NTB_LNK_STA_SPEED(x)           ((x) & NTB_LNK_STA_SPEED_MASK)
 #define NTB_LNK_STA_WIDTH(x)           (((x) & NTB_LNK_STA_WIDTH_MASK) >> 4)
 
-/* Use the following addresses for translation between b2b ntb devices in case
- * the hardware default values are not reliable. */
-#define XEON_B2B_BAR0_ADDR     0x1000000000000000ull
-#define XEON_B2B_BAR2_ADDR64   0x2000000000000000ull
-#define XEON_B2B_BAR4_ADDR64   0x4000000000000000ull
-#define XEON_B2B_BAR4_ADDR32   0x20000000u
-#define XEON_B2B_BAR5_ADDR32   0x40000000u
-
-/* The peer ntb secondary config space is 32KB fixed size */
-#define XEON_B2B_MIN_SIZE              0x8000
-
-/* flags to indicate hardware errata */
-#define NTB_HWERR_SDOORBELL_LOCKUP     BIT_ULL(0)
-#define NTB_HWERR_SB01BASE_LOCKUP      BIT_ULL(1)
-#define NTB_HWERR_B2BDOORBELL_BIT14    BIT_ULL(2)
-#define NTB_HWERR_MSIX_VECTOR32_BAD    BIT_ULL(3)
-
 /* flags to indicate unsafe api */
 #define NTB_UNSAFE_DB                  BIT_ULL(0)
 #define NTB_UNSAFE_SPAD                        BIT_ULL(1)
@@ -328,4 +187,64 @@ struct intel_ntb_dev {
 #define hb_ndev(__work) container_of(__work, struct intel_ntb_dev, \
                                     hb_timer.work)
 
+static inline int pdev_is_gen1(struct pci_dev *pdev)
+{
+       switch (pdev->device) {
+       case PCI_DEVICE_ID_INTEL_NTB_SS_JSF:
+       case PCI_DEVICE_ID_INTEL_NTB_SS_SNB:
+       case PCI_DEVICE_ID_INTEL_NTB_SS_IVT:
+       case PCI_DEVICE_ID_INTEL_NTB_SS_HSX:
+       case PCI_DEVICE_ID_INTEL_NTB_SS_BDX:
+       case PCI_DEVICE_ID_INTEL_NTB_PS_JSF:
+       case PCI_DEVICE_ID_INTEL_NTB_PS_SNB:
+       case PCI_DEVICE_ID_INTEL_NTB_PS_IVT:
+       case PCI_DEVICE_ID_INTEL_NTB_PS_HSX:
+       case PCI_DEVICE_ID_INTEL_NTB_PS_BDX:
+       case PCI_DEVICE_ID_INTEL_NTB_B2B_JSF:
+       case PCI_DEVICE_ID_INTEL_NTB_B2B_SNB:
+       case PCI_DEVICE_ID_INTEL_NTB_B2B_IVT:
+       case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX:
+       case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX:
+               return 1;
+       }
+       return 0;
+}
+
+static inline int pdev_is_gen3(struct pci_dev *pdev)
+{
+       if (pdev->device == PCI_DEVICE_ID_INTEL_NTB_B2B_SKX)
+               return 1;
+
+       return 0;
+}
+
+#ifndef ioread64
+#ifdef readq
+#define ioread64 readq
+#else
+#define ioread64 _ioread64
+static inline u64 _ioread64(void __iomem *mmio)
+{
+       u64 low, high;
+
+       low = ioread32(mmio);
+       high = ioread32(mmio + sizeof(u32));
+       return low | (high << 32);
+}
+#endif
+#endif
+
+#ifndef iowrite64
+#ifdef writeq
+#define iowrite64 writeq
+#else
+#define iowrite64 _iowrite64
+static inline void _iowrite64(u64 val, void __iomem *mmio)
+{
+       iowrite32(val, mmio);
+       iowrite32(val >> 32, mmio + sizeof(u32));
+}
+#endif
+#endif
+
 #endif
index 9878c48826e3ee5889b6b1b38024db580a3b848a..9398959664769b5f6cd3c79e4914199d1cf35f0d 100644 (file)
@@ -637,7 +637,7 @@ static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,
         */
        node = dev_to_node(&ndev->dev);
        for (i = qp->rx_alloc_entry; i < qp->rx_max_entry; i++) {
-               entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node);
+               entry = kzalloc_node(sizeof(*entry), GFP_KERNEL, node);
                if (!entry)
                        return -ENOMEM;
 
@@ -1102,7 +1102,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
        max_mw_count_for_spads = (spad_count - MW0_SZ_HIGH) / 2;
        nt->mw_count = min(mw_count, max_mw_count_for_spads);
 
-       nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec),
+       nt->mw_vec = kcalloc_node(mw_count, sizeof(*nt->mw_vec),
                                  GFP_KERNEL, node);
        if (!nt->mw_vec) {
                rc = -ENOMEM;
@@ -1143,7 +1143,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev)
        nt->qp_bitmap = qp_bitmap;
        nt->qp_bitmap_free = qp_bitmap;
 
-       nt->qp_vec = kzalloc_node(qp_count * sizeof(*nt->qp_vec),
+       nt->qp_vec = kcalloc_node(qp_count, sizeof(*nt->qp_vec),
                                  GFP_KERNEL, node);
        if (!nt->qp_vec) {
                rc = -ENOMEM;
@@ -1828,7 +1828,7 @@ ntb_transport_create_queue(void *data, struct device *client_dev,
                qp->rx_dma_chan ? "DMA" : "CPU");
 
        for (i = 0; i < NTB_QP_DEF_NUM_ENTRIES; i++) {
-               entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node);
+               entry = kzalloc_node(sizeof(*entry), GFP_KERNEL, node);
                if (!entry)
                        goto err1;
 
@@ -1839,7 +1839,7 @@ ntb_transport_create_queue(void *data, struct device *client_dev,
        qp->rx_alloc_entry = NTB_QP_DEF_NUM_ENTRIES;
 
        for (i = 0; i < qp->tx_max_entry; i++) {
-               entry = kzalloc_node(sizeof(*entry), GFP_ATOMIC, node);
+               entry = kzalloc_node(sizeof(*entry), GFP_KERNEL, node);
                if (!entry)
                        goto err2;
 
index b3b0b648be62b929e99d2554aaaef1eeab0b4bf5..146de9489339b9534780b3abf84f0315c6f4671c 100644 (file)
@@ -122,7 +122,8 @@ static int rockchip_rk3328_efuse_read(void *context, unsigned int offset,
        addr_offset = offset % RK3399_NBYTES;
        addr_len = addr_end - addr_start;
 
-       buf = kzalloc(sizeof(*buf) * addr_len * RK3399_NBYTES, GFP_KERNEL);
+       buf = kzalloc(array3_size(addr_len, RK3399_NBYTES, sizeof(*buf)),
+                     GFP_KERNEL);
        if (!buf) {
                ret = -ENOMEM;
                goto nomem;
@@ -174,7 +175,8 @@ static int rockchip_rk3399_efuse_read(void *context, unsigned int offset,
        addr_offset = offset % RK3399_NBYTES;
        addr_len = addr_end - addr_start;
 
-       buf = kzalloc(sizeof(*buf) * addr_len * RK3399_NBYTES, GFP_KERNEL);
+       buf = kzalloc(array3_size(addr_len, RK3399_NBYTES, sizeof(*buf)),
+                     GFP_KERNEL);
        if (!buf) {
                clk_disable_unprepare(efuse->clk);
                return -ENOMEM;
index 26bb637afe924b314a25ec1a2ca6f5e669a14f24..d020f89248fd76a7baca320bb6a4238a71d785c0 100644 (file)
@@ -185,7 +185,7 @@ static int sunxi_sid_probe(struct platform_device *pdev)
        if (IS_ERR(nvmem))
                return PTR_ERR(nvmem);
 
-       randomness = kzalloc(sizeof(u8) * (size), GFP_KERNEL);
+       randomness = kzalloc(size, GFP_KERNEL);
        if (!randomness) {
                ret = -EINVAL;
                goto err_unreg_nvmem;
index 0b49a62b38a3800aff88b76307a294d093876dd4..6925d993e1f0f41b4894303fe77b3cf29729f595 100644 (file)
@@ -129,7 +129,7 @@ struct platform_device *of_device_alloc(struct device_node *np,
 
        /* Populate the resource table */
        if (num_irq || num_reg) {
-               res = kzalloc(sizeof(*res) * (num_irq + num_reg), GFP_KERNEL);
+               res = kcalloc(num_irq + num_reg, sizeof(*res), GFP_KERNEL);
                if (!res) {
                        platform_device_put(dev);
                        return NULL;
@@ -505,6 +505,7 @@ EXPORT_SYMBOL_GPL(of_platform_default_populate);
 #ifndef CONFIG_PPC
 static const struct of_device_id reserved_mem_matches[] = {
        { .compatible = "qcom,rmtfs-mem" },
+       { .compatible = "qcom,cmd-db" },
        { .compatible = "ramoops" },
        {}
 };
index ecee50d10d149a7894d8feb274b95ea46fa7fb22..722537e14848436bfb58bc1c32fabd5c786166ba 100644 (file)
@@ -156,7 +156,7 @@ static void __init of_unittest_dynamic(void)
        }
 
        /* Array of 4 properties for the purpose of testing */
-       prop = kzalloc(sizeof(*prop) * 4, GFP_KERNEL);
+       prop = kcalloc(4, sizeof(*prop), GFP_KERNEL);
        if (!prop) {
                unittest(0, "kzalloc() failed\n");
                return;
index 370eff3acd8ae64a6ddd8c40f48d495188ae778b..9e5a9a3112c9cec57abcffab6c9b23640682756c 100644 (file)
@@ -122,8 +122,8 @@ static int _store_optimized_voltages(struct device *dev,
                goto out;
        }
 
-       table = kzalloc(sizeof(*data->vdd_table) *
-                                 data->num_vdd_table, GFP_KERNEL);
+       table = kcalloc(data->num_vdd_table, sizeof(*data->vdd_table),
+                       GFP_KERNEL);
        if (!table) {
                ret = -ENOMEM;
                goto out;
index 32888f2bd1a977a2db21bb19beed519241280f17..12ea4a4ad60779afc551aecfffd8c2886a5688cf 100644 (file)
@@ -91,7 +91,7 @@ int alloc_event_buffer(void)
                return -EINVAL;
 
        buffer_pos = 0;
-       event_buffer = vmalloc(sizeof(unsigned long) * buffer_size);
+       event_buffer = vmalloc(array_size(buffer_size, sizeof(unsigned long)));
        if (!event_buffer)
                return -ENOMEM;
 
index 44333bd8f90886260e2219acad391dadaa9fd095..a97f4eada60b317e38a8cd1e0c780851a825986e 100644 (file)
@@ -20,7 +20,7 @@ menuconfig PARPORT
          drive, PLIP link (Parallel Line Internet Protocol is mainly used to
          create a mini network by connecting the parallel ports of two local
          machines) etc., then you need to say Y here; please read
-         <file:Documentation/parport.txt> and
+         <file:Documentation/admin-guide/parport.rst> and
          <file:drivers/parport/BUGS-parport>.
 
          For extensive information about drivers for many devices attaching
@@ -33,7 +33,7 @@ menuconfig PARPORT
          the module will be called parport.
          If you have more than one parallel port and want to specify which
          port and IRQ to be used by this driver at module load time, take a
-         look at <file:Documentation/parport.txt>.
+         look at <file:Documentation/admin-guide/parport.rst>.
 
          If unsure, say Y.
 
@@ -71,7 +71,7 @@ config PARPORT_PC_FIFO
          As well as actually having a FIFO, or DMA capability, the kernel
          will need to know which IRQ the parallel port has.  By default,
          parallel port interrupts will not be used, and so neither will the
-         FIFO.  See <file:Documentation/parport.txt> to find out how to
+         FIFO.  See <file:Documentation/admin-guide/parport.rst> to find out how to
          specify which IRQ/DMA to use.
 
 config PARPORT_PC_SUPERIO
index b2f07635e94d4970b15b28f75d3e5afe3e5697f1..56ff8f6d31fc503598954811e495ac44dcefe597 100644 (file)
@@ -145,8 +145,6 @@ config PCI_HYPERV
           PCI devices from a PCI backend to support PCI driver domains.
 
 source "drivers/pci/hotplug/Kconfig"
-source "drivers/pci/cadence/Kconfig"
-source "drivers/pci/dwc/Kconfig"
-source "drivers/pci/host/Kconfig"
+source "drivers/pci/controller/Kconfig"
 source "drivers/pci/endpoint/Kconfig"
 source "drivers/pci/switch/Kconfig"
index 84c9eef6b1c3ea353c631ec19d29442173d34325..535201984b8b0c5c0c58d585528b7593bbcf61be 100644 (file)
@@ -28,14 +28,10 @@ obj-$(CONFIG_PCI_PF_STUB)   += pci-pf-stub.o
 obj-$(CONFIG_PCI_ECAM)         += ecam.o
 obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o
 
-obj-y                          += host/
+obj-y                          += controller/
 obj-y                          += switch/
 
 # Endpoint library must be initialized before its users
 obj-$(CONFIG_PCI_ENDPOINT)     += endpoint/
 
-obj-$(CONFIG_PCIE_CADENCE)     += cadence/
-# pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
-obj-y                          += dwc/
-
 ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG
diff --git a/drivers/pci/cadence/Kconfig b/drivers/pci/cadence/Kconfig
deleted file mode 100644 (file)
index e6824cb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-menu "Cadence PCIe controllers support"
-
-config PCIE_CADENCE
-       bool
-
-config PCIE_CADENCE_HOST
-       bool "Cadence PCIe host controller"
-       depends on OF
-       depends on PCI
-       select IRQ_DOMAIN
-       select PCIE_CADENCE
-       help
-         Say Y here if you want to support the Cadence PCIe controller in host
-         mode. This PCIe controller may be embedded into many different vendors
-         SoCs.
-
-config PCIE_CADENCE_EP
-       bool "Cadence PCIe endpoint controller"
-       depends on OF
-       depends on PCI_ENDPOINT
-       select PCIE_CADENCE
-       help
-         Say Y here if you want to support the Cadence PCIe  controller in
-         endpoint mode. This PCIe controller may be embedded into many
-         different vendors SoCs.
-
-endmenu
diff --git a/drivers/pci/cadence/Makefile b/drivers/pci/cadence/Makefile
deleted file mode 100644 (file)
index 719392b..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence.o
-obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o
-obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep.o
similarity index 90%
rename from drivers/pci/host/Kconfig
rename to drivers/pci/controller/Kconfig
index a96e23bda6640f4b4904487d51445a2c86b060c8..18fa09b3ac8f2c377ccd8e9ba890f01d66b3c367 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 
-menu "PCI host controller drivers"
+menu "PCI controller drivers"
        depends on PCI
 
 config PCI_MVEBU
@@ -20,6 +20,34 @@ config PCI_AARDVARK
         controller is part of the South Bridge of the Marvel Armada
         3700 SoC.
 
+menu "Cadence PCIe controllers support"
+
+config PCIE_CADENCE
+       bool
+
+config PCIE_CADENCE_HOST
+       bool "Cadence PCIe host controller"
+       depends on OF
+       depends on PCI
+       select IRQ_DOMAIN
+       select PCIE_CADENCE
+       help
+         Say Y here if you want to support the Cadence PCIe controller in host
+         mode. This PCIe controller may be embedded into many different vendors
+         SoCs.
+
+config PCIE_CADENCE_EP
+       bool "Cadence PCIe endpoint controller"
+       depends on OF
+       depends on PCI_ENDPOINT
+       select PCIE_CADENCE
+       help
+         Say Y here if you want to support the Cadence PCIe  controller in
+         endpoint mode. This PCIe controller may be embedded into many
+         different vendors SoCs.
+
+endmenu
+
 config PCIE_XILINX_NWL
        bool "NWL PCIe Core"
        depends on ARCH_ZYNQMP || COMPILE_TEST
@@ -243,4 +271,5 @@ config VMD
          To compile this driver as a module, choose M here: the
          module will be called vmd.
 
+source "drivers/pci/controller/dwc/Kconfig"
 endmenu
similarity index 89%
rename from drivers/pci/host/Makefile
rename to drivers/pci/controller/Makefile
index 11d21b026d373335a1315a83dd9d4f0a6da6a149..24322b92f20029263c40c719f5249443958dda8d 100644 (file)
@@ -1,4 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence.o
+obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o
+obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep.o
 obj-$(CONFIG_PCI_FTPCI100) += pci-ftpci100.o
 obj-$(CONFIG_PCI_HYPERV) += pci-hyperv.o
 obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o
@@ -25,6 +28,9 @@ obj-$(CONFIG_PCIE_ROCKCHIP_HOST) += pcie-rockchip-host.o
 obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o
 obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o
 obj-$(CONFIG_VMD) += vmd.o
+# pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
+obj-y                          += dwc/
+
 
 # The following drivers are for devices that use the generic ACPI
 # pci_root.c driver but don't support standard ECAM config access.
similarity index 99%
rename from drivers/pci/dwc/pci-dra7xx.c
rename to drivers/pci/controller/dwc/pci-dra7xx.c
index f688204e50c5f5e7862e75b9e264a650856eb483..345aab56ce8bb1c7434a00c0d81d14ce74fbebc4 100644 (file)
@@ -27,7 +27,7 @@
 #include <linux/mfd/syscon.h>
 #include <linux/regmap.h>
 
-#include "../pci.h"
+#include "../../pci.h"
 #include "pcie-designware.h"
 
 /* PCIe controller wrapper DRA7XX configuration registers */
@@ -639,11 +639,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
                return phy_count;
        }
 
-       phy = devm_kzalloc(dev, sizeof(*phy) * phy_count, GFP_KERNEL);
+       phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL);
        if (!phy)
                return -ENOMEM;
 
-       link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL);
+       link = devm_kcalloc(dev, phy_count, sizeof(*link), GFP_KERNEL);
        if (!link)
                return -ENOMEM;
 
similarity index 98%
rename from drivers/pci/dwc/pcie-designware-ep.c
rename to drivers/pci/controller/dwc/pcie-designware-ep.c
index 1eec4415a77f05fe1ebfd7593815fee553d85ae6..8650416f6f9e46df6c722be7ae780da0916218d5 100644 (file)
@@ -366,19 +366,21 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)
                return -EINVAL;
        }
 
-       ep->ib_window_map = devm_kzalloc(dev, sizeof(long) *
+       ep->ib_window_map = devm_kcalloc(dev,
                                         BITS_TO_LONGS(ep->num_ib_windows),
+                                        sizeof(long),
                                         GFP_KERNEL);
        if (!ep->ib_window_map)
                return -ENOMEM;
 
-       ep->ob_window_map = devm_kzalloc(dev, sizeof(long) *
+       ep->ob_window_map = devm_kcalloc(dev,
                                         BITS_TO_LONGS(ep->num_ob_windows),
+                                        sizeof(long),
                                         GFP_KERNEL);
        if (!ep->ob_window_map)
                return -ENOMEM;
 
-       addr = devm_kzalloc(dev, sizeof(phys_addr_t) * ep->num_ob_windows,
+       addr = devm_kcalloc(dev, ep->num_ob_windows, sizeof(phys_addr_t),
                            GFP_KERNEL);
        if (!addr)
                return -ENOMEM;
similarity index 99%
rename from drivers/pci/dwc/pcie-designware-host.c
rename to drivers/pci/controller/dwc/pcie-designware-host.c
index cba1432e395dad14577cda788164c439ba99e9df..781aa03aeede34adbad23fa6b37b0d2275d00458 100644 (file)
@@ -15,7 +15,7 @@
 #include <linux/pci_regs.h>
 #include <linux/platform_device.h>
 
-#include "../pci.h"
+#include "../../pci.h"
 #include "pcie-designware.h"
 
 static struct pci_ops dw_pcie_ops;
similarity index 99%
rename from drivers/pci/dwc/pcie-hisi.c
rename to drivers/pci/controller/dwc/pcie-hisi.c
index 2658aaebb993d6e74ab07752f022027800711acf..6d9e1b2b8f7b03f6bdb7d0ce3a4ce42d019fd90e 100644 (file)
@@ -19,7 +19,7 @@
 #include <linux/pci-acpi.h>
 #include <linux/pci-ecam.h>
 #include <linux/regmap.h>
-#include "../pci.h"
+#include "../../pci.h"
 
 #if defined(CONFIG_PCI_HISI) || (defined(CONFIG_ACPI) && defined(CONFIG_PCI_QUIRKS))
 
similarity index 99%
rename from drivers/pci/cadence/pcie-cadence-ep.c
rename to drivers/pci/controller/pcie-cadence-ep.c
index 3d8283e450a910e6e3fa0d3612c98b7f1529abd7..e3fe4124e3afd427a674cddd3f2f3e0b3cf96c3f 100644 (file)
@@ -467,7 +467,8 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev)
                dev_err(dev, "missing \"cdns,max-outbound-regions\"\n");
                return ret;
        }
-       ep->ob_addr = devm_kzalloc(dev, ep->max_regions * sizeof(*ep->ob_addr),
+       ep->ob_addr = devm_kcalloc(dev,
+                                  ep->max_regions, sizeof(*ep->ob_addr),
                                   GFP_KERNEL);
        if (!ep->ob_addr)
                return -ENOMEM;
similarity index 99%
rename from drivers/pci/host/pcie-rockchip-ep.c
rename to drivers/pci/controller/pcie-rockchip-ep.c
index fc267a49a932e4c5e935b549552a4c1400032194..6beba8ed7b84b2f4d450a0f0cee19abb88f9c83b 100644 (file)
@@ -593,7 +593,7 @@ static int rockchip_pcie_ep_probe(struct platform_device *pdev)
                            PCIE_CLIENT_CONFIG);
 
        max_regions = ep->max_regions;
-       ep->ob_addr = devm_kzalloc(dev, max_regions * sizeof(*ep->ob_addr),
+       ep->ob_addr = devm_kcalloc(dev, max_regions, sizeof(*ep->ob_addr),
                                   GFP_KERNEL);
 
        if (!ep->ob_addr) {
index f45b74fcc059ae15a5734ba0b26e977b097df5a5..4d88afdfc8433ca159deefc544657f29d1a168b4 100644 (file)
@@ -474,7 +474,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
                return 0;
 
        /* Dynamically create the MSI attributes for the PCI device */
-       msi_attrs = kzalloc(sizeof(void *) * (num_msi + 1), GFP_KERNEL);
+       msi_attrs = kcalloc(num_msi + 1, sizeof(void *), GFP_KERNEL);
        if (!msi_attrs)
                return -ENOMEM;
        for_each_pci_msi_entry(entry, pdev) {
@@ -501,7 +501,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
        msi_irq_group->name = "msi_irqs";
        msi_irq_group->attrs = msi_attrs;
 
-       msi_irq_groups = kzalloc(sizeof(void *) * 2, GFP_KERNEL);
+       msi_irq_groups = kcalloc(2, sizeof(void *), GFP_KERNEL);
        if (!msi_irq_groups)
                goto error_irq_group;
        msi_irq_groups[0] = msi_irq_group;
index 788a200fb2dc4b3956f66ee07b7aeaa55157d0b2..0c4653c1d2cec6f743a0bd650ead5c029ef299bc 100644 (file)
@@ -1076,7 +1076,7 @@ void pci_create_legacy_files(struct pci_bus *b)
 {
        int error;
 
-       b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2,
+       b->legacy_io = kcalloc(2, sizeof(struct bin_attribute),
                               GFP_ATOMIC);
        if (!b->legacy_io)
                goto kzalloc_err;
index b12e28b3d8f932d510680439f9f07fbc5bdb70ed..0a1e9d379bc56e4fa7ed664b140aaaab88928a5a 100644 (file)
@@ -23,7 +23,42 @@ config HOTPLUG_PCI_PCIE
 
          When in doubt, say N.
 
-source "drivers/pci/pcie/aer/Kconfig"
+config PCIEAER
+       bool "PCI Express Advanced Error Reporting support"
+       depends on PCIEPORTBUS
+       select RAS
+       default y
+       help
+         This enables PCI Express Root Port Advanced Error Reporting
+         (AER) driver support. Error reporting messages sent to Root
+         Port will be handled by PCI Express AER driver.
+
+config PCIEAER_INJECT
+       tristate "PCI Express error injection support"
+       depends on PCIEAER
+       default n
+       help
+         This enables PCI Express Root Port Advanced Error Reporting
+         (AER) software error injector.
+
+         Debugging AER code is quite difficult because it is hard
+         to trigger various real hardware errors. Software-based
+         error injection can fake almost all kinds of errors with the
+         help of a user space helper tool aer-inject, which can be
+         gotten from:
+            http://www.kernel.org/pub/linux/utils/pci/aer-inject/
+
+#
+# PCI Express ECRC
+#
+config PCIE_ECRC
+       bool "PCI Express ECRC settings control"
+       depends on PCIEAER
+       help
+         Used to override firmware/bios settings for PCI Express ECRC
+         (transaction layer end-to-end CRC checking).
+
+         When in doubt, say N.
 
 #
 # PCI Express ASPM
@@ -92,7 +127,7 @@ config PCIE_PME
        depends on PCIEPORTBUS && PM
 
 config PCIE_DPC
-       bool "PCIe Downstream Port Containment support"
+       bool "PCI Express Downstream Port Containment support"
        depends on PCIEPORTBUS && PCIEAER
        default n
        help
@@ -103,7 +138,7 @@ config PCIE_DPC
          it is safe to answer N.
 
 config PCIE_PTM
-       bool "PCIe Precision Time Measurement support"
+       bool "PCI Express Precision Time Measurement support"
        default n
        depends on PCIEPORTBUS
        help
index 03f4e0b3a1400475ee0187995075c24767e92ef8..ab514083d5d4246ec3b56de9d578e7c2716359c1 100644 (file)
@@ -7,7 +7,8 @@ pcieportdrv-y                   := portdrv_core.o portdrv_pci.o err.o
 obj-$(CONFIG_PCIEPORTBUS)      += pcieportdrv.o
 
 obj-$(CONFIG_PCIEASPM)         += aspm.o
-obj-$(CONFIG_PCIEAER)          += aer/
+obj-$(CONFIG_PCIEAER)          += aer.o
+obj-$(CONFIG_PCIEAER_INJECT)   += aer_inject.o
 obj-$(CONFIG_PCIE_PME)         += pme.o
 obj-$(CONFIG_PCIE_DPC)         += dpc.o
 obj-$(CONFIG_PCIE_PTM)         += ptm.o
diff --git a/drivers/pci/pcie/aer.c b/drivers/pci/pcie/aer.c
new file mode 100644 (file)
index 0000000..a2e8838
--- /dev/null
@@ -0,0 +1,1377 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Implement the AER root port service driver. The driver registers an IRQ
+ * handler. When a root port triggers an AER interrupt, the IRQ handler
+ * collects root port status and schedules work.
+ *
+ * Copyright (C) 2006 Intel Corp.
+ *     Tom Long Nguyen (tom.l.nguyen@intel.com)
+ *     Zhang Yanmin (yanmin.zhang@intel.com)
+ *
+ * (C) Copyright 2009 Hewlett-Packard Development Company, L.P.
+ *    Andrew Patterson <andrew.patterson@hp.com>
+ */
+
+#include <linux/cper.h>
+#include <linux/pci.h>
+#include <linux/pci-acpi.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/pm.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/kfifo.h>
+#include <linux/slab.h>
+#include <acpi/apei.h>
+#include <ras/ras_event.h>
+
+#include "../pci.h"
+#include "portdrv.h"
+
+#define AER_ERROR_SOURCES_MAX          100
+#define AER_MAX_MULTI_ERR_DEVICES      5       /* Not likely to have more */
+
+struct aer_err_info {
+       struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
+       int error_dev_num;
+
+       unsigned int id:16;
+
+       unsigned int severity:2;        /* 0:NONFATAL | 1:FATAL | 2:COR */
+       unsigned int __pad1:5;
+       unsigned int multi_error_valid:1;
+
+       unsigned int first_error:5;
+       unsigned int __pad2:2;
+       unsigned int tlp_header_valid:1;
+
+       unsigned int status;            /* COR/UNCOR Error Status */
+       unsigned int mask;              /* COR/UNCOR Error Mask */
+       struct aer_header_log_regs tlp; /* TLP Header */
+};
+
+struct aer_err_source {
+       unsigned int status;
+       unsigned int id;
+};
+
+struct aer_rpc {
+       struct pci_dev *rpd;            /* Root Port device */
+       struct work_struct dpc_handler;
+       struct aer_err_source e_sources[AER_ERROR_SOURCES_MAX];
+       struct aer_err_info e_info;
+       unsigned short prod_idx;        /* Error Producer Index */
+       unsigned short cons_idx;        /* Error Consumer Index */
+       int isr;
+       spinlock_t e_lock;              /*
+                                        * Lock access to Error Status/ID Regs
+                                        * and error producer/consumer index
+                                        */
+       struct mutex rpc_mutex;         /*
+                                        * only one thread could do
+                                        * recovery on the same
+                                        * root port hierarchy
+                                        */
+};
+
+#define AER_LOG_TLP_MASKS              (PCI_ERR_UNC_POISON_TLP|        \
+                                       PCI_ERR_UNC_ECRC|               \
+                                       PCI_ERR_UNC_UNSUP|              \
+                                       PCI_ERR_UNC_COMP_ABORT|         \
+                                       PCI_ERR_UNC_UNX_COMP|           \
+                                       PCI_ERR_UNC_MALF_TLP)
+
+#define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE|   \
+                                       PCI_EXP_RTCTL_SENFEE|   \
+                                       PCI_EXP_RTCTL_SEFEE)
+#define ROOT_PORT_INTR_ON_MESG_MASK    (PCI_ERR_ROOT_CMD_COR_EN|       \
+                                       PCI_ERR_ROOT_CMD_NONFATAL_EN|   \
+                                       PCI_ERR_ROOT_CMD_FATAL_EN)
+#define ERR_COR_ID(d)                  (d & 0xffff)
+#define ERR_UNCOR_ID(d)                        (d >> 16)
+
+static int pcie_aer_disable;
+
+void pci_no_aer(void)
+{
+       pcie_aer_disable = 1;
+}
+
+bool pci_aer_available(void)
+{
+       return !pcie_aer_disable && pci_msi_enabled();
+}
+
+#ifdef CONFIG_PCIE_ECRC
+
+#define ECRC_POLICY_DEFAULT 0          /* ECRC set by BIOS */
+#define ECRC_POLICY_OFF     1          /* ECRC off for performance */
+#define ECRC_POLICY_ON      2          /* ECRC on for data integrity */
+
+static int ecrc_policy = ECRC_POLICY_DEFAULT;
+
+static const char *ecrc_policy_str[] = {
+       [ECRC_POLICY_DEFAULT] = "bios",
+       [ECRC_POLICY_OFF] = "off",
+       [ECRC_POLICY_ON] = "on"
+};
+
+/**
+ * enable_ercr_checking - enable PCIe ECRC checking for a device
+ * @dev: the PCI device
+ *
+ * Returns 0 on success, or negative on failure.
+ */
+static int enable_ecrc_checking(struct pci_dev *dev)
+{
+       int pos;
+       u32 reg32;
+
+       if (!pci_is_pcie(dev))
+               return -ENODEV;
+
+       pos = dev->aer_cap;
+       if (!pos)
+               return -ENODEV;
+
+       pci_read_config_dword(dev, pos + PCI_ERR_CAP, &reg32);
+       if (reg32 & PCI_ERR_CAP_ECRC_GENC)
+               reg32 |= PCI_ERR_CAP_ECRC_GENE;
+       if (reg32 & PCI_ERR_CAP_ECRC_CHKC)
+               reg32 |= PCI_ERR_CAP_ECRC_CHKE;
+       pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32);
+
+       return 0;
+}
+
+/**
+ * disable_ercr_checking - disables PCIe ECRC checking for a device
+ * @dev: the PCI device
+ *
+ * Returns 0 on success, or negative on failure.
+ */
+static int disable_ecrc_checking(struct pci_dev *dev)
+{
+       int pos;
+       u32 reg32;
+
+       if (!pci_is_pcie(dev))
+               return -ENODEV;
+
+       pos = dev->aer_cap;
+       if (!pos)
+               return -ENODEV;
+
+       pci_read_config_dword(dev, pos + PCI_ERR_CAP, &reg32);
+       reg32 &= ~(PCI_ERR_CAP_ECRC_GENE | PCI_ERR_CAP_ECRC_CHKE);
+       pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32);
+
+       return 0;
+}
+
+/**
+ * pcie_set_ecrc_checking - set/unset PCIe ECRC checking for a device based on global policy
+ * @dev: the PCI device
+ */
+void pcie_set_ecrc_checking(struct pci_dev *dev)
+{
+       switch (ecrc_policy) {
+       case ECRC_POLICY_DEFAULT:
+               return;
+       case ECRC_POLICY_OFF:
+               disable_ecrc_checking(dev);
+               break;
+       case ECRC_POLICY_ON:
+               enable_ecrc_checking(dev);
+               break;
+       default:
+               return;
+       }
+}
+
+/**
+ * pcie_ecrc_get_policy - parse kernel command-line ecrc option
+ */
+void pcie_ecrc_get_policy(char *str)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(ecrc_policy_str); i++)
+               if (!strncmp(str, ecrc_policy_str[i],
+                            strlen(ecrc_policy_str[i])))
+                       break;
+       if (i >= ARRAY_SIZE(ecrc_policy_str))
+               return;
+
+       ecrc_policy = i;
+}
+#endif /* CONFIG_PCIE_ECRC */
+
+#ifdef CONFIG_ACPI_APEI
+static inline int hest_match_pci(struct acpi_hest_aer_common *p,
+                                struct pci_dev *pci)
+{
+       return   ACPI_HEST_SEGMENT(p->bus) == pci_domain_nr(pci->bus) &&
+                ACPI_HEST_BUS(p->bus)     == pci->bus->number &&
+                p->device                 == PCI_SLOT(pci->devfn) &&
+                p->function               == PCI_FUNC(pci->devfn);
+}
+
+static inline bool hest_match_type(struct acpi_hest_header *hest_hdr,
+                               struct pci_dev *dev)
+{
+       u16 hest_type = hest_hdr->type;
+       u8 pcie_type = pci_pcie_type(dev);
+
+       if ((hest_type == ACPI_HEST_TYPE_AER_ROOT_PORT &&
+               pcie_type == PCI_EXP_TYPE_ROOT_PORT) ||
+           (hest_type == ACPI_HEST_TYPE_AER_ENDPOINT &&
+               pcie_type == PCI_EXP_TYPE_ENDPOINT) ||
+           (hest_type == ACPI_HEST_TYPE_AER_BRIDGE &&
+               (dev->class >> 16) == PCI_BASE_CLASS_BRIDGE))
+               return true;
+       return false;
+}
+
+struct aer_hest_parse_info {
+       struct pci_dev *pci_dev;
+       int firmware_first;
+};
+
+static int hest_source_is_pcie_aer(struct acpi_hest_header *hest_hdr)
+{
+       if (hest_hdr->type == ACPI_HEST_TYPE_AER_ROOT_PORT ||
+           hest_hdr->type == ACPI_HEST_TYPE_AER_ENDPOINT ||
+           hest_hdr->type == ACPI_HEST_TYPE_AER_BRIDGE)
+               return 1;
+       return 0;
+}
+
+static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
+{
+       struct aer_hest_parse_info *info = data;
+       struct acpi_hest_aer_common *p;
+       int ff;
+
+       if (!hest_source_is_pcie_aer(hest_hdr))
+               return 0;
+
+       p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
+       ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
+
+       /*
+        * If no specific device is supplied, determine whether
+        * FIRMWARE_FIRST is set for *any* PCIe device.
+        */
+       if (!info->pci_dev) {
+               info->firmware_first |= ff;
+               return 0;
+       }
+
+       /* Otherwise, check the specific device */
+       if (p->flags & ACPI_HEST_GLOBAL) {
+               if (hest_match_type(hest_hdr, info->pci_dev))
+                       info->firmware_first = ff;
+       } else
+               if (hest_match_pci(p, info->pci_dev))
+                       info->firmware_first = ff;
+
+       return 0;
+}
+
+static void aer_set_firmware_first(struct pci_dev *pci_dev)
+{
+       int rc;
+       struct aer_hest_parse_info info = {
+               .pci_dev        = pci_dev,
+               .firmware_first = 0,
+       };
+
+       rc = apei_hest_parse(aer_hest_parse, &info);
+
+       if (rc)
+               pci_dev->__aer_firmware_first = 0;
+       else
+               pci_dev->__aer_firmware_first = info.firmware_first;
+       pci_dev->__aer_firmware_first_valid = 1;
+}
+
+int pcie_aer_get_firmware_first(struct pci_dev *dev)
+{
+       if (!pci_is_pcie(dev))
+               return 0;
+
+       if (!dev->__aer_firmware_first_valid)
+               aer_set_firmware_first(dev);
+       return dev->__aer_firmware_first;
+}
+#define        PCI_EXP_AER_FLAGS       (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \
+                                PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE)
+
+static bool aer_firmware_first;
+
+/**
+ * aer_acpi_firmware_first - Check if APEI should control AER.
+ */
+bool aer_acpi_firmware_first(void)
+{
+       static bool parsed = false;
+       struct aer_hest_parse_info info = {
+               .pci_dev        = NULL, /* Check all PCIe devices */
+               .firmware_first = 0,
+       };
+
+       if (!parsed) {
+               apei_hest_parse(aer_hest_parse, &info);
+               aer_firmware_first = info.firmware_first;
+               parsed = true;
+       }
+       return aer_firmware_first;
+}
+#endif
+
+#define        PCI_EXP_AER_FLAGS       (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \
+                                PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE)
+
+int pci_enable_pcie_error_reporting(struct pci_dev *dev)
+{
+       if (pcie_aer_get_firmware_first(dev))
+               return -EIO;
+
+       if (!dev->aer_cap)
+               return -EIO;
+
+       return pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS);
+}
+EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting);
+
+int pci_disable_pcie_error_reporting(struct pci_dev *dev)
+{
+       if (pcie_aer_get_firmware_first(dev))
+               return -EIO;
+
+       return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL,
+                                         PCI_EXP_AER_FLAGS);
+}
+EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting);
+
+int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
+{
+       int pos;
+       u32 status;
+
+       pos = dev->aer_cap;
+       if (!pos)
+               return -EIO;
+
+       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
+       if (status)
+               pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
+
+int pci_cleanup_aer_error_status_regs(struct pci_dev *dev)
+{
+       int pos;
+       u32 status;
+       int port_type;
+
+       if (!pci_is_pcie(dev))
+               return -ENODEV;
+
+       pos = dev->aer_cap;
+       if (!pos)
+               return -EIO;
+
+       port_type = pci_pcie_type(dev);
+       if (port_type == PCI_EXP_TYPE_ROOT_PORT) {
+               pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &status);
+               pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, status);
+       }
+
+       pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &status);
+       pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, status);
+
+       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
+       pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
+
+       return 0;
+}
+
+int pci_aer_init(struct pci_dev *dev)
+{
+       dev->aer_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
+       return pci_cleanup_aer_error_status_regs(dev);
+}
+
+#define AER_AGENT_RECEIVER             0
+#define AER_AGENT_REQUESTER            1
+#define AER_AGENT_COMPLETER            2
+#define AER_AGENT_TRANSMITTER          3
+
+#define AER_AGENT_REQUESTER_MASK(t)    ((t == AER_CORRECTABLE) ?       \
+       0 : (PCI_ERR_UNC_COMP_TIME|PCI_ERR_UNC_UNSUP))
+#define AER_AGENT_COMPLETER_MASK(t)    ((t == AER_CORRECTABLE) ?       \
+       0 : PCI_ERR_UNC_COMP_ABORT)
+#define AER_AGENT_TRANSMITTER_MASK(t)  ((t == AER_CORRECTABLE) ?       \
+       (PCI_ERR_COR_REP_ROLL|PCI_ERR_COR_REP_TIMER) : 0)
+
+#define AER_GET_AGENT(t, e)                                            \
+       ((e & AER_AGENT_COMPLETER_MASK(t)) ? AER_AGENT_COMPLETER :      \
+       (e & AER_AGENT_REQUESTER_MASK(t)) ? AER_AGENT_REQUESTER :       \
+       (e & AER_AGENT_TRANSMITTER_MASK(t)) ? AER_AGENT_TRANSMITTER :   \
+       AER_AGENT_RECEIVER)
+
+#define AER_PHYSICAL_LAYER_ERROR       0
+#define AER_DATA_LINK_LAYER_ERROR      1
+#define AER_TRANSACTION_LAYER_ERROR    2
+
+#define AER_PHYSICAL_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ?     \
+       PCI_ERR_COR_RCVR : 0)
+#define AER_DATA_LINK_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ?    \
+       (PCI_ERR_COR_BAD_TLP|                                           \
+       PCI_ERR_COR_BAD_DLLP|                                           \
+       PCI_ERR_COR_REP_ROLL|                                           \
+       PCI_ERR_COR_REP_TIMER) : PCI_ERR_UNC_DLP)
+
+#define AER_GET_LAYER_ERROR(t, e)                                      \
+       ((e & AER_PHYSICAL_LAYER_ERROR_MASK(t)) ? AER_PHYSICAL_LAYER_ERROR : \
+       (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
+       AER_TRANSACTION_LAYER_ERROR)
+
+/*
+ * AER error strings
+ */
+static const char *aer_error_severity_string[] = {
+       "Uncorrected (Non-Fatal)",
+       "Uncorrected (Fatal)",
+       "Corrected"
+};
+
+static const char *aer_error_layer[] = {
+       "Physical Layer",
+       "Data Link Layer",
+       "Transaction Layer"
+};
+
+static const char *aer_correctable_error_string[] = {
+       "Receiver Error",               /* Bit Position 0       */
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       "Bad TLP",                      /* Bit Position 6       */
+       "Bad DLLP",                     /* Bit Position 7       */
+       "RELAY_NUM Rollover",           /* Bit Position 8       */
+       NULL,
+       NULL,
+       NULL,
+       "Replay Timer Timeout",         /* Bit Position 12      */
+       "Advisory Non-Fatal",           /* Bit Position 13      */
+       "Corrected Internal Error",     /* Bit Position 14      */
+       "Header Log Overflow",          /* Bit Position 15      */
+};
+
+static const char *aer_uncorrectable_error_string[] = {
+       "Undefined",                    /* Bit Position 0       */
+       NULL,
+       NULL,
+       NULL,
+       "Data Link Protocol",           /* Bit Position 4       */
+       "Surprise Down Error",          /* Bit Position 5       */
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       NULL,
+       "Poisoned TLP",                 /* Bit Position 12      */
+       "Flow Control Protocol",        /* Bit Position 13      */
+       "Completion Timeout",           /* Bit Position 14      */
+       "Completer Abort",              /* Bit Position 15      */
+       "Unexpected Completion",        /* Bit Position 16      */
+       "Receiver Overflow",            /* Bit Position 17      */
+       "Malformed TLP",                /* Bit Position 18      */
+       "ECRC",                         /* Bit Position 19      */
+       "Unsupported Request",          /* Bit Position 20      */
+       "ACS Violation",                /* Bit Position 21      */
+       "Uncorrectable Internal Error", /* Bit Position 22      */
+       "MC Blocked TLP",               /* Bit Position 23      */
+       "AtomicOp Egress Blocked",      /* Bit Position 24      */
+       "TLP Prefix Blocked Error",     /* Bit Position 25      */
+};
+
+static const char *aer_agent_string[] = {
+       "Receiver ID",
+       "Requester ID",
+       "Completer ID",
+       "Transmitter ID"
+};
+
+static void __print_tlp_header(struct pci_dev *dev,
+                              struct aer_header_log_regs *t)
+{
+       pci_err(dev, "  TLP Header: %08x %08x %08x %08x\n",
+               t->dw0, t->dw1, t->dw2, t->dw3);
+}
+
+static void __aer_print_error(struct pci_dev *dev,
+                             struct aer_err_info *info)
+{
+       int i, status;
+       const char *errmsg = NULL;
+       status = (info->status & ~info->mask);
+
+       for (i = 0; i < 32; i++) {
+               if (!(status & (1 << i)))
+                       continue;
+
+               if (info->severity == AER_CORRECTABLE)
+                       errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
+                               aer_correctable_error_string[i] : NULL;
+               else
+                       errmsg = i < ARRAY_SIZE(aer_uncorrectable_error_string) ?
+                               aer_uncorrectable_error_string[i] : NULL;
+
+               if (errmsg)
+                       pci_err(dev, "   [%2d] %-22s%s\n", i, errmsg,
+                               info->first_error == i ? " (First)" : "");
+               else
+                       pci_err(dev, "   [%2d] Unknown Error Bit%s\n",
+                               i, info->first_error == i ? " (First)" : "");
+       }
+}
+
+static void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
+{
+       int layer, agent;
+       int id = ((dev->bus->number << 8) | dev->devfn);
+
+       if (!info->status) {
+               pci_err(dev, "PCIe Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n",
+                       aer_error_severity_string[info->severity]);
+               goto out;
+       }
+
+       layer = AER_GET_LAYER_ERROR(info->severity, info->status);
+       agent = AER_GET_AGENT(info->severity, info->status);
+
+       pci_err(dev, "PCIe Bus Error: severity=%s, type=%s, (%s)\n",
+               aer_error_severity_string[info->severity],
+               aer_error_layer[layer], aer_agent_string[agent]);
+
+       pci_err(dev, "  device [%04x:%04x] error status/mask=%08x/%08x\n",
+               dev->vendor, dev->device,
+               info->status, info->mask);
+
+       __aer_print_error(dev, info);
+
+       if (info->tlp_header_valid)
+               __print_tlp_header(dev, &info->tlp);
+
+out:
+       if (info->id && info->error_dev_num > 1 && info->id == id)
+               pci_err(dev, "  Error of this Agent is reported first\n");
+
+       trace_aer_event(dev_name(&dev->dev), (info->status & ~info->mask),
+                       info->severity, info->tlp_header_valid, &info->tlp);
+}
+
+static void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
+{
+       u8 bus = info->id >> 8;
+       u8 devfn = info->id & 0xff;
+
+       pci_info(dev, "AER: %s%s error received: %04x:%02x:%02x.%d\n",
+               info->multi_error_valid ? "Multiple " : "",
+               aer_error_severity_string[info->severity],
+               pci_domain_nr(dev->bus), bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+}
+
+#ifdef CONFIG_ACPI_APEI_PCIEAER
+int cper_severity_to_aer(int cper_severity)
+{
+       switch (cper_severity) {
+       case CPER_SEV_RECOVERABLE:
+               return AER_NONFATAL;
+       case CPER_SEV_FATAL:
+               return AER_FATAL;
+       default:
+               return AER_CORRECTABLE;
+       }
+}
+EXPORT_SYMBOL_GPL(cper_severity_to_aer);
+
+void cper_print_aer(struct pci_dev *dev, int aer_severity,
+                   struct aer_capability_regs *aer)
+{
+       int layer, agent, tlp_header_valid = 0;
+       u32 status, mask;
+       struct aer_err_info info;
+
+       if (aer_severity == AER_CORRECTABLE) {
+               status = aer->cor_status;
+               mask = aer->cor_mask;
+       } else {
+               status = aer->uncor_status;
+               mask = aer->uncor_mask;
+               tlp_header_valid = status & AER_LOG_TLP_MASKS;
+       }
+
+       layer = AER_GET_LAYER_ERROR(aer_severity, status);
+       agent = AER_GET_AGENT(aer_severity, status);
+
+       memset(&info, 0, sizeof(info));
+       info.severity = aer_severity;
+       info.status = status;
+       info.mask = mask;
+       info.first_error = PCI_ERR_CAP_FEP(aer->cap_control);
+
+       pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask);
+       __aer_print_error(dev, &info);
+       pci_err(dev, "aer_layer=%s, aer_agent=%s\n",
+               aer_error_layer[layer], aer_agent_string[agent]);
+
+       if (aer_severity != AER_CORRECTABLE)
+               pci_err(dev, "aer_uncor_severity: 0x%08x\n",
+                       aer->uncor_severity);
+
+       if (tlp_header_valid)
+               __print_tlp_header(dev, &aer->header_log);
+
+       trace_aer_event(dev_name(&dev->dev), (status & ~mask),
+                       aer_severity, tlp_header_valid, &aer->header_log);
+}
+#endif
+
+/**
+ * add_error_device - list device to be handled
+ * @e_info: pointer to error info
+ * @dev: pointer to pci_dev to be added
+ */
+static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev)
+{
+       if (e_info->error_dev_num < AER_MAX_MULTI_ERR_DEVICES) {
+               e_info->dev[e_info->error_dev_num] = dev;
+               e_info->error_dev_num++;
+               return 0;
+       }
+       return -ENOSPC;
+}
+
+/**
+ * is_error_source - check whether the device is source of reported error
+ * @dev: pointer to pci_dev to be checked
+ * @e_info: pointer to reported error info
+ */
+static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
+{
+       int pos;
+       u32 status, mask;
+       u16 reg16;
+
+       /*
+        * When bus id is equal to 0, it might be a bad id
+        * reported by root port.
+        */
+       if ((PCI_BUS_NUM(e_info->id) != 0) &&
+           !(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_AERSID)) {
+               /* Device ID match? */
+               if (e_info->id == ((dev->bus->number << 8) | dev->devfn))
+                       return true;
+
+               /* Continue id comparing if there is no multiple error */
+               if (!e_info->multi_error_valid)
+                       return false;
+       }
+
+       /*
+        * When either
+        *      1) bus id is equal to 0. Some ports might lose the bus
+        *              id of error source id;
+        *      2) bus flag PCI_BUS_FLAGS_NO_AERSID is set
+        *      3) There are multiple errors and prior ID comparing fails;
+        * We check AER status registers to find possible reporter.
+        */
+       if (atomic_read(&dev->enable_cnt) == 0)
+               return false;
+
+       /* Check if AER is enabled */
+       pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &reg16);
+       if (!(reg16 & PCI_EXP_AER_FLAGS))
+               return false;
+
+       pos = dev->aer_cap;
+       if (!pos)
+               return false;
+
+       /* Check if error is recorded */
+       if (e_info->severity == AER_CORRECTABLE) {
+               pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &status);
+               pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK, &mask);
+       } else {
+               pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
+               pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
+       }
+       if (status & ~mask)
+               return true;
+
+       return false;
+}
+
+static int find_device_iter(struct pci_dev *dev, void *data)
+{
+       struct aer_err_info *e_info = (struct aer_err_info *)data;
+
+       if (is_error_source(dev, e_info)) {
+               /* List this device */
+               if (add_error_device(e_info, dev)) {
+                       /* We cannot handle more... Stop iteration */
+                       /* TODO: Should print error message here? */
+                       return 1;
+               }
+
+               /* If there is only a single error, stop iteration */
+               if (!e_info->multi_error_valid)
+                       return 1;
+       }
+       return 0;
+}
+
+/**
+ * find_source_device - search through device hierarchy for source device
+ * @parent: pointer to Root Port pci_dev data structure
+ * @e_info: including detailed error information such like id
+ *
+ * Return true if found.
+ *
+ * Invoked by DPC when error is detected at the Root Port.
+ * Caller of this function must set id, severity, and multi_error_valid of
+ * struct aer_err_info pointed by @e_info properly.  This function must fill
+ * e_info->error_dev_num and e_info->dev[], based on the given information.
+ */
+static bool find_source_device(struct pci_dev *parent,
+               struct aer_err_info *e_info)
+{
+       struct pci_dev *dev = parent;
+       int result;
+
+       /* Must reset in this function */
+       e_info->error_dev_num = 0;
+
+       /* Is Root Port an agent that sends error message? */
+       result = find_device_iter(dev, e_info);
+       if (result)
+               return true;
+
+       pci_walk_bus(parent->subordinate, find_device_iter, e_info);
+
+       if (!e_info->error_dev_num) {
+               pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n",
+                          e_info->id);
+               return false;
+       }
+       return true;
+}
+
+/**
+ * handle_error_source - handle logging error into an event log
+ * @dev: pointer to pci_dev data structure of error source device
+ * @info: comprehensive error information
+ *
+ * Invoked when an error being detected by Root Port.
+ */
+static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)
+{
+       int pos;
+
+       if (info->severity == AER_CORRECTABLE) {
+               /*
+                * Correctable error does not need software intervention.
+                * No need to go through error recovery process.
+                */
+               pos = dev->aer_cap;
+               if (pos)
+                       pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS,
+                                       info->status);
+       } else if (info->severity == AER_NONFATAL)
+               pcie_do_nonfatal_recovery(dev);
+       else if (info->severity == AER_FATAL)
+               pcie_do_fatal_recovery(dev, PCIE_PORT_SERVICE_AER);
+}
+
+#ifdef CONFIG_ACPI_APEI_PCIEAER
+
+#define AER_RECOVER_RING_ORDER         4
+#define AER_RECOVER_RING_SIZE          (1 << AER_RECOVER_RING_ORDER)
+
+struct aer_recover_entry {
+       u8      bus;
+       u8      devfn;
+       u16     domain;
+       int     severity;
+       struct aer_capability_regs *regs;
+};
+
+static DEFINE_KFIFO(aer_recover_ring, struct aer_recover_entry,
+                   AER_RECOVER_RING_SIZE);
+
+static void aer_recover_work_func(struct work_struct *work)
+{
+       struct aer_recover_entry entry;
+       struct pci_dev *pdev;
+
+       while (kfifo_get(&aer_recover_ring, &entry)) {
+               pdev = pci_get_domain_bus_and_slot(entry.domain, entry.bus,
+                                                  entry.devfn);
+               if (!pdev) {
+                       pr_err("AER recover: Can not find pci_dev for %04x:%02x:%02x:%x\n",
+                              entry.domain, entry.bus,
+                              PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn));
+                       continue;
+               }
+               cper_print_aer(pdev, entry.severity, entry.regs);
+               if (entry.severity == AER_NONFATAL)
+                       pcie_do_nonfatal_recovery(pdev);
+               else if (entry.severity == AER_FATAL)
+                       pcie_do_fatal_recovery(pdev, PCIE_PORT_SERVICE_AER);
+               pci_dev_put(pdev);
+       }
+}
+
+/*
+ * Mutual exclusion for writers of aer_recover_ring, reader side don't
+ * need lock, because there is only one reader and lock is not needed
+ * between reader and writer.
+ */
+static DEFINE_SPINLOCK(aer_recover_ring_lock);
+static DECLARE_WORK(aer_recover_work, aer_recover_work_func);
+
+void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
+                      int severity, struct aer_capability_regs *aer_regs)
+{
+       unsigned long flags;
+       struct aer_recover_entry entry = {
+               .bus            = bus,
+               .devfn          = devfn,
+               .domain         = domain,
+               .severity       = severity,
+               .regs           = aer_regs,
+       };
+
+       spin_lock_irqsave(&aer_recover_ring_lock, flags);
+       if (kfifo_put(&aer_recover_ring, entry))
+               schedule_work(&aer_recover_work);
+       else
+               pr_err("AER recover: Buffer overflow when recovering AER for %04x:%02x:%02x:%x\n",
+                      domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
+       spin_unlock_irqrestore(&aer_recover_ring_lock, flags);
+}
+EXPORT_SYMBOL_GPL(aer_recover_queue);
+#endif
+
+/**
+ * get_device_error_info - read error status from dev and store it to info
+ * @dev: pointer to the device expected to have a error record
+ * @info: pointer to structure to store the error record
+ *
+ * Return 1 on success, 0 on error.
+ *
+ * Note that @info is reused among all error devices. Clear fields properly.
+ */
+static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
+{
+       int pos, temp;
+
+       /* Must reset in this function */
+       info->status = 0;
+       info->tlp_header_valid = 0;
+
+       pos = dev->aer_cap;
+
+       /* The device might not support AER */
+       if (!pos)
+               return 0;
+
+       if (info->severity == AER_CORRECTABLE) {
+               pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS,
+                       &info->status);
+               pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK,
+                       &info->mask);
+               if (!(info->status & ~info->mask))
+                       return 0;
+       } else if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
+               info->severity == AER_NONFATAL) {
+
+               /* Link is still healthy for IO reads */
+               pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
+                       &info->status);
+               pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK,
+                       &info->mask);
+               if (!(info->status & ~info->mask))
+                       return 0;
+
+               /* Get First Error Pointer */
+               pci_read_config_dword(dev, pos + PCI_ERR_CAP, &temp);
+               info->first_error = PCI_ERR_CAP_FEP(temp);
+
+               if (info->status & AER_LOG_TLP_MASKS) {
+                       info->tlp_header_valid = 1;
+                       pci_read_config_dword(dev,
+                               pos + PCI_ERR_HEADER_LOG, &info->tlp.dw0);
+                       pci_read_config_dword(dev,
+                               pos + PCI_ERR_HEADER_LOG + 4, &info->tlp.dw1);
+                       pci_read_config_dword(dev,
+                               pos + PCI_ERR_HEADER_LOG + 8, &info->tlp.dw2);
+                       pci_read_config_dword(dev,
+                               pos + PCI_ERR_HEADER_LOG + 12, &info->tlp.dw3);
+               }
+       }
+
+       return 1;
+}
+
+static inline void aer_process_err_devices(struct aer_err_info *e_info)
+{
+       int i;
+
+       /* Report all before handle them, not to lost records by reset etc. */
+       for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
+               if (get_device_error_info(e_info->dev[i], e_info))
+                       aer_print_error(e_info->dev[i], e_info);
+       }
+       for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
+               if (get_device_error_info(e_info->dev[i], e_info))
+                       handle_error_source(e_info->dev[i], e_info);
+       }
+}
+
+/**
+ * aer_isr_one_error - consume an error detected by root port
+ * @rpc: pointer to the root port which holds an error
+ * @e_src: pointer to an error source
+ */
+static void aer_isr_one_error(struct aer_rpc *rpc,
+               struct aer_err_source *e_src)
+{
+       struct pci_dev *pdev = rpc->rpd;
+       struct aer_err_info *e_info = &rpc->e_info;
+
+       /*
+        * There is a possibility that both correctable error and
+        * uncorrectable error being logged. Report correctable error first.
+        */
+       if (e_src->status & PCI_ERR_ROOT_COR_RCV) {
+               e_info->id = ERR_COR_ID(e_src->id);
+               e_info->severity = AER_CORRECTABLE;
+
+               if (e_src->status & PCI_ERR_ROOT_MULTI_COR_RCV)
+                       e_info->multi_error_valid = 1;
+               else
+                       e_info->multi_error_valid = 0;
+               aer_print_port_info(pdev, e_info);
+
+               if (find_source_device(pdev, e_info))
+                       aer_process_err_devices(e_info);
+       }
+
+       if (e_src->status & PCI_ERR_ROOT_UNCOR_RCV) {
+               e_info->id = ERR_UNCOR_ID(e_src->id);
+
+               if (e_src->status & PCI_ERR_ROOT_FATAL_RCV)
+                       e_info->severity = AER_FATAL;
+               else
+                       e_info->severity = AER_NONFATAL;
+
+               if (e_src->status & PCI_ERR_ROOT_MULTI_UNCOR_RCV)
+                       e_info->multi_error_valid = 1;
+               else
+                       e_info->multi_error_valid = 0;
+
+               aer_print_port_info(pdev, e_info);
+
+               if (find_source_device(pdev, e_info))
+                       aer_process_err_devices(e_info);
+       }
+}
+
+/**
+ * get_e_source - retrieve an error source
+ * @rpc: pointer to the root port which holds an error
+ * @e_src: pointer to store retrieved error source
+ *
+ * Return 1 if an error source is retrieved, otherwise 0.
+ *
+ * Invoked by DPC handler to consume an error.
+ */
+static int get_e_source(struct aer_rpc *rpc, struct aer_err_source *e_src)
+{
+       unsigned long flags;
+
+       /* Lock access to Root error producer/consumer index */
+       spin_lock_irqsave(&rpc->e_lock, flags);
+       if (rpc->prod_idx == rpc->cons_idx) {
+               spin_unlock_irqrestore(&rpc->e_lock, flags);
+               return 0;
+       }
+
+       *e_src = rpc->e_sources[rpc->cons_idx];
+       rpc->cons_idx++;
+       if (rpc->cons_idx == AER_ERROR_SOURCES_MAX)
+               rpc->cons_idx = 0;
+       spin_unlock_irqrestore(&rpc->e_lock, flags);
+
+       return 1;
+}
+
+/**
+ * aer_isr - consume errors detected by root port
+ * @work: definition of this work item
+ *
+ * Invoked, as DPC, when root port records new detected error
+ */
+static void aer_isr(struct work_struct *work)
+{
+       struct aer_rpc *rpc = container_of(work, struct aer_rpc, dpc_handler);
+       struct aer_err_source uninitialized_var(e_src);
+
+       mutex_lock(&rpc->rpc_mutex);
+       while (get_e_source(rpc, &e_src))
+               aer_isr_one_error(rpc, &e_src);
+       mutex_unlock(&rpc->rpc_mutex);
+}
+
+/**
+ * aer_irq - Root Port's ISR
+ * @irq: IRQ assigned to Root Port
+ * @context: pointer to Root Port data structure
+ *
+ * Invoked when Root Port detects AER messages.
+ */
+irqreturn_t aer_irq(int irq, void *context)
+{
+       unsigned int status, id;
+       struct pcie_device *pdev = (struct pcie_device *)context;
+       struct aer_rpc *rpc = get_service_data(pdev);
+       int next_prod_idx;
+       unsigned long flags;
+       int pos;
+
+       pos = pdev->port->aer_cap;
+       /*
+        * Must lock access to Root Error Status Reg, Root Error ID Reg,
+        * and Root error producer/consumer index
+        */
+       spin_lock_irqsave(&rpc->e_lock, flags);
+
+       /* Read error status */
+       pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, &status);
+       if (!(status & (PCI_ERR_ROOT_UNCOR_RCV|PCI_ERR_ROOT_COR_RCV))) {
+               spin_unlock_irqrestore(&rpc->e_lock, flags);
+               return IRQ_NONE;
+       }
+
+       /* Read error source and clear error status */
+       pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_ERR_SRC, &id);
+       pci_write_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, status);
+
+       /* Store error source for later DPC handler */
+       next_prod_idx = rpc->prod_idx + 1;
+       if (next_prod_idx == AER_ERROR_SOURCES_MAX)
+               next_prod_idx = 0;
+       if (next_prod_idx == rpc->cons_idx) {
+               /*
+                * Error Storm Condition - possibly the same error occurred.
+                * Drop the error.
+                */
+               spin_unlock_irqrestore(&rpc->e_lock, flags);
+               return IRQ_HANDLED;
+       }
+       rpc->e_sources[rpc->prod_idx].status =  status;
+       rpc->e_sources[rpc->prod_idx].id = id;
+       rpc->prod_idx = next_prod_idx;
+       spin_unlock_irqrestore(&rpc->e_lock, flags);
+
+       /*  Invoke DPC handler */
+       schedule_work(&rpc->dpc_handler);
+
+       return IRQ_HANDLED;
+}
+EXPORT_SYMBOL_GPL(aer_irq);
+
+static int set_device_error_reporting(struct pci_dev *dev, void *data)
+{
+       bool enable = *((bool *)data);
+       int type = pci_pcie_type(dev);
+
+       if ((type == PCI_EXP_TYPE_ROOT_PORT) ||
+           (type == PCI_EXP_TYPE_UPSTREAM) ||
+           (type == PCI_EXP_TYPE_DOWNSTREAM)) {
+               if (enable)
+                       pci_enable_pcie_error_reporting(dev);
+               else
+                       pci_disable_pcie_error_reporting(dev);
+       }
+
+       if (enable)
+               pcie_set_ecrc_checking(dev);
+
+       return 0;
+}
+
+/**
+ * set_downstream_devices_error_reporting - enable/disable the error reporting  bits on the root port and its downstream ports.
+ * @dev: pointer to root port's pci_dev data structure
+ * @enable: true = enable error reporting, false = disable error reporting.
+ */
+static void set_downstream_devices_error_reporting(struct pci_dev *dev,
+                                                  bool enable)
+{
+       set_device_error_reporting(dev, &enable);
+
+       if (!dev->subordinate)
+               return;
+       pci_walk_bus(dev->subordinate, set_device_error_reporting, &enable);
+}
+
+/**
+ * aer_enable_rootport - enable Root Port's interrupts when receiving messages
+ * @rpc: pointer to a Root Port data structure
+ *
+ * Invoked when PCIe bus loads AER service driver.
+ */
+static void aer_enable_rootport(struct aer_rpc *rpc)
+{
+       struct pci_dev *pdev = rpc->rpd;
+       int aer_pos;
+       u16 reg16;
+       u32 reg32;
+
+       /* Clear PCIe Capability's Device Status */
+       pcie_capability_read_word(pdev, PCI_EXP_DEVSTA, &reg16);
+       pcie_capability_write_word(pdev, PCI_EXP_DEVSTA, reg16);
+
+       /* Disable system error generation in response to error messages */
+       pcie_capability_clear_word(pdev, PCI_EXP_RTCTL,
+                                  SYSTEM_ERROR_INTR_ON_MESG_MASK);
+
+       aer_pos = pdev->aer_cap;
+       /* Clear error status */
+       pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, &reg32);
+       pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, reg32);
+       pci_read_config_dword(pdev, aer_pos + PCI_ERR_COR_STATUS, &reg32);
+       pci_write_config_dword(pdev, aer_pos + PCI_ERR_COR_STATUS, reg32);
+       pci_read_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, &reg32);
+       pci_write_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, reg32);
+
+       /*
+        * Enable error reporting for the root port device and downstream port
+        * devices.
+        */
+       set_downstream_devices_error_reporting(pdev, true);
+
+       /* Enable Root Port's interrupt in response to error messages */
+       pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_COMMAND, &reg32);
+       reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
+       pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_COMMAND, reg32);
+}
+
+/**
+ * aer_disable_rootport - disable Root Port's interrupts when receiving messages
+ * @rpc: pointer to a Root Port data structure
+ *
+ * Invoked when PCIe bus unloads AER service driver.
+ */
+static void aer_disable_rootport(struct aer_rpc *rpc)
+{
+       struct pci_dev *pdev = rpc->rpd;
+       u32 reg32;
+       int pos;
+
+       /*
+        * Disable error reporting for the root port device and downstream port
+        * devices.
+        */
+       set_downstream_devices_error_reporting(pdev, false);
+
+       pos = pdev->aer_cap;
+       /* Disable Root's interrupt in response to error messages */
+       pci_read_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, &reg32);
+       reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
+       pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, reg32);
+
+       /* Clear Root's error status reg */
+       pci_read_config_dword(pdev, pos + PCI_ERR_ROOT_STATUS, &reg32);
+       pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_STATUS, reg32);
+}
+
+/**
+ * aer_alloc_rpc - allocate Root Port data structure
+ * @dev: pointer to the pcie_dev data structure
+ *
+ * Invoked when Root Port's AER service is loaded.
+ */
+static struct aer_rpc *aer_alloc_rpc(struct pcie_device *dev)
+{
+       struct aer_rpc *rpc;
+
+       rpc = kzalloc(sizeof(struct aer_rpc), GFP_KERNEL);
+       if (!rpc)
+               return NULL;
+
+       /* Initialize Root lock access, e_lock, to Root Error Status Reg */
+       spin_lock_init(&rpc->e_lock);
+
+       rpc->rpd = dev->port;
+       INIT_WORK(&rpc->dpc_handler, aer_isr);
+       mutex_init(&rpc->rpc_mutex);
+
+       /* Use PCIe bus function to store rpc into PCIe device */
+       set_service_data(dev, rpc);
+
+       return rpc;
+}
+
+/**
+ * aer_remove - clean up resources
+ * @dev: pointer to the pcie_dev data structure
+ *
+ * Invoked when PCI Express bus unloads or AER probe fails.
+ */
+static void aer_remove(struct pcie_device *dev)
+{
+       struct aer_rpc *rpc = get_service_data(dev);
+
+       if (rpc) {
+               /* If register interrupt service, it must be free. */
+               if (rpc->isr)
+                       free_irq(dev->irq, dev);
+
+               flush_work(&rpc->dpc_handler);
+               aer_disable_rootport(rpc);
+               kfree(rpc);
+               set_service_data(dev, NULL);
+       }
+}
+
+/**
+ * aer_probe - initialize resources
+ * @dev: pointer to the pcie_dev data structure
+ *
+ * Invoked when PCI Express bus loads AER service driver.
+ */
+static int aer_probe(struct pcie_device *dev)
+{
+       int status;
+       struct aer_rpc *rpc;
+       struct device *device = &dev->port->dev;
+
+       /* Alloc rpc data structure */
+       rpc = aer_alloc_rpc(dev);
+       if (!rpc) {
+               dev_printk(KERN_DEBUG, device, "alloc AER rpc failed\n");
+               aer_remove(dev);
+               return -ENOMEM;
+       }
+
+       /* Request IRQ ISR */
+       status = request_irq(dev->irq, aer_irq, IRQF_SHARED, "aerdrv", dev);
+       if (status) {
+               dev_printk(KERN_DEBUG, device, "request AER IRQ %d failed\n",
+                          dev->irq);
+               aer_remove(dev);
+               return status;
+       }
+
+       rpc->isr = 1;
+
+       aer_enable_rootport(rpc);
+       dev_info(device, "AER enabled with IRQ %d\n", dev->irq);
+       return 0;
+}
+
+/**
+ * aer_root_reset - reset link on Root Port
+ * @dev: pointer to Root Port's pci_dev data structure
+ *
+ * Invoked by Port Bus driver when performing link reset at Root Port.
+ */
+static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
+{
+       u32 reg32;
+       int pos;
+
+       pos = dev->aer_cap;
+
+       /* Disable Root's interrupt in response to error messages */
+       pci_read_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, &reg32);
+       reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
+       pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32);
+
+       pci_reset_bridge_secondary_bus(dev);
+       pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n");
+
+       /* Clear Root Error Status */
+       pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &reg32);
+       pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, reg32);
+
+       /* Enable Root Port's interrupt in response to error messages */
+       pci_read_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, &reg32);
+       reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
+       pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32);
+
+       return PCI_ERS_RESULT_RECOVERED;
+}
+
+/**
+ * aer_error_resume - clean up corresponding error status bits
+ * @dev: pointer to Root Port's pci_dev data structure
+ *
+ * Invoked by Port Bus driver during nonfatal recovery.
+ */
+static void aer_error_resume(struct pci_dev *dev)
+{
+       int pos;
+       u32 status, mask;
+       u16 reg16;
+
+       /* Clean up Root device status */
+       pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &reg16);
+       pcie_capability_write_word(dev, PCI_EXP_DEVSTA, reg16);
+
+       /* Clean AER Root Error Status */
+       pos = dev->aer_cap;
+       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
+       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &mask);
+       status &= ~mask; /* Clear corresponding nonfatal bits */
+       pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
+}
+
+static struct pcie_port_service_driver aerdriver = {
+       .name           = "aer",
+       .port_type      = PCI_EXP_TYPE_ROOT_PORT,
+       .service        = PCIE_PORT_SERVICE_AER,
+
+       .probe          = aer_probe,
+       .remove         = aer_remove,
+       .error_resume   = aer_error_resume,
+       .reset_link     = aer_root_reset,
+};
+
+/**
+ * aer_service_init - register AER root service driver
+ *
+ * Invoked when AER root service driver is loaded.
+ */
+static int __init aer_service_init(void)
+{
+       if (!pci_aer_available() || aer_acpi_firmware_first())
+               return -ENXIO;
+       return pcie_port_service_register(&aerdriver);
+}
+device_initcall(aer_service_init);
diff --git a/drivers/pci/pcie/aer/Kconfig b/drivers/pci/pcie/aer/Kconfig
deleted file mode 100644 (file)
index 5a64eb3..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# PCI Express Root Port Device AER Configuration
-#
-
-config PCIEAER
-       bool "Root Port Advanced Error Reporting support"
-       depends on PCIEPORTBUS
-       select RAS
-       default y
-       help
-         This enables PCI Express Root Port Advanced Error Reporting
-         (AER) driver support. Error reporting messages sent to Root
-         Port will be handled by PCI Express AER driver.
-
-
-#
-# PCI Express ECRC
-#
-config PCIE_ECRC
-       bool "PCI Express ECRC settings control"
-       depends on PCIEAER
-       help
-         Used to override firmware/bios settings for PCI Express ECRC
-         (transaction layer end-to-end CRC checking).
-
-         When in doubt, say N.
-
-source "drivers/pci/pcie/aer/Kconfig.debug"
diff --git a/drivers/pci/pcie/aer/Kconfig.debug b/drivers/pci/pcie/aer/Kconfig.debug
deleted file mode 100644 (file)
index 67e0217..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# PCI Express Root Port Device AER Debug Configuration
-#
-
-config PCIEAER_INJECT
-       tristate "PCIe AER error injector support"
-       depends on PCIEAER
-       default n
-       help
-         This enables PCI Express Root Port Advanced Error Reporting
-         (AER) software error injector.
-
-         Debugging PCIe AER code is quite difficult because it is hard
-         to trigger various real hardware errors. Software based
-         error injection can fake almost all kinds of errors with the
-         help of a user space helper tool aer-inject, which can be
-         gotten from:
-            http://www.kernel.org/pub/linux/utils/pci/aer-inject/
diff --git a/drivers/pci/pcie/aer/Makefile b/drivers/pci/pcie/aer/Makefile
deleted file mode 100644 (file)
index 09bd890..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for PCI-Express Root Port Advanced Error Reporting Driver
-#
-
-obj-$(CONFIG_PCIEAER) += aerdriver.o
-
-obj-$(CONFIG_PCIE_ECRC)        += ecrc.o
-
-aerdriver-objs := aerdrv_errprint.o aerdrv_core.o aerdrv.o
-aerdriver-$(CONFIG_ACPI) += aerdrv_acpi.o
-
-obj-$(CONFIG_PCIEAER_INJECT) += aer_inject.o
diff --git a/drivers/pci/pcie/aer/aerdrv.c b/drivers/pci/pcie/aer/aerdrv.c
deleted file mode 100644 (file)
index 9735c19..0000000
+++ /dev/null
@@ -1,371 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Implement the AER root port service driver. The driver registers an IRQ
- * handler. When a root port triggers an AER interrupt, the IRQ handler
- * collects root port status and schedules work.
- *
- * Copyright (C) 2006 Intel Corp.
- *     Tom Long Nguyen (tom.l.nguyen@intel.com)
- *     Zhang Yanmin (yanmin.zhang@intel.com)
- */
-
-#include <linux/pci.h>
-#include <linux/pci-acpi.h>
-#include <linux/sched.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/pm.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-
-#include "aerdrv.h"
-#include "../../pci.h"
-
-static int aer_probe(struct pcie_device *dev);
-static void aer_remove(struct pcie_device *dev);
-static void aer_error_resume(struct pci_dev *dev);
-static pci_ers_result_t aer_root_reset(struct pci_dev *dev);
-
-static struct pcie_port_service_driver aerdriver = {
-       .name           = "aer",
-       .port_type      = PCI_EXP_TYPE_ROOT_PORT,
-       .service        = PCIE_PORT_SERVICE_AER,
-
-       .probe          = aer_probe,
-       .remove         = aer_remove,
-       .error_resume   = aer_error_resume,
-       .reset_link     = aer_root_reset,
-};
-
-static int pcie_aer_disable;
-
-void pci_no_aer(void)
-{
-       pcie_aer_disable = 1;
-}
-
-bool pci_aer_available(void)
-{
-       return !pcie_aer_disable && pci_msi_enabled();
-}
-
-static int set_device_error_reporting(struct pci_dev *dev, void *data)
-{
-       bool enable = *((bool *)data);
-       int type = pci_pcie_type(dev);
-
-       if ((type == PCI_EXP_TYPE_ROOT_PORT) ||
-           (type == PCI_EXP_TYPE_UPSTREAM) ||
-           (type == PCI_EXP_TYPE_DOWNSTREAM)) {
-               if (enable)
-                       pci_enable_pcie_error_reporting(dev);
-               else
-                       pci_disable_pcie_error_reporting(dev);
-       }
-
-       if (enable)
-               pcie_set_ecrc_checking(dev);
-
-       return 0;
-}
-
-/**
- * set_downstream_devices_error_reporting - enable/disable the error reporting  bits on the root port and its downstream ports.
- * @dev: pointer to root port's pci_dev data structure
- * @enable: true = enable error reporting, false = disable error reporting.
- */
-static void set_downstream_devices_error_reporting(struct pci_dev *dev,
-                                                  bool enable)
-{
-       set_device_error_reporting(dev, &enable);
-
-       if (!dev->subordinate)
-               return;
-       pci_walk_bus(dev->subordinate, set_device_error_reporting, &enable);
-}
-
-/**
- * aer_enable_rootport - enable Root Port's interrupts when receiving messages
- * @rpc: pointer to a Root Port data structure
- *
- * Invoked when PCIe bus loads AER service driver.
- */
-static void aer_enable_rootport(struct aer_rpc *rpc)
-{
-       struct pci_dev *pdev = rpc->rpd;
-       int aer_pos;
-       u16 reg16;
-       u32 reg32;
-
-       /* Clear PCIe Capability's Device Status */
-       pcie_capability_read_word(pdev, PCI_EXP_DEVSTA, &reg16);
-       pcie_capability_write_word(pdev, PCI_EXP_DEVSTA, reg16);
-
-       /* Disable system error generation in response to error messages */
-       pcie_capability_clear_word(pdev, PCI_EXP_RTCTL,
-                                  SYSTEM_ERROR_INTR_ON_MESG_MASK);
-
-       aer_pos = pdev->aer_cap;
-       /* Clear error status */
-       pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, &reg32);
-       pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_STATUS, reg32);
-       pci_read_config_dword(pdev, aer_pos + PCI_ERR_COR_STATUS, &reg32);
-       pci_write_config_dword(pdev, aer_pos + PCI_ERR_COR_STATUS, reg32);
-       pci_read_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, &reg32);
-       pci_write_config_dword(pdev, aer_pos + PCI_ERR_UNCOR_STATUS, reg32);
-
-       /*
-        * Enable error reporting for the root port device and downstream port
-        * devices.
-        */
-       set_downstream_devices_error_reporting(pdev, true);
-
-       /* Enable Root Port's interrupt in response to error messages */
-       pci_read_config_dword(pdev, aer_pos + PCI_ERR_ROOT_COMMAND, &reg32);
-       reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
-       pci_write_config_dword(pdev, aer_pos + PCI_ERR_ROOT_COMMAND, reg32);
-}
-
-/**
- * aer_disable_rootport - disable Root Port's interrupts when receiving messages
- * @rpc: pointer to a Root Port data structure
- *
- * Invoked when PCIe bus unloads AER service driver.
- */
-static void aer_disable_rootport(struct aer_rpc *rpc)
-{
-       struct pci_dev *pdev = rpc->rpd;
-       u32 reg32;
-       int pos;
-
-       /*
-        * Disable error reporting for the root port device and downstream port
-        * devices.
-        */
-       set_downstream_devices_error_reporting(pdev, false);
-
-       pos = pdev->aer_cap;
-       /* Disable Root's interrupt in response to error messages */
-       pci_read_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, &reg32);
-       reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
-       pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_COMMAND, reg32);
-
-       /* Clear Root's error status reg */
-       pci_read_config_dword(pdev, pos + PCI_ERR_ROOT_STATUS, &reg32);
-       pci_write_config_dword(pdev, pos + PCI_ERR_ROOT_STATUS, reg32);
-}
-
-/**
- * aer_irq - Root Port's ISR
- * @irq: IRQ assigned to Root Port
- * @context: pointer to Root Port data structure
- *
- * Invoked when Root Port detects AER messages.
- */
-irqreturn_t aer_irq(int irq, void *context)
-{
-       unsigned int status, id;
-       struct pcie_device *pdev = (struct pcie_device *)context;
-       struct aer_rpc *rpc = get_service_data(pdev);
-       int next_prod_idx;
-       unsigned long flags;
-       int pos;
-
-       pos = pdev->port->aer_cap;
-       /*
-        * Must lock access to Root Error Status Reg, Root Error ID Reg,
-        * and Root error producer/consumer index
-        */
-       spin_lock_irqsave(&rpc->e_lock, flags);
-
-       /* Read error status */
-       pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, &status);
-       if (!(status & (PCI_ERR_ROOT_UNCOR_RCV|PCI_ERR_ROOT_COR_RCV))) {
-               spin_unlock_irqrestore(&rpc->e_lock, flags);
-               return IRQ_NONE;
-       }
-
-       /* Read error source and clear error status */
-       pci_read_config_dword(pdev->port, pos + PCI_ERR_ROOT_ERR_SRC, &id);
-       pci_write_config_dword(pdev->port, pos + PCI_ERR_ROOT_STATUS, status);
-
-       /* Store error source for later DPC handler */
-       next_prod_idx = rpc->prod_idx + 1;
-       if (next_prod_idx == AER_ERROR_SOURCES_MAX)
-               next_prod_idx = 0;
-       if (next_prod_idx == rpc->cons_idx) {
-               /*
-                * Error Storm Condition - possibly the same error occurred.
-                * Drop the error.
-                */
-               spin_unlock_irqrestore(&rpc->e_lock, flags);
-               return IRQ_HANDLED;
-       }
-       rpc->e_sources[rpc->prod_idx].status =  status;
-       rpc->e_sources[rpc->prod_idx].id = id;
-       rpc->prod_idx = next_prod_idx;
-       spin_unlock_irqrestore(&rpc->e_lock, flags);
-
-       /*  Invoke DPC handler */
-       schedule_work(&rpc->dpc_handler);
-
-       return IRQ_HANDLED;
-}
-EXPORT_SYMBOL_GPL(aer_irq);
-
-/**
- * aer_alloc_rpc - allocate Root Port data structure
- * @dev: pointer to the pcie_dev data structure
- *
- * Invoked when Root Port's AER service is loaded.
- */
-static struct aer_rpc *aer_alloc_rpc(struct pcie_device *dev)
-{
-       struct aer_rpc *rpc;
-
-       rpc = kzalloc(sizeof(struct aer_rpc), GFP_KERNEL);
-       if (!rpc)
-               return NULL;
-
-       /* Initialize Root lock access, e_lock, to Root Error Status Reg */
-       spin_lock_init(&rpc->e_lock);
-
-       rpc->rpd = dev->port;
-       INIT_WORK(&rpc->dpc_handler, aer_isr);
-       mutex_init(&rpc->rpc_mutex);
-
-       /* Use PCIe bus function to store rpc into PCIe device */
-       set_service_data(dev, rpc);
-
-       return rpc;
-}
-
-/**
- * aer_remove - clean up resources
- * @dev: pointer to the pcie_dev data structure
- *
- * Invoked when PCI Express bus unloads or AER probe fails.
- */
-static void aer_remove(struct pcie_device *dev)
-{
-       struct aer_rpc *rpc = get_service_data(dev);
-
-       if (rpc) {
-               /* If register interrupt service, it must be free. */
-               if (rpc->isr)
-                       free_irq(dev->irq, dev);
-
-               flush_work(&rpc->dpc_handler);
-               aer_disable_rootport(rpc);
-               kfree(rpc);
-               set_service_data(dev, NULL);
-       }
-}
-
-/**
- * aer_probe - initialize resources
- * @dev: pointer to the pcie_dev data structure
- *
- * Invoked when PCI Express bus loads AER service driver.
- */
-static int aer_probe(struct pcie_device *dev)
-{
-       int status;
-       struct aer_rpc *rpc;
-       struct device *device = &dev->port->dev;
-
-       /* Alloc rpc data structure */
-       rpc = aer_alloc_rpc(dev);
-       if (!rpc) {
-               dev_printk(KERN_DEBUG, device, "alloc AER rpc failed\n");
-               aer_remove(dev);
-               return -ENOMEM;
-       }
-
-       /* Request IRQ ISR */
-       status = request_irq(dev->irq, aer_irq, IRQF_SHARED, "aerdrv", dev);
-       if (status) {
-               dev_printk(KERN_DEBUG, device, "request AER IRQ %d failed\n",
-                          dev->irq);
-               aer_remove(dev);
-               return status;
-       }
-
-       rpc->isr = 1;
-
-       aer_enable_rootport(rpc);
-       dev_info(device, "AER enabled with IRQ %d\n", dev->irq);
-       return 0;
-}
-
-/**
- * aer_root_reset - reset link on Root Port
- * @dev: pointer to Root Port's pci_dev data structure
- *
- * Invoked by Port Bus driver when performing link reset at Root Port.
- */
-static pci_ers_result_t aer_root_reset(struct pci_dev *dev)
-{
-       u32 reg32;
-       int pos;
-
-       pos = dev->aer_cap;
-
-       /* Disable Root's interrupt in response to error messages */
-       pci_read_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, &reg32);
-       reg32 &= ~ROOT_PORT_INTR_ON_MESG_MASK;
-       pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32);
-
-       pci_reset_bridge_secondary_bus(dev);
-       pci_printk(KERN_DEBUG, dev, "Root Port link has been reset\n");
-
-       /* Clear Root Error Status */
-       pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &reg32);
-       pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, reg32);
-
-       /* Enable Root Port's interrupt in response to error messages */
-       pci_read_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, &reg32);
-       reg32 |= ROOT_PORT_INTR_ON_MESG_MASK;
-       pci_write_config_dword(dev, pos + PCI_ERR_ROOT_COMMAND, reg32);
-
-       return PCI_ERS_RESULT_RECOVERED;
-}
-
-/**
- * aer_error_resume - clean up corresponding error status bits
- * @dev: pointer to Root Port's pci_dev data structure
- *
- * Invoked by Port Bus driver during nonfatal recovery.
- */
-static void aer_error_resume(struct pci_dev *dev)
-{
-       int pos;
-       u32 status, mask;
-       u16 reg16;
-
-       /* Clean up Root device status */
-       pcie_capability_read_word(dev, PCI_EXP_DEVSTA, &reg16);
-       pcie_capability_write_word(dev, PCI_EXP_DEVSTA, reg16);
-
-       /* Clean AER Root Error Status */
-       pos = dev->aer_cap;
-       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
-       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_SEVER, &mask);
-       status &= ~mask; /* Clear corresponding nonfatal bits */
-       pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
-}
-
-/**
- * aer_service_init - register AER root service driver
- *
- * Invoked when AER root service driver is loaded.
- */
-static int __init aer_service_init(void)
-{
-       if (!pci_aer_available() || aer_acpi_firmware_first())
-               return -ENXIO;
-       return pcie_port_service_register(&aerdriver);
-}
-device_initcall(aer_service_init);
diff --git a/drivers/pci/pcie/aer/aerdrv.h b/drivers/pci/pcie/aer/aerdrv.h
deleted file mode 100644 (file)
index 6e0ad9a..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright (C) 2006 Intel Corp.
- *     Tom Long Nguyen (tom.l.nguyen@intel.com)
- *     Zhang Yanmin (yanmin.zhang@intel.com)
- */
-
-#ifndef _AERDRV_H_
-#define _AERDRV_H_
-
-#include <linux/workqueue.h>
-#include <linux/aer.h>
-#include <linux/interrupt.h>
-
-#include "../portdrv.h"
-
-#define SYSTEM_ERROR_INTR_ON_MESG_MASK (PCI_EXP_RTCTL_SECEE|   \
-                                       PCI_EXP_RTCTL_SENFEE|   \
-                                       PCI_EXP_RTCTL_SEFEE)
-#define ROOT_PORT_INTR_ON_MESG_MASK    (PCI_ERR_ROOT_CMD_COR_EN|       \
-                                       PCI_ERR_ROOT_CMD_NONFATAL_EN|   \
-                                       PCI_ERR_ROOT_CMD_FATAL_EN)
-#define ERR_COR_ID(d)                  (d & 0xffff)
-#define ERR_UNCOR_ID(d)                        (d >> 16)
-
-#define AER_ERROR_SOURCES_MAX          100
-
-#define AER_LOG_TLP_MASKS              (PCI_ERR_UNC_POISON_TLP|        \
-                                       PCI_ERR_UNC_ECRC|               \
-                                       PCI_ERR_UNC_UNSUP|              \
-                                       PCI_ERR_UNC_COMP_ABORT|         \
-                                       PCI_ERR_UNC_UNX_COMP|           \
-                                       PCI_ERR_UNC_MALF_TLP)
-
-#define AER_MAX_MULTI_ERR_DEVICES      5       /* Not likely to have more */
-struct aer_err_info {
-       struct pci_dev *dev[AER_MAX_MULTI_ERR_DEVICES];
-       int error_dev_num;
-
-       unsigned int id:16;
-
-       unsigned int severity:2;        /* 0:NONFATAL | 1:FATAL | 2:COR */
-       unsigned int __pad1:5;
-       unsigned int multi_error_valid:1;
-
-       unsigned int first_error:5;
-       unsigned int __pad2:2;
-       unsigned int tlp_header_valid:1;
-
-       unsigned int status;            /* COR/UNCOR Error Status */
-       unsigned int mask;              /* COR/UNCOR Error Mask */
-       struct aer_header_log_regs tlp; /* TLP Header */
-};
-
-struct aer_err_source {
-       unsigned int status;
-       unsigned int id;
-};
-
-struct aer_rpc {
-       struct pci_dev *rpd;            /* Root Port device */
-       struct work_struct dpc_handler;
-       struct aer_err_source e_sources[AER_ERROR_SOURCES_MAX];
-       struct aer_err_info e_info;
-       unsigned short prod_idx;        /* Error Producer Index */
-       unsigned short cons_idx;        /* Error Consumer Index */
-       int isr;
-       spinlock_t e_lock;              /*
-                                        * Lock access to Error Status/ID Regs
-                                        * and error producer/consumer index
-                                        */
-       struct mutex rpc_mutex;         /*
-                                        * only one thread could do
-                                        * recovery on the same
-                                        * root port hierarchy
-                                        */
-};
-
-extern struct bus_type pcie_port_bus_type;
-void aer_isr(struct work_struct *work);
-void aer_print_error(struct pci_dev *dev, struct aer_err_info *info);
-void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info);
-irqreturn_t aer_irq(int irq, void *context);
-
-#ifdef CONFIG_ACPI_APEI
-int pcie_aer_get_firmware_first(struct pci_dev *pci_dev);
-#else
-static inline int pcie_aer_get_firmware_first(struct pci_dev *pci_dev)
-{
-       if (pci_dev->__aer_firmware_first_valid)
-               return pci_dev->__aer_firmware_first;
-       return 0;
-}
-#endif
-#endif /* _AERDRV_H_ */
diff --git a/drivers/pci/pcie/aer/aerdrv_acpi.c b/drivers/pci/pcie/aer/aerdrv_acpi.c
deleted file mode 100644 (file)
index 08c87de..0000000
+++ /dev/null
@@ -1,141 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Access ACPI _OSC method
- *
- * Copyright (C) 2006 Intel Corp.
- *     Tom Long Nguyen (tom.l.nguyen@intel.com)
- *     Zhang Yanmin (yanmin.zhang@intel.com)
- */
-
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/pm.h>
-#include <linux/suspend.h>
-#include <linux/acpi.h>
-#include <linux/pci-acpi.h>
-#include <linux/delay.h>
-#include <acpi/apei.h>
-#include "aerdrv.h"
-
-#ifdef CONFIG_ACPI_APEI
-static inline int hest_match_pci(struct acpi_hest_aer_common *p,
-                                struct pci_dev *pci)
-{
-       return   ACPI_HEST_SEGMENT(p->bus) == pci_domain_nr(pci->bus) &&
-                ACPI_HEST_BUS(p->bus)     == pci->bus->number &&
-                p->device                 == PCI_SLOT(pci->devfn) &&
-                p->function               == PCI_FUNC(pci->devfn);
-}
-
-static inline bool hest_match_type(struct acpi_hest_header *hest_hdr,
-                               struct pci_dev *dev)
-{
-       u16 hest_type = hest_hdr->type;
-       u8 pcie_type = pci_pcie_type(dev);
-
-       if ((hest_type == ACPI_HEST_TYPE_AER_ROOT_PORT &&
-               pcie_type == PCI_EXP_TYPE_ROOT_PORT) ||
-           (hest_type == ACPI_HEST_TYPE_AER_ENDPOINT &&
-               pcie_type == PCI_EXP_TYPE_ENDPOINT) ||
-           (hest_type == ACPI_HEST_TYPE_AER_BRIDGE &&
-               (dev->class >> 16) == PCI_BASE_CLASS_BRIDGE))
-               return true;
-       return false;
-}
-
-struct aer_hest_parse_info {
-       struct pci_dev *pci_dev;
-       int firmware_first;
-};
-
-static int hest_source_is_pcie_aer(struct acpi_hest_header *hest_hdr)
-{
-       if (hest_hdr->type == ACPI_HEST_TYPE_AER_ROOT_PORT ||
-           hest_hdr->type == ACPI_HEST_TYPE_AER_ENDPOINT ||
-           hest_hdr->type == ACPI_HEST_TYPE_AER_BRIDGE)
-               return 1;
-       return 0;
-}
-
-static int aer_hest_parse(struct acpi_hest_header *hest_hdr, void *data)
-{
-       struct aer_hest_parse_info *info = data;
-       struct acpi_hest_aer_common *p;
-       int ff;
-
-       if (!hest_source_is_pcie_aer(hest_hdr))
-               return 0;
-
-       p = (struct acpi_hest_aer_common *)(hest_hdr + 1);
-       ff = !!(p->flags & ACPI_HEST_FIRMWARE_FIRST);
-
-       /*
-        * If no specific device is supplied, determine whether
-        * FIRMWARE_FIRST is set for *any* PCIe device.
-        */
-       if (!info->pci_dev) {
-               info->firmware_first |= ff;
-               return 0;
-       }
-
-       /* Otherwise, check the specific device */
-       if (p->flags & ACPI_HEST_GLOBAL) {
-               if (hest_match_type(hest_hdr, info->pci_dev))
-                       info->firmware_first = ff;
-       } else
-               if (hest_match_pci(p, info->pci_dev))
-                       info->firmware_first = ff;
-
-       return 0;
-}
-
-static void aer_set_firmware_first(struct pci_dev *pci_dev)
-{
-       int rc;
-       struct aer_hest_parse_info info = {
-               .pci_dev        = pci_dev,
-               .firmware_first = 0,
-       };
-
-       rc = apei_hest_parse(aer_hest_parse, &info);
-
-       if (rc)
-               pci_dev->__aer_firmware_first = 0;
-       else
-               pci_dev->__aer_firmware_first = info.firmware_first;
-       pci_dev->__aer_firmware_first_valid = 1;
-}
-
-int pcie_aer_get_firmware_first(struct pci_dev *dev)
-{
-       if (!pci_is_pcie(dev))
-               return 0;
-
-       if (!dev->__aer_firmware_first_valid)
-               aer_set_firmware_first(dev);
-       return dev->__aer_firmware_first;
-}
-
-static bool aer_firmware_first;
-
-/**
- * aer_acpi_firmware_first - Check if APEI should control AER.
- */
-bool aer_acpi_firmware_first(void)
-{
-       static bool parsed = false;
-       struct aer_hest_parse_info info = {
-               .pci_dev        = NULL, /* Check all PCIe devices */
-               .firmware_first = 0,
-       };
-
-       if (!parsed) {
-               apei_hest_parse(aer_hest_parse, &info);
-               aer_firmware_first = info.firmware_first;
-               parsed = true;
-       }
-       return aer_firmware_first;
-}
-#endif
diff --git a/drivers/pci/pcie/aer/aerdrv_core.c b/drivers/pci/pcie/aer/aerdrv_core.c
deleted file mode 100644 (file)
index 42d4f3f..0000000
+++ /dev/null
@@ -1,496 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Implement the core part of PCIe AER. When a PCIe error is delivered, an
- * error message will be collected and printed to console, then an error
- * recovery procedure will be executed by following the PCI error recovery
- * rules.
- *
- * Copyright (C) 2006 Intel Corp.
- *     Tom Long Nguyen (tom.l.nguyen@intel.com)
- *     Zhang Yanmin (yanmin.zhang@intel.com)
- */
-
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/pm.h>
-#include <linux/suspend.h>
-#include <linux/delay.h>
-#include <linux/slab.h>
-#include <linux/kfifo.h>
-#include "aerdrv.h"
-#include "../../pci.h"
-
-#define        PCI_EXP_AER_FLAGS       (PCI_EXP_DEVCTL_CERE | PCI_EXP_DEVCTL_NFERE | \
-                                PCI_EXP_DEVCTL_FERE | PCI_EXP_DEVCTL_URRE)
-
-int pci_enable_pcie_error_reporting(struct pci_dev *dev)
-{
-       if (pcie_aer_get_firmware_first(dev))
-               return -EIO;
-
-       if (!dev->aer_cap)
-               return -EIO;
-
-       return pcie_capability_set_word(dev, PCI_EXP_DEVCTL, PCI_EXP_AER_FLAGS);
-}
-EXPORT_SYMBOL_GPL(pci_enable_pcie_error_reporting);
-
-int pci_disable_pcie_error_reporting(struct pci_dev *dev)
-{
-       if (pcie_aer_get_firmware_first(dev))
-               return -EIO;
-
-       return pcie_capability_clear_word(dev, PCI_EXP_DEVCTL,
-                                         PCI_EXP_AER_FLAGS);
-}
-EXPORT_SYMBOL_GPL(pci_disable_pcie_error_reporting);
-
-int pci_cleanup_aer_uncorrect_error_status(struct pci_dev *dev)
-{
-       int pos;
-       u32 status;
-
-       pos = dev->aer_cap;
-       if (!pos)
-               return -EIO;
-
-       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
-       if (status)
-               pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(pci_cleanup_aer_uncorrect_error_status);
-
-int pci_cleanup_aer_error_status_regs(struct pci_dev *dev)
-{
-       int pos;
-       u32 status;
-       int port_type;
-
-       if (!pci_is_pcie(dev))
-               return -ENODEV;
-
-       pos = dev->aer_cap;
-       if (!pos)
-               return -EIO;
-
-       port_type = pci_pcie_type(dev);
-       if (port_type == PCI_EXP_TYPE_ROOT_PORT) {
-               pci_read_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, &status);
-               pci_write_config_dword(dev, pos + PCI_ERR_ROOT_STATUS, status);
-       }
-
-       pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &status);
-       pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS, status);
-
-       pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
-       pci_write_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, status);
-
-       return 0;
-}
-
-int pci_aer_init(struct pci_dev *dev)
-{
-       dev->aer_cap = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);
-       return pci_cleanup_aer_error_status_regs(dev);
-}
-
-/**
- * add_error_device - list device to be handled
- * @e_info: pointer to error info
- * @dev: pointer to pci_dev to be added
- */
-static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev)
-{
-       if (e_info->error_dev_num < AER_MAX_MULTI_ERR_DEVICES) {
-               e_info->dev[e_info->error_dev_num] = dev;
-               e_info->error_dev_num++;
-               return 0;
-       }
-       return -ENOSPC;
-}
-
-/**
- * is_error_source - check whether the device is source of reported error
- * @dev: pointer to pci_dev to be checked
- * @e_info: pointer to reported error info
- */
-static bool is_error_source(struct pci_dev *dev, struct aer_err_info *e_info)
-{
-       int pos;
-       u32 status, mask;
-       u16 reg16;
-
-       /*
-        * When bus id is equal to 0, it might be a bad id
-        * reported by root port.
-        */
-       if ((PCI_BUS_NUM(e_info->id) != 0) &&
-           !(dev->bus->bus_flags & PCI_BUS_FLAGS_NO_AERSID)) {
-               /* Device ID match? */
-               if (e_info->id == ((dev->bus->number << 8) | dev->devfn))
-                       return true;
-
-               /* Continue id comparing if there is no multiple error */
-               if (!e_info->multi_error_valid)
-                       return false;
-       }
-
-       /*
-        * When either
-        *      1) bus id is equal to 0. Some ports might lose the bus
-        *              id of error source id;
-        *      2) bus flag PCI_BUS_FLAGS_NO_AERSID is set
-        *      3) There are multiple errors and prior ID comparing fails;
-        * We check AER status registers to find possible reporter.
-        */
-       if (atomic_read(&dev->enable_cnt) == 0)
-               return false;
-
-       /* Check if AER is enabled */
-       pcie_capability_read_word(dev, PCI_EXP_DEVCTL, &reg16);
-       if (!(reg16 & PCI_EXP_AER_FLAGS))
-               return false;
-
-       pos = dev->aer_cap;
-       if (!pos)
-               return false;
-
-       /* Check if error is recorded */
-       if (e_info->severity == AER_CORRECTABLE) {
-               pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS, &status);
-               pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK, &mask);
-       } else {
-               pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS, &status);
-               pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK, &mask);
-       }
-       if (status & ~mask)
-               return true;
-
-       return false;
-}
-
-static int find_device_iter(struct pci_dev *dev, void *data)
-{
-       struct aer_err_info *e_info = (struct aer_err_info *)data;
-
-       if (is_error_source(dev, e_info)) {
-               /* List this device */
-               if (add_error_device(e_info, dev)) {
-                       /* We cannot handle more... Stop iteration */
-                       /* TODO: Should print error message here? */
-                       return 1;
-               }
-
-               /* If there is only a single error, stop iteration */
-               if (!e_info->multi_error_valid)
-                       return 1;
-       }
-       return 0;
-}
-
-/**
- * find_source_device - search through device hierarchy for source device
- * @parent: pointer to Root Port pci_dev data structure
- * @e_info: including detailed error information such like id
- *
- * Return true if found.
- *
- * Invoked by DPC when error is detected at the Root Port.
- * Caller of this function must set id, severity, and multi_error_valid of
- * struct aer_err_info pointed by @e_info properly.  This function must fill
- * e_info->error_dev_num and e_info->dev[], based on the given information.
- */
-static bool find_source_device(struct pci_dev *parent,
-               struct aer_err_info *e_info)
-{
-       struct pci_dev *dev = parent;
-       int result;
-
-       /* Must reset in this function */
-       e_info->error_dev_num = 0;
-
-       /* Is Root Port an agent that sends error message? */
-       result = find_device_iter(dev, e_info);
-       if (result)
-               return true;
-
-       pci_walk_bus(parent->subordinate, find_device_iter, e_info);
-
-       if (!e_info->error_dev_num) {
-               pci_printk(KERN_DEBUG, parent, "can't find device of ID%04x\n",
-                          e_info->id);
-               return false;
-       }
-       return true;
-}
-
-/**
- * handle_error_source - handle logging error into an event log
- * @dev: pointer to pci_dev data structure of error source device
- * @info: comprehensive error information
- *
- * Invoked when an error being detected by Root Port.
- */
-static void handle_error_source(struct pci_dev *dev, struct aer_err_info *info)
-{
-       int pos;
-
-       if (info->severity == AER_CORRECTABLE) {
-               /*
-                * Correctable error does not need software intervention.
-                * No need to go through error recovery process.
-                */
-               pos = dev->aer_cap;
-               if (pos)
-                       pci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS,
-                                       info->status);
-       } else if (info->severity == AER_NONFATAL)
-               pcie_do_nonfatal_recovery(dev);
-       else if (info->severity == AER_FATAL)
-               pcie_do_fatal_recovery(dev, PCIE_PORT_SERVICE_AER);
-}
-
-#ifdef CONFIG_ACPI_APEI_PCIEAER
-
-#define AER_RECOVER_RING_ORDER         4
-#define AER_RECOVER_RING_SIZE          (1 << AER_RECOVER_RING_ORDER)
-
-struct aer_recover_entry {
-       u8      bus;
-       u8      devfn;
-       u16     domain;
-       int     severity;
-       struct aer_capability_regs *regs;
-};
-
-static DEFINE_KFIFO(aer_recover_ring, struct aer_recover_entry,
-                   AER_RECOVER_RING_SIZE);
-
-static void aer_recover_work_func(struct work_struct *work)
-{
-       struct aer_recover_entry entry;
-       struct pci_dev *pdev;
-
-       while (kfifo_get(&aer_recover_ring, &entry)) {
-               pdev = pci_get_domain_bus_and_slot(entry.domain, entry.bus,
-                                                  entry.devfn);
-               if (!pdev) {
-                       pr_err("AER recover: Can not find pci_dev for %04x:%02x:%02x:%x\n",
-                              entry.domain, entry.bus,
-                              PCI_SLOT(entry.devfn), PCI_FUNC(entry.devfn));
-                       continue;
-               }
-               cper_print_aer(pdev, entry.severity, entry.regs);
-               if (entry.severity == AER_NONFATAL)
-                       pcie_do_nonfatal_recovery(pdev);
-               else if (entry.severity == AER_FATAL)
-                       pcie_do_fatal_recovery(pdev, PCIE_PORT_SERVICE_AER);
-               pci_dev_put(pdev);
-       }
-}
-
-/*
- * Mutual exclusion for writers of aer_recover_ring, reader side don't
- * need lock, because there is only one reader and lock is not needed
- * between reader and writer.
- */
-static DEFINE_SPINLOCK(aer_recover_ring_lock);
-static DECLARE_WORK(aer_recover_work, aer_recover_work_func);
-
-void aer_recover_queue(int domain, unsigned int bus, unsigned int devfn,
-                      int severity, struct aer_capability_regs *aer_regs)
-{
-       unsigned long flags;
-       struct aer_recover_entry entry = {
-               .bus            = bus,
-               .devfn          = devfn,
-               .domain         = domain,
-               .severity       = severity,
-               .regs           = aer_regs,
-       };
-
-       spin_lock_irqsave(&aer_recover_ring_lock, flags);
-       if (kfifo_put(&aer_recover_ring, entry))
-               schedule_work(&aer_recover_work);
-       else
-               pr_err("AER recover: Buffer overflow when recovering AER for %04x:%02x:%02x:%x\n",
-                      domain, bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
-       spin_unlock_irqrestore(&aer_recover_ring_lock, flags);
-}
-EXPORT_SYMBOL_GPL(aer_recover_queue);
-#endif
-
-/**
- * get_device_error_info - read error status from dev and store it to info
- * @dev: pointer to the device expected to have a error record
- * @info: pointer to structure to store the error record
- *
- * Return 1 on success, 0 on error.
- *
- * Note that @info is reused among all error devices. Clear fields properly.
- */
-static int get_device_error_info(struct pci_dev *dev, struct aer_err_info *info)
-{
-       int pos, temp;
-
-       /* Must reset in this function */
-       info->status = 0;
-       info->tlp_header_valid = 0;
-
-       pos = dev->aer_cap;
-
-       /* The device might not support AER */
-       if (!pos)
-               return 0;
-
-       if (info->severity == AER_CORRECTABLE) {
-               pci_read_config_dword(dev, pos + PCI_ERR_COR_STATUS,
-                       &info->status);
-               pci_read_config_dword(dev, pos + PCI_ERR_COR_MASK,
-                       &info->mask);
-               if (!(info->status & ~info->mask))
-                       return 0;
-       } else if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-               info->severity == AER_NONFATAL) {
-
-               /* Link is still healthy for IO reads */
-               pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_STATUS,
-                       &info->status);
-               pci_read_config_dword(dev, pos + PCI_ERR_UNCOR_MASK,
-                       &info->mask);
-               if (!(info->status & ~info->mask))
-                       return 0;
-
-               /* Get First Error Pointer */
-               pci_read_config_dword(dev, pos + PCI_ERR_CAP, &temp);
-               info->first_error = PCI_ERR_CAP_FEP(temp);
-
-               if (info->status & AER_LOG_TLP_MASKS) {
-                       info->tlp_header_valid = 1;
-                       pci_read_config_dword(dev,
-                               pos + PCI_ERR_HEADER_LOG, &info->tlp.dw0);
-                       pci_read_config_dword(dev,
-                               pos + PCI_ERR_HEADER_LOG + 4, &info->tlp.dw1);
-                       pci_read_config_dword(dev,
-                               pos + PCI_ERR_HEADER_LOG + 8, &info->tlp.dw2);
-                       pci_read_config_dword(dev,
-                               pos + PCI_ERR_HEADER_LOG + 12, &info->tlp.dw3);
-               }
-       }
-
-       return 1;
-}
-
-static inline void aer_process_err_devices(struct aer_err_info *e_info)
-{
-       int i;
-
-       /* Report all before handle them, not to lost records by reset etc. */
-       for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
-               if (get_device_error_info(e_info->dev[i], e_info))
-                       aer_print_error(e_info->dev[i], e_info);
-       }
-       for (i = 0; i < e_info->error_dev_num && e_info->dev[i]; i++) {
-               if (get_device_error_info(e_info->dev[i], e_info))
-                       handle_error_source(e_info->dev[i], e_info);
-       }
-}
-
-/**
- * aer_isr_one_error - consume an error detected by root port
- * @rpc: pointer to the root port which holds an error
- * @e_src: pointer to an error source
- */
-static void aer_isr_one_error(struct aer_rpc *rpc,
-               struct aer_err_source *e_src)
-{
-       struct pci_dev *pdev = rpc->rpd;
-       struct aer_err_info *e_info = &rpc->e_info;
-
-       /*
-        * There is a possibility that both correctable error and
-        * uncorrectable error being logged. Report correctable error first.
-        */
-       if (e_src->status & PCI_ERR_ROOT_COR_RCV) {
-               e_info->id = ERR_COR_ID(e_src->id);
-               e_info->severity = AER_CORRECTABLE;
-
-               if (e_src->status & PCI_ERR_ROOT_MULTI_COR_RCV)
-                       e_info->multi_error_valid = 1;
-               else
-                       e_info->multi_error_valid = 0;
-               aer_print_port_info(pdev, e_info);
-
-               if (find_source_device(pdev, e_info))
-                       aer_process_err_devices(e_info);
-       }
-
-       if (e_src->status & PCI_ERR_ROOT_UNCOR_RCV) {
-               e_info->id = ERR_UNCOR_ID(e_src->id);
-
-               if (e_src->status & PCI_ERR_ROOT_FATAL_RCV)
-                       e_info->severity = AER_FATAL;
-               else
-                       e_info->severity = AER_NONFATAL;
-
-               if (e_src->status & PCI_ERR_ROOT_MULTI_UNCOR_RCV)
-                       e_info->multi_error_valid = 1;
-               else
-                       e_info->multi_error_valid = 0;
-
-               aer_print_port_info(pdev, e_info);
-
-               if (find_source_device(pdev, e_info))
-                       aer_process_err_devices(e_info);
-       }
-}
-
-/**
- * get_e_source - retrieve an error source
- * @rpc: pointer to the root port which holds an error
- * @e_src: pointer to store retrieved error source
- *
- * Return 1 if an error source is retrieved, otherwise 0.
- *
- * Invoked by DPC handler to consume an error.
- */
-static int get_e_source(struct aer_rpc *rpc, struct aer_err_source *e_src)
-{
-       unsigned long flags;
-
-       /* Lock access to Root error producer/consumer index */
-       spin_lock_irqsave(&rpc->e_lock, flags);
-       if (rpc->prod_idx == rpc->cons_idx) {
-               spin_unlock_irqrestore(&rpc->e_lock, flags);
-               return 0;
-       }
-
-       *e_src = rpc->e_sources[rpc->cons_idx];
-       rpc->cons_idx++;
-       if (rpc->cons_idx == AER_ERROR_SOURCES_MAX)
-               rpc->cons_idx = 0;
-       spin_unlock_irqrestore(&rpc->e_lock, flags);
-
-       return 1;
-}
-
-/**
- * aer_isr - consume errors detected by root port
- * @work: definition of this work item
- *
- * Invoked, as DPC, when root port records new detected error
- */
-void aer_isr(struct work_struct *work)
-{
-       struct aer_rpc *rpc = container_of(work, struct aer_rpc, dpc_handler);
-       struct aer_err_source uninitialized_var(e_src);
-
-       mutex_lock(&rpc->rpc_mutex);
-       while (get_e_source(rpc, &e_src))
-               aer_isr_one_error(rpc, &e_src);
-       mutex_unlock(&rpc->rpc_mutex);
-}
diff --git a/drivers/pci/pcie/aer/aerdrv_errprint.c b/drivers/pci/pcie/aer/aerdrv_errprint.c
deleted file mode 100644 (file)
index 4985bdf..0000000
+++ /dev/null
@@ -1,260 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Format error messages and print them to console.
- *
- * Copyright (C) 2006 Intel Corp.
- *     Tom Long Nguyen (tom.l.nguyen@intel.com)
- *     Zhang Yanmin (yanmin.zhang@intel.com)
- */
-
-#include <linux/module.h>
-#include <linux/pci.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/pm.h>
-#include <linux/suspend.h>
-#include <linux/cper.h>
-
-#include "aerdrv.h"
-#include <ras/ras_event.h>
-
-#define AER_AGENT_RECEIVER             0
-#define AER_AGENT_REQUESTER            1
-#define AER_AGENT_COMPLETER            2
-#define AER_AGENT_TRANSMITTER          3
-
-#define AER_AGENT_REQUESTER_MASK(t)    ((t == AER_CORRECTABLE) ?       \
-       0 : (PCI_ERR_UNC_COMP_TIME|PCI_ERR_UNC_UNSUP))
-#define AER_AGENT_COMPLETER_MASK(t)    ((t == AER_CORRECTABLE) ?       \
-       0 : PCI_ERR_UNC_COMP_ABORT)
-#define AER_AGENT_TRANSMITTER_MASK(t)  ((t == AER_CORRECTABLE) ?       \
-       (PCI_ERR_COR_REP_ROLL|PCI_ERR_COR_REP_TIMER) : 0)
-
-#define AER_GET_AGENT(t, e)                                            \
-       ((e & AER_AGENT_COMPLETER_MASK(t)) ? AER_AGENT_COMPLETER :      \
-       (e & AER_AGENT_REQUESTER_MASK(t)) ? AER_AGENT_REQUESTER :       \
-       (e & AER_AGENT_TRANSMITTER_MASK(t)) ? AER_AGENT_TRANSMITTER :   \
-       AER_AGENT_RECEIVER)
-
-#define AER_PHYSICAL_LAYER_ERROR       0
-#define AER_DATA_LINK_LAYER_ERROR      1
-#define AER_TRANSACTION_LAYER_ERROR    2
-
-#define AER_PHYSICAL_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ?     \
-       PCI_ERR_COR_RCVR : 0)
-#define AER_DATA_LINK_LAYER_ERROR_MASK(t) ((t == AER_CORRECTABLE) ?    \
-       (PCI_ERR_COR_BAD_TLP|                                           \
-       PCI_ERR_COR_BAD_DLLP|                                           \
-       PCI_ERR_COR_REP_ROLL|                                           \
-       PCI_ERR_COR_REP_TIMER) : PCI_ERR_UNC_DLP)
-
-#define AER_GET_LAYER_ERROR(t, e)                                      \
-       ((e & AER_PHYSICAL_LAYER_ERROR_MASK(t)) ? AER_PHYSICAL_LAYER_ERROR : \
-       (e & AER_DATA_LINK_LAYER_ERROR_MASK(t)) ? AER_DATA_LINK_LAYER_ERROR : \
-       AER_TRANSACTION_LAYER_ERROR)
-
-/*
- * AER error strings
- */
-static const char *aer_error_severity_string[] = {
-       "Uncorrected (Non-Fatal)",
-       "Uncorrected (Fatal)",
-       "Corrected"
-};
-
-static const char *aer_error_layer[] = {
-       "Physical Layer",
-       "Data Link Layer",
-       "Transaction Layer"
-};
-
-static const char *aer_correctable_error_string[] = {
-       "Receiver Error",               /* Bit Position 0       */
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       "Bad TLP",                      /* Bit Position 6       */
-       "Bad DLLP",                     /* Bit Position 7       */
-       "RELAY_NUM Rollover",           /* Bit Position 8       */
-       NULL,
-       NULL,
-       NULL,
-       "Replay Timer Timeout",         /* Bit Position 12      */
-       "Advisory Non-Fatal",           /* Bit Position 13      */
-       "Corrected Internal Error",     /* Bit Position 14      */
-       "Header Log Overflow",          /* Bit Position 15      */
-};
-
-static const char *aer_uncorrectable_error_string[] = {
-       "Undefined",                    /* Bit Position 0       */
-       NULL,
-       NULL,
-       NULL,
-       "Data Link Protocol",           /* Bit Position 4       */
-       "Surprise Down Error",          /* Bit Position 5       */
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       NULL,
-       "Poisoned TLP",                 /* Bit Position 12      */
-       "Flow Control Protocol",        /* Bit Position 13      */
-       "Completion Timeout",           /* Bit Position 14      */
-       "Completer Abort",              /* Bit Position 15      */
-       "Unexpected Completion",        /* Bit Position 16      */
-       "Receiver Overflow",            /* Bit Position 17      */
-       "Malformed TLP",                /* Bit Position 18      */
-       "ECRC",                         /* Bit Position 19      */
-       "Unsupported Request",          /* Bit Position 20      */
-       "ACS Violation",                /* Bit Position 21      */
-       "Uncorrectable Internal Error", /* Bit Position 22      */
-       "MC Blocked TLP",               /* Bit Position 23      */
-       "AtomicOp Egress Blocked",      /* Bit Position 24      */
-       "TLP Prefix Blocked Error",     /* Bit Position 25      */
-};
-
-static const char *aer_agent_string[] = {
-       "Receiver ID",
-       "Requester ID",
-       "Completer ID",
-       "Transmitter ID"
-};
-
-static void __print_tlp_header(struct pci_dev *dev,
-                              struct aer_header_log_regs *t)
-{
-       pci_err(dev, "  TLP Header: %08x %08x %08x %08x\n",
-               t->dw0, t->dw1, t->dw2, t->dw3);
-}
-
-static void __aer_print_error(struct pci_dev *dev,
-                             struct aer_err_info *info)
-{
-       int i, status;
-       const char *errmsg = NULL;
-       status = (info->status & ~info->mask);
-
-       for (i = 0; i < 32; i++) {
-               if (!(status & (1 << i)))
-                       continue;
-
-               if (info->severity == AER_CORRECTABLE)
-                       errmsg = i < ARRAY_SIZE(aer_correctable_error_string) ?
-                               aer_correctable_error_string[i] : NULL;
-               else
-                       errmsg = i < ARRAY_SIZE(aer_uncorrectable_error_string) ?
-                               aer_uncorrectable_error_string[i] : NULL;
-
-               if (errmsg)
-                       pci_err(dev, "   [%2d] %-22s%s\n", i, errmsg,
-                               info->first_error == i ? " (First)" : "");
-               else
-                       pci_err(dev, "   [%2d] Unknown Error Bit%s\n",
-                               i, info->first_error == i ? " (First)" : "");
-       }
-}
-
-void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
-{
-       int layer, agent;
-       int id = ((dev->bus->number << 8) | dev->devfn);
-
-       if (!info->status) {
-               pci_err(dev, "PCIe Bus Error: severity=%s, type=Inaccessible, (Unregistered Agent ID)\n",
-                       aer_error_severity_string[info->severity]);
-               goto out;
-       }
-
-       layer = AER_GET_LAYER_ERROR(info->severity, info->status);
-       agent = AER_GET_AGENT(info->severity, info->status);
-
-       pci_err(dev, "PCIe Bus Error: severity=%s, type=%s, (%s)\n",
-               aer_error_severity_string[info->severity],
-               aer_error_layer[layer], aer_agent_string[agent]);
-
-       pci_err(dev, "  device [%04x:%04x] error status/mask=%08x/%08x\n",
-               dev->vendor, dev->device,
-               info->status, info->mask);
-
-       __aer_print_error(dev, info);
-
-       if (info->tlp_header_valid)
-               __print_tlp_header(dev, &info->tlp);
-
-out:
-       if (info->id && info->error_dev_num > 1 && info->id == id)
-               pci_err(dev, "  Error of this Agent is reported first\n");
-
-       trace_aer_event(dev_name(&dev->dev), (info->status & ~info->mask),
-                       info->severity, info->tlp_header_valid, &info->tlp);
-}
-
-void aer_print_port_info(struct pci_dev *dev, struct aer_err_info *info)
-{
-       u8 bus = info->id >> 8;
-       u8 devfn = info->id & 0xff;
-
-       pci_info(dev, "AER: %s%s error received: %04x:%02x:%02x.%d\n",
-               info->multi_error_valid ? "Multiple " : "",
-               aer_error_severity_string[info->severity],
-               pci_domain_nr(dev->bus), bus, PCI_SLOT(devfn), PCI_FUNC(devfn));
-}
-
-#ifdef CONFIG_ACPI_APEI_PCIEAER
-int cper_severity_to_aer(int cper_severity)
-{
-       switch (cper_severity) {
-       case CPER_SEV_RECOVERABLE:
-               return AER_NONFATAL;
-       case CPER_SEV_FATAL:
-               return AER_FATAL;
-       default:
-               return AER_CORRECTABLE;
-       }
-}
-EXPORT_SYMBOL_GPL(cper_severity_to_aer);
-
-void cper_print_aer(struct pci_dev *dev, int aer_severity,
-                   struct aer_capability_regs *aer)
-{
-       int layer, agent, tlp_header_valid = 0;
-       u32 status, mask;
-       struct aer_err_info info;
-
-       if (aer_severity == AER_CORRECTABLE) {
-               status = aer->cor_status;
-               mask = aer->cor_mask;
-       } else {
-               status = aer->uncor_status;
-               mask = aer->uncor_mask;
-               tlp_header_valid = status & AER_LOG_TLP_MASKS;
-       }
-
-       layer = AER_GET_LAYER_ERROR(aer_severity, status);
-       agent = AER_GET_AGENT(aer_severity, status);
-
-       memset(&info, 0, sizeof(info));
-       info.severity = aer_severity;
-       info.status = status;
-       info.mask = mask;
-       info.first_error = PCI_ERR_CAP_FEP(aer->cap_control);
-
-       pci_err(dev, "aer_status: 0x%08x, aer_mask: 0x%08x\n", status, mask);
-       __aer_print_error(dev, &info);
-       pci_err(dev, "aer_layer=%s, aer_agent=%s\n",
-               aer_error_layer[layer], aer_agent_string[agent]);
-
-       if (aer_severity != AER_CORRECTABLE)
-               pci_err(dev, "aer_uncor_severity: 0x%08x\n",
-                       aer->uncor_severity);
-
-       if (tlp_header_valid)
-               __print_tlp_header(dev, &aer->header_log);
-
-       trace_aer_event(dev_name(&dev->dev), (status & ~mask),
-                       aer_severity, tlp_header_valid, &aer->header_log);
-}
-#endif
diff --git a/drivers/pci/pcie/aer/ecrc.c b/drivers/pci/pcie/aer/ecrc.c
deleted file mode 100644 (file)
index 039efb6..0000000
+++ /dev/null
@@ -1,117 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Enable/disable PCIe ECRC checking
- *
- * (C) Copyright 2009 Hewlett-Packard Development Company, L.P.
- *    Andrew Patterson <andrew.patterson@hp.com>
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/pci.h>
-#include <linux/pci_regs.h>
-#include <linux/errno.h>
-#include "../../pci.h"
-
-#define ECRC_POLICY_DEFAULT 0          /* ECRC set by BIOS */
-#define ECRC_POLICY_OFF     1          /* ECRC off for performance */
-#define ECRC_POLICY_ON      2          /* ECRC on for data integrity */
-
-static int ecrc_policy = ECRC_POLICY_DEFAULT;
-
-static const char *ecrc_policy_str[] = {
-       [ECRC_POLICY_DEFAULT] = "bios",
-       [ECRC_POLICY_OFF] = "off",
-       [ECRC_POLICY_ON] = "on"
-};
-
-/**
- * enable_ercr_checking - enable PCIe ECRC checking for a device
- * @dev: the PCI device
- *
- * Returns 0 on success, or negative on failure.
- */
-static int enable_ecrc_checking(struct pci_dev *dev)
-{
-       int pos;
-       u32 reg32;
-
-       if (!pci_is_pcie(dev))
-               return -ENODEV;
-
-       pos = dev->aer_cap;
-       if (!pos)
-               return -ENODEV;
-
-       pci_read_config_dword(dev, pos + PCI_ERR_CAP, &reg32);
-       if (reg32 & PCI_ERR_CAP_ECRC_GENC)
-               reg32 |= PCI_ERR_CAP_ECRC_GENE;
-       if (reg32 & PCI_ERR_CAP_ECRC_CHKC)
-               reg32 |= PCI_ERR_CAP_ECRC_CHKE;
-       pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32);
-
-       return 0;
-}
-
-/**
- * disable_ercr_checking - disables PCIe ECRC checking for a device
- * @dev: the PCI device
- *
- * Returns 0 on success, or negative on failure.
- */
-static int disable_ecrc_checking(struct pci_dev *dev)
-{
-       int pos;
-       u32 reg32;
-
-       if (!pci_is_pcie(dev))
-               return -ENODEV;
-
-       pos = dev->aer_cap;
-       if (!pos)
-               return -ENODEV;
-
-       pci_read_config_dword(dev, pos + PCI_ERR_CAP, &reg32);
-       reg32 &= ~(PCI_ERR_CAP_ECRC_GENE | PCI_ERR_CAP_ECRC_CHKE);
-       pci_write_config_dword(dev, pos + PCI_ERR_CAP, reg32);
-
-       return 0;
-}
-
-/**
- * pcie_set_ecrc_checking - set/unset PCIe ECRC checking for a device based on global policy
- * @dev: the PCI device
- */
-void pcie_set_ecrc_checking(struct pci_dev *dev)
-{
-       switch (ecrc_policy) {
-       case ECRC_POLICY_DEFAULT:
-               return;
-       case ECRC_POLICY_OFF:
-               disable_ecrc_checking(dev);
-               break;
-       case ECRC_POLICY_ON:
-               enable_ecrc_checking(dev);
-               break;
-       default:
-               return;
-       }
-}
-
-/**
- * pcie_ecrc_get_policy - parse kernel command-line ecrc option
- */
-void pcie_ecrc_get_policy(char *str)
-{
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(ecrc_policy_str); i++)
-               if (!strncmp(str, ecrc_policy_str[i],
-                            strlen(ecrc_policy_str[i])))
-                       break;
-       if (i >= ARRAY_SIZE(ecrc_policy_str))
-               return;
-
-       ecrc_policy = i;
-}
similarity index 99%
rename from drivers/pci/pcie/aer/aer_inject.c
rename to drivers/pci/pcie/aer_inject.c
index a49090935303c236b8d85a476c1209bd13d21929..0eb24346cad3057f964d75b7045524bc792df6f3 100644 (file)
@@ -21,7 +21,8 @@
 #include <linux/uaccess.h>
 #include <linux/stddef.h>
 #include <linux/device.h>
-#include "aerdrv.h"
+
+#include "portdrv.h"
 
 /* Override the existing corrected and uncorrected error masks */
 static bool aer_mask_override;
index d6436681c5354110f5341a376581ad27668aa925..921ed979109da572171a4e415b614c66ea6c391f 100644 (file)
@@ -13,7 +13,6 @@
 
 #include "portdrv.h"
 #include "../pci.h"
-#include "aer/aerdrv.h"
 
 struct dpc_dev {
        struct pcie_device      *dev;
index 2bb5db7b53e6c69d3758fbecf33701b82825f80b..6ffc797a0dc1c9a25004be6b0da94727a4956aba 100644 (file)
@@ -110,6 +110,21 @@ static inline bool pcie_pme_no_msi(void) { return false; }
 static inline void pcie_pme_interrupt_enable(struct pci_dev *dev, bool en) {}
 #endif /* !CONFIG_PCIE_PME */
 
+#ifdef CONFIG_ACPI_APEI
+int pcie_aer_get_firmware_first(struct pci_dev *pci_dev);
+#else
+static inline int pcie_aer_get_firmware_first(struct pci_dev *pci_dev)
+{
+       if (pci_dev->__aer_firmware_first_valid)
+               return pci_dev->__aer_firmware_first;
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_PCIEAER
+irqreturn_t aer_irq(int irq, void *context);
+#endif
+
 struct pcie_port_service_driver *pcie_port_find_service(struct pci_dev *dev,
                                                        u32 service);
 struct device *pcie_port_find_device(struct pci_dev *dev, u32 service);
index 102646fedb5602b94c7f223aa4b2ffe32d5f25e0..ac0672b8dfca4d8245c49e74ded32923054f022a 100644 (file)
@@ -1481,11 +1481,11 @@ static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf,
        u_char *tuplebuffer;
        u_char *tempbuffer;
 
-       tuplebuffer = kmalloc(sizeof(u_char) * 256, GFP_KERNEL);
+       tuplebuffer = kmalloc_array(256, sizeof(u_char), GFP_KERNEL);
        if (!tuplebuffer)
                return -ENOMEM;
 
-       tempbuffer = kmalloc(sizeof(u_char) * 258, GFP_KERNEL);
+       tempbuffer = kmalloc_array(258, sizeof(u_char), GFP_KERNEL);
        if (!tempbuffer) {
                ret = -ENOMEM;
                goto free_tuple;
index 959ae3e65ef8b2ae902141eb068865849e0deaad..f0af9985ca09219c6840c33901cb441b5e3130ce 100644 (file)
@@ -628,7 +628,7 @@ static int pd6729_pci_probe(struct pci_dev *dev,
        char configbyte;
        struct pd6729_socket *socket;
 
-       socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS,
+       socket = kcalloc(MAX_SOCKETS, sizeof(struct pd6729_socket),
                         GFP_KERNEL);
        if (!socket) {
                dev_warn(&dev->dev, "failed to kzalloc socket.\n");
index 136ccaf53df8d88cc5cc409f01cea24b40c50edd..fa530913a2c8fc73c37a9b668447f1058d99815a 100644 (file)
@@ -771,8 +771,8 @@ static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
                maps_per_pin++;
        if (num_pulls)
                maps_per_pin++;
-       cur_map = maps = kzalloc(num_pins * maps_per_pin * sizeof(*maps),
-                               GFP_KERNEL);
+       cur_map = maps = kcalloc(num_pins * maps_per_pin, sizeof(*maps),
+                                GFP_KERNEL);
        if (!maps)
                return -ENOMEM;
 
index a620a8e8fa7877a62d7a258eb2732d9dbcf56266..d6d183e9db17c7cce99f1fae4a5f3f330620d012 100644 (file)
@@ -216,8 +216,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev)
        }
 
        /* we will reallocate later */
-       pctrl->functions = devm_kzalloc(&pdev->dev,
-                                       max_functions * sizeof(*pctrl->functions),
+       pctrl->functions = devm_kcalloc(&pdev->dev,
+                                       max_functions,
+                                       sizeof(*pctrl->functions),
                                        GFP_KERNEL);
        if (!pctrl->functions)
                return -ENOMEM;
@@ -261,8 +262,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev)
 
                        if (!function->groups) {
                                function->groups =
-                                       devm_kzalloc(&pdev->dev,
-                                                    function->ngroups * sizeof(char *),
+                                       devm_kcalloc(&pdev->dev,
+                                                    function->ngroups,
+                                                    sizeof(char *),
                                                     GFP_KERNEL);
 
                                if (!function->groups)
index e582a21cfe549640f8e2b07b67401644b89f3bea..1c6bb15579e1e5d82a715cb9edea2aeea21384be 100644 (file)
@@ -81,7 +81,8 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev,
                        map_num++;
        }
 
-       new_map = kmalloc(sizeof(struct pinctrl_map) * map_num, GFP_KERNEL);
+       new_map = kmalloc_array(map_num, sizeof(struct pinctrl_map),
+                               GFP_KERNEL);
        if (!new_map)
                return -ENOMEM;
 
@@ -476,10 +477,12 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
        config = imx_pinconf_parse_generic_config(np, ipctl);
 
        grp->num_pins = size / pin_size;
-       grp->data = devm_kzalloc(ipctl->dev, grp->num_pins *
-                                sizeof(struct imx_pin), GFP_KERNEL);
-       grp->pins = devm_kzalloc(ipctl->dev, grp->num_pins *
-                                sizeof(unsigned int), GFP_KERNEL);
+       grp->data = devm_kcalloc(ipctl->dev,
+                                grp->num_pins, sizeof(struct imx_pin),
+                                GFP_KERNEL);
+       grp->pins = devm_kcalloc(ipctl->dev,
+                                grp->num_pins, sizeof(unsigned int),
+                                GFP_KERNEL);
        if (!grp->pins || !grp->data)
                return -ENOMEM;
 
@@ -697,8 +700,9 @@ int imx_pinctrl_probe(struct platform_device *pdev,
        if (!ipctl)
                return -ENOMEM;
 
-       ipctl->pin_regs = devm_kmalloc(&pdev->dev, sizeof(*ipctl->pin_regs) *
-                                     info->npins, GFP_KERNEL);
+       ipctl->pin_regs = devm_kmalloc_array(&pdev->dev,
+                                      info->npins, sizeof(*ipctl->pin_regs),
+                                      GFP_KERNEL);
        if (!ipctl->pin_regs)
                return -ENOMEM;
 
index 5af89de0ff02c91c44bedf866ba8728749653d1c..c3bdd90b14223d0b17c39a9c821c85bdc8db5378 100644 (file)
@@ -241,7 +241,8 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev,
        for (i = 0; i < grp->npins; i++)
                map_num++;
 
-       new_map = kmalloc(sizeof(struct pinctrl_map) * map_num, GFP_KERNEL);
+       new_map = kmalloc_array(map_num, sizeof(struct pinctrl_map),
+                               GFP_KERNEL);
        if (!new_map)
                return -ENOMEM;
 
@@ -482,10 +483,10 @@ static int imx1_pinctrl_parse_groups(struct device_node *np,
        }
 
        grp->npins = size / 12;
-       grp->pins = devm_kzalloc(info->dev,
-                       grp->npins * sizeof(struct imx1_pin), GFP_KERNEL);
-       grp->pin_ids = devm_kzalloc(info->dev,
-                       grp->npins * sizeof(unsigned int), GFP_KERNEL);
+       grp->pins = devm_kcalloc(info->dev,
+                       grp->npins, sizeof(struct imx1_pin), GFP_KERNEL);
+       grp->pin_ids = devm_kcalloc(info->dev,
+                       grp->npins, sizeof(unsigned int), GFP_KERNEL);
 
        if (!grp->pins || !grp->pin_ids)
                return -ENOMEM;
@@ -522,8 +523,8 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
        if (func->num_groups == 0)
                return -EINVAL;
 
-       func->groups = devm_kzalloc(info->dev,
-                       func->num_groups * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(info->dev,
+                       func->num_groups, sizeof(char *), GFP_KERNEL);
 
        if (!func->groups)
                return -ENOMEM;
@@ -565,12 +566,12 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev,
        }
 
        info->nfunctions = nfuncs;
-       info->functions = devm_kzalloc(&pdev->dev,
-                       nfuncs * sizeof(struct imx1_pmx_func), GFP_KERNEL);
+       info->functions = devm_kcalloc(&pdev->dev,
+                       nfuncs, sizeof(struct imx1_pmx_func), GFP_KERNEL);
 
        info->ngroups = ngroups;
-       info->groups = devm_kzalloc(&pdev->dev,
-                       ngroups * sizeof(struct imx1_pin_group), GFP_KERNEL);
+       info->groups = devm_kcalloc(&pdev->dev,
+                       ngroups, sizeof(struct imx1_pin_group), GFP_KERNEL);
 
 
        if (!info->functions || !info->groups)
index 594f3e5ce9a9e81d63e7d60dbd35cca9e97d46f7..a612e46ca51c07d6e07399d0217a8ae3395c90f1 100644 (file)
@@ -89,7 +89,7 @@ static int mxs_dt_node_to_map(struct pinctrl_dev *pctldev,
        if (!purecfg && config)
                new_num = 2;
 
-       new_map = kzalloc(sizeof(*new_map) * new_num, GFP_KERNEL);
+       new_map = kcalloc(new_num, sizeof(*new_map), GFP_KERNEL);
        if (!new_map)
                return -ENOMEM;
 
@@ -370,12 +370,12 @@ static int mxs_pinctrl_parse_group(struct platform_device *pdev,
                return -EINVAL;
        g->npins = length / sizeof(u32);
 
-       g->pins = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->pins),
+       g->pins = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->pins),
                               GFP_KERNEL);
        if (!g->pins)
                return -ENOMEM;
 
-       g->muxsel = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->muxsel),
+       g->muxsel = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->muxsel),
                                 GFP_KERNEL);
        if (!g->muxsel)
                return -ENOMEM;
@@ -426,13 +426,16 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
                }
        }
 
-       soc->functions = devm_kzalloc(&pdev->dev, soc->nfunctions *
-                                     sizeof(*soc->functions), GFP_KERNEL);
+       soc->functions = devm_kcalloc(&pdev->dev,
+                                     soc->nfunctions,
+                                     sizeof(*soc->functions),
+                                     GFP_KERNEL);
        if (!soc->functions)
                return -ENOMEM;
 
-       soc->groups = devm_kzalloc(&pdev->dev, soc->ngroups *
-                                  sizeof(*soc->groups), GFP_KERNEL);
+       soc->groups = devm_kcalloc(&pdev->dev,
+                                  soc->ngroups, sizeof(*soc->groups),
+                                  GFP_KERNEL);
        if (!soc->groups)
                return -ENOMEM;
 
@@ -492,7 +495,8 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
 
                if (strcmp(fn, child->name)) {
                        f = &soc->functions[idxf++];
-                       f->groups = devm_kzalloc(&pdev->dev, f->ngroups *
+                       f->groups = devm_kcalloc(&pdev->dev,
+                                                f->ngroups,
                                                 sizeof(*f->groups),
                                                 GFP_KERNEL);
                        if (!f->groups)
index 674ffdf8103c3f3a875621f55f192576cc72ccfa..53cf800688e947ff4720273e64dad39b3d6b8133 100644 (file)
@@ -856,9 +856,10 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info)
                struct armada_37xx_pin_group *grp = &info->groups[n];
                int i, j, f;
 
-               grp->pins = devm_kzalloc(info->dev,
-                                        (grp->npins + grp->extra_npins) *
-                                        sizeof(*grp->pins), GFP_KERNEL);
+               grp->pins = devm_kcalloc(info->dev,
+                                        grp->npins + grp->extra_npins,
+                                        sizeof(*grp->pins),
+                                        GFP_KERNEL);
                if (!grp->pins)
                        return -ENOMEM;
 
@@ -908,7 +909,8 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info)
                const char **groups;
                int g;
 
-               funcs[n].groups = devm_kzalloc(info->dev, funcs[n].ngroups *
+               funcs[n].groups = devm_kcalloc(info->dev,
+                                              funcs[n].ngroups,
                                               sizeof(*(funcs[n].groups)),
                                               GFP_KERNEL);
                if (!funcs[n].groups)
@@ -948,8 +950,9 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
        ctrldesc->pmxops = &armada_37xx_pmx_ops;
        ctrldesc->confops = &armada_37xx_pinconf_ops;
 
-       pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
-                              pin_data->nr_pins, GFP_KERNEL);
+       pindesc = devm_kcalloc(&pdev->dev,
+                              pin_data->nr_pins, sizeof(*pindesc),
+                              GFP_KERNEL);
        if (!pindesc)
                return -ENOMEM;
 
@@ -968,8 +971,10 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev,
         * we allocate functions for number of pins and hope there are
         * fewer unique functions than pins available
         */
-       info->funcs = devm_kzalloc(&pdev->dev, pin_data->nr_pins *
-                          sizeof(struct armada_37xx_pmx_func), GFP_KERNEL);
+       info->funcs = devm_kcalloc(&pdev->dev,
+                                  pin_data->nr_pins,
+                                  sizeof(struct armada_37xx_pmx_func),
+                                  GFP_KERNEL);
        if (!info->funcs)
                return -ENOMEM;
 
index 5e828468e43da2243582da0b8c52cc3557f9beb0..43231fd065a186b4bf0729fff828f9e368be29e4 100644 (file)
@@ -630,8 +630,8 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev)
 
        nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG);
 
-       mpp_saved_regs = devm_kmalloc(&pdev->dev, nregs * sizeof(u32),
-                                     GFP_KERNEL);
+       mpp_saved_regs = devm_kmalloc_array(&pdev->dev, nregs, sizeof(u32),
+                                           GFP_KERNEL);
        if (!mpp_saved_regs)
                return -ENOMEM;
 
index 9e05cfaf75f020d60595bf8ee0172170bd81bf56..d7ec7119701b4e220f42681b3fdb5df5122ef59f 100644 (file)
@@ -501,8 +501,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev,
 
        /* we allocate functions for number of pins and hope
         * there are fewer unique functions than pins available */
-       funcs = devm_kzalloc(&pdev->dev, funcsize *
-                            sizeof(struct mvebu_pinctrl_function), GFP_KERNEL);
+       funcs = devm_kcalloc(&pdev->dev,
+                            funcsize, sizeof(struct mvebu_pinctrl_function),
+                            GFP_KERNEL);
        if (!funcs)
                return -ENOMEM;
 
@@ -549,8 +550,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev,
 
                        /* allocate group name array if not done already */
                        if (!f->groups) {
-                               f->groups = devm_kzalloc(&pdev->dev,
-                                                f->num_groups * sizeof(char *),
+                               f->groups = devm_kcalloc(&pdev->dev,
+                                                f->num_groups,
+                                                sizeof(char *),
                                                 GFP_KERNEL);
                                if (!f->groups)
                                        return -ENOMEM;
@@ -622,8 +624,10 @@ int mvebu_pinctrl_probe(struct platform_device *pdev)
                }
        }
 
-       pdesc = devm_kzalloc(&pdev->dev, pctl->desc.npins *
-                            sizeof(struct pinctrl_pin_desc), GFP_KERNEL);
+       pdesc = devm_kcalloc(&pdev->dev,
+                            pctl->desc.npins,
+                            sizeof(struct pinctrl_pin_desc),
+                            GFP_KERNEL);
        if (!pdesc)
                return -ENOMEM;
 
index bafb3d40545e4fd5ddf26d8010601e916603097c..67e4d9ffa6b1f4e4825d59ea81e736fb59af6192 100644 (file)
@@ -945,27 +945,30 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
                return PTR_ERR(atmel_pioctrl->clk);
        }
 
-       atmel_pioctrl->pins = devm_kzalloc(dev, sizeof(*atmel_pioctrl->pins)
-                       * atmel_pioctrl->npins, GFP_KERNEL);
+       atmel_pioctrl->pins = devm_kcalloc(dev,
+                                          atmel_pioctrl->npins,
+                                          sizeof(*atmel_pioctrl->pins),
+                                          GFP_KERNEL);
        if (!atmel_pioctrl->pins)
                return -ENOMEM;
 
-       pin_desc = devm_kzalloc(dev, sizeof(*pin_desc)
-                       * atmel_pioctrl->npins, GFP_KERNEL);
+       pin_desc = devm_kcalloc(dev, atmel_pioctrl->npins, sizeof(*pin_desc),
+                               GFP_KERNEL);
        if (!pin_desc)
                return -ENOMEM;
        atmel_pinctrl_desc.pins = pin_desc;
        atmel_pinctrl_desc.npins = atmel_pioctrl->npins;
 
        /* One pin is one group since a pin can achieve all functions. */
-       group_names = devm_kzalloc(dev, sizeof(*group_names)
-                       * atmel_pioctrl->npins, GFP_KERNEL);
+       group_names = devm_kcalloc(dev,
+                                  atmel_pioctrl->npins, sizeof(*group_names),
+                                  GFP_KERNEL);
        if (!group_names)
                return -ENOMEM;
        atmel_pioctrl->group_names = group_names;
 
-       atmel_pioctrl->groups = devm_kzalloc(&pdev->dev,
-                       sizeof(*atmel_pioctrl->groups) * atmel_pioctrl->npins,
+       atmel_pioctrl->groups = devm_kcalloc(&pdev->dev,
+                       atmel_pioctrl->npins, sizeof(*atmel_pioctrl->groups),
                        GFP_KERNEL);
        if (!atmel_pioctrl->groups)
                return -ENOMEM;
@@ -1001,20 +1004,24 @@ static int atmel_pinctrl_probe(struct platform_device *pdev)
        atmel_pioctrl->gpio_chip->parent = dev;
        atmel_pioctrl->gpio_chip->names = atmel_pioctrl->group_names;
 
-       atmel_pioctrl->pm_wakeup_sources = devm_kzalloc(dev,
-                       sizeof(*atmel_pioctrl->pm_wakeup_sources)
-                       * atmel_pioctrl->nbanks, GFP_KERNEL);
+       atmel_pioctrl->pm_wakeup_sources = devm_kcalloc(dev,
+                       atmel_pioctrl->nbanks,
+                       sizeof(*atmel_pioctrl->pm_wakeup_sources),
+                       GFP_KERNEL);
        if (!atmel_pioctrl->pm_wakeup_sources)
                return -ENOMEM;
 
-       atmel_pioctrl->pm_suspend_backup = devm_kzalloc(dev,
-                       sizeof(*atmel_pioctrl->pm_suspend_backup)
-                       * atmel_pioctrl->nbanks, GFP_KERNEL);
+       atmel_pioctrl->pm_suspend_backup = devm_kcalloc(dev,
+                       atmel_pioctrl->nbanks,
+                       sizeof(*atmel_pioctrl->pm_suspend_backup),
+                       GFP_KERNEL);
        if (!atmel_pioctrl->pm_suspend_backup)
                return -ENOMEM;
 
-       atmel_pioctrl->irqs = devm_kzalloc(dev, sizeof(*atmel_pioctrl->irqs)
-                       * atmel_pioctrl->nbanks, GFP_KERNEL);
+       atmel_pioctrl->irqs = devm_kcalloc(dev,
+                                          atmel_pioctrl->nbanks,
+                                          sizeof(*atmel_pioctrl->irqs),
+                                          GFP_KERNEL);
        if (!atmel_pioctrl->irqs)
                return -ENOMEM;
 
index 297f1d161211cc0bfce732fdf4aa87c5ada21a1c..50f0ec42c63723528576b4498df84fa147428250 100644 (file)
@@ -269,7 +269,8 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev,
        }
 
        map_num += grp->npins;
-       new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num, GFP_KERNEL);
+       new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map),
+                              GFP_KERNEL);
        if (!new_map)
                return -ENOMEM;
 
@@ -1049,7 +1050,8 @@ static int at91_pinctrl_mux_mask(struct at91_pinctrl *info,
        }
        info->nmux = size / gpio_banks;
 
-       info->mux_mask = devm_kzalloc(info->dev, sizeof(u32) * size, GFP_KERNEL);
+       info->mux_mask = devm_kcalloc(info->dev, size, sizeof(u32),
+                                     GFP_KERNEL);
        if (!info->mux_mask)
                return -ENOMEM;
 
@@ -1087,10 +1089,12 @@ static int at91_pinctrl_parse_groups(struct device_node *np,
        }
 
        grp->npins = size / 4;
-       pin = grp->pins_conf = devm_kzalloc(info->dev, grp->npins * sizeof(struct at91_pmx_pin),
-                               GFP_KERNEL);
-       grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int),
-                               GFP_KERNEL);
+       pin = grp->pins_conf = devm_kcalloc(info->dev,
+                                           grp->npins,
+                                           sizeof(struct at91_pmx_pin),
+                                           GFP_KERNEL);
+       grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int),
+                                GFP_KERNEL);
        if (!grp->pins_conf || !grp->pins)
                return -ENOMEM;
 
@@ -1129,8 +1133,8 @@ static int at91_pinctrl_parse_functions(struct device_node *np,
                dev_err(info->dev, "no groups defined\n");
                return -EINVAL;
        }
-       func->groups = devm_kzalloc(info->dev,
-                       func->ngroups * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(info->dev,
+                       func->ngroups, sizeof(char *), GFP_KERNEL);
        if (!func->groups)
                return -ENOMEM;
 
@@ -1192,12 +1196,16 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev,
 
        dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
        dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups);
-       info->functions = devm_kzalloc(&pdev->dev, info->nfunctions * sizeof(struct at91_pmx_func),
+       info->functions = devm_kcalloc(&pdev->dev,
+                                       info->nfunctions,
+                                       sizeof(struct at91_pmx_func),
                                        GFP_KERNEL);
        if (!info->functions)
                return -ENOMEM;
 
-       info->groups = devm_kzalloc(&pdev->dev, info->ngroups * sizeof(struct at91_pin_group),
+       info->groups = devm_kcalloc(&pdev->dev,
+                                       info->ngroups,
+                                       sizeof(struct at91_pin_group),
                                        GFP_KERNEL);
        if (!info->groups)
                return -ENOMEM;
@@ -1256,7 +1264,9 @@ static int at91_pinctrl_probe(struct platform_device *pdev)
        at91_pinctrl_desc.name = dev_name(&pdev->dev);
        at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK;
        at91_pinctrl_desc.pins = pdesc =
-               devm_kzalloc(&pdev->dev, sizeof(*pdesc) * at91_pinctrl_desc.npins, GFP_KERNEL);
+               devm_kcalloc(&pdev->dev,
+                            at91_pinctrl_desc.npins, sizeof(*pdesc),
+                            GFP_KERNEL);
 
        if (!at91_pinctrl_desc.pins)
                return -ENOMEM;
@@ -1763,7 +1773,7 @@ static int at91_gpio_probe(struct platform_device *pdev)
                        chip->ngpio = ngpio;
        }
 
-       names = devm_kzalloc(&pdev->dev, sizeof(char *) * chip->ngpio,
+       names = devm_kcalloc(&pdev->dev, chip->ngpio, sizeof(char *),
                             GFP_KERNEL);
 
        if (!names) {
index 1231bbbfa74472d8c18de5bc310016ad64de0afe..a52779f33ad4a466978132bb0e6906188cc4b8bd 100644 (file)
@@ -328,7 +328,8 @@ static void axp20x_funcs_groups_from_mask(struct device *dev, unsigned int mask,
 
        func->ngroups = ngroups;
        if (func->ngroups > 0) {
-               func->groups = devm_kzalloc(dev, ngroups * sizeof(const char *),
+               func->groups = devm_kcalloc(dev,
+                                           ngroups, sizeof(const char *),
                                            GFP_KERNEL);
                group = func->groups;
                for_each_set_bit(bit, &mask_cpy, mask_len) {
@@ -358,8 +359,8 @@ static void axp20x_build_funcs_groups(struct platform_device *pdev)
        /* Every pin supports GPIO_OUT and GPIO_IN functions */
        for (i = 0; i <= AXP20X_FUNC_GPIO_IN; i++) {
                pctl->funcs[i].ngroups = npins;
-               pctl->funcs[i].groups = devm_kzalloc(&pdev->dev,
-                                                    npins * sizeof(char *),
+               pctl->funcs[i].groups = devm_kcalloc(&pdev->dev,
+                                                    npins, sizeof(char *),
                                                     GFP_KERNEL);
                for (pin = 0; pin < npins; pin++)
                        pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name;
index ce269ced4d49b489e767a4c6562bc193b651f86a..5353b23f775c9885709fe1faeeff47e210cb215a 100644 (file)
@@ -291,10 +291,11 @@ static int dc_pinctrl_probe(struct platform_device *pdev)
        if (IS_ERR(pmap->regs))
                return PTR_ERR(pmap->regs);
 
-       pins = devm_kzalloc(&pdev->dev, sizeof(*pins)*PINS_COUNT, GFP_KERNEL);
+       pins = devm_kcalloc(&pdev->dev, PINS_COUNT, sizeof(*pins),
+                           GFP_KERNEL);
        if (!pins)
                return -ENOMEM;
-       pin_names = devm_kzalloc(&pdev->dev, name_len * PINS_COUNT,
+       pin_names = devm_kcalloc(&pdev->dev, PINS_COUNT, name_len,
                                 GFP_KERNEL);
        if (!pin_names)
                return -ENOMEM;
index ac38a3f9f86bf6aab07cfb66d4f5a1f4e65b4b1f..a1d7156d0a43ad49ac6312ab67b67a7312ad9e10 100644 (file)
@@ -770,8 +770,8 @@ static int ingenic_pinctrl_probe(struct platform_device *pdev)
        pctl_desc->pmxops = &ingenic_pmxops;
        pctl_desc->confops = &ingenic_confops;
        pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
-       pctl_desc->pins = jzpc->pdesc = devm_kzalloc(&pdev->dev,
-                       sizeof(*jzpc->pdesc) * pctl_desc->npins, GFP_KERNEL);
+       pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
+                       pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
        if (!jzpc->pdesc)
                return -ENOMEM;
 
index 41dc39c7a7b14c700936eb38075aa440af0a1d85..81632af3a86ae5799a9e1194dc2f1df6f24b7019 100644 (file)
@@ -158,7 +158,8 @@ static int ltq_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
 
        for_each_child_of_node(np_config, np)
                max_maps += ltq_pinctrl_dt_subnode_size(np);
-       *map = kzalloc(max_maps * sizeof(struct pinctrl_map) * 2, GFP_KERNEL);
+       *map = kzalloc(array3_size(max_maps, sizeof(struct pinctrl_map), 2),
+                      GFP_KERNEL);
        if (!*map)
                return -ENOMEM;
        tmp = *map;
index d090f37ca4a114683d69e203532b20dc653c1d35..190f17e4bbdafd287b9dd8d9cdeee4011f80c6c5 100644 (file)
@@ -1308,8 +1308,9 @@ static int lpc18xx_create_group_func_map(struct device *dev,
                }
 
                scu->func[func].ngroups = ngroups;
-               scu->func[func].groups = devm_kzalloc(dev, ngroups *
-                                                     sizeof(char *), GFP_KERNEL);
+               scu->func[func].groups = devm_kcalloc(dev,
+                                                     ngroups, sizeof(char *),
+                                                     GFP_KERNEL);
                if (!scu->func[func].groups)
                        return -ENOMEM;
 
index b5b3547fdcb2bcf33c50cf3ebcb634de48994bb3..15bb1cb8729b936eb73f519286f7d5a88f0e0a3f 100644 (file)
@@ -330,7 +330,8 @@ static int ocelot_create_group_func_map(struct device *dev,
                }
 
                info->func[f].ngroups = npins;
-               info->func[f].groups = devm_kzalloc(dev, npins *
+               info->func[f].groups = devm_kcalloc(dev,
+                                                        npins,
                                                         sizeof(char *),
                                                         GFP_KERNEL);
                if (!info->func[f].groups)
index 1882713e68f932c7074d9d06a2eeaa91c7ad108f..f4a61429e06e7bd28c20a9ff0e54cfbf41cee4fe 100644 (file)
@@ -507,7 +507,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev,
        }
 
        map_num += grp->npins;
-       new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num,
+       new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map),
                                                                GFP_KERNEL);
        if (!new_map)
                return -ENOMEM;
@@ -2473,10 +2473,11 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np,
 
        grp->npins = size / 4;
 
-       grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int),
+       grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int),
                                                GFP_KERNEL);
-       grp->data = devm_kzalloc(info->dev, grp->npins *
-                                         sizeof(struct rockchip_pin_config),
+       grp->data = devm_kcalloc(info->dev,
+                                       grp->npins,
+                                       sizeof(struct rockchip_pin_config),
                                        GFP_KERNEL);
        if (!grp->pins || !grp->data)
                return -ENOMEM;
@@ -2528,8 +2529,8 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np,
        if (func->ngroups <= 0)
                return 0;
 
-       func->groups = devm_kzalloc(info->dev,
-                       func->ngroups * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(info->dev,
+                       func->ngroups, sizeof(char *), GFP_KERNEL);
        if (!func->groups)
                return -ENOMEM;
 
@@ -2560,13 +2561,15 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev,
        dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
        dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups);
 
-       info->functions = devm_kzalloc(dev, info->nfunctions *
+       info->functions = devm_kcalloc(dev,
+                                             info->nfunctions,
                                              sizeof(struct rockchip_pmx_func),
                                              GFP_KERNEL);
        if (!info->functions)
                return -EINVAL;
 
-       info->groups = devm_kzalloc(dev, info->ngroups *
+       info->groups = devm_kcalloc(dev,
+                                           info->ngroups,
                                            sizeof(struct rockchip_pin_group),
                                            GFP_KERNEL);
        if (!info->groups)
@@ -2604,8 +2607,9 @@ static int rockchip_pinctrl_register(struct platform_device *pdev,
        ctrldesc->pmxops = &rockchip_pmx_ops;
        ctrldesc->confops = &rockchip_pinconf_ops;
 
-       pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
-                       info->ctrl->nr_pins, GFP_KERNEL);
+       pindesc = devm_kcalloc(&pdev->dev,
+                              info->ctrl->nr_pins, sizeof(*pindesc),
+                              GFP_KERNEL);
        if (!pindesc)
                return -ENOMEM;
 
index 9c3c00515aa0fe20619fa7d2832d28ccee62c0db..b3153c095199d3bed84d7b846432fa3e783c08f0 100644 (file)
@@ -712,8 +712,8 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs)
        }
 
        dev_dbg(pcs->dev, "allocating %i pins\n", nr_pins);
-       pcs->pins.pa = devm_kzalloc(pcs->dev,
-                               sizeof(*pcs->pins.pa) * nr_pins,
+       pcs->pins.pa = devm_kcalloc(pcs->dev,
+                               nr_pins, sizeof(*pcs->pins.pa),
                                GFP_KERNEL);
        if (!pcs->pins.pa)
                return -ENOMEM;
@@ -924,15 +924,15 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np,
        if (!nconfs)
                return 0;
 
-       func->conf = devm_kzalloc(pcs->dev,
-                                 sizeof(struct pcs_conf_vals) * nconfs,
+       func->conf = devm_kcalloc(pcs->dev,
+                                 nconfs, sizeof(struct pcs_conf_vals),
                                  GFP_KERNEL);
        if (!func->conf)
                return -ENOMEM;
        func->nconfs = nconfs;
        conf = &(func->conf[0]);
        m++;
-       settings = devm_kzalloc(pcs->dev, sizeof(unsigned long) * nconfs,
+       settings = devm_kcalloc(pcs->dev, nconfs, sizeof(unsigned long),
                                GFP_KERNEL);
        if (!settings)
                return -ENOMEM;
@@ -988,11 +988,11 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
                return -EINVAL;
        }
 
-       vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL);
+       vals = devm_kcalloc(pcs->dev, rows, sizeof(*vals), GFP_KERNEL);
        if (!vals)
                return -ENOMEM;
 
-       pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows, GFP_KERNEL);
+       pins = devm_kcalloc(pcs->dev, rows, sizeof(*pins), GFP_KERNEL);
        if (!pins)
                goto free_vals;
 
@@ -1089,13 +1089,15 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
 
        npins_in_row = pcs->width / pcs->bits_per_pin;
 
-       vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row,
-                       GFP_KERNEL);
+       vals = devm_kzalloc(pcs->dev,
+                           array3_size(rows, npins_in_row, sizeof(*vals)),
+                           GFP_KERNEL);
        if (!vals)
                return -ENOMEM;
 
-       pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows * npins_in_row,
-                       GFP_KERNEL);
+       pins = devm_kzalloc(pcs->dev,
+                           array3_size(rows, npins_in_row, sizeof(*pins)),
+                           GFP_KERNEL);
        if (!pins)
                goto free_vals;
 
@@ -1217,7 +1219,7 @@ static int pcs_dt_node_to_map(struct pinctrl_dev *pctldev,
        pcs = pinctrl_dev_get_drvdata(pctldev);
 
        /* create 2 maps. One is for pinmux, and the other is for pinconf. */
-       *map = devm_kzalloc(pcs->dev, sizeof(**map) * 2, GFP_KERNEL);
+       *map = devm_kcalloc(pcs->dev, 2, sizeof(**map), GFP_KERNEL);
        if (!*map)
                return -ENOMEM;
 
index 2081c67667a88b3a7927e4c3e4bc7a753787f043..0966bb0bf71fb6dc6618340d51286d914a82a7e4 100644 (file)
@@ -823,8 +823,8 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
        }
 
        map_num = grp->npins + 1;
-       new_map = devm_kzalloc(pctldev->dev,
-                               sizeof(*new_map) * map_num, GFP_KERNEL);
+       new_map = devm_kcalloc(pctldev->dev,
+                               map_num, sizeof(*new_map), GFP_KERNEL);
        if (!new_map)
                return -ENOMEM;
 
@@ -1191,9 +1191,9 @@ static int st_pctl_dt_parse_groups(struct device_node *np,
 
        grp->npins = npins;
        grp->name = np->name;
-       grp->pins = devm_kzalloc(info->dev, npins * sizeof(u32), GFP_KERNEL);
-       grp->pin_conf = devm_kzalloc(info->dev,
-                                       npins * sizeof(*conf), GFP_KERNEL);
+       grp->pins = devm_kcalloc(info->dev, npins, sizeof(u32), GFP_KERNEL);
+       grp->pin_conf = devm_kcalloc(info->dev,
+                                       npins, sizeof(*conf), GFP_KERNEL);
 
        if (!grp->pins || !grp->pin_conf)
                return -ENOMEM;
@@ -1249,8 +1249,8 @@ static int st_pctl_parse_functions(struct device_node *np,
                dev_err(info->dev, "No groups defined\n");
                return -EINVAL;
        }
-       func->groups = devm_kzalloc(info->dev,
-                       func->ngroups * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(info->dev,
+                       func->ngroups, sizeof(char *), GFP_KERNEL);
        if (!func->groups)
                return -ENOMEM;
 
@@ -1573,14 +1573,15 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
        dev_info(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
        dev_info(&pdev->dev, "ngroups = %d\n", info->ngroups);
 
-       info->functions = devm_kzalloc(&pdev->dev,
-               info->nfunctions * sizeof(*info->functions), GFP_KERNEL);
+       info->functions = devm_kcalloc(&pdev->dev,
+               info->nfunctions, sizeof(*info->functions), GFP_KERNEL);
 
-       info->groups = devm_kzalloc(&pdev->dev,
-                       info->ngroups * sizeof(*info->groups) , GFP_KERNEL);
+       info->groups = devm_kcalloc(&pdev->dev,
+                       info->ngroups, sizeof(*info->groups),
+                       GFP_KERNEL);
 
-       info->banks = devm_kzalloc(&pdev->dev,
-                       info->nbanks * sizeof(*info->banks), GFP_KERNEL);
+       info->banks = devm_kcalloc(&pdev->dev,
+                       info->nbanks, sizeof(*info->banks), GFP_KERNEL);
 
        if (!info->functions || !info->groups || !info->banks)
                return -ENOMEM;
@@ -1608,8 +1609,8 @@ static int st_pctl_probe_dt(struct platform_device *pdev,
        }
 
        pctl_desc->npins = info->nbanks * ST_GPIO_PINS_PER_BANK;
-       pdesc = devm_kzalloc(&pdev->dev,
-                       sizeof(*pdesc) * pctl_desc->npins, GFP_KERNEL);
+       pdesc = devm_kcalloc(&pdev->dev,
+                       pctl_desc->npins, sizeof(*pdesc), GFP_KERNEL);
        if (!pdesc)
                return -ENOMEM;
 
index cd0f402c116460f8e7edf1d20815f764ce31abab..93f8bd04e7fe69ab92bb48c2715aa24371d315c3 100644 (file)
@@ -1727,8 +1727,8 @@ static int pinmux_xway_probe(struct platform_device *pdev)
        xway_chip.ngpio = xway_soc->pin_count;
 
        /* load our pad descriptors */
-       xway_info.pads = devm_kzalloc(&pdev->dev,
-                       sizeof(struct pinctrl_pin_desc) * xway_chip.ngpio,
+       xway_info.pads = devm_kcalloc(&pdev->dev,
+                       xway_chip.ngpio, sizeof(struct pinctrl_pin_desc),
                        GFP_KERNEL);
        if (!xway_info.pads)
                return -ENOMEM;
index 0a625a64ff5de87baa110a4d7acc3c8e9a5c860d..a263ddd94945d1cc377c5c264390f45494cbfd87 100644 (file)
@@ -491,8 +491,9 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
                        continue;
                }
 
-               weint_data = devm_kzalloc(dev, bank->nr_pins
-                                       * sizeof(*weint_data), GFP_KERNEL);
+               weint_data = devm_kcalloc(dev,
+                                         bank->nr_pins, sizeof(*weint_data),
+                                         GFP_KERNEL);
                if (!weint_data)
                        return -ENOMEM;
 
index 618945a0fd3807dee68486f9d8c206c03c068ab2..698c7d8c9a0864e2ad820b5422516a3a5c968462 100644 (file)
@@ -674,7 +674,7 @@ static struct samsung_pin_group *samsung_pinctrl_create_groups(
        const struct pinctrl_pin_desc *pdesc;
        int i;
 
-       groups = devm_kzalloc(dev, ctrldesc->npins * sizeof(*groups),
+       groups = devm_kcalloc(dev, ctrldesc->npins, sizeof(*groups),
                                GFP_KERNEL);
        if (!groups)
                return ERR_PTR(-EINVAL);
@@ -711,7 +711,7 @@ static int samsung_pinctrl_create_function(struct device *dev,
 
        func->name = func_np->full_name;
 
-       func->groups = devm_kzalloc(dev, npins * sizeof(char *), GFP_KERNEL);
+       func->groups = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL);
        if (!func->groups)
                return -ENOMEM;
 
@@ -768,7 +768,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions(
                }
        }
 
-       functions = devm_kzalloc(dev, func_cnt * sizeof(*functions),
+       functions = devm_kcalloc(dev, func_cnt, sizeof(*functions),
                                        GFP_KERNEL);
        if (!functions)
                return ERR_PTR(-ENOMEM);
@@ -860,8 +860,9 @@ static int samsung_pinctrl_register(struct platform_device *pdev,
        ctrldesc->pmxops = &samsung_pinmux_ops;
        ctrldesc->confops = &samsung_pinconf_ops;
 
-       pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
-                       drvdata->nr_pins, GFP_KERNEL);
+       pindesc = devm_kcalloc(&pdev->dev,
+                              drvdata->nr_pins, sizeof(*pindesc),
+                              GFP_KERNEL);
        if (!pindesc)
                return -ENOMEM;
        ctrldesc->pins = pindesc;
@@ -875,8 +876,10 @@ static int samsung_pinctrl_register(struct platform_device *pdev,
         * allocate space for storing the dynamically generated names for all
         * the pins which belong to this pin-controller.
         */
-       pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH *
-                                       drvdata->nr_pins, GFP_KERNEL);
+       pin_names = devm_kzalloc(&pdev->dev,
+                                array3_size(sizeof(char), PIN_NAME_LENGTH,
+                                            drvdata->nr_pins),
+                                GFP_KERNEL);
        if (!pin_names)
                return -ENOMEM;
 
index eb06981538b427d5747c79588228b799b09d7562..c671c3c4aca6c04f907eee096789b44a0a3e3aed 100644 (file)
@@ -57,7 +57,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc,
                return -EINVAL;
 
        /* Allocate memory windows and IRQs arrays. */
-       windows = devm_kzalloc(pfc->dev, num_windows * sizeof(*windows),
+       windows = devm_kcalloc(pfc->dev, num_windows, sizeof(*windows),
                               GFP_KERNEL);
        if (windows == NULL)
                return -ENOMEM;
@@ -66,7 +66,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc,
        pfc->windows = windows;
 
        if (num_irqs) {
-               irqs = devm_kzalloc(pfc->dev, num_irqs * sizeof(*irqs),
+               irqs = devm_kcalloc(pfc->dev, num_irqs, sizeof(*irqs),
                                    GFP_KERNEL);
                if (irqs == NULL)
                        return -ENOMEM;
@@ -444,7 +444,7 @@ static int sh_pfc_init_ranges(struct sh_pfc *pfc)
        }
 
        pfc->nr_ranges = nr_ranges;
-       pfc->ranges = devm_kzalloc(pfc->dev, sizeof(*pfc->ranges) * nr_ranges,
+       pfc->ranges = devm_kcalloc(pfc->dev, nr_ranges, sizeof(*pfc->ranges),
                                   GFP_KERNEL);
        if (pfc->ranges == NULL)
                return -ENOMEM;
index 946d9be50b62cb329250762780c809805ed79735..6ffdc6beb203c83dbbe0828c3357bfb50db80996 100644 (file)
@@ -107,7 +107,7 @@ static int gpio_setup_data_regs(struct sh_pfc_chip *chip)
        for (i = 0; pfc->info->data_regs[i].reg_width; ++i)
                ;
 
-       chip->regs = devm_kzalloc(pfc->dev, i * sizeof(*chip->regs),
+       chip->regs = devm_kcalloc(pfc->dev, i, sizeof(*chip->regs),
                                  GFP_KERNEL);
        if (chip->regs == NULL)
                return -ENOMEM;
@@ -224,8 +224,9 @@ static int gpio_pin_setup(struct sh_pfc_chip *chip)
        struct gpio_chip *gc = &chip->gpio_chip;
        int ret;
 
-       chip->pins = devm_kzalloc(pfc->dev, pfc->info->nr_pins *
-                                 sizeof(*chip->pins), GFP_KERNEL);
+       chip->pins = devm_kcalloc(pfc->dev,
+                                 pfc->info->nr_pins, sizeof(*chip->pins),
+                                 GFP_KERNEL);
        if (chip->pins == NULL)
                return -ENOMEM;
 
index 70db21638901914ff53da83f1eb90dac222a3c9a..654dc20e171b9363e3e8227a7df55ef775866848 100644 (file)
@@ -770,14 +770,14 @@ static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
        unsigned int i;
 
        /* Allocate and initialize the pins and configs arrays. */
-       pmx->pins = devm_kzalloc(pfc->dev,
-                                sizeof(*pmx->pins) * pfc->info->nr_pins,
+       pmx->pins = devm_kcalloc(pfc->dev,
+                                pfc->info->nr_pins, sizeof(*pmx->pins),
                                 GFP_KERNEL);
        if (unlikely(!pmx->pins))
                return -ENOMEM;
 
-       pmx->configs = devm_kzalloc(pfc->dev,
-                                   sizeof(*pmx->configs) * pfc->info->nr_pins,
+       pmx->configs = devm_kcalloc(pfc->dev,
+                                   pfc->info->nr_pins, sizeof(*pmx->configs),
                                    GFP_KERNEL);
        if (unlikely(!pmx->configs))
                return -ENOMEM;
index ca2347d0d57946574840ee778f2f4124b388c328..505845c66dd01930517c99563b6ea972ebe7262a 100644 (file)
@@ -108,7 +108,7 @@ static int sirfsoc_dt_node_to_map(struct pinctrl_dev *pctldev,
                return -ENODEV;
        }
 
-       *map = kzalloc(sizeof(**map) * count, GFP_KERNEL);
+       *map = kcalloc(count, sizeof(**map), GFP_KERNEL);
        if (!*map)
                return -ENOMEM;
 
index d2123e396b29c8e7bd8557dc623a496f19faa3d7..9d906474f3e448b30f948c77d91de5e83f48ab3d 100644 (file)
@@ -538,9 +538,9 @@ static int plgpio_probe(struct platform_device *pdev)
                dev_warn(&pdev->dev, "clk_get() failed, work without it\n");
 
 #ifdef CONFIG_PM_SLEEP
-       plgpio->csave_regs = devm_kzalloc(&pdev->dev,
-                       sizeof(*plgpio->csave_regs) *
+       plgpio->csave_regs = devm_kcalloc(&pdev->dev,
                        DIV_ROUND_UP(plgpio->chip.ngpio, MAX_GPIO_PER_REG),
+                       sizeof(*plgpio->csave_regs),
                        GFP_KERNEL);
        if (!plgpio->csave_regs)
                return -ENOMEM;
index efe79d3f76596102a5c264c3065e37c4ccbdc3ab..c4f850345dc462c8886195982a0537d7e36b312f 100644 (file)
@@ -172,7 +172,7 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
                return -ENODEV;
        }
 
-       *map = kzalloc(sizeof(**map) * count, GFP_KERNEL);
+       *map = kcalloc(count, sizeof(**map), GFP_KERNEL);
        if (!*map)
                return -ENOMEM;
 
index ba1c2ca406e42450d6c1fe04fe5922fca4bae29b..78c2f548b25f1ef5dc3cbe702f2ef8db10416523 100644 (file)
@@ -879,8 +879,9 @@ static int sprd_pinctrl_parse_groups(struct device_node *np,
 
        grp->name = np->name;
        grp->npins = ret;
-       grp->pins = devm_kzalloc(sprd_pctl->dev, grp->npins *
-                                sizeof(unsigned int), GFP_KERNEL);
+       grp->pins = devm_kcalloc(sprd_pctl->dev,
+                                grp->npins, sizeof(unsigned int),
+                                GFP_KERNEL);
        if (!grp->pins)
                return -ENOMEM;
 
@@ -931,14 +932,15 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl)
        if (!info->ngroups)
                return 0;
 
-       info->groups = devm_kzalloc(sprd_pctl->dev, info->ngroups *
+       info->groups = devm_kcalloc(sprd_pctl->dev,
+                                   info->ngroups,
                                    sizeof(struct sprd_pin_group),
                                    GFP_KERNEL);
        if (!info->groups)
                return -ENOMEM;
 
-       info->grp_names = devm_kzalloc(sprd_pctl->dev,
-                                      info->ngroups * sizeof(char *),
+       info->grp_names = devm_kcalloc(sprd_pctl->dev,
+                                      info->ngroups, sizeof(char *),
                                       GFP_KERNEL);
        if (!info->grp_names)
                return -ENOMEM;
@@ -980,8 +982,8 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl,
        int i;
 
        info->npins = pins_cnt;
-       info->pins = devm_kzalloc(sprd_pctl->dev,
-                                 info->npins * sizeof(struct sprd_pin),
+       info->pins = devm_kcalloc(sprd_pctl->dev,
+                                 info->npins, sizeof(struct sprd_pin),
                                  GFP_KERNEL);
        if (!info->pins)
                return -ENOMEM;
@@ -1057,7 +1059,8 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev,
                return ret;
        }
 
-       pin_desc = devm_kzalloc(&pdev->dev, pinctrl_info->npins *
+       pin_desc = devm_kcalloc(&pdev->dev,
+                               pinctrl_info->npins,
                                sizeof(struct pinctrl_pin_desc),
                                GFP_KERNEL);
        if (!pin_desc)
index 25e80a5370ca02f65999abd8932aec8b6aa05fc6..4d9bf9b3e9f3e45d8e7d1eeeeedf4cb88181b46f 100644 (file)
@@ -277,7 +277,7 @@ static unsigned long *sunxi_pctrl_build_pin_config(struct device_node *node,
        if (!configlen)
                return NULL;
 
-       pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL);
+       pinconfig = kcalloc(configlen, sizeof(*pinconfig), GFP_KERNEL);
        if (!pinconfig)
                return ERR_PTR(-ENOMEM);
 
@@ -352,7 +352,7 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev,
         * any configuration.
         */
        nmaps = npins * 2;
-       *map = kmalloc(nmaps * sizeof(struct pinctrl_map), GFP_KERNEL);
+       *map = kmalloc_array(nmaps, sizeof(struct pinctrl_map), GFP_KERNEL);
        if (!*map)
                return -ENOMEM;
 
@@ -1055,8 +1055,8 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
         * this means that the number of pins is the maximum group
         * number we will ever see.
         */
-       pctl->groups = devm_kzalloc(&pdev->dev,
-                                   pctl->desc->npins * sizeof(*pctl->groups),
+       pctl->groups = devm_kcalloc(&pdev->dev,
+                                   pctl->desc->npins, sizeof(*pctl->groups),
                                    GFP_KERNEL);
        if (!pctl->groups)
                return -ENOMEM;
@@ -1079,8 +1079,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
         * We suppose that we won't have any more functions than pins,
         * we'll reallocate that later anyway
         */
-       pctl->functions = devm_kzalloc(&pdev->dev,
-                                      pctl->ngroups * sizeof(*pctl->functions),
+       pctl->functions = devm_kcalloc(&pdev->dev,
+                                      pctl->ngroups,
+                                      sizeof(*pctl->functions),
                                       GFP_KERNEL);
        if (!pctl->functions)
                return -ENOMEM;
@@ -1137,8 +1138,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev)
 
                        if (!func_item->groups) {
                                func_item->groups =
-                                       devm_kzalloc(&pdev->dev,
-                                                    func_item->ngroups * sizeof(*func_item->groups),
+                                       devm_kcalloc(&pdev->dev,
+                                                    func_item->ngroups,
+                                                    sizeof(*func_item->groups),
                                                     GFP_KERNEL);
                                if (!func_item->groups)
                                        return -ENOMEM;
@@ -1281,8 +1283,8 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev,
                return ret;
        }
 
-       pins = devm_kzalloc(&pdev->dev,
-                           pctl->desc->npins * sizeof(*pins),
+       pins = devm_kcalloc(&pdev->dev,
+                           pctl->desc->npins, sizeof(*pins),
                            GFP_KERNEL);
        if (!pins)
                return -ENOMEM;
index 49c7c1499bc3cddee80102f0fd83d5f4ab551569..f974eee29a1988c4a6f152c7246ccec3c4d490f9 100644 (file)
@@ -665,8 +665,8 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
         * Each mux group will appear in 4 functions' list of groups.
         * This over-allocates slightly, since not all groups are mux groups.
         */
-       pmx->group_pins = devm_kzalloc(&pdev->dev,
-               soc_data->ngroups * 4 * sizeof(*pmx->group_pins),
+       pmx->group_pins = devm_kcalloc(&pdev->dev,
+               soc_data->ngroups * 4, sizeof(*pmx->group_pins),
                GFP_KERNEL);
        if (!pmx->group_pins)
                return -ENOMEM;
@@ -708,7 +708,7 @@ int tegra_pinctrl_probe(struct platform_device *pdev,
        }
        pmx->nbanks = i;
 
-       pmx->regs = devm_kzalloc(&pdev->dev, pmx->nbanks * sizeof(*pmx->regs),
+       pmx->regs = devm_kcalloc(&pdev->dev, pmx->nbanks, sizeof(*pmx->regs),
                                 GFP_KERNEL);
        if (!pmx->regs)
                return -ENOMEM;
index a8a6510183b692e95972206a9b4618547e9f1b6e..8782c348ebe9443d8e0ec2df3298d8100a38cb00 100644 (file)
@@ -510,11 +510,11 @@ static int ti_iodelay_dt_node_to_map(struct pinctrl_dev *pctldev,
                goto free_map;
        }
 
-       pins = devm_kzalloc(iod->dev, sizeof(*pins) * rows, GFP_KERNEL);
+       pins = devm_kcalloc(iod->dev, rows, sizeof(*pins), GFP_KERNEL);
        if (!pins)
                goto free_group;
 
-       cfg = devm_kzalloc(iod->dev, sizeof(*cfg) * rows, GFP_KERNEL);
+       cfg = devm_kcalloc(iod->dev, rows, sizeof(*cfg), GFP_KERNEL);
        if (!cfg) {
                error = -ENOMEM;
                goto free_pins;
@@ -749,7 +749,7 @@ static int ti_iodelay_alloc_pins(struct device *dev,
        nr_pins = ti_iodelay_offset_to_pin(iod, r->regmap_config->max_register);
        dev_dbg(dev, "Allocating %i pins\n", nr_pins);
 
-       iod->pa = devm_kzalloc(dev, sizeof(*iod->pa) * nr_pins, GFP_KERNEL);
+       iod->pa = devm_kcalloc(dev, nr_pins, sizeof(*iod->pa), GFP_KERNEL);
        if (!iod->pa)
                return -ENOMEM;
 
index d73956bdc21136ff29361bd2858391b2ae174bcf..c08318a5a91b6a7a201ce44c43424aa93ae03445 100644 (file)
@@ -352,7 +352,7 @@ static int wmt_pctl_dt_node_to_map(struct pinctrl_dev *pctldev,
        if (num_pulls)
                maps_per_pin++;
 
-       cur_map = maps = kzalloc(num_pins * maps_per_pin * sizeof(*maps),
+       cur_map = maps = kcalloc(num_pins * maps_per_pin, sizeof(*maps),
                                 GFP_KERNEL);
        if (!maps)
                return -ENOMEM;
index ded366bb6564d8bda1ff37a65845ed72ea265970..caa44dd2880a824c03c1366742287d1398b10f54 100644 (file)
@@ -277,7 +277,7 @@ static int zx_pinctrl_build_state(struct platform_device *pdev)
 
        /* Every single pin composes a group */
        ngroups = info->npins;
-       groups = devm_kzalloc(&pdev->dev, ngroups * sizeof(*groups),
+       groups = devm_kcalloc(&pdev->dev, ngroups, sizeof(*groups),
                              GFP_KERNEL);
        if (!groups)
                return -ENOMEM;
@@ -362,8 +362,8 @@ static int zx_pinctrl_build_state(struct platform_device *pdev)
 
                        func = functions + j;
                        if (!func->group_names) {
-                               func->group_names = devm_kzalloc(&pdev->dev,
-                                               func->num_group_names *
+                               func->group_names = devm_kcalloc(&pdev->dev,
+                                               func->num_group_names,
                                                sizeof(*func->group_names),
                                                GFP_KERNEL);
                                if (!func->group_names) {
index cc265ed8deb7f8aa7926566f26ac27aafb925196..c62ee8e610a0fcd307718f38cabe998a669ab8ea 100644 (file)
@@ -470,3 +470,23 @@ void cros_ec_debugfs_remove(struct cros_ec_dev *ec)
        cros_ec_cleanup_console_log(ec->debug_info);
 }
 EXPORT_SYMBOL(cros_ec_debugfs_remove);
+
+void cros_ec_debugfs_suspend(struct cros_ec_dev *ec)
+{
+       /*
+        * cros_ec_debugfs_init() failures are non-fatal; it's also possible
+        * that we initted things but decided that console log wasn't supported.
+        * We'll use the same set of checks that cros_ec_debugfs_remove() +
+        * cros_ec_cleanup_console_log() end up using to handle those cases.
+        */
+       if (ec->debug_info && ec->debug_info->log_buffer.buf)
+               cancel_delayed_work_sync(&ec->debug_info->log_poll_work);
+}
+EXPORT_SYMBOL(cros_ec_debugfs_suspend);
+
+void cros_ec_debugfs_resume(struct cros_ec_dev *ec)
+{
+       if (ec->debug_info && ec->debug_info->log_buffer.buf)
+               schedule_delayed_work(&ec->debug_info->log_poll_work, 0);
+}
+EXPORT_SYMBOL(cros_ec_debugfs_resume);
index ea9e7f4479cad668dc261ee4386dee272f729888..ac97aa020db326dfc32ce821943ff37e2d77749c 100644 (file)
 #define MLXREG_HOTPLUG_RST_CNTR                3
 
 #define MLXREG_HOTPLUG_ATTRS_MAX       24
+#define MLXREG_HOTPLUG_NOT_ASSERT      3
 
 /**
  * struct mlxreg_hotplug_priv_data - platform private data:
  * @irq: platform device interrupt number;
+ * @dev: basic device;
  * @pdev: platform device;
  * @plat: platform data;
- * @dwork: delayed work template;
+ * @regmap: register map handle;
+ * @dwork_irq: delayed work template;
  * @lock: spin lock;
  * @hwmon: hwmon device;
  * @mlxreg_hotplug_attr: sysfs attributes array;
@@ -71,6 +74,8 @@
  * @cell: location of top aggregation interrupt register;
  * @mask: top aggregation interrupt common mask;
  * @aggr_cache: last value of aggregation register status;
+ * @after_probe: flag indication probing completion;
+ * @not_asserted: number of entries in workqueue with no signal assertion;
  */
 struct mlxreg_hotplug_priv_data {
        int irq;
@@ -79,7 +84,6 @@ struct mlxreg_hotplug_priv_data {
        struct mlxreg_hotplug_platform_data *plat;
        struct regmap *regmap;
        struct delayed_work dwork_irq;
-       struct delayed_work dwork;
        spinlock_t lock; /* sync with interrupt */
        struct device *hwmon;
        struct attribute *mlxreg_hotplug_attr[MLXREG_HOTPLUG_ATTRS_MAX + 1];
@@ -91,6 +95,7 @@ struct mlxreg_hotplug_priv_data {
        u32 mask;
        u32 aggr_cache;
        bool after_probe;
+       u8 not_asserted;
 };
 
 static int mlxreg_hotplug_device_create(struct mlxreg_hotplug_priv_data *priv,
@@ -217,7 +222,8 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv)
                }
        }
 
-       priv->group.attrs = devm_kzalloc(&priv->pdev->dev, num_attrs *
+       priv->group.attrs = devm_kcalloc(&priv->pdev->dev,
+                                        num_attrs,
                                         sizeof(struct attribute *),
                                         GFP_KERNEL);
        if (!priv->group.attrs)
@@ -408,6 +414,18 @@ static void mlxreg_hotplug_work_handler(struct work_struct *work)
        aggr_asserted = priv->aggr_cache ^ regval;
        priv->aggr_cache = regval;
 
+       /*
+        * Handler is invoked, but no assertion is detected at top aggregation
+        * status level. Set aggr_asserted to mask value to allow handler extra
+        * run over all relevant signals to recover any missed signal.
+        */
+       if (priv->not_asserted == MLXREG_HOTPLUG_NOT_ASSERT) {
+               priv->not_asserted = 0;
+               aggr_asserted = pdata->mask;
+       }
+       if (!aggr_asserted)
+               goto unmask_event;
+
        /* Handle topology and health configuration changes. */
        for (i = 0; i < pdata->counter; i++, item++) {
                if (aggr_asserted & item->aggr_mask) {
@@ -418,27 +436,26 @@ static void mlxreg_hotplug_work_handler(struct work_struct *work)
                }
        }
 
-       if (aggr_asserted) {
-               spin_lock_irqsave(&priv->lock, flags);
+       spin_lock_irqsave(&priv->lock, flags);
 
-               /*
-                * It is possible, that some signals have been inserted, while
-                * interrupt has been masked by mlxreg_hotplug_work_handler.
-                * In this case such signals will be missed. In order to handle
-                * these signals delayed work is canceled and work task
-                * re-scheduled for immediate execution. It allows to handle
-                * missed signals, if any. In other case work handler just
-                * validates that no new signals have been received during
-                * masking.
-                */
-               cancel_delayed_work(&priv->dwork_irq);
-               schedule_delayed_work(&priv->dwork_irq, 0);
+       /*
+        * It is possible, that some signals have been inserted, while
+        * interrupt has been masked by mlxreg_hotplug_work_handler. In this
+        * case such signals will be missed. In order to handle these signals
+        * delayed work is canceled and work task re-scheduled for immediate
+        * execution. It allows to handle missed signals, if any. In other case
+        * work handler just validates that no new signals have been received
+        * during masking.
+        */
+       cancel_delayed_work(&priv->dwork_irq);
+       schedule_delayed_work(&priv->dwork_irq, 0);
 
-               spin_unlock_irqrestore(&priv->lock, flags);
+       spin_unlock_irqrestore(&priv->lock, flags);
 
-               return;
-       }
+       return;
 
+unmask_event:
+       priv->not_asserted++;
        /* Unmask aggregation event (no need acknowledge). */
        ret = regmap_write(priv->regmap, pdata->cell +
                           MLXREG_HOTPLUG_AGGR_MASK_OFF, pdata->mask);
index f27cb186437dcc7214ca6985e5c0a3c13bc70592..ac4d4883041537c3f4c6124acd6b52f141b6c89a 100644 (file)
@@ -1052,7 +1052,7 @@ config SAMSUNG_LAPTOP
          function keys, wireless LED, LCD backlight level.
 
          It may also provide some sysfs files described in
-         <file:Documentation/ABI/testing/sysfs-platform-samsung-laptop>
+         <file:Documentation/ABI/testing/sysfs-driver-samsung-laptop>
 
          To compile this driver as a module, choose M here: the module
          will be called samsung-laptop.
index 1be71f956d5c2872a1c31d77482bf65ddcb733a1..8952173dd380b6e650c6d54dd6498660286f0a27 100644 (file)
@@ -129,6 +129,7 @@ static const struct key_entry acer_wmi_keymap[] __initconst = {
        {KE_IGNORE, 0x83, {KEY_TOUCHPAD_TOGGLE} },
        {KE_KEY, 0x85, {KEY_TOUCHPAD_TOGGLE} },
        {KE_KEY, 0x86, {KEY_WLAN} },
+       {KE_KEY, 0x87, {KEY_POWER} },
        {KE_END, 0}
 };
 
index 9d7dbd925065c2f9e5321431d93e97d71b7b20ce..d975462a4c576748eb6163f512a607d4d3b8d19e 100644 (file)
@@ -458,19 +458,19 @@ static int alienware_zone_init(struct platform_device *dev)
         *      - zone_data num_zones is for the distinct zones
         */
        zone_dev_attrs =
-           kzalloc(sizeof(struct device_attribute) * (quirks->num_zones + 1),
+           kcalloc(quirks->num_zones + 1, sizeof(struct device_attribute),
                    GFP_KERNEL);
        if (!zone_dev_attrs)
                return -ENOMEM;
 
        zone_attrs =
-           kzalloc(sizeof(struct attribute *) * (quirks->num_zones + 2),
+           kcalloc(quirks->num_zones + 2, sizeof(struct attribute *),
                    GFP_KERNEL);
        if (!zone_attrs)
                return -ENOMEM;
 
        zone_data =
-           kzalloc(sizeof(struct platform_zone) * (quirks->num_zones),
+           kcalloc(quirks->num_zones, sizeof(struct platform_zone),
                    GFP_KERNEL);
        if (!zone_data)
                return -ENOMEM;
index 7c4eb86c851ed9568cb882d32a9a5fdd3a0d13a0..fd2ffebc868fc7ed6ae2c55a899debbf1c5041bd 100644 (file)
@@ -495,7 +495,7 @@ static int gmux_set_power_state(enum vga_switcheroo_client_id id,
        return gmux_set_discrete_state(apple_gmux_data, state);
 }
 
-static int gmux_get_client_id(struct pci_dev *pdev)
+static enum vga_switcheroo_client_id gmux_get_client_id(struct pci_dev *pdev)
 {
        /*
         * Early Macbook Pros with switchable graphics use nvidia
index c4768be24ba9c402b8d4e0163008e11bc64d4ac1..700c48ddfa7c099b79c8d040954e8b2a35e5164c 100644 (file)
@@ -1593,8 +1593,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
                                    int idx)
 {
        struct device *dev = container_of(kobj, struct device, kobj);
-       struct platform_device *pdev = to_platform_device(dev);
-       struct asus_laptop *asus = platform_get_drvdata(pdev);
+       struct asus_laptop *asus = dev_get_drvdata(dev);
        acpi_handle handle = asus->handle;
        bool supported;
 
index f086469ea740987dec7c9996b982968491fa3140..6afd011de9e514ef05e13c6a5912ff2e78c2be00 100644 (file)
@@ -72,7 +72,7 @@ static u64 asus_wireless_method(acpi_handle handle, const char *method,
                acpi_handle_err(handle,
                                "Failed to eval method %s, param %#x (%d)\n",
                                method, param, s);
-       acpi_handle_debug(handle, "%s returned %#x\n", method, (uint) ret);
+       acpi_handle_debug(handle, "%s returned %#llx\n", method, ret);
        return ret;
 }
 
index ffffb9909ae1527a06ef7d68fc42a6c55b77b7ed..3d523ca6469462f4dba34935904c2ea66326a630 100644 (file)
@@ -1875,8 +1875,7 @@ static umode_t asus_sysfs_is_visible(struct kobject *kobj,
                                    struct attribute *attr, int idx)
 {
        struct device *dev = container_of(kobj, struct device, kobj);
-       struct platform_device *pdev = to_platform_device(dev);
-       struct asus_wmi *asus = platform_get_drvdata(pdev);
+       struct asus_wmi *asus = dev_get_drvdata(dev);
        bool ok = true;
        int devid = -1;
 
index c52c6723374b50b26041d7681c3d9ae3564d50ce..f1fa8612db406168f53db3d71a025255c0622af0 100644 (file)
@@ -38,6 +38,7 @@
 struct quirk_entry {
        bool touchpad_led;
        bool kbd_led_levels_off_1;
+       bool kbd_missing_ac_tag;
 
        bool needs_kbd_timeouts;
        /*
@@ -68,6 +69,10 @@ static struct quirk_entry quirk_dell_xps13_9333 = {
        .kbd_timeouts = { 0, 5, 15, 60, 5 * 60, 15 * 60, -1 },
 };
 
+static struct quirk_entry quirk_dell_xps13_9370 = {
+       .kbd_missing_ac_tag = true,
+};
+
 static struct quirk_entry quirk_dell_latitude_e6410 = {
        .kbd_led_levels_off_1 = true,
 };
@@ -291,6 +296,15 @@ static const struct dmi_system_id dell_quirks[] __initconst = {
                },
                .driver_data = &quirk_dell_xps13_9333,
        },
+       {
+               .callback = dmi_matched,
+               .ident = "Dell XPS 13 9370",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "XPS 13 9370"),
+               },
+               .driver_data = &quirk_dell_xps13_9370,
+       },
        {
                .callback = dmi_matched,
                .ident = "Dell Latitude E6410",
@@ -1401,7 +1415,8 @@ static inline int kbd_init_info(void)
         *       timeout value which is shared for both battery and AC power
         *       settings. So do not try to set AC values on old models.
         */
-       if (dell_smbios_find_token(KBD_LED_AC_TOKEN))
+       if ((quirks && quirks->kbd_missing_ac_tag) ||
+           dell_smbios_find_token(KBD_LED_AC_TOKEN))
                kbd_timeout_ac_supported = true;
 
        kbd_get_state(&state);
index 33fb2a20458a58fba2bee9ce79ad7571c184c7f3..9dc282ed5a9e1db7d926348ea30bd7905893a27c 100644 (file)
@@ -555,11 +555,10 @@ static void free_group(struct platform_device *pdev)
 
 static int __init dell_smbios_init(void)
 {
-       const struct dmi_device *valid;
        int ret, wmi, smm;
 
-       valid = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, "Dell System", NULL);
-       if (!valid) {
+       if (!dmi_find_device(DMI_DEV_TYPE_OEM_STRING, "Dell System", NULL) &&
+           !dmi_find_device(DMI_DEV_TYPE_OEM_STRING, "www.dell.com", NULL)) {
                pr_err("Unable to run on non-Dell system\n");
                return -ENODEV;
        }
index 8d102195a3927fa4bf76f4230d069d6038414923..16c7f3d9a3352ec48d72f877e2e7486ea78250c7 100644 (file)
@@ -233,7 +233,7 @@ static const u16 bios_to_linux_keycode[256] = {
        [18]    = KEY_PROG1,
        [19]    = KEY_BRIGHTNESSDOWN,
        [20]    = KEY_BRIGHTNESSUP,
-       [21]    = KEY_UNKNOWN,
+       [21]    = KEY_BRIGHTNESS_AUTO,
        [22]    = KEY_KBDILLUMTOGGLE,
        [23]    = KEY_UNKNOWN,
        [24]    = KEY_SWITCHVIDEOMODE,
@@ -261,6 +261,12 @@ static const u16 bios_to_linux_keycode[256] = {
  * override them.
  */
 static const struct key_entry dell_wmi_keymap_type_0010[] = {
+       /* Fn-lock switched to function keys */
+       { KE_IGNORE, 0x0, { KEY_RESERVED } },
+
+       /* Fn-lock switched to multimedia keys */
+       { KE_IGNORE, 0x1, { KEY_RESERVED } },
+
        /* Mic mute */
        { KE_KEY, 0x150, { KEY_MICMUTE } },
 
@@ -296,6 +302,14 @@ static const struct key_entry dell_wmi_keymap_type_0010[] = {
        { KE_KEY,    0x851, { KEY_PROG2 } },
        { KE_KEY,    0x852, { KEY_PROG3 } },
 
+       /*
+        * Radio disable (notify only -- there is no model for which the
+        * WMI event is supposed to trigger an action).
+        */
+       { KE_IGNORE, 0xe008, { KEY_RFKILL } },
+
+       /* Fn-lock */
+       { KE_IGNORE, 0xe035, { KEY_RESERVED } },
 };
 
 /*
index cd95b6f3a06405835edadfc6ea92a5b46bab591f..6afeaece2f50ca4deec027577631a787c274b7fb 100644 (file)
@@ -91,6 +91,9 @@
 #define FLAG_RFKILL                    BIT(5)
 #define FLAG_LID                       BIT(8)
 #define FLAG_DOCK                      BIT(9)
+#define FLAG_TOUCHPAD_TOGGLE           BIT(26)
+#define FLAG_MICMUTE                   BIT(29)
+#define FLAG_SOFTKEYS                  (FLAG_RFKILL | FLAG_TOUCHPAD_TOGGLE | FLAG_MICMUTE)
 
 /* FUNC interface - LED control */
 #define FUNC_LED_OFF                   BIT(0)
@@ -456,14 +459,15 @@ static void acpi_fujitsu_bl_notify(struct acpi_device *device, u32 event)
 /* ACPI device for hotkey handling */
 
 static const struct key_entry keymap_default[] = {
-       { KE_KEY, KEY1_CODE, { KEY_PROG1 } },
-       { KE_KEY, KEY2_CODE, { KEY_PROG2 } },
-       { KE_KEY, KEY3_CODE, { KEY_PROG3 } },
-       { KE_KEY, KEY4_CODE, { KEY_PROG4 } },
-       { KE_KEY, KEY5_CODE, { KEY_RFKILL } },
-       { KE_KEY, BIT(5),    { KEY_RFKILL } },
-       { KE_KEY, BIT(26),   { KEY_TOUCHPAD_TOGGLE } },
-       { KE_KEY, BIT(29),   { KEY_MICMUTE } },
+       { KE_KEY, KEY1_CODE,            { KEY_PROG1 } },
+       { KE_KEY, KEY2_CODE,            { KEY_PROG2 } },
+       { KE_KEY, KEY3_CODE,            { KEY_PROG3 } },
+       { KE_KEY, KEY4_CODE,            { KEY_PROG4 } },
+       { KE_KEY, KEY5_CODE,            { KEY_RFKILL } },
+       /* Soft keys read from status flags */
+       { KE_KEY, FLAG_RFKILL,          { KEY_RFKILL } },
+       { KE_KEY, FLAG_TOUCHPAD_TOGGLE, { KEY_TOUCHPAD_TOGGLE } },
+       { KE_KEY, FLAG_MICMUTE,         { KEY_MICMUTE } },
        { KE_END, 0 }
 };
 
@@ -903,7 +907,8 @@ static void acpi_fujitsu_laptop_release(struct acpi_device *device)
 static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event)
 {
        struct fujitsu_laptop *priv = acpi_driver_data(device);
-       int scancode, i = 0, ret;
+       unsigned long flags;
+       int scancode, i = 0;
        unsigned int irb;
 
        if (event != ACPI_FUJITSU_NOTIFY_CODE) {
@@ -930,21 +935,17 @@ static void acpi_fujitsu_laptop_notify(struct acpi_device *device, u32 event)
                                         "Unknown GIRB result [%x]\n", irb);
        }
 
-       /* On some models (first seen on the Skylake-based Lifebook
-        * E736/E746/E756), the touchpad toggle hotkey (Fn+F4) is
-        * handled in software; its state is queried using FUNC_FLAGS
+       /*
+        * First seen on the Skylake-based Lifebook E736/E746/E756), the
+        * touchpad toggle hotkey (Fn+F4) is handled in software. Other models
+        * have since added additional "soft keys". These are reported in the
+        * status flags queried using FUNC_FLAGS.
         */
-       if (priv->flags_supported & (BIT(5) | BIT(26) | BIT(29))) {
-               ret = call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0);
-               if (ret & BIT(5))
-                       sparse_keymap_report_event(priv->input,
-                                                  BIT(5), 1, true);
-               if (ret & BIT(26))
-                       sparse_keymap_report_event(priv->input,
-                                                  BIT(26), 1, true);
-               if (ret & BIT(29))
-                       sparse_keymap_report_event(priv->input,
-                                                  BIT(29), 1, true);
+       if (priv->flags_supported & (FLAG_SOFTKEYS)) {
+               flags = call_fext_func(device, FUNC_FLAGS, 0x1, 0x0, 0x0);
+               flags &= (FLAG_SOFTKEYS);
+               for_each_set_bit(i, &flags, BITS_PER_LONG)
+                       sparse_keymap_report_event(priv->input, BIT(i), 1, true);
        }
 }
 
index 535199c9e6bc6fa182ea9612fcabf85a7ba02ba8..45b7cb01f4101ee8526ac5f4f7f86a626959f220 100644 (file)
@@ -43,6 +43,7 @@
 #define IDEAPAD_RFKILL_DEV_NUM (3)
 
 #define BM_CONSERVATION_BIT (5)
+#define HA_FNLOCK_BIT       (10)
 
 #define CFG_BT_BIT     (16)
 #define CFG_3G_BIT     (17)
@@ -59,6 +60,8 @@ static const char *const ideapad_wmi_fnesc_events[] = {
 enum {
        BMCMD_CONSERVATION_ON = 3,
        BMCMD_CONSERVATION_OFF = 5,
+       HACMD_FNLOCK_ON = 0xe,
+       HACMD_FNLOCK_OFF = 0xf,
 };
 
 enum {
@@ -139,11 +142,11 @@ static int method_gbmd(acpi_handle handle, unsigned long *ret)
        return result;
 }
 
-static int method_sbmc(acpi_handle handle, int cmd)
+static int method_int1(acpi_handle handle, char *method, int cmd)
 {
        acpi_status status;
 
-       status = acpi_execute_simple_method(handle, "SBMC", cmd);
+       status = acpi_execute_simple_method(handle, method, cmd);
        return ACPI_FAILURE(status) ? -1 : 0;
 }
 
@@ -487,7 +490,7 @@ static ssize_t conservation_mode_store(struct device *dev,
        if (ret)
                return ret;
 
-       ret = method_sbmc(priv->adev->handle, state ?
+       ret = method_int1(priv->adev->handle, "SBMC", state ?
                                              BMCMD_CONSERVATION_ON :
                                              BMCMD_CONSERVATION_OFF);
        if (ret < 0)
@@ -497,11 +500,51 @@ static ssize_t conservation_mode_store(struct device *dev,
 
 static DEVICE_ATTR_RW(conservation_mode);
 
+static ssize_t fn_lock_show(struct device *dev,
+                           struct device_attribute *attr,
+                           char *buf)
+{
+       struct ideapad_private *priv = dev_get_drvdata(dev);
+       unsigned long result;
+       int hals;
+       int fail = read_method_int(priv->adev->handle, "HALS", &hals);
+
+       if (fail)
+               return sprintf(buf, "-1\n");
+
+       result = hals;
+       return sprintf(buf, "%u\n", test_bit(HA_FNLOCK_BIT, &result));
+}
+
+static ssize_t fn_lock_store(struct device *dev,
+                            struct device_attribute *attr,
+                            const char *buf, size_t count)
+{
+       struct ideapad_private *priv = dev_get_drvdata(dev);
+       bool state;
+       int ret;
+
+       ret = kstrtobool(buf, &state);
+       if (ret)
+               return ret;
+
+       ret = method_int1(priv->adev->handle, "SALS", state ?
+                         HACMD_FNLOCK_ON :
+                         HACMD_FNLOCK_OFF);
+       if (ret < 0)
+               return -EIO;
+       return count;
+}
+
+static DEVICE_ATTR_RW(fn_lock);
+
+
 static struct attribute *ideapad_attributes[] = {
        &dev_attr_camera_power.attr,
        &dev_attr_fan_mode.attr,
        &dev_attr_touchpad.attr,
        &dev_attr_conservation_mode.attr,
+       &dev_attr_fn_lock.attr,
        NULL
 };
 
@@ -522,6 +565,9 @@ static umode_t ideapad_is_visible(struct kobject *kobj,
        } else if (attr == &dev_attr_conservation_mode.attr) {
                supported = acpi_has_method(priv->adev->handle, "GBMD") &&
                            acpi_has_method(priv->adev->handle, "SBMC");
+       } else if (attr == &dev_attr_fn_lock.attr) {
+               supported = acpi_has_method(priv->adev->handle, "HALS") &&
+                       acpi_has_method(priv->adev->handle, "SALS");
        } else
                supported = true;
 
@@ -1079,6 +1125,13 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
                        DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo ideapad Y700-17ISK"),
                },
        },
+       {
+               .ident = "Lenovo ideapad MIIX 720-12IKB",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+                       DMI_MATCH(DMI_PRODUCT_VERSION, "MIIX 720-12IKB"),
+               },
+       },
        {
                .ident = "Lenovo Legion Y520-15IKBN",
                .matches = {
@@ -1163,6 +1216,13 @@ static const struct dmi_system_id no_hw_rfkill_list[] = {
                        DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo YOGA 920-13IKB"),
                },
        },
+       {
+               .ident = "Lenovo Zhaoyang E42-80",
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
+                       DMI_MATCH(DMI_PRODUCT_VERSION, "ZHAOYANG E42-80"),
+               },
+       },
        {}
 };
 
index a0c95853fd3f98abbe1979ad2478d6b781c7b046..014fc1634a3d856300e4c439c6b5c0c20a699b58 100644 (file)
@@ -964,12 +964,12 @@ static int ips_monitor(void *data)
        u16 *mcp_samples, *ctv1_samples, *ctv2_samples, *mch_samples;
        u8 cur_seqno, last_seqno;
 
-       mcp_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
-       ctv1_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
-       ctv2_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
-       mch_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
-       cpu_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL);
-       mchp_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL);
+       mcp_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL);
+       ctv1_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL);
+       ctv2_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL);
+       mch_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL);
+       cpu_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u32), GFP_KERNEL);
+       mchp_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u32), GFP_KERNEL);
        if (!mcp_samples || !ctv1_samples || !ctv2_samples || !mch_samples ||
                        !cpu_samples || !mchp_samples) {
                dev_err(ips->dev,
index 2c85f75e32b08b27af3c96fa413fc9ebbccc252c..75c8fef7a482c41717c69aa8ef98b21ef4dd1043 100644 (file)
@@ -584,11 +584,11 @@ int intel_scu_ipc_i2c_cntrl(u32 addr, u32 *data)
        if (cmd == IPC_I2C_READ) {
                writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR);
                /* Write not getting updated without delay */
-               mdelay(1);
+               usleep_range(1000, 2000);
                *data = readl(scu->i2c_base + I2C_DATA_ADDR);
        } else if (cmd == IPC_I2C_WRITE) {
                writel(*data, scu->i2c_base + I2C_DATA_ADDR);
-               mdelay(1);
+               usleep_range(1000, 2000);
                writel(addr, scu->i2c_base + IPC_I2C_CNTRL_ADDR);
        } else {
                dev_err(scu->dev,
index 7a0bd24c1ae2dcd5304150d52a54d124192e753a..a0fd9aa6d93258f7305dae2dd60506f9f1464689 100644 (file)
 /* LPC bus IO offsets */
 #define MLXPLAT_CPLD_LPC_I2C_BASE_ADRR         0x2000
 #define MLXPLAT_CPLD_LPC_REG_BASE_ADRR         0x2500
+#define MLXPLAT_CPLD_LPC_REG_LED1_OFFSET       0x20
+#define MLXPLAT_CPLD_LPC_REG_LED2_OFFSET       0x21
+#define MLXPLAT_CPLD_LPC_REG_LED3_OFFSET       0x22
+#define MLXPLAT_CPLD_LPC_REG_LED4_OFFSET       0x23
+#define MLXPLAT_CPLD_LPC_REG_LED5_OFFSET       0x24
 #define MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET       0x3a
 #define MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET  0x3b
 #define MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET     0x40
@@ -84,6 +89,8 @@
 #define MLXPLAT_CPLD_PWR_MASK          GENMASK(1, 0)
 #define MLXPLAT_CPLD_FAN_MASK          GENMASK(3, 0)
 #define MLXPLAT_CPLD_FAN_NG_MASK       GENMASK(5, 0)
+#define MLXPLAT_CPLD_LED_LO_NIBBLE_MASK        GENMASK(7, 4)
+#define MLXPLAT_CPLD_LED_HI_NIBBLE_MASK        GENMASK(3, 0)
 
 /* Default I2C parent bus number */
 #define MLXPLAT_CPLD_PHYS_ADAPTER_DEF_NR       1
  * @pdev_i2c - i2c controller platform device
  * @pdev_mux - array of mux platform devices
  * @pdev_hotplug - hotplug platform devices
+ * @pdev_led - led platform devices
  */
 struct mlxplat_priv {
        struct platform_device *pdev_i2c;
        struct platform_device *pdev_mux[MLXPLAT_CPLD_LPC_MUX_DEVS];
        struct platform_device *pdev_hotplug;
+       struct platform_device *pdev_led;
 };
 
 /* Regions for LPC I2C controller and LPC base register space */
@@ -592,9 +601,227 @@ struct mlxreg_core_hotplug_platform_data mlxplat_mlxcpld_default_ng_data = {
        .mask_low = MLXPLAT_CPLD_LOW_AGGR_MASK_LOW,
 };
 
+/* Platform led default data */
+static struct mlxreg_core_data mlxplat_mlxcpld_default_led_data[] = {
+       {
+               .label = "status:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "status:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK
+       },
+       {
+               .label = "psu:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "psu:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan1:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan1:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan2:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan2:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan3:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan3:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan4:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan4:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+};
+
+static struct mlxreg_core_platform_data mlxplat_default_led_data = {
+               .data = mlxplat_mlxcpld_default_led_data,
+               .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_led_data),
+};
+
+/* Platform led MSN21xx system family data */
+static struct mlxreg_core_data mlxplat_mlxcpld_msn21xx_led_data[] = {
+       {
+               .label = "status:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "status:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK
+       },
+       {
+               .label = "fan:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "psu1:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "psu1:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "psu2:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "psu2:red",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "uid:blue",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED5_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+};
+
+static struct mlxreg_core_platform_data mlxplat_msn21xx_led_data = {
+               .data = mlxplat_mlxcpld_msn21xx_led_data,
+               .counter = ARRAY_SIZE(mlxplat_mlxcpld_msn21xx_led_data),
+};
+
+/* Platform led for default data for 200GbE systems */
+static struct mlxreg_core_data mlxplat_mlxcpld_default_ng_led_data[] = {
+       {
+               .label = "status:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "status:orange",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK
+       },
+       {
+               .label = "psu:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "psu:orange",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED1_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan1:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan1:orange",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan2:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan2:orange",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED2_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan3:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan3:orange",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan4:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan4:orange",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED3_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan5:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan5:orange",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_LO_NIBBLE_MASK,
+       },
+       {
+               .label = "fan6:green",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+       {
+               .label = "fan6:orange",
+               .reg = MLXPLAT_CPLD_LPC_REG_LED4_OFFSET,
+               .mask = MLXPLAT_CPLD_LED_HI_NIBBLE_MASK,
+       },
+};
+
+static struct mlxreg_core_platform_data mlxplat_default_ng_led_data = {
+               .data = mlxplat_mlxcpld_default_ng_led_data,
+               .counter = ARRAY_SIZE(mlxplat_mlxcpld_default_ng_led_data),
+};
+
+
 static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg)
 {
        switch (reg) {
+       case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET:
        case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET:
        case MLXPLAT_CPLD_LPC_REG_AGGRLO_MASK_OFFSET:
        case MLXPLAT_CPLD_LPC_REG_PSU_EVENT_OFFSET:
@@ -611,6 +838,11 @@ static bool mlxplat_mlxcpld_writeable_reg(struct device *dev, unsigned int reg)
 static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg)
 {
        switch (reg) {
+       case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET:
        case MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET:
        case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET:
        case MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET:
@@ -632,6 +864,11 @@ static bool mlxplat_mlxcpld_readable_reg(struct device *dev, unsigned int reg)
 static bool mlxplat_mlxcpld_volatile_reg(struct device *dev, unsigned int reg)
 {
        switch (reg) {
+       case MLXPLAT_CPLD_LPC_REG_LED1_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED2_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED3_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED4_OFFSET:
+       case MLXPLAT_CPLD_LPC_REG_LED5_OFFSET:
        case MLXPLAT_CPLD_LPC_REG_AGGR_OFFSET:
        case MLXPLAT_CPLD_LPC_REG_AGGR_MASK_OFFSET:
        case MLXPLAT_CPLD_LPC_REG_AGGRLO_OFFSET:
@@ -692,6 +929,7 @@ static struct resource mlxplat_mlxcpld_resources[] = {
 
 static struct platform_device *mlxplat_dev;
 static struct mlxreg_core_hotplug_platform_data *mlxplat_hotplug;
+static struct mlxreg_core_platform_data *mlxplat_led;
 
 static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi)
 {
@@ -705,6 +943,7 @@ static int __init mlxplat_dmi_default_matched(const struct dmi_system_id *dmi)
        mlxplat_hotplug = &mlxplat_mlxcpld_default_data;
        mlxplat_hotplug->deferred_nr =
                mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
+       mlxplat_led = &mlxplat_default_led_data;
 
        return 1;
 };
@@ -721,6 +960,7 @@ static int __init mlxplat_dmi_msn21xx_matched(const struct dmi_system_id *dmi)
        mlxplat_hotplug = &mlxplat_mlxcpld_msn21xx_data;
        mlxplat_hotplug->deferred_nr =
                mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
+       mlxplat_led = &mlxplat_msn21xx_led_data;
 
        return 1;
 };
@@ -737,6 +977,7 @@ static int __init mlxplat_dmi_msn274x_matched(const struct dmi_system_id *dmi)
        mlxplat_hotplug = &mlxplat_mlxcpld_msn274x_data;
        mlxplat_hotplug->deferred_nr =
                mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
+       mlxplat_led = &mlxplat_default_led_data;
 
        return 1;
 };
@@ -753,6 +994,7 @@ static int __init mlxplat_dmi_msn201x_matched(const struct dmi_system_id *dmi)
        mlxplat_hotplug = &mlxplat_mlxcpld_msn201x_data;
        mlxplat_hotplug->deferred_nr =
                mlxplat_default_channels[i - 1][MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
+       mlxplat_led = &mlxplat_default_ng_led_data;
 
        return 1;
 };
@@ -769,6 +1011,7 @@ static int __init mlxplat_dmi_qmb7xx_matched(const struct dmi_system_id *dmi)
        mlxplat_hotplug = &mlxplat_mlxcpld_default_ng_data;
        mlxplat_hotplug->deferred_nr =
                mlxplat_msn21xx_channels[MLXPLAT_CPLD_GRP_CHNL_NUM - 1];
+       mlxplat_led = &mlxplat_msn21xx_led_data;
 
        return 1;
 };
@@ -844,6 +1087,36 @@ static const struct dmi_system_id mlxplat_dmi_table[] __initconst = {
                        DMI_MATCH(DMI_PRODUCT_NAME, "SN34"),
                },
        },
+       {
+               .callback = mlxplat_dmi_default_matched,
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_NAME, "VMOD0001"),
+               },
+       },
+       {
+               .callback = mlxplat_dmi_msn21xx_matched,
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_NAME, "VMOD0002"),
+               },
+       },
+       {
+               .callback = mlxplat_dmi_msn274x_matched,
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_NAME, "VMOD0003"),
+               },
+       },
+       {
+               .callback = mlxplat_dmi_msn201x_matched,
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_NAME, "VMOD0004"),
+               },
+       },
+       {
+               .callback = mlxplat_dmi_qmb7xx_matched,
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_NAME, "VMOD0005"),
+               },
+       },
        { }
 };
 
@@ -960,14 +1233,27 @@ static int __init mlxplat_init(void)
                goto fail_platform_mux_register;
        }
 
+       /* Add LED driver. */
+       mlxplat_led->regmap = mlxplat_hotplug->regmap;
+       priv->pdev_led = platform_device_register_resndata(
+                               &mlxplat_dev->dev, "leds-mlxreg",
+                               PLATFORM_DEVID_NONE, NULL, 0,
+                               mlxplat_led, sizeof(*mlxplat_led));
+       if (IS_ERR(priv->pdev_led)) {
+               err = PTR_ERR(priv->pdev_led);
+               goto fail_platform_hotplug_register;
+       }
+
        /* Sync registers with hardware. */
        regcache_mark_dirty(mlxplat_hotplug->regmap);
        err = regcache_sync(mlxplat_hotplug->regmap);
        if (err)
-               goto fail_platform_hotplug_register;
+               goto fail_platform_led_register;
 
        return 0;
 
+fail_platform_led_register:
+       platform_device_unregister(priv->pdev_led);
 fail_platform_hotplug_register:
        platform_device_unregister(priv->pdev_hotplug);
 fail_platform_mux_register:
@@ -986,6 +1272,7 @@ static void __exit mlxplat_exit(void)
        struct mlxplat_priv *priv = platform_get_drvdata(mlxplat_dev);
        int i;
 
+       platform_device_unregister(priv->pdev_led);
        platform_device_unregister(priv->pdev_hotplug);
 
        for (i = ARRAY_SIZE(mlxplat_mux_data) - 1; i >= 0 ; i--)
index 5c39b3211709bca675216625786bf3967e477ba9..8361ad75389a96f4c8f7eb87ff57ddb48f2a3380 100644 (file)
@@ -571,7 +571,7 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device)
                return -ENOMEM;
        }
 
-       pcc->sinf = kzalloc(sizeof(u32) * (num_sifr + 1), GFP_KERNEL);
+       pcc->sinf = kcalloc(num_sifr + 1, sizeof(u32), GFP_KERNEL);
        if (!pcc->sinf) {
                result = -ENOMEM;
                goto out_hotkey;
index 03305e0b89ff808b5665d474b86baba62539c05e..7b160ee981152992655ff0b6f9357617f44fa18b 100644 (file)
@@ -1216,8 +1216,7 @@ static umode_t samsung_sysfs_is_visible(struct kobject *kobj,
                                        struct attribute *attr, int idx)
 {
        struct device *dev = container_of(kobj, struct device, kobj);
-       struct platform_device *pdev = to_platform_device(dev);
-       struct samsung_laptop *samsung = platform_get_drvdata(pdev);
+       struct samsung_laptop *samsung = dev_get_drvdata(dev);
        bool ok = true;
 
        if (attr == &dev_attr_performance_level.attr)
index 452aacabaa8efc71115bd4c107e485f490fe138d..853a7ce4601cd1f0d508197b27e79455e936e2f1 100644 (file)
@@ -53,6 +53,20 @@ static const struct silead_ts_dmi_data jumper_ezpad_mini3_data = {
        .properties     = jumper_ezpad_mini3_props,
 };
 
+static const struct property_entry jumper_ezpad_6_pro_props[] = {
+       PROPERTY_ENTRY_U32("touchscreen-size-x", 1980),
+       PROPERTY_ENTRY_U32("touchscreen-size-y", 1500),
+       PROPERTY_ENTRY_STRING("firmware-name", "gsl3692-jumper-ezpad-6-pro.fw"),
+       PROPERTY_ENTRY_U32("silead,max-fingers", 10),
+       PROPERTY_ENTRY_BOOL("silead,home-button"),
+       { }
+};
+
+static const struct silead_ts_dmi_data jumper_ezpad_6_pro_data = {
+       .acpi_name      = "MSSL1680:00",
+       .properties     = jumper_ezpad_6_pro_props,
+};
+
 static const struct property_entry dexp_ursus_7w_props[] = {
        PROPERTY_ENTRY_U32("touchscreen-size-x", 890),
        PROPERTY_ENTRY_U32("touchscreen-size-y", 630),
@@ -127,7 +141,25 @@ static const struct silead_ts_dmi_data pipo_w2s_data = {
        .properties     = pipo_w2s_props,
 };
 
-static const struct property_entry pov_mobii_wintab_p800w_props[] = {
+static const struct property_entry pov_mobii_wintab_p800w_v20_props[] = {
+       PROPERTY_ENTRY_U32("touchscreen-min-x", 32),
+       PROPERTY_ENTRY_U32("touchscreen-min-y", 16),
+       PROPERTY_ENTRY_U32("touchscreen-size-x", 1692),
+       PROPERTY_ENTRY_U32("touchscreen-size-y", 1146),
+       PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
+       PROPERTY_ENTRY_STRING("firmware-name",
+                             "gsl3680-pov-mobii-wintab-p800w-v20.fw"),
+       PROPERTY_ENTRY_U32("silead,max-fingers", 10),
+       PROPERTY_ENTRY_BOOL("silead,home-button"),
+       { }
+};
+
+static const struct silead_ts_dmi_data pov_mobii_wintab_p800w_v20_data = {
+       .acpi_name      = "MSSL1680:00",
+       .properties     = pov_mobii_wintab_p800w_v20_props,
+};
+
+static const struct property_entry pov_mobii_wintab_p800w_v21_props[] = {
        PROPERTY_ENTRY_U32("touchscreen-size-x", 1800),
        PROPERTY_ENTRY_U32("touchscreen-size-y", 1150),
        PROPERTY_ENTRY_BOOL("touchscreen-swapped-x-y"),
@@ -137,9 +169,9 @@ static const struct property_entry pov_mobii_wintab_p800w_props[] = {
        { }
 };
 
-static const struct silead_ts_dmi_data pov_mobii_wintab_p800w_data = {
+static const struct silead_ts_dmi_data pov_mobii_wintab_p800w_v21_data = {
        .acpi_name      = "MSSL1680:00",
-       .properties     = pov_mobii_wintab_p800w_props,
+       .properties     = pov_mobii_wintab_p800w_v21_props,
 };
 
 static const struct property_entry itworks_tw891_props[] = {
@@ -277,6 +309,23 @@ static const struct silead_ts_dmi_data teclast_x3_plus_data = {
        .properties     = teclast_x3_plus_props,
 };
 
+static const struct property_entry onda_v891w_v1_props[] = {
+       PROPERTY_ENTRY_U32("touchscreen-min-x", 46),
+       PROPERTY_ENTRY_U32("touchscreen-min-y",  8),
+       PROPERTY_ENTRY_U32("touchscreen-size-x", 1676),
+       PROPERTY_ENTRY_U32("touchscreen-size-y", 1130),
+       PROPERTY_ENTRY_STRING("firmware-name",
+                             "gsl3680-onda-v891w-v1.fw"),
+       PROPERTY_ENTRY_U32("silead,max-fingers", 10),
+       PROPERTY_ENTRY_BOOL("silead,home-button"),
+       { }
+};
+
+static const struct silead_ts_dmi_data onda_v891w_v1_data = {
+       .acpi_name      = "MSSL1680:00",
+       .properties     = onda_v891w_v1_props,
+};
+
 static const struct dmi_system_id silead_ts_dmi_table[] = {
        {
                /* CUBE iwork8 Air */
@@ -296,6 +345,17 @@ static const struct dmi_system_id silead_ts_dmi_table[] = {
                        DMI_MATCH(DMI_BIOS_VERSION, "jumperx.T87.KFBNEEA"),
                },
        },
+       {
+               /* Jumper EZpad 6 Pro */
+               .driver_data = (void *)&jumper_ezpad_6_pro_data,
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Jumper"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "EZpad"),
+                       DMI_MATCH(DMI_BIOS_VERSION, "5.12"),
+                       /* Above matches are too generic, add bios-date match */
+                       DMI_MATCH(DMI_BIOS_DATE, "08/18/2017"),
+               },
+       },
        {
                /* DEXP Ursus 7W */
                .driver_data = (void *)&dexp_ursus_7w_data,
@@ -361,8 +421,19 @@ static const struct dmi_system_id silead_ts_dmi_table[] = {
                },
        },
        {
-               /* Point of View mobii wintab p800w */
-               .driver_data = (void *)&pov_mobii_wintab_p800w_data,
+               /* Point of View mobii wintab p800w (v2.0) */
+               .driver_data = (void *)&pov_mobii_wintab_p800w_v20_data,
+               .matches = {
+                       DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
+                       DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
+                       DMI_MATCH(DMI_BIOS_VERSION, "3BAIR1014"),
+                       /* Above matches are too generic, add bios-date match */
+                       DMI_MATCH(DMI_BIOS_DATE, "10/24/2014"),
+               },
+       },
+       {
+               /* Point of View mobii wintab p800w (v2.1) */
+               .driver_data = (void *)&pov_mobii_wintab_p800w_v21_data,
                .matches = {
                        DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"),
                        DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"),
@@ -412,6 +483,15 @@ static const struct dmi_system_id silead_ts_dmi_table[] = {
                        DMI_MATCH(DMI_PRODUCT_NAME, "S806"),
                },
        },
+       {
+               /* Chuwi Hi8 (H1D_S806_206) */
+               .driver_data = (void *)&chuwi_hi8_data,
+               .matches = {
+                       DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
+                       DMI_MATCH(DMI_PRODUCT_NAME, "BayTrail"),
+                       DMI_MATCH(DMI_BIOS_VERSION, "H1D_S806_206"),
+               },
+       },
        {
                /* Chuwi Vi8 (CWI506) */
                .driver_data = (void *)&chuwi_vi8_data,
@@ -463,6 +543,17 @@ static const struct dmi_system_id silead_ts_dmi_table[] = {
                        DMI_MATCH(DMI_PRODUCT_NAME, "Y8W81"),
                },
        },
+       {
+               /* ONDA V891w revision P891WBEBV1B00 aka v1 */
+               .driver_data = (void *)&onda_v891w_v1_data,
+               .matches = {
+                       DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "ONDA"),
+                       DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONDA Tablet"),
+                       DMI_EXACT_MATCH(DMI_BOARD_VERSION, "V001"),
+                       /* Exact match, different versions need different fw */
+                       DMI_EXACT_MATCH(DMI_BIOS_VERSION, "ONDA.W89EBBN08"),
+               },
+       },
        { },
 };
 
index da1ca4856ea192afefa641c9511c45dc7d34aa01..cae9b059569229d7c937e2f7101040969d9c7d5f 100644 (file)
@@ -212,7 +212,12 @@ enum tpacpi_hkey_event_t {
        TP_HKEY_EV_ALARM_BAT_XHOT       = 0x6012, /* battery critically hot */
        TP_HKEY_EV_ALARM_SENSOR_HOT     = 0x6021, /* sensor too hot */
        TP_HKEY_EV_ALARM_SENSOR_XHOT    = 0x6022, /* sensor critically hot */
-       TP_HKEY_EV_THM_TABLE_CHANGED    = 0x6030, /* thermal table changed */
+       TP_HKEY_EV_THM_TABLE_CHANGED    = 0x6030, /* windows; thermal table changed */
+       TP_HKEY_EV_THM_CSM_COMPLETED    = 0x6032, /* windows; thermal control set
+                                                  * command completed. Related to
+                                                  * AML DYTC */
+       TP_HKEY_EV_THM_TRANSFM_CHANGED  = 0x60F0, /* windows; thermal transformation
+                                                  * changed. Related to AML GMTS */
 
        /* AC-related events */
        TP_HKEY_EV_AC_CHANGED           = 0x6040, /* AC status changed */
@@ -4034,15 +4039,23 @@ static bool hotkey_notify_6xxx(const u32 hkey,
                                 bool *send_acpi_ev,
                                 bool *ignore_acpi_ev)
 {
-       bool known = true;
-
        /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */
        *send_acpi_ev = true;
        *ignore_acpi_ev = false;
 
        switch (hkey) {
        case TP_HKEY_EV_THM_TABLE_CHANGED:
-               pr_info("EC reports that Thermal Table has changed\n");
+               pr_debug("EC reports: Thermal Table has changed\n");
+               /* recommended action: do nothing, we don't have
+                * Lenovo ATM information */
+               return true;
+       case TP_HKEY_EV_THM_CSM_COMPLETED:
+               pr_debug("EC reports: Thermal Control Command set completed (DYTC)\n");
+               /* recommended action: do nothing, we don't have
+                * Lenovo ATM information */
+               return true;
+       case TP_HKEY_EV_THM_TRANSFM_CHANGED:
+               pr_debug("EC reports: Thermal Transformation changed (GMTS)\n");
                /* recommended action: do nothing, we don't have
                 * Lenovo ATM information */
                return true;
@@ -4083,7 +4096,7 @@ static bool hotkey_notify_6xxx(const u32 hkey,
                tpacpi_input_send_tabletsw();
                hotkey_tablet_mode_notify_change();
                *send_acpi_ev = false;
-               break;
+               return true;
 
        case TP_HKEY_EV_PALM_DETECTED:
        case TP_HKEY_EV_PALM_UNDETECTED:
@@ -4092,13 +4105,12 @@ static bool hotkey_notify_6xxx(const u32 hkey,
                return true;
 
        default:
-               pr_warn("unknown possible thermal alarm or keyboard event received\n");
-               known = false;
+               /* report simply as unknown, no sensor dump */
+               return false;
        }
 
        thermal_dump_all_sensors();
-
-       return known;
+       return true;
 }
 
 static void hotkey_notify(struct ibm_struct *ibm, u32 event)
@@ -6006,7 +6018,7 @@ static int __init led_init(struct ibm_init_struct *iibm)
        if (led_supported == TPACPI_LED_NONE)
                return 1;
 
-       tpacpi_leds = kzalloc(sizeof(*tpacpi_leds) * TPACPI_LED_NUMLEDS,
+       tpacpi_leds = kcalloc(TPACPI_LED_NUMLEDS, sizeof(*tpacpi_leds),
                              GFP_KERNEL);
        if (!tpacpi_leds) {
                pr_err("Out of memory for LED data\n");
index 2a50b465479303b0d2f4dda72625e6a35017be48..faa1a67cf3d2c704bce6ceaea6c9e555b84d8ddb 100644 (file)
@@ -1380,7 +1380,7 @@ static int charger_manager_register_sysfs(struct charger_manager *cm)
 
                snprintf(buf, 10, "charger.%d", i);
                str = devm_kzalloc(cm->dev,
-                               sizeof(char) * (strlen(buf) + 1), GFP_KERNEL);
+                               strlen(buf) + 1, GFP_KERNEL);
                if (!str)
                        return -ENOMEM;
 
@@ -1522,8 +1522,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
        of_property_read_u32(np, "cm-num-chargers", &num_chgs);
        if (num_chgs) {
                /* Allocate empty bin at the tail of array */
-               desc->psy_charger_stat = devm_kzalloc(dev, sizeof(char *)
-                                               * (num_chgs + 1), GFP_KERNEL);
+               desc->psy_charger_stat = devm_kcalloc(dev,
+                                                     num_chgs + 1,
+                                                     sizeof(char *),
+                                                     GFP_KERNEL);
                if (desc->psy_charger_stat) {
                        int i;
                        for (i = 0; i < num_chgs; i++)
@@ -1555,8 +1557,9 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
                struct charger_regulator *chg_regs;
                struct device_node *child;
 
-               chg_regs = devm_kzalloc(dev, sizeof(*chg_regs)
-                                       * desc->num_charger_regulators,
+               chg_regs = devm_kcalloc(dev,
+                                       desc->num_charger_regulators,
+                                       sizeof(*chg_regs),
                                        GFP_KERNEL);
                if (!chg_regs)
                        return ERR_PTR(-ENOMEM);
@@ -1573,9 +1576,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
                        /* charger cables */
                        chg_regs->num_cables = of_get_child_count(child);
                        if (chg_regs->num_cables) {
-                               cables = devm_kzalloc(dev, sizeof(*cables)
-                                               * chg_regs->num_cables,
-                                               GFP_KERNEL);
+                               cables = devm_kcalloc(dev,
+                                                     chg_regs->num_cables,
+                                                     sizeof(*cables),
+                                                     GFP_KERNEL);
                                if (!cables) {
                                        of_node_put(child);
                                        return ERR_PTR(-ENOMEM);
@@ -1725,10 +1729,11 @@ static int charger_manager_probe(struct platform_device *pdev)
        cm->charger_psy_desc.name = cm->psy_name_buf;
 
        /* Allocate for psy properties because they may vary */
-       cm->charger_psy_desc.properties = devm_kzalloc(&pdev->dev,
-                               sizeof(enum power_supply_property)
-                               * (ARRAY_SIZE(default_charger_props) +
-                               NUM_CHARGER_PSY_OPTIONAL), GFP_KERNEL);
+       cm->charger_psy_desc.properties =
+               devm_kcalloc(&pdev->dev,
+                            ARRAY_SIZE(default_charger_props) +
+                               NUM_CHARGER_PSY_OPTIONAL,
+                            sizeof(enum power_supply_property), GFP_KERNEL);
        if (!cm->charger_psy_desc.properties)
                return -ENOMEM;
 
index f57ab0a27301d067094487d32ea79677f1f7cad8..d21f478741c17e786d534476a0288cf544c19b2e 100644 (file)
@@ -263,8 +263,8 @@ static int power_supply_check_supplies(struct power_supply *psy)
        if (!psy->supplied_from)
                return -ENOMEM;
 
-       *psy->supplied_from = devm_kzalloc(&psy->dev,
-                                          sizeof(char *) * (cnt - 1),
+       *psy->supplied_from = devm_kcalloc(&psy->dev,
+                                          cnt - 1, sizeof(char *),
                                           GFP_KERNEL);
        if (!*psy->supplied_from)
                return -ENOMEM;
index bd4f66651513f8bdcdd7fe419c706acd82058277..6754e761778af9289000ce2eb5b4c6f5f659662a 100644 (file)
@@ -201,7 +201,7 @@ static int wm97xx_bat_probe(struct platform_device *dev)
        if (pdata->min_voltage >= 0)
                props++;        /* POWER_SUPPLY_PROP_VOLTAGE_MIN */
 
-       prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
+       prop = kcalloc(props, sizeof(*prop), GFP_KERNEL);
        if (!prop) {
                ret = -ENOMEM;
                goto err3;
index 8a43b49cfd35f0966461ea0cca32847c9f55861e..bcc2d1a9b0a797fa0897d1357a053779143c5adc 100644 (file)
@@ -146,7 +146,7 @@ static int z2_batt_ps_init(struct z2_charger *charger, int props)
        if (info->min_voltage >= 0)
                props++;        /* POWER_SUPPLY_PROP_VOLTAGE_MIN */
 
-       prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
+       prop = kcalloc(props, sizeof(*prop), GFP_KERNEL);
        if (!prop)
                return -ENOMEM;
 
index 64b2b2501a790978c48dd08af87178bb78d968c1..9e2f274bd44f2e3446608cc97951a42329f73956 100644 (file)
@@ -545,15 +545,16 @@ struct powercap_zone *powercap_register_zone(
        dev_set_name(&power_zone->dev, "%s:%x",
                                        dev_name(power_zone->dev.parent),
                                        power_zone->id);
-       power_zone->constraints = kzalloc(sizeof(*power_zone->constraints) *
-                                        nr_constraints, GFP_KERNEL);
+       power_zone->constraints = kcalloc(nr_constraints,
+                                         sizeof(*power_zone->constraints),
+                                         GFP_KERNEL);
        if (!power_zone->constraints)
                goto err_const_alloc;
 
        nr_attrs = nr_constraints * POWERCAP_CONSTRAINTS_ATTRS +
                                                POWERCAP_ZONE_MAX_ATTRS + 1;
-       power_zone->zone_dev_attrs = kzalloc(sizeof(void *) *
-                                               nr_attrs, GFP_KERNEL);
+       power_zone->zone_dev_attrs = kcalloc(nr_attrs, sizeof(void *),
+                                            GFP_KERNEL);
        if (!power_zone->zone_dev_attrs)
                goto err_attr_alloc;
        create_power_zone_common_attributes(power_zone);
index 4635cb35008c2cdead18f80ab9f692ed8968ff98..a4d262db9945ff10a1d0f67409cb0b03c76026b8 100644 (file)
@@ -401,7 +401,7 @@ config PWM_STI
 
 config PWM_STM32
        tristate "STMicroelectronics STM32 PWM"
-       depends on MFD_STM32_TIMERS || COMPILE_TEST
+       depends on MFD_STM32_TIMERS
        help
          Generic PWM framework driver for STM32 SoCs.
 
index 4fb1be246c44e4ec071f6426022269288d038c1f..0d0f8376bc35118e1aac4bf8f1c2be1d6010e44b 100644 (file)
@@ -460,8 +460,7 @@ MODULE_DEVICE_TABLE(of, atmel_tcb_pwm_dt_ids);
 #ifdef CONFIG_PM_SLEEP
 static int atmel_tcb_pwm_suspend(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
+       struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev);
        void __iomem *base = tcbpwm->tc->regs;
        int i;
 
@@ -478,8 +477,7 @@ static int atmel_tcb_pwm_suspend(struct device *dev)
 
 static int atmel_tcb_pwm_resume(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct atmel_tcb_pwm_chip *tcbpwm = platform_get_drvdata(pdev);
+       struct atmel_tcb_pwm_chip *tcbpwm = dev_get_drvdata(dev);
        void __iomem *base = tcbpwm->tc->regs;
        int i;
 
index 52584e9962edd43adf83d9da04fc2e16672fcc87..15b40a8bc4fbbb456ab8aff72f1a7c44062966ca 100644 (file)
@@ -225,7 +225,7 @@ static int lp3943_pwm_parse_dt(struct device *dev,
                if (num_outputs == 0)
                        continue;
 
-               output = devm_kzalloc(dev, sizeof(*output) * num_outputs,
+               output = devm_kcalloc(dev, num_outputs, sizeof(*output),
                                      GFP_KERNEL);
                if (!output)
                        return -ENOMEM;
index 5d6ed1507d29284f2ba28f2cc781f4b797067f01..5561b9e190f84a63513ff3b86ecbeef7461404e8 100644 (file)
@@ -74,6 +74,10 @@ static int pwm_lpss_remove_platform(struct platform_device *pdev)
        return pwm_lpss_remove(lpwm);
 }
 
+static SIMPLE_DEV_PM_OPS(pwm_lpss_platform_pm_ops,
+                        pwm_lpss_suspend,
+                        pwm_lpss_resume);
+
 static const struct acpi_device_id pwm_lpss_acpi_match[] = {
        { "80860F09", (unsigned long)&pwm_lpss_byt_info },
        { "80862288", (unsigned long)&pwm_lpss_bsw_info },
@@ -86,6 +90,7 @@ static struct platform_driver pwm_lpss_driver_platform = {
        .driver = {
                .name = "pwm-lpss",
                .acpi_match_table = pwm_lpss_acpi_match,
+               .pm = &pwm_lpss_platform_pm_ops,
        },
        .probe = pwm_lpss_probe_platform,
        .remove = pwm_lpss_remove_platform,
index 8db0d40ccacde84a61d292936f6bbdeeed7ac358..4721a264bac2580cf8d21ee54396e0b494f1c9dc 100644 (file)
 /* Size of each PWM register space if multiple */
 #define PWM_SIZE                       0x400
 
+#define MAX_PWMS                       4
+
 struct pwm_lpss_chip {
        struct pwm_chip chip;
        void __iomem *regs;
        const struct pwm_lpss_boardinfo *info;
+       u32 saved_ctrl[MAX_PWMS];
 };
 
 static inline struct pwm_lpss_chip *to_lpwm(struct pwm_chip *chip)
@@ -177,6 +180,9 @@ struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
        unsigned long c;
        int ret;
 
+       if (WARN_ON(info->npwm > MAX_PWMS))
+               return ERR_PTR(-ENODEV);
+
        lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL);
        if (!lpwm)
                return ERR_PTR(-ENOMEM);
@@ -212,6 +218,30 @@ int pwm_lpss_remove(struct pwm_lpss_chip *lpwm)
 }
 EXPORT_SYMBOL_GPL(pwm_lpss_remove);
 
+int pwm_lpss_suspend(struct device *dev)
+{
+       struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev);
+       int i;
+
+       for (i = 0; i < lpwm->info->npwm; i++)
+               lpwm->saved_ctrl[i] = readl(lpwm->regs + i * PWM_SIZE + PWM);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(pwm_lpss_suspend);
+
+int pwm_lpss_resume(struct device *dev)
+{
+       struct pwm_lpss_chip *lpwm = dev_get_drvdata(dev);
+       int i;
+
+       for (i = 0; i < lpwm->info->npwm; i++)
+               writel(lpwm->saved_ctrl[i], lpwm->regs + i * PWM_SIZE + PWM);
+
+       return 0;
+}
+EXPORT_SYMBOL_GPL(pwm_lpss_resume);
+
 MODULE_DESCRIPTION("PWM driver for Intel LPSS");
 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
 MODULE_LICENSE("GPL v2");
index 98306bb02cfe71c0775eb430e7cf623fdc431889..7a4238ad1fcb1f25390032019170759c6666ae83 100644 (file)
@@ -28,5 +28,7 @@ struct pwm_lpss_boardinfo {
 struct pwm_lpss_chip *pwm_lpss_probe(struct device *dev, struct resource *r,
                                     const struct pwm_lpss_boardinfo *info);
 int pwm_lpss_remove(struct pwm_lpss_chip *lpwm);
+int pwm_lpss_suspend(struct device *dev);
+int pwm_lpss_resume(struct device *dev);
 
 #endif /* __PWM_LPSS_H */
index 0767deba8e622dbfb8227910252266c5f54ef777..822860b4801a6823008d51346e82d0f279c6c053 100644 (file)
@@ -541,8 +541,8 @@ static int meson_pwm_probe(struct platform_device *pdev)
        meson->data = of_device_get_match_data(&pdev->dev);
        meson->inverter_mask = BIT(meson->chip.npwm) - 1;
 
-       channels = devm_kcalloc(&pdev->dev, meson->chip.npwm, sizeof(*meson),
-                               GFP_KERNEL);
+       channels = devm_kcalloc(&pdev->dev, meson->chip.npwm,
+                               sizeof(*channels), GFP_KERNEL);
        if (!channels)
                return -ENOMEM;
 
index 91d11f2e2fefd2897a693199bc8c904faf165003..748f614d53755daabdd9f1529d7ba9cd602cb611 100644 (file)
@@ -261,8 +261,7 @@ MODULE_DEVICE_TABLE(of, rcar_pwm_of_table);
 #ifdef CONFIG_PM_SLEEP
 static struct pwm_device *rcar_pwm_dev_to_pwm_dev(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct rcar_pwm_chip *rcar_pwm = platform_get_drvdata(pdev);
+       struct rcar_pwm_chip *rcar_pwm = dev_get_drvdata(dev);
        struct pwm_chip *chip = &rcar_pwm->chip;
 
        return &chip->pwms[0];
index 2708212933f72f077d2f23ef6b283a35c7bd0413..4f842550fbd127ce1b0f53522dfb7f4e60b74329 100644 (file)
@@ -8,6 +8,7 @@
  *             pwm-atmel.c from Bo Shen
  */
 
+#include <linux/bitfield.h>
 #include <linux/mfd/stm32-timers.h>
 #include <linux/module.h>
 #include <linux/of.h>
@@ -25,6 +26,7 @@ struct stm32_pwm {
        struct regmap *regmap;
        u32 max_arr;
        bool have_complementary_output;
+       u32 capture[4] ____cacheline_aligned; /* DMA'able buffer */
 };
 
 struct stm32_breakinput {
@@ -62,6 +64,258 @@ static int write_ccrx(struct stm32_pwm *dev, int ch, u32 value)
        return -EINVAL;
 }
 
+#define TIM_CCER_CC12P (TIM_CCER_CC1P | TIM_CCER_CC2P)
+#define TIM_CCER_CC12E (TIM_CCER_CC1E | TIM_CCER_CC2E)
+#define TIM_CCER_CC34P (TIM_CCER_CC3P | TIM_CCER_CC4P)
+#define TIM_CCER_CC34E (TIM_CCER_CC3E | TIM_CCER_CC4E)
+
+/*
+ * Capture using PWM input mode:
+ *                              ___          ___
+ * TI[1, 2, 3 or 4]: ........._|   |________|
+ *                             ^0  ^1       ^2
+ *                              .   .        .
+ *                              .   .        XXXXX
+ *                              .   .   XXXXX     |
+ *                              .  XXXXX     .    |
+ *                            XXXXX .        .    |
+ * COUNTER:        ______XXXXX  .   .        .    |_XXX
+ *                 start^       .   .        .        ^stop
+ *                      .       .   .        .
+ *                      v       v   .        v
+ *                                  v
+ * CCR1/CCR3:       tx..........t0...........t2
+ * CCR2/CCR4:       tx..............t1.........
+ *
+ * DMA burst transfer:          |            |
+ *                              v            v
+ * DMA buffer:                  { t0, tx }   { t2, t1 }
+ * DMA done:                                 ^
+ *
+ * 0: IC1/3 snapchot on rising edge: counter value -> CCR1/CCR3
+ *    + DMA transfer CCR[1/3] & CCR[2/4] values (t0, tx: doesn't care)
+ * 1: IC2/4 snapchot on falling edge: counter value -> CCR2/CCR4
+ * 2: IC1/3 snapchot on rising edge: counter value -> CCR1/CCR3
+ *    + DMA transfer CCR[1/3] & CCR[2/4] values (t2, t1)
+ *
+ * DMA done, compute:
+ * - Period     = t2 - t0
+ * - Duty cycle = t1 - t0
+ */
+static int stm32_pwm_raw_capture(struct stm32_pwm *priv, struct pwm_device *pwm,
+                                unsigned long tmo_ms, u32 *raw_prd,
+                                u32 *raw_dty)
+{
+       struct device *parent = priv->chip.dev->parent;
+       enum stm32_timers_dmas dma_id;
+       u32 ccen, ccr;
+       int ret;
+
+       /* Ensure registers have been updated, enable counter and capture */
+       regmap_update_bits(priv->regmap, TIM_EGR, TIM_EGR_UG, TIM_EGR_UG);
+       regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, TIM_CR1_CEN);
+
+       /* Use cc1 or cc3 DMA resp for PWM input channels 1 & 2 or 3 & 4 */
+       dma_id = pwm->hwpwm < 2 ? STM32_TIMERS_DMA_CH1 : STM32_TIMERS_DMA_CH3;
+       ccen = pwm->hwpwm < 2 ? TIM_CCER_CC12E : TIM_CCER_CC34E;
+       ccr = pwm->hwpwm < 2 ? TIM_CCR1 : TIM_CCR3;
+       regmap_update_bits(priv->regmap, TIM_CCER, ccen, ccen);
+
+       /*
+        * Timer DMA burst mode. Request 2 registers, 2 bursts, to get both
+        * CCR1 & CCR2 (or CCR3 & CCR4) on each capture event.
+        * We'll get two capture snapchots: { CCR1, CCR2 }, { CCR1, CCR2 }
+        * or { CCR3, CCR4 }, { CCR3, CCR4 }
+        */
+       ret = stm32_timers_dma_burst_read(parent, priv->capture, dma_id, ccr, 2,
+                                         2, tmo_ms);
+       if (ret)
+               goto stop;
+
+       /* Period: t2 - t0 (take care of counter overflow) */
+       if (priv->capture[0] <= priv->capture[2])
+               *raw_prd = priv->capture[2] - priv->capture[0];
+       else
+               *raw_prd = priv->max_arr - priv->capture[0] + priv->capture[2];
+
+       /* Duty cycle capture requires at least two capture units */
+       if (pwm->chip->npwm < 2)
+               *raw_dty = 0;
+       else if (priv->capture[0] <= priv->capture[3])
+               *raw_dty = priv->capture[3] - priv->capture[0];
+       else
+               *raw_dty = priv->max_arr - priv->capture[0] + priv->capture[3];
+
+       if (*raw_dty > *raw_prd) {
+               /*
+                * Race beetween PWM input and DMA: it may happen
+                * falling edge triggers new capture on TI2/4 before DMA
+                * had a chance to read CCR2/4. It means capture[1]
+                * contains period + duty_cycle. So, subtract period.
+                */
+               *raw_dty -= *raw_prd;
+       }
+
+stop:
+       regmap_update_bits(priv->regmap, TIM_CCER, ccen, 0);
+       regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_CEN, 0);
+
+       return ret;
+}
+
+static int stm32_pwm_capture(struct pwm_chip *chip, struct pwm_device *pwm,
+                            struct pwm_capture *result, unsigned long tmo_ms)
+{
+       struct stm32_pwm *priv = to_stm32_pwm_dev(chip);
+       unsigned long long prd, div, dty;
+       unsigned long rate;
+       unsigned int psc = 0, icpsc, scale;
+       u32 raw_prd = 0, raw_dty = 0;
+       int ret = 0;
+
+       mutex_lock(&priv->lock);
+
+       if (active_channels(priv)) {
+               ret = -EBUSY;
+               goto unlock;
+       }
+
+       ret = clk_enable(priv->clk);
+       if (ret) {
+               dev_err(priv->chip.dev, "failed to enable counter clock\n");
+               goto unlock;
+       }
+
+       rate = clk_get_rate(priv->clk);
+       if (!rate) {
+               ret = -EINVAL;
+               goto clk_dis;
+       }
+
+       /* prescaler: fit timeout window provided by upper layer */
+       div = (unsigned long long)rate * (unsigned long long)tmo_ms;
+       do_div(div, MSEC_PER_SEC);
+       prd = div;
+       while ((div > priv->max_arr) && (psc < MAX_TIM_PSC)) {
+               psc++;
+               div = prd;
+               do_div(div, psc + 1);
+       }
+       regmap_write(priv->regmap, TIM_ARR, priv->max_arr);
+       regmap_write(priv->regmap, TIM_PSC, psc);
+
+       /* Map TI1 or TI2 PWM input to IC1 & IC2 (or TI3/4 to IC3 & IC4) */
+       regmap_update_bits(priv->regmap,
+                          pwm->hwpwm < 2 ? TIM_CCMR1 : TIM_CCMR2,
+                          TIM_CCMR_CC1S | TIM_CCMR_CC2S, pwm->hwpwm & 0x1 ?
+                          TIM_CCMR_CC1S_TI2 | TIM_CCMR_CC2S_TI2 :
+                          TIM_CCMR_CC1S_TI1 | TIM_CCMR_CC2S_TI1);
+
+       /* Capture period on IC1/3 rising edge, duty cycle on IC2/4 falling. */
+       regmap_update_bits(priv->regmap, TIM_CCER, pwm->hwpwm < 2 ?
+                          TIM_CCER_CC12P : TIM_CCER_CC34P, pwm->hwpwm < 2 ?
+                          TIM_CCER_CC2P : TIM_CCER_CC4P);
+
+       ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty);
+       if (ret)
+               goto stop;
+
+       /*
+        * Got a capture. Try to improve accuracy at high rates:
+        * - decrease counter clock prescaler, scale up to max rate.
+        * - use input prescaler, capture once every /2 /4 or /8 edges.
+        */
+       if (raw_prd) {
+               u32 max_arr = priv->max_arr - 0x1000; /* arbitrary margin */
+
+               scale = max_arr / min(max_arr, raw_prd);
+       } else {
+               scale = priv->max_arr; /* bellow resolution, use max scale */
+       }
+
+       if (psc && scale > 1) {
+               /* 2nd measure with new scale */
+               psc /= scale;
+               regmap_write(priv->regmap, TIM_PSC, psc);
+               ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd,
+                                           &raw_dty);
+               if (ret)
+                       goto stop;
+       }
+
+       /* Compute intermediate period not to exceed timeout at low rates */
+       prd = (unsigned long long)raw_prd * (psc + 1) * NSEC_PER_SEC;
+       do_div(prd, rate);
+
+       for (icpsc = 0; icpsc < MAX_TIM_ICPSC ; icpsc++) {
+               /* input prescaler: also keep arbitrary margin */
+               if (raw_prd >= (priv->max_arr - 0x1000) >> (icpsc + 1))
+                       break;
+               if (prd >= (tmo_ms * NSEC_PER_MSEC) >> (icpsc + 2))
+                       break;
+       }
+
+       if (!icpsc)
+               goto done;
+
+       /* Last chance to improve period accuracy, using input prescaler */
+       regmap_update_bits(priv->regmap,
+                          pwm->hwpwm < 2 ? TIM_CCMR1 : TIM_CCMR2,
+                          TIM_CCMR_IC1PSC | TIM_CCMR_IC2PSC,
+                          FIELD_PREP(TIM_CCMR_IC1PSC, icpsc) |
+                          FIELD_PREP(TIM_CCMR_IC2PSC, icpsc));
+
+       ret = stm32_pwm_raw_capture(priv, pwm, tmo_ms, &raw_prd, &raw_dty);
+       if (ret)
+               goto stop;
+
+       if (raw_dty >= (raw_prd >> icpsc)) {
+               /*
+                * We may fall here using input prescaler, when input
+                * capture starts on high side (before falling edge).
+                * Example with icpsc to capture on each 4 events:
+                *
+                *       start   1st capture                     2nd capture
+                *         v     v                               v
+                *         ___   _____   _____   _____   _____   ____
+                * TI1..4     |__|    |__|    |__|    |__|    |__|
+                *            v  v    .  .    .  .    .       v  v
+                * icpsc1/3:  .  0    .  1    .  2    .  3    .  0
+                * icpsc2/4:  0       1       2       3       0
+                *            v  v                            v  v
+                * CCR1/3  ......t0..............................t2
+                * CCR2/4  ..t1..............................t1'...
+                *               .                            .  .
+                * Capture0:     .<----------------------------->.
+                * Capture1:     .<-------------------------->.  .
+                *               .                            .  .
+                * Period:       .<------>                    .  .
+                * Low side:                                  .<>.
+                *
+                * Result:
+                * - Period = Capture0 / icpsc
+                * - Duty = Period - Low side = Period - (Capture0 - Capture1)
+                */
+               raw_dty = (raw_prd >> icpsc) - (raw_prd - raw_dty);
+       }
+
+done:
+       prd = (unsigned long long)raw_prd * (psc + 1) * NSEC_PER_SEC;
+       result->period = DIV_ROUND_UP_ULL(prd, rate << icpsc);
+       dty = (unsigned long long)raw_dty * (psc + 1) * NSEC_PER_SEC;
+       result->duty_cycle = DIV_ROUND_UP_ULL(dty, rate);
+stop:
+       regmap_write(priv->regmap, TIM_CCER, 0);
+       regmap_write(priv->regmap, pwm->hwpwm < 2 ? TIM_CCMR1 : TIM_CCMR2, 0);
+       regmap_write(priv->regmap, TIM_PSC, 0);
+clk_dis:
+       clk_disable(priv->clk);
+unlock:
+       mutex_unlock(&priv->lock);
+
+       return ret;
+}
+
 static int stm32_pwm_config(struct stm32_pwm *priv, int ch,
                            int duty_ns, int period_ns)
 {
@@ -230,6 +484,7 @@ static int stm32_pwm_apply_locked(struct pwm_chip *chip, struct pwm_device *pwm,
 static const struct pwm_ops stm32pwm_ops = {
        .owner = THIS_MODULE,
        .apply = stm32_pwm_apply_locked,
+       .capture = IS_ENABLED(CONFIG_DMA_ENGINE) ? stm32_pwm_capture : NULL,
 };
 
 static int stm32_pwm_set_breakinput(struct stm32_pwm *priv,
index 0434ab7b649709cd6fcbf5192ca697b6f0148982..a8cb8d2f2abbbff0ce6405b14d4fc73172d1391b 100644 (file)
@@ -975,7 +975,7 @@ static int rio_mport_transfer_ioctl(struct file *filp, void __user *arg)
             priv->md->properties.transfer_mode) == 0)
                return -ENODEV;
 
-       transfer = vmalloc(transaction.count * sizeof(*transfer));
+       transfer = vmalloc(array_size(sizeof(*transfer), transaction.count));
        if (!transfer)
                return -ENOMEM;
 
index 161b927d9de1e24b3a034ac3926741312c655456..fd7b517132acef92915c72ea363222c1cac607bd 100644 (file)
@@ -425,9 +425,9 @@ static struct rio_dev *rio_setup_device(struct rio_net *net,
                rswitch = rdev->rswitch;
                rswitch->port_ok = 0;
                spin_lock_init(&rswitch->lock);
-               rswitch->route_table = kzalloc(sizeof(u8)*
-                                       RIO_MAX_ROUTE_ENTRIES(port->sys_size),
-                                       GFP_KERNEL);
+               rswitch->route_table =
+                       kzalloc(RIO_MAX_ROUTE_ENTRIES(port->sys_size),
+                               GFP_KERNEL);
                if (!rswitch->route_table)
                        goto cleanup;
                /* Initialize switch route table */
index 7652477e6a9df95cb4b43c0ef7753886250371fd..21e20483bd918b83e91cf5d8d14e73b4c208b99a 100644 (file)
@@ -424,9 +424,10 @@ static int act8865_pdata_from_dt(struct device *dev,
        if (matched <= 0)
                return matched;
 
-       pdata->regulators = devm_kzalloc(dev,
-                                        sizeof(struct act8865_regulator_data) *
-                                        num_matches, GFP_KERNEL);
+       pdata->regulators = devm_kcalloc(dev,
+                                        num_matches,
+                                        sizeof(struct act8865_regulator_data),
+                                        GFP_KERNEL);
        if (!pdata->regulators)
                return -ENOMEM;
 
index 874d415d6b4f9a5878fab8394bd043de0fdfeab1..565a71343a8e6014fa61ace5fb3a1b6b490f34b5 100644 (file)
@@ -239,8 +239,10 @@ static int as3711_regulator_probe(struct platform_device *pdev)
                }
        }
 
-       regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM *
-                       sizeof(struct as3711_regulator), GFP_KERNEL);
+       regs = devm_kcalloc(&pdev->dev,
+                           AS3711_REGULATOR_NUM,
+                           sizeof(struct as3711_regulator),
+                           GFP_KERNEL);
        if (!regs)
                return -ENOMEM;
 
index 9dd715407b39471e29309a924393ef8b2ba6ee50..92d6d7b10cf7fdc506edefb0130178b4a5186902 100644 (file)
@@ -383,8 +383,10 @@ static int bcm590xx_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, pmu);
 
-       pmu->desc = devm_kzalloc(&pdev->dev, BCM590XX_NUM_REGS *
-                       sizeof(struct regulator_desc), GFP_KERNEL);
+       pmu->desc = devm_kcalloc(&pdev->dev,
+                                BCM590XX_NUM_REGS,
+                                sizeof(struct regulator_desc),
+                                GFP_KERNEL);
        if (!pmu->desc)
                return -ENOMEM;
 
index 6a8f9cd69f520f8ff188c267a774b7c8af7ea64a..2df26f36c687681b51b2c648303a00f57034cd98 100644 (file)
@@ -681,8 +681,8 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt(
        if (!pdata)
                return ERR_PTR(-ENOMEM);
 
-       pdata->regulator_data = devm_kzalloc(&pdev->dev,
-                                       num * sizeof(*pdata->regulator_data),
+       pdata->regulator_data = devm_kcalloc(&pdev->dev,
+                                       num, sizeof(*pdata->regulator_data),
                                        GFP_KERNEL);
        if (!pdata->regulator_data)
                return ERR_PTR(-ENOMEM);
index a86b8997bb54cc3be5bc01354b4949e1cd9e38a7..b2f5ec4f658ab6eeb1801185fb478b4f31748305 100644 (file)
@@ -172,8 +172,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
 
        if (ret > 0) {
                config->nr_gpios = ret;
-               config->gpios = devm_kzalloc(dev,
-                                       sizeof(struct gpio) * config->nr_gpios,
+               config->gpios = devm_kcalloc(dev,
+                                       config->nr_gpios, sizeof(struct gpio),
                                        GFP_KERNEL);
                if (!config->gpios)
                        return ERR_PTR(-ENOMEM);
@@ -214,9 +214,9 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np,
                return ERR_PTR(-EINVAL);
        }
 
-       config->states = devm_kzalloc(dev,
-                               sizeof(struct gpio_regulator_state)
-                               * (proplen / 2),
+       config->states = devm_kcalloc(dev,
+                               proplen / 2,
+                               sizeof(struct gpio_regulator_state),
                                GFP_KERNEL);
        if (!config->states)
                return ERR_PTR(-ENOMEM);
index 66bbaa9994333dc383ea6b51aa14e823d43ada62..cc52779b53f709717438f562b2a53153ecb1557a 100644 (file)
@@ -194,8 +194,10 @@ static int of_get_max1586_platform_data(struct device *dev,
        if (matched <= 0)
                return matched;
 
-       pdata->subdevs = devm_kzalloc(dev, sizeof(struct max1586_subdev_data) *
-                                               matched, GFP_KERNEL);
+       pdata->subdevs = devm_kcalloc(dev,
+                                     matched,
+                                     sizeof(struct max1586_subdev_data),
+                                     GFP_KERNEL);
        if (!pdata->subdevs)
                return -ENOMEM;
 
index a6183425f27d19084c7eb261a127d678c88eab0b..4cf6897a401f62004fd3eee979de9c59e73cb6ae 100644 (file)
@@ -351,8 +351,10 @@ static int max8660_pdata_from_dt(struct device *dev,
        if (matched <= 0)
                return matched;
 
-       pdata->subdevs = devm_kzalloc(dev, sizeof(struct max8660_subdev_data) *
-                                               matched, GFP_KERNEL);
+       pdata->subdevs = devm_kcalloc(dev,
+                                     matched,
+                                     sizeof(struct max8660_subdev_data),
+                                     GFP_KERNEL);
        if (!pdata->subdevs)
                return -ENOMEM;
 
index 559b9ac454043e06ce49b83db459ca8f64ecdd27..a8ea30ee18a6be50722c51a0b045fd93c5b2e2be 100644 (file)
@@ -929,8 +929,9 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev,
        /* count the number of regulators to be supported in pmic */
        pdata->num_regulators = of_get_child_count(regulators_np);
 
-       rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
-                               pdata->num_regulators, GFP_KERNEL);
+       rdata = devm_kcalloc(&pdev->dev,
+                            pdata->num_regulators, sizeof(*rdata),
+                            GFP_KERNEL);
        if (!rdata) {
                of_node_put(regulators_np);
                return -ENOMEM;
index 6a2b61c012b50157773d533ea904fd8d59da9298..6b9f262ebbb09034d8822da5bfed683dbff09e2e 100644 (file)
@@ -670,8 +670,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev,
        /* count the number of regulators to be supported in pmic */
        pdata->num_regulators = of_get_child_count(regulators_np);
 
-       rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) *
-                               pdata->num_regulators, GFP_KERNEL);
+       rdata = devm_kcalloc(iodev->dev,
+                            pdata->num_regulators, sizeof(*rdata),
+                            GFP_KERNEL);
        if (!rdata) {
                of_node_put(regulators_np);
                return -ENOMEM;
index 41271aeea63e3ab36a2359e1857efdc1435f491d..da4fb98247578546f2babe0f790d47ac71656237 100644 (file)
@@ -171,7 +171,7 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt(
        if (!parent)
                return NULL;
 
-       data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators,
+       data = devm_kcalloc(&pdev->dev, priv->num_regulators, sizeof(*data),
                            GFP_KERNEL);
        if (!data) {
                of_node_put(parent);
index 8f782d22fdbef61d4566c9bc63bc6120be461cbe..92b41a6a4dc201101e491830dcaa3fe4b8ddd7b9 100644 (file)
@@ -173,8 +173,9 @@ static int pbias_regulator_probe(struct platform_device *pdev)
        if (count < 0)
                return count;
 
-       drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data)
-                              * count, GFP_KERNEL);
+       drvdata = devm_kcalloc(&pdev->dev,
+                              count, sizeof(struct pbias_regulator_data),
+                              GFP_KERNEL);
        if (!drvdata)
                return -ENOMEM;
 
index d0f1340168b18080875e08e8b0b1f578cc5c3091..2ec51af4367365bcb119be2956dd78d5fb4979b5 100644 (file)
@@ -132,8 +132,10 @@ static int rc5t583_regulator_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       regs = devm_kzalloc(&pdev->dev, RC5T583_REGULATOR_MAX *
-                       sizeof(struct rc5t583_regulator), GFP_KERNEL);
+       regs = devm_kcalloc(&pdev->dev,
+                           RC5T583_REGULATOR_MAX,
+                           sizeof(struct rc5t583_regulator),
+                           GFP_KERNEL);
        if (!regs)
                return -ENOMEM;
 
index 7726b874e5399cd55be8c4b7f0963956b64af0db..d1207ec683db22e72c4811a04f2d9529b7a65906 100644 (file)
@@ -1139,8 +1139,8 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev,
-                       sizeof(*s2mps11->ext_control_gpio) * rdev_num,
+       s2mps11->ext_control_gpio = devm_kmalloc_array(&pdev->dev,
+                       rdev_num, sizeof(*s2mps11->ext_control_gpio),
                        GFP_KERNEL);
        if (!s2mps11->ext_control_gpio)
                return -ENOMEM;
@@ -1162,7 +1162,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev)
                }
        }
 
-       rdata = kzalloc(sizeof(*rdata) * rdev_num, GFP_KERNEL);
+       rdata = kcalloc(rdev_num, sizeof(*rdata), GFP_KERNEL);
        if (!rdata)
                return -ENOMEM;
 
index b8443a360646b7998f2a41e6435be6643c69f63c..0cbc980753c2f0fcb6151a67d60457e2daeadb93 100644 (file)
@@ -553,13 +553,15 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev,
        /* count the number of regulators to be supported in pmic */
        pdata->num_regulators = of_get_child_count(regulators_np);
 
-       rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
-                               pdata->num_regulators, GFP_KERNEL);
+       rdata = devm_kcalloc(&pdev->dev,
+                            pdata->num_regulators, sizeof(*rdata),
+                            GFP_KERNEL);
        if (!rdata)
                return -ENOMEM;
 
-       rmode = devm_kzalloc(&pdev->dev, sizeof(*rmode) *
-                               pdata->num_regulators, GFP_KERNEL);
+       rmode = devm_kcalloc(&pdev->dev,
+                            pdata->num_regulators, sizeof(*rmode),
+                            GFP_KERNEL);
        if (!rmode)
                return -ENOMEM;
 
index d2f9942987535586dc69da863fbaa6b4ab16bdf4..cced1ffb896c1169dba81bde5c9b83a63890ceab 100644 (file)
@@ -532,13 +532,13 @@ static int ti_abb_init_table(struct device *dev, struct ti_abb *abb,
        }
        num_entries /= num_values;
 
-       info = devm_kzalloc(dev, sizeof(*info) * num_entries, GFP_KERNEL);
+       info = devm_kcalloc(dev, num_entries, sizeof(*info), GFP_KERNEL);
        if (!info)
                return -ENOMEM;
 
        abb->info = info;
 
-       volt_table = devm_kzalloc(dev, sizeof(unsigned int) * num_entries,
+       volt_table = devm_kcalloc(dev, num_entries, sizeof(unsigned int),
                                  GFP_KERNEL);
        if (!volt_table)
                return -ENOMEM;
index 2d398fa3b720d633f20283ba69836175d689a8e0..edaef9e4dc74ea7e1994343a2e2eb6a4e7bf02ef 100644 (file)
@@ -331,8 +331,9 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data(
        if (!tps65090_pdata)
                return ERR_PTR(-ENOMEM);
 
-       reg_pdata = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX *
-                               sizeof(*reg_pdata), GFP_KERNEL);
+       reg_pdata = devm_kcalloc(&pdev->dev,
+                                TPS65090_REGULATOR_MAX, sizeof(*reg_pdata),
+                                GFP_KERNEL);
        if (!reg_pdata)
                return ERR_PTR(-ENOMEM);
 
@@ -429,8 +430,9 @@ static int tps65090_regulator_probe(struct platform_device *pdev)
                return tps65090_pdata ? PTR_ERR(tps65090_pdata) : -EINVAL;
        }
 
-       pmic = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * sizeof(*pmic),
-                       GFP_KERNEL);
+       pmic = devm_kcalloc(&pdev->dev,
+                           TPS65090_REGULATOR_MAX, sizeof(*pmic),
+                           GFP_KERNEL);
        if (!pmic)
                return -ENOMEM;
 
index 7b12e880d1eae0d4f332119d82e510a643dc89e5..fc12badf38059f96b4bea38a6ffaed8bd9a71dbc 100644 (file)
@@ -229,8 +229,9 @@ static int tps65217_regulator_probe(struct platform_device *pdev)
        unsigned int val;
 
        /* Allocate memory for strobes */
-       tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) *
-                                   TPS65217_NUM_REGULATOR, GFP_KERNEL);
+       tps->strobes = devm_kcalloc(&pdev->dev,
+                                   TPS65217_NUM_REGULATOR, sizeof(u8),
+                                   GFP_KERNEL);
 
        platform_set_drvdata(pdev, tps);
 
index 1827185beacc4e7f9079ae68a170f9c39003560c..6209beee10188d6c17e0d9f395367909a4e3aacd 100644 (file)
@@ -324,8 +324,9 @@ static int tps65218_regulator_probe(struct platform_device *pdev)
        config.regmap = tps->regmap;
 
        /* Allocate memory for strobes */
-       tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) *
-                                   TPS65218_NUM_REGULATOR, GFP_KERNEL);
+       tps->strobes = devm_kcalloc(&pdev->dev,
+                                   TPS65218_NUM_REGULATOR, sizeof(u8),
+                                   GFP_KERNEL);
        if (!tps->strobes)
                return -ENOMEM;
 
index 81672a58fcc234f381a40c3b43eda132a6dd96a5..02ccdaa226a73f97a5fc812f5173c2bef44d25f4 100644 (file)
@@ -1131,18 +1131,24 @@ static int tps65910_probe(struct platform_device *pdev)
                return -ENODEV;
        }
 
-       pmic->desc = devm_kzalloc(&pdev->dev, pmic->num_regulators *
-                       sizeof(struct regulator_desc), GFP_KERNEL);
+       pmic->desc = devm_kcalloc(&pdev->dev,
+                                 pmic->num_regulators,
+                                 sizeof(struct regulator_desc),
+                                 GFP_KERNEL);
        if (!pmic->desc)
                return -ENOMEM;
 
-       pmic->info = devm_kzalloc(&pdev->dev, pmic->num_regulators *
-                       sizeof(struct tps_info *), GFP_KERNEL);
+       pmic->info = devm_kcalloc(&pdev->dev,
+                                 pmic->num_regulators,
+                                 sizeof(struct tps_info *),
+                                 GFP_KERNEL);
        if (!pmic->info)
                return -ENOMEM;
 
-       pmic->rdev = devm_kzalloc(&pdev->dev, pmic->num_regulators *
-                       sizeof(struct regulator_dev *), GFP_KERNEL);
+       pmic->rdev = devm_kcalloc(&pdev->dev,
+                                 pmic->num_regulators,
+                                 sizeof(struct regulator_dev *),
+                                 GFP_KERNEL);
        if (!pmic->rdev)
                return -ENOMEM;
 
index d4cc60ad18ae4b39cc2c484e971b0075e51231ef..1001147404c38ecbc091e618111bb06f9352ba29 100644 (file)
@@ -691,8 +691,8 @@ static int tps80031_regulator_probe(struct platform_device *pdev)
                return -EINVAL;
        }
 
-       pmic = devm_kzalloc(&pdev->dev,
-                       TPS80031_REGULATOR_MAX * sizeof(*pmic), GFP_KERNEL);
+       pmic = devm_kcalloc(&pdev->dev,
+                       TPS80031_REGULATOR_MAX, sizeof(*pmic), GFP_KERNEL);
        if (!pmic)
                return -ENOMEM;
 
index 027274008b086d6f421a3aa0c0ecf5cf2804cb76..cd1c168fd18898dc802e90b5327abc2b9a6fae0d 100644 (file)
@@ -24,7 +24,6 @@ config IMX_REMOTEPROC
 
 config OMAP_REMOTEPROC
        tristate "OMAP remoteproc support"
-       depends on HAS_DMA
        depends on ARCH_OMAP4 || SOC_OMAP5
        depends on OMAP_IOMMU
        select MAILBOX
index bf3b9034c319eed88f86a1ef3fd61792f389466e..b668e32996e215bd474f0e0d2060bdf80c13c573 100644 (file)
@@ -25,7 +25,7 @@
 #include "remoteproc_internal.h"
 
 static char *da8xx_fw_name;
-module_param(da8xx_fw_name, charp, S_IRUGO);
+module_param(da8xx_fw_name, charp, 0444);
 MODULE_PARM_DESC(da8xx_fw_name,
                 "Name of DSP firmware file in /lib/firmware (if not specified defaults to 'rproc-dsp-fw')");
 
@@ -138,6 +138,7 @@ static int da8xx_rproc_start(struct rproc *rproc)
        struct device *dev = rproc->dev.parent;
        struct da8xx_rproc *drproc = (struct da8xx_rproc *)rproc->priv;
        struct clk *dsp_clk = drproc->dsp_clk;
+       int ret;
 
        /* hw requires the start (boot) address be on 1KB boundary */
        if (rproc->bootaddr & 0x3ff) {
@@ -148,7 +149,12 @@ static int da8xx_rproc_start(struct rproc *rproc)
 
        writel(rproc->bootaddr, drproc->bootreg);
 
-       clk_enable(dsp_clk);
+       ret = clk_prepare_enable(dsp_clk);
+       if (ret) {
+               dev_err(dev, "clk_prepare_enable() failed: %d\n", ret);
+               return ret;
+       }
+
        davinci_clk_reset_deassert(dsp_clk);
 
        return 0;
@@ -159,7 +165,7 @@ static int da8xx_rproc_stop(struct rproc *rproc)
        struct da8xx_rproc *drproc = rproc->priv;
 
        davinci_clk_reset_assert(drproc->dsp_clk);
-       clk_disable(drproc->dsp_clk);
+       clk_disable_unprepare(drproc->dsp_clk);
 
        return 0;
 }
index cbbafdcaaecb7576da27039233c72c47a7bcf5ae..2bf8e7c49f2a7ed8ae9d9ec425b391e1544cd599 100644 (file)
@@ -57,6 +57,8 @@
 #define RMB_PMI_META_DATA_REG          0x10
 #define RMB_PMI_CODE_START_REG         0x14
 #define RMB_PMI_CODE_LENGTH_REG                0x18
+#define RMB_MBA_MSS_STATUS             0x40
+#define RMB_MBA_ALT_RESET              0x44
 
 #define RMB_CMD_META_DATA_READY                0x1
 #define RMB_CMD_LOAD_READY             0x2
 #define QDSP6SS_XO_CBCR                0x0038
 #define QDSP6SS_ACC_OVERRIDE_VAL               0x20
 
+/* QDSP6v65 parameters */
+#define QDSP6SS_SLEEP                   0x3C
+#define QDSP6SS_BOOT_CORE_START         0x400
+#define QDSP6SS_BOOT_CMD                0x404
+#define SLEEP_CHECK_MAX_LOOPS           200
+#define BOOT_FSM_TIMEOUT                10000
+
 struct reg_info {
        struct regulator *reg;
        int uV;
@@ -121,9 +130,11 @@ struct rproc_hexagon_res {
        struct qcom_mss_reg_res *proxy_supply;
        struct qcom_mss_reg_res *active_supply;
        char **proxy_clk_names;
+       char **reset_clk_names;
        char **active_clk_names;
        int version;
        bool need_mem_protection;
+       bool has_alt_reset;
 };
 
 struct q6v5 {
@@ -143,9 +154,15 @@ struct q6v5 {
        struct qcom_smem_state *state;
        unsigned stop_bit;
 
+       int handover_irq;
+
+       bool proxy_unvoted;
+
        struct clk *active_clks[8];
+       struct clk *reset_clks[4];
        struct clk *proxy_clks[4];
        int active_clk_count;
+       int reset_clk_count;
        int proxy_clk_count;
 
        struct reg_info active_regs[1];
@@ -166,10 +183,12 @@ struct q6v5 {
        void *mpss_region;
        size_t mpss_size;
 
+       struct qcom_rproc_glink glink_subdev;
        struct qcom_rproc_subdev smd_subdev;
        struct qcom_rproc_ssr ssr_subdev;
        struct qcom_sysmon *sysmon;
        bool need_mem_protection;
+       bool has_alt_reset;
        int mpss_perm;
        int mba_perm;
        int version;
@@ -179,6 +198,7 @@ enum {
        MSS_MSM8916,
        MSS_MSM8974,
        MSS_MSM8996,
+       MSS_SDM845,
 };
 
 static int q6v5_regulator_init(struct device *dev, struct reg_info *regs,
@@ -333,6 +353,29 @@ static int q6v5_load(struct rproc *rproc, const struct firmware *fw)
        return 0;
 }
 
+static int q6v5_reset_assert(struct q6v5 *qproc)
+{
+       if (qproc->has_alt_reset)
+               return reset_control_reset(qproc->mss_restart);
+       else
+               return reset_control_assert(qproc->mss_restart);
+}
+
+static int q6v5_reset_deassert(struct q6v5 *qproc)
+{
+       int ret;
+
+       if (qproc->has_alt_reset) {
+               writel(1, qproc->rmb_base + RMB_MBA_ALT_RESET);
+               ret = reset_control_reset(qproc->mss_restart);
+               writel(0, qproc->rmb_base + RMB_MBA_ALT_RESET);
+       } else {
+               ret = reset_control_deassert(qproc->mss_restart);
+       }
+
+       return ret;
+}
+
 static int q6v5_rmb_pbl_wait(struct q6v5 *qproc, int ms)
 {
        unsigned long timeout;
@@ -385,8 +428,35 @@ static int q6v5proc_reset(struct q6v5 *qproc)
        int ret;
        int i;
 
+       if (qproc->version == MSS_SDM845) {
+               val = readl(qproc->reg_base + QDSP6SS_SLEEP);
+               val |= 0x1;
+               writel(val, qproc->reg_base + QDSP6SS_SLEEP);
 
-       if (qproc->version == MSS_MSM8996) {
+               ret = readl_poll_timeout(qproc->reg_base + QDSP6SS_SLEEP,
+                                        val, !(val & BIT(31)), 1,
+                                        SLEEP_CHECK_MAX_LOOPS);
+               if (ret) {
+                       dev_err(qproc->dev, "QDSP6SS Sleep clock timed out\n");
+                       return -ETIMEDOUT;
+               }
+
+               /* De-assert QDSP6 stop core */
+               writel(1, qproc->reg_base + QDSP6SS_BOOT_CORE_START);
+               /* Trigger boot FSM */
+               writel(1, qproc->reg_base + QDSP6SS_BOOT_CMD);
+
+               ret = readl_poll_timeout(qproc->rmb_base + RMB_MBA_MSS_STATUS,
+                               val, (val & BIT(0)) != 0, 10, BOOT_FSM_TIMEOUT);
+               if (ret) {
+                       dev_err(qproc->dev, "Boot FSM failed to complete.\n");
+                       /* Reset the modem so that boot FSM is in reset state */
+                       q6v5_reset_deassert(qproc);
+                       return ret;
+               }
+
+               goto pbl_wait;
+       } else if (qproc->version == MSS_MSM8996) {
                /* Override the ACC value if required */
                writel(QDSP6SS_ACC_OVERRIDE_VAL,
                       qproc->reg_base + QDSP6SS_STRAP_ACC);
@@ -494,6 +564,7 @@ static int q6v5proc_reset(struct q6v5 *qproc)
        val &= ~Q6SS_STOP_CORE;
        writel(val, qproc->reg_base + QDSP6SS_RESET_REG);
 
+pbl_wait:
        /* Wait for PBL status */
        ret = q6v5_rmb_pbl_wait(qproc, 1000);
        if (ret == -ETIMEDOUT) {
@@ -615,7 +686,7 @@ static int q6v5_mpss_load(struct q6v5 *qproc)
        struct elf32_hdr *ehdr;
        phys_addr_t mpss_reloc;
        phys_addr_t boot_addr;
-       phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX;
+       phys_addr_t min_addr = PHYS_ADDR_MAX;
        phys_addr_t max_addr = 0;
        bool relocate = false;
        char seg_name[10];
@@ -727,11 +798,15 @@ static int q6v5_start(struct rproc *rproc)
        int xfermemop_ret;
        int ret;
 
+       qproc->proxy_unvoted = false;
+
+       enable_irq(qproc->handover_irq);
+
        ret = q6v5_regulator_enable(qproc, qproc->proxy_regs,
                                    qproc->proxy_reg_count);
        if (ret) {
                dev_err(qproc->dev, "failed to enable proxy supplies\n");
-               return ret;
+               goto disable_irqs;
        }
 
        ret = q6v5_clk_enable(qproc->dev, qproc->proxy_clks,
@@ -747,12 +822,20 @@ static int q6v5_start(struct rproc *rproc)
                dev_err(qproc->dev, "failed to enable supplies\n");
                goto disable_proxy_clk;
        }
-       ret = reset_control_deassert(qproc->mss_restart);
+
+       ret = q6v5_clk_enable(qproc->dev, qproc->reset_clks,
+                             qproc->reset_clk_count);
        if (ret) {
-               dev_err(qproc->dev, "failed to deassert mss restart\n");
+               dev_err(qproc->dev, "failed to enable reset clocks\n");
                goto disable_vdd;
        }
 
+       ret = q6v5_reset_deassert(qproc);
+       if (ret) {
+               dev_err(qproc->dev, "failed to deassert mss restart\n");
+               goto disable_reset_clks;
+       }
+
        ret = q6v5_clk_enable(qproc->dev, qproc->active_clks,
                              qproc->active_clk_count);
        if (ret) {
@@ -761,13 +844,11 @@ static int q6v5_start(struct rproc *rproc)
        }
 
        /* Assign MBA image access in DDR to q6 */
-       xfermemop_ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,
-                                               qproc->mba_phys,
-                                               qproc->mba_size);
-       if (xfermemop_ret) {
+       ret = q6v5_xfer_mem_ownership(qproc, &qproc->mba_perm, true,
+                                     qproc->mba_phys, qproc->mba_size);
+       if (ret) {
                dev_err(qproc->dev,
-                       "assigning Q6 access to mba memory failed: %d\n",
-                       xfermemop_ret);
+                       "assigning Q6 access to mba memory failed: %d\n", ret);
                goto disable_active_clks;
        }
 
@@ -810,11 +891,6 @@ static int q6v5_start(struct rproc *rproc)
                        "Failed to reclaim mba buffer system may become unstable\n");
        qproc->running = true;
 
-       q6v5_clk_disable(qproc->dev, qproc->proxy_clks,
-                        qproc->proxy_clk_count);
-       q6v5_regulator_disable(qproc, qproc->proxy_regs,
-                              qproc->proxy_reg_count);
-
        return 0;
 
 reclaim_mpss:
@@ -842,7 +918,10 @@ static int q6v5_start(struct rproc *rproc)
                         qproc->active_clk_count);
 
 assert_reset:
-       reset_control_assert(qproc->mss_restart);
+       q6v5_reset_assert(qproc);
+disable_reset_clks:
+       q6v5_clk_disable(qproc->dev, qproc->reset_clks,
+                        qproc->reset_clk_count);
 disable_vdd:
        q6v5_regulator_disable(qproc, qproc->active_regs,
                               qproc->active_reg_count);
@@ -853,6 +932,9 @@ static int q6v5_start(struct rproc *rproc)
        q6v5_regulator_disable(qproc, qproc->proxy_regs,
                               qproc->proxy_reg_count);
 
+disable_irqs:
+       disable_irq(qproc->handover_irq);
+
        return ret;
 }
 
@@ -892,7 +974,19 @@ static int q6v5_stop(struct rproc *rproc)
                                      qproc->mpss_phys, qproc->mpss_size);
        WARN_ON(ret);
 
-       reset_control_assert(qproc->mss_restart);
+       q6v5_reset_assert(qproc);
+
+       disable_irq(qproc->handover_irq);
+
+       if (!qproc->proxy_unvoted) {
+               q6v5_clk_disable(qproc->dev, qproc->proxy_clks,
+                                qproc->proxy_clk_count);
+               q6v5_regulator_disable(qproc, qproc->proxy_regs,
+                                      qproc->proxy_reg_count);
+       }
+
+       q6v5_clk_disable(qproc->dev, qproc->reset_clks,
+                        qproc->reset_clk_count);
        q6v5_clk_disable(qproc->dev, qproc->active_clks,
                         qproc->active_clk_count);
        q6v5_regulator_disable(qproc, qproc->active_regs,
@@ -960,7 +1054,7 @@ static irqreturn_t q6v5_fatal_interrupt(int irq, void *dev)
        return IRQ_HANDLED;
 }
 
-static irqreturn_t q6v5_handover_interrupt(int irq, void *dev)
+static irqreturn_t q6v5_ready_interrupt(int irq, void *dev)
 {
        struct q6v5 *qproc = dev;
 
@@ -968,6 +1062,20 @@ static irqreturn_t q6v5_handover_interrupt(int irq, void *dev)
        return IRQ_HANDLED;
 }
 
+static irqreturn_t q6v5_handover_interrupt(int irq, void *dev)
+{
+       struct q6v5 *qproc = dev;
+
+       q6v5_clk_disable(qproc->dev, qproc->proxy_clks,
+                        qproc->proxy_clk_count);
+       q6v5_regulator_disable(qproc, qproc->proxy_regs,
+                              qproc->proxy_reg_count);
+
+       qproc->proxy_unvoted = true;
+
+       return IRQ_HANDLED;
+}
+
 static irqreturn_t q6v5_stop_ack_interrupt(int irq, void *dev)
 {
        struct q6v5 *qproc = dev;
@@ -1051,22 +1159,23 @@ static int q6v5_request_irq(struct q6v5 *qproc,
                             const char *name,
                             irq_handler_t thread_fn)
 {
+       int irq;
        int ret;
 
-       ret = platform_get_irq_byname(pdev, name);
-       if (ret < 0) {
+       irq = platform_get_irq_byname(pdev, name);
+       if (irq < 0) {
                dev_err(&pdev->dev, "no %s IRQ defined\n", name);
-               return ret;
+               return irq;
        }
 
-       ret = devm_request_threaded_irq(&pdev->dev, ret,
+       ret = devm_request_threaded_irq(&pdev->dev, irq,
                                        NULL, thread_fn,
                                        IRQF_TRIGGER_RISING | IRQF_ONESHOT,
                                        "q6v5", qproc);
        if (ret)
                dev_err(&pdev->dev, "request %s IRQ failed\n", name);
 
-       return ret;
+       return ret ? : irq;
 }
 
 static int q6v5_alloc_memory_region(struct q6v5 *qproc)
@@ -1157,6 +1266,14 @@ static int q6v5_probe(struct platform_device *pdev)
        }
        qproc->proxy_clk_count = ret;
 
+       ret = q6v5_init_clocks(&pdev->dev, qproc->reset_clks,
+                              desc->reset_clk_names);
+       if (ret < 0) {
+               dev_err(&pdev->dev, "Failed to get reset clocks.\n");
+               goto free_rproc;
+       }
+       qproc->reset_clk_count = ret;
+
        ret = q6v5_init_clocks(&pdev->dev, qproc->active_clks,
                               desc->active_clk_names);
        if (ret < 0) {
@@ -1186,6 +1303,7 @@ static int q6v5_probe(struct platform_device *pdev)
                goto free_rproc;
 
        qproc->version = desc->version;
+       qproc->has_alt_reset = desc->has_alt_reset;
        qproc->need_mem_protection = desc->need_mem_protection;
        ret = q6v5_request_irq(qproc, pdev, "wdog", q6v5_wdog_interrupt);
        if (ret < 0)
@@ -1195,9 +1313,15 @@ static int q6v5_probe(struct platform_device *pdev)
        if (ret < 0)
                goto free_rproc;
 
+       ret = q6v5_request_irq(qproc, pdev, "ready", q6v5_ready_interrupt);
+       if (ret < 0)
+               goto free_rproc;
+
        ret = q6v5_request_irq(qproc, pdev, "handover", q6v5_handover_interrupt);
        if (ret < 0)
                goto free_rproc;
+       qproc->handover_irq = ret;
+       disable_irq(qproc->handover_irq);
 
        ret = q6v5_request_irq(qproc, pdev, "stop-ack", q6v5_stop_ack_interrupt);
        if (ret < 0)
@@ -1210,6 +1334,7 @@ static int q6v5_probe(struct platform_device *pdev)
        }
        qproc->mpss_perm = BIT(QCOM_SCM_VMID_HLOS);
        qproc->mba_perm = BIT(QCOM_SCM_VMID_HLOS);
+       qcom_add_glink_subdev(rproc, &qproc->glink_subdev);
        qcom_add_smd_subdev(rproc, &qproc->smd_subdev);
        qcom_add_ssr_subdev(rproc, &qproc->ssr_subdev, "mpss");
        qproc->sysmon = qcom_add_sysmon_subdev(rproc, "modem", 0x12);
@@ -1233,6 +1358,7 @@ static int q6v5_remove(struct platform_device *pdev)
        rproc_del(qproc->rproc);
 
        qcom_remove_sysmon_subdev(qproc->sysmon);
+       qcom_remove_glink_subdev(qproc->rproc, &qproc->glink_subdev);
        qcom_remove_smd_subdev(qproc->rproc, &qproc->smd_subdev);
        qcom_remove_ssr_subdev(qproc->rproc, &qproc->ssr_subdev);
        rproc_free(qproc->rproc);
@@ -1240,6 +1366,31 @@ static int q6v5_remove(struct platform_device *pdev)
        return 0;
 }
 
+static const struct rproc_hexagon_res sdm845_mss = {
+       .hexagon_mba_image = "mba.mbn",
+       .proxy_clk_names = (char*[]){
+                       "xo",
+                       "axis2",
+                       "prng",
+                       NULL
+       },
+       .reset_clk_names = (char*[]){
+                       "iface",
+                       "snoc_axi",
+                       NULL
+       },
+       .active_clk_names = (char*[]){
+                       "bus",
+                       "mem",
+                       "gpll0_mss",
+                       "mnoc_axi",
+                       NULL
+       },
+       .need_mem_protection = true,
+       .has_alt_reset = true,
+       .version = MSS_SDM845,
+};
+
 static const struct rproc_hexagon_res msm8996_mss = {
        .hexagon_mba_image = "mba.mbn",
        .proxy_clk_names = (char*[]){
@@ -1255,6 +1406,7 @@ static const struct rproc_hexagon_res msm8996_mss = {
                        NULL
        },
        .need_mem_protection = true,
+       .has_alt_reset = false,
        .version = MSS_MSM8996,
 };
 
@@ -1286,6 +1438,7 @@ static const struct rproc_hexagon_res msm8916_mss = {
                NULL
        },
        .need_mem_protection = false,
+       .has_alt_reset = false,
        .version = MSS_MSM8916,
 };
 
@@ -1325,6 +1478,7 @@ static const struct rproc_hexagon_res msm8974_mss = {
                NULL
        },
        .need_mem_protection = false,
+       .has_alt_reset = false,
        .version = MSS_MSM8974,
 };
 
@@ -1333,6 +1487,7 @@ static const struct of_device_id q6v5_of_match[] = {
        { .compatible = "qcom,msm8916-mss-pil", .data = &msm8916_mss},
        { .compatible = "qcom,msm8974-mss-pil", .data = &msm8974_mss},
        { .compatible = "qcom,msm8996-mss-pil", .data = &msm8996_mss},
+       { .compatible = "qcom,sdm845-mss-pil", .data = &sdm845_mss},
        { },
 };
 MODULE_DEVICE_TABLE(of, q6v5_of_match);
index 99520b0a1329b4d35d66b4b288b5ad63d1a8eacf..a2635c21db7f8eccc77965ed7975f9e34a9e28fd 100644 (file)
@@ -189,7 +189,8 @@ static int ti_syscon_reset_probe(struct platform_device *pdev)
        }
 
        nr_controls = (size / sizeof(*list)) / 7;
-       controls = devm_kzalloc(dev, nr_controls * sizeof(*controls), GFP_KERNEL);
+       controls = devm_kcalloc(dev, nr_controls, sizeof(*controls),
+                               GFP_KERNEL);
        if (!controls)
                return -ENOMEM;
 
index ac18f2f27881091d529b746c96c6dff2ab3f99d3..e9030ff1bf2fa3d27e83b9848f012a13becb4500 100644 (file)
@@ -63,6 +63,9 @@ static const struct uniphier_reset_data uniphier_pro4_sys_reset_data[] = {
        UNIPHIER_RESETX(12, 0x2000, 6),         /* GIO (Ether, SATA, USB3) */
        UNIPHIER_RESETX(14, 0x2000, 17),        /* USB30 */
        UNIPHIER_RESETX(15, 0x2004, 17),        /* USB31 */
+       UNIPHIER_RESETX(28, 0x2000, 18),        /* SATA0 */
+       UNIPHIER_RESETX(29, 0x2004, 18),        /* SATA1 */
+       UNIPHIER_RESETX(30, 0x2000, 19),        /* SATA-PHY */
        UNIPHIER_RESETX(40, 0x2000, 13),        /* AIO */
        UNIPHIER_RESET_END,
 };
@@ -73,6 +76,7 @@ static const struct uniphier_reset_data uniphier_pro5_sys_reset_data[] = {
        UNIPHIER_RESETX(12, 0x2000, 6),         /* GIO (PCIe, USB3) */
        UNIPHIER_RESETX(14, 0x2000, 17),        /* USB30 */
        UNIPHIER_RESETX(15, 0x2004, 17),        /* USB31 */
+       UNIPHIER_RESETX(24, 0x2008, 2),         /* PCIe */
        UNIPHIER_RESETX(40, 0x2000, 13),        /* AIO */
        UNIPHIER_RESET_END,
 };
@@ -89,7 +93,7 @@ static const struct uniphier_reset_data uniphier_pxs2_sys_reset_data[] = {
        UNIPHIER_RESETX(20, 0x2014, 5),         /* USB31-PHY0 */
        UNIPHIER_RESETX(21, 0x2014, 1),         /* USB31-PHY1 */
        UNIPHIER_RESETX(28, 0x2014, 12),        /* SATA */
-       UNIPHIER_RESET(29, 0x2014, 8),          /* SATA-PHY (active high) */
+       UNIPHIER_RESET(30, 0x2014, 8),          /* SATA-PHY (active high) */
        UNIPHIER_RESETX(40, 0x2000, 13),        /* AIO */
        UNIPHIER_RESET_END,
 };
@@ -99,6 +103,7 @@ static const struct uniphier_reset_data uniphier_ld11_sys_reset_data[] = {
        UNIPHIER_RESETX(4, 0x200c, 2),          /* eMMC */
        UNIPHIER_RESETX(6, 0x200c, 6),          /* Ether */
        UNIPHIER_RESETX(8, 0x200c, 8),          /* STDMAC (HSC, MIO) */
+       UNIPHIER_RESETX(9, 0x200c, 9),          /* HSC */
        UNIPHIER_RESETX(40, 0x2008, 0),         /* AIO */
        UNIPHIER_RESETX(41, 0x2008, 1),         /* EVEA */
        UNIPHIER_RESETX(42, 0x2010, 2),         /* EXIV */
@@ -110,11 +115,13 @@ static const struct uniphier_reset_data uniphier_ld20_sys_reset_data[] = {
        UNIPHIER_RESETX(4, 0x200c, 2),          /* eMMC */
        UNIPHIER_RESETX(6, 0x200c, 6),          /* Ether */
        UNIPHIER_RESETX(8, 0x200c, 8),          /* STDMAC (HSC) */
+       UNIPHIER_RESETX(9, 0x200c, 9),          /* HSC */
        UNIPHIER_RESETX(14, 0x200c, 5),         /* USB30 */
        UNIPHIER_RESETX(16, 0x200c, 12),        /* USB30-PHY0 */
        UNIPHIER_RESETX(17, 0x200c, 13),        /* USB30-PHY1 */
        UNIPHIER_RESETX(18, 0x200c, 14),        /* USB30-PHY2 */
        UNIPHIER_RESETX(19, 0x200c, 15),        /* USB30-PHY3 */
+       UNIPHIER_RESETX(24, 0x200c, 4),         /* PCIe */
        UNIPHIER_RESETX(40, 0x2008, 0),         /* AIO */
        UNIPHIER_RESETX(41, 0x2008, 1),         /* EVEA */
        UNIPHIER_RESETX(42, 0x2010, 2),         /* EXIV */
@@ -134,6 +141,10 @@ static const struct uniphier_reset_data uniphier_pxs3_sys_reset_data[] = {
        UNIPHIER_RESETX(18, 0x200c, 20),        /* USB30-PHY2 */
        UNIPHIER_RESETX(20, 0x200c, 17),        /* USB31-PHY0 */
        UNIPHIER_RESETX(21, 0x200c, 19),        /* USB31-PHY1 */
+       UNIPHIER_RESETX(24, 0x200c, 3),         /* PCIe */
+       UNIPHIER_RESETX(28, 0x200c, 7),         /* SATA0 */
+       UNIPHIER_RESETX(29, 0x200c, 8),         /* SATA1 */
+       UNIPHIER_RESETX(30, 0x200c, 21),        /* SATA-PHY */
        UNIPHIER_RESET_END,
 };
 
index 65a9f6b892f06a9ffc06e93181a84cadefab09d2..d0322b41eca54c87b749c86a944e2d6073ed6c9c 100644 (file)
@@ -1,3 +1,5 @@
+# SPDX-License-Identifier: GPL-2.0
+
 menu "Rpmsg drivers"
 
 # RPMSG always gets selected by whoever wants it
@@ -39,6 +41,7 @@ config RPMSG_QCOM_GLINK_SMEM
 
 config RPMSG_QCOM_SMD
        tristate "Qualcomm Shared Memory Driver (SMD)"
+       depends on MAILBOX
        depends on QCOM_SMEM
        select RPMSG
        help
index 768ef542a841161ce0276c2a181067c3ed12ba28..f505f58b797d7b3088e3eb8587cb12bc16304636 100644 (file)
@@ -1,14 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2016-2017, Linaro Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 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/idr.h>
index 0cae8a8199f86938ccb92089b9f3e8f7e351e1d3..624184fc458ee94cf8fda772ca7a24e33b98a874 100644 (file)
@@ -1,14 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Copyright (c) 2016-2017, Linaro Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 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.
  */
 
 #ifndef __QCOM_GLINK_NATIVE_H__
index 69b25d157d0f67f49ece7a8ec5abc56165f77e27..f64f45d1a735a6933fe109699aed4f6b11eb0f0c 100644 (file)
@@ -1,14 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2016-2017, Linaro Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 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/idr.h>
index 3fa9d43e2c879c82a12c7866737fa5b3d92909c6..2b5cf279095403f9ab54ffac2db194d4445b2503 100644 (file)
@@ -1,14 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2016, Linaro Ltd
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 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/io.h>
index 5ce9bf7b897d82da403c489ed69abd3ec5de41d5..6437bbeebc9103479d8fa145316ac7f9137b5223 100644 (file)
@@ -1,19 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2015, Sony Mobile Communications AB.
  * Copyright (c) 2012-2013, 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/interrupt.h>
 #include <linux/io.h>
+#include <linux/mailbox_client.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of_irq.h>
@@ -107,6 +100,8 @@ static const struct {
  * @ipc_regmap:                regmap handle holding the outgoing ipc register
  * @ipc_offset:                offset within @ipc_regmap of the register for ipc
  * @ipc_bit:           bit in the register at @ipc_offset of @ipc_regmap
+ * @mbox_client:       mailbox client handle
+ * @mbox_chan:         apcs ipc mailbox channel handle
  * @channels:          list of all channels detected on this edge
  * @channels_lock:     guard for modifications of @channels
  * @allocated:         array of bitmaps representing already allocated channels
@@ -129,6 +124,9 @@ struct qcom_smd_edge {
        int ipc_offset;
        int ipc_bit;
 
+       struct mbox_client mbox_client;
+       struct mbox_chan *mbox_chan;
+
        struct list_head channels;
        spinlock_t channels_lock;
 
@@ -366,7 +364,17 @@ static void qcom_smd_signal_channel(struct qcom_smd_channel *channel)
 {
        struct qcom_smd_edge *edge = channel->edge;
 
-       regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit));
+       if (edge->mbox_chan) {
+               /*
+                * We can ignore a failing mbox_send_message() as the only
+                * possible cause is that the FIFO in the framework is full of
+                * other writes to the same bit.
+                */
+               mbox_send_message(edge->mbox_chan, NULL);
+               mbox_client_txdone(edge->mbox_chan, 0);
+       } else {
+               regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit));
+       }
 }
 
 /*
@@ -1100,12 +1108,12 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
        void *info;
        int ret;
 
-       channel = devm_kzalloc(&edge->dev, sizeof(*channel), GFP_KERNEL);
+       channel = kzalloc(sizeof(*channel), GFP_KERNEL);
        if (!channel)
                return ERR_PTR(-ENOMEM);
 
        channel->edge = edge;
-       channel->name = devm_kstrdup(&edge->dev, name, GFP_KERNEL);
+       channel->name = kstrdup(name, GFP_KERNEL);
        if (!channel->name)
                return ERR_PTR(-ENOMEM);
 
@@ -1156,8 +1164,8 @@ static struct qcom_smd_channel *qcom_smd_create_channel(struct qcom_smd_edge *ed
        return channel;
 
 free_name_and_channel:
-       devm_kfree(&edge->dev, channel->name);
-       devm_kfree(&edge->dev, channel);
+       kfree(channel->name);
+       kfree(channel);
 
        return ERR_PTR(ret);
 }
@@ -1326,27 +1334,37 @@ static int qcom_smd_parse_edge(struct device *dev,
        key = "qcom,remote-pid";
        of_property_read_u32(node, key, &edge->remote_pid);
 
-       syscon_np = of_parse_phandle(node, "qcom,ipc", 0);
-       if (!syscon_np) {
-               dev_err(dev, "no qcom,ipc node\n");
-               return -ENODEV;
-       }
+       edge->mbox_client.dev = dev;
+       edge->mbox_client.knows_txdone = true;
+       edge->mbox_chan = mbox_request_channel(&edge->mbox_client, 0);
+       if (IS_ERR(edge->mbox_chan)) {
+               if (PTR_ERR(edge->mbox_chan) != -ENODEV)
+                       return PTR_ERR(edge->mbox_chan);
 
-       edge->ipc_regmap = syscon_node_to_regmap(syscon_np);
-       if (IS_ERR(edge->ipc_regmap))
-               return PTR_ERR(edge->ipc_regmap);
+               edge->mbox_chan = NULL;
 
-       key = "qcom,ipc";
-       ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);
-       if (ret < 0) {
-               dev_err(dev, "no offset in %s\n", key);
-               return -EINVAL;
-       }
+               syscon_np = of_parse_phandle(node, "qcom,ipc", 0);
+               if (!syscon_np) {
+                       dev_err(dev, "no qcom,ipc node\n");
+                       return -ENODEV;
+               }
 
-       ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);
-       if (ret < 0) {
-               dev_err(dev, "no bit in %s\n", key);
-               return -EINVAL;
+               edge->ipc_regmap = syscon_node_to_regmap(syscon_np);
+               if (IS_ERR(edge->ipc_regmap))
+                       return PTR_ERR(edge->ipc_regmap);
+
+               key = "qcom,ipc";
+               ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);
+               if (ret < 0) {
+                       dev_err(dev, "no offset in %s\n", key);
+                       return -EINVAL;
+               }
+
+               ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);
+               if (ret < 0) {
+                       dev_err(dev, "no bit in %s\n", key);
+                       return -EINVAL;
+               }
        }
 
        ret = of_property_read_string(node, "label", &edge->name);
@@ -1378,13 +1396,13 @@ static int qcom_smd_parse_edge(struct device *dev,
  */
 static void qcom_smd_edge_release(struct device *dev)
 {
-       struct qcom_smd_channel *channel;
+       struct qcom_smd_channel *channel, *tmp;
        struct qcom_smd_edge *edge = to_smd_edge(dev);
 
-       list_for_each_entry(channel, &edge->channels, list) {
-               SET_RX_CHANNEL_INFO(channel, state, SMD_CHANNEL_CLOSED);
-               SET_RX_CHANNEL_INFO(channel, head, 0);
-               SET_RX_CHANNEL_INFO(channel, tail, 0);
+       list_for_each_entry_safe(channel, tmp, &edge->channels, list) {
+               list_del(&channel->list);
+               kfree(channel->name);
+               kfree(channel);
        }
 
        kfree(edge);
@@ -1453,6 +1471,9 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
        return edge;
 
 unregister_dev:
+       if (!IS_ERR_OR_NULL(edge->mbox_chan))
+               mbox_free_channel(edge->mbox_chan);
+
        device_unregister(&edge->dev);
        return ERR_PTR(ret);
 }
@@ -1481,6 +1502,7 @@ int qcom_smd_unregister_edge(struct qcom_smd_edge *edge)
        if (ret)
                dev_warn(&edge->dev, "can't remove smd device: %d\n", ret);
 
+       mbox_free_channel(edge->mbox_chan);
        device_unregister(&edge->dev);
 
        return 0;
index 1efdf9ff8679902af6f922eda1a15f883babba3c..76a4477c63649320c8ce7ae98bfb1d369ce7830f 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2016, Linaro Ltd.
  * Copyright (c) 2012, Michal Simek <monstr@monstr.eu>
@@ -7,15 +8,6 @@
  *
  * Based on rpmsg performance statistics driver by Michal Simek, which in turn
  * was based on TI & Google OMX rpmsg driver.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 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/cdev.h>
 #include <linux/device.h>
index 920a02f0462c45f520997769890351c89fcc1242..b714a543a91d93c8fff11766fcd867c7bc8a1a68 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * remote processor messaging bus
  *
@@ -6,15 +7,6 @@
  *
  * Ohad Ben-Cohen <ohad@wizery.com>
  * Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
  */
 
 #define pr_fmt(fmt) "%s: " fmt, __func__
@@ -333,11 +325,49 @@ field##_show(struct device *dev,                                  \
 }                                                                      \
 static DEVICE_ATTR_RO(field);
 
+#define rpmsg_string_attr(field, member)                               \
+static ssize_t                                                         \
+field##_store(struct device *dev, struct device_attribute *attr,       \
+             const char *buf, size_t sz)                               \
+{                                                                      \
+       struct rpmsg_device *rpdev = to_rpmsg_device(dev);              \
+       char *new, *old;                                                \
+                                                                       \
+       new = kstrndup(buf, sz, GFP_KERNEL);                            \
+       if (!new)                                                       \
+               return -ENOMEM;                                         \
+       new[strcspn(new, "\n")] = '\0';                                 \
+                                                                       \
+       device_lock(dev);                                               \
+       old = rpdev->member;                                            \
+       if (strlen(new)) {                                              \
+               rpdev->member = new;                                    \
+       } else {                                                        \
+               kfree(new);                                             \
+               rpdev->member = NULL;                                   \
+       }                                                               \
+       device_unlock(dev);                                             \
+                                                                       \
+       kfree(old);                                                     \
+                                                                       \
+       return sz;                                                      \
+}                                                                      \
+static ssize_t                                                         \
+field##_show(struct device *dev,                                       \
+            struct device_attribute *attr, char *buf)                  \
+{                                                                      \
+       struct rpmsg_device *rpdev = to_rpmsg_device(dev);              \
+                                                                       \
+       return sprintf(buf, "%s\n", rpdev->member);                     \
+}                                                                      \
+static DEVICE_ATTR_RW(field)
+
 /* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */
 rpmsg_show_attr(name, id.name, "%s\n");
 rpmsg_show_attr(src, src, "0x%x\n");
 rpmsg_show_attr(dst, dst, "0x%x\n");
 rpmsg_show_attr(announce, announce ? "true" : "false", "%s\n");
+rpmsg_string_attr(driver_override, driver_override);
 
 static ssize_t modalias_show(struct device *dev,
                             struct device_attribute *attr, char *buf)
@@ -359,6 +389,7 @@ static struct attribute *rpmsg_dev_attrs[] = {
        &dev_attr_dst.attr,
        &dev_attr_src.attr,
        &dev_attr_announce.attr,
+       &dev_attr_driver_override.attr,
        NULL,
 };
 ATTRIBUTE_GROUPS(rpmsg_dev);
index 685aa70e9cbe0e84f336bc6e969b8be926ff423e..0d791c30b7ea6aece53695bfb3abe31a7848d6bc 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * remote processor messaging bus internals
  *
@@ -6,15 +7,6 @@
  *
  * Ohad Ben-Cohen <ohad@wizery.com>
  * Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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 __RPMSG_INTERNAL_H__
index 82b83002fcba0af16549dd64f6e12f75c4245731..664f957012cdee0247484fed2e157a30b7ec1fc9 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Virtio-based remote processor messaging bus
  *
@@ -6,15 +7,6 @@
  *
  * Ohad Ben-Cohen <ohad@wizery.com>
  * Brian Swetland <swetland@google.com>
- *
- * This software is licensed under the terms of the GNU General Public
- * License version 2, as published by the Free Software Foundation, and
- * may be copied, distributed, and modified under those terms.
- *
- * 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.
  */
 
 #define pr_fmt(fmt) "%s: " fmt, __func__
index 1a61fa56f3ad77bad999d234778e8d953fc1ad5a..385f8303bb412becfbe497ff24d2ebbe8ccfe09a 100644 (file)
@@ -322,10 +322,9 @@ static int mtk_rtc_probe(struct platform_device *pdev)
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        rtc->addr_base = res->start;
 
-       res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-       rtc->irq = irq_create_mapping(mt6397_chip->irq_domain, res->start);
-       if (rtc->irq <= 0)
-               return -EINVAL;
+       rtc->irq = platform_get_irq(pdev, 0);
+       if (rtc->irq < 0)
+               return rtc->irq;
 
        rtc->regmap = mt6397_chip->regmap;
        rtc->dev = &pdev->dev;
index fb2c3599d95c20e3d2cc7f400889e65aea6449c6..0af8c5295b650b1132e5946b123b558a08e91ccc 100644 (file)
@@ -561,8 +561,8 @@ static int dasd_eer_open(struct inode *inp, struct file *filp)
                return -EINVAL;
        }
        eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE;
-       eerb->buffer = kmalloc(eerb->buffer_page_count * sizeof(char *),
-                              GFP_KERNEL);
+       eerb->buffer = kmalloc_array(eerb->buffer_page_count, sizeof(char *),
+                                    GFP_KERNEL);
         if (!eerb->buffer) {
                kfree(eerb);
                 return -ENOMEM;
index 29024492b8ede9fed0eb1a94b28bd319ca001136..ed607288e696f64c7d041e4b791ef74836017640 100644 (file)
@@ -238,9 +238,9 @@ dcssblk_is_continuous(struct dcssblk_dev_info *dev_info)
        if (dev_info->num_of_segments <= 1)
                return 0;
 
-       sort_list = kzalloc(
-                       sizeof(struct segment_info) * dev_info->num_of_segments,
-                       GFP_KERNEL);
+       sort_list = kcalloc(dev_info->num_of_segments,
+                           sizeof(struct segment_info),
+                           GFP_KERNEL);
        if (sort_list == NULL)
                return -ENOMEM;
        i = 0;
index db1fbf9b00b5062795528541bcf5eb7d1cb14c9a..79eb60958015a5348818dfc94c23b2aa3585f0c1 100644 (file)
@@ -78,7 +78,7 @@ kbd_alloc(void) {
                }
        }
        kbd->fn_handler =
-               kzalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL);
+               kcalloc(NR_FN_HANDLER, sizeof(fn_handler_fn *), GFP_KERNEL);
        if (!kbd->fn_handler)
                goto out_func;
        kbd->accent_table = kmemdup(ebc_accent_table,
index 99f41db5123b1050230423a726f3d58b64f0e4cd..1e244f78f1929c871f7dbdcc23d8bd59d6df0b80 100644 (file)
@@ -300,7 +300,7 @@ static int sclp_sd_store_data(struct sclp_sd_data *result, u8 di)
                goto out_result;
 
        /* Allocate memory */
-       data = vzalloc((size_t) dsize * PAGE_SIZE);
+       data = vzalloc(array_size((size_t)dsize, PAGE_SIZE));
        if (!data) {
                rc = -ENOMEM;
                goto out;
index 1c98023cffd4165a8ad5117c907fa9258d918c4f..5b8af278228282914a4250ee655aa4f85355ef7f 100644 (file)
@@ -719,7 +719,8 @@ tty3270_alloc_view(void)
        if (!tp)
                goto out_err;
        tp->freemem_pages =
-               kmalloc(sizeof(void *) * TTY3270_STRING_PAGES, GFP_KERNEL);
+               kmalloc_array(TTY3270_STRING_PAGES, sizeof(void *),
+                             GFP_KERNEL);
        if (!tp->freemem_pages)
                goto out_tp;
        INIT_LIST_HEAD(&tp->freemem);
index 52aa894243187484c03bf301d274990cdbeacb32..cbde65ab217063f627b0eac66e7294152c8f8aac 100644 (file)
@@ -242,7 +242,7 @@ static struct ccw1 *alloc_chan_prog(const char __user *ubuf, int rec_count,
         * That means we allocate room for CCWs to cover count/reclen
         * records plus a NOP.
         */
-       cpa = kzalloc((rec_count + 1) * sizeof(struct ccw1),
+       cpa = kcalloc(rec_count + 1, sizeof(struct ccw1),
                      GFP_KERNEL | GFP_DMA);
        if (!cpa)
                return ERR_PTR(-ENOMEM);
index 4369662cfff5a7ad094d522590901bc845933872..76d3c50bf078bc0ce1490a0ec7d571eeac17634a 100644 (file)
@@ -152,7 +152,7 @@ static int zcore_memmap_open(struct inode *inode, struct file *filp)
        char *buf;
        int i = 0;
 
-       buf = kzalloc(memblock.memory.cnt * CHUNK_INFO_SIZE, GFP_KERNEL);
+       buf = kcalloc(memblock.memory.cnt, CHUNK_INFO_SIZE, GFP_KERNEL);
        if (!buf) {
                return -ENOMEM;
        }
index 4c14ce428e92d8927fedb8702d3d9dd26801ddad..78f1be41b05e3fb2cc5c91b31e0ec00877735851 100644 (file)
@@ -536,7 +536,7 @@ void qdio_print_subchannel_info(struct qdio_irq *irq_ptr,
 
 int qdio_enable_async_operation(struct qdio_output_q *outq)
 {
-       outq->aobs = kzalloc(sizeof(struct qaob *) * QDIO_MAX_BUFFERS_PER_Q,
+       outq->aobs = kcalloc(QDIO_MAX_BUFFERS_PER_Q, sizeof(struct qaob *),
                             GFP_ATOMIC);
        if (!outq->aobs) {
                outq->use_cq = 0;
index 0787b587e4b8b690c9f1cb9bb511a6a6897f959b..07dea602205bdf2a18bfe85fad5888cf2f91b4dd 100644 (file)
@@ -241,8 +241,9 @@ static int set_subchannel_ind(struct qdio_irq *irq_ptr, int reset)
 /* allocate non-shared indicators and shared indicator */
 int __init tiqdio_allocate_memory(void)
 {
-       q_indicators = kzalloc(sizeof(struct indicator_t) * TIQDIO_NR_INDICATORS,
-                            GFP_KERNEL);
+       q_indicators = kcalloc(TIQDIO_NR_INDICATORS,
+                              sizeof(struct indicator_t),
+                              GFP_KERNEL);
        if (!q_indicators)
                return -ENOMEM;
        return 0;
index ed80d00cdb6f132e2e7a01394dcf046eed9c0c89..3929c8be8098b4098d5752d6697db506796fa9b4 100644 (file)
@@ -121,7 +121,7 @@ static int alloc_and_prep_cprbmem(size_t paramblen,
         * allocate consecutive memory for request CPRB, request param
         * block, reply CPRB and reply param block
         */
-       cprbmem = kzalloc(2 * cprbplusparamblen, GFP_KERNEL);
+       cprbmem = kcalloc(2, cprbplusparamblen, GFP_KERNEL);
        if (!cprbmem)
                return -ENOMEM;
 
@@ -899,9 +899,9 @@ int pkey_findcard(const struct pkey_seckey *seckey,
                return -EINVAL;
 
        /* fetch status of all crypto cards */
-       device_status = kmalloc(MAX_ZDEV_ENTRIES_EXT
-                               * sizeof(struct zcrypt_device_status_ext),
-                               GFP_KERNEL);
+       device_status = kmalloc_array(MAX_ZDEV_ENTRIES_EXT,
+                                     sizeof(struct zcrypt_device_status_ext),
+                                     GFP_KERNEL);
        if (!device_status)
                return -ENOMEM;
        zcrypt_device_status_mask_ext(device_status);
index 7ce98b70cad38bf55be1fd4a15bdaa62761ff159..7617d21cb2960618cbc097bbf85cb8515234aa14 100644 (file)
@@ -1379,7 +1379,7 @@ static int add_channel(struct ccw_device *cdev, enum ctcm_channel_types type,
        } else
                ccw_num = 8;
 
-       ch->ccw = kzalloc(ccw_num * sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
+       ch->ccw = kcalloc(ccw_num, sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
        if (ch->ccw == NULL)
                                        goto nomem_return;
 
index 9f28b6f2efc417d48081d6debcd9d5d2253fe9ef..8e1474f1ffacfb22b773b02aa1bff6ff91c61ce9 100644 (file)
@@ -374,9 +374,10 @@ static int qeth_alloc_cq(struct qeth_card *card)
                }
                card->qdio.no_in_queues = 2;
                card->qdio.out_bufstates =
-                       kzalloc(card->qdio.no_out_queues *
-                               QDIO_MAX_BUFFERS_PER_Q *
-                               sizeof(struct qdio_outbuf_state), GFP_KERNEL);
+                       kcalloc(card->qdio.no_out_queues *
+                                       QDIO_MAX_BUFFERS_PER_Q,
+                               sizeof(struct qdio_outbuf_state),
+                               GFP_KERNEL);
                outbuf_states = card->qdio.out_bufstates;
                if (outbuf_states == NULL) {
                        rc = -1;
@@ -2538,8 +2539,9 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card)
 
        /* outbound */
        card->qdio.out_qs =
-               kzalloc(card->qdio.no_out_queues *
-                       sizeof(struct qeth_qdio_out_q *), GFP_KERNEL);
+               kcalloc(card->qdio.no_out_queues,
+                       sizeof(struct qeth_qdio_out_q *),
+                       GFP_KERNEL);
        if (!card->qdio.out_qs)
                goto out_freepool;
        for (i = 0; i < card->qdio.no_out_queues; ++i) {
@@ -4963,8 +4965,8 @@ static int qeth_qdio_establish(struct qeth_card *card)
 
        QETH_DBF_TEXT(SETUP, 2, "qdioest");
 
-       qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char),
-                             GFP_KERNEL);
+       qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q,
+                                 GFP_KERNEL);
        if (!qib_param_field) {
                rc =  -ENOMEM;
                goto out_free_nothing;
@@ -4973,8 +4975,8 @@ static int qeth_qdio_establish(struct qeth_card *card)
        qeth_create_qib_param_field(card, qib_param_field);
        qeth_create_qib_param_field_blkt(card, qib_param_field);
 
-       in_sbal_ptrs = kzalloc(card->qdio.no_in_queues *
-                              QDIO_MAX_BUFFERS_PER_Q * sizeof(void *),
+       in_sbal_ptrs = kcalloc(card->qdio.no_in_queues * QDIO_MAX_BUFFERS_PER_Q,
+                              sizeof(void *),
                               GFP_KERNEL);
        if (!in_sbal_ptrs) {
                rc = -ENOMEM;
@@ -4985,7 +4987,7 @@ static int qeth_qdio_establish(struct qeth_card *card)
                        virt_to_phys(card->qdio.in_q->bufs[i].buffer);
        }
 
-       queue_start_poll = kzalloc(sizeof(void *) * card->qdio.no_in_queues,
+       queue_start_poll = kcalloc(card->qdio.no_in_queues, sizeof(void *),
                                   GFP_KERNEL);
        if (!queue_start_poll) {
                rc = -ENOMEM;
@@ -4997,8 +4999,9 @@ static int qeth_qdio_establish(struct qeth_card *card)
        qeth_qdio_establish_cq(card, in_sbal_ptrs, queue_start_poll);
 
        out_sbal_ptrs =
-               kzalloc(card->qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q *
-                       sizeof(void *), GFP_KERNEL);
+               kcalloc(card->qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q,
+                       sizeof(void *),
+                       GFP_KERNEL);
        if (!out_sbal_ptrs) {
                rc = -ENOMEM;
                goto out_free_queue_start_poll;
index 1754f55e2facfb4b21169a7c97ee514392c9eaa8..524f9ea62e52a0ed472b1177c57f7aa3b0f98f17 100644 (file)
@@ -30,7 +30,7 @@
  * the recommended way for applications to use the coprocessor, and
  * the driver interface is not intended for general use.
  *
- * See Documentation/sparc/oradax/oracle_dax.txt for more details.
+ * See Documentation/sparc/oradax/oracle-dax.txt for more details.
  */
 
 #include <linux/uaccess.h>
index 35380a58d3f0dd03c13add8bfe03dbc5f13e589b..0d4ffe0ae3065b8129567110e42ea564d4b01a5a 100644 (file)
@@ -2366,7 +2366,7 @@ static int __init blogic_init(void)
        if (blogic_probe_options.noprobe)
                return -ENODEV;
        blogic_probeinfo_list =
-           kzalloc(BLOGIC_MAX_ADAPTERS * sizeof(struct blogic_probeinfo),
+           kcalloc(BLOGIC_MAX_ADAPTERS, sizeof(struct blogic_probeinfo),
                            GFP_KERNEL);
        if (blogic_probeinfo_list == NULL) {
                blogic_err("BusLogic: Unable to allocate Probe Info List\n",
index e7961cbd2c55ab81020084730e8ec19f45aeda7d..a9831bd37a73d52462489d025c1631a576ca2fbc 100644 (file)
@@ -4132,7 +4132,7 @@ static int aac_convert_sgraw2(struct aac_raw_io2 *rio2, int pages, int nseg, int
        if (aac_convert_sgl == 0)
                return 0;
 
-       sge = kmalloc(nseg_new * sizeof(struct sge_ieee1212), GFP_ATOMIC);
+       sge = kmalloc_array(nseg_new, sizeof(struct sge_ieee1212), GFP_ATOMIC);
        if (sge == NULL)
                return -ENOMEM;
 
index a2b3430072c7e51f55604352f1d9141f5d7f3e2e..25f6600d6c090c45e9dfb6c7aabaadc7ffa72662 100644 (file)
@@ -845,7 +845,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
                                        rcode = -EINVAL;
                                        goto cleanup;
                                }
-                               p = kmalloc(sg_count[i], GFP_KERNEL|GFP_DMA32);
+                               p = kmalloc(sg_count[i], GFP_KERNEL);
                                if (!p) {
                                        dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
                                                sg_count[i], i, usg->count));
@@ -886,7 +886,7 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
                                        rcode = -EINVAL;
                                        goto cleanup;
                                }
-                               p = kmalloc(sg_count[i], GFP_KERNEL|GFP_DMA32);
+                               p = kmalloc(sg_count[i], GFP_KERNEL);
                                if (!p) {
                                        dprintk((KERN_DEBUG"aacraid: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
                                          sg_count[i], i, upsg->count));
index f24fb942065d69878c0cc451e91d6066a944117d..04443577d48b371f37afb057ec5bceb9f2e000f7 100644 (file)
@@ -1681,7 +1681,9 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
        if (aac_reset_devices || reset_devices)
                aac->init_reset = true;
 
-       aac->fibs = kzalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL);
+       aac->fibs = kcalloc(shost->can_queue + AAC_NUM_MGT_FIB,
+                           sizeof(struct fib),
+                           GFP_KERNEL);
        if (!aac->fibs)
                goto out_free_host;
        spin_lock_init(&aac->fib_lock);
index 124217927c4af267554733df8cad79afe9cc7bee..41add33e3f1f5babe73333cb8663546c4f75f61f 100644 (file)
@@ -400,7 +400,8 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd)
 #endif
        if (bufflen) {  /* allocate memory before taking host_lock */
                sg_count = scsi_sg_count(cmd);
-               cptr = kmalloc(sizeof(*cptr) * sg_count, GFP_KERNEL | GFP_DMA);
+               cptr = kmalloc_array(sg_count, sizeof(*cptr),
+                                    GFP_KERNEL | GFP_DMA);
                if (!cptr)
                        return SCSI_MLQUEUE_HOST_BUSY;
        } else {
index 034f4eebb1603f6271c929e51a304660fae6ac30..2d82ec85753efc9628cbdf5faa7e1699e64113cb 100644 (file)
@@ -6112,10 +6112,6 @@ ahd_alloc(void *platform_arg, char *name)
        ahd->int_coalescing_stop_threshold =
            AHD_INT_COALESCING_STOP_THRESHOLD_DEFAULT;
 
-       if (ahd_platform_alloc(ahd, platform_arg) != 0) {
-               ahd_free(ahd);
-               ahd = NULL;
-       }
 #ifdef AHD_DEBUG
        if ((ahd_debug & AHD_SHOW_MEMORY) != 0) {
                printk("%s: scb size = 0x%x, hscb size = 0x%x\n",
@@ -6123,6 +6119,10 @@ ahd_alloc(void *platform_arg, char *name)
                       (u_int)sizeof(struct hardware_scb));
        }
 #endif
+       if (ahd_platform_alloc(ahd, platform_arg) != 0) {
+               ahd_free(ahd);
+               ahd = NULL;
+       }
        return (ahd);
 }
 
@@ -7063,7 +7063,8 @@ ahd_init(struct ahd_softc *ahd)
        AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
 
        ahd->stack_size = ahd_probe_stack_size(ahd);
-       ahd->saved_stack = kmalloc(ahd->stack_size * sizeof(uint16_t), GFP_ATOMIC);
+       ahd->saved_stack = kmalloc_array(ahd->stack_size, sizeof(uint16_t),
+                                        GFP_ATOMIC);
        if (ahd->saved_stack == NULL)
                return (ENOMEM);
 
index e97eceacf522f822f201dd9216dea7e635fd44ce..915a34f141e4f66503133af8453521de0ffb3783 100644 (file)
@@ -4779,8 +4779,8 @@ ahc_init_scbdata(struct ahc_softc *ahc)
        SLIST_INIT(&scb_data->sg_maps);
 
        /* Allocate SCB resources */
-       scb_data->scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC,
-                               GFP_ATOMIC);
+       scb_data->scbarray = kcalloc(AHC_SCB_MAX_ALLOC, sizeof(struct scb),
+                                    GFP_ATOMIC);
        if (scb_data->scbarray == NULL)
                return (ENOMEM);
 
index 2dbc8330d7d34b4e9904e88f6ae79778c50cd07c..3b8ad55e59de13e898c44cd5fc46d0e55cdf8f68 100644 (file)
@@ -220,8 +220,9 @@ static int asd_init_scbs(struct asd_ha_struct *asd_ha)
 
        /* allocate the index array and bitmap */
        asd_ha->seq.tc_index_bitmap_bits = asd_ha->hw_prof.max_scbs;
-       asd_ha->seq.tc_index_array = kzalloc(asd_ha->seq.tc_index_bitmap_bits*
-                                            sizeof(void *), GFP_KERNEL);
+       asd_ha->seq.tc_index_array = kcalloc(asd_ha->seq.tc_index_bitmap_bits,
+                                            sizeof(void *),
+                                            GFP_KERNEL);
        if (!asd_ha->seq.tc_index_array)
                return -ENOMEM;
 
@@ -291,7 +292,8 @@ static int asd_alloc_edbs(struct asd_ha_struct *asd_ha, gfp_t gfp_flags)
        struct asd_seq_data *seq = &asd_ha->seq;
        int i;
 
-       seq->edb_arr = kmalloc(seq->num_edbs*sizeof(*seq->edb_arr), gfp_flags);
+       seq->edb_arr = kmalloc_array(seq->num_edbs, sizeof(*seq->edb_arr),
+                                    gfp_flags);
        if (!seq->edb_arr)
                return -ENOMEM;
 
@@ -323,8 +325,8 @@ static int asd_alloc_escbs(struct asd_ha_struct *asd_ha,
        struct asd_ascb *escb;
        int i, escbs;
 
-       seq->escb_arr = kmalloc(seq->num_escbs*sizeof(*seq->escb_arr),
-                               gfp_flags);
+       seq->escb_arr = kmalloc_array(seq->num_escbs, sizeof(*seq->escb_arr),
+                                     gfp_flags);
        if (!seq->escb_arr)
                return -ENOMEM;
 
index 6c838865ac5a7b32fd853aa36a07611e9809adc3..80e5b283fd8172b0ac02282aa2f4a3d7f646337e 100644 (file)
@@ -350,7 +350,7 @@ static ssize_t asd_store_update_bios(struct device *dev,
        int flash_command = FLASH_CMD_NONE;
        int err = 0;
 
-       cmd_ptr = kzalloc(count*2, GFP_KERNEL);
+       cmd_ptr = kcalloc(count, 2, GFP_KERNEL);
 
        if (!cmd_ptr) {
                err = FAIL_OUT_MEMORY;
index 3441ce3ebabfed136f79560d734e37874837177c..996dfe9039285dd9fb1a0914f5dc3d98f7aa0d5b 100644 (file)
@@ -70,7 +70,7 @@ int queue_initialise (Queue_t *queue)
         * need to keep free lists or allocate this
         * memory.
         */
-       queue->alloc = q = kmalloc(sizeof(QE_t) * nqueues, GFP_KERNEL);
+       queue->alloc = q = kmalloc_array(nqueues, sizeof(QE_t), GFP_KERNEL);
        if (q) {
                for (; nqueues; q++, nqueues--) {
                        SET_MAGIC(q, QUEUE_MAGIC_FREE);
index b3cfdd5f4d1c3812baf40f34c936b53f3b34acdf..818d185d63f0776d81d9c6b88482807065e2b472 100644 (file)
@@ -2467,8 +2467,8 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
 
        /* Allocate memory for wrb_context */
        phwi_ctrlr = phba->phwi_ctrlr;
-       phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
-                                         phba->params.cxns_per_ctrl,
+       phwi_ctrlr->wrb_context = kcalloc(phba->params.cxns_per_ctrl,
+                                         sizeof(struct hwi_wrb_context),
                                          GFP_KERNEL);
        if (!phwi_ctrlr->wrb_context) {
                kfree(phba->phwi_ctrlr);
@@ -2483,8 +2483,9 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
                return -ENOMEM;
        }
 
-       mem_arr_orig = kmalloc(sizeof(*mem_arr_orig) * BEISCSI_MAX_FRAGS_INIT,
-                              GFP_KERNEL);
+       mem_arr_orig = kmalloc_array(BEISCSI_MAX_FRAGS_INIT,
+                                    sizeof(*mem_arr_orig),
+                                    GFP_KERNEL);
        if (!mem_arr_orig) {
                kfree(phba->init_mem);
                kfree(phwi_ctrlr->wrb_context);
@@ -2533,8 +2534,8 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba)
                } while (alloc_size);
                mem_descr->num_elements = j;
                mem_descr->size_in_bytes = phba->mem_req[i];
-               mem_descr->mem_array = kmalloc(sizeof(*mem_arr) * j,
-                                              GFP_KERNEL);
+               mem_descr->mem_array = kmalloc_array(j, sizeof(*mem_arr),
+                                                    GFP_KERNEL);
                if (!mem_descr->mem_array)
                        goto free_mem;
 
@@ -2620,8 +2621,8 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba)
 
        /* Allocate memory for WRBQ */
        phwi_ctxt = phwi_ctrlr->phwi_ctxt;
-       phwi_ctxt->be_wrbq = kzalloc(sizeof(struct be_queue_info) *
-                                    phba->params.cxns_per_ctrl,
+       phwi_ctxt->be_wrbq = kcalloc(phba->params.cxns_per_ctrl,
+                                    sizeof(struct be_queue_info),
                                     GFP_KERNEL);
        if (!phwi_ctxt->be_wrbq) {
                beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
@@ -2632,16 +2633,18 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba)
        for (index = 0; index < phba->params.cxns_per_ctrl; index++) {
                pwrb_context = &phwi_ctrlr->wrb_context[index];
                pwrb_context->pwrb_handle_base =
-                               kzalloc(sizeof(struct wrb_handle *) *
-                                       phba->params.wrbs_per_cxn, GFP_KERNEL);
+                               kcalloc(phba->params.wrbs_per_cxn,
+                                       sizeof(struct wrb_handle *),
+                                       GFP_KERNEL);
                if (!pwrb_context->pwrb_handle_base) {
                        beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
                                    "BM_%d : Mem Alloc Failed. Failing to load\n");
                        goto init_wrb_hndl_failed;
                }
                pwrb_context->pwrb_handle_basestd =
-                               kzalloc(sizeof(struct wrb_handle *) *
-                                       phba->params.wrbs_per_cxn, GFP_KERNEL);
+                               kcalloc(phba->params.wrbs_per_cxn,
+                                       sizeof(struct wrb_handle *),
+                                       GFP_KERNEL);
                if (!pwrb_context->pwrb_handle_basestd) {
                        beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
                                    "BM_%d : Mem Alloc Failed. Failing to load\n");
@@ -3353,8 +3356,9 @@ beiscsi_create_wrb_rings(struct beiscsi_hba *phba,
        idx = 0;
        mem_descr = phba->init_mem;
        mem_descr += HWI_MEM_WRB;
-       pwrb_arr = kmalloc(sizeof(*pwrb_arr) * phba->params.cxns_per_ctrl,
-                          GFP_KERNEL);
+       pwrb_arr = kmalloc_array(phba->params.cxns_per_ctrl,
+                                sizeof(*pwrb_arr),
+                                GFP_KERNEL);
        if (!pwrb_arr) {
                beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
                            "BM_%d : Memory alloc failed in create wrb ring.\n");
@@ -3894,18 +3898,18 @@ static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba)
        mem_descr_sglh = phba->init_mem;
        mem_descr_sglh += HWI_MEM_SGLH;
        if (1 == mem_descr_sglh->num_elements) {
-               phba->io_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) *
-                                                phba->params.ios_per_ctrl,
+               phba->io_sgl_hndl_base = kcalloc(phba->params.ios_per_ctrl,
+                                                sizeof(struct sgl_handle *),
                                                 GFP_KERNEL);
                if (!phba->io_sgl_hndl_base) {
                        beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
                                    "BM_%d : Mem Alloc Failed. Failing to load\n");
                        return -ENOMEM;
                }
-               phba->eh_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) *
-                                                (phba->params.icds_per_ctrl -
-                                                phba->params.ios_per_ctrl),
-                                                GFP_KERNEL);
+               phba->eh_sgl_hndl_base =
+                       kcalloc(phba->params.icds_per_ctrl -
+                                       phba->params.ios_per_ctrl,
+                               sizeof(struct sgl_handle *), GFP_KERNEL);
                if (!phba->eh_sgl_hndl_base) {
                        kfree(phba->io_sgl_hndl_base);
                        beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
@@ -4032,8 +4036,9 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba)
                        phba->cid_array_info[ulp_num] = ptr_cid_info;
                }
        }
-       phba->ep_array = kzalloc(sizeof(struct iscsi_endpoint *) *
-                                phba->params.cxns_per_ctrl, GFP_KERNEL);
+       phba->ep_array = kcalloc(phba->params.cxns_per_ctrl,
+                                sizeof(struct iscsi_endpoint *),
+                                GFP_KERNEL);
        if (!phba->ep_array) {
                beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
                            "BM_%d : Failed to allocate memory in "
@@ -4043,8 +4048,9 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba)
                goto free_memory;
        }
 
-       phba->conn_table = kzalloc(sizeof(struct beiscsi_conn *) *
-                                  phba->params.cxns_per_ctrl, GFP_KERNEL);
+       phba->conn_table = kcalloc(phba->params.cxns_per_ctrl,
+                                  sizeof(struct beiscsi_conn *),
+                                  GFP_KERNEL);
        if (!phba->conn_table) {
                beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
                            "BM_%d : Failed to allocate memory in"
index d4d276c757ea79929c7e3c25ee4974d58db567a8..26b0fa4e90b58b5340bf18bb20e1a22fd8d5c677 100644 (file)
@@ -927,7 +927,7 @@ bfad_im_num_of_discovered_ports_show(struct device *dev,
        struct bfa_rport_qualifier_s *rports = NULL;
        unsigned long   flags;
 
-       rports = kzalloc(sizeof(struct bfa_rport_qualifier_s) * nrports,
+       rports = kcalloc(nrports, sizeof(struct bfa_rport_qualifier_s),
                         GFP_ATOMIC);
        if (rports == NULL)
                return snprintf(buf, PAGE_SIZE, "Failed\n");
index 7c884f881180959e04947211f4994469a2a9538a..5d163ca1b36666041fc22d5413fd2e6ecb1ebd3c 100644 (file)
@@ -3252,8 +3252,9 @@ bfad_fcxp_map_sg(struct bfad_s *bfad, void *payload_kbuf,
        struct bfa_sge_s        *sg_table;
        int sge_num = 1;
 
-       buf_base = kzalloc((sizeof(struct bfad_buf_info) +
-                          sizeof(struct bfa_sge_s)) * sge_num, GFP_KERNEL);
+       buf_base = kcalloc(sizeof(struct bfad_buf_info) +
+                               sizeof(struct bfa_sge_s),
+                          sge_num, GFP_KERNEL);
        if (!buf_base)
                return NULL;
 
index 65de1d0578a1fa03ff350eee94e8c5145bce88b3..f000458133789935fbb2b15550d91106ec5c65ca 100644 (file)
@@ -1397,7 +1397,7 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct cnic_dev *cnic)
        hba->next_conn_id = 0;
 
        hba->tgt_ofld_list =
-               kzalloc(sizeof(struct bnx2fc_rport *) * BNX2FC_NUM_MAX_SESS,
+               kcalloc(BNX2FC_NUM_MAX_SESS, sizeof(struct bnx2fc_rport *),
                        GFP_KERNEL);
        if (!hba->tgt_ofld_list) {
                printk(KERN_ERR PFX "Unable to allocate tgt offload list\n");
index 5a645b8b9af170d66a2abd510393c5f5c5725aa8..350257c13a5bac433f1fdfbfcdc12dc6698587cb 100644 (file)
@@ -240,15 +240,15 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba)
                return NULL;
        }
 
-       cmgr->free_list = kzalloc(sizeof(*cmgr->free_list) *
-                                 arr_sz, GFP_KERNEL);
+       cmgr->free_list = kcalloc(arr_sz, sizeof(*cmgr->free_list),
+                                 GFP_KERNEL);
        if (!cmgr->free_list) {
                printk(KERN_ERR PFX "failed to alloc free_list\n");
                goto mem_err;
        }
 
-       cmgr->free_list_lock = kzalloc(sizeof(*cmgr->free_list_lock) *
-                                      arr_sz, GFP_KERNEL);
+       cmgr->free_list_lock = kcalloc(arr_sz, sizeof(*cmgr->free_list_lock),
+                                      GFP_KERNEL);
        if (!cmgr->free_list_lock) {
                printk(KERN_ERR PFX "failed to alloc free_list_lock\n");
                kfree(cmgr->free_list);
index c0a17789752febb281182c15c1b74f14da25841e..faa357b62c61686fba4b9548895b4e3709c9d6f7 100644 (file)
@@ -276,7 +276,7 @@ csio_wr_alloc_q(struct csio_hw *hw, uint32_t qsize, uint32_t wrsize,
                        q->un.iq.flq_idx = flq_idx;
 
                        flq = wrm->q_arr[q->un.iq.flq_idx];
-                       flq->un.fl.bufs = kzalloc(flq->credits *
+                       flq->un.fl.bufs = kcalloc(flq->credits,
                                                  sizeof(struct csio_dma_buf),
                                                  GFP_KERNEL);
                        if (!flq->un.fl.bufs) {
@@ -1579,7 +1579,7 @@ csio_wrm_init(struct csio_wrm *wrm, struct csio_hw *hw)
                return -EINVAL;
        }
 
-       wrm->q_arr = kzalloc(sizeof(struct csio_q *) * wrm->num_q, GFP_KERNEL);
+       wrm->q_arr = kcalloc(wrm->num_q, sizeof(struct csio_q *), GFP_KERNEL);
        if (!wrm->q_arr)
                goto err;
 
index 9db645dde35ec355071219362d301f05ef322543..bbe77db8938d6c5217793447658b98ae3317a91a 100644 (file)
@@ -833,7 +833,7 @@ bool esas2r_init_adapter_struct(struct esas2r_adapter *a,
 
        /* allocate requests for asynchronous events */
        a->first_ae_req =
-               kzalloc(num_ae_requests * sizeof(struct esas2r_request),
+               kcalloc(num_ae_requests, sizeof(struct esas2r_request),
                        GFP_KERNEL);
 
        if (a->first_ae_req == NULL) {
@@ -843,8 +843,8 @@ bool esas2r_init_adapter_struct(struct esas2r_adapter *a,
        }
 
        /* allocate the S/G list memory descriptors */
-       a->sg_list_mds = kzalloc(
-               num_sg_lists * sizeof(struct esas2r_mem_desc), GFP_KERNEL);
+       a->sg_list_mds = kcalloc(num_sg_lists, sizeof(struct esas2r_mem_desc),
+                                GFP_KERNEL);
 
        if (a->sg_list_mds == NULL) {
                esas2r_log(ESAS2R_LOG_CRIT,
@@ -854,8 +854,9 @@ bool esas2r_init_adapter_struct(struct esas2r_adapter *a,
 
        /* allocate the request table */
        a->req_table =
-               kzalloc((num_requests + num_ae_requests +
-                        1) * sizeof(struct esas2r_request *), GFP_KERNEL);
+               kcalloc(num_requests + num_ae_requests + 1,
+                       sizeof(struct esas2r_request *),
+                       GFP_KERNEL);
 
        if (a->req_table == NULL) {
                esas2r_log(ESAS2R_LOG_CRIT,
index 097f37de6ce91231082353f327485d8f189d68ba..ea23c8dffc252af3d0209167e99118c98575d848 100644 (file)
@@ -1390,8 +1390,8 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip,
         */
        num_vlink_desc = rlen / sizeof(*vp);
        if (num_vlink_desc)
-               vlink_desc_arr = kmalloc(sizeof(vp) * num_vlink_desc,
-                                        GFP_ATOMIC);
+               vlink_desc_arr = kmalloc_array(num_vlink_desc, sizeof(vp),
+                                              GFP_ATOMIC);
        if (!vlink_desc_arr)
                return;
        num_vlink_desc = 0;
index 6d3e1cb4fea61f5eebb8ac976d6da79b24908f9a..139fffa3658a4ab8fe666e4d04acf2b2f30393f5 100644 (file)
@@ -233,8 +233,8 @@ static int fnic_trace_debugfs_open(struct inode *inode,
                return -ENOMEM;
 
        if (*rdata_ptr == fc_trc_flag->fnic_trace) {
-               fnic_dbg_prt->buffer = vmalloc(3 *
-                                       (trace_max_pages * PAGE_SIZE));
+               fnic_dbg_prt->buffer = vmalloc(array3_size(3, trace_max_pages,
+                                                          PAGE_SIZE));
                if (!fnic_dbg_prt->buffer) {
                        kfree(fnic_dbg_prt);
                        return -ENOMEM;
@@ -244,7 +244,8 @@ static int fnic_trace_debugfs_open(struct inode *inode,
                fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt);
        } else {
                fnic_dbg_prt->buffer =
-                       vmalloc(3 * (fnic_fc_trace_max_pages * PAGE_SIZE));
+                       vmalloc(array3_size(3, fnic_fc_trace_max_pages,
+                                           PAGE_SIZE));
                if (!fnic_dbg_prt->buffer) {
                        kfree(fnic_dbg_prt);
                        return -ENOMEM;
index 98597b59c12ab6eb944ffa21107f10178c03e024..8271785bdb9303a630bd8a5c39295d70691c4ccf 100644 (file)
@@ -477,8 +477,9 @@ int fnic_trace_buf_init(void)
        }
        memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE));
 
-       fnic_trace_entries.page_offset = vmalloc(fnic_max_trace_entries *
-                                                 sizeof(unsigned long));
+       fnic_trace_entries.page_offset =
+               vmalloc(array_size(fnic_max_trace_entries,
+                                  sizeof(unsigned long)));
        if (!fnic_trace_entries.page_offset) {
                printk(KERN_ERR PFX "Failed to allocate memory for"
                                  " page_offset\n");
@@ -555,8 +556,9 @@ int fnic_fc_trace_init(void)
 
        fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/
                                FC_TRC_SIZE_BYTES;
-       fnic_fc_ctlr_trace_buf_p = (unsigned long)vmalloc(
-                                       fnic_fc_trace_max_pages * PAGE_SIZE);
+       fnic_fc_ctlr_trace_buf_p =
+               (unsigned long)vmalloc(array_size(PAGE_SIZE,
+                                                 fnic_fc_trace_max_pages));
        if (!fnic_fc_ctlr_trace_buf_p) {
                pr_err("fnic: Failed to allocate memory for "
                       "FC Control Trace Buf\n");
@@ -568,8 +570,9 @@ int fnic_fc_trace_init(void)
                        fnic_fc_trace_max_pages * PAGE_SIZE);
 
        /* Allocate memory for page offset */
-       fc_trace_entries.page_offset = vmalloc(fc_trace_max_entries *
-                                               sizeof(unsigned long));
+       fc_trace_entries.page_offset =
+               vmalloc(array_size(fc_trace_max_entries,
+                                  sizeof(unsigned long)));
        if (!fc_trace_entries.page_offset) {
                pr_err("fnic:Failed to allocate memory for page_offset\n");
                if (fnic_fc_ctlr_trace_buf_p) {
index 3a9eca163db8117e7bbf1132c7965d5253850668..15c7f3b6f35eecee2ca3ca88c16c63809c2791bf 100644 (file)
@@ -1923,8 +1923,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h,
        }
        spin_unlock_irqrestore(&h->reset_lock, flags);
 
-       added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL);
-       removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL);
+       added = kcalloc(HPSA_MAX_DEVICES, sizeof(*added), GFP_KERNEL);
+       removed = kcalloc(HPSA_MAX_DEVICES, sizeof(*removed), GFP_KERNEL);
 
        if (!added || !removed) {
                dev_warn(&h->pdev->dev, "out of memory in "
@@ -2171,14 +2171,15 @@ static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h)
                return 0;
 
        h->ioaccel2_cmd_sg_list =
-               kzalloc(sizeof(*h->ioaccel2_cmd_sg_list) * h->nr_cmds,
+               kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list),
                                        GFP_KERNEL);
        if (!h->ioaccel2_cmd_sg_list)
                return -ENOMEM;
        for (i = 0; i < h->nr_cmds; i++) {
                h->ioaccel2_cmd_sg_list[i] =
-                       kmalloc(sizeof(*h->ioaccel2_cmd_sg_list[i]) *
-                                       h->maxsgentries, GFP_KERNEL);
+                       kmalloc_array(h->maxsgentries,
+                                     sizeof(*h->ioaccel2_cmd_sg_list[i]),
+                                     GFP_KERNEL);
                if (!h->ioaccel2_cmd_sg_list[i])
                        goto clean;
        }
@@ -2210,14 +2211,15 @@ static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h)
        if (h->chainsize <= 0)
                return 0;
 
-       h->cmd_sg_list = kzalloc(sizeof(*h->cmd_sg_list) * h->nr_cmds,
-                               GFP_KERNEL);
+       h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list),
+                                GFP_KERNEL);
        if (!h->cmd_sg_list)
                return -ENOMEM;
 
        for (i = 0; i < h->nr_cmds; i++) {
-               h->cmd_sg_list[i] = kmalloc(sizeof(*h->cmd_sg_list[i]) *
-                                               h->chainsize, GFP_KERNEL);
+               h->cmd_sg_list[i] = kmalloc_array(h->chainsize,
+                                                 sizeof(*h->cmd_sg_list[i]),
+                                                 GFP_KERNEL);
                if (!h->cmd_sg_list[i])
                        goto clean;
 
@@ -4319,7 +4321,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h)
        bool physical_device;
        DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
 
-       currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL);
+       currentsd = kcalloc(HPSA_MAX_DEVICES, sizeof(*currentsd), GFP_KERNEL);
        physdev_list = kzalloc(sizeof(*physdev_list), GFP_KERNEL);
        logdev_list = kzalloc(sizeof(*logdev_list), GFP_KERNEL);
        tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL);
@@ -6402,12 +6404,12 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp)
                status = -EINVAL;
                goto cleanup1;
        }
-       buff = kzalloc(SG_ENTRIES_IN_CMD * sizeof(char *), GFP_KERNEL);
+       buff = kcalloc(SG_ENTRIES_IN_CMD, sizeof(char *), GFP_KERNEL);
        if (!buff) {
                status = -ENOMEM;
                goto cleanup1;
        }
-       buff_size = kmalloc(SG_ENTRIES_IN_CMD * sizeof(int), GFP_KERNEL);
+       buff_size = kmalloc_array(SG_ENTRIES_IN_CMD, sizeof(int), GFP_KERNEL);
        if (!buff_size) {
                status = -ENOMEM;
                goto cleanup1;
@@ -7151,7 +7153,7 @@ static int controller_reset_failed(struct CfgTable __iomem *cfgtable)
        char *driver_ver, *old_driver_ver;
        int rc, size = sizeof(cfgtable->driver_version);
 
-       old_driver_ver = kmalloc(2 * size, GFP_KERNEL);
+       old_driver_ver = kmalloc_array(2, size, GFP_KERNEL);
        if (!old_driver_ver)
                return -ENOMEM;
        driver_ver = old_driver_ver + size;
@@ -7931,9 +7933,9 @@ static void hpsa_free_cmd_pool(struct ctlr_info *h)
 
 static int hpsa_alloc_cmd_pool(struct ctlr_info *h)
 {
-       h->cmd_pool_bits = kzalloc(
-               DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG) *
-               sizeof(unsigned long), GFP_KERNEL);
+       h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG),
+                                  sizeof(unsigned long),
+                                  GFP_KERNEL);
        h->cmd_pool = pci_alloc_consistent(h->pdev,
                    h->nr_cmds * sizeof(*h->cmd_pool),
                    &(h->cmd_pool_dhandle));
@@ -8507,7 +8509,7 @@ static struct ctlr_info *hpda_alloc_ctlr_info(void)
        if (!h)
                return NULL;
 
-       h->reply_map = kzalloc(sizeof(*h->reply_map) * nr_cpu_ids, GFP_KERNEL);
+       h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL);
        if (!h->reply_map) {
                kfree(h);
                return NULL;
@@ -8869,7 +8871,7 @@ static void hpsa_disable_rld_caching(struct ctlr_info *h)
        kfree(options);
 }
 
-static void hpsa_shutdown(struct pci_dev *pdev)
+static void __hpsa_shutdown(struct pci_dev *pdev)
 {
        struct ctlr_info *h;
 
@@ -8884,6 +8886,12 @@ static void hpsa_shutdown(struct pci_dev *pdev)
        hpsa_disable_interrupt_mode(h);         /* pci_init 2 */
 }
 
+static void hpsa_shutdown(struct pci_dev *pdev)
+{
+       __hpsa_shutdown(pdev);
+       pci_disable_device(pdev);
+}
+
 static void hpsa_free_device_info(struct ctlr_info *h)
 {
        int i;
@@ -8927,7 +8935,7 @@ static void hpsa_remove_one(struct pci_dev *pdev)
                scsi_remove_host(h->scsi_host);         /* init_one 8 */
        /* includes hpsa_free_irqs - init_one 4 */
        /* includes hpsa_disable_interrupt_mode - pci_init 2 */
-       hpsa_shutdown(pdev);
+       __hpsa_shutdown(pdev);
 
        hpsa_free_device_info(h);               /* scan */
 
index 6615ad8754b89f73292be3d067360be823979995..0a9b8b387bd2e70e87310ef7908012a46f32942f 100644 (file)
@@ -4331,9 +4331,11 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg)
        }
 
        if (ioa_cfg->sis64)
-               ioa_data = vmalloc(IPR_FMT3_MAX_NUM_DUMP_PAGES * sizeof(__be32 *));
+               ioa_data = vmalloc(array_size(IPR_FMT3_MAX_NUM_DUMP_PAGES,
+                                             sizeof(__be32 *)));
        else
-               ioa_data = vmalloc(IPR_FMT2_MAX_NUM_DUMP_PAGES * sizeof(__be32 *));
+               ioa_data = vmalloc(array_size(IPR_FMT2_MAX_NUM_DUMP_PAGES,
+                                             sizeof(__be32 *)));
 
        if (!ioa_data) {
                ipr_err("Dump memory allocation failed\n");
@@ -9713,8 +9715,9 @@ static int ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg)
        int i, rc = -ENOMEM;
 
        ENTER;
-       ioa_cfg->res_entries = kzalloc(sizeof(struct ipr_resource_entry) *
-                                      ioa_cfg->max_devs_supported, GFP_KERNEL);
+       ioa_cfg->res_entries = kcalloc(ioa_cfg->max_devs_supported,
+                                      sizeof(struct ipr_resource_entry),
+                                      GFP_KERNEL);
 
        if (!ioa_cfg->res_entries)
                goto out;
@@ -9775,8 +9778,9 @@ static int ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg)
                list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q);
        }
 
-       ioa_cfg->trace = kzalloc(sizeof(struct ipr_trace_entry) *
-                                IPR_NUM_TRACE_ENTRIES, GFP_KERNEL);
+       ioa_cfg->trace = kcalloc(IPR_NUM_TRACE_ENTRIES,
+                                sizeof(struct ipr_trace_entry),
+                                GFP_KERNEL);
 
        if (!ioa_cfg->trace)
                goto out_free_hostrcb_dma;
index 05cf4daf87886b70aeab68ea3687e2378a8d5513..08c7b1e25fe481503ae5d4fd48324f703b40addf 100644 (file)
@@ -232,14 +232,14 @@ static int isci_register_sas_ha(struct isci_host *isci_host)
        struct asd_sas_phy **sas_phys;
        struct asd_sas_port **sas_ports;
 
-       sas_phys = devm_kzalloc(&isci_host->pdev->dev,
-                               SCI_MAX_PHYS * sizeof(void *),
+       sas_phys = devm_kcalloc(&isci_host->pdev->dev,
+                               SCI_MAX_PHYS, sizeof(void *),
                                GFP_KERNEL);
        if (!sas_phys)
                return -ENOMEM;
 
-       sas_ports = devm_kzalloc(&isci_host->pdev->dev,
-                                SCI_MAX_PORTS * sizeof(void *),
+       sas_ports = devm_kcalloc(&isci_host->pdev->dev,
+                                SCI_MAX_PORTS, sizeof(void *),
                                 GFP_KERNEL);
        if (!sas_ports)
                return -ENOMEM;
index 71bdc0b52cf9432ece5acdb19e17a850920dd647..d6093838f5f203dfc0968f2c2ee34f402af96093 100644 (file)
@@ -2576,7 +2576,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size)
         * the array. */
        if (items)
                num_arrays++;
-       q->pool = kvzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
+       q->pool = kvcalloc(num_arrays * max, sizeof(void *), GFP_KERNEL);
        if (q->pool == NULL)
                return -ENOMEM;
 
index 8b7114348def9d4faa1ce416a40324627af92844..fadc99cb60df935b7a285f39b4ac7d0d50622c3f 100644 (file)
@@ -443,7 +443,7 @@ static int sas_expander_discover(struct domain_device *dev)
        struct expander_device *ex = &dev->ex_dev;
        int res = -ENOMEM;
 
-       ex->ex_phy = kzalloc(sizeof(*ex->ex_phy)*ex->num_phys, GFP_KERNEL);
+       ex->ex_phy = kcalloc(ex->num_phys, sizeof(*ex->ex_phy), GFP_KERNEL);
        if (!ex->ex_phy)
                return -ENOMEM;
 
index 7ae343b1463013dc4f1e9cf09f06111da4c478bf..52cae87da0d21fb7cf8bb0fcf69da8f2c841face 100644 (file)
@@ -5723,8 +5723,9 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba)
        }
 
        if (!phba->sli.sli3_ring)
-               phba->sli.sli3_ring = kzalloc(LPFC_SLI3_MAX_RING *
-                       sizeof(struct lpfc_sli_ring), GFP_KERNEL);
+               phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING,
+                                             sizeof(struct lpfc_sli_ring),
+                                             GFP_KERNEL);
        if (!phba->sli.sli3_ring)
                return -ENOMEM;
 
@@ -6233,7 +6234,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba)
 
        /* Allocate eligible FCF bmask memory for FCF roundrobin failover */
        longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG;
-       phba->fcf.fcf_rr_bmask = kzalloc(longs * sizeof(unsigned long),
+       phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long),
                                         GFP_KERNEL);
        if (!phba->fcf.fcf_rr_bmask) {
                lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
index 41361662ff08175dfde84358bb18c59d318d5d52..0758edb9dfe24cd1c5aea26fe8e1434a8031224f 100644 (file)
@@ -120,8 +120,9 @@ lpfc_mem_alloc(struct lpfc_hba *phba, int align)
        if (!phba->lpfc_mbuf_pool)
                goto fail_free_dma_buf_pool;
 
-       pool->elements = kmalloc(sizeof(struct lpfc_dmabuf) *
-                                        LPFC_MBUF_POOL_SIZE, GFP_KERNEL);
+       pool->elements = kmalloc_array(LPFC_MBUF_POOL_SIZE,
+                                      sizeof(struct lpfc_dmabuf),
+                                      GFP_KERNEL);
        if (!pool->elements)
                goto fail_free_lpfc_mbuf_pool;
 
index 4b70d53acb7204d542a45108ef99bc237726ef53..6f3c00a233ecdde57e42100c8a1a83ba94a631b3 100644 (file)
@@ -1720,7 +1720,7 @@ lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq)
                                           - LPFC_IOCBQ_LOOKUP_INCREMENT)) {
                new_len = psli->iocbq_lookup_len + LPFC_IOCBQ_LOOKUP_INCREMENT;
                spin_unlock_irq(&phba->hbalock);
-               new_arr = kzalloc(new_len * sizeof (struct lpfc_iocbq *),
+               new_arr = kcalloc(new_len, sizeof(struct lpfc_iocbq *),
                                  GFP_KERNEL);
                if (new_arr) {
                        spin_lock_irq(&phba->hbalock);
@@ -5142,16 +5142,17 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba)
                 */
                if ((phba->vpi_bmask == NULL) && (phba->vpi_ids == NULL)) {
                        longs = (phba->max_vpi + BITS_PER_LONG) / BITS_PER_LONG;
-                       phba->vpi_bmask = kzalloc(longs * sizeof(unsigned long),
+                       phba->vpi_bmask = kcalloc(longs,
+                                                 sizeof(unsigned long),
                                                  GFP_KERNEL);
                        if (!phba->vpi_bmask) {
                                rc = -ENOMEM;
                                goto lpfc_sli_hba_setup_error;
                        }
 
-                       phba->vpi_ids = kzalloc(
-                                       (phba->max_vpi+1) * sizeof(uint16_t),
-                                       GFP_KERNEL);
+                       phba->vpi_ids = kcalloc(phba->max_vpi + 1,
+                                               sizeof(uint16_t),
+                                               GFP_KERNEL);
                        if (!phba->vpi_ids) {
                                kfree(phba->vpi_bmask);
                                rc = -ENOMEM;
@@ -5836,14 +5837,14 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type)
        length = sizeof(struct lpfc_rsrc_blks);
        switch (type) {
        case LPFC_RSC_TYPE_FCOE_RPI:
-               phba->sli4_hba.rpi_bmask = kzalloc(longs *
+               phba->sli4_hba.rpi_bmask = kcalloc(longs,
                                                   sizeof(unsigned long),
                                                   GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.rpi_bmask)) {
                        rc = -ENOMEM;
                        goto err_exit;
                }
-               phba->sli4_hba.rpi_ids = kzalloc(rsrc_id_cnt *
+               phba->sli4_hba.rpi_ids = kcalloc(rsrc_id_cnt,
                                                 sizeof(uint16_t),
                                                 GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.rpi_ids)) {
@@ -5865,15 +5866,13 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type)
                ext_blk_list = &phba->sli4_hba.lpfc_rpi_blk_list;
                break;
        case LPFC_RSC_TYPE_FCOE_VPI:
-               phba->vpi_bmask = kzalloc(longs *
-                                         sizeof(unsigned long),
+               phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long),
                                          GFP_KERNEL);
                if (unlikely(!phba->vpi_bmask)) {
                        rc = -ENOMEM;
                        goto err_exit;
                }
-               phba->vpi_ids = kzalloc(rsrc_id_cnt *
-                                        sizeof(uint16_t),
+               phba->vpi_ids = kcalloc(rsrc_id_cnt, sizeof(uint16_t),
                                         GFP_KERNEL);
                if (unlikely(!phba->vpi_ids)) {
                        kfree(phba->vpi_bmask);
@@ -5887,7 +5886,7 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type)
                ext_blk_list = &phba->lpfc_vpi_blk_list;
                break;
        case LPFC_RSC_TYPE_FCOE_XRI:
-               phba->sli4_hba.xri_bmask = kzalloc(longs *
+               phba->sli4_hba.xri_bmask = kcalloc(longs,
                                                   sizeof(unsigned long),
                                                   GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.xri_bmask)) {
@@ -5895,7 +5894,7 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type)
                        goto err_exit;
                }
                phba->sli4_hba.max_cfg_param.xri_used = 0;
-               phba->sli4_hba.xri_ids = kzalloc(rsrc_id_cnt *
+               phba->sli4_hba.xri_ids = kcalloc(rsrc_id_cnt,
                                                 sizeof(uint16_t),
                                                 GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.xri_ids)) {
@@ -5910,14 +5909,14 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type)
                ext_blk_list = &phba->sli4_hba.lpfc_xri_blk_list;
                break;
        case LPFC_RSC_TYPE_FCOE_VFI:
-               phba->sli4_hba.vfi_bmask = kzalloc(longs *
+               phba->sli4_hba.vfi_bmask = kcalloc(longs,
                                                   sizeof(unsigned long),
                                                   GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.vfi_bmask)) {
                        rc = -ENOMEM;
                        goto err_exit;
                }
-               phba->sli4_hba.vfi_ids = kzalloc(rsrc_id_cnt *
+               phba->sli4_hba.vfi_ids = kcalloc(rsrc_id_cnt,
                                                 sizeof(uint16_t),
                                                 GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.vfi_ids)) {
@@ -6250,15 +6249,14 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
                }
                base = phba->sli4_hba.max_cfg_param.rpi_base;
                longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG;
-               phba->sli4_hba.rpi_bmask = kzalloc(longs *
+               phba->sli4_hba.rpi_bmask = kcalloc(longs,
                                                   sizeof(unsigned long),
                                                   GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.rpi_bmask)) {
                        rc = -ENOMEM;
                        goto err_exit;
                }
-               phba->sli4_hba.rpi_ids = kzalloc(count *
-                                                sizeof(uint16_t),
+               phba->sli4_hba.rpi_ids = kcalloc(count, sizeof(uint16_t),
                                                 GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.rpi_ids)) {
                        rc = -ENOMEM;
@@ -6279,15 +6277,13 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
                }
                base = phba->sli4_hba.max_cfg_param.vpi_base;
                longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG;
-               phba->vpi_bmask = kzalloc(longs *
-                                         sizeof(unsigned long),
+               phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long),
                                          GFP_KERNEL);
                if (unlikely(!phba->vpi_bmask)) {
                        rc = -ENOMEM;
                        goto free_rpi_ids;
                }
-               phba->vpi_ids = kzalloc(count *
-                                       sizeof(uint16_t),
+               phba->vpi_ids = kcalloc(count, sizeof(uint16_t),
                                        GFP_KERNEL);
                if (unlikely(!phba->vpi_ids)) {
                        rc = -ENOMEM;
@@ -6308,7 +6304,7 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
                }
                base = phba->sli4_hba.max_cfg_param.xri_base;
                longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG;
-               phba->sli4_hba.xri_bmask = kzalloc(longs *
+               phba->sli4_hba.xri_bmask = kcalloc(longs,
                                                   sizeof(unsigned long),
                                                   GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.xri_bmask)) {
@@ -6316,8 +6312,7 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
                        goto free_vpi_ids;
                }
                phba->sli4_hba.max_cfg_param.xri_used = 0;
-               phba->sli4_hba.xri_ids = kzalloc(count *
-                                                sizeof(uint16_t),
+               phba->sli4_hba.xri_ids = kcalloc(count, sizeof(uint16_t),
                                                 GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.xri_ids)) {
                        rc = -ENOMEM;
@@ -6338,15 +6333,14 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba)
                }
                base = phba->sli4_hba.max_cfg_param.vfi_base;
                longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG;
-               phba->sli4_hba.vfi_bmask = kzalloc(longs *
+               phba->sli4_hba.vfi_bmask = kcalloc(longs,
                                                   sizeof(unsigned long),
                                                   GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.vfi_bmask)) {
                        rc = -ENOMEM;
                        goto free_xri_ids;
                }
-               phba->sli4_hba.vfi_ids = kzalloc(count *
-                                                sizeof(uint16_t),
+               phba->sli4_hba.vfi_ids = kcalloc(count, sizeof(uint16_t),
                                                 GFP_KERNEL);
                if (unlikely(!phba->sli4_hba.vfi_ids)) {
                        rc = -ENOMEM;
index c9d33b1268cb66c57fb2e8c0246a944586ada4c3..81bc12dedf415c03f538e5a078b392d5f3410f17 100644 (file)
@@ -840,7 +840,7 @@ lpfc_create_vport_work_array(struct lpfc_hba *phba)
        struct lpfc_vport *port_iterator;
        struct lpfc_vport **vports;
        int index = 0;
-       vports = kzalloc((phba->max_vports + 1) * sizeof(struct lpfc_vport *),
+       vports = kcalloc(phba->max_vports + 1, sizeof(struct lpfc_vport *),
                         GFP_KERNEL);
        if (vports == NULL)
                return NULL;
index 8c4d3003b68b2ed087b73ec41f036105b367f754..177701dfdfcbcd7e7b3ff4c92ce7c639bcddd730 100644 (file)
@@ -464,8 +464,9 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat
                 * +1 to allow for aligning.
         * XXX FIXME: Use DMA consistent routines
         */
-               dma_cmd_space = kmalloc((host->sg_tablesize + 2) *
-                                       sizeof(struct dbdma_cmd), GFP_KERNEL);
+               dma_cmd_space = kmalloc_array(host->sg_tablesize + 2,
+                                            sizeof(struct dbdma_cmd),
+                                            GFP_KERNEL);
                if (dma_cmd_space == 0) {
                        printk(KERN_ERR "mac53c94: couldn't allocate dma "
                               "command space for %pOF\n", node);
index 3b3767e240d89db30eea8f4f019ac9bdc13bf880..8e8cf1145d7f0d8c03cdb70634559a9f5f710ace 100644 (file)
@@ -4292,7 +4292,8 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
                goto out_host_put;
        }
 
-       adapter->scb_list = kmalloc(sizeof(scb_t) * MAX_COMMANDS, GFP_KERNEL);
+       adapter->scb_list = kmalloc_array(MAX_COMMANDS, sizeof(scb_t),
+                                         GFP_KERNEL);
        if (!adapter->scb_list) {
                dev_warn(&pdev->dev, "out of RAM\n");
                goto out_free_cmd_buffer;
index bb802b0c12b8663570dbc57bf6f032d575360e7a..8428247015db6f0c0b5890054e90bb741614feb6 100644 (file)
@@ -935,10 +935,12 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp)
         * Allocate single blocks of memory for all required kiocs,
         * mailboxes and passthru structures.
         */
-       adapter->kioc_list      = kmalloc(sizeof(uioc_t) * lld_adp->max_kioc,
-                                               GFP_KERNEL);
-       adapter->mbox_list      = kmalloc(sizeof(mbox64_t) * lld_adp->max_kioc,
-                                               GFP_KERNEL);
+       adapter->kioc_list      = kmalloc_array(lld_adp->max_kioc,
+                                                 sizeof(uioc_t),
+                                                 GFP_KERNEL);
+       adapter->mbox_list      = kmalloc_array(lld_adp->max_kioc,
+                                                 sizeof(mbox64_t),
+                                                 GFP_KERNEL);
        adapter->pthru_dma_pool = dma_pool_create("megaraid mm pthru pool",
                                                &adapter->pdev->dev,
                                                sizeof(mraid_passthru_t),
index c5d0c4bd71d241f224c02826dda29025a290ef65..71d97573a667fe1f2870df134f186d9f2ffb9839 100644 (file)
@@ -5419,9 +5419,9 @@ static int megasas_init_fw(struct megasas_instance *instance)
        /* stream detection initialization */
        if (instance->adapter_type == VENTURA_SERIES) {
                fusion->stream_detect_by_ld =
-                       kzalloc(sizeof(struct LD_STREAM_DETECT *)
-                       * MAX_LOGICAL_DRIVES_EXT,
-                       GFP_KERNEL);
+                       kcalloc(MAX_LOGICAL_DRIVES_EXT,
+                               sizeof(struct LD_STREAM_DETECT *),
+                               GFP_KERNEL);
                if (!fusion->stream_detect_by_ld) {
                        dev_err(&instance->pdev->dev,
                                "unable to allocate stream detection for pool of LDs\n");
@@ -6139,7 +6139,7 @@ static inline int megasas_alloc_mfi_ctrl_mem(struct megasas_instance *instance)
  */
 static int megasas_alloc_ctrl_mem(struct megasas_instance *instance)
 {
-       instance->reply_map = kzalloc(sizeof(unsigned int) * nr_cpu_ids,
+       instance->reply_map = kcalloc(nr_cpu_ids, sizeof(unsigned int),
                                      GFP_KERNEL);
        if (!instance->reply_map)
                return -ENOMEM;
index 98a7a090b75e92c9d3b94ecc14783449ebd298c0..94c23ad51179f6b491a2f188fe82792791b16ae6 100644 (file)
@@ -487,7 +487,7 @@ megasas_alloc_cmdlist_fusion(struct megasas_instance *instance)
         * commands.
         */
        fusion->cmd_list =
-               kzalloc(sizeof(struct megasas_cmd_fusion *) * max_mpt_cmd,
+               kcalloc(max_mpt_cmd, sizeof(struct megasas_cmd_fusion *),
                        GFP_KERNEL);
        if (!fusion->cmd_list) {
                dev_err(&instance->pdev->dev,
@@ -4829,8 +4829,9 @@ megasas_alloc_fusion_context(struct megasas_instance *instance)
                (PLD_SPAN_INFO)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
                                                fusion->log_to_span_pages);
        if (!fusion->log_to_span) {
-               fusion->log_to_span = vzalloc(MAX_LOGICAL_DRIVES_EXT *
-                                             sizeof(LD_SPAN_INFO));
+               fusion->log_to_span =
+                       vzalloc(array_size(MAX_LOGICAL_DRIVES_EXT,
+                                          sizeof(LD_SPAN_INFO)));
                if (!fusion->log_to_span) {
                        dev_err(&instance->pdev->dev, "Failed from %s %d\n",
                                __func__, __LINE__);
@@ -4844,8 +4845,9 @@ megasas_alloc_fusion_context(struct megasas_instance *instance)
                (struct LD_LOAD_BALANCE_INFO *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
                fusion->load_balance_info_pages);
        if (!fusion->load_balance_info) {
-               fusion->load_balance_info = vzalloc(MAX_LOGICAL_DRIVES_EXT *
-                       sizeof(struct LD_LOAD_BALANCE_INFO));
+               fusion->load_balance_info =
+                       vzalloc(array_size(MAX_LOGICAL_DRIVES_EXT,
+                                          sizeof(struct LD_LOAD_BALANCE_INFO)));
                if (!fusion->load_balance_info)
                        dev_err(&instance->pdev->dev, "Failed to allocate load_balance_info, "
                                "continuing without Load Balance support\n");
index bf04fa90f4337174f7c5f8b99210fe9f7f556acb..569392d0d4c9e478b8e7d1fc745cb7e741005ff3 100644 (file)
@@ -3348,6 +3348,7 @@ _base_mpi_ep_writeq(__u64 b, volatile void __iomem *addr,
        spin_lock_irqsave(writeq_lock, flags);
        writel((u32)(data_out), addr);
        writel((u32)(data_out >> 32), (addr + 4));
+       mmiowb();
        spin_unlock_irqrestore(writeq_lock, flags);
 }
 
index 2bbe797f8c3dae62118c88b26537737a2215052a..7a1a1edde35d372246847d0e5d1af39b9c33de84 100644 (file)
@@ -381,7 +381,7 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd,
                struct scatterlist *sg, *sgl = (struct scatterlist *)buffer;
                int i;
 
-               pages = kzalloc(use_sg * sizeof(struct page *), GFP_KERNEL);
+               pages = kcalloc(use_sg, sizeof(struct page *), GFP_KERNEL);
                if (!pages)
                        goto free_req;
 
@@ -1488,7 +1488,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
        int                     dbg              = debugging;
 #endif
 
-       if ((buffer = vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL)
+       if ((buffer = vmalloc(array_size((nframes + 1), OS_DATA_SIZE))) == NULL)
                return (-EIO);
 
        printk(KERN_INFO "%s:I: Reading back %d frames from drive buffer%s\n",
@@ -5856,7 +5856,9 @@ static int osst_probe(struct device *dev)
        /* if this is the first attach, build the infrastructure */
        write_lock(&os_scsi_tapes_lock);
        if (os_scsi_tapes == NULL) {
-               os_scsi_tapes = kmalloc(osst_max_dev * sizeof(struct osst_tape *), GFP_ATOMIC);
+               os_scsi_tapes = kmalloc_array(osst_max_dev,
+                                              sizeof(struct osst_tape *),
+                                              GFP_ATOMIC);
                if (os_scsi_tapes == NULL) {
                        write_unlock(&os_scsi_tapes_lock);
                        printk(KERN_ERR "osst :E: Unable to allocate array for OnStream SCSI tapes.\n");
index 596f3ff965f5bd9a3eea4beb0a9567b70b6543ac..d193961ea82f1c308ac14b679f2a221727c7ae92 100644 (file)
@@ -705,7 +705,7 @@ static ssize_t pm8001_store_update_fw(struct device *cdev,
                return -EINPROGRESS;
        pm8001_ha->fw_status = FLASH_IN_PROGRESS;
 
-       cmd_ptr = kzalloc(count*2, GFP_KERNEL);
+       cmd_ptr = kcalloc(count, 2, GFP_KERNEL);
        if (!cmd_ptr) {
                pm8001_ha->fw_status = FAIL_OUT_MEMORY;
                return -ENOMEM;
index 95530393872d5f6bcecdeeec3c3f8e47c62463f8..4e86994e10e81f4c41a2617ce8660e97ee772e66 100644 (file)
@@ -4873,8 +4873,9 @@ static int pmcraid_allocate_config_buffers(struct pmcraid_instance *pinstance)
        int i;
 
        pinstance->res_entries =
-                       kzalloc(sizeof(struct pmcraid_resource_entry) *
-                               PMCRAID_MAX_RESOURCES, GFP_KERNEL);
+                       kcalloc(PMCRAID_MAX_RESOURCES,
+                               sizeof(struct pmcraid_resource_entry),
+                               GFP_KERNEL);
 
        if (NULL == pinstance->res_entries) {
                pmcraid_err("failed to allocate memory for resource table\n");
index 32ee7f62fef973abdbee2341b170d0c2c65282aa..cf274a79e77aac86d338d358a71a753636002812 100644 (file)
@@ -524,7 +524,7 @@ static int qedi_init_id_tbl(struct qedi_portid_tbl *id_tbl, u16 size,
        id_tbl->max = size;
        id_tbl->next = next;
        spin_lock_init(&id_tbl->lock);
-       id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL);
+       id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL);
        if (!id_tbl->table)
                return -ENOMEM;
 
index 1aa3720ea2ed582ef9b451506a8c83225bd0fa66..7b675243bd16c61a703cffa69c0f5f0a55a62ea6 100644 (file)
@@ -3089,8 +3089,9 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req)
                        req->num_outstanding_cmds = ha->cur_fw_iocb_count;
        }
 
-       req->outstanding_cmds = kzalloc(sizeof(srb_t *) *
-           req->num_outstanding_cmds, GFP_KERNEL);
+       req->outstanding_cmds = kcalloc(req->num_outstanding_cmds,
+                                       sizeof(srb_t *),
+                                       GFP_KERNEL);
 
        if (!req->outstanding_cmds) {
                /*
@@ -3098,8 +3099,9 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req)
                 * initialization.
                 */
                req->num_outstanding_cmds = MIN_OUTSTANDING_COMMANDS;
-               req->outstanding_cmds = kzalloc(sizeof(srb_t *) *
-                   req->num_outstanding_cmds, GFP_KERNEL);
+               req->outstanding_cmds = kcalloc(req->num_outstanding_cmds,
+                                               sizeof(srb_t *),
+                                               GFP_KERNEL);
 
                if (!req->outstanding_cmds) {
                        ql_log(ql_log_fatal, NULL, 0x0126,
@@ -5007,7 +5009,8 @@ qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport)
                return;
 
        if (fcport->fp_speed == PORT_SPEED_UNKNOWN ||
-           fcport->fp_speed > ha->link_data_rate)
+           fcport->fp_speed > ha->link_data_rate ||
+           !ha->flags.gpsc_supported)
                return;
 
        rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed,
index a3dc83f9444dade9e3a549756dddd23b0d4d852a..9fa5a2557f2c7cc475430ed363ef3c7775768ef8 100644 (file)
@@ -2494,8 +2494,12 @@ qla2x00_status_entry(scsi_qla_host_t *vha, struct rsp_que *rsp, void *pkt)
                ox_id = le16_to_cpu(sts24->ox_id);
                par_sense_len = sizeof(sts24->data);
                /* Valid values of the retry delay timer are 0x1-0xffef */
-               if (sts24->retry_delay > 0 && sts24->retry_delay < 0xfff1)
-                       retry_delay = sts24->retry_delay;
+               if (sts24->retry_delay > 0 && sts24->retry_delay < 0xfff1) {
+                       retry_delay = sts24->retry_delay & 0x3fff;
+                       ql_dbg(ql_dbg_io, sp->vha, 0x3033,
+                           "%s: scope=%#x retry_delay=%#x\n", __func__,
+                           sts24->retry_delay >> 14, retry_delay);
+               }
        } else {
                if (scsi_status & SS_SENSE_LEN_VALID)
                        sense_len = le16_to_cpu(sts->req_sense_length);
@@ -3434,8 +3438,9 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp)
                            "Adjusted Max no of queues pairs: %d.\n", ha->max_qpairs);
                }
        }
-       ha->msix_entries = kzalloc(sizeof(struct qla_msix_entry) *
-                               ha->msix_count, GFP_KERNEL);
+       ha->msix_entries = kcalloc(ha->msix_count,
+                                  sizeof(struct qla_msix_entry),
+                                  GFP_KERNEL);
        if (!ha->msix_entries) {
                ql_log(ql_log_fatal, vha, 0x00c8,
                    "Failed to allocate memory for ha->msix_entries.\n");
index d8a36c13aedaf8606a4931287bb2879aee23dcae..7e875f5752299bdb6af02e542ba90362a399a5c7 100644 (file)
@@ -292,6 +292,14 @@ qla2x00_mailbox_command(scsi_qla_host_t *vha, mbx_cmd_t *mcp)
                        if (time_after(jiffies, wait_time))
                                break;
 
+                       /*
+                        * Check if it's UNLOADING, cause we cannot poll in
+                        * this case, or else a NULL pointer dereference
+                        * is triggered.
+                        */
+                       if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags)))
+                               return QLA_FUNCTION_TIMEOUT;
+
                        /* Check for pending interrupts. */
                        qla2x00_poll(ha->rsp_q_map[0]);
 
index 872d66dd79cd6e7966e381431e69b73cd88d8fac..de2bc78449e786500b0680411d6245895ac43790 100644 (file)
@@ -1230,7 +1230,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha)
        ql_log(ql_log_info, vha, 0x0072,
            "%d CRB init values found in ROM.\n", n);
 
-       buf = kmalloc(n * sizeof(struct crb_addr_pair), GFP_KERNEL);
+       buf = kmalloc_array(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
        if (buf == NULL) {
                ql_log(ql_log_fatal, vha, 0x010c,
                    "Unable to allocate memory.\n");
index 817c18a8e84d0b3e508d224fe6db442a8c93ea34..e881fce7477a90956a4d45b856e484d89821b9e4 100644 (file)
@@ -410,7 +410,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
                                struct rsp_que *rsp)
 {
        scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
-       ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_req_queues,
+       ha->req_q_map = kcalloc(ha->max_req_queues, sizeof(struct req_que *),
                                GFP_KERNEL);
        if (!ha->req_q_map) {
                ql_log(ql_log_fatal, vha, 0x003b,
@@ -418,7 +418,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req,
                goto fail_req_map;
        }
 
-       ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_rsp_queues,
+       ha->rsp_q_map = kcalloc(ha->max_rsp_queues, sizeof(struct rsp_que *),
                                GFP_KERNEL);
        if (!ha->rsp_q_map) {
                ql_log(ql_log_fatal, vha, 0x003c,
@@ -4045,8 +4045,9 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
            (*rsp)->ring);
        /* Allocate memory for NVRAM data for vports */
        if (ha->nvram_npiv_size) {
-               ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) *
-                   ha->nvram_npiv_size, GFP_KERNEL);
+               ha->npiv_info = kcalloc(ha->nvram_npiv_size,
+                                       sizeof(struct qla_npiv_entry),
+                                       GFP_KERNEL);
                if (!ha->npiv_info) {
                        ql_log_pci(ql_log_fatal, ha->pdev, 0x002d,
                            "Failed to allocate memory for npiv_info.\n");
@@ -4080,8 +4081,9 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
        INIT_LIST_HEAD(&ha->vp_list);
 
        /* Allocate memory for our loop_id bitmap */
-       ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long),
-           GFP_KERNEL);
+       ha->loop_id_map = kcalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE),
+                                 sizeof(long),
+                                 GFP_KERNEL);
        if (!ha->loop_id_map)
                goto fail_loop_id_map;
        else {
index b85c833099fffe34aa532a03dcfd3c2bbf257ecc..0fea2e2326becbf4993dd7cc216e36dad529d678 100644 (file)
@@ -6248,8 +6248,9 @@ int qlt_add_target(struct qla_hw_data *ha, struct scsi_qla_host *base_vha)
                return -ENOMEM;
        }
 
-       tgt->qphints = kzalloc((ha->max_qpairs + 1) *
-           sizeof(struct qla_qpair_hint), GFP_KERNEL);
+       tgt->qphints = kcalloc(ha->max_qpairs + 1,
+                              sizeof(struct qla_qpair_hint),
+                              GFP_KERNEL);
        if (!tgt->qphints) {
                kfree(tgt);
                ql_log(ql_log_warn, base_vha, 0x0197,
@@ -7089,8 +7090,9 @@ qlt_mem_alloc(struct qla_hw_data *ha)
        if (!QLA_TGT_MODE_ENABLED())
                return 0;
 
-       ha->tgt.tgt_vp_map = kzalloc(sizeof(struct qla_tgt_vp_map) *
-           MAX_MULTI_ID_FABRIC, GFP_KERNEL);
+       ha->tgt.tgt_vp_map = kcalloc(MAX_MULTI_ID_FABRIC,
+                                    sizeof(struct qla_tgt_vp_map),
+                                    GFP_KERNEL);
        if (!ha->tgt.tgt_vp_map)
                return -ENOMEM;
 
index 0c2e82af9c0ac6a96c43c96eef659c8a07dd0487..7732e9336d43aa6c11e87c9cd94ec13e810101ba 100644 (file)
@@ -1661,7 +1661,9 @@ static int tcm_qla2xxx_init_lport(struct tcm_qla2xxx_lport *lport)
                return rc;
        }
 
-       lport->lport_loopid_map = vzalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
+       lport->lport_loopid_map =
+               vzalloc(array_size(65536,
+                                  sizeof(struct tcm_qla2xxx_fc_loopid)));
        if (!lport->lport_loopid_map) {
                pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n",
                    sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
index 43f73583ef5c4a9abbb3ec43d2ac8aa2cf0493b2..d2b333d629be25077bb7ae09d4fc4070726c21b6 100644 (file)
@@ -1077,7 +1077,7 @@ qla4_82xx_pinit_from_rom(struct scsi_qla_host *ha, int verbose)
        ql4_printk(KERN_INFO, ha,
                "%s: %d CRB init values found in ROM.\n", DRIVER_NAME, n);
 
-       buf = kmalloc(n * sizeof(struct crb_addr_pair), GFP_KERNEL);
+       buf = kmalloc_array(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
        if (buf == NULL) {
                ql4_printk(KERN_WARNING, ha,
                    "%s: [ERROR] Unable to malloc memory.\n", DRIVER_NAME);
index 656c98e116a902da2c230c2026d3b2632548e2f6..24d7496cd9e23cfc2a97126fc22b5f4c25a253b0 100644 (file)
@@ -3450,7 +3450,7 @@ static int resp_comp_write(struct scsi_cmnd *scp,
                return check_condition_result;
        }
        dnum = 2 * num;
-       arr = kzalloc(dnum * lb_size, GFP_ATOMIC);
+       arr = kcalloc(lb_size, dnum, GFP_ATOMIC);
        if (NULL == arr) {
                mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC,
                                INSUFF_RES_ASCQ);
@@ -5439,7 +5439,8 @@ static int __init scsi_debug_init(void)
                }
 
                map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1;
-               map_storep = vmalloc(BITS_TO_LONGS(map_size) * sizeof(long));
+               map_storep = vmalloc(array_size(sizeof(long),
+                                               BITS_TO_LONGS(map_size)));
 
                pr_info("%lu provisioning blocks\n", map_size);
 
index 323e3dc4bc591622b293a70ceee49b5084f93418..a14fef11776ec846c482178ee555c8122a598d22 100644 (file)
@@ -442,7 +442,7 @@ static s64 sd_zbc_check_zone_size(struct scsi_disk *sdkp)
                        } else if (this_zone_blocks != zone_blocks &&
                                   (block + this_zone_blocks < sdkp->capacity
                                    || this_zone_blocks > zone_blocks)) {
-                               this_zone_blocks = 0;
+                               zone_blocks = 0;
                                goto out;
                        }
                        block += this_zone_blocks;
@@ -494,7 +494,7 @@ static s64 sd_zbc_check_zone_size(struct scsi_disk *sdkp)
 static inline unsigned long *
 sd_zbc_alloc_zone_bitmap(u32 nr_zones, int numa_node)
 {
-       return kzalloc_node(BITS_TO_LONGS(nr_zones) * sizeof(unsigned long),
+       return kcalloc_node(BITS_TO_LONGS(nr_zones), sizeof(unsigned long),
                            GFP_KERNEL, numa_node);
 }
 
index 62f04c0511cfe9cb95ccd1eb36e202fb11da6334..0fc39224ce1e4f10c81db98ab01650215e2d44c8 100644 (file)
@@ -747,7 +747,7 @@ static int ses_intf_add(struct device *cdev,
                buf = NULL;
        }
 page2_not_supported:
-       scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL);
+       scomp = kcalloc(components, sizeof(struct ses_component), GFP_KERNEL);
        if (!scomp)
                goto err_free;
 
index 573763908562836e0770671805701518ab1a599b..53ae52dbff84afd2021e80b7c1329cb7c53117c2 100644 (file)
@@ -1045,7 +1045,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
                else {
                        sg_req_info_t *rinfo;
 
-                       rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
+                       rinfo = kcalloc(SG_MAX_QUEUE, SZ_SG_REQ_INFO,
                                        GFP_KERNEL);
                        if (!rinfo)
                                return -ENOMEM;
index 592b6dbf8b3592396152aee2af597f32f4512b09..b78d20b74ed8e31c5ee2c4cb523e91b39bda7441 100644 (file)
@@ -1820,8 +1820,9 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info)
 
        num_new_devices = num_physicals + num_logicals;
 
-       new_device_list = kmalloc(sizeof(*new_device_list) *
-               num_new_devices, GFP_KERNEL);
+       new_device_list = kmalloc_array(num_new_devices,
+                                       sizeof(*new_device_list),
+                                       GFP_KERNEL);
        if (!new_device_list) {
                dev_warn(&ctrl_info->pci_dev->dev, "%s\n", out_of_memory_msg);
                rc = -ENOMEM;
@@ -4251,8 +4252,9 @@ static int pqi_alloc_io_resources(struct pqi_ctrl_info *ctrl_info)
        struct device *dev;
        struct pqi_io_request *io_request;
 
-       ctrl_info->io_request_pool = kzalloc(ctrl_info->max_io_slots *
-               sizeof(ctrl_info->io_request_pool[0]), GFP_KERNEL);
+       ctrl_info->io_request_pool =
+               kcalloc(ctrl_info->max_io_slots,
+                       sizeof(ctrl_info->io_request_pool[0]), GFP_KERNEL);
 
        if (!ctrl_info->io_request_pool) {
                dev_err(&ctrl_info->pci_dev->dev,
index c9e27e752c2545dff1a3714ce5817f7e3036e07b..50c66ccc4b41eaa836ea08d5dfdda2c9206545e2 100644 (file)
@@ -3888,7 +3888,7 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg)
        tb->dma = need_dma;
        tb->buffer_size = 0;
 
-       tb->reserved_pages = kzalloc(max_sg * sizeof(struct page *),
+       tb->reserved_pages = kcalloc(max_sg, sizeof(struct page *),
                                     GFP_KERNEL);
        if (!tb->reserved_pages) {
                kfree(tb);
@@ -4915,7 +4915,8 @@ static int sgl_map_user_pages(struct st_buffer *STbp,
        if (count == 0)
                return 0;
 
-       if ((pages = kmalloc(max_pages * sizeof(*pages), GFP_KERNEL)) == NULL)
+       pages = kmalloc_array(max_pages, sizeof(*pages), GFP_KERNEL);
+       if (pages == NULL)
                return -ENOMEM;
 
         /* Try to fault in all of the necessary pages */
index e82bde0772963cbbde59a52712984f56921d39d9..895a9b5ac98993ecac1c7c3ff2621548b3dd6cea 100644 (file)
@@ -86,8 +86,8 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba)
                goto out;
        }
 
-       clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq),
-                       GFP_KERNEL);
+       clkfreq = devm_kcalloc(dev, sz, sizeof(*clkfreq),
+                              GFP_KERNEL);
        if (!clkfreq) {
                ret = -ENOMEM;
                goto out;
index 3a811c5f70bace97e5c2973864dac08d5dfbf216..397081d320b1952c2677b8bceefc6c69fb402f39 100644 (file)
@@ -3357,8 +3357,8 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba)
        }
 
        /* Allocate memory for local reference block */
-       hba->lrb = devm_kzalloc(hba->dev,
-                               hba->nutrs * sizeof(struct ufshcd_lrb),
+       hba->lrb = devm_kcalloc(hba->dev,
+                               hba->nutrs, sizeof(struct ufshcd_lrb),
                                GFP_KERNEL);
        if (!hba->lrb) {
                dev_err(hba->dev, "LRB Memory allocation failed\n");
index 45d04631888a4f67d0884971226074c6628a063d..6dc8891ccb745a8b1bb259de3fd03e46715d9325 100644 (file)
@@ -794,9 +794,10 @@ static int virtscsi_init(struct virtio_device *vdev,
        struct irq_affinity desc = { .pre_vectors = 2 };
 
        num_vqs = vscsi->num_queues + VIRTIO_SCSI_VQ_BASE;
-       vqs = kmalloc(num_vqs * sizeof(struct virtqueue *), GFP_KERNEL);
-       callbacks = kmalloc(num_vqs * sizeof(vq_callback_t *), GFP_KERNEL);
-       names = kmalloc(num_vqs * sizeof(char *), GFP_KERNEL);
+       vqs = kmalloc_array(num_vqs, sizeof(struct virtqueue *), GFP_KERNEL);
+       callbacks = kmalloc_array(num_vqs, sizeof(vq_callback_t *),
+                                 GFP_KERNEL);
+       names = kmalloc_array(num_vqs, sizeof(char *), GFP_KERNEL);
 
        if (!callbacks || !vqs || !names) {
                err = -ENOMEM;
index 7442bc130055c3745e02a7a1e4503742335513b5..eeb028b9cdb39ae495cd1b6dc6ba4a34361fadf4 100644 (file)
@@ -249,7 +249,7 @@ static int __init sh_clk_div_register_ops(struct clk *clks, int nr,
        int k;
 
        freq_table_size *= (nr_divs + 1);
-       freq_table = kzalloc(freq_table_size * nr, GFP_KERNEL);
+       freq_table = kcalloc(nr, freq_table_size, GFP_KERNEL);
        if (!freq_table) {
                pr_err("%s: unable to alloc memory\n", __func__);
                return -ENOMEM;
index 8e72bcbd3d6d4b4da15f716d74cd89be8906b0a3..46f0f322d4d8f7d4c2b4d373d74da5d58c8774d5 100644 (file)
@@ -203,7 +203,7 @@ int __init register_intc_controller(struct intc_desc *desc)
 
        if (desc->num_resources) {
                d->nr_windows = desc->num_resources;
-               d->window = kzalloc(d->nr_windows * sizeof(*d->window),
+               d->window = kcalloc(d->nr_windows, sizeof(*d->window),
                                    GFP_NOWAIT);
                if (!d->window)
                        goto err1;
@@ -230,12 +230,12 @@ int __init register_intc_controller(struct intc_desc *desc)
        d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0;
        d->nr_reg += hw->subgroups ? hw->nr_subgroups : 0;
 
-       d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT);
+       d->reg = kcalloc(d->nr_reg, sizeof(*d->reg), GFP_NOWAIT);
        if (!d->reg)
                goto err2;
 
 #ifdef CONFIG_SMP
-       d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT);
+       d->smp = kcalloc(d->nr_reg, sizeof(*d->smp), GFP_NOWAIT);
        if (!d->smp)
                goto err3;
 #endif
@@ -253,7 +253,7 @@ int __init register_intc_controller(struct intc_desc *desc)
        }
 
        if (hw->prio_regs) {
-               d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio),
+               d->prio = kcalloc(hw->nr_vectors, sizeof(*d->prio),
                                  GFP_NOWAIT);
                if (!d->prio)
                        goto err4;
@@ -269,7 +269,7 @@ int __init register_intc_controller(struct intc_desc *desc)
        }
 
        if (hw->sense_regs) {
-               d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense),
+               d->sense = kcalloc(hw->nr_vectors, sizeof(*d->sense),
                                   GFP_NOWAIT);
                if (!d->sense)
                        goto err5;
index 7525039d812cebdc44f8d6f2f41e37355cdda742..2e45988d1259c9cf0573cb00604c97d86218e83b 100644 (file)
@@ -161,7 +161,7 @@ int maple_add_packet(struct maple_device *mdev, u32 function, u32 command,
        void *sendbuf = NULL;
 
        if (length) {
-               sendbuf = kzalloc(length * 4, GFP_KERNEL);
+               sendbuf = kcalloc(length, 4, GFP_KERNEL);
                if (!sendbuf) {
                        ret = -ENOMEM;
                        goto out;
index bb36a8fbc9b1bcc2ee8311de86b197e62f179be6..db1f5135846aac611a4da17454f406581fd35124 100644 (file)
@@ -540,7 +540,7 @@ static int qcom_slim_probe(struct platform_device *pdev)
        ctrl->tx.sl_sz = SLIM_MSGQ_BUF_LEN;
        ctrl->rx.n = QCOM_RX_MSGS;
        ctrl->rx.sl_sz = SLIM_MSGQ_BUF_LEN;
-       ctrl->wr_comp = kzalloc(sizeof(struct completion *) * QCOM_TX_MSGS,
+       ctrl->wr_comp = kcalloc(QCOM_TX_MSGS, sizeof(struct completion *),
                                GFP_KERNEL);
        if (!ctrl->wr_comp)
                return -ENOMEM;
index 40523577bdaa0df387a68a905b76a3493af7c97d..113e884697fd8c3478d9b7900a79360fb3fad2f5 100644 (file)
@@ -14,7 +14,7 @@ obj-$(CONFIG_ARCH_MXC)                += imx/
 obj-$(CONFIG_SOC_XWAY)         += lantiq/
 obj-y                          += mediatek/
 obj-$(CONFIG_ARCH_MESON)       += amlogic/
-obj-$(CONFIG_ARCH_QCOM)                += qcom/
+obj-y                          += qcom/
 obj-y                          += renesas/
 obj-$(CONFIG_ARCH_ROCKCHIP)    += rockchip/
 obj-$(CONFIG_SOC_SAMSUNG)      += samsung/
index f7ed1187518b9d2b47bedd29ae6b5a1e3ab566fd..a78dfe0a2b503c3a98e09f48c606f45ea184a513 100644 (file)
@@ -165,8 +165,10 @@ static int rpi_power_probe(struct platform_device *pdev)
                return -ENOMEM;
 
        rpi_domains->xlate.domains =
-               devm_kzalloc(dev, sizeof(*rpi_domains->xlate.domains) *
-                            RPI_POWER_DOMAIN_COUNT, GFP_KERNEL);
+               devm_kcalloc(dev,
+                            RPI_POWER_DOMAIN_COUNT,
+                            sizeof(*rpi_domains->xlate.domains),
+                            GFP_KERNEL);
        if (!rpi_domains->xlate.domains)
                return -ENOMEM;
 
index ba3cfa8e279b508fc632147da0aab110e81724ca..ecb22749df0bfa4a4fc0596f8eb32a9b693c5004 100644 (file)
@@ -1021,7 +1021,8 @@ int qman_alloc_fq_table(u32 _num_fqids)
 {
        num_fqids = _num_fqids;
 
-       fq_table = vzalloc(num_fqids * 2 * sizeof(struct qman_fq *));
+       fq_table = vzalloc(array3_size(sizeof(struct qman_fq *),
+                                      num_fqids, 2));
        if (!fq_table)
                return -ENOMEM;
 
@@ -1181,7 +1182,7 @@ static int qman_create_portal(struct qman_portal *portal,
        qm_dqrr_set_ithresh(p, QMAN_PIRQ_DQRR_ITHRESH);
        qm_mr_set_ithresh(p, QMAN_PIRQ_MR_ITHRESH);
        qm_out(p, QM_REG_ITPR, QMAN_PIRQ_IPERIOD);
-       portal->cgrs = kmalloc(2 * sizeof(*cgrs), GFP_KERNEL);
+       portal->cgrs = kmalloc_array(2, sizeof(*cgrs), GFP_KERNEL);
        if (!portal->cgrs)
                goto fail_cgrs;
        /* initial snapshot is no-depletion */
index c4d35f32af8d704b021d1c992cd50629c34adc5d..32f0748fd0678fedc520b08b807590981d007154 100644 (file)
@@ -443,17 +443,25 @@ static int imx_gpc_probe(struct platform_device *pdev)
                        if (domain_index >= of_id_data->num_domains)
                                continue;
 
-                       domain = &imx_gpc_domains[domain_index];
-                       domain->regmap = regmap;
-                       domain->ipg_rate_mhz = ipg_rate_mhz;
-
                        pd_pdev = platform_device_alloc("imx-pgc-power-domain",
                                                        domain_index);
                        if (!pd_pdev) {
                                of_node_put(np);
                                return -ENOMEM;
                        }
-                       pd_pdev->dev.platform_data = domain;
+
+                       ret = platform_device_add_data(pd_pdev,
+                                                      &imx_gpc_domains[domain_index],
+                                                      sizeof(imx_gpc_domains[domain_index]));
+                       if (ret) {
+                               platform_device_put(pd_pdev);
+                               of_node_put(np);
+                               return ret;
+                       }
+                       domain = pd_pdev->dev.platform_data;
+                       domain->regmap = regmap;
+                       domain->ipg_rate_mhz = ipg_rate_mhz;
+
                        pd_pdev->dev.parent = &pdev->dev;
                        pd_pdev->dev.of_node = np;
 
index afc7ecc3c1876158d33e45933458fc035593c39f..f4e3bd40c72e60c0448c98456f7b53f6be7936bd 100644 (file)
@@ -155,7 +155,7 @@ static int imx7_gpc_pu_pgc_sw_pdn_req(struct generic_pm_domain *genpd)
        return imx7_gpc_pu_pgc_sw_pxx_req(genpd, false);
 }
 
-static struct imx7_pgc_domain imx7_pgc_domains[] = {
+static const struct imx7_pgc_domain imx7_pgc_domains[] = {
        [IMX7_POWER_DOMAIN_MIPI_PHY] = {
                .genpd = {
                        .name      = "mipi-phy",
@@ -321,11 +321,6 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
                        continue;
                }
 
-               domain = &imx7_pgc_domains[domain_index];
-               domain->regmap = regmap;
-               domain->genpd.power_on  = imx7_gpc_pu_pgc_sw_pup_req;
-               domain->genpd.power_off = imx7_gpc_pu_pgc_sw_pdn_req;
-
                pd_pdev = platform_device_alloc("imx7-pgc-domain",
                                                domain_index);
                if (!pd_pdev) {
@@ -334,7 +329,20 @@ static int imx_gpcv2_probe(struct platform_device *pdev)
                        return -ENOMEM;
                }
 
-               pd_pdev->dev.platform_data = domain;
+               ret = platform_device_add_data(pd_pdev,
+                                              &imx7_pgc_domains[domain_index],
+                                              sizeof(imx7_pgc_domains[domain_index]));
+               if (ret) {
+                       platform_device_put(pd_pdev);
+                       of_node_put(np);
+                       return ret;
+               }
+
+               domain = pd_pdev->dev.platform_data;
+               domain->regmap = regmap;
+               domain->genpd.power_on  = imx7_gpc_pu_pgc_sw_pup_req;
+               domain->genpd.power_off = imx7_gpc_pu_pgc_sw_pdn_req;
+
                pd_pdev->dev.parent = dev;
                pd_pdev->dev.of_node = np;
 
index 8c310de01e93744d182055fee11b38ba63953605..958861c9e6ee86df270d3e7d38847ba4a722f603 100644 (file)
@@ -17,6 +17,9 @@
 #include <linux/soc/mediatek/infracfg.h>
 #include <asm/processor.h>
 
+#define MTK_POLL_DELAY_US   10
+#define MTK_POLL_TIMEOUT    (jiffies_to_usecs(HZ))
+
 #define INFRA_TOPAXI_PROTECTEN         0x0220
 #define INFRA_TOPAXI_PROTECTSTA1       0x0228
 #define INFRA_TOPAXI_PROTECTEN_SET     0x0260
@@ -37,7 +40,6 @@
 int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
                bool reg_update)
 {
-       unsigned long expired;
        u32 val;
        int ret;
 
@@ -47,22 +49,11 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
        else
                regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_SET, mask);
 
-       expired = jiffies + HZ;
-
-       while (1) {
-               ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val);
-               if (ret)
-                       return ret;
-
-               if ((val & mask) == mask)
-                       break;
+       ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
+                                      val, (val & mask) == mask,
+                                      MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
 
-               cpu_relax();
-               if (time_after(jiffies, expired))
-                       return -EIO;
-       }
-
-       return 0;
+       return ret;
 }
 
 /**
@@ -80,30 +71,17 @@ int mtk_infracfg_set_bus_protection(struct regmap *infracfg, u32 mask,
 int mtk_infracfg_clear_bus_protection(struct regmap *infracfg, u32 mask,
                bool reg_update)
 {
-       unsigned long expired;
        int ret;
+       u32 val;
 
        if (reg_update)
                regmap_update_bits(infracfg, INFRA_TOPAXI_PROTECTEN, mask, 0);
        else
                regmap_write(infracfg, INFRA_TOPAXI_PROTECTEN_CLR, mask);
 
-       expired = jiffies + HZ;
-
-       while (1) {
-               u32 val;
-
-               ret = regmap_read(infracfg, INFRA_TOPAXI_PROTECTSTA1, &val);
-               if (ret)
-                       return ret;
-
-               if (!(val & mask))
-                       break;
-
-               cpu_relax();
-               if (time_after(jiffies, expired))
-                       return -EIO;
-       }
+       ret = regmap_read_poll_timeout(infracfg, INFRA_TOPAXI_PROTECTSTA1,
+                                      val, !(val & mask),
+                                      MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
 
-       return 0;
+       return ret;
 }
index e9e054a15b7d22e6f12834a5d71e76589e0a26e4..2afae64061d85c939ea61a8285f1c33b894ac8a4 100644 (file)
@@ -1458,19 +1458,12 @@ static int pwrap_probe(struct platform_device *pdev)
        int ret, irq;
        struct pmic_wrapper *wrp;
        struct device_node *np = pdev->dev.of_node;
-       const struct of_device_id *of_id =
-               of_match_device(of_pwrap_match_tbl, &pdev->dev);
        const struct of_device_id *of_slave_id = NULL;
        struct resource *res;
 
-       if (!of_id) {
-               dev_err(&pdev->dev, "Error: No device match found\n");
-               return -ENODEV;
-       }
+       if (np->child)
+               of_slave_id = of_match_node(of_slave_match_tbl, np->child);
 
-       if (pdev->dev.of_node->child)
-               of_slave_id = of_match_node(of_slave_match_tbl,
-                                           pdev->dev.of_node->child);
        if (!of_slave_id) {
                dev_dbg(&pdev->dev, "slave pmic should be defined in dts\n");
                return -EINVAL;
@@ -1482,7 +1475,7 @@ static int pwrap_probe(struct platform_device *pdev)
 
        platform_set_drvdata(pdev, wrp);
 
-       wrp->master = of_id->data;
+       wrp->master = of_device_get_match_data(&pdev->dev);
        wrp->slave = of_slave_id->data;
        wrp->dev = &pdev->dev;
 
index d762a46d434fc8c99be832d6938dbb8d9bf55768..5b24bb4bfbf6608084ccf5607c4649d27c33ea14 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/clk.h>
 #include <linux/init.h>
 #include <linux/io.h>
+#include <linux/iopoll.h>
 #include <linux/mfd/syscon.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <dt-bindings/power/mt7623a-power.h>
 #include <dt-bindings/power/mt8173-power.h>
 
+#define MTK_POLL_DELAY_US   10
+#define MTK_POLL_TIMEOUT    (jiffies_to_usecs(HZ))
+
+#define MTK_SCPD_ACTIVE_WAKEUP         BIT(0)
+#define MTK_SCPD_FWAIT_SRAM            BIT(1)
+#define MTK_SCPD_CAPS(_scpd, _x)       ((_scpd)->data->caps & (_x))
+
 #define SPM_VDE_PWR_CON                        0x0210
 #define SPM_MFG_PWR_CON                        0x0214
 #define SPM_VEN_PWR_CON                        0x0230
@@ -116,7 +124,7 @@ struct scp_domain_data {
        u32 sram_pdn_ack_bits;
        u32 bus_prot_mask;
        enum clk_id clk_id[MAX_CLKS];
-       bool active_wakeup;
+       u8 caps;
 };
 
 struct scp;
@@ -184,12 +192,10 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
 {
        struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd);
        struct scp *scp = scpd->scp;
-       unsigned long timeout;
-       bool expired;
        void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs;
-       u32 sram_pdn_ack = scpd->data->sram_pdn_ack_bits;
+       u32 pdn_ack = scpd->data->sram_pdn_ack_bits;
        u32 val;
-       int ret;
+       int ret, tmp;
        int i;
 
        if (scpd->supply) {
@@ -215,23 +221,10 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
        writel(val, ctl_addr);
 
        /* wait until PWR_ACK = 1 */
-       timeout = jiffies + HZ;
-       expired = false;
-       while (1) {
-               ret = scpsys_domain_is_on(scpd);
-               if (ret > 0)
-                       break;
-
-               if (expired) {
-                       ret = -ETIMEDOUT;
-                       goto err_pwr_ack;
-               }
-
-               cpu_relax();
-
-               if (time_after(jiffies, timeout))
-                       expired = true;
-       }
+       ret = readx_poll_timeout(scpsys_domain_is_on, scpd, tmp, tmp > 0,
+                                MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
+       if (ret < 0)
+               goto err_pwr_ack;
 
        val &= ~PWR_CLK_DIS_BIT;
        writel(val, ctl_addr);
@@ -245,20 +238,20 @@ static int scpsys_power_on(struct generic_pm_domain *genpd)
        val &= ~scpd->data->sram_pdn_bits;
        writel(val, ctl_addr);
 
-       /* wait until SRAM_PDN_ACK all 0 */
-       timeout = jiffies + HZ;
-       expired = false;
-       while (sram_pdn_ack && (readl(ctl_addr) & sram_pdn_ack)) {
+       /* Either wait until SRAM_PDN_ACK all 0 or have a force wait */
+       if (MTK_SCPD_CAPS(scpd, MTK_SCPD_FWAIT_SRAM)) {
+               /*
+                * Currently, MTK_SCPD_FWAIT_SRAM is necessary only for
+                * MT7622_POWER_DOMAIN_WB and thus just a trivial setup is
+                * applied here.
+                */
+               usleep_range(12000, 12100);
 
-               if (expired) {
-                       ret = -ETIMEDOUT;
+       } else {
+               ret = readl_poll_timeout(ctl_addr, tmp, (tmp & pdn_ack) == 0,
+                                        MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
+               if (ret < 0)
                        goto err_pwr_ack;
-               }
-
-               cpu_relax();
-
-               if (time_after(jiffies, timeout))
-                       expired = true;
        }
 
        if (scpd->data->bus_prot_mask) {
@@ -289,12 +282,10 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
 {
        struct scp_domain *scpd = container_of(genpd, struct scp_domain, genpd);
        struct scp *scp = scpd->scp;
-       unsigned long timeout;
-       bool expired;
        void __iomem *ctl_addr = scp->base + scpd->data->ctl_offs;
        u32 pdn_ack = scpd->data->sram_pdn_ack_bits;
        u32 val;
-       int ret;
+       int ret, tmp;
        int i;
 
        if (scpd->data->bus_prot_mask) {
@@ -310,19 +301,10 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
        writel(val, ctl_addr);
 
        /* wait until SRAM_PDN_ACK all 1 */
-       timeout = jiffies + HZ;
-       expired = false;
-       while (pdn_ack && (readl(ctl_addr) & pdn_ack) != pdn_ack) {
-               if (expired) {
-                       ret = -ETIMEDOUT;
-                       goto out;
-               }
-
-               cpu_relax();
-
-               if (time_after(jiffies, timeout))
-                       expired = true;
-       }
+       ret = readl_poll_timeout(ctl_addr, tmp, (tmp & pdn_ack) == pdn_ack,
+                                MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
+       if (ret < 0)
+               goto out;
 
        val |= PWR_ISO_BIT;
        writel(val, ctl_addr);
@@ -340,23 +322,10 @@ static int scpsys_power_off(struct generic_pm_domain *genpd)
        writel(val, ctl_addr);
 
        /* wait until PWR_ACK = 0 */
-       timeout = jiffies + HZ;
-       expired = false;
-       while (1) {
-               ret = scpsys_domain_is_on(scpd);
-               if (ret == 0)
-                       break;
-
-               if (expired) {
-                       ret = -ETIMEDOUT;
-                       goto out;
-               }
-
-               cpu_relax();
-
-               if (time_after(jiffies, timeout))
-                       expired = true;
-       }
+       ret = readx_poll_timeout(scpsys_domain_is_on, scpd, tmp, tmp == 0,
+                                MTK_POLL_DELAY_US, MTK_POLL_TIMEOUT);
+       if (ret < 0)
+               goto out;
 
        for (i = 0; i < MAX_CLKS && scpd->clk[i]; i++)
                clk_disable_unprepare(scpd->clk[i]);
@@ -407,15 +376,15 @@ static struct scp *init_scp(struct platform_device *pdev,
        if (IS_ERR(scp->base))
                return ERR_CAST(scp->base);
 
-       scp->domains = devm_kzalloc(&pdev->dev,
-                               sizeof(*scp->domains) * num, GFP_KERNEL);
+       scp->domains = devm_kcalloc(&pdev->dev,
+                               num, sizeof(*scp->domains), GFP_KERNEL);
        if (!scp->domains)
                return ERR_PTR(-ENOMEM);
 
        pd_data = &scp->pd_data;
 
-       pd_data->domains = devm_kzalloc(&pdev->dev,
-                       sizeof(*pd_data->domains) * num, GFP_KERNEL);
+       pd_data->domains = devm_kcalloc(&pdev->dev,
+                       num, sizeof(*pd_data->domains), GFP_KERNEL);
        if (!pd_data->domains)
                return ERR_PTR(-ENOMEM);
 
@@ -469,7 +438,7 @@ static struct scp *init_scp(struct platform_device *pdev,
                genpd->name = data->name;
                genpd->power_off = scpsys_power_off;
                genpd->power_on = scpsys_power_on;
-               if (scpd->data->active_wakeup)
+               if (MTK_SCPD_CAPS(scpd, MTK_SCPD_ACTIVE_WAKEUP))
                        genpd->flags |= GENPD_FLAG_ACTIVE_WAKEUP;
        }
 
@@ -522,7 +491,7 @@ static const struct scp_domain_data scp_domain_data_mt2701[] = {
                .bus_prot_mask = MT2701_TOP_AXI_PROT_EN_CONN_M |
                                 MT2701_TOP_AXI_PROT_EN_CONN_S,
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2701_POWER_DOMAIN_DISP] = {
                .name = "disp",
@@ -531,7 +500,7 @@ static const struct scp_domain_data scp_domain_data_mt2701[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .clk_id = {CLK_MM},
                .bus_prot_mask = MT2701_TOP_AXI_PROT_EN_MM_M0,
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2701_POWER_DOMAIN_MFG] = {
                .name = "mfg",
@@ -540,7 +509,7 @@ static const struct scp_domain_data scp_domain_data_mt2701[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(12, 12),
                .clk_id = {CLK_MFG},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2701_POWER_DOMAIN_VDEC] = {
                .name = "vdec",
@@ -549,7 +518,7 @@ static const struct scp_domain_data scp_domain_data_mt2701[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(12, 12),
                .clk_id = {CLK_MM},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2701_POWER_DOMAIN_ISP] = {
                .name = "isp",
@@ -558,7 +527,7 @@ static const struct scp_domain_data scp_domain_data_mt2701[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(13, 12),
                .clk_id = {CLK_MM},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2701_POWER_DOMAIN_BDP] = {
                .name = "bdp",
@@ -566,7 +535,7 @@ static const struct scp_domain_data scp_domain_data_mt2701[] = {
                .ctl_offs = SPM_BDP_PWR_CON,
                .sram_pdn_bits = GENMASK(11, 8),
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2701_POWER_DOMAIN_ETH] = {
                .name = "eth",
@@ -575,7 +544,7 @@ static const struct scp_domain_data scp_domain_data_mt2701[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_ETHIF},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2701_POWER_DOMAIN_HIF] = {
                .name = "hif",
@@ -584,14 +553,14 @@ static const struct scp_domain_data scp_domain_data_mt2701[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_ETHIF},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2701_POWER_DOMAIN_IFR_MSC] = {
                .name = "ifr_msc",
                .sta_mask = PWR_STATUS_IFR_MSC,
                .ctl_offs = SPM_IFR_MSC_PWR_CON,
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
 };
 
@@ -606,7 +575,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(8, 8),
                .sram_pdn_ack_bits = GENMASK(12, 12),
                .clk_id = {CLK_MM},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_VDEC] = {
                .name = "vdec",
@@ -615,7 +584,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(8, 8),
                .sram_pdn_ack_bits = GENMASK(12, 12),
                .clk_id = {CLK_MM, CLK_VDEC},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_VENC] = {
                .name = "venc",
@@ -624,7 +593,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_MM, CLK_VENC, CLK_JPGDEC},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_ISP] = {
                .name = "isp",
@@ -633,7 +602,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(13, 12),
                .clk_id = {CLK_MM},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_AUDIO] = {
                .name = "audio",
@@ -642,7 +611,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_AUDIO},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_USB] = {
                .name = "usb",
@@ -651,7 +620,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(10, 8),
                .sram_pdn_ack_bits = GENMASK(14, 12),
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_USB2] = {
                .name = "usb2",
@@ -660,7 +629,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(10, 8),
                .sram_pdn_ack_bits = GENMASK(14, 12),
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_MFG] = {
                .name = "mfg",
@@ -670,7 +639,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_ack_bits = GENMASK(16, 16),
                .clk_id = {CLK_MFG},
                .bus_prot_mask = BIT(14) | BIT(21) | BIT(23),
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_MFG_SC1] = {
                .name = "mfg_sc1",
@@ -679,7 +648,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(8, 8),
                .sram_pdn_ack_bits = GENMASK(16, 16),
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_MFG_SC2] = {
                .name = "mfg_sc2",
@@ -688,7 +657,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(8, 8),
                .sram_pdn_ack_bits = GENMASK(16, 16),
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT2712_POWER_DOMAIN_MFG_SC3] = {
                .name = "mfg_sc3",
@@ -697,7 +666,7 @@ static const struct scp_domain_data scp_domain_data_mt2712[] = {
                .sram_pdn_bits = GENMASK(8, 8),
                .sram_pdn_ack_bits = GENMASK(16, 16),
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
 };
 
@@ -797,7 +766,7 @@ static const struct scp_domain_data scp_domain_data_mt7622[] = {
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_NONE},
                .bus_prot_mask = MT7622_TOP_AXI_PROT_EN_ETHSYS,
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT7622_POWER_DOMAIN_HIF0] = {
                .name = "hif0",
@@ -807,7 +776,7 @@ static const struct scp_domain_data scp_domain_data_mt7622[] = {
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_HIFSEL},
                .bus_prot_mask = MT7622_TOP_AXI_PROT_EN_HIF0,
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT7622_POWER_DOMAIN_HIF1] = {
                .name = "hif1",
@@ -817,7 +786,7 @@ static const struct scp_domain_data scp_domain_data_mt7622[] = {
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_HIFSEL},
                .bus_prot_mask = MT7622_TOP_AXI_PROT_EN_HIF1,
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT7622_POWER_DOMAIN_WB] = {
                .name = "wb",
@@ -827,7 +796,7 @@ static const struct scp_domain_data scp_domain_data_mt7622[] = {
                .sram_pdn_ack_bits = 0,
                .clk_id = {CLK_NONE},
                .bus_prot_mask = MT7622_TOP_AXI_PROT_EN_WB,
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP | MTK_SCPD_FWAIT_SRAM,
        },
 };
 
@@ -843,7 +812,7 @@ static const struct scp_domain_data scp_domain_data_mt7623a[] = {
                .bus_prot_mask = MT2701_TOP_AXI_PROT_EN_CONN_M |
                                 MT2701_TOP_AXI_PROT_EN_CONN_S,
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT7623A_POWER_DOMAIN_ETH] = {
                .name = "eth",
@@ -852,7 +821,7 @@ static const struct scp_domain_data scp_domain_data_mt7623a[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_ETHIF},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT7623A_POWER_DOMAIN_HIF] = {
                .name = "hif",
@@ -861,14 +830,14 @@ static const struct scp_domain_data scp_domain_data_mt7623a[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_ETHIF},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT7623A_POWER_DOMAIN_IFR_MSC] = {
                .name = "ifr_msc",
                .sta_mask = PWR_STATUS_IFR_MSC,
                .ctl_offs = SPM_IFR_MSC_PWR_CON,
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
 };
 
@@ -934,7 +903,7 @@ static const struct scp_domain_data scp_domain_data_mt8173[] = {
                .sram_pdn_bits = GENMASK(11, 8),
                .sram_pdn_ack_bits = GENMASK(15, 12),
                .clk_id = {CLK_NONE},
-               .active_wakeup = true,
+               .caps = MTK_SCPD_ACTIVE_WAKEUP,
        },
        [MT8173_POWER_DOMAIN_MFG_ASYNC] = {
                .name = "mfg_async",
@@ -1067,15 +1036,13 @@ static const struct of_device_id of_scpsys_match_tbl[] = {
 
 static int scpsys_probe(struct platform_device *pdev)
 {
-       const struct of_device_id *match;
        const struct scp_subdomain *sd;
        const struct scp_soc_data *soc;
        struct scp *scp;
        struct genpd_onecell_data *pd_data;
        int i, ret;
 
-       match = of_match_device(of_scpsys_match_tbl, &pdev->dev);
-       soc = (const struct scp_soc_data *)match->data;
+       soc = of_device_get_match_data(&pdev->dev);
 
        scp = init_scp(pdev, soc->domains, soc->num_domains, &soc->regs,
                        soc->bus_prot_reg_update);
index d053f2634c67a30da9c04a9b0f484c2d6683c59e..9dc02f390ba314bf8cfbb1b86223af1859af2507 100644 (file)
@@ -3,6 +3,24 @@
 #
 menu "Qualcomm SoC drivers"
 
+config QCOM_COMMAND_DB
+       bool "Qualcomm Command DB"
+       depends on (ARCH_QCOM && OF) || COMPILE_TEST
+       help
+         Command DB queries shared memory by key string for shared system
+         resources. Platform drivers that require to set state of a shared
+         resource on a RPM-hardened platform must use this database to get
+         SoC specific identifier and information for the shared resources.
+
+config QCOM_GENI_SE
+       tristate "QCOM GENI Serial Engine Driver"
+       depends on ARCH_QCOM || COMPILE_TEST
+       help
+         This driver is used to manage Generic Interface (GENI) firmware based
+         Qualcomm Technologies, Inc. Universal Peripheral (QUP) Wrapper. This
+         driver is also used to manage the common aspects of multiple Serial
+         Engines present in the QUP.
+
 config QCOM_GLINK_SSR
        tristate "Qualcomm Glink SSR driver"
        depends on RPMSG
index 39de5dee55d9d3835b6c1f91d227ef2abae26fde..19dcf957cb3a052bb339d0559223adc45b05c43d 100644 (file)
@@ -1,4 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
+obj-$(CONFIG_QCOM_GENI_SE) +=  qcom-geni-se.o
+obj-$(CONFIG_QCOM_COMMAND_DB) += cmd-db.o
 obj-$(CONFIG_QCOM_GLINK_SSR) +=        glink_ssr.o
 obj-$(CONFIG_QCOM_GSBI)        +=      qcom_gsbi.o
 obj-$(CONFIG_QCOM_MDT_LOADER)  += mdt_loader.o
diff --git a/drivers/soc/qcom/cmd-db.c b/drivers/soc/qcom/cmd-db.c
new file mode 100644 (file)
index 0000000..a6f6462
--- /dev/null
@@ -0,0 +1,317 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */
+
+#include <linux/kernel.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/of_reserved_mem.h>
+#include <linux/platform_device.h>
+#include <linux/types.h>
+
+#include <soc/qcom/cmd-db.h>
+
+#define NUM_PRIORITY           2
+#define MAX_SLV_ID             8
+#define SLAVE_ID_MASK          0x7
+#define SLAVE_ID_SHIFT         16
+
+/**
+ * struct entry_header: header for each entry in cmddb
+ *
+ * @id: resource's identifier
+ * @priority: unused
+ * @addr: the address of the resource
+ * @len: length of the data
+ * @offset: offset from :@data_offset, start of the data
+ */
+struct entry_header {
+       u8 id[8];
+       __le32 priority[NUM_PRIORITY];
+       __le32 addr;
+       __le16 len;
+       __le16 offset;
+};
+
+/**
+ * struct rsc_hdr: resource header information
+ *
+ * @slv_id: id for the resource
+ * @header_offset: entry's header at offset from the end of the cmd_db_header
+ * @data_offset: entry's data at offset from the end of the cmd_db_header
+ * @cnt: number of entries for HW type
+ * @version: MSB is major, LSB is minor
+ * @reserved: reserved for future use.
+ */
+struct rsc_hdr {
+       __le16 slv_id;
+       __le16 header_offset;
+       __le16 data_offset;
+       __le16 cnt;
+       __le16 version;
+       __le16 reserved[3];
+};
+
+/**
+ * struct cmd_db_header: The DB header information
+ *
+ * @version: The cmd db version
+ * @magic: constant expected in the database
+ * @header: array of resources
+ * @checksum: checksum for the header. Unused.
+ * @reserved: reserved memory
+ * @data: driver specific data
+ */
+struct cmd_db_header {
+       __le32 version;
+       u8 magic[4];
+       struct rsc_hdr header[MAX_SLV_ID];
+       __le32 checksum;
+       __le32 reserved;
+       u8 data[];
+};
+
+/**
+ * DOC: Description of the Command DB database.
+ *
+ * At the start of the command DB memory is the cmd_db_header structure.
+ * The cmd_db_header holds the version, checksum, magic key as well as an
+ * array for header for each slave (depicted by the rsc_header). Each h/w
+ * based accelerator is a 'slave' (shared resource) and has slave id indicating
+ * the type of accelerator. The rsc_header is the header for such individual
+ * slaves of a given type. The entries for each of these slaves begin at the
+ * rsc_hdr.header_offset. In addition each slave could have auxiliary data
+ * that may be needed by the driver. The data for the slave starts at the
+ * entry_header.offset to the location pointed to by the rsc_hdr.data_offset.
+ *
+ * Drivers have a stringified key to a slave/resource. They can query the slave
+ * information and get the slave id and the auxiliary data and the length of the
+ * data. Using this information, they can format the request to be sent to the
+ * h/w accelerator and request a resource state.
+ */
+
+static const u8 CMD_DB_MAGIC[] = { 0xdb, 0x30, 0x03, 0x0c };
+
+static bool cmd_db_magic_matches(const struct cmd_db_header *header)
+{
+       const u8 *magic = header->magic;
+
+       return memcmp(magic, CMD_DB_MAGIC, ARRAY_SIZE(CMD_DB_MAGIC)) == 0;
+}
+
+static struct cmd_db_header *cmd_db_header;
+
+
+static inline void *rsc_to_entry_header(struct rsc_hdr *hdr)
+{
+       u16 offset = le16_to_cpu(hdr->header_offset);
+
+       return cmd_db_header->data + offset;
+}
+
+static inline void *
+rsc_offset(struct rsc_hdr *hdr, struct entry_header *ent)
+{
+       u16 offset = le16_to_cpu(hdr->data_offset);
+       u16 loffset = le16_to_cpu(ent->offset);
+
+       return cmd_db_header->data + offset + loffset;
+}
+
+/**
+ * cmd_db_ready - Indicates if command DB is available
+ *
+ * Return: 0 on success, errno otherwise
+ */
+int cmd_db_ready(void)
+{
+       if (cmd_db_header == NULL)
+               return -EPROBE_DEFER;
+       else if (!cmd_db_magic_matches(cmd_db_header))
+               return -EINVAL;
+
+       return 0;
+}
+EXPORT_SYMBOL(cmd_db_ready);
+
+static int cmd_db_get_header(const char *id, struct entry_header *eh,
+                            struct rsc_hdr *rh)
+{
+       struct rsc_hdr *rsc_hdr;
+       struct entry_header *ent;
+       int ret, i, j;
+       u8 query[8];
+
+       ret = cmd_db_ready();
+       if (ret)
+               return ret;
+
+       if (!eh || !rh)
+               return -EINVAL;
+
+       /* Pad out query string to same length as in DB */
+       strncpy(query, id, sizeof(query));
+
+       for (i = 0; i < MAX_SLV_ID; i++) {
+               rsc_hdr = &cmd_db_header->header[i];
+               if (!rsc_hdr->slv_id)
+                       break;
+
+               ent = rsc_to_entry_header(rsc_hdr);
+               for (j = 0; j < le16_to_cpu(rsc_hdr->cnt); j++, ent++) {
+                       if (memcmp(ent->id, query, sizeof(ent->id)) == 0)
+                               break;
+               }
+
+               if (j < le16_to_cpu(rsc_hdr->cnt)) {
+                       memcpy(eh, ent, sizeof(*ent));
+                       memcpy(rh, rsc_hdr, sizeof(*rh));
+                       return 0;
+               }
+       }
+
+       return -ENODEV;
+}
+
+/**
+ * cmd_db_read_addr() - Query command db for resource id address.
+ *
+ * @id: resource id to query for address
+ *
+ * Return: resource address on success, 0 on error
+ *
+ * This is used to retrieve resource address based on resource
+ * id.
+ */
+u32 cmd_db_read_addr(const char *id)
+{
+       int ret;
+       struct entry_header ent;
+       struct rsc_hdr rsc_hdr;
+
+       ret = cmd_db_get_header(id, &ent, &rsc_hdr);
+
+       return ret < 0 ? 0 : le32_to_cpu(ent.addr);
+}
+EXPORT_SYMBOL(cmd_db_read_addr);
+
+/**
+ * cmd_db_read_aux_data() - Query command db for aux data.
+ *
+ *  @id: Resource to retrieve AUX Data on.
+ *  @data: Data buffer to copy returned aux data to. Returns size on NULL
+ *  @len: Caller provides size of data buffer passed in.
+ *
+ *  Return: size of data on success, errno otherwise
+ */
+int cmd_db_read_aux_data(const char *id, u8 *data, size_t len)
+{
+       int ret;
+       struct entry_header ent;
+       struct rsc_hdr rsc_hdr;
+       u16 ent_len;
+
+       if (!data)
+               return -EINVAL;
+
+       ret = cmd_db_get_header(id, &ent, &rsc_hdr);
+       if (ret)
+               return ret;
+
+       ent_len = le16_to_cpu(ent.len);
+       if (len < ent_len)
+               return -EINVAL;
+
+       len = min_t(u16, ent_len, len);
+       memcpy(data, rsc_offset(&rsc_hdr, &ent), len);
+
+       return len;
+}
+EXPORT_SYMBOL(cmd_db_read_aux_data);
+
+/**
+ * cmd_db_read_aux_data_len - Get the length of the auxiliary data stored in DB.
+ *
+ * @id: Resource to retrieve AUX Data.
+ *
+ * Return: size on success, 0 on error
+ */
+size_t cmd_db_read_aux_data_len(const char *id)
+{
+       int ret;
+       struct entry_header ent;
+       struct rsc_hdr rsc_hdr;
+
+       ret = cmd_db_get_header(id, &ent, &rsc_hdr);
+
+       return ret < 0 ? 0 : le16_to_cpu(ent.len);
+}
+EXPORT_SYMBOL(cmd_db_read_aux_data_len);
+
+/**
+ * cmd_db_read_slave_id - Get the slave ID for a given resource address
+ *
+ * @id: Resource id to query the DB for version
+ *
+ * Return: cmd_db_hw_type enum on success, CMD_DB_HW_INVALID on error
+ */
+enum cmd_db_hw_type cmd_db_read_slave_id(const char *id)
+{
+       int ret;
+       struct entry_header ent;
+       struct rsc_hdr rsc_hdr;
+       u32 addr;
+
+       ret = cmd_db_get_header(id, &ent, &rsc_hdr);
+       if (ret < 0)
+               return CMD_DB_HW_INVALID;
+
+       addr = le32_to_cpu(ent.addr);
+       return (addr >> SLAVE_ID_SHIFT) & SLAVE_ID_MASK;
+}
+EXPORT_SYMBOL(cmd_db_read_slave_id);
+
+static int cmd_db_dev_probe(struct platform_device *pdev)
+{
+       struct reserved_mem *rmem;
+       int ret = 0;
+
+       rmem = of_reserved_mem_lookup(pdev->dev.of_node);
+       if (!rmem) {
+               dev_err(&pdev->dev, "failed to acquire memory region\n");
+               return -EINVAL;
+       }
+
+       cmd_db_header = memremap(rmem->base, rmem->size, MEMREMAP_WB);
+       if (IS_ERR_OR_NULL(cmd_db_header)) {
+               ret = PTR_ERR(cmd_db_header);
+               cmd_db_header = NULL;
+               return ret;
+       }
+
+       if (!cmd_db_magic_matches(cmd_db_header)) {
+               dev_err(&pdev->dev, "Invalid Command DB Magic\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
+static const struct of_device_id cmd_db_match_table[] = {
+       { .compatible = "qcom,cmd-db" },
+       { },
+};
+
+static struct platform_driver cmd_db_dev_driver = {
+       .probe  = cmd_db_dev_probe,
+       .driver = {
+                  .name = "cmd-db",
+                  .of_match_table = cmd_db_match_table,
+       },
+};
+
+static int __init cmd_db_device_init(void)
+{
+       return platform_driver_register(&cmd_db_dev_driver);
+}
+arch_initcall(cmd_db_device_init);
index 17b314d9a148cb24bf252be3d76ee835c53c4dda..dc09d7ac905fff805bedb073e2a4e79529f88032 100644 (file)
@@ -50,7 +50,7 @@ ssize_t qcom_mdt_get_size(const struct firmware *fw)
        const struct elf32_phdr *phdrs;
        const struct elf32_phdr *phdr;
        const struct elf32_hdr *ehdr;
-       phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX;
+       phys_addr_t min_addr = PHYS_ADDR_MAX;
        phys_addr_t max_addr = 0;
        int i;
 
@@ -97,7 +97,7 @@ int qcom_mdt_load(struct device *dev, const struct firmware *fw,
        const struct elf32_hdr *ehdr;
        const struct firmware *seg_fw;
        phys_addr_t mem_reloc;
-       phys_addr_t min_addr = (phys_addr_t)ULLONG_MAX;
+       phys_addr_t min_addr = PHYS_ADDR_MAX;
        phys_addr_t max_addr = 0;
        size_t fw_name_len;
        ssize_t offset;
diff --git a/drivers/soc/qcom/qcom-geni-se.c b/drivers/soc/qcom/qcom-geni-se.c
new file mode 100644 (file)
index 0000000..feed3db
--- /dev/null
@@ -0,0 +1,748 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+
+#include <linux/clk.h>
+#include <linux/slab.h>
+#include <linux/dma-mapping.h>
+#include <linux/io.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_platform.h>
+#include <linux/pinctrl/consumer.h>
+#include <linux/platform_device.h>
+#include <linux/qcom-geni-se.h>
+
+/**
+ * DOC: Overview
+ *
+ * Generic Interface (GENI) Serial Engine (SE) Wrapper driver is introduced
+ * to manage GENI firmware based Qualcomm Universal Peripheral (QUP) Wrapper
+ * controller. QUP Wrapper is designed to support various serial bus protocols
+ * like UART, SPI, I2C, I3C, etc.
+ */
+
+/**
+ * DOC: Hardware description
+ *
+ * GENI based QUP is a highly-flexible and programmable module for supporting
+ * a wide range of serial interfaces like UART, SPI, I2C, I3C, etc. A single
+ * QUP module can provide upto 8 serial interfaces, using its internal
+ * serial engines. The actual configuration is determined by the target
+ * platform configuration. The protocol supported by each interface is
+ * determined by the firmware loaded to the serial engine. Each SE consists
+ * of a DMA Engine and GENI sub modules which enable serial engines to
+ * support FIFO and DMA modes of operation.
+ *
+ *
+ *                      +-----------------------------------------+
+ *                      |QUP Wrapper                              |
+ *                      |         +----------------------------+  |
+ *   --QUP & SE Clocks-->         | Serial Engine N            |  +-IO------>
+ *                      |         | ...                        |  | Interface
+ *   <---Clock Perf.----+    +----+-----------------------+    |  |
+ *     State Interface  |    | Serial Engine 1            |    |  |
+ *                      |    |                            |    |  |
+ *                      |    |                            |    |  |
+ *   <--------AHB------->    |                            |    |  |
+ *                      |    |                            +----+  |
+ *                      |    |                            |       |
+ *                      |    |                            |       |
+ *   <------SE IRQ------+    +----------------------------+       |
+ *                      |                                         |
+ *                      +-----------------------------------------+
+ *
+ *                         Figure 1: GENI based QUP Wrapper
+ *
+ * The GENI submodules include primary and secondary sequencers which are
+ * used to drive TX & RX operations. On serial interfaces that operate using
+ * master-slave model, primary sequencer drives both TX & RX operations. On
+ * serial interfaces that operate using peer-to-peer model, primary sequencer
+ * drives TX operation and secondary sequencer drives RX operation.
+ */
+
+/**
+ * DOC: Software description
+ *
+ * GENI SE Wrapper driver is structured into 2 parts:
+ *
+ * geni_wrapper represents QUP Wrapper controller. This part of the driver
+ * manages QUP Wrapper information such as hardware version, clock
+ * performance table that is common to all the internal serial engines.
+ *
+ * geni_se represents serial engine. This part of the driver manages serial
+ * engine information such as clocks, containing QUP Wrapper, etc. This part
+ * of driver also supports operations (eg. initialize the concerned serial
+ * engine, select between FIFO and DMA mode of operation etc.) that are
+ * common to all the serial engines and are independent of serial interfaces.
+ */
+
+#define MAX_CLK_PERF_LEVEL 32
+#define NUM_AHB_CLKS 2
+
+/**
+ * @struct geni_wrapper - Data structure to represent the QUP Wrapper Core
+ * @dev:               Device pointer of the QUP wrapper core
+ * @base:              Base address of this instance of QUP wrapper core
+ * @ahb_clks:          Handle to the primary & secondary AHB clocks
+ */
+struct geni_wrapper {
+       struct device *dev;
+       void __iomem *base;
+       struct clk_bulk_data ahb_clks[NUM_AHB_CLKS];
+};
+
+#define QUP_HW_VER_REG                 0x4
+
+/* Common SE registers */
+#define GENI_INIT_CFG_REVISION         0x0
+#define GENI_S_INIT_CFG_REVISION       0x4
+#define GENI_OUTPUT_CTRL               0x24
+#define GENI_CGC_CTRL                  0x28
+#define GENI_CLK_CTRL_RO               0x60
+#define GENI_IF_DISABLE_RO             0x64
+#define GENI_FW_S_REVISION_RO          0x6c
+#define SE_GENI_BYTE_GRAN              0x254
+#define SE_GENI_TX_PACKING_CFG0                0x260
+#define SE_GENI_TX_PACKING_CFG1                0x264
+#define SE_GENI_RX_PACKING_CFG0                0x284
+#define SE_GENI_RX_PACKING_CFG1                0x288
+#define SE_GENI_M_GP_LENGTH            0x910
+#define SE_GENI_S_GP_LENGTH            0x914
+#define SE_DMA_TX_PTR_L                        0xc30
+#define SE_DMA_TX_PTR_H                        0xc34
+#define SE_DMA_TX_ATTR                 0xc38
+#define SE_DMA_TX_LEN                  0xc3c
+#define SE_DMA_TX_IRQ_EN               0xc48
+#define SE_DMA_TX_IRQ_EN_SET           0xc4c
+#define SE_DMA_TX_IRQ_EN_CLR           0xc50
+#define SE_DMA_TX_LEN_IN               0xc54
+#define SE_DMA_TX_MAX_BURST            0xc5c
+#define SE_DMA_RX_PTR_L                        0xd30
+#define SE_DMA_RX_PTR_H                        0xd34
+#define SE_DMA_RX_ATTR                 0xd38
+#define SE_DMA_RX_LEN                  0xd3c
+#define SE_DMA_RX_IRQ_EN               0xd48
+#define SE_DMA_RX_IRQ_EN_SET           0xd4c
+#define SE_DMA_RX_IRQ_EN_CLR           0xd50
+#define SE_DMA_RX_LEN_IN               0xd54
+#define SE_DMA_RX_MAX_BURST            0xd5c
+#define SE_DMA_RX_FLUSH                        0xd60
+#define SE_GSI_EVENT_EN                        0xe18
+#define SE_IRQ_EN                      0xe1c
+#define SE_DMA_GENERAL_CFG             0xe30
+
+/* GENI_OUTPUT_CTRL fields */
+#define DEFAULT_IO_OUTPUT_CTRL_MSK     GENMASK(6, 0)
+
+/* GENI_CGC_CTRL fields */
+#define CFG_AHB_CLK_CGC_ON             BIT(0)
+#define CFG_AHB_WR_ACLK_CGC_ON         BIT(1)
+#define DATA_AHB_CLK_CGC_ON            BIT(2)
+#define SCLK_CGC_ON                    BIT(3)
+#define TX_CLK_CGC_ON                  BIT(4)
+#define RX_CLK_CGC_ON                  BIT(5)
+#define EXT_CLK_CGC_ON                 BIT(6)
+#define PROG_RAM_HCLK_OFF              BIT(8)
+#define PROG_RAM_SCLK_OFF              BIT(9)
+#define DEFAULT_CGC_EN                 GENMASK(6, 0)
+
+/* SE_GSI_EVENT_EN fields */
+#define DMA_RX_EVENT_EN                        BIT(0)
+#define DMA_TX_EVENT_EN                        BIT(1)
+#define GENI_M_EVENT_EN                        BIT(2)
+#define GENI_S_EVENT_EN                        BIT(3)
+
+/* SE_IRQ_EN fields */
+#define DMA_RX_IRQ_EN                  BIT(0)
+#define DMA_TX_IRQ_EN                  BIT(1)
+#define GENI_M_IRQ_EN                  BIT(2)
+#define GENI_S_IRQ_EN                  BIT(3)
+
+/* SE_DMA_GENERAL_CFG */
+#define DMA_RX_CLK_CGC_ON              BIT(0)
+#define DMA_TX_CLK_CGC_ON              BIT(1)
+#define DMA_AHB_SLV_CFG_ON             BIT(2)
+#define AHB_SEC_SLV_CLK_CGC_ON         BIT(3)
+#define DUMMY_RX_NON_BUFFERABLE                BIT(4)
+#define RX_DMA_ZERO_PADDING_EN         BIT(5)
+#define RX_DMA_IRQ_DELAY_MSK           GENMASK(8, 6)
+#define RX_DMA_IRQ_DELAY_SHFT          6
+
+/**
+ * geni_se_get_qup_hw_version() - Read the QUP wrapper Hardware version
+ * @se:        Pointer to the corresponding serial engine.
+ *
+ * Return: Hardware Version of the wrapper.
+ */
+u32 geni_se_get_qup_hw_version(struct geni_se *se)
+{
+       struct geni_wrapper *wrapper = se->wrapper;
+
+       return readl_relaxed(wrapper->base + QUP_HW_VER_REG);
+}
+EXPORT_SYMBOL(geni_se_get_qup_hw_version);
+
+static void geni_se_io_set_mode(void __iomem *base)
+{
+       u32 val;
+
+       val = readl_relaxed(base + SE_IRQ_EN);
+       val |= GENI_M_IRQ_EN | GENI_S_IRQ_EN;
+       val |= DMA_TX_IRQ_EN | DMA_RX_IRQ_EN;
+       writel_relaxed(val, base + SE_IRQ_EN);
+
+       val = readl_relaxed(base + SE_GENI_DMA_MODE_EN);
+       val &= ~GENI_DMA_MODE_EN;
+       writel_relaxed(val, base + SE_GENI_DMA_MODE_EN);
+
+       writel_relaxed(0, base + SE_GSI_EVENT_EN);
+}
+
+static void geni_se_io_init(void __iomem *base)
+{
+       u32 val;
+
+       val = readl_relaxed(base + GENI_CGC_CTRL);
+       val |= DEFAULT_CGC_EN;
+       writel_relaxed(val, base + GENI_CGC_CTRL);
+
+       val = readl_relaxed(base + SE_DMA_GENERAL_CFG);
+       val |= AHB_SEC_SLV_CLK_CGC_ON | DMA_AHB_SLV_CFG_ON;
+       val |= DMA_TX_CLK_CGC_ON | DMA_RX_CLK_CGC_ON;
+       writel_relaxed(val, base + SE_DMA_GENERAL_CFG);
+
+       writel_relaxed(DEFAULT_IO_OUTPUT_CTRL_MSK, base + GENI_OUTPUT_CTRL);
+       writel_relaxed(FORCE_DEFAULT, base + GENI_FORCE_DEFAULT_REG);
+}
+
+/**
+ * geni_se_init() - Initialize the GENI serial engine
+ * @se:                Pointer to the concerned serial engine.
+ * @rx_wm:     Receive watermark, in units of FIFO words.
+ * @rx_rfr_wm: Ready-for-receive watermark, in units of FIFO words.
+ *
+ * This function is used to initialize the GENI serial engine, configure
+ * receive watermark and ready-for-receive watermarks.
+ */
+void geni_se_init(struct geni_se *se, u32 rx_wm, u32 rx_rfr)
+{
+       u32 val;
+
+       geni_se_io_init(se->base);
+       geni_se_io_set_mode(se->base);
+
+       writel_relaxed(rx_wm, se->base + SE_GENI_RX_WATERMARK_REG);
+       writel_relaxed(rx_rfr, se->base + SE_GENI_RX_RFR_WATERMARK_REG);
+
+       val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN);
+       val |= M_COMMON_GENI_M_IRQ_EN;
+       writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN);
+
+       val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN);
+       val |= S_COMMON_GENI_S_IRQ_EN;
+       writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN);
+}
+EXPORT_SYMBOL(geni_se_init);
+
+static void geni_se_select_fifo_mode(struct geni_se *se)
+{
+       u32 proto = geni_se_read_proto(se);
+       u32 val;
+
+       writel_relaxed(0, se->base + SE_GSI_EVENT_EN);
+       writel_relaxed(0xffffffff, se->base + SE_GENI_M_IRQ_CLEAR);
+       writel_relaxed(0xffffffff, se->base + SE_GENI_S_IRQ_CLEAR);
+       writel_relaxed(0xffffffff, se->base + SE_DMA_TX_IRQ_CLR);
+       writel_relaxed(0xffffffff, se->base + SE_DMA_RX_IRQ_CLR);
+       writel_relaxed(0xffffffff, se->base + SE_IRQ_EN);
+
+       val = readl_relaxed(se->base + SE_GENI_M_IRQ_EN);
+       if (proto != GENI_SE_UART) {
+               val |= M_CMD_DONE_EN | M_TX_FIFO_WATERMARK_EN;
+               val |= M_RX_FIFO_WATERMARK_EN | M_RX_FIFO_LAST_EN;
+       }
+       writel_relaxed(val, se->base + SE_GENI_M_IRQ_EN);
+
+       val = readl_relaxed(se->base + SE_GENI_S_IRQ_EN);
+       if (proto != GENI_SE_UART)
+               val |= S_CMD_DONE_EN;
+       writel_relaxed(val, se->base + SE_GENI_S_IRQ_EN);
+
+       val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN);
+       val &= ~GENI_DMA_MODE_EN;
+       writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN);
+}
+
+static void geni_se_select_dma_mode(struct geni_se *se)
+{
+       u32 val;
+
+       writel_relaxed(0, se->base + SE_GSI_EVENT_EN);
+       writel_relaxed(0xffffffff, se->base + SE_GENI_M_IRQ_CLEAR);
+       writel_relaxed(0xffffffff, se->base + SE_GENI_S_IRQ_CLEAR);
+       writel_relaxed(0xffffffff, se->base + SE_DMA_TX_IRQ_CLR);
+       writel_relaxed(0xffffffff, se->base + SE_DMA_RX_IRQ_CLR);
+       writel_relaxed(0xffffffff, se->base + SE_IRQ_EN);
+
+       val = readl_relaxed(se->base + SE_GENI_DMA_MODE_EN);
+       val |= GENI_DMA_MODE_EN;
+       writel_relaxed(val, se->base + SE_GENI_DMA_MODE_EN);
+}
+
+/**
+ * geni_se_select_mode() - Select the serial engine transfer mode
+ * @se:                Pointer to the concerned serial engine.
+ * @mode:      Transfer mode to be selected.
+ */
+void geni_se_select_mode(struct geni_se *se, enum geni_se_xfer_mode mode)
+{
+       WARN_ON(mode != GENI_SE_FIFO && mode != GENI_SE_DMA);
+
+       switch (mode) {
+       case GENI_SE_FIFO:
+               geni_se_select_fifo_mode(se);
+               break;
+       case GENI_SE_DMA:
+               geni_se_select_dma_mode(se);
+               break;
+       case GENI_SE_INVALID:
+       default:
+               break;
+       }
+}
+EXPORT_SYMBOL(geni_se_select_mode);
+
+/**
+ * DOC: Overview
+ *
+ * GENI FIFO packing is highly configurable. TX/RX packing/unpacking consist
+ * of up to 4 operations, each operation represented by 4 configuration vectors
+ * of 10 bits programmed in GENI_TX_PACKING_CFG0 and GENI_TX_PACKING_CFG1 for
+ * TX FIFO and in GENI_RX_PACKING_CFG0 and GENI_RX_PACKING_CFG1 for RX FIFO.
+ * Refer to below examples for detailed bit-field description.
+ *
+ * Example 1: word_size = 7, packing_mode = 4 x 8, msb_to_lsb = 1
+ *
+ *        +-----------+-------+-------+-------+-------+
+ *        |           | vec_0 | vec_1 | vec_2 | vec_3 |
+ *        +-----------+-------+-------+-------+-------+
+ *        | start     | 0x6   | 0xe   | 0x16  | 0x1e  |
+ *        | direction | 1     | 1     | 1     | 1     |
+ *        | length    | 6     | 6     | 6     | 6     |
+ *        | stop      | 0     | 0     | 0     | 1     |
+ *        +-----------+-------+-------+-------+-------+
+ *
+ * Example 2: word_size = 15, packing_mode = 2 x 16, msb_to_lsb = 0
+ *
+ *        +-----------+-------+-------+-------+-------+
+ *        |           | vec_0 | vec_1 | vec_2 | vec_3 |
+ *        +-----------+-------+-------+-------+-------+
+ *        | start     | 0x0   | 0x8   | 0x10  | 0x18  |
+ *        | direction | 0     | 0     | 0     | 0     |
+ *        | length    | 7     | 6     | 7     | 6     |
+ *        | stop      | 0     | 0     | 0     | 1     |
+ *        +-----------+-------+-------+-------+-------+
+ *
+ * Example 3: word_size = 23, packing_mode = 1 x 32, msb_to_lsb = 1
+ *
+ *        +-----------+-------+-------+-------+-------+
+ *        |           | vec_0 | vec_1 | vec_2 | vec_3 |
+ *        +-----------+-------+-------+-------+-------+
+ *        | start     | 0x16  | 0xe   | 0x6   | 0x0   |
+ *        | direction | 1     | 1     | 1     | 1     |
+ *        | length    | 7     | 7     | 6     | 0     |
+ *        | stop      | 0     | 0     | 1     | 0     |
+ *        +-----------+-------+-------+-------+-------+
+ *
+ */
+
+#define NUM_PACKING_VECTORS 4
+#define PACKING_START_SHIFT 5
+#define PACKING_DIR_SHIFT 4
+#define PACKING_LEN_SHIFT 1
+#define PACKING_STOP_BIT BIT(0)
+#define PACKING_VECTOR_SHIFT 10
+/**
+ * geni_se_config_packing() - Packing configuration of the serial engine
+ * @se:                Pointer to the concerned serial engine
+ * @bpw:       Bits of data per transfer word.
+ * @pack_words:        Number of words per fifo element.
+ * @msb_to_lsb:        Transfer from MSB to LSB or vice-versa.
+ * @tx_cfg:    Flag to configure the TX Packing.
+ * @rx_cfg:    Flag to configure the RX Packing.
+ *
+ * This function is used to configure the packing rules for the current
+ * transfer.
+ */
+void geni_se_config_packing(struct geni_se *se, int bpw, int pack_words,
+                           bool msb_to_lsb, bool tx_cfg, bool rx_cfg)
+{
+       u32 cfg0, cfg1, cfg[NUM_PACKING_VECTORS] = {0};
+       int len;
+       int temp_bpw = bpw;
+       int idx_start = msb_to_lsb ? bpw - 1 : 0;
+       int idx = idx_start;
+       int idx_delta = msb_to_lsb ? -BITS_PER_BYTE : BITS_PER_BYTE;
+       int ceil_bpw = ALIGN(bpw, BITS_PER_BYTE);
+       int iter = (ceil_bpw * pack_words) / BITS_PER_BYTE;
+       int i;
+
+       if (iter <= 0 || iter > NUM_PACKING_VECTORS)
+               return;
+
+       for (i = 0; i < iter; i++) {
+               len = min_t(int, temp_bpw, BITS_PER_BYTE) - 1;
+               cfg[i] = idx << PACKING_START_SHIFT;
+               cfg[i] |= msb_to_lsb << PACKING_DIR_SHIFT;
+               cfg[i] |= len << PACKING_LEN_SHIFT;
+
+               if (temp_bpw <= BITS_PER_BYTE) {
+                       idx = ((i + 1) * BITS_PER_BYTE) + idx_start;
+                       temp_bpw = bpw;
+               } else {
+                       idx = idx + idx_delta;
+                       temp_bpw = temp_bpw - BITS_PER_BYTE;
+               }
+       }
+       cfg[iter - 1] |= PACKING_STOP_BIT;
+       cfg0 = cfg[0] | (cfg[1] << PACKING_VECTOR_SHIFT);
+       cfg1 = cfg[2] | (cfg[3] << PACKING_VECTOR_SHIFT);
+
+       if (tx_cfg) {
+               writel_relaxed(cfg0, se->base + SE_GENI_TX_PACKING_CFG0);
+               writel_relaxed(cfg1, se->base + SE_GENI_TX_PACKING_CFG1);
+       }
+       if (rx_cfg) {
+               writel_relaxed(cfg0, se->base + SE_GENI_RX_PACKING_CFG0);
+               writel_relaxed(cfg1, se->base + SE_GENI_RX_PACKING_CFG1);
+       }
+
+       /*
+        * Number of protocol words in each FIFO entry
+        * 0 - 4x8, four words in each entry, max word size of 8 bits
+        * 1 - 2x16, two words in each entry, max word size of 16 bits
+        * 2 - 1x32, one word in each entry, max word size of 32 bits
+        * 3 - undefined
+        */
+       if (pack_words || bpw == 32)
+               writel_relaxed(bpw / 16, se->base + SE_GENI_BYTE_GRAN);
+}
+EXPORT_SYMBOL(geni_se_config_packing);
+
+static void geni_se_clks_off(struct geni_se *se)
+{
+       struct geni_wrapper *wrapper = se->wrapper;
+
+       clk_disable_unprepare(se->clk);
+       clk_bulk_disable_unprepare(ARRAY_SIZE(wrapper->ahb_clks),
+                                               wrapper->ahb_clks);
+}
+
+/**
+ * geni_se_resources_off() - Turn off resources associated with the serial
+ *                           engine
+ * @se:        Pointer to the concerned serial engine.
+ *
+ * Return: 0 on success, standard Linux error codes on failure/error.
+ */
+int geni_se_resources_off(struct geni_se *se)
+{
+       int ret;
+
+       ret = pinctrl_pm_select_sleep_state(se->dev);
+       if (ret)
+               return ret;
+
+       geni_se_clks_off(se);
+       return 0;
+}
+EXPORT_SYMBOL(geni_se_resources_off);
+
+static int geni_se_clks_on(struct geni_se *se)
+{
+       int ret;
+       struct geni_wrapper *wrapper = se->wrapper;
+
+       ret = clk_bulk_prepare_enable(ARRAY_SIZE(wrapper->ahb_clks),
+                                               wrapper->ahb_clks);
+       if (ret)
+               return ret;
+
+       ret = clk_prepare_enable(se->clk);
+       if (ret)
+               clk_bulk_disable_unprepare(ARRAY_SIZE(wrapper->ahb_clks),
+                                                       wrapper->ahb_clks);
+       return ret;
+}
+
+/**
+ * geni_se_resources_on() - Turn on resources associated with the serial
+ *                          engine
+ * @se:        Pointer to the concerned serial engine.
+ *
+ * Return: 0 on success, standard Linux error codes on failure/error.
+ */
+int geni_se_resources_on(struct geni_se *se)
+{
+       int ret;
+
+       ret = geni_se_clks_on(se);
+       if (ret)
+               return ret;
+
+       ret = pinctrl_pm_select_default_state(se->dev);
+       if (ret)
+               geni_se_clks_off(se);
+
+       return ret;
+}
+EXPORT_SYMBOL(geni_se_resources_on);
+
+/**
+ * geni_se_clk_tbl_get() - Get the clock table to program DFS
+ * @se:                Pointer to the concerned serial engine.
+ * @tbl:       Table in which the output is returned.
+ *
+ * This function is called by the protocol drivers to determine the different
+ * clock frequencies supported by serial engine core clock. The protocol
+ * drivers use the output to determine the clock frequency index to be
+ * programmed into DFS.
+ *
+ * Return: number of valid performance levels in the table on success,
+ *        standard Linux error codes on failure.
+ */
+int geni_se_clk_tbl_get(struct geni_se *se, unsigned long **tbl)
+{
+       unsigned long freq = 0;
+       int i;
+
+       if (se->clk_perf_tbl) {
+               *tbl = se->clk_perf_tbl;
+               return se->num_clk_levels;
+       }
+
+       se->clk_perf_tbl = devm_kcalloc(se->dev, MAX_CLK_PERF_LEVEL,
+                                       sizeof(*se->clk_perf_tbl),
+                                       GFP_KERNEL);
+       if (!se->clk_perf_tbl)
+               return -ENOMEM;
+
+       for (i = 0; i < MAX_CLK_PERF_LEVEL; i++) {
+               freq = clk_round_rate(se->clk, freq + 1);
+               if (!freq || freq == se->clk_perf_tbl[i - 1])
+                       break;
+               se->clk_perf_tbl[i] = freq;
+       }
+       se->num_clk_levels = i;
+       *tbl = se->clk_perf_tbl;
+       return se->num_clk_levels;
+}
+EXPORT_SYMBOL(geni_se_clk_tbl_get);
+
+/**
+ * geni_se_clk_freq_match() - Get the matching or closest SE clock frequency
+ * @se:                Pointer to the concerned serial engine.
+ * @req_freq:  Requested clock frequency.
+ * @index:     Index of the resultant frequency in the table.
+ * @res_freq:  Resultant frequency which matches or is closer to the
+ *             requested frequency.
+ * @exact:     Flag to indicate exact multiple requirement of the requested
+ *             frequency.
+ *
+ * This function is called by the protocol drivers to determine the matching
+ * or exact multiple of the requested frequency, as provided by the serial
+ * engine clock in order to meet the performance requirements. If there is
+ * no matching or exact multiple of the requested frequency found, then it
+ * selects the closest floor frequency, if exact flag is not set.
+ *
+ * Return: 0 on success, standard Linux error codes on failure.
+ */
+int geni_se_clk_freq_match(struct geni_se *se, unsigned long req_freq,
+                          unsigned int *index, unsigned long *res_freq,
+                          bool exact)
+{
+       unsigned long *tbl;
+       int num_clk_levels;
+       int i;
+
+       num_clk_levels = geni_se_clk_tbl_get(se, &tbl);
+       if (num_clk_levels < 0)
+               return num_clk_levels;
+
+       if (num_clk_levels == 0)
+               return -EINVAL;
+
+       *res_freq = 0;
+       for (i = 0; i < num_clk_levels; i++) {
+               if (!(tbl[i] % req_freq)) {
+                       *index = i;
+                       *res_freq = tbl[i];
+                       return 0;
+               }
+
+               if (!(*res_freq) || ((tbl[i] > *res_freq) &&
+                                    (tbl[i] < req_freq))) {
+                       *index = i;
+                       *res_freq = tbl[i];
+               }
+       }
+
+       if (exact)
+               return -EINVAL;
+
+       return 0;
+}
+EXPORT_SYMBOL(geni_se_clk_freq_match);
+
+#define GENI_SE_DMA_DONE_EN BIT(0)
+#define GENI_SE_DMA_EOT_EN BIT(1)
+#define GENI_SE_DMA_AHB_ERR_EN BIT(2)
+#define GENI_SE_DMA_EOT_BUF BIT(0)
+/**
+ * geni_se_tx_dma_prep() - Prepare the serial engine for TX DMA transfer
+ * @se:                        Pointer to the concerned serial engine.
+ * @buf:               Pointer to the TX buffer.
+ * @len:               Length of the TX buffer.
+ * @iova:              Pointer to store the mapped DMA address.
+ *
+ * This function is used to prepare the buffers for DMA TX.
+ *
+ * Return: 0 on success, standard Linux error codes on failure.
+ */
+int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len,
+                       dma_addr_t *iova)
+{
+       struct geni_wrapper *wrapper = se->wrapper;
+       u32 val;
+
+       *iova = dma_map_single(wrapper->dev, buf, len, DMA_TO_DEVICE);
+       if (dma_mapping_error(wrapper->dev, *iova))
+               return -EIO;
+
+       val = GENI_SE_DMA_DONE_EN;
+       val |= GENI_SE_DMA_EOT_EN;
+       val |= GENI_SE_DMA_AHB_ERR_EN;
+       writel_relaxed(val, se->base + SE_DMA_TX_IRQ_EN_SET);
+       writel_relaxed(lower_32_bits(*iova), se->base + SE_DMA_TX_PTR_L);
+       writel_relaxed(upper_32_bits(*iova), se->base + SE_DMA_TX_PTR_H);
+       writel_relaxed(GENI_SE_DMA_EOT_BUF, se->base + SE_DMA_TX_ATTR);
+       writel_relaxed(len, se->base + SE_DMA_TX_LEN);
+       return 0;
+}
+EXPORT_SYMBOL(geni_se_tx_dma_prep);
+
+/**
+ * geni_se_rx_dma_prep() - Prepare the serial engine for RX DMA transfer
+ * @se:                        Pointer to the concerned serial engine.
+ * @buf:               Pointer to the RX buffer.
+ * @len:               Length of the RX buffer.
+ * @iova:              Pointer to store the mapped DMA address.
+ *
+ * This function is used to prepare the buffers for DMA RX.
+ *
+ * Return: 0 on success, standard Linux error codes on failure.
+ */
+int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len,
+                       dma_addr_t *iova)
+{
+       struct geni_wrapper *wrapper = se->wrapper;
+       u32 val;
+
+       *iova = dma_map_single(wrapper->dev, buf, len, DMA_FROM_DEVICE);
+       if (dma_mapping_error(wrapper->dev, *iova))
+               return -EIO;
+
+       val = GENI_SE_DMA_DONE_EN;
+       val |= GENI_SE_DMA_EOT_EN;
+       val |= GENI_SE_DMA_AHB_ERR_EN;
+       writel_relaxed(val, se->base + SE_DMA_RX_IRQ_EN_SET);
+       writel_relaxed(lower_32_bits(*iova), se->base + SE_DMA_RX_PTR_L);
+       writel_relaxed(upper_32_bits(*iova), se->base + SE_DMA_RX_PTR_H);
+       /* RX does not have EOT buffer type bit. So just reset RX_ATTR */
+       writel_relaxed(0, se->base + SE_DMA_RX_ATTR);
+       writel_relaxed(len, se->base + SE_DMA_RX_LEN);
+       return 0;
+}
+EXPORT_SYMBOL(geni_se_rx_dma_prep);
+
+/**
+ * geni_se_tx_dma_unprep() - Unprepare the serial engine after TX DMA transfer
+ * @se:                        Pointer to the concerned serial engine.
+ * @iova:              DMA address of the TX buffer.
+ * @len:               Length of the TX buffer.
+ *
+ * This function is used to unprepare the DMA buffers after DMA TX.
+ */
+void geni_se_tx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len)
+{
+       struct geni_wrapper *wrapper = se->wrapper;
+
+       if (iova && !dma_mapping_error(wrapper->dev, iova))
+               dma_unmap_single(wrapper->dev, iova, len, DMA_TO_DEVICE);
+}
+EXPORT_SYMBOL(geni_se_tx_dma_unprep);
+
+/**
+ * geni_se_rx_dma_unprep() - Unprepare the serial engine after RX DMA transfer
+ * @se:                        Pointer to the concerned serial engine.
+ * @iova:              DMA address of the RX buffer.
+ * @len:               Length of the RX buffer.
+ *
+ * This function is used to unprepare the DMA buffers after DMA RX.
+ */
+void geni_se_rx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len)
+{
+       struct geni_wrapper *wrapper = se->wrapper;
+
+       if (iova && !dma_mapping_error(wrapper->dev, iova))
+               dma_unmap_single(wrapper->dev, iova, len, DMA_FROM_DEVICE);
+}
+EXPORT_SYMBOL(geni_se_rx_dma_unprep);
+
+static int geni_se_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct resource *res;
+       struct geni_wrapper *wrapper;
+       int ret;
+
+       wrapper = devm_kzalloc(dev, sizeof(*wrapper), GFP_KERNEL);
+       if (!wrapper)
+               return -ENOMEM;
+
+       wrapper->dev = dev;
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+       wrapper->base = devm_ioremap_resource(dev, res);
+       if (IS_ERR(wrapper->base))
+               return PTR_ERR(wrapper->base);
+
+       wrapper->ahb_clks[0].id = "m-ahb";
+       wrapper->ahb_clks[1].id = "s-ahb";
+       ret = devm_clk_bulk_get(dev, NUM_AHB_CLKS, wrapper->ahb_clks);
+       if (ret) {
+               dev_err(dev, "Err getting AHB clks %d\n", ret);
+               return ret;
+       }
+
+       dev_set_drvdata(dev, wrapper);
+       dev_dbg(dev, "GENI SE Driver probed\n");
+       return devm_of_platform_populate(dev);
+}
+
+static const struct of_device_id geni_se_dt_match[] = {
+       { .compatible = "qcom,geni-se-qup", },
+       {}
+};
+MODULE_DEVICE_TABLE(of, geni_se_dt_match);
+
+static struct platform_driver geni_se_driver = {
+       .driver = {
+               .name = "geni_se_qup",
+               .of_match_table = geni_se_dt_match,
+       },
+       .probe = geni_se_probe,
+};
+module_platform_driver(geni_se_driver);
+
+MODULE_DESCRIPTION("GENI Serial Engine Driver");
+MODULE_LICENSE("GPL v2");
index 321982277697552402c3d07ed77dd5b8a9c6e523..938ca41c56cdc794cd7bbc25409e8350668f0295 100644 (file)
@@ -639,10 +639,11 @@ int qmi_handle_init(struct qmi_handle *qmi, size_t recv_buf_size,
        if (ops)
                qmi->ops = *ops;
 
+       /* Make room for the header */
+       recv_buf_size += sizeof(struct qmi_header);
+       /* Must also be sufficient to hold a control packet */
        if (recv_buf_size < sizeof(struct qrtr_ctrl_pkt))
                recv_buf_size = sizeof(struct qrtr_ctrl_pkt);
-       else
-               recv_buf_size += sizeof(struct qmi_header);
 
        qmi->recv_buf_size = recv_buf_size;
        qmi->recv_buf = kzalloc(recv_buf_size, GFP_KERNEL);
index c2346752b3eaacdc64fb30bfefd2a53bc05add83..93517ed833558cd6962443ea9d085bc776f75c0d 100644 (file)
@@ -226,6 +226,7 @@ static const struct of_device_id qcom_smd_rpm_of_match[] = {
        { .compatible = "qcom,rpm-msm8916" },
        { .compatible = "qcom,rpm-msm8974" },
        { .compatible = "qcom,rpm-msm8996" },
+       { .compatible = "qcom,rpm-msm8998" },
        {}
 };
 MODULE_DEVICE_TABLE(of, qcom_smd_rpm_of_match);
index 0b94d62fad2bf8632c57e31a9b3bbf3ab971d11a..70b2ee80d6bdfab8f0cb960143b83d127eee3ba2 100644 (file)
@@ -280,7 +280,7 @@ struct qcom_smem {
        struct smem_region regions[0];
 };
 
-static struct smem_private_entry *
+static void *
 phdr_to_last_uncached_entry(struct smem_partition_header *phdr)
 {
        void *p = phdr;
@@ -288,15 +288,18 @@ phdr_to_last_uncached_entry(struct smem_partition_header *phdr)
        return p + le32_to_cpu(phdr->offset_free_uncached);
 }
 
-static void *phdr_to_first_cached_entry(struct smem_partition_header *phdr,
+static struct smem_private_entry *
+phdr_to_first_cached_entry(struct smem_partition_header *phdr,
                                        size_t cacheline)
 {
        void *p = phdr;
+       struct smem_private_entry *e;
 
-       return p + le32_to_cpu(phdr->size) - ALIGN(sizeof(*phdr), cacheline);
+       return p + le32_to_cpu(phdr->size) - ALIGN(sizeof(*e), cacheline);
 }
 
-static void *phdr_to_last_cached_entry(struct smem_partition_header *phdr)
+static void *
+phdr_to_last_cached_entry(struct smem_partition_header *phdr)
 {
        void *p = phdr;
 
@@ -361,14 +364,14 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem,
        end = phdr_to_last_uncached_entry(phdr);
        cached = phdr_to_last_cached_entry(phdr);
 
-       while (hdr < end) {
-               if (hdr->canary != SMEM_PRIVATE_CANARY) {
-                       dev_err(smem->dev,
-                               "Found invalid canary in hosts %d:%d partition\n",
-                               phdr->host0, phdr->host1);
-                       return -EINVAL;
-               }
+       if (smem->global_partition) {
+               dev_err(smem->dev, "Already found the global partition\n");
+               return -EINVAL;
+       }
 
+       while (hdr < end) {
+               if (hdr->canary != SMEM_PRIVATE_CANARY)
+                       goto bad_canary;
                if (le16_to_cpu(hdr->item) == item)
                        return -EEXIST;
 
@@ -377,7 +380,7 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem,
 
        /* Check that we don't grow into the cached region */
        alloc_size = sizeof(*hdr) + ALIGN(size, 8);
-       if ((void *)hdr + alloc_size >= cached) {
+       if ((void *)hdr + alloc_size > cached) {
                dev_err(smem->dev, "Out of memory\n");
                return -ENOSPC;
        }
@@ -397,6 +400,11 @@ static int qcom_smem_alloc_private(struct qcom_smem *smem,
        le32_add_cpu(&phdr->offset_free_uncached, alloc_size);
 
        return 0;
+bad_canary:
+       dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n",
+               le16_to_cpu(phdr->host0), le16_to_cpu(phdr->host1));
+
+       return -EINVAL;
 }
 
 static int qcom_smem_alloc_global(struct qcom_smem *smem,
@@ -560,8 +568,8 @@ static void *qcom_smem_get_private(struct qcom_smem *smem,
        return ERR_PTR(-ENOENT);
 
 invalid_canary:
-       dev_err(smem->dev, "Found invalid canary in hosts %d:%d partition\n",
-                       phdr->host0, phdr->host1);
+       dev_err(smem->dev, "Found invalid canary in hosts %hu:%hu partition\n",
+                       le16_to_cpu(phdr->host0), le16_to_cpu(phdr->host1));
 
        return ERR_PTR(-EINVAL);
 }
@@ -647,6 +655,33 @@ int qcom_smem_get_free_space(unsigned host)
 }
 EXPORT_SYMBOL(qcom_smem_get_free_space);
 
+/**
+ * qcom_smem_virt_to_phys() - return the physical address associated
+ * with an smem item pointer (previously returned by qcom_smem_get()
+ * @p: the virtual address to convert
+ *
+ * Returns 0 if the pointer provided is not within any smem region.
+ */
+phys_addr_t qcom_smem_virt_to_phys(void *p)
+{
+       unsigned i;
+
+       for (i = 0; i < __smem->num_regions; i++) {
+               struct smem_region *region = &__smem->regions[i];
+
+               if (p < region->virt_base)
+                       continue;
+               if (p < region->virt_base + region->size) {
+                       u64 offset = p - region->virt_base;
+
+                       return (phys_addr_t)region->aux_base + offset;
+               }
+       }
+
+       return 0;
+}
+EXPORT_SYMBOL(qcom_smem_virt_to_phys);
+
 static int qcom_smem_get_sbl_version(struct qcom_smem *smem)
 {
        struct smem_header *header;
@@ -695,9 +730,10 @@ static u32 qcom_smem_get_item_count(struct qcom_smem *smem)
 static int qcom_smem_set_global_partition(struct qcom_smem *smem)
 {
        struct smem_partition_header *header;
-       struct smem_ptable_entry *entry = NULL;
+       struct smem_ptable_entry *entry;
        struct smem_ptable *ptable;
        u32 host0, host1, size;
+       bool found = false;
        int i;
 
        ptable = qcom_smem_get_ptable(smem);
@@ -709,11 +745,13 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem)
                host0 = le16_to_cpu(entry->host0);
                host1 = le16_to_cpu(entry->host1);
 
-               if (host0 == SMEM_GLOBAL_HOST && host0 == host1)
+               if (host0 == SMEM_GLOBAL_HOST && host0 == host1) {
+                       found = true;
                        break;
+               }
        }
 
-       if (!entry) {
+       if (!found) {
                dev_err(smem->dev, "Missing entry for global partition\n");
                return -EINVAL;
        }
@@ -723,11 +761,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem)
                return -EINVAL;
        }
 
-       if (smem->global_partition) {
-               dev_err(smem->dev, "Already found the global partition\n");
-               return -EINVAL;
-       }
-
        header = smem->regions[0].virt_base + le32_to_cpu(entry->offset);
        host0 = le16_to_cpu(header->host0);
        host1 = le16_to_cpu(header->host1);
index 3bbe6114a42028d14d8bd87bdca87f46cee681b1..1d824cbd462dc2eaf875b3572e07e282e0ee2614 100644 (file)
@@ -4,9 +4,11 @@ config SOC_RENESAS
        select SOC_BUS
        select RST_RCAR if ARCH_RCAR_GEN1 || ARCH_RCAR_GEN2 || \
                           ARCH_R8A7795 || ARCH_R8A7796 || ARCH_R8A77965 || \
-                          ARCH_R8A77970 || ARCH_R8A77980 || ARCH_R8A77995
+                          ARCH_R8A77970 || ARCH_R8A77980 || ARCH_R8A77990 || \
+                          ARCH_R8A77995
        select SYSC_R8A7743 if ARCH_R8A7743
        select SYSC_R8A7745 if ARCH_R8A7745
+       select SYSC_R8A77470 if ARCH_R8A77470
        select SYSC_R8A7779 if ARCH_R8A7779
        select SYSC_R8A7790 if ARCH_R8A7790
        select SYSC_R8A7791 if ARCH_R8A7791 || ARCH_R8A7793
@@ -17,6 +19,7 @@ config SOC_RENESAS
        select SYSC_R8A77965 if ARCH_R8A77965
        select SYSC_R8A77970 if ARCH_R8A77970
        select SYSC_R8A77980 if ARCH_R8A77980
+       select SYSC_R8A77990 if ARCH_R8A77990
        select SYSC_R8A77995 if ARCH_R8A77995
 
 if SOC_RENESAS
@@ -30,6 +33,10 @@ config SYSC_R8A7745
        bool "RZ/G1E System Controller support" if COMPILE_TEST
        select SYSC_RCAR
 
+config SYSC_R8A77470
+       bool "RZ/G1C System Controller support" if COMPILE_TEST
+       select SYSC_RCAR
+
 config SYSC_R8A7779
        bool "R-Car H1 System Controller support" if COMPILE_TEST
        select SYSC_RCAR
@@ -70,6 +77,10 @@ config SYSC_R8A77980
        bool "R-Car V3H System Controller support" if COMPILE_TEST
        select SYSC_RCAR
 
+config SYSC_R8A77990
+       bool "R-Car E3 System Controller support" if COMPILE_TEST
+       select SYSC_RCAR
+
 config SYSC_R8A77995
        bool "R-Car D3 System Controller support" if COMPILE_TEST
        select SYSC_RCAR
index ccb5ec57a262f962e731bad381231aaeff8cd724..7dc0f20d79079be51ca7e07ff278b7650360c0ab 100644 (file)
@@ -5,6 +5,7 @@ obj-$(CONFIG_SOC_RENESAS)       += renesas-soc.o
 # SoC
 obj-$(CONFIG_SYSC_R8A7743)     += r8a7743-sysc.o
 obj-$(CONFIG_SYSC_R8A7745)     += r8a7745-sysc.o
+obj-$(CONFIG_SYSC_R8A77470)    += r8a77470-sysc.o
 obj-$(CONFIG_SYSC_R8A7779)     += r8a7779-sysc.o
 obj-$(CONFIG_SYSC_R8A7790)     += r8a7790-sysc.o
 obj-$(CONFIG_SYSC_R8A7791)     += r8a7791-sysc.o
@@ -15,6 +16,7 @@ obj-$(CONFIG_SYSC_R8A7796)    += r8a7796-sysc.o
 obj-$(CONFIG_SYSC_R8A77965)    += r8a77965-sysc.o
 obj-$(CONFIG_SYSC_R8A77970)    += r8a77970-sysc.o
 obj-$(CONFIG_SYSC_R8A77980)    += r8a77980-sysc.o
+obj-$(CONFIG_SYSC_R8A77990)    += r8a77990-sysc.o
 obj-$(CONFIG_SYSC_R8A77995)    += r8a77995-sysc.o
 
 # Family
diff --git a/drivers/soc/renesas/r8a77470-sysc.c b/drivers/soc/renesas/r8a77470-sysc.c
new file mode 100644 (file)
index 0000000..cfa015e
--- /dev/null
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Renesas RZ/G1C System Controller
+ *
+ * Copyright (C) 2018 Renesas Electronics Corp.
+ */
+
+#include <linux/bug.h>
+#include <linux/kernel.h>
+
+#include <dt-bindings/power/r8a77470-sysc.h>
+
+#include "rcar-sysc.h"
+
+static const struct rcar_sysc_area r8a77470_areas[] __initconst = {
+       { "always-on",      0, 0, R8A77470_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
+       { "ca7-scu",    0x100, 0, R8A77470_PD_CA7_SCU,  R8A77470_PD_ALWAYS_ON,
+         PD_SCU },
+       { "ca7-cpu0",   0x1c0, 0, R8A77470_PD_CA7_CPU0, R8A77470_PD_CA7_SCU,
+         PD_CPU_NOCR },
+       { "ca7-cpu1",   0x1c0, 1, R8A77470_PD_CA7_CPU1, R8A77470_PD_CA7_SCU,
+         PD_CPU_NOCR },
+       { "sgx",         0xc0, 0, R8A77470_PD_SGX, R8A77470_PD_ALWAYS_ON },
+};
+
+const struct rcar_sysc_info r8a77470_sysc_info __initconst = {
+       .areas = r8a77470_areas,
+       .num_areas = ARRAY_SIZE(r8a77470_areas),
+};
diff --git a/drivers/soc/renesas/r8a77990-sysc.c b/drivers/soc/renesas/r8a77990-sysc.c
new file mode 100644 (file)
index 0000000..15579eb
--- /dev/null
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Renesas R-Car E3 System Controller
+ *
+ * Copyright (C) 2018 Renesas Electronics Corp.
+ */
+
+#include <linux/bug.h>
+#include <linux/kernel.h>
+#include <linux/sys_soc.h>
+
+#include <dt-bindings/power/r8a77990-sysc.h>
+
+#include "rcar-sysc.h"
+
+static struct rcar_sysc_area r8a77990_areas[] __initdata = {
+       { "always-on",      0, 0, R8A77990_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
+       { "ca53-scu",   0x140, 0, R8A77990_PD_CA53_SCU,  R8A77990_PD_ALWAYS_ON,
+         PD_SCU },
+       { "ca53-cpu0",  0x200, 0, R8A77990_PD_CA53_CPU0, R8A77990_PD_CA53_SCU,
+         PD_CPU_NOCR },
+       { "ca53-cpu1",  0x200, 1, R8A77990_PD_CA53_CPU1, R8A77990_PD_CA53_SCU,
+         PD_CPU_NOCR },
+       { "cr7",        0x240, 0, R8A77990_PD_CR7,      R8A77990_PD_ALWAYS_ON },
+       { "a3vc",       0x380, 0, R8A77990_PD_A3VC,     R8A77990_PD_ALWAYS_ON },
+       { "a2vc1",      0x3c0, 1, R8A77990_PD_A2VC1,    R8A77990_PD_A3VC },
+       { "3dg-a",      0x100, 0, R8A77990_PD_3DG_A,    R8A77990_PD_ALWAYS_ON },
+       { "3dg-b",      0x100, 1, R8A77990_PD_3DG_B,    R8A77990_PD_3DG_A },
+};
+
+static void __init rcar_sysc_fix_parent(struct rcar_sysc_area *areas,
+                                       unsigned int num_areas, u8 id,
+                                       int new_parent)
+{
+       unsigned int i;
+
+       for (i = 0; i < num_areas; i++)
+               if (areas[i].isr_bit == id) {
+                       areas[i].parent = new_parent;
+                       return;
+               }
+}
+
+/* Fixups for R-Car E3 ES1.0 revision */
+static const struct soc_device_attribute r8a77990[] __initconst = {
+       { .soc_id = "r8a77990", .revision = "ES1.0" },
+       { /* sentinel */ }
+};
+
+static int __init r8a77990_sysc_init(void)
+{
+       if (soc_device_match(r8a77990)) {
+               rcar_sysc_fix_parent(r8a77990_areas,
+                                    ARRAY_SIZE(r8a77990_areas),
+                                    R8A77990_PD_3DG_A, R8A77990_PD_3DG_B);
+               rcar_sysc_fix_parent(r8a77990_areas,
+                                    ARRAY_SIZE(r8a77990_areas),
+                                    R8A77990_PD_3DG_B, R8A77990_PD_ALWAYS_ON);
+       }
+
+       return 0;
+}
+
+const struct rcar_sysc_info r8a77990_sysc_info __initconst = {
+       .init = r8a77990_sysc_init,
+       .areas = r8a77990_areas,
+       .num_areas = ARRAY_SIZE(r8a77990_areas),
+};
index f718429cab02393d6454befb30df24393e0b30be..1b2ef415bbe1cbf7f6adccdf36a52abce3ad22e4 100644 (file)
 
 #include <linux/bug.h>
 #include <linux/kernel.h>
-#include <linux/sys_soc.h>
 
 #include <dt-bindings/power/r8a77995-sysc.h>
 
 #include "rcar-sysc.h"
 
-static struct rcar_sysc_area r8a77995_areas[] __initdata = {
+static const struct rcar_sysc_area r8a77995_areas[] __initconst = {
        { "always-on",     0, 0, R8A77995_PD_ALWAYS_ON, -1, PD_ALWAYS_ON },
        { "ca53-scu",  0x140, 0, R8A77995_PD_CA53_SCU,  R8A77995_PD_ALWAYS_ON,
          PD_SCU },
index 8e9cb7996ab06c01218f4709c1f9290946295e15..d9c1034e70e94d05d4557d98535aeac873aa51a4 100644 (file)
@@ -44,6 +44,7 @@ static const struct of_device_id rcar_rst_matches[] __initconst = {
        /* RZ/G is handled like R-Car Gen2 */
        { .compatible = "renesas,r8a7743-rst", .data = &rcar_rst_gen2 },
        { .compatible = "renesas,r8a7745-rst", .data = &rcar_rst_gen2 },
+       { .compatible = "renesas,r8a77470-rst", .data = &rcar_rst_gen2 },
        /* R-Car Gen1 */
        { .compatible = "renesas,r8a7778-reset-wdt", .data = &rcar_rst_gen1 },
        { .compatible = "renesas,r8a7779-reset-wdt", .data = &rcar_rst_gen1 },
@@ -59,6 +60,7 @@ static const struct of_device_id rcar_rst_matches[] __initconst = {
        { .compatible = "renesas,r8a77965-rst", .data = &rcar_rst_gen3 },
        { .compatible = "renesas,r8a77970-rst", .data = &rcar_rst_gen3 },
        { .compatible = "renesas,r8a77980-rst", .data = &rcar_rst_gen3 },
+       { .compatible = "renesas,r8a77990-rst", .data = &rcar_rst_gen3 },
        { .compatible = "renesas,r8a77995-rst", .data = &rcar_rst_gen3 },
        { /* sentinel */ }
 };
index faf20e71936179170a315e4035ade8dda99ca00c..95120acc4d806da630f49737cca1eede3286edae 100644 (file)
@@ -261,6 +261,9 @@ static const struct of_device_id rcar_sysc_matches[] __initconst = {
 #ifdef CONFIG_SYSC_R8A7745
        { .compatible = "renesas,r8a7745-sysc", .data = &r8a7745_sysc_info },
 #endif
+#ifdef CONFIG_SYSC_R8A77470
+       { .compatible = "renesas,r8a77470-sysc", .data = &r8a77470_sysc_info },
+#endif
 #ifdef CONFIG_SYSC_R8A7779
        { .compatible = "renesas,r8a7779-sysc", .data = &r8a7779_sysc_info },
 #endif
@@ -293,6 +296,9 @@ static const struct of_device_id rcar_sysc_matches[] __initconst = {
 #ifdef CONFIG_SYSC_R8A77980
        { .compatible = "renesas,r8a77980-sysc", .data = &r8a77980_sysc_info },
 #endif
+#ifdef CONFIG_SYSC_R8A77990
+       { .compatible = "renesas,r8a77990-sysc", .data = &r8a77990_sysc_info },
+#endif
 #ifdef CONFIG_SYSC_R8A77995
        { .compatible = "renesas,r8a77995-sysc", .data = &r8a77995_sysc_info },
 #endif
index dcdc9ec8eba79dbf21459089a2bebf3133b4d638..a22e7cf25e309bb5a4700b4b840c83d240804798 100644 (file)
@@ -51,6 +51,7 @@ struct rcar_sysc_info {
 
 extern const struct rcar_sysc_info r8a7743_sysc_info;
 extern const struct rcar_sysc_info r8a7745_sysc_info;
+extern const struct rcar_sysc_info r8a77470_sysc_info;
 extern const struct rcar_sysc_info r8a7779_sysc_info;
 extern const struct rcar_sysc_info r8a7790_sysc_info;
 extern const struct rcar_sysc_info r8a7791_sysc_info;
@@ -61,6 +62,7 @@ extern const struct rcar_sysc_info r8a7796_sysc_info;
 extern const struct rcar_sysc_info r8a77965_sysc_info;
 extern const struct rcar_sysc_info r8a77970_sysc_info;
 extern const struct rcar_sysc_info r8a77980_sysc_info;
+extern const struct rcar_sysc_info r8a77990_sysc_info;
 extern const struct rcar_sysc_info r8a77995_sysc_info;
 
 
index ea71c413c9267d94adabe1f3465c0c4cee53b089..d44d0e687ab8adb3bdcf97537d5ac97aade5c6c6 100644 (file)
@@ -100,6 +100,11 @@ static const struct renesas_soc soc_rz_g1e __initconst __maybe_unused = {
        .id     = 0x4c,
 };
 
+static const struct renesas_soc soc_rz_g1c __initconst __maybe_unused = {
+       .family = &fam_rzg,
+       .id     = 0x53,
+};
+
 static const struct renesas_soc soc_rcar_m1a __initconst __maybe_unused = {
        .family = &fam_rcar_gen1,
 };
@@ -159,6 +164,11 @@ static const struct renesas_soc soc_rcar_v3h __initconst __maybe_unused = {
        .id     = 0x56,
 };
 
+static const struct renesas_soc soc_rcar_e3 __initconst __maybe_unused = {
+       .family = &fam_rcar_gen3,
+       .id     = 0x57,
+};
+
 static const struct renesas_soc soc_rcar_d3 __initconst __maybe_unused = {
        .family = &fam_rcar_gen3,
        .id     = 0x58,
@@ -192,6 +202,9 @@ static const struct of_device_id renesas_socs[] __initconst = {
 #ifdef CONFIG_ARCH_R8A7745
        { .compatible = "renesas,r8a7745",      .data = &soc_rz_g1e },
 #endif
+#ifdef CONFIG_ARCH_R8A77470
+       { .compatible = "renesas,r8a77470",     .data = &soc_rz_g1c },
+#endif
 #ifdef CONFIG_ARCH_R8A7778
        { .compatible = "renesas,r8a7778",      .data = &soc_rcar_m1a },
 #endif
@@ -228,6 +241,9 @@ static const struct of_device_id renesas_socs[] __initconst = {
 #ifdef CONFIG_ARCH_R8A77980
        { .compatible = "renesas,r8a77980",     .data = &soc_rcar_v3h },
 #endif
+#ifdef CONFIG_ARCH_R8A77990
+       { .compatible = "renesas,r8a77990",     .data = &soc_rcar_e3 },
+#endif
 #ifdef CONFIG_ARCH_R8A77995
        { .compatible = "renesas,r8a77995",     .data = &soc_rcar_d3 },
 #endif
index f874baaf934cb9050f03b51c1a75ac50c54f3e3c..6dff8682155f98c69143b912037ff7a0187d49c0 100644 (file)
 #include <linux/clk.h>
 #include <linux/regmap.h>
 #include <linux/mfd/syscon.h>
+#include <dt-bindings/power/px30-power.h>
+#include <dt-bindings/power/rk3036-power.h>
+#include <dt-bindings/power/rk3128-power.h>
+#include <dt-bindings/power/rk3228-power.h>
 #include <dt-bindings/power/rk3288-power.h>
 #include <dt-bindings/power/rk3328-power.h>
 #include <dt-bindings/power/rk3366-power.h>
@@ -104,6 +108,18 @@ struct rockchip_pmu {
        .active_wakeup = wakeup,                        \
 }
 
+#define DOMAIN_RK3036(req, ack, idle, wakeup)          \
+{                                                      \
+       .req_mask = (req >= 0) ? BIT(req) : 0,          \
+       .req_w_mask = (req >= 0) ?  BIT(req + 16) : 0,  \
+       .ack_mask = (ack >= 0) ? BIT(ack) : 0,          \
+       .idle_mask = (idle >= 0) ? BIT(idle) : 0,       \
+       .active_wakeup = wakeup,                        \
+}
+
+#define DOMAIN_PX30(pwr, status, req, wakeup)          \
+       DOMAIN_M(pwr, status, req, (req) + 16, req, wakeup)
+
 #define DOMAIN_RK3288(pwr, status, req, wakeup)                \
        DOMAIN(pwr, status, req, req, (req) + 16, wakeup)
 
@@ -256,7 +272,7 @@ static void rockchip_do_pmu_set_power_domain(struct rockchip_pm_domain *pd,
                return;
        else if (pd->info->pwr_w_mask)
                regmap_write(pmu->regmap, pmu->info->pwr_offset,
-                            on ? pd->info->pwr_mask :
+                            on ? pd->info->pwr_w_mask :
                             (pd->info->pwr_mask | pd->info->pwr_w_mask));
        else
                regmap_update_bits(pmu->regmap, pmu->info->pwr_offset,
@@ -700,6 +716,49 @@ static int rockchip_pm_domain_probe(struct platform_device *pdev)
        return error;
 }
 
+static const struct rockchip_domain_info px30_pm_domains[] = {
+       [PX30_PD_USB]           = DOMAIN_PX30(5, 5, 10, false),
+       [PX30_PD_SDCARD]        = DOMAIN_PX30(8, 8, 9, false),
+       [PX30_PD_GMAC]          = DOMAIN_PX30(10, 10, 6, false),
+       [PX30_PD_MMC_NAND]      = DOMAIN_PX30(11, 11, 5, false),
+       [PX30_PD_VPU]           = DOMAIN_PX30(12, 12, 14, false),
+       [PX30_PD_VO]            = DOMAIN_PX30(13, 13, 7, false),
+       [PX30_PD_VI]            = DOMAIN_PX30(14, 14, 8, false),
+       [PX30_PD_GPU]           = DOMAIN_PX30(15, 15, 2, false),
+};
+
+static const struct rockchip_domain_info rk3036_pm_domains[] = {
+       [RK3036_PD_MSCH]        = DOMAIN_RK3036(14, 23, 30, true),
+       [RK3036_PD_CORE]        = DOMAIN_RK3036(13, 17, 24, false),
+       [RK3036_PD_PERI]        = DOMAIN_RK3036(12, 18, 25, false),
+       [RK3036_PD_VIO]         = DOMAIN_RK3036(11, 19, 26, false),
+       [RK3036_PD_VPU]         = DOMAIN_RK3036(10, 20, 27, false),
+       [RK3036_PD_GPU]         = DOMAIN_RK3036(9, 21, 28, false),
+       [RK3036_PD_SYS]         = DOMAIN_RK3036(8, 22, 29, false),
+};
+
+static const struct rockchip_domain_info rk3128_pm_domains[] = {
+       [RK3128_PD_CORE]        = DOMAIN_RK3288(0, 0, 4, false),
+       [RK3128_PD_MSCH]        = DOMAIN_RK3288(-1, -1, 6, true),
+       [RK3128_PD_VIO]         = DOMAIN_RK3288(3, 3, 2, false),
+       [RK3128_PD_VIDEO]       = DOMAIN_RK3288(2, 2, 1, false),
+       [RK3128_PD_GPU]         = DOMAIN_RK3288(1, 1, 3, false),
+};
+
+static const struct rockchip_domain_info rk3228_pm_domains[] = {
+       [RK3228_PD_CORE]        = DOMAIN_RK3036(0, 0, 16, true),
+       [RK3228_PD_MSCH]        = DOMAIN_RK3036(1, 1, 17, true),
+       [RK3228_PD_BUS]         = DOMAIN_RK3036(2, 2, 18, true),
+       [RK3228_PD_SYS]         = DOMAIN_RK3036(3, 3, 19, true),
+       [RK3228_PD_VIO]         = DOMAIN_RK3036(4, 4, 20, false),
+       [RK3228_PD_VOP]         = DOMAIN_RK3036(5, 5, 21, false),
+       [RK3228_PD_VPU]         = DOMAIN_RK3036(6, 6, 22, false),
+       [RK3228_PD_RKVDEC]      = DOMAIN_RK3036(7, 7, 23, false),
+       [RK3228_PD_GPU]         = DOMAIN_RK3036(8, 8, 24, false),
+       [RK3228_PD_PERI]        = DOMAIN_RK3036(9, 9, 25, true),
+       [RK3228_PD_GMAC]        = DOMAIN_RK3036(10, 10, 26, false),
+};
+
 static const struct rockchip_domain_info rk3288_pm_domains[] = {
        [RK3288_PD_VIO]         = DOMAIN_RK3288(7, 7, 4, false),
        [RK3288_PD_HEVC]        = DOMAIN_RK3288(14, 10, 9, false),
@@ -767,6 +826,46 @@ static const struct rockchip_domain_info rk3399_pm_domains[] = {
        [RK3399_PD_SDIOAUDIO]   = DOMAIN_RK3399(31, 31, 29, true),
 };
 
+static const struct rockchip_pmu_info px30_pmu = {
+       .pwr_offset = 0x18,
+       .status_offset = 0x20,
+       .req_offset = 0x64,
+       .idle_offset = 0x6c,
+       .ack_offset = 0x6c,
+
+       .num_domains = ARRAY_SIZE(px30_pm_domains),
+       .domain_info = px30_pm_domains,
+};
+
+static const struct rockchip_pmu_info rk3036_pmu = {
+       .req_offset = 0x148,
+       .idle_offset = 0x14c,
+       .ack_offset = 0x14c,
+
+       .num_domains = ARRAY_SIZE(rk3036_pm_domains),
+       .domain_info = rk3036_pm_domains,
+};
+
+static const struct rockchip_pmu_info rk3128_pmu = {
+       .pwr_offset = 0x04,
+       .status_offset = 0x08,
+       .req_offset = 0x0c,
+       .idle_offset = 0x10,
+       .ack_offset = 0x10,
+
+       .num_domains = ARRAY_SIZE(rk3128_pm_domains),
+       .domain_info = rk3128_pm_domains,
+};
+
+static const struct rockchip_pmu_info rk3228_pmu = {
+       .req_offset = 0x40c,
+       .idle_offset = 0x488,
+       .ack_offset = 0x488,
+
+       .num_domains = ARRAY_SIZE(rk3228_pm_domains),
+       .domain_info = rk3228_pm_domains,
+};
+
 static const struct rockchip_pmu_info rk3288_pmu = {
        .pwr_offset = 0x08,
        .status_offset = 0x0c,
@@ -841,6 +940,22 @@ static const struct rockchip_pmu_info rk3399_pmu = {
 };
 
 static const struct of_device_id rockchip_pm_domain_dt_match[] = {
+       {
+               .compatible = "rockchip,px30-power-controller",
+               .data = (void *)&px30_pmu,
+       },
+       {
+               .compatible = "rockchip,rk3036-power-controller",
+               .data = (void *)&rk3036_pmu,
+       },
+       {
+               .compatible = "rockchip,rk3128-power-controller",
+               .data = (void *)&rk3128_pmu,
+       },
+       {
+               .compatible = "rockchip,rk3228-power-controller",
+               .data = (void *)&rk3228_pmu,
+       },
        {
                .compatible = "rockchip,rk3288-power-controller",
                .data = (void *)&rk3288_pmu,
index caf45cf7aa8e638925cc5ad3c10e21d0b2071bd8..ab8582971bfca7f507872a8a6d390746cdfa2f68 100644 (file)
 #include <linux/err.h>
 #include <linux/slab.h>
 #include <linux/pm_domain.h>
-#include <linux/clk.h>
 #include <linux/delay.h>
 #include <linux/of_address.h>
 #include <linux/of_platform.h>
 #include <linux/sched.h>
 
-#define MAX_CLK_PER_DOMAIN     4
-
 struct exynos_pm_domain_config {
        /* Value for LOCAL_PWR_CFG and STATUS fields for each domain */
        u32 local_pwr_cfg;
@@ -33,10 +30,6 @@ struct exynos_pm_domain {
        void __iomem *base;
        bool is_off;
        struct generic_pm_domain pd;
-       struct clk *oscclk;
-       struct clk *clk[MAX_CLK_PER_DOMAIN];
-       struct clk *pclk[MAX_CLK_PER_DOMAIN];
-       struct clk *asb_clk[MAX_CLK_PER_DOMAIN];
        u32 local_pwr_cfg;
 };
 
@@ -46,29 +39,10 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
        void __iomem *base;
        u32 timeout, pwr;
        char *op;
-       int i;
 
        pd = container_of(domain, struct exynos_pm_domain, pd);
        base = pd->base;
 
-       for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
-               if (IS_ERR(pd->asb_clk[i]))
-                       break;
-               clk_prepare_enable(pd->asb_clk[i]);
-       }
-
-       /* Set oscclk before powering off a domain*/
-       if (!power_on) {
-               for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
-                       if (IS_ERR(pd->clk[i]))
-                               break;
-                       pd->pclk[i] = clk_get_parent(pd->clk[i]);
-                       if (clk_set_parent(pd->clk[i], pd->oscclk))
-                               pr_err("%s: error setting oscclk as parent to clock %d\n",
-                                               domain->name, i);
-               }
-       }
-
        pwr = power_on ? pd->local_pwr_cfg : 0;
        writel_relaxed(pwr, base);
 
@@ -86,26 +60,6 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on)
                usleep_range(80, 100);
        }
 
-       /* Restore clocks after powering on a domain*/
-       if (power_on) {
-               for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
-                       if (IS_ERR(pd->clk[i]))
-                               break;
-
-                       if (IS_ERR(pd->pclk[i]))
-                               continue; /* Skip on first power up */
-                       if (clk_set_parent(pd->clk[i], pd->pclk[i]))
-                               pr_err("%s: error setting parent to clock%d\n",
-                                               domain->name, i);
-               }
-       }
-
-       for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
-               if (IS_ERR(pd->asb_clk[i]))
-                       break;
-               clk_disable_unprepare(pd->asb_clk[i]);
-       }
-
        return 0;
 }
 
@@ -147,12 +101,6 @@ static __init const char *exynos_get_domain_name(struct device_node *node)
        return kstrdup_const(name, GFP_KERNEL);
 }
 
-static const char *soc_force_no_clk[] = {
-       "samsung,exynos5250-clock",
-       "samsung,exynos5420-clock",
-       "samsung,exynos5800-clock",
-};
-
 static __init int exynos4_pm_init_power_domain(void)
 {
        struct device_node *np;
@@ -161,7 +109,7 @@ static __init int exynos4_pm_init_power_domain(void)
        for_each_matching_node_and_match(np, exynos_pm_domain_of_match, &match) {
                const struct exynos_pm_domain_config *pm_domain_cfg;
                struct exynos_pm_domain *pd;
-               int on, i;
+               int on;
 
                pm_domain_cfg = match->data;
 
@@ -189,42 +137,6 @@ static __init int exynos4_pm_init_power_domain(void)
                pd->pd.power_on = exynos_pd_power_on;
                pd->local_pwr_cfg = pm_domain_cfg->local_pwr_cfg;
 
-               for (i = 0; i < ARRAY_SIZE(soc_force_no_clk); i++)
-                       if (of_find_compatible_node(NULL, NULL,
-                                                   soc_force_no_clk[i]))
-                               goto no_clk;
-
-               for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
-                       char clk_name[8];
-
-                       snprintf(clk_name, sizeof(clk_name), "asb%d", i);
-                       pd->asb_clk[i] = of_clk_get_by_name(np, clk_name);
-                       if (IS_ERR(pd->asb_clk[i]))
-                               break;
-               }
-
-               pd->oscclk = of_clk_get_by_name(np, "oscclk");
-               if (IS_ERR(pd->oscclk))
-                       goto no_clk;
-
-               for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) {
-                       char clk_name[8];
-
-                       snprintf(clk_name, sizeof(clk_name), "clk%d", i);
-                       pd->clk[i] = of_clk_get_by_name(np, clk_name);
-                       if (IS_ERR(pd->clk[i]))
-                               break;
-                       /*
-                        * Skip setting parent on first power up.
-                        * The parent at this time may not be useful at all.
-                        */
-                       pd->pclk[i] = ERR_PTR(-EINVAL);
-               }
-
-               if (IS_ERR(pd->clk[0]))
-                       clk_put(pd->oscclk);
-
-no_clk:
                on = readl_relaxed(pd->base + 0x4) & pd->local_pwr_cfg;
 
                pm_genpd_init(&pd->pd, NULL, !on);
index 56866ba4cfc4ae67fbe3fb78a8925de2f90dc574..3efc47e82973b43ff7431bdacad428aea757bffc 100644 (file)
@@ -19,6 +19,8 @@
 #ifndef __KNAV_QMSS_H__
 #define __KNAV_QMSS_H__
 
+#include <linux/percpu.h>
+
 #define THRESH_GTE     BIT(7)
 #define THRESH_LT      0
 
@@ -162,11 +164,11 @@ struct knav_qmgr_info {
  * notifies:                   notifier counts
  */
 struct knav_queue_stats {
-       atomic_t         pushes;
-       atomic_t         pops;
-       atomic_t         push_errors;
-       atomic_t         pop_errors;
-       atomic_t         notifies;
+       unsigned int pushes;
+       unsigned int pops;
+       unsigned int push_errors;
+       unsigned int pop_errors;
+       unsigned int notifies;
 };
 
 /**
@@ -283,7 +285,7 @@ struct knav_queue_inst {
 struct knav_queue {
        struct knav_reg_queue __iomem   *reg_push, *reg_pop, *reg_peek;
        struct knav_queue_inst          *inst;
-       struct knav_queue_stats stats;
+       struct knav_queue_stats __percpu        *stats;
        knav_queue_notify_fn            notifier_fn;
        void                            *notifier_fn_arg;
        atomic_t                        notifier_enabled;
index 3d7225f4e77fe511bc84f80f818db639fae0de2c..316e82e46f6cbff0500ba8409529dffc3d0eddbe 100644 (file)
@@ -405,8 +405,8 @@ static int knav_acc_init_queue(struct knav_range_info *range,
 {
        unsigned id = kq->id - range->queue_base;
 
-       kq->descs = devm_kzalloc(range->kdev->dev,
-                                ACC_DESCS_MAX * sizeof(u32), GFP_KERNEL);
+       kq->descs = devm_kcalloc(range->kdev->dev,
+                                ACC_DESCS_MAX, sizeof(u32), GFP_KERNEL);
        if (!kq->descs)
                return -ENOMEM;
 
@@ -552,7 +552,7 @@ int knav_init_acc_range(struct knav_device *kdev,
        info->list_size = list_size;
        mem_size   = PAGE_ALIGN(list_size * 2);
        info->mem_size  = mem_size;
-       range->acc = devm_kzalloc(kdev->dev, channels * sizeof(*range->acc),
+       range->acc = devm_kcalloc(kdev->dev, channels, sizeof(*range->acc),
                                  GFP_KERNEL);
        if (!range->acc)
                return -ENOMEM;
index 419365a8d1c2a81dd4e00faaaf9d5295195b3c46..6755f2af56195d773248ae60f8a6261c2e34ae44 100644 (file)
@@ -99,7 +99,7 @@ void knav_queue_notify(struct knav_queue_inst *inst)
                        continue;
                if (WARN_ON(!qh->notifier_fn))
                        continue;
-               atomic_inc(&qh->stats.notifies);
+               this_cpu_inc(qh->stats->notifies);
                qh->notifier_fn(qh->notifier_fn_arg);
        }
        rcu_read_unlock();
@@ -230,6 +230,12 @@ static struct knav_queue *__knav_queue_open(struct knav_queue_inst *inst,
        if (!qh)
                return ERR_PTR(-ENOMEM);
 
+       qh->stats = alloc_percpu(struct knav_queue_stats);
+       if (!qh->stats) {
+               ret = -ENOMEM;
+               goto err;
+       }
+
        qh->flags = flags;
        qh->inst = inst;
        id = inst->id - inst->qmgr->start_queue;
@@ -245,13 +251,17 @@ static struct knav_queue *__knav_queue_open(struct knav_queue_inst *inst,
                if (range->ops && range->ops->open_queue)
                        ret = range->ops->open_queue(range, inst, flags);
 
-               if (ret) {
-                       devm_kfree(inst->kdev->dev, qh);
-                       return ERR_PTR(ret);
-               }
+               if (ret)
+                       goto err;
        }
        list_add_tail_rcu(&qh->list, &inst->handles);
        return qh;
+
+err:
+       if (qh->stats)
+               free_percpu(qh->stats);
+       devm_kfree(inst->kdev->dev, qh);
+       return ERR_PTR(ret);
 }
 
 static struct knav_queue *
@@ -427,6 +437,12 @@ static void knav_queue_debug_show_instance(struct seq_file *s,
 {
        struct knav_device *kdev = inst->kdev;
        struct knav_queue *qh;
+       int cpu = 0;
+       int pushes = 0;
+       int pops = 0;
+       int push_errors = 0;
+       int pop_errors = 0;
+       int notifies = 0;
 
        if (!knav_queue_is_busy(inst))
                return;
@@ -434,19 +450,22 @@ static void knav_queue_debug_show_instance(struct seq_file *s,
        seq_printf(s, "\tqueue id %d (%s)\n",
                   kdev->base_id + inst->id, inst->name);
        for_each_handle_rcu(qh, inst) {
-               seq_printf(s, "\t\thandle %p: ", qh);
-               seq_printf(s, "pushes %8d, ",
-                          atomic_read(&qh->stats.pushes));
-               seq_printf(s, "pops %8d, ",
-                          atomic_read(&qh->stats.pops));
-               seq_printf(s, "count %8d, ",
-                          knav_queue_get_count(qh));
-               seq_printf(s, "notifies %8d, ",
-                          atomic_read(&qh->stats.notifies));
-               seq_printf(s, "push errors %8d, ",
-                          atomic_read(&qh->stats.push_errors));
-               seq_printf(s, "pop errors %8d\n",
-                          atomic_read(&qh->stats.pop_errors));
+               for_each_possible_cpu(cpu) {
+                       pushes += per_cpu_ptr(qh->stats, cpu)->pushes;
+                       pops += per_cpu_ptr(qh->stats, cpu)->pops;
+                       push_errors += per_cpu_ptr(qh->stats, cpu)->push_errors;
+                       pop_errors += per_cpu_ptr(qh->stats, cpu)->pop_errors;
+                       notifies += per_cpu_ptr(qh->stats, cpu)->notifies;
+               }
+
+               seq_printf(s, "\t\thandle %p: pushes %8d, pops %8d, count %8d, notifies %8d, push errors %8d, pop errors %8d\n",
+                               qh,
+                               pushes,
+                               pops,
+                               knav_queue_get_count(qh),
+                               notifies,
+                               push_errors,
+                               pop_errors);
        }
 }
 
@@ -563,6 +582,7 @@ void knav_queue_close(void *qhandle)
                if (range->ops && range->ops->close_queue)
                        range->ops->close_queue(range, inst);
        }
+       free_percpu(qh->stats);
        devm_kfree(inst->kdev->dev, qh);
 }
 EXPORT_SYMBOL_GPL(knav_queue_close);
@@ -636,7 +656,7 @@ int knav_queue_push(void *qhandle, dma_addr_t dma,
        val = (u32)dma | ((size / 16) - 1);
        writel_relaxed(val, &qh->reg_push[0].ptr_size_thresh);
 
-       atomic_inc(&qh->stats.pushes);
+       this_cpu_inc(qh->stats->pushes);
        return 0;
 }
 EXPORT_SYMBOL_GPL(knav_queue_push);
@@ -674,7 +694,7 @@ dma_addr_t knav_queue_pop(void *qhandle, unsigned *size)
        if (size)
                *size = ((val & DESC_SIZE_MASK) + 1) * 16;
 
-       atomic_inc(&qh->stats.pops);
+       this_cpu_inc(qh->stats->pops);
        return dma;
 }
 EXPORT_SYMBOL_GPL(knav_queue_pop);
index 8974a0fcda1bdb21872d6317ed954b1311e56ea2..4b5e250e86159f5585205498b8029d85abf39879 100644 (file)
@@ -1291,7 +1291,7 @@ static int _sdw_prepare_stream(struct sdw_stream_runtime *stream)
  *
  * @stream: Soundwire stream
  *
- * Documentation/soundwire/stream.txt explains this API in detail
+ * Documentation/driver-api/soundwire/stream.rst explains this API in detail
  */
 int sdw_prepare_stream(struct sdw_stream_runtime *stream)
 {
@@ -1348,7 +1348,7 @@ static int _sdw_enable_stream(struct sdw_stream_runtime *stream)
  *
  * @stream: Soundwire stream
  *
- * Documentation/soundwire/stream.txt explains this API in detail
+ * Documentation/driver-api/soundwire/stream.rst explains this API in detail
  */
 int sdw_enable_stream(struct sdw_stream_runtime *stream)
 {
@@ -1400,7 +1400,7 @@ static int _sdw_disable_stream(struct sdw_stream_runtime *stream)
  *
  * @stream: Soundwire stream
  *
- * Documentation/soundwire/stream.txt explains this API in detail
+ * Documentation/driver-api/soundwire/stream.rst explains this API in detail
  */
 int sdw_disable_stream(struct sdw_stream_runtime *stream)
 {
@@ -1456,7 +1456,7 @@ static int _sdw_deprepare_stream(struct sdw_stream_runtime *stream)
  *
  * @stream: Soundwire stream
  *
- * Documentation/soundwire/stream.txt explains this API in detail
+ * Documentation/driver-api/soundwire/stream.rst explains this API in detail
  */
 int sdw_deprepare_stream(struct sdw_stream_runtime *stream)
 {
index 60d59b003aa4339752c97e5c27ba11d15f4d4390..577084bb911bad7292f0ea4bcbbf7d0b1b9e35ba 100644 (file)
@@ -923,9 +923,10 @@ static int davinci_spi_probe(struct platform_device *pdev)
        /* pdata in dspi is now updated and point pdata to that */
        pdata = &dspi->pdata;
 
-       dspi->bytes_per_word = devm_kzalloc(&pdev->dev,
-                                           sizeof(*dspi->bytes_per_word) *
-                                           pdata->num_chipselect, GFP_KERNEL);
+       dspi->bytes_per_word = devm_kcalloc(&pdev->dev,
+                                           pdata->num_chipselect,
+                                           sizeof(*dspi->bytes_per_word),
+                                           GFP_KERNEL);
        if (dspi->bytes_per_word == NULL) {
                ret = -ENOMEM;
                goto free_master;
index e5cc07357746afd20c55c75ae3a407d35c2d14d0..f1526757aaf6da88d7be55aaa7ae70c6c3579c2d 100644 (file)
@@ -671,8 +671,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev)
        master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
 
        master->num_chipselect = info->num_chipselect;
-       master->cs_gpios = devm_kzalloc(&master->dev,
-                                       sizeof(int) * master->num_chipselect,
+       master->cs_gpios = devm_kcalloc(&master->dev,
+                                       master->num_chipselect, sizeof(int),
                                        GFP_KERNEL);
        if (!master->cs_gpios) {
                error = -ENOMEM;
index b85a93cad44a1ecb117a4c9bcae161bc109a23c6..6ae92d4dca19d6201c5f2ddd4e552f4d639bbce2 100644 (file)
@@ -373,8 +373,9 @@ static int spi_gpio_probe(struct platform_device *pdev)
 
        spi_gpio = spi_master_get_devdata(master);
 
-       spi_gpio->cs_gpios = devm_kzalloc(&pdev->dev,
-                               pdata->num_chipselect * sizeof(*spi_gpio->cs_gpios),
+       spi_gpio->cs_gpios = devm_kcalloc(&pdev->dev,
+                               pdata->num_chipselect,
+                               sizeof(*spi_gpio->cs_gpios),
                                GFP_KERNEL);
        if (!spi_gpio->cs_gpios)
                return -ENOMEM;
index 866246f2104102ff82e01eab3caaacf13ced4ffc..d3b21faf6b1f812c1f089cf9f8964f732385c69c 100644 (file)
@@ -1511,8 +1511,9 @@ static int spi_imx_probe(struct platform_device *pdev)
        if (mxc_platform_info) {
                master->num_chipselect = mxc_platform_info->num_chipselect;
                if (mxc_platform_info->chipselect) {
-                       master->cs_gpios = devm_kzalloc(&master->dev,
-                               sizeof(int) * master->num_chipselect, GFP_KERNEL);
+                       master->cs_gpios = devm_kcalloc(&master->dev,
+                               master->num_chipselect, sizeof(int),
+                               GFP_KERNEL);
                        if (!master->cs_gpios)
                                return -ENOMEM;
 
index b5911282a61116c47b0237071df40261831f94ab..085f580be7ec4d151a846618da4d9d472803fc54 100644 (file)
@@ -213,8 +213,8 @@ static int tiny_spi_of_probe(struct platform_device *pdev)
                return 0;
        hw->gpio_cs_count = of_gpio_count(np);
        if (hw->gpio_cs_count > 0) {
-               hw->gpio_cs = devm_kzalloc(&pdev->dev,
-                               hw->gpio_cs_count * sizeof(unsigned int),
+               hw->gpio_cs = devm_kcalloc(&pdev->dev,
+                               hw->gpio_cs_count, sizeof(unsigned int),
                                GFP_KERNEL);
                if (!hw->gpio_cs)
                        return -ENOMEM;
index 4797c57f426303b87d351d9b28a1dcb41fa12df1..1af8c96b940e203dfabf0b270ad46267b4308e12 100644 (file)
@@ -2135,7 +2135,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id)
        pl022->master_info = platform_info;
        pl022->adev = adev;
        pl022->vendor = id->data;
-       pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int),
+       pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int),
                                          GFP_KERNEL);
        if (!pl022->chipselects) {
                status = -ENOMEM;
index efc624f9e490e64e9ea1645e87327010a9324f0d..ec395a6baf9cacbae1830cf062fb40ae7e778f62 100644 (file)
@@ -2049,7 +2049,7 @@ static int of_spi_register_master(struct spi_controller *ctlr)
        else if (nb < 0)
                return nb;
 
-       cs = devm_kzalloc(&ctlr->dev, sizeof(int) * ctlr->num_chipselect,
+       cs = devm_kcalloc(&ctlr->dev, ctlr->num_chipselect, sizeof(int),
                          GFP_KERNEL);
        ctlr->cs_gpios = cs;
 
index 772dad65396ed68015f7d00563fb116138dfeff8..e8c4403297082898c54d0aacf09c778a399aa2d0 100644 (file)
@@ -25,7 +25,8 @@ void *ion_heap_map_kernel(struct ion_heap *heap,
        pgprot_t pgprot;
        struct sg_table *table = buffer->sg_table;
        int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE;
-       struct page **pages = vmalloc(sizeof(struct page *) * npages);
+       struct page **pages = vmalloc(array_size(npages,
+                                                sizeof(struct page *)));
        struct page **tmp = pages;
 
        if (!pages)
index 0e36b66ae5f75d58a9216569d7f86a3da991fbbf..731e47149af8072318045e18efee2379aa6de540 100644 (file)
@@ -246,7 +246,7 @@ static int fbtft_request_gpios_dt(struct fbtft_par *par)
 static int fbtft_backlight_update_status(struct backlight_device *bd)
 {
        struct fbtft_par *par = bl_get_data(bd);
-       bool polarity = !!(bd->props.state & BL_CORE_DRIVER1);
+       bool polarity = par->polarity;
 
        fbtft_par_dbg(DEBUG_BACKLIGHT, par,
                "%s: polarity=%d, power=%d, fb_blank=%d\n",
@@ -296,7 +296,7 @@ void fbtft_register_backlight(struct fbtft_par *par)
        /* Assume backlight is off, get polarity from current state of pin */
        bl_props.power = FB_BLANK_POWERDOWN;
        if (!gpio_get_value(par->gpio.led[0]))
-               bl_props.state |= BL_CORE_DRIVER1;
+               par->polarity = true;
 
        bd = backlight_device_register(dev_driver_string(par->info->device),
                                       par->info->device, par,
index e19e64e0d094c26078c45b1ff7df924a62962a3c..c7cb4a7896f478f1765f9b5d2b6442ec27f342ba 100644 (file)
@@ -229,6 +229,7 @@ struct fbtft_par {
        ktime_t update_time;
        bool bgr;
        void *extra;
+       bool polarity;
 };
 
 #define NUMARGS(...)  (sizeof((int[]){__VA_ARGS__})/sizeof(int))
index 0ba6771654f785776208b611ac93087e06818325..72ba9da3d179206562fad9add2a968a3c380e62e 100644 (file)
@@ -11,7 +11,7 @@ pool management for network interfaces.
 This document provides an overview the Linux DPIO driver, its
 subcomponents, and its APIs.
 
-See Documentation/dpaa2/overview.txt for a general overview of DPAA2
+See Documentation/networking/dpaa2/overview.rst for a general overview of DPAA2
 and the general DPAA2 driver architecture in Linux.
 
 Driver Overview
index 15e57f7016302bbdb001baa65c702cd110b6b3c2..b71078339e860d8d6713f28ec20f2a31588d18a4 100644 (file)
@@ -144,7 +144,7 @@ static const char **gb_generate_enum_strings(struct gbaudio_module_info *gb,
        __u8 *data;
 
        items = le32_to_cpu(gbenum->items);
-       strings = devm_kzalloc(gb->dev, sizeof(char *) * items, GFP_KERNEL);
+       strings = devm_kcalloc(gb->dev, items, sizeof(char *), GFP_KERNEL);
        data = gbenum->names;
 
        for (i = 0; i < items; i++) {
index 341f729a97791b6eec8b9fb46b7e2582d944bb9b..6dded10f4155fa2c20658a5c977ac2fe52719a1d 100644 (file)
@@ -1175,8 +1175,9 @@ static int gb_camera_debugfs_init(struct gb_camera *gcam)
 
        gcam->debugfs.root = debugfs_create_dir(dirname, gb_debugfs_get());
 
-       gcam->debugfs.buffers = vmalloc(sizeof(*gcam->debugfs.buffers) *
-                                       GB_CAMERA_DEBUGFS_BUFFER_MAX);
+       gcam->debugfs.buffers =
+               vmalloc(array_size(GB_CAMERA_DEBUGFS_BUFFER_MAX,
+                                  sizeof(*gcam->debugfs.buffers)));
        if (!gcam->debugfs.buffers)
                return -ENOMEM;
 
index 051f85dbe89e47677dc2834a87998e7162652bf2..6bee2a2dad68870586869d2ef18ee74db10d747d 100644 (file)
@@ -3,7 +3,7 @@ TODO:
 From the initial code review:
 
 The main thing you need to do is to implement all the controls using the
-control framework (see Documentation/video4linux/v4l2-controls.txt).
+control framework (see Documentation/media/kapi/v4l2-controls.rst).
 Most drivers are by now converted to the control framework, so you will
 find many examples of how to do this in drivers/media/radio.
 
index 289d775c482028f0e4289b9a5a981cf780fa0b08..b0be80f05767869b9947a64dabd657ea18a129c4 100644 (file)
@@ -303,9 +303,9 @@ static int imx_media_alloc_pad_vdev_lists(struct imx_media_dev *imxmd)
 
        list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {
                entity = &sd->entity;
-               vdev_lists = devm_kzalloc(
+               vdev_lists = devm_kcalloc(
                        imxmd->md.dev,
-                       entity->num_pads * sizeof(*vdev_lists),
+                       entity->num_pads, sizeof(*vdev_lists),
                        GFP_KERNEL);
                if (!vdev_lists)
                        return -ENOMEM;
@@ -544,7 +544,7 @@ static int imx_media_probe(struct platform_device *pdev)
                goto unreg_dev;
        }
 
-       subdevs = devm_kzalloc(imxmd->md.dev, sizeof(*subdevs) * num_subdevs,
+       subdevs = devm_kcalloc(imxmd->md.dev, num_subdevs, sizeof(*subdevs),
                               GFP_KERNEL);
        if (!subdevs) {
                ret = -ENOMEM;
index 63df5de5068debf057acd01d7a1b21a2db3fb343..34a18135ede00114a7dc3259b393fb5ef221b94a 100644 (file)
@@ -7,7 +7,7 @@ config VIDEO_ZORAN
          36057/36067 PCI controller chipset. This includes the Iomega
          Buz, Pinnacle DC10+ and the Linux Media Labs LML33. There is
          a driver homepage at <http://mjpeg.sf.net/driver-zoran/>. For
-         more information, check <file:Documentation/video4linux/Zoran>.
+         more information, check <file:Documentation/media/v4l-drivers/zoran.rst>.
 
          To compile this driver as a module, choose M here: the
          module will be called zr36067.
index d2e13fffbc6be8d8b6c9d3be3f4efaaeb7601fac..d7842224fff6351e5d9a9befa01760f965969fc5 100644 (file)
@@ -941,7 +941,7 @@ static int zoran_open(struct file *file)
        /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows
         * on norm-change! */
        fh->overlay_mask =
-           kmalloc(((768 + 31) / 32) * 576 * 4, GFP_KERNEL);
+           kmalloc(array3_size((768 + 31) / 32, 576, 4), GFP_KERNEL);
        if (!fh->overlay_mask) {
                dprintk(1,
                        KERN_ERR
@@ -1220,7 +1220,8 @@ static int setup_window(struct zoran_fh *fh,
                }
        } else if (clipcount) {
                /* write our own bitmap from the clips */
-               vcp = vmalloc(sizeof(struct v4l2_clip) * (clipcount + 4));
+               vcp = vmalloc(array_size(sizeof(struct v4l2_clip),
+                                        clipcount + 4));
                if (vcp == NULL) {
                        dprintk(1,
                                KERN_ERR
index 2d9ab2620b82df501095a90e7e420097b2dee254..0c3e498ae99cde7ff67818a96e84a37410d206e6 100644 (file)
@@ -143,7 +143,7 @@ static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev,
        if (!max_maps)
                return max_maps;
 
-       *map = kzalloc(max_maps * sizeof(struct pinctrl_map), GFP_KERNEL);
+       *map = kcalloc(max_maps, sizeof(struct pinctrl_map), GFP_KERNEL);
        if (!*map)
                return -ENOMEM;
 
@@ -287,7 +287,8 @@ static int rt2880_pinmux_index(struct rt2880_priv *p)
        }
 
        /* allocate the group names array needed by the gpio function */
-       p->group_names = devm_kzalloc(p->dev, sizeof(char *) * p->group_count, GFP_KERNEL);
+       p->group_names = devm_kcalloc(p->dev, p->group_count, sizeof(char *),
+                                     GFP_KERNEL);
        if (!p->group_names)
                return -1;
 
@@ -300,8 +301,12 @@ static int rt2880_pinmux_index(struct rt2880_priv *p)
        p->func_count++;
 
        /* allocate our function and group mapping index buffers */
-       f = p->func = devm_kzalloc(p->dev, sizeof(struct rt2880_pmx_func) * p->func_count, GFP_KERNEL);
-       gpio_func.groups = devm_kzalloc(p->dev, sizeof(int) * p->group_count, GFP_KERNEL);
+       f = p->func = devm_kcalloc(p->dev,
+                                  p->func_count,
+                                  sizeof(struct rt2880_pmx_func),
+                                  GFP_KERNEL);
+       gpio_func.groups = devm_kcalloc(p->dev, p->group_count, sizeof(int),
+                                       GFP_KERNEL);
        if (!f || !gpio_func.groups)
                return -1;
 
@@ -337,7 +342,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p)
                if (!p->func[i]->pin_count)
                        continue;
 
-               p->func[i]->pins = devm_kzalloc(p->dev, sizeof(int) * p->func[i]->pin_count, GFP_KERNEL);
+               p->func[i]->pins = devm_kcalloc(p->dev,
+                                               p->func[i]->pin_count,
+                                               sizeof(int),
+                                               GFP_KERNEL);
                for (j = 0; j < p->func[i]->pin_count; j++)
                        p->func[i]->pins[j] = p->func[i]->pin_first + j;
 
@@ -347,11 +355,11 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p)
        }
 
        /* the buffer that tells us which pins are gpio */
-       p->gpio = devm_kzalloc(p->dev,sizeof(uint8_t) * p->max_pins,
-               GFP_KERNEL);
+       p->gpio = devm_kcalloc(p->dev,p->max_pins, sizeof(uint8_t),
+                              GFP_KERNEL);
        /* the pads needed to tell pinctrl about our pins */
-       p->pads = devm_kzalloc(p->dev,
-               sizeof(struct pinctrl_pin_desc) * p->max_pins,
+       p->pads = devm_kcalloc(p->dev,
+               p->max_pins, sizeof(struct pinctrl_pin_desc),
                GFP_KERNEL);
        if (!p->pads || !p->gpio ) {
                dev_err(p->dev, "Failed to allocate gpio data\n");
index 24e92998a30c74da6ecc67e321cd0818866d7507..50e7cae32f75fe21c71dd55c59953f7bcd0b82fa 100644 (file)
@@ -53,7 +53,7 @@ int rtw_init_mlme_priv(struct adapter *padapter)
 
        memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
 
-       pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)));
+       pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network)));
 
        if (!pbuf) {
                res = _FAIL;
index 37a610d05ad2a35d3fa59caafa7a70893ace925e..f2cdcc2bcab48b3a596885f203160804ae423011 100644 (file)
@@ -597,8 +597,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee,
        bool                    bMatchWinStart = false, bPktInBuf = false;
        IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize);
 
-       prxbIndicateArray = kmalloc(sizeof(struct ieee80211_rxb *) *
-                       REORDER_WIN_SIZE, GFP_KERNEL);
+       prxbIndicateArray = kmalloc_array(REORDER_WIN_SIZE,
+                                         sizeof(struct ieee80211_rxb *),
+                                         GFP_KERNEL);
        if (!prxbIndicateArray)
                return;
 
index a4df95cc7f607bccb56a54218156ea816e00bfbb..8b17400f6c13834b7c1fd83200bb371fd2a2172f 100644 (file)
@@ -1640,8 +1640,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev)
 {
        struct r8192_priv *priv = ieee80211_priv(dev);
 
-       priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB + 1),
-                              GFP_KERNEL);
+       priv->rx_urb = kmalloc_array(MAX_RX_URB + 1, sizeof(struct urb *),
+                                    GFP_KERNEL);
        if (!priv->rx_urb)
                return -ENOMEM;
 
index cc4f115e082c55cd0b0c342d3267f4f9744746dc..f9392b8db49bcde74b60183252198f300ff92227 100644 (file)
@@ -37,7 +37,7 @@ sint  _rtw_init_mlme_priv(struct adapter *padapter)
 
        memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
 
-       pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)));
+       pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network)));
 
        if (pbuf == NULL) {
                res = _FAIL;
index d7c7d146a84de25725f9da8e1459cffb028155fa..1dc71455f270c5539fe2aaff39a07becc9cd8560 100644 (file)
@@ -237,8 +237,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf)
        }
 
        /* allocate memory for efuse_tbl and efuse_word */
-       efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE] *
-                           sizeof(u8), GFP_ATOMIC);
+       efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE],
+                           GFP_ATOMIC);
        if (!efuse_tbl)
                return;
        efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC);
index 821256b95e2279068ce8dad366a277645bcc8798..b89ef15e3c2046a964c3d32d529cd221123f185f 100644 (file)
@@ -2618,7 +2618,7 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
        segment = &ms_card->segment[seg_no];
 
        if (!segment->l2p_table) {
-               segment->l2p_table = vmalloc(table_size * 2);
+               segment->l2p_table = vmalloc(array_size(table_size, 2));
                if (!segment->l2p_table) {
                        rtsx_trace(chip);
                        goto BUILD_FAIL;
index 4ad472dd9daffb767a5e3ffd200988b333819670..8a823466ca2bfe6e492c00207f77453b3777ca9e 100644 (file)
@@ -1660,13 +1660,13 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
 
        dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len);
 
-       data = vzalloc(dw_len * 4);
+       data = vzalloc(array_size(dw_len, 4));
        if (!data) {
                rtsx_trace(chip);
                return STATUS_NOMEM;
        }
 
-       mask = vzalloc(dw_len * 4);
+       mask = vzalloc(array_size(dw_len, 4));
        if (!mask) {
                vfree(data);
                rtsx_trace(chip);
@@ -1721,7 +1721,7 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
 
        dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len);
 
-       data = vmalloc(dw_len * 4);
+       data = vmalloc(array_size(dw_len, 4));
        if (!data) {
                rtsx_trace(chip);
                return STATUS_NOMEM;
index 167e98f8688e01008fe9be1f913a5de41a61ed0c..4fc521c51c0e8d639a54ff6d1c6799f97361f16d 100644 (file)
@@ -865,7 +865,7 @@ static void do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp,
                if (cmdrsp->scsi.no_disk_result == 0)
                        return;
 
-               buf = kzalloc(sizeof(char) * 36, GFP_KERNEL);
+               buf = kzalloc(36, GFP_KERNEL);
                if (!buf)
                        return;
 
index f0e8f0f4ccb4fc21f7cf419d64a319a8be394b00..ee5081ba53138b41eac01d432080e487ee2f49ae 100644 (file)
@@ -250,10 +250,10 @@ int transport_alloc_session_tags(struct se_session *se_sess,
 {
        int rc;
 
-       se_sess->sess_cmd_map = kzalloc(tag_num * tag_size,
+       se_sess->sess_cmd_map = kcalloc(tag_size, tag_num,
                                        GFP_KERNEL | __GFP_NOWARN | __GFP_RETRY_MAYFAIL);
        if (!se_sess->sess_cmd_map) {
-               se_sess->sess_cmd_map = vzalloc(tag_num * tag_size);
+               se_sess->sess_cmd_map = vzalloc(array_size(tag_size, tag_num));
                if (!se_sess->sess_cmd_map) {
                        pr_err("Unable to allocate se_sess->sess_cmd_map\n");
                        return -ENOMEM;
index 94b183efd23626188388bba10cc98f258287b229..7f96dfa32b9cdf1cbf167fe1b0581e3b94f1a08b 100644 (file)
@@ -1717,8 +1717,9 @@ static int tcmu_configure_device(struct se_device *dev)
 
        info = &udev->uio_info;
 
-       udev->data_bitmap = kzalloc(BITS_TO_LONGS(udev->max_blocks) *
-                                   sizeof(unsigned long), GFP_KERNEL);
+       udev->data_bitmap = kcalloc(BITS_TO_LONGS(udev->max_blocks),
+                                   sizeof(unsigned long),
+                                   GFP_KERNEL);
        if (!udev->data_bitmap) {
                ret = -ENOMEM;
                goto err_bitmap_alloc;
index ee3a215b333abd64435ca0828319dbf1501fd158..334d98be03b995c22844057e71778f53bd799405 100644 (file)
@@ -1,11 +1,6 @@
-/*
- * Copyright 2013 Freescale Semiconductor, Inc.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- */
+// SPDX-License-Identifier: GPL-2.0
+//
+// Copyright 2013 Freescale Semiconductor, Inc.
 
 #include <linux/clk.h>
 #include <linux/cpufreq.h>
 #define REG_CLR                0x8
 #define REG_TOG                0xc
 
-#define MISC0                          0x0150
-#define MISC0_REFTOP_SELBIASOFF                (1 << 3)
-#define MISC1                          0x0160
-#define MISC1_IRQ_TEMPHIGH             (1 << 29)
+/* i.MX6 specific */
+#define IMX6_MISC0                             0x0150
+#define IMX6_MISC0_REFTOP_SELBIASOFF           (1 << 3)
+#define IMX6_MISC1                             0x0160
+#define IMX6_MISC1_IRQ_TEMPHIGH                        (1 << 29)
 /* Below LOW and PANIC bits are only for TEMPMON_IMX6SX */
-#define MISC1_IRQ_TEMPLOW              (1 << 28)
-#define MISC1_IRQ_TEMPPANIC            (1 << 27)
-
-#define TEMPSENSE0                     0x0180
-#define TEMPSENSE0_ALARM_VALUE_SHIFT   20
-#define TEMPSENSE0_ALARM_VALUE_MASK    (0xfff << TEMPSENSE0_ALARM_VALUE_SHIFT)
-#define TEMPSENSE0_TEMP_CNT_SHIFT      8
-#define TEMPSENSE0_TEMP_CNT_MASK       (0xfff << TEMPSENSE0_TEMP_CNT_SHIFT)
-#define TEMPSENSE0_FINISHED            (1 << 2)
-#define TEMPSENSE0_MEASURE_TEMP                (1 << 1)
-#define TEMPSENSE0_POWER_DOWN          (1 << 0)
-
-#define TEMPSENSE1                     0x0190
-#define TEMPSENSE1_MEASURE_FREQ                0xffff
-/* Below TEMPSENSE2 is only for TEMPMON_IMX6SX */
-#define TEMPSENSE2                     0x0290
-#define TEMPSENSE2_LOW_VALUE_SHIFT     0
-#define TEMPSENSE2_LOW_VALUE_MASK      0xfff
-#define TEMPSENSE2_PANIC_VALUE_SHIFT   16
-#define TEMPSENSE2_PANIC_VALUE_MASK    0xfff0000
+#define IMX6_MISC1_IRQ_TEMPLOW                 (1 << 28)
+#define IMX6_MISC1_IRQ_TEMPPANIC               (1 << 27)
+
+#define IMX6_TEMPSENSE0                                0x0180
+#define IMX6_TEMPSENSE0_ALARM_VALUE_SHIFT      20
+#define IMX6_TEMPSENSE0_ALARM_VALUE_MASK       (0xfff << 20)
+#define IMX6_TEMPSENSE0_TEMP_CNT_SHIFT         8
+#define IMX6_TEMPSENSE0_TEMP_CNT_MASK          (0xfff << 8)
+#define IMX6_TEMPSENSE0_FINISHED               (1 << 2)
+#define IMX6_TEMPSENSE0_MEASURE_TEMP           (1 << 1)
+#define IMX6_TEMPSENSE0_POWER_DOWN             (1 << 0)
+
+#define IMX6_TEMPSENSE1                                0x0190
+#define IMX6_TEMPSENSE1_MEASURE_FREQ           0xffff
+#define IMX6_TEMPSENSE1_MEASURE_FREQ_SHIFT     0
 
 #define OCOTP_MEM0                     0x0480
 #define OCOTP_ANA1                     0x04e0
 
+/* Below TEMPSENSE2 is only for TEMPMON_IMX6SX */
+#define IMX6_TEMPSENSE2                                0x0290
+#define IMX6_TEMPSENSE2_LOW_VALUE_SHIFT                0
+#define IMX6_TEMPSENSE2_LOW_VALUE_MASK         0xfff
+#define IMX6_TEMPSENSE2_PANIC_VALUE_SHIFT      16
+#define IMX6_TEMPSENSE2_PANIC_VALUE_MASK       0xfff0000
+
+/* i.MX7 specific */
+#define IMX7_ANADIG_DIGPROG                    0x800
+#define IMX7_TEMPSENSE0                                0x300
+#define IMX7_TEMPSENSE0_PANIC_ALARM_SHIFT      18
+#define IMX7_TEMPSENSE0_PANIC_ALARM_MASK       (0x1ff << 18)
+#define IMX7_TEMPSENSE0_HIGH_ALARM_SHIFT       9
+#define IMX7_TEMPSENSE0_HIGH_ALARM_MASK                (0x1ff << 9)
+#define IMX7_TEMPSENSE0_LOW_ALARM_SHIFT                0
+#define IMX7_TEMPSENSE0_LOW_ALARM_MASK         0x1ff
+
+#define IMX7_TEMPSENSE1                                0x310
+#define IMX7_TEMPSENSE1_MEASURE_FREQ_SHIFT     16
+#define IMX7_TEMPSENSE1_MEASURE_FREQ_MASK      (0xffff << 16)
+#define IMX7_TEMPSENSE1_FINISHED               (1 << 11)
+#define IMX7_TEMPSENSE1_MEASURE_TEMP           (1 << 10)
+#define IMX7_TEMPSENSE1_POWER_DOWN             (1 << 9)
+#define IMX7_TEMPSENSE1_TEMP_VALUE_SHIFT       0
+#define IMX7_TEMPSENSE1_TEMP_VALUE_MASK                0x1ff
+
 /* The driver supports 1 passive trip point and 1 critical trip point */
 enum imx_thermal_trip {
        IMX_TRIP_PASSIVE,
@@ -72,17 +89,114 @@ enum imx_thermal_trip {
 
 #define TEMPMON_IMX6Q                  1
 #define TEMPMON_IMX6SX                 2
+#define TEMPMON_IMX7D                  3
 
 struct thermal_soc_data {
        u32 version;
+
+       u32 sensor_ctrl;
+       u32 power_down_mask;
+       u32 measure_temp_mask;
+
+       u32 measure_freq_ctrl;
+       u32 measure_freq_mask;
+       u32 measure_freq_shift;
+
+       u32 temp_data;
+       u32 temp_value_mask;
+       u32 temp_value_shift;
+       u32 temp_valid_mask;
+
+       u32 panic_alarm_ctrl;
+       u32 panic_alarm_mask;
+       u32 panic_alarm_shift;
+
+       u32 high_alarm_ctrl;
+       u32 high_alarm_mask;
+       u32 high_alarm_shift;
+
+       u32 low_alarm_ctrl;
+       u32 low_alarm_mask;
+       u32 low_alarm_shift;
 };
 
 static struct thermal_soc_data thermal_imx6q_data = {
        .version = TEMPMON_IMX6Q,
+
+       .sensor_ctrl = IMX6_TEMPSENSE0,
+       .power_down_mask = IMX6_TEMPSENSE0_POWER_DOWN,
+       .measure_temp_mask = IMX6_TEMPSENSE0_MEASURE_TEMP,
+
+       .measure_freq_ctrl = IMX6_TEMPSENSE1,
+       .measure_freq_shift = IMX6_TEMPSENSE1_MEASURE_FREQ_SHIFT,
+       .measure_freq_mask = IMX6_TEMPSENSE1_MEASURE_FREQ,
+
+       .temp_data = IMX6_TEMPSENSE0,
+       .temp_value_mask = IMX6_TEMPSENSE0_TEMP_CNT_MASK,
+       .temp_value_shift = IMX6_TEMPSENSE0_TEMP_CNT_SHIFT,
+       .temp_valid_mask = IMX6_TEMPSENSE0_FINISHED,
+
+       .high_alarm_ctrl = IMX6_TEMPSENSE0,
+       .high_alarm_mask = IMX6_TEMPSENSE0_ALARM_VALUE_MASK,
+       .high_alarm_shift = IMX6_TEMPSENSE0_ALARM_VALUE_SHIFT,
 };
 
 static struct thermal_soc_data thermal_imx6sx_data = {
        .version = TEMPMON_IMX6SX,
+
+       .sensor_ctrl = IMX6_TEMPSENSE0,
+       .power_down_mask = IMX6_TEMPSENSE0_POWER_DOWN,
+       .measure_temp_mask = IMX6_TEMPSENSE0_MEASURE_TEMP,
+
+       .measure_freq_ctrl = IMX6_TEMPSENSE1,
+       .measure_freq_shift = IMX6_TEMPSENSE1_MEASURE_FREQ_SHIFT,
+       .measure_freq_mask = IMX6_TEMPSENSE1_MEASURE_FREQ,
+
+       .temp_data = IMX6_TEMPSENSE0,
+       .temp_value_mask = IMX6_TEMPSENSE0_TEMP_CNT_MASK,
+       .temp_value_shift = IMX6_TEMPSENSE0_TEMP_CNT_SHIFT,
+       .temp_valid_mask = IMX6_TEMPSENSE0_FINISHED,
+
+       .high_alarm_ctrl = IMX6_TEMPSENSE0,
+       .high_alarm_mask = IMX6_TEMPSENSE0_ALARM_VALUE_MASK,
+       .high_alarm_shift = IMX6_TEMPSENSE0_ALARM_VALUE_SHIFT,
+
+       .panic_alarm_ctrl = IMX6_TEMPSENSE2,
+       .panic_alarm_mask = IMX6_TEMPSENSE2_PANIC_VALUE_MASK,
+       .panic_alarm_shift = IMX6_TEMPSENSE2_PANIC_VALUE_SHIFT,
+
+       .low_alarm_ctrl = IMX6_TEMPSENSE2,
+       .low_alarm_mask = IMX6_TEMPSENSE2_LOW_VALUE_MASK,
+       .low_alarm_shift = IMX6_TEMPSENSE2_LOW_VALUE_SHIFT,
+};
+
+static struct thermal_soc_data thermal_imx7d_data = {
+       .version = TEMPMON_IMX7D,
+
+       .sensor_ctrl = IMX7_TEMPSENSE1,
+       .power_down_mask = IMX7_TEMPSENSE1_POWER_DOWN,
+       .measure_temp_mask = IMX7_TEMPSENSE1_MEASURE_TEMP,
+
+       .measure_freq_ctrl = IMX7_TEMPSENSE1,
+       .measure_freq_shift = IMX7_TEMPSENSE1_MEASURE_FREQ_SHIFT,
+       .measure_freq_mask = IMX7_TEMPSENSE1_MEASURE_FREQ_MASK,
+
+       .temp_data = IMX7_TEMPSENSE1,
+       .temp_value_mask = IMX7_TEMPSENSE1_TEMP_VALUE_MASK,
+       .temp_value_shift = IMX7_TEMPSENSE1_TEMP_VALUE_SHIFT,
+       .temp_valid_mask = IMX7_TEMPSENSE1_FINISHED,
+
+       .panic_alarm_ctrl = IMX7_TEMPSENSE1,
+       .panic_alarm_mask = IMX7_TEMPSENSE0_PANIC_ALARM_MASK,
+       .panic_alarm_shift = IMX7_TEMPSENSE0_PANIC_ALARM_SHIFT,
+
+       .high_alarm_ctrl = IMX7_TEMPSENSE0,
+       .high_alarm_mask = IMX7_TEMPSENSE0_HIGH_ALARM_MASK,
+       .high_alarm_shift = IMX7_TEMPSENSE0_HIGH_ALARM_SHIFT,
+
+       .low_alarm_ctrl = IMX7_TEMPSENSE0,
+       .low_alarm_mask = IMX7_TEMPSENSE0_LOW_ALARM_MASK,
+       .low_alarm_shift = IMX7_TEMPSENSE0_LOW_ALARM_SHIFT,
 };
 
 struct imx_thermal_data {
@@ -107,31 +221,42 @@ struct imx_thermal_data {
 static void imx_set_panic_temp(struct imx_thermal_data *data,
                               int panic_temp)
 {
+       const struct thermal_soc_data *soc_data = data->socdata;
        struct regmap *map = data->tempmon;
        int critical_value;
 
        critical_value = (data->c2 - panic_temp) / data->c1;
-       regmap_write(map, TEMPSENSE2 + REG_CLR, TEMPSENSE2_PANIC_VALUE_MASK);
-       regmap_write(map, TEMPSENSE2 + REG_SET, critical_value <<
-                       TEMPSENSE2_PANIC_VALUE_SHIFT);
+
+       regmap_write(map, soc_data->panic_alarm_ctrl + REG_CLR,
+                    soc_data->panic_alarm_mask);
+       regmap_write(map, soc_data->panic_alarm_ctrl + REG_SET,
+                    critical_value << soc_data->panic_alarm_shift);
 }
 
 static void imx_set_alarm_temp(struct imx_thermal_data *data,
                               int alarm_temp)
 {
        struct regmap *map = data->tempmon;
+       const struct thermal_soc_data *soc_data = data->socdata;
        int alarm_value;
 
        data->alarm_temp = alarm_temp;
-       alarm_value = (data->c2 - alarm_temp) / data->c1;
-       regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_ALARM_VALUE_MASK);
-       regmap_write(map, TEMPSENSE0 + REG_SET, alarm_value <<
-                       TEMPSENSE0_ALARM_VALUE_SHIFT);
+
+       if (data->socdata->version == TEMPMON_IMX7D)
+               alarm_value = alarm_temp / 1000 + data->c1 - 25;
+       else
+               alarm_value = (data->c2 - alarm_temp) / data->c1;
+
+       regmap_write(map, soc_data->high_alarm_ctrl + REG_CLR,
+                    soc_data->high_alarm_mask);
+       regmap_write(map, soc_data->high_alarm_ctrl + REG_SET,
+                    alarm_value << soc_data->high_alarm_shift);
 }
 
 static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
 {
        struct imx_thermal_data *data = tz->devdata;
+       const struct thermal_soc_data *soc_data = data->socdata;
        struct regmap *map = data->tempmon;
        unsigned int n_meas;
        bool wait;
@@ -139,16 +264,18 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
 
        if (data->mode == THERMAL_DEVICE_ENABLED) {
                /* Check if a measurement is currently in progress */
-               regmap_read(map, TEMPSENSE0, &val);
-               wait = !(val & TEMPSENSE0_FINISHED);
+               regmap_read(map, soc_data->temp_data, &val);
+               wait = !(val & soc_data->temp_valid_mask);
        } else {
                /*
                 * Every time we measure the temperature, we will power on the
                 * temperature sensor, enable measurements, take a reading,
                 * disable measurements, power off the temperature sensor.
                 */
-               regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
-               regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP);
+               regmap_write(map, soc_data->sensor_ctrl + REG_CLR,
+                           soc_data->power_down_mask);
+               regmap_write(map, soc_data->sensor_ctrl + REG_SET,
+                           soc_data->measure_temp_mask);
 
                wait = true;
        }
@@ -160,22 +287,28 @@ static int imx_get_temp(struct thermal_zone_device *tz, int *temp)
        if (wait)
                usleep_range(20, 50);
 
-       regmap_read(map, TEMPSENSE0, &val);
+       regmap_read(map, soc_data->temp_data, &val);
 
        if (data->mode != THERMAL_DEVICE_ENABLED) {
-               regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_MEASURE_TEMP);
-               regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN);
+               regmap_write(map, soc_data->sensor_ctrl + REG_CLR,
+                            soc_data->measure_temp_mask);
+               regmap_write(map, soc_data->sensor_ctrl + REG_SET,
+                            soc_data->power_down_mask);
        }
 
-       if ((val & TEMPSENSE0_FINISHED) == 0) {
+       if ((val & soc_data->temp_valid_mask) == 0) {
                dev_dbg(&tz->device, "temp measurement never finished\n");
                return -EAGAIN;
        }
 
-       n_meas = (val & TEMPSENSE0_TEMP_CNT_MASK) >> TEMPSENSE0_TEMP_CNT_SHIFT;
+       n_meas = (val & soc_data->temp_value_mask)
+               >> soc_data->temp_value_shift;
 
        /* See imx_init_calib() for formula derivation */
-       *temp = data->c2 - n_meas * data->c1;
+       if (data->socdata->version == TEMPMON_IMX7D)
+               *temp = (n_meas - data->c1 + 25) * 1000;
+       else
+               *temp = data->c2 - n_meas * data->c1;
 
        /* Update alarm value to next higher trip point for TEMPMON_IMX6Q */
        if (data->socdata->version == TEMPMON_IMX6Q) {
@@ -219,21 +352,26 @@ static int imx_set_mode(struct thermal_zone_device *tz,
 {
        struct imx_thermal_data *data = tz->devdata;
        struct regmap *map = data->tempmon;
+       const struct thermal_soc_data *soc_data = data->socdata;
 
        if (mode == THERMAL_DEVICE_ENABLED) {
                tz->polling_delay = IMX_POLLING_DELAY;
                tz->passive_delay = IMX_PASSIVE_DELAY;
 
-               regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
-               regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP);
+               regmap_write(map, soc_data->sensor_ctrl + REG_CLR,
+                            soc_data->power_down_mask);
+               regmap_write(map, soc_data->sensor_ctrl + REG_SET,
+                            soc_data->measure_temp_mask);
 
                if (!data->irq_enabled) {
                        data->irq_enabled = true;
                        enable_irq(data->irq);
                }
        } else {
-               regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_MEASURE_TEMP);
-               regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN);
+               regmap_write(map, soc_data->sensor_ctrl + REG_CLR,
+                            soc_data->measure_temp_mask);
+               regmap_write(map, soc_data->sensor_ctrl + REG_SET,
+                            soc_data->power_down_mask);
 
                tz->polling_delay = 0;
                tz->passive_delay = 0;
@@ -354,6 +492,15 @@ static int imx_init_calib(struct platform_device *pdev, u32 ocotp_ana1)
                return -EINVAL;
        }
 
+       /*
+        * On i.MX7D, we only use the calibration data at 25C to get the temp,
+        * Tmeas = ( Nmeas - n1) + 25; n1 is the fuse value for 25C.
+        */
+       if (data->socdata->version == TEMPMON_IMX7D) {
+               data->c1 = (ocotp_ana1 >> 9) & 0x1ff;
+               return 0;
+       }
+
        /*
         * The sensor is calibrated at 25 °C (aka T1) and the value measured
         * (aka N1) at this temperature is provided in bits [31:20] in the
@@ -492,6 +639,7 @@ static irqreturn_t imx_thermal_alarm_irq_thread(int irq, void *dev)
 static const struct of_device_id of_imx_thermal_match[] = {
        { .compatible = "fsl,imx6q-tempmon", .data = &thermal_imx6q_data, },
        { .compatible = "fsl,imx6sx-tempmon", .data = &thermal_imx6sx_data, },
+       { .compatible = "fsl,imx7d-tempmon", .data = &thermal_imx7d_data, },
        { /* end */ }
 };
 MODULE_DEVICE_TABLE(of, of_imx_thermal_match);
@@ -523,14 +671,15 @@ static int imx_thermal_probe(struct platform_device *pdev)
 
        /* make sure the IRQ flag is clear before enabling irq on i.MX6SX */
        if (data->socdata->version == TEMPMON_IMX6SX) {
-               regmap_write(map, MISC1 + REG_CLR, MISC1_IRQ_TEMPHIGH |
-                       MISC1_IRQ_TEMPLOW | MISC1_IRQ_TEMPPANIC);
+               regmap_write(map, IMX6_MISC1 + REG_CLR,
+                       IMX6_MISC1_IRQ_TEMPHIGH | IMX6_MISC1_IRQ_TEMPLOW
+                       | IMX6_MISC1_IRQ_TEMPPANIC);
                /*
                 * reset value of LOW ALARM is incorrect, set it to lowest
                 * value to avoid false trigger of low alarm.
                 */
-               regmap_write(map, TEMPSENSE2 + REG_SET,
-                       TEMPSENSE2_LOW_VALUE_MASK);
+               regmap_write(map, data->socdata->low_alarm_ctrl + REG_SET,
+                            data->socdata->low_alarm_mask);
        }
 
        data->irq = platform_get_irq(pdev, 0);
@@ -557,11 +706,17 @@ static int imx_thermal_probe(struct platform_device *pdev)
        }
 
        /* Make sure sensor is in known good state for measurements */
-       regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
-       regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_MEASURE_TEMP);
-       regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ);
-       regmap_write(map, MISC0 + REG_SET, MISC0_REFTOP_SELBIASOFF);
-       regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_CLR,
+                    data->socdata->power_down_mask);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_CLR,
+                    data->socdata->measure_temp_mask);
+       regmap_write(map, data->socdata->measure_freq_ctrl + REG_CLR,
+                    data->socdata->measure_freq_mask);
+       if (data->socdata->version != TEMPMON_IMX7D)
+               regmap_write(map, IMX6_MISC0 + REG_SET,
+                       IMX6_MISC0_REFTOP_SELBIASOFF);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
+                    data->socdata->power_down_mask);
 
        data->policy = cpufreq_cpu_get(0);
        if (!data->policy) {
@@ -626,16 +781,20 @@ static int imx_thermal_probe(struct platform_device *pdev)
                 data->temp_passive / 1000);
 
        /* Enable measurements at ~ 10 Hz */
-       regmap_write(map, TEMPSENSE1 + REG_CLR, TEMPSENSE1_MEASURE_FREQ);
+       regmap_write(map, data->socdata->measure_freq_ctrl + REG_CLR,
+                    data->socdata->measure_freq_mask);
        measure_freq = DIV_ROUND_UP(32768, 10); /* 10 Hz */
-       regmap_write(map, TEMPSENSE1 + REG_SET, measure_freq);
+       regmap_write(map, data->socdata->measure_freq_ctrl + REG_SET,
+                    measure_freq << data->socdata->measure_freq_shift);
        imx_set_alarm_temp(data, data->temp_passive);
 
        if (data->socdata->version == TEMPMON_IMX6SX)
                imx_set_panic_temp(data, data->temp_critical);
 
-       regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
-       regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_CLR,
+                    data->socdata->power_down_mask);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
+                    data->socdata->measure_temp_mask);
 
        data->irq_enabled = true;
        data->mode = THERMAL_DEVICE_ENABLED;
@@ -661,7 +820,8 @@ static int imx_thermal_remove(struct platform_device *pdev)
        struct regmap *map = data->tempmon;
 
        /* Disable measurements */
-       regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
+                    data->socdata->power_down_mask);
        if (!IS_ERR(data->thermal_clk))
                clk_disable_unprepare(data->thermal_clk);
 
@@ -684,8 +844,10 @@ static int imx_thermal_suspend(struct device *dev)
         * temperature will be read as the thermal sensor is powered
         * down.
         */
-       regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_MEASURE_TEMP);
-       regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_CLR,
+                    data->socdata->measure_temp_mask);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
+                    data->socdata->power_down_mask);
        data->mode = THERMAL_DEVICE_DISABLED;
        clk_disable_unprepare(data->thermal_clk);
 
@@ -702,8 +864,10 @@ static int imx_thermal_resume(struct device *dev)
        if (ret)
                return ret;
        /* Enabled thermal sensor after resume */
-       regmap_write(map, TEMPSENSE0 + REG_CLR, TEMPSENSE0_POWER_DOWN);
-       regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_MEASURE_TEMP);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_CLR,
+                    data->socdata->power_down_mask);
+       regmap_write(map, data->socdata->sensor_ctrl + REG_SET,
+                    data->socdata->measure_temp_mask);
        data->mode = THERMAL_DEVICE_ENABLED;
 
        return 0;
index c719167e9f2829dedea376e21b51a773559e5866..45e7e5cbdffb438648869b2ebd236b906ad82933 100644 (file)
@@ -96,7 +96,7 @@ int acpi_parse_trt(acpi_handle handle, int *trt_count, struct trt **trtp,
        }
 
        *trt_count = p->package.count;
-       trts = kzalloc(*trt_count * sizeof(struct trt), GFP_KERNEL);
+       trts = kcalloc(*trt_count, sizeof(struct trt), GFP_KERNEL);
        if (!trts) {
                result = -ENOMEM;
                goto end;
@@ -178,7 +178,7 @@ int acpi_parse_art(acpi_handle handle, int *art_count, struct art **artp,
 
        /* ignore p->package.elements[0], as this is _ART Revision field */
        *art_count = p->package.count - 1;
-       arts = kzalloc(*art_count * sizeof(struct art), GFP_KERNEL);
+       arts = kcalloc(*art_count, sizeof(struct art), GFP_KERNEL);
        if (!arts) {
                result = -ENOMEM;
                goto end;
index 145a5c53ff5c0fd16c579352124394ece156c0eb..9ec27ac1856bf3b4c68b40427744ecc5af18fc9a 100644 (file)
@@ -147,9 +147,9 @@ static int int340x_thermal_get_trip_hyst(struct thermal_zone_device *zone,
 
        status = acpi_evaluate_integer(d->adev->handle, "GTSH", NULL, &hyst);
        if (ACPI_FAILURE(status))
-               return -EIO;
-
-       *temp = hyst * 100;
+               *temp = 0;
+       else
+               *temp = hyst * 100;
 
        return 0;
 }
@@ -239,9 +239,10 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev,
        if (ACPI_FAILURE(status))
                trip_cnt = 0;
        else {
-               int34x_thermal_zone->aux_trips = kzalloc(
-                               sizeof(*int34x_thermal_zone->aux_trips) *
-                               trip_cnt, GFP_KERNEL);
+               int34x_thermal_zone->aux_trips =
+                       kcalloc(trip_cnt,
+                               sizeof(*int34x_thermal_zone->aux_trips),
+                               GFP_KERNEL);
                if (!int34x_thermal_zone->aux_trips) {
                        ret = -ENOMEM;
                        goto err_trip_alloc;
index 80bbf9ce2fb66f7d2a3c49566bcc94f7bd29ff8c..284cf2c5a8fd92db5bde9705e67d2510fe984731 100644 (file)
@@ -43,6 +43,9 @@
 #define PCI_DEVICE_ID_PROC_BXTX_THERMAL  0x4A8C
 #define PCI_DEVICE_ID_PROC_BXTP_THERMAL  0x5A8C
 
+/* GeminiLake thermal reporting device */
+#define PCI_DEVICE_ID_PROC_GLK_THERMAL 0x318C
+
 struct power_config {
        u32     index;
        u32     min_uw;
@@ -467,6 +470,7 @@ static const struct pci_device_id proc_thermal_pci_ids[] = {
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_BXTP_THERMAL)},
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_CNL_THERMAL)},
        { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_CFL_THERMAL)},
+       { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PROC_GLK_THERMAL)},
        { 0, },
 };
 
index c75661a3801ab6a23b4d75450617c5165a647e52..0691f260f6eabec0536e4975f82be279aeb78630 100644 (file)
 /* The number of sensing points per bank */
 #define MT2712_NUM_SENSORS_PER_ZONE    4
 
+#define MT7622_TEMP_AUXADC_CHANNEL     11
+#define MT7622_NUM_SENSORS             1
+#define MT7622_NUM_ZONES               1
+#define MT7622_NUM_SENSORS_PER_ZONE    1
+#define MT7622_TS1     0
+
 struct mtk_thermal;
 
 struct thermal_bank_cfg {
@@ -242,6 +248,12 @@ static const int mt2712_adcpnp[MT2712_NUM_SENSORS_PER_ZONE] = {
 
 static const int mt2712_mux_values[MT2712_NUM_SENSORS] = { 0, 1, 2, 3 };
 
+/* MT7622 thermal sensor data */
+static const int mt7622_bank_data[MT7622_NUM_SENSORS] = { MT7622_TS1, };
+static const int mt7622_msr[MT7622_NUM_SENSORS_PER_ZONE] = { TEMP_MSR0, };
+static const int mt7622_adcpnp[MT7622_NUM_SENSORS_PER_ZONE] = { TEMP_ADCPNP0, };
+static const int mt7622_mux_values[MT7622_NUM_SENSORS] = { 0, };
+
 /**
  * The MT8173 thermal controller has four banks. Each bank can read up to
  * four temperature sensors simultaneously. The MT8173 has a total of 5
@@ -329,6 +341,25 @@ static const struct mtk_thermal_data mt2712_thermal_data = {
        .sensor_mux_values = mt2712_mux_values,
 };
 
+/*
+ * MT7622 have only one sensing point which uses AUXADC Channel 11 for raw data
+ * access.
+ */
+static const struct mtk_thermal_data mt7622_thermal_data = {
+       .auxadc_channel = MT7622_TEMP_AUXADC_CHANNEL,
+       .num_banks = MT7622_NUM_ZONES,
+       .num_sensors = MT7622_NUM_SENSORS,
+       .bank_data = {
+               {
+                       .num_sensors = 1,
+                       .sensors = mt7622_bank_data,
+               },
+       },
+       .msr = mt7622_msr,
+       .adcpnp = mt7622_adcpnp,
+       .sensor_mux_values = mt7622_mux_values,
+};
+
 /**
  * raw_to_mcelsius - convert a raw ADC value to mcelsius
  * @mt:                The thermal controller
@@ -631,6 +662,10 @@ static const struct of_device_id mtk_thermal_of_match[] = {
        {
                .compatible = "mediatek,mt2712-thermal",
                .data = (void *)&mt2712_thermal_data,
+       },
+       {
+               .compatible = "mediatek,mt7622-thermal",
+               .data = (void *)&mt7622_thermal_data,
        }, {
        },
 };
@@ -642,7 +677,6 @@ static int mtk_thermal_probe(struct platform_device *pdev)
        struct device_node *auxadc, *apmixedsys, *np = pdev->dev.of_node;
        struct mtk_thermal *mt;
        struct resource *res;
-       const struct of_device_id *of_id;
        u64 auxadc_phys_base, apmixed_phys_base;
        struct thermal_zone_device *tzdev;
 
@@ -650,9 +684,7 @@ static int mtk_thermal_probe(struct platform_device *pdev)
        if (!mt)
                return -ENOMEM;
 
-       of_id = of_match_device(mtk_thermal_of_match, &pdev->dev);
-       if (of_id)
-               mt->conf = (const struct mtk_thermal_data *)of_id->data;
+       mt->conf = of_device_get_match_data(&pdev->dev);
 
        mt->clk_peri_therm = devm_clk_get(&pdev->dev, "therm");
        if (IS_ERR(mt->clk_peri_therm))
index e09f0354a4bc378488d522a27ab215909388d1a5..977a8307fbb1a4e0d66cb1c619834472bfe0d1ea 100644 (file)
@@ -1,26 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *  of-thermal.c - Generic Thermal Management device tree support.
  *
  *  Copyright (C) 2013 Texas Instruments
  *  Copyright (C) 2013 Eduardo Valentin <eduardo.valentin@ti.com>
- *
- *
- *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 #include <linux/thermal.h>
 #include <linux/slab.h>
@@ -870,7 +853,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np)
        if (tz->ntrips == 0) /* must have at least one child */
                goto finish;
 
-       tz->trips = kzalloc(tz->ntrips * sizeof(*tz->trips), GFP_KERNEL);
+       tz->trips = kcalloc(tz->ntrips, sizeof(*tz->trips), GFP_KERNEL);
        if (!tz->trips) {
                ret = -ENOMEM;
                goto free_tz;
@@ -896,7 +879,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np)
        if (tz->num_tbps == 0)
                goto finish;
 
-       tz->tbps = kzalloc(tz->num_tbps * sizeof(*tz->tbps), GFP_KERNEL);
+       tz->tbps = kcalloc(tz->num_tbps, sizeof(*tz->tbps), GFP_KERNEL);
        if (!tz->tbps) {
                ret = -ENOMEM;
                goto free_trips;
index 95f987d5aa7177d8da537c86bfe6fcc22114538e..ad4f3a8d656056971a05e1bbb3c3ee7fa20d5a11 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2015, 2017, 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
@@ -11,6 +11,7 @@
  * GNU General Public License for more details.
  */
 
+#include <linux/bitops.h>
 #include <linux/delay.h>
 #include <linux/err.h>
 #include <linux/iio/consumer.h>
 #define QPNP_TM_REG_ALARM_CTRL         0x46
 
 #define QPNP_TM_TYPE                   0x09
-#define QPNP_TM_SUBTYPE                        0x08
+#define QPNP_TM_SUBTYPE_GEN1           0x08
+#define QPNP_TM_SUBTYPE_GEN2           0x09
 
-#define STATUS_STAGE_MASK              0x03
+#define STATUS_GEN1_STAGE_MASK         GENMASK(1, 0)
+#define STATUS_GEN2_STATE_MASK         GENMASK(6, 4)
+#define STATUS_GEN2_STATE_SHIFT                4
 
-#define SHUTDOWN_CTRL1_THRESHOLD_MASK  0x03
+#define SHUTDOWN_CTRL1_OVERRIDE_MASK   GENMASK(7, 6)
+#define SHUTDOWN_CTRL1_THRESHOLD_MASK  GENMASK(1, 0)
 
-#define ALARM_CTRL_FORCE_ENABLE                0x80
+#define ALARM_CTRL_FORCE_ENABLE                BIT(7)
 
 /*
  * Trip point values based on threshold control
@@ -58,6 +63,7 @@
 struct qpnp_tm_chip {
        struct regmap                   *map;
        struct thermal_zone_device      *tz_dev;
+       unsigned int                    subtype;
        long                            temp;
        unsigned int                    thresh;
        unsigned int                    stage;
@@ -66,6 +72,9 @@ struct qpnp_tm_chip {
        struct iio_channel              *adc;
 };
 
+/* This array maps from GEN2 alarm state to GEN1 alarm stage */
+static const unsigned int alarm_state_map[8] = {0, 1, 1, 2, 2, 3, 3, 3};
+
 static int qpnp_tm_read(struct qpnp_tm_chip *chip, u16 addr, u8 *data)
 {
        unsigned int val;
@@ -84,30 +93,59 @@ static int qpnp_tm_write(struct qpnp_tm_chip *chip, u16 addr, u8 data)
        return regmap_write(chip->map, chip->base + addr, data);
 }
 
+/**
+ * qpnp_tm_get_temp_stage() - return over-temperature stage
+ * @chip:              Pointer to the qpnp_tm chip
+ *
+ * Return: stage (GEN1) or state (GEN2) on success, or errno on failure.
+ */
+static int qpnp_tm_get_temp_stage(struct qpnp_tm_chip *chip)
+{
+       int ret;
+       u8 reg = 0;
+
+       ret = qpnp_tm_read(chip, QPNP_TM_REG_STATUS, &reg);
+       if (ret < 0)
+               return ret;
+
+       if (chip->subtype == QPNP_TM_SUBTYPE_GEN1)
+               ret = reg & STATUS_GEN1_STAGE_MASK;
+       else
+               ret = (reg & STATUS_GEN2_STATE_MASK) >> STATUS_GEN2_STATE_SHIFT;
+
+       return ret;
+}
+
 /*
  * This function updates the internal temp value based on the
  * current thermal stage and threshold as well as the previous stage
  */
 static int qpnp_tm_update_temp_no_adc(struct qpnp_tm_chip *chip)
 {
-       unsigned int stage;
+       unsigned int stage, stage_new, stage_old;
        int ret;
-       u8 reg = 0;
 
-       ret = qpnp_tm_read(chip, QPNP_TM_REG_STATUS, &reg);
+       ret = qpnp_tm_get_temp_stage(chip);
        if (ret < 0)
                return ret;
+       stage = ret;
 
-       stage = reg & STATUS_STAGE_MASK;
+       if (chip->subtype == QPNP_TM_SUBTYPE_GEN1) {
+               stage_new = stage;
+               stage_old = chip->stage;
+       } else {
+               stage_new = alarm_state_map[stage];
+               stage_old = alarm_state_map[chip->stage];
+       }
 
-       if (stage > chip->stage) {
+       if (stage_new > stage_old) {
                /* increasing stage, use lower bound */
-               chip->temp = (stage - 1) * TEMP_STAGE_STEP +
+               chip->temp = (stage_new - 1) * TEMP_STAGE_STEP +
                             chip->thresh * TEMP_THRESH_STEP +
                             TEMP_STAGE_HYSTERESIS + TEMP_THRESH_MIN;
-       } else if (stage < chip->stage) {
+       } else if (stage_new < stage_old) {
                /* decreasing stage, use upper bound */
-               chip->temp = stage * TEMP_STAGE_STEP +
+               chip->temp = stage_new * TEMP_STAGE_STEP +
                             chip->thresh * TEMP_THRESH_STEP -
                             TEMP_STAGE_HYSTERESIS + TEMP_THRESH_MIN;
        }
@@ -162,28 +200,37 @@ static irqreturn_t qpnp_tm_isr(int irq, void *data)
  */
 static int qpnp_tm_init(struct qpnp_tm_chip *chip)
 {
+       unsigned int stage;
        int ret;
-       u8 reg;
+       u8 reg = 0;
 
-       chip->thresh = THRESH_MIN;
+       ret = qpnp_tm_read(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, &reg);
+       if (ret < 0)
+               return ret;
+
+       chip->thresh = reg & SHUTDOWN_CTRL1_THRESHOLD_MASK;
        chip->temp = DEFAULT_TEMP;
 
-       ret = qpnp_tm_read(chip, QPNP_TM_REG_STATUS, &reg);
+       ret = qpnp_tm_get_temp_stage(chip);
        if (ret < 0)
                return ret;
+       chip->stage = ret;
 
-       chip->stage = reg & STATUS_STAGE_MASK;
+       stage = chip->subtype == QPNP_TM_SUBTYPE_GEN1
+               ? chip->stage : alarm_state_map[chip->stage];
 
-       if (chip->stage)
+       if (stage)
                chip->temp = chip->thresh * TEMP_THRESH_STEP +
-                            (chip->stage - 1) * TEMP_STAGE_STEP +
+                            (stage - 1) * TEMP_STAGE_STEP +
                             TEMP_THRESH_MIN;
 
        /*
         * Set threshold and disable software override of stage 2 and 3
         * shutdowns.
         */
-       reg = chip->thresh & SHUTDOWN_CTRL1_THRESHOLD_MASK;
+       chip->thresh = THRESH_MIN;
+       reg &= ~(SHUTDOWN_CTRL1_OVERRIDE_MASK | SHUTDOWN_CTRL1_THRESHOLD_MASK);
+       reg |= chip->thresh & SHUTDOWN_CTRL1_THRESHOLD_MASK;
        ret = qpnp_tm_write(chip, QPNP_TM_REG_SHUTDOWN_CTRL1, reg);
        if (ret < 0)
                return ret;
@@ -246,12 +293,15 @@ static int qpnp_tm_probe(struct platform_device *pdev)
                return ret;
        }
 
-       if (type != QPNP_TM_TYPE || subtype != QPNP_TM_SUBTYPE) {
+       if (type != QPNP_TM_TYPE || (subtype != QPNP_TM_SUBTYPE_GEN1
+                                    && subtype != QPNP_TM_SUBTYPE_GEN2)) {
                dev_err(&pdev->dev, "invalid type 0x%02x or subtype 0x%02x\n",
                        type, subtype);
                return -ENODEV;
        }
 
+       chip->subtype = subtype;
+
        ret = qpnp_tm_init(chip);
        if (ret < 0) {
                dev_err(&pdev->dev, "init failed\n");
index c2c34425279df67b952c0cf269c85eeedb729fbd..3440166c2ae922859afb62fdf8901c1092fc8697 100644 (file)
@@ -115,6 +115,7 @@ static int tsens_probe(struct platform_device *pdev)
        struct tsens_device *tmdev;
        const struct tsens_data *data;
        const struct of_device_id *id;
+       u32 num_sensors;
 
        if (pdev->dev.of_node)
                dev = &pdev->dev;
@@ -129,19 +130,24 @@ static int tsens_probe(struct platform_device *pdev)
        else
                data = &data_8960;
 
-       if (data->num_sensors <= 0) {
+       num_sensors = data->num_sensors;
+
+       if (np)
+               of_property_read_u32(np, "#qcom,sensors", &num_sensors);
+
+       if (num_sensors <= 0) {
                dev_err(dev, "invalid number of sensors\n");
                return -EINVAL;
        }
 
        tmdev = devm_kzalloc(dev,
-                            struct_size(tmdev, sensor, data->num_sensors),
+                            struct_size(tmdev, sensor, num_sensors),
                             GFP_KERNEL);
        if (!tmdev)
                return -ENOMEM;
 
        tmdev->dev = dev;
-       tmdev->num_sensors = data->num_sensors;
+       tmdev->num_sensors = num_sensors;
        tmdev->ops = data->ops;
        for (i = 0;  i < tmdev->num_sensors; i++) {
                if (data->hw_ids)
index 561a0a332208504ac274730649da62af23fcdafe..766521eb70715a1ff6c9a6b93434ec47d8716c49 100644 (file)
@@ -132,7 +132,7 @@ static inline void rcar_gen3_thermal_write(struct rcar_gen3_thermal_tsc *tsc,
 #define RCAR3_THERMAL_GRAN 500 /* mili Celsius */
 
 /* no idea where these constants come from */
-#define TJ_1 96
+#define TJ_1 116
 #define TJ_3 -41
 
 static void rcar_gen3_thermal_calc_coefs(struct equation_coefs *coef,
@@ -146,7 +146,7 @@ static void rcar_gen3_thermal_calc_coefs(struct equation_coefs *coef,
         * Division is not scaled in BSP and if scaled it might overflow
         * the dividend (4095 * 4095 << 14 > INT_MAX) so keep it unscaled
         */
-       tj_2 = (FIXPT_INT((ptat[1] - ptat[2]) * 137)
+       tj_2 = (FIXPT_INT((ptat[1] - ptat[2]) * 157)
                / (ptat[0] - ptat[2])) - FIXPT_INT(41);
 
        coef->a1 = FIXPT_DIV(FIXPT_INT(thcode[1] - thcode[2]),
@@ -207,8 +207,8 @@ static int rcar_gen3_thermal_set_trips(void *devdata, int low, int high)
 {
        struct rcar_gen3_thermal_tsc *tsc = devdata;
 
-       low = clamp_val(low, -40000, 125000);
-       high = clamp_val(high, -40000, 125000);
+       low = clamp_val(low, -40000, 120000);
+       high = clamp_val(high, -40000, 120000);
 
        rcar_gen3_thermal_write(tsc, REG_GEN3_IRQTEMP1,
                                rcar_gen3_thermal_mcelsius_to_temp(tsc, low));
@@ -329,6 +329,7 @@ static void rcar_gen3_thermal_init(struct rcar_gen3_thermal_tsc *tsc)
 static const struct of_device_id rcar_gen3_thermal_dt_ids[] = {
        { .compatible = "renesas,r8a7795-thermal", },
        { .compatible = "renesas,r8a7796-thermal", },
+       { .compatible = "renesas,r8a77965-thermal", },
        {},
 };
 MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids);
@@ -354,11 +355,11 @@ static int rcar_gen3_thermal_probe(struct platform_device *pdev)
 
        /* default values if FUSEs are missing */
        /* TODO: Read values from hardware on supported platforms */
-       int ptat[3] = { 2351, 1509, 435 };
+       int ptat[3] = { 2631, 1509, 435 };
        int thcode[TSC_MAX_NUM][3] = {
-               { 3248, 2800, 2221 },
-               { 3245, 2795, 2216 },
-               { 3250, 2805, 2237 },
+               { 3397, 2800, 2221 },
+               { 3393, 2795, 2216 },
+               { 3389, 2805, 2237 },
        };
 
        priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
index 73e5fee6cf1d55ddd67729180564f06559da8b59..45fb284d4c1159f27c66907d906c442b0e591543 100644 (file)
@@ -58,10 +58,47 @@ struct rcar_thermal_common {
        spinlock_t lock;
 };
 
+struct rcar_thermal_chip {
+       unsigned int use_of_thermal : 1;
+       unsigned int has_filonoff : 1;
+       unsigned int irq_per_ch : 1;
+       unsigned int needs_suspend_resume : 1;
+       unsigned int nirqs;
+};
+
+static const struct rcar_thermal_chip rcar_thermal = {
+       .use_of_thermal = 0,
+       .has_filonoff = 1,
+       .irq_per_ch = 0,
+       .needs_suspend_resume = 0,
+       .nirqs = 1,
+};
+
+static const struct rcar_thermal_chip rcar_gen2_thermal = {
+       .use_of_thermal = 1,
+       .has_filonoff = 1,
+       .irq_per_ch = 0,
+       .needs_suspend_resume = 0,
+       .nirqs = 1,
+};
+
+static const struct rcar_thermal_chip rcar_gen3_thermal = {
+       .use_of_thermal = 1,
+       .has_filonoff = 0,
+       .irq_per_ch = 1,
+       .needs_suspend_resume = 1,
+       /*
+        * The Gen3 chip has 3 interrupts, but this driver uses only 2
+        * interrupts to detect a temperature change, rise or fall.
+        */
+       .nirqs = 2,
+};
+
 struct rcar_thermal_priv {
        void __iomem *base;
        struct rcar_thermal_common *common;
        struct thermal_zone_device *zone;
+       const struct rcar_thermal_chip *chip;
        struct delayed_work work;
        struct mutex lock;
        struct list_head list;
@@ -77,13 +114,20 @@ struct rcar_thermal_priv {
 #define rcar_priv_to_dev(priv)         ((priv)->common->dev)
 #define rcar_has_irq_support(priv)     ((priv)->common->base)
 #define rcar_id_to_shift(priv)         ((priv)->id * 8)
-#define rcar_of_data(dev)              ((unsigned long)of_device_get_match_data(dev))
-#define rcar_use_of_thermal(dev)       (rcar_of_data(dev) == USE_OF_THERMAL)
 
-#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 },
+       {
+               .compatible = "renesas,rcar-thermal",
+               .data = &rcar_thermal,
+       },
+       {
+               .compatible = "renesas,rcar-gen2-thermal",
+                .data = &rcar_gen2_thermal,
+       },
+       {
+               .compatible = "renesas,thermal-r8a77995",
+               .data = &rcar_gen3_thermal,
+       },
        {},
 };
 MODULE_DEVICE_TABLE(of, rcar_thermal_dt_ids);
@@ -190,7 +234,8 @@ static int rcar_thermal_update_temp(struct rcar_thermal_priv *priv)
         * enable IRQ
         */
        if (rcar_has_irq_support(priv)) {
-               rcar_thermal_write(priv, FILONOFF, 0);
+               if (priv->chip->has_filonoff)
+                       rcar_thermal_write(priv, FILONOFF, 0);
 
                /* enable Rising/Falling edge interrupt */
                rcar_thermal_write(priv, POSNEG,  0x1);
@@ -420,7 +465,7 @@ static int rcar_thermal_remove(struct platform_device *pdev)
 
        rcar_thermal_for_each_priv(priv, common) {
                rcar_thermal_irq_disable(priv);
-               if (rcar_use_of_thermal(dev))
+               if (priv->chip->use_of_thermal)
                        thermal_remove_hwmon_sysfs(priv->zone);
                else
                        thermal_zone_device_unregister(priv->zone);
@@ -438,6 +483,7 @@ 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 rcar_thermal_chip *chip = of_device_get_match_data(dev);
        int mres = 0;
        int i;
        int ret = -ENODEV;
@@ -457,19 +503,35 @@ static int rcar_thermal_probe(struct platform_device *pdev)
        pm_runtime_enable(dev);
        pm_runtime_get_sync(dev);
 
-       irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
-       if (irq) {
-               /*
-                * platform has IRQ support.
-                * Then, driver uses common registers
-                * rcar_has_irq_support() will be enabled
-                */
-               res = platform_get_resource(pdev, IORESOURCE_MEM, mres++);
-               common->base = devm_ioremap_resource(dev, res);
-               if (IS_ERR(common->base))
-                       return PTR_ERR(common->base);
+       for (i = 0; i < chip->nirqs; i++) {
+               irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
+               if (!irq)
+                       continue;
+               if (!common->base) {
+                       /*
+                        * platform has IRQ support.
+                        * Then, driver uses common registers
+                        * rcar_has_irq_support() will be enabled
+                        */
+                       res = platform_get_resource(pdev, IORESOURCE_MEM,
+                                                   mres++);
+                       common->base = devm_ioremap_resource(dev, res);
+                       if (IS_ERR(common->base))
+                               return PTR_ERR(common->base);
+
+                       idle = 0; /* polling delay is not needed */
+               }
 
-               idle = 0; /* polling delay is not needed */
+               ret = devm_request_irq(dev, irq->start, rcar_thermal_irq,
+                                      IRQF_SHARED, dev_name(dev), common);
+               if (ret) {
+                       dev_err(dev, "irq request failed\n ");
+                       goto error_unregister;
+               }
+
+               /* update ENR bits */
+               if (chip->irq_per_ch)
+                       enr_bits |= 1 << i;
        }
 
        for (i = 0;; i++) {
@@ -491,6 +553,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
 
                priv->common = common;
                priv->id = i;
+               priv->chip = chip;
                mutex_init(&priv->lock);
                INIT_LIST_HEAD(&priv->list);
                INIT_DELAYED_WORK(&priv->work, rcar_thermal_work);
@@ -498,7 +561,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
                if (ret < 0)
                        goto error_unregister;
 
-               if (rcar_use_of_thermal(dev))
+               if (chip->use_of_thermal)
                        priv->zone = devm_thermal_zone_of_sensor_register(
                                                dev, i, priv,
                                                &rcar_thermal_zone_of_ops);
@@ -515,7 +578,7 @@ static int rcar_thermal_probe(struct platform_device *pdev)
                        goto error_unregister;
                }
 
-               if (rcar_use_of_thermal(dev)) {
+               if (chip->use_of_thermal) {
                        /*
                         * thermal_zone doesn't enable hwmon as default,
                         * but, enable it here to keep compatible
@@ -531,20 +594,12 @@ static int rcar_thermal_probe(struct platform_device *pdev)
                list_move_tail(&priv->list, &common->head);
 
                /* update ENR bits */
-               enr_bits |= 3 << (i * 8);
+               if (!chip->irq_per_ch)
+                       enr_bits |= 3 << (i * 8);
        }
 
-       /* enable temperature comparation */
-       if (irq) {
-               ret = devm_request_irq(dev, irq->start, rcar_thermal_irq, 0,
-                                      dev_name(dev), common);
-               if (ret) {
-                       dev_err(dev, "irq request failed\n ");
-                       goto error_unregister;
-               }
-
+       if (enr_bits)
                rcar_thermal_common_write(common, ENR, enr_bits);
-       }
 
        dev_info(dev, "%d sensor probed\n", i);
 
@@ -556,9 +611,48 @@ static int rcar_thermal_probe(struct platform_device *pdev)
        return ret;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int rcar_thermal_suspend(struct device *dev)
+{
+       struct rcar_thermal_common *common = dev_get_drvdata(dev);
+       struct rcar_thermal_priv *priv = list_first_entry(&common->head,
+                                                         typeof(*priv), list);
+
+       if (priv->chip->needs_suspend_resume) {
+               rcar_thermal_common_write(common, ENR, 0);
+               rcar_thermal_irq_disable(priv);
+               rcar_thermal_bset(priv, THSCR, CPCTL, 0);
+       }
+
+       return 0;
+}
+
+static int rcar_thermal_resume(struct device *dev)
+{
+       struct rcar_thermal_common *common = dev_get_drvdata(dev);
+       struct rcar_thermal_priv *priv = list_first_entry(&common->head,
+                                                         typeof(*priv), list);
+       int ret;
+
+       if (priv->chip->needs_suspend_resume) {
+               ret = rcar_thermal_update_temp(priv);
+               if (ret < 0)
+                       return ret;
+               rcar_thermal_irq_enable(priv);
+               rcar_thermal_common_write(common, ENR, 0x03);
+       }
+
+       return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(rcar_thermal_pm_ops, rcar_thermal_suspend,
+                        rcar_thermal_resume);
+
 static struct platform_driver rcar_thermal_driver = {
        .driver = {
                .name   = "rcar_thermal",
+               .pm = &rcar_thermal_pm_ops,
                .of_match_table = rcar_thermal_dt_ids,
        },
        .probe          = rcar_thermal_probe,
index ac83f721db24d78cff24d9349ecf75edafe9f2d4..a992e51ef06526eee82e9513da07b1b9046c03a5 100644 (file)
 #include <linux/io.h>
 #include <linux/interrupt.h>
 #include <linux/module.h>
-#include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 
-#include "exynos_tmu.h"
+#include <dt-bindings/thermal/thermal_exynos.h>
+
 #include "../thermal_core.h"
 
 /* Exynos generic registers */
@@ -75,9 +76,6 @@
 #define EXYNOS_TMU_THERM_TRIP_EN_SHIFT 12
 
 #define EXYNOS_TMU_INTEN_RISE0_SHIFT   0
-#define EXYNOS_TMU_INTEN_RISE1_SHIFT   4
-#define EXYNOS_TMU_INTEN_RISE2_SHIFT   8
-#define EXYNOS_TMU_INTEN_RISE3_SHIFT   12
 #define EXYNOS_TMU_INTEN_FALL0_SHIFT   16
 
 #define EXYNOS_EMUL_TIME       0x57F0
 #define EXYNOS4412_MUX_ADDR_SHIFT          20
 
 /* Exynos5433 specific registers */
-#define EXYNOS5433_TMU_REG_CONTROL1            0x024
-#define EXYNOS5433_TMU_SAMPLING_INTERVAL       0x02c
-#define EXYNOS5433_TMU_COUNTER_VALUE0          0x030
-#define EXYNOS5433_TMU_COUNTER_VALUE1          0x034
-#define EXYNOS5433_TMU_REG_CURRENT_TEMP1       0x044
 #define EXYNOS5433_THD_TEMP_RISE3_0            0x050
 #define EXYNOS5433_THD_TEMP_RISE7_4            0x054
 #define EXYNOS5433_THD_TEMP_FALL3_0            0x060
 
 #define EXYNOS5433_PD_DET_EN                   1
 
-/*exynos5440 specific registers*/
-#define EXYNOS5440_TMU_S0_7_TRIM               0x000
-#define EXYNOS5440_TMU_S0_7_CTRL               0x020
-#define EXYNOS5440_TMU_S0_7_DEBUG              0x040
-#define EXYNOS5440_TMU_S0_7_TEMP               0x0f0
-#define EXYNOS5440_TMU_S0_7_TH0                        0x110
-#define EXYNOS5440_TMU_S0_7_TH1                        0x130
-#define EXYNOS5440_TMU_S0_7_TH2                        0x150
-#define EXYNOS5440_TMU_S0_7_IRQEN              0x210
-#define EXYNOS5440_TMU_S0_7_IRQ                        0x230
-/* exynos5440 common registers */
-#define EXYNOS5440_TMU_IRQ_STATUS              0x000
-#define EXYNOS5440_TMU_PMIN                    0x004
-
-#define EXYNOS5440_TMU_INTEN_RISE0_SHIFT       0
-#define EXYNOS5440_TMU_INTEN_RISE1_SHIFT       1
-#define EXYNOS5440_TMU_INTEN_RISE2_SHIFT       2
-#define EXYNOS5440_TMU_INTEN_RISE3_SHIFT       3
-#define EXYNOS5440_TMU_INTEN_FALL0_SHIFT       4
-#define EXYNOS5440_TMU_TH_RISE4_SHIFT          24
-#define EXYNOS5440_EFUSE_SWAP_OFFSET           8
+#define EXYNOS5433_G3D_BASE                    0x10070000
 
 /* Exynos7 specific registers */
 #define EXYNOS7_THD_TEMP_RISE7_6               0x50
 #define EXYNOS7_TMU_TEMP_MASK                  0x1ff
 #define EXYNOS7_PD_DET_EN_SHIFT                        23
 #define EXYNOS7_TMU_INTEN_RISE0_SHIFT          0
-#define EXYNOS7_TMU_INTEN_RISE1_SHIFT          1
-#define EXYNOS7_TMU_INTEN_RISE2_SHIFT          2
-#define EXYNOS7_TMU_INTEN_RISE3_SHIFT          3
-#define EXYNOS7_TMU_INTEN_RISE4_SHIFT          4
-#define EXYNOS7_TMU_INTEN_RISE5_SHIFT          5
-#define EXYNOS7_TMU_INTEN_RISE6_SHIFT          6
-#define EXYNOS7_TMU_INTEN_RISE7_SHIFT          7
 #define EXYNOS7_EMUL_DATA_SHIFT                        7
 #define EXYNOS7_EMUL_DATA_MASK                 0x1ff
 
+#define EXYNOS_FIRST_POINT_TRIM                        25
+#define EXYNOS_SECOND_POINT_TRIM               85
+
+#define EXYNOS_NOISE_CANCEL_MODE               4
+
 #define MCELSIUS       1000
+
+enum soc_type {
+       SOC_ARCH_EXYNOS3250 = 1,
+       SOC_ARCH_EXYNOS4210,
+       SOC_ARCH_EXYNOS4412,
+       SOC_ARCH_EXYNOS5250,
+       SOC_ARCH_EXYNOS5260,
+       SOC_ARCH_EXYNOS5420,
+       SOC_ARCH_EXYNOS5420_TRIMINFO,
+       SOC_ARCH_EXYNOS5433,
+       SOC_ARCH_EXYNOS7,
+};
+
 /**
  * struct exynos_tmu_data : A structure to hold the private data of the TMU
        driver
  * @id: identifier of the one instance of the TMU controller.
- * @pdata: pointer to the tmu platform/configuration data
  * @base: base address of the single instance of the TMU controller.
  * @base_second: base address of the common registers of the TMU controller.
  * @irq: irq number of the TMU controller.
  * @clk: pointer to the clock structure.
  * @clk_sec: pointer to the clock structure for accessing the base_second.
  * @sclk: pointer to the clock structure for accessing the tmu special clk.
+ * @cal_type: calibration type for temperature
+ * @efuse_value: SoC defined fuse value
+ * @min_efuse_value: minimum valid trimming data
+ * @max_efuse_value: maximum valid trimming data
  * @temp_error1: fused value of the first point trim.
  * @temp_error2: fused value of the second point trim.
+ * @gain: gain of amplifier in the positive-TC generator block
+ *     0 < gain <= 15
+ * @reference_voltage: reference voltage of amplifier
+ *     in the positive-TC generator block
+ *     0 < reference_voltage <= 31
  * @regulator: pointer to the TMU regulator structure.
  * @reg_conf: pointer to structure to register with core thermal.
  * @ntrip: number of supported trip points.
  */
 struct exynos_tmu_data {
        int id;
-       struct exynos_tmu_platform_data *pdata;
        void __iomem *base;
        void __iomem *base_second;
        int irq;
@@ -202,71 +193,42 @@ struct exynos_tmu_data {
        struct work_struct irq_work;
        struct mutex lock;
        struct clk *clk, *clk_sec, *sclk;
+       u32 cal_type;
+       u32 efuse_value;
+       u32 min_efuse_value;
+       u32 max_efuse_value;
        u16 temp_error1, temp_error2;
+       u8 gain;
+       u8 reference_voltage;
        struct regulator *regulator;
        struct thermal_zone_device *tzd;
        unsigned int ntrip;
        bool enabled;
 
-       int (*tmu_initialize)(struct platform_device *pdev);
+       void (*tmu_set_trip_temp)(struct exynos_tmu_data *data, int trip,
+                                u8 temp);
+       void (*tmu_set_trip_hyst)(struct exynos_tmu_data *data, int trip,
+                                u8 temp, u8 hyst);
+       void (*tmu_initialize)(struct platform_device *pdev);
        void (*tmu_control)(struct platform_device *pdev, bool on);
        int (*tmu_read)(struct exynos_tmu_data *data);
        void (*tmu_set_emulation)(struct exynos_tmu_data *data, int temp);
        void (*tmu_clear_irqs)(struct exynos_tmu_data *data);
 };
 
-static void exynos_report_trigger(struct exynos_tmu_data *p)
-{
-       char data[10], *envp[] = { data, NULL };
-       struct thermal_zone_device *tz = p->tzd;
-       int temp;
-       unsigned int i;
-
-       if (!tz) {
-               pr_err("No thermal zone device defined\n");
-               return;
-       }
-
-       thermal_zone_device_update(tz, THERMAL_EVENT_UNSPECIFIED);
-
-       mutex_lock(&tz->lock);
-       /* Find the level for which trip happened */
-       for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
-               tz->ops->get_trip_temp(tz, i, &temp);
-               if (tz->last_temperature < temp)
-                       break;
-       }
-
-       snprintf(data, sizeof(data), "%u", i);
-       kobject_uevent_env(&tz->device.kobj, KOBJ_CHANGE, envp);
-       mutex_unlock(&tz->lock);
-}
-
 /*
  * TMU treats temperature as a mapped temperature code.
  * The temperature is converted differently depending on the calibration type.
  */
 static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
 {
-       struct exynos_tmu_platform_data *pdata = data->pdata;
-       int temp_code;
-
-       switch (pdata->cal_type) {
-       case TYPE_TWO_POINT_TRIMMING:
-               temp_code = (temp - pdata->first_point_trim) *
-                       (data->temp_error2 - data->temp_error1) /
-                       (pdata->second_point_trim - pdata->first_point_trim) +
-                       data->temp_error1;
-               break;
-       case TYPE_ONE_POINT_TRIMMING:
-               temp_code = temp + data->temp_error1 - pdata->first_point_trim;
-               break;
-       default:
-               temp_code = temp + pdata->default_temp_offset;
-               break;
-       }
+       if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
+               return temp + data->temp_error1 - EXYNOS_FIRST_POINT_TRIM;
 
-       return temp_code;
+       return (temp - EXYNOS_FIRST_POINT_TRIM) *
+               (data->temp_error2 - data->temp_error1) /
+               (EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) +
+               data->temp_error1;
 }
 
 /*
@@ -275,120 +237,123 @@ static int temp_to_code(struct exynos_tmu_data *data, u8 temp)
  */
 static int code_to_temp(struct exynos_tmu_data *data, u16 temp_code)
 {
-       struct exynos_tmu_platform_data *pdata = data->pdata;
-       int temp;
-
-       switch (pdata->cal_type) {
-       case TYPE_TWO_POINT_TRIMMING:
-               temp = (temp_code - data->temp_error1) *
-                       (pdata->second_point_trim - pdata->first_point_trim) /
-                       (data->temp_error2 - data->temp_error1) +
-                       pdata->first_point_trim;
-               break;
-       case TYPE_ONE_POINT_TRIMMING:
-               temp = temp_code - data->temp_error1 + pdata->first_point_trim;
-               break;
-       default:
-               temp = temp_code - pdata->default_temp_offset;
-               break;
-       }
+       if (data->cal_type == TYPE_ONE_POINT_TRIMMING)
+               return temp_code - data->temp_error1 + EXYNOS_FIRST_POINT_TRIM;
 
-       return temp;
+       return (temp_code - data->temp_error1) *
+               (EXYNOS_SECOND_POINT_TRIM - EXYNOS_FIRST_POINT_TRIM) /
+               (data->temp_error2 - data->temp_error1) +
+               EXYNOS_FIRST_POINT_TRIM;
 }
 
 static void sanitize_temp_error(struct exynos_tmu_data *data, u32 trim_info)
 {
-       struct exynos_tmu_platform_data *pdata = data->pdata;
+       u16 tmu_temp_mask =
+               (data->soc == SOC_ARCH_EXYNOS7) ? EXYNOS7_TMU_TEMP_MASK
+                                               : EXYNOS_TMU_TEMP_MASK;
 
-       data->temp_error1 = trim_info & EXYNOS_TMU_TEMP_MASK;
+       data->temp_error1 = trim_info & tmu_temp_mask;
        data->temp_error2 = ((trim_info >> EXYNOS_TRIMINFO_85_SHIFT) &
                                EXYNOS_TMU_TEMP_MASK);
 
        if (!data->temp_error1 ||
-               (pdata->min_efuse_value > data->temp_error1) ||
-               (data->temp_error1 > pdata->max_efuse_value))
-               data->temp_error1 = pdata->efuse_value & EXYNOS_TMU_TEMP_MASK;
+           (data->min_efuse_value > data->temp_error1) ||
+           (data->temp_error1 > data->max_efuse_value))
+               data->temp_error1 = data->efuse_value & EXYNOS_TMU_TEMP_MASK;
 
        if (!data->temp_error2)
                data->temp_error2 =
-                       (pdata->efuse_value >> EXYNOS_TRIMINFO_85_SHIFT) &
+                       (data->efuse_value >> EXYNOS_TRIMINFO_85_SHIFT) &
                        EXYNOS_TMU_TEMP_MASK;
 }
 
-static u32 get_th_reg(struct exynos_tmu_data *data, u32 threshold, bool falling)
+static int exynos_tmu_initialize(struct platform_device *pdev)
 {
-       struct thermal_zone_device *tz = data->tzd;
+       struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+       struct thermal_zone_device *tzd = data->tzd;
        const struct thermal_trip * const trips =
-               of_thermal_get_trip_points(tz);
-       unsigned long temp;
-       int i;
+               of_thermal_get_trip_points(tzd);
+       unsigned int status;
+       int ret = 0, temp, hyst;
 
        if (!trips) {
-               pr_err("%s: Cannot get trip points from of-thermal.c!\n",
-                      __func__);
-               return 0;
+               dev_err(&pdev->dev,
+                       "Cannot get trip points from device tree!\n");
+               return -ENODEV;
        }
 
-       for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
-               if (trips[i].type == THERMAL_TRIP_CRITICAL)
-                       continue;
-
-               temp = trips[i].temperature / MCELSIUS;
-               if (falling)
-                       temp -= (trips[i].hysteresis / MCELSIUS);
-               else
-                       threshold &= ~(0xff << 8 * i);
-
-               threshold |= temp_to_code(data, temp) << 8 * i;
+       if (data->soc != SOC_ARCH_EXYNOS5433) /* FIXME */
+               ret = tzd->ops->get_crit_temp(tzd, &temp);
+       if (ret) {
+               dev_err(&pdev->dev,
+                       "No CRITICAL trip point defined in device tree!\n");
+               goto out;
        }
 
-       return threshold;
-}
-
-static int exynos_tmu_initialize(struct platform_device *pdev)
-{
-       struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-       int ret;
-
-       if (of_thermal_get_ntrips(data->tzd) > data->ntrip) {
+       if (of_thermal_get_ntrips(tzd) > data->ntrip) {
                dev_info(&pdev->dev,
                         "More trip points than supported by this TMU.\n");
                dev_info(&pdev->dev,
                         "%d trip points should be configured in polling mode.\n",
-                        (of_thermal_get_ntrips(data->tzd) - data->ntrip));
+                        (of_thermal_get_ntrips(tzd) - data->ntrip));
        }
 
        mutex_lock(&data->lock);
        clk_enable(data->clk);
        if (!IS_ERR(data->clk_sec))
                clk_enable(data->clk_sec);
-       ret = data->tmu_initialize(pdev);
+
+       status = readb(data->base + EXYNOS_TMU_REG_STATUS);
+       if (!status) {
+               ret = -EBUSY;
+       } else {
+               int i, ntrips =
+                       min_t(int, of_thermal_get_ntrips(tzd), data->ntrip);
+
+               data->tmu_initialize(pdev);
+
+               /* Write temperature code for rising and falling threshold */
+               for (i = 0; i < ntrips; i++) {
+                       /* Write temperature code for rising threshold */
+                       ret = tzd->ops->get_trip_temp(tzd, i, &temp);
+                       if (ret)
+                               goto err;
+                       temp /= MCELSIUS;
+                       data->tmu_set_trip_temp(data, i, temp);
+
+                       /* Write temperature code for falling threshold */
+                       ret = tzd->ops->get_trip_hyst(tzd, i, &hyst);
+                       if (ret)
+                               goto err;
+                       hyst /= MCELSIUS;
+                       data->tmu_set_trip_hyst(data, i, temp, hyst);
+               }
+
+               data->tmu_clear_irqs(data);
+       }
+err:
        clk_disable(data->clk);
        mutex_unlock(&data->lock);
        if (!IS_ERR(data->clk_sec))
                clk_disable(data->clk_sec);
-
+out:
        return ret;
 }
 
 static u32 get_con_reg(struct exynos_tmu_data *data, u32 con)
 {
-       struct exynos_tmu_platform_data *pdata = data->pdata;
-
        if (data->soc == SOC_ARCH_EXYNOS4412 ||
            data->soc == SOC_ARCH_EXYNOS3250)
                con |= (EXYNOS4412_MUX_ADDR_VALUE << EXYNOS4412_MUX_ADDR_SHIFT);
 
        con &= ~(EXYNOS_TMU_REF_VOLTAGE_MASK << EXYNOS_TMU_REF_VOLTAGE_SHIFT);
-       con |= pdata->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT;
+       con |= data->reference_voltage << EXYNOS_TMU_REF_VOLTAGE_SHIFT;
 
        con &= ~(EXYNOS_TMU_BUF_SLOPE_SEL_MASK << EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT);
-       con |= (pdata->gain << EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT);
+       con |= (data->gain << EXYNOS_TMU_BUF_SLOPE_SEL_SHIFT);
 
-       if (pdata->noise_cancel_mode) {
-               con &= ~(EXYNOS_TMU_TRIP_MODE_MASK << EXYNOS_TMU_TRIP_MODE_SHIFT);
-               con |= (pdata->noise_cancel_mode << EXYNOS_TMU_TRIP_MODE_SHIFT);
-       }
+       con &= ~(EXYNOS_TMU_TRIP_MODE_MASK << EXYNOS_TMU_TRIP_MODE_SHIFT);
+       con |= (EXYNOS_NOISE_CANCEL_MODE << EXYNOS_TMU_TRIP_MODE_SHIFT);
 
        return con;
 }
@@ -405,65 +370,70 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
        mutex_unlock(&data->lock);
 }
 
-static int exynos4210_tmu_initialize(struct platform_device *pdev)
+static void exynos4210_tmu_set_trip_temp(struct exynos_tmu_data *data,
+                                        int trip, u8 temp)
 {
-       struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-       struct thermal_zone_device *tz = data->tzd;
        const struct thermal_trip * const trips =
-               of_thermal_get_trip_points(tz);
-       int ret = 0, threshold_code, i;
-       unsigned long reference, temp;
-       unsigned int status;
+               of_thermal_get_trip_points(data->tzd);
+       u8 ref, th_code;
 
-       if (!trips) {
-               pr_err("%s: Cannot get trip points from of-thermal.c!\n",
-                      __func__);
-               ret = -ENODEV;
-               goto out;
-       }
+       ref = trips[0].temperature / MCELSIUS;
 
-       status = readb(data->base + EXYNOS_TMU_REG_STATUS);
-       if (!status) {
-               ret = -EBUSY;
-               goto out;
+       if (trip == 0) {
+               th_code = temp_to_code(data, ref);
+               writeb(th_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
        }
 
+       temp -= ref;
+       writeb(temp, data->base + EXYNOS4210_TMU_REG_TRIG_LEVEL0 + trip * 4);
+}
+
+/* failing thresholds are not supported on Exynos4210 */
+static void exynos4210_tmu_set_trip_hyst(struct exynos_tmu_data *data,
+                                        int trip, u8 temp, u8 hyst)
+{
+}
+
+static void exynos4210_tmu_initialize(struct platform_device *pdev)
+{
+       struct exynos_tmu_data *data = platform_get_drvdata(pdev);
+
        sanitize_temp_error(data, readl(data->base + EXYNOS_TMU_REG_TRIMINFO));
+}
 
-       /* Write temperature code for threshold */
-       reference = trips[0].temperature / MCELSIUS;
-       threshold_code = temp_to_code(data, reference);
-       if (threshold_code < 0) {
-               ret = threshold_code;
-               goto out;
-       }
-       writeb(threshold_code, data->base + EXYNOS4210_TMU_REG_THRESHOLD_TEMP);
+static void exynos4412_tmu_set_trip_temp(struct exynos_tmu_data *data,
+                                        int trip, u8 temp)
+{
+       u32 th, con;
 
-       for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
-               temp = trips[i].temperature / MCELSIUS;
-               writeb(temp - reference, data->base +
-                      EXYNOS4210_TMU_REG_TRIG_LEVEL0 + i * 4);
+       th = readl(data->base + EXYNOS_THD_TEMP_RISE);
+       th &= ~(0xff << 8 * trip);
+       th |= temp_to_code(data, temp) << 8 * trip;
+       writel(th, data->base + EXYNOS_THD_TEMP_RISE);
+
+       if (trip == 3) {
+               con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
+               con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
+               writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
        }
+}
 
-       data->tmu_clear_irqs(data);
-out:
-       return ret;
+static void exynos4412_tmu_set_trip_hyst(struct exynos_tmu_data *data,
+                                        int trip, u8 temp, u8 hyst)
+{
+       u32 th;
+
+       th = readl(data->base + EXYNOS_THD_TEMP_FALL);
+       th &= ~(0xff << 8 * trip);
+       if (hyst)
+               th |= temp_to_code(data, temp - hyst) << 8 * trip;
+       writel(th, data->base + EXYNOS_THD_TEMP_FALL);
 }
 
-static int exynos4412_tmu_initialize(struct platform_device *pdev)
+static void exynos4412_tmu_initialize(struct platform_device *pdev)
 {
        struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-       const struct thermal_trip * const trips =
-               of_thermal_get_trip_points(data->tzd);
-       unsigned int status, trim_info, con, ctrl, rising_threshold;
-       int ret = 0, threshold_code, i;
-       unsigned long crit_temp = 0;
-
-       status = readb(data->base + EXYNOS_TMU_REG_STATUS);
-       if (!status) {
-               ret = -EBUSY;
-               goto out;
-       }
+       unsigned int trim_info, ctrl;
 
        if (data->soc == SOC_ARCH_EXYNOS3250 ||
            data->soc == SOC_ARCH_EXYNOS4412 ||
@@ -485,58 +455,53 @@ static int exynos4412_tmu_initialize(struct platform_device *pdev)
                trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
 
        sanitize_temp_error(data, trim_info);
+}
 
-       /* Write temperature code for rising and falling threshold */
-       rising_threshold = readl(data->base + EXYNOS_THD_TEMP_RISE);
-       rising_threshold = get_th_reg(data, rising_threshold, false);
-       writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
-       writel(get_th_reg(data, 0, true), data->base + EXYNOS_THD_TEMP_FALL);
-
-       data->tmu_clear_irqs(data);
+static void exynos5433_tmu_set_trip_temp(struct exynos_tmu_data *data,
+                                        int trip, u8 temp)
+{
+       unsigned int reg_off, j;
+       u32 th;
 
-       /* if last threshold limit is also present */
-       for (i = 0; i < of_thermal_get_ntrips(data->tzd); i++) {
-               if (trips[i].type == THERMAL_TRIP_CRITICAL) {
-                       crit_temp = trips[i].temperature;
-                       break;
-               }
+       if (trip > 3) {
+               reg_off = EXYNOS5433_THD_TEMP_RISE7_4;
+               j = trip - 4;
+       } else {
+               reg_off = EXYNOS5433_THD_TEMP_RISE3_0;
+               j = trip;
        }
 
-       if (i == of_thermal_get_ntrips(data->tzd)) {
-               pr_err("%s: No CRITICAL trip point defined at of-thermal.c!\n",
-                      __func__);
-               ret = -EINVAL;
-               goto out;
-       }
+       th = readl(data->base + reg_off);
+       th &= ~(0xff << j * 8);
+       th |= (temp_to_code(data, temp) << j * 8);
+       writel(th, data->base + reg_off);
+}
 
-       threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
-       /* 1-4 level to be assigned in th0 reg */
-       rising_threshold &= ~(0xff << 8 * i);
-       rising_threshold |= threshold_code << 8 * i;
-       writel(rising_threshold, data->base + EXYNOS_THD_TEMP_RISE);
-       con = readl(data->base + EXYNOS_TMU_REG_CONTROL);
-       con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-       writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
+static void exynos5433_tmu_set_trip_hyst(struct exynos_tmu_data *data,
+                                        int trip, u8 temp, u8 hyst)
+{
+       unsigned int reg_off, j;
+       u32 th;
 
-out:
-       return ret;
+       if (trip > 3) {
+               reg_off = EXYNOS5433_THD_TEMP_FALL7_4;
+               j = trip - 4;
+       } else {
+               reg_off = EXYNOS5433_THD_TEMP_FALL3_0;
+               j = trip;
+       }
+
+       th = readl(data->base + reg_off);
+       th &= ~(0xff << j * 8);
+       th |= (temp_to_code(data, temp - hyst) << j * 8);
+       writel(th, data->base + reg_off);
 }
 
-static int exynos5433_tmu_initialize(struct platform_device *pdev)
+static void exynos5433_tmu_initialize(struct platform_device *pdev)
 {
        struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-       struct exynos_tmu_platform_data *pdata = data->pdata;
-       struct thermal_zone_device *tz = data->tzd;
-       unsigned int status, trim_info;
-       unsigned int rising_threshold = 0, falling_threshold = 0;
-       int temp, temp_hist;
-       int ret = 0, threshold_code, i, sensor_id, cal_type;
-
-       status = readb(data->base + EXYNOS_TMU_REG_STATUS);
-       if (!status) {
-               ret = -EBUSY;
-               goto out;
-       }
+       unsigned int trim_info;
+       int sensor_id, cal_type;
 
        trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
        sanitize_temp_error(data, trim_info);
@@ -552,227 +517,84 @@ static int exynos5433_tmu_initialize(struct platform_device *pdev)
                                >> EXYNOS5433_TRIMINFO_CALIB_SEL_SHIFT;
 
        switch (cal_type) {
-       case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING:
-               pdata->cal_type = TYPE_ONE_POINT_TRIMMING;
-               break;
        case EXYNOS5433_TRIMINFO_TWO_POINT_TRIMMING:
-               pdata->cal_type = TYPE_TWO_POINT_TRIMMING;
+               data->cal_type = TYPE_TWO_POINT_TRIMMING;
                break;
+       case EXYNOS5433_TRIMINFO_ONE_POINT_TRIMMING:
        default:
-               pdata->cal_type = TYPE_ONE_POINT_TRIMMING;
+               data->cal_type = TYPE_ONE_POINT_TRIMMING;
                break;
        }
 
        dev_info(&pdev->dev, "Calibration type is %d-point calibration\n",
                        cal_type ?  2 : 1);
-
-       /* Write temperature code for rising and falling threshold */
-       for (i = 0; i < of_thermal_get_ntrips(tz); i++) {
-               int rising_reg_offset, falling_reg_offset;
-               int j = 0;
-
-               switch (i) {
-               case 0:
-               case 1:
-               case 2:
-               case 3:
-                       rising_reg_offset = EXYNOS5433_THD_TEMP_RISE3_0;
-                       falling_reg_offset = EXYNOS5433_THD_TEMP_FALL3_0;
-                       j = i;
-                       break;
-               case 4:
-               case 5:
-               case 6:
-               case 7:
-                       rising_reg_offset = EXYNOS5433_THD_TEMP_RISE7_4;
-                       falling_reg_offset = EXYNOS5433_THD_TEMP_FALL7_4;
-                       j = i - 4;
-                       break;
-               default:
-                       continue;
-               }
-
-               /* Write temperature code for rising threshold */
-               tz->ops->get_trip_temp(tz, i, &temp);
-               temp /= MCELSIUS;
-               threshold_code = temp_to_code(data, temp);
-
-               rising_threshold = readl(data->base + rising_reg_offset);
-               rising_threshold |= (threshold_code << j * 8);
-               writel(rising_threshold, data->base + rising_reg_offset);
-
-               /* Write temperature code for falling threshold */
-               tz->ops->get_trip_hyst(tz, i, &temp_hist);
-               temp_hist = temp - (temp_hist / MCELSIUS);
-               threshold_code = temp_to_code(data, temp_hist);
-
-               falling_threshold = readl(data->base + falling_reg_offset);
-               falling_threshold &= ~(0xff << j * 8);
-               falling_threshold |= (threshold_code << j * 8);
-               writel(falling_threshold, data->base + falling_reg_offset);
-       }
-
-       data->tmu_clear_irqs(data);
-out:
-       return ret;
 }
 
-static int exynos5440_tmu_initialize(struct platform_device *pdev)
+static void exynos7_tmu_set_trip_temp(struct exynos_tmu_data *data,
+                                     int trip, u8 temp)
 {
-       struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-       unsigned int trim_info = 0, con, rising_threshold;
-       int threshold_code;
-       int crit_temp = 0;
+       unsigned int reg_off, bit_off;
+       u32 th;
 
-       /*
-        * For exynos5440 soc triminfo value is swapped between TMU0 and
-        * TMU2, so the below logic is needed.
-        */
-       switch (data->id) {
-       case 0:
-               trim_info = readl(data->base + EXYNOS5440_EFUSE_SWAP_OFFSET +
-                                EXYNOS5440_TMU_S0_7_TRIM);
-               break;
-       case 1:
-               trim_info = readl(data->base + EXYNOS5440_TMU_S0_7_TRIM);
-               break;
-       case 2:
-               trim_info = readl(data->base - EXYNOS5440_EFUSE_SWAP_OFFSET +
-                                 EXYNOS5440_TMU_S0_7_TRIM);
-       }
-       sanitize_temp_error(data, trim_info);
+       reg_off = ((7 - trip) / 2) * 4;
+       bit_off = ((8 - trip) % 2);
 
-       /* Write temperature code for rising and falling threshold */
-       rising_threshold = readl(data->base + EXYNOS5440_TMU_S0_7_TH0);
-       rising_threshold = get_th_reg(data, rising_threshold, false);
-       writel(rising_threshold, data->base + EXYNOS5440_TMU_S0_7_TH0);
-       writel(0, data->base + EXYNOS5440_TMU_S0_7_TH1);
+       th = readl(data->base + EXYNOS7_THD_TEMP_RISE7_6 + reg_off);
+       th &= ~(EXYNOS7_TMU_TEMP_MASK << (16 * bit_off));
+       th |= temp_to_code(data, temp) << (16 * bit_off);
+       writel(th, data->base + EXYNOS7_THD_TEMP_RISE7_6 + reg_off);
+}
 
-       data->tmu_clear_irqs(data);
+static void exynos7_tmu_set_trip_hyst(struct exynos_tmu_data *data,
+                                     int trip, u8 temp, u8 hyst)
+{
+       unsigned int reg_off, bit_off;
+       u32 th;
 
-       /* if last threshold limit is also present */
-       if (!data->tzd->ops->get_crit_temp(data->tzd, &crit_temp)) {
-               threshold_code = temp_to_code(data, crit_temp / MCELSIUS);
-               /* 5th level to be assigned in th2 reg */
-               rising_threshold =
-                       threshold_code << EXYNOS5440_TMU_TH_RISE4_SHIFT;
-               writel(rising_threshold, data->base + EXYNOS5440_TMU_S0_7_TH2);
-               con = readl(data->base + EXYNOS5440_TMU_S0_7_CTRL);
-               con |= (1 << EXYNOS_TMU_THERM_TRIP_EN_SHIFT);
-               writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
-       }
-       /* Clear the PMIN in the common TMU register */
-       if (!data->id)
-               writel(0, data->base_second + EXYNOS5440_TMU_PMIN);
+       reg_off = ((7 - trip) / 2) * 4;
+       bit_off = ((8 - trip) % 2);
 
-       return 0;
+       th = readl(data->base + EXYNOS7_THD_TEMP_FALL7_6 + reg_off);
+       th &= ~(EXYNOS7_TMU_TEMP_MASK << (16 * bit_off));
+       th |= temp_to_code(data, temp - hyst) << (16 * bit_off);
+       writel(th, data->base + EXYNOS7_THD_TEMP_FALL7_6 + reg_off);
 }
 
-static int exynos7_tmu_initialize(struct platform_device *pdev)
+static void exynos7_tmu_initialize(struct platform_device *pdev)
 {
        struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-       struct thermal_zone_device *tz = data->tzd;
-       struct exynos_tmu_platform_data *pdata = data->pdata;
-       unsigned int status, trim_info;
-       unsigned int rising_threshold = 0, falling_threshold = 0;
-       int ret = 0, threshold_code, i;
-       int temp, temp_hist;
-       unsigned int reg_off, bit_off;
-
-       status = readb(data->base + EXYNOS_TMU_REG_STATUS);
-       if (!status) {
-               ret = -EBUSY;
-               goto out;
-       }
+       unsigned int trim_info;
 
        trim_info = readl(data->base + EXYNOS_TMU_REG_TRIMINFO);
-
-       data->temp_error1 = trim_info & EXYNOS7_TMU_TEMP_MASK;
-       if (!data->temp_error1 ||
-           (pdata->min_efuse_value > data->temp_error1) ||
-           (data->temp_error1 > pdata->max_efuse_value))
-               data->temp_error1 = pdata->efuse_value & EXYNOS_TMU_TEMP_MASK;
-
-       /* Write temperature code for rising and falling threshold */
-       for (i = (of_thermal_get_ntrips(tz) - 1); i >= 0; i--) {
-               /*
-                * On exynos7 there are 4 rising and 4 falling threshold
-                * registers (0x50-0x5c and 0x60-0x6c respectively). Each
-                * register holds the value of two threshold levels (at bit
-                * offsets 0 and 16). Based on the fact that there are atmost
-                * eight possible trigger levels, calculate the register and
-                * bit offsets where the threshold levels are to be written.
-                *
-                * e.g. EXYNOS7_THD_TEMP_RISE7_6 (0x50)
-                * [24:16] - Threshold level 7
-                * [8:0] - Threshold level 6
-                * e.g. EXYNOS7_THD_TEMP_RISE5_4 (0x54)
-                * [24:16] - Threshold level 5
-                * [8:0] - Threshold level 4
-                *
-                * and similarly for falling thresholds.
-                *
-                * Based on the above, calculate the register and bit offsets
-                * for rising/falling threshold levels and populate them.
-                */
-               reg_off = ((7 - i) / 2) * 4;
-               bit_off = ((8 - i) % 2);
-
-               tz->ops->get_trip_temp(tz, i, &temp);
-               temp /= MCELSIUS;
-
-               tz->ops->get_trip_hyst(tz, i, &temp_hist);
-               temp_hist = temp - (temp_hist / MCELSIUS);
-
-               /* Set 9-bit temperature code for rising threshold levels */
-               threshold_code = temp_to_code(data, temp);
-               rising_threshold = readl(data->base +
-                       EXYNOS7_THD_TEMP_RISE7_6 + reg_off);
-               rising_threshold &= ~(EXYNOS7_TMU_TEMP_MASK << (16 * bit_off));
-               rising_threshold |= threshold_code << (16 * bit_off);
-               writel(rising_threshold,
-                      data->base + EXYNOS7_THD_TEMP_RISE7_6 + reg_off);
-
-               /* Set 9-bit temperature code for falling threshold levels */
-               threshold_code = temp_to_code(data, temp_hist);
-               falling_threshold &= ~(EXYNOS7_TMU_TEMP_MASK << (16 * bit_off));
-               falling_threshold |= threshold_code << (16 * bit_off);
-               writel(falling_threshold,
-                      data->base + EXYNOS7_THD_TEMP_FALL7_6 + reg_off);
-       }
-
-       data->tmu_clear_irqs(data);
-out:
-       return ret;
+       sanitize_temp_error(data, trim_info);
 }
 
 static void exynos4210_tmu_control(struct platform_device *pdev, bool on)
 {
        struct exynos_tmu_data *data = platform_get_drvdata(pdev);
        struct thermal_zone_device *tz = data->tzd;
-       unsigned int con, interrupt_en;
+       unsigned int con, interrupt_en = 0, i;
 
        con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
 
        if (on) {
-               con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
-               interrupt_en =
-                       (of_thermal_is_trip_valid(tz, 3)
-                        << EXYNOS_TMU_INTEN_RISE3_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 2)
-                        << EXYNOS_TMU_INTEN_RISE2_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 1)
-                        << EXYNOS_TMU_INTEN_RISE1_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 0)
-                        << EXYNOS_TMU_INTEN_RISE0_SHIFT);
+               for (i = 0; i < data->ntrip; i++) {
+                       if (!of_thermal_is_trip_valid(tz, i))
+                               continue;
+
+                       interrupt_en |=
+                               (1 << (EXYNOS_TMU_INTEN_RISE0_SHIFT + i * 4));
+               }
 
                if (data->soc != SOC_ARCH_EXYNOS4210)
                        interrupt_en |=
                                interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
+
+               con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
        } else {
                con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
-               interrupt_en = 0; /* Disable all interrupts */
        }
+
        writel(interrupt_en, data->base + EXYNOS_TMU_REG_INTEN);
        writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
 }
@@ -781,36 +603,25 @@ static void exynos5433_tmu_control(struct platform_device *pdev, bool on)
 {
        struct exynos_tmu_data *data = platform_get_drvdata(pdev);
        struct thermal_zone_device *tz = data->tzd;
-       unsigned int con, interrupt_en, pd_det_en;
+       unsigned int con, interrupt_en = 0, pd_det_en, i;
 
        con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
 
        if (on) {
-               con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
-               interrupt_en =
-                       (of_thermal_is_trip_valid(tz, 7)
-                       << EXYNOS7_TMU_INTEN_RISE7_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 6)
-                       << EXYNOS7_TMU_INTEN_RISE6_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 5)
-                       << EXYNOS7_TMU_INTEN_RISE5_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 4)
-                       << EXYNOS7_TMU_INTEN_RISE4_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 3)
-                       << EXYNOS7_TMU_INTEN_RISE3_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 2)
-                       << EXYNOS7_TMU_INTEN_RISE2_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 1)
-                       << EXYNOS7_TMU_INTEN_RISE1_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 0)
-                       << EXYNOS7_TMU_INTEN_RISE0_SHIFT);
+               for (i = 0; i < data->ntrip; i++) {
+                       if (!of_thermal_is_trip_valid(tz, i))
+                               continue;
+
+                       interrupt_en |=
+                               (1 << (EXYNOS7_TMU_INTEN_RISE0_SHIFT + i));
+               }
 
                interrupt_en |=
                        interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
-       } else {
+
+               con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
+       } else
                con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
-               interrupt_en = 0; /* Disable all interrupts */
-       }
 
        pd_det_en = on ? EXYNOS5433_PD_DET_EN : 0;
 
@@ -819,70 +630,31 @@ static void exynos5433_tmu_control(struct platform_device *pdev, bool on)
        writel(con, data->base + EXYNOS_TMU_REG_CONTROL);
 }
 
-static void exynos5440_tmu_control(struct platform_device *pdev, bool on)
-{
-       struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-       struct thermal_zone_device *tz = data->tzd;
-       unsigned int con, interrupt_en;
-
-       con = get_con_reg(data, readl(data->base + EXYNOS5440_TMU_S0_7_CTRL));
-
-       if (on) {
-               con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
-               interrupt_en =
-                       (of_thermal_is_trip_valid(tz, 3)
-                        << EXYNOS5440_TMU_INTEN_RISE3_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 2)
-                        << EXYNOS5440_TMU_INTEN_RISE2_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 1)
-                        << EXYNOS5440_TMU_INTEN_RISE1_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 0)
-                        << EXYNOS5440_TMU_INTEN_RISE0_SHIFT);
-               interrupt_en |=
-                       interrupt_en << EXYNOS5440_TMU_INTEN_FALL0_SHIFT;
-       } else {
-               con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
-               interrupt_en = 0; /* Disable all interrupts */
-       }
-       writel(interrupt_en, data->base + EXYNOS5440_TMU_S0_7_IRQEN);
-       writel(con, data->base + EXYNOS5440_TMU_S0_7_CTRL);
-}
-
 static void exynos7_tmu_control(struct platform_device *pdev, bool on)
 {
        struct exynos_tmu_data *data = platform_get_drvdata(pdev);
        struct thermal_zone_device *tz = data->tzd;
-       unsigned int con, interrupt_en;
+       unsigned int con, interrupt_en = 0, i;
 
        con = get_con_reg(data, readl(data->base + EXYNOS_TMU_REG_CONTROL));
 
        if (on) {
-               con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
-               con |= (1 << EXYNOS7_PD_DET_EN_SHIFT);
-               interrupt_en =
-                       (of_thermal_is_trip_valid(tz, 7)
-                       << EXYNOS7_TMU_INTEN_RISE7_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 6)
-                       << EXYNOS7_TMU_INTEN_RISE6_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 5)
-                       << EXYNOS7_TMU_INTEN_RISE5_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 4)
-                       << EXYNOS7_TMU_INTEN_RISE4_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 3)
-                       << EXYNOS7_TMU_INTEN_RISE3_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 2)
-                       << EXYNOS7_TMU_INTEN_RISE2_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 1)
-                       << EXYNOS7_TMU_INTEN_RISE1_SHIFT) |
-                       (of_thermal_is_trip_valid(tz, 0)
-                       << EXYNOS7_TMU_INTEN_RISE0_SHIFT);
+               for (i = 0; i < data->ntrip; i++) {
+                       if (!of_thermal_is_trip_valid(tz, i))
+                               continue;
+
+                       interrupt_en |=
+                               (1 << (EXYNOS7_TMU_INTEN_RISE0_SHIFT + i));
+               }
 
                interrupt_en |=
                        interrupt_en << EXYNOS_TMU_INTEN_FALL0_SHIFT;
+
+               con |= (1 << EXYNOS_TMU_CORE_EN_SHIFT);
+               con |= (1 << EXYNOS7_PD_DET_EN_SHIFT);
        } else {
                con &= ~(1 << EXYNOS_TMU_CORE_EN_SHIFT);
                con &= ~(1 << EXYNOS7_PD_DET_EN_SHIFT);
-               interrupt_en = 0; /* Disable all interrupts */
        }
 
        writel(interrupt_en, data->base + EXYNOS7_TMU_REG_INTEN);
@@ -896,6 +668,12 @@ static int exynos_get_temp(void *p, int *temp)
 
        if (!data || !data->tmu_read || !data->enabled)
                return -EINVAL;
+       else if (!data->enabled)
+               /*
+                * Called too early, probably
+                * from thermal_zone_of_sensor_register().
+                */
+               return -EAGAIN;
 
        mutex_lock(&data->lock);
        clk_enable(data->clk);
@@ -919,10 +697,8 @@ static u32 get_emul_con_reg(struct exynos_tmu_data *data, unsigned int val,
        if (temp) {
                temp /= MCELSIUS;
 
-               if (data->soc != SOC_ARCH_EXYNOS5440) {
-                       val &= ~(EXYNOS_EMUL_TIME_MASK << EXYNOS_EMUL_TIME_SHIFT);
-                       val |= (EXYNOS_EMUL_TIME << EXYNOS_EMUL_TIME_SHIFT);
-               }
+               val &= ~(EXYNOS_EMUL_TIME_MASK << EXYNOS_EMUL_TIME_SHIFT);
+               val |= (EXYNOS_EMUL_TIME << EXYNOS_EMUL_TIME_SHIFT);
                if (data->soc == SOC_ARCH_EXYNOS7) {
                        val &= ~(EXYNOS7_EMUL_DATA_MASK <<
                                EXYNOS7_EMUL_DATA_SHIFT);
@@ -963,16 +739,6 @@ static void exynos4412_tmu_set_emulation(struct exynos_tmu_data *data,
        writel(val, data->base + emul_con);
 }
 
-static void exynos5440_tmu_set_emulation(struct exynos_tmu_data *data,
-                                        int temp)
-{
-       unsigned int val;
-
-       val = readl(data->base + EXYNOS5440_TMU_S0_7_DEBUG);
-       val = get_emul_con_reg(data, val, temp);
-       writel(val, data->base + EXYNOS5440_TMU_S0_7_DEBUG);
-}
-
 static int exynos_tmu_set_emulation(void *drv_data, int temp)
 {
        struct exynos_tmu_data *data = drv_data;
@@ -995,7 +761,6 @@ static int exynos_tmu_set_emulation(void *drv_data, int temp)
 }
 #else
 #define exynos4412_tmu_set_emulation NULL
-#define exynos5440_tmu_set_emulation NULL
 static int exynos_tmu_set_emulation(void *drv_data, int temp)
        { return -EINVAL; }
 #endif /* CONFIG_THERMAL_EMULATION */
@@ -1013,11 +778,6 @@ static int exynos4412_tmu_read(struct exynos_tmu_data *data)
        return readb(data->base + EXYNOS_TMU_REG_CURRENT_TEMP);
 }
 
-static int exynos5440_tmu_read(struct exynos_tmu_data *data)
-{
-       return readb(data->base + EXYNOS5440_TMU_S0_7_TEMP);
-}
-
 static int exynos7_tmu_read(struct exynos_tmu_data *data)
 {
        return readw(data->base + EXYNOS_TMU_REG_CURRENT_TEMP) &
@@ -1028,20 +788,14 @@ static void exynos_tmu_work(struct work_struct *work)
 {
        struct exynos_tmu_data *data = container_of(work,
                        struct exynos_tmu_data, irq_work);
-       unsigned int val_type;
 
        if (!IS_ERR(data->clk_sec))
                clk_enable(data->clk_sec);
-       /* Find which sensor generated this interrupt */
-       if (data->soc == SOC_ARCH_EXYNOS5440) {
-               val_type = readl(data->base_second + EXYNOS5440_TMU_IRQ_STATUS);
-               if (!((val_type >> data->id) & 0x1))
-                       goto out;
-       }
        if (!IS_ERR(data->clk_sec))
                clk_disable(data->clk_sec);
 
-       exynos_report_trigger(data);
+       thermal_zone_device_update(data->tzd, THERMAL_EVENT_UNSPECIFIED);
+
        mutex_lock(&data->lock);
        clk_enable(data->clk);
 
@@ -1050,7 +804,6 @@ static void exynos_tmu_work(struct work_struct *work)
 
        clk_disable(data->clk);
        mutex_unlock(&data->lock);
-out:
        enable_irq(data->irq);
 }
 
@@ -1085,15 +838,6 @@ static void exynos4210_tmu_clear_irqs(struct exynos_tmu_data *data)
        writel(val_irq, data->base + tmu_intclear);
 }
 
-static void exynos5440_tmu_clear_irqs(struct exynos_tmu_data *data)
-{
-       unsigned int val_irq;
-
-       val_irq = readl(data->base + EXYNOS5440_TMU_S0_7_IRQ);
-       /* clear the interrupts */
-       writel(val_irq, data->base + EXYNOS5440_TMU_S0_7_IRQ);
-}
-
 static irqreturn_t exynos_tmu_irq(int irq, void *id)
 {
        struct exynos_tmu_data *data = id;
@@ -1105,86 +849,41 @@ static irqreturn_t exynos_tmu_irq(int irq, void *id)
 }
 
 static const struct of_device_id exynos_tmu_match[] = {
-       { .compatible = "samsung,exynos3250-tmu", },
-       { .compatible = "samsung,exynos4210-tmu", },
-       { .compatible = "samsung,exynos4412-tmu", },
-       { .compatible = "samsung,exynos5250-tmu", },
-       { .compatible = "samsung,exynos5260-tmu", },
-       { .compatible = "samsung,exynos5420-tmu", },
-       { .compatible = "samsung,exynos5420-tmu-ext-triminfo", },
-       { .compatible = "samsung,exynos5433-tmu", },
-       { .compatible = "samsung,exynos5440-tmu", },
-       { .compatible = "samsung,exynos7-tmu", },
-       { /* sentinel */ },
+       {
+               .compatible = "samsung,exynos3250-tmu",
+               .data = (const void *)SOC_ARCH_EXYNOS3250,
+       }, {
+               .compatible = "samsung,exynos4210-tmu",
+               .data = (const void *)SOC_ARCH_EXYNOS4210,
+       }, {
+               .compatible = "samsung,exynos4412-tmu",
+               .data = (const void *)SOC_ARCH_EXYNOS4412,
+       }, {
+               .compatible = "samsung,exynos5250-tmu",
+               .data = (const void *)SOC_ARCH_EXYNOS5250,
+       }, {
+               .compatible = "samsung,exynos5260-tmu",
+               .data = (const void *)SOC_ARCH_EXYNOS5260,
+       }, {
+               .compatible = "samsung,exynos5420-tmu",
+               .data = (const void *)SOC_ARCH_EXYNOS5420,
+       }, {
+               .compatible = "samsung,exynos5420-tmu-ext-triminfo",
+               .data = (const void *)SOC_ARCH_EXYNOS5420_TRIMINFO,
+       }, {
+               .compatible = "samsung,exynos5433-tmu",
+               .data = (const void *)SOC_ARCH_EXYNOS5433,
+       }, {
+               .compatible = "samsung,exynos7-tmu",
+               .data = (const void *)SOC_ARCH_EXYNOS7,
+       },
+       { },
 };
 MODULE_DEVICE_TABLE(of, exynos_tmu_match);
 
-static int exynos_of_get_soc_type(struct device_node *np)
-{
-       if (of_device_is_compatible(np, "samsung,exynos3250-tmu"))
-               return SOC_ARCH_EXYNOS3250;
-       else if (of_device_is_compatible(np, "samsung,exynos4210-tmu"))
-               return SOC_ARCH_EXYNOS4210;
-       else if (of_device_is_compatible(np, "samsung,exynos4412-tmu"))
-               return SOC_ARCH_EXYNOS4412;
-       else if (of_device_is_compatible(np, "samsung,exynos5250-tmu"))
-               return SOC_ARCH_EXYNOS5250;
-       else if (of_device_is_compatible(np, "samsung,exynos5260-tmu"))
-               return SOC_ARCH_EXYNOS5260;
-       else if (of_device_is_compatible(np, "samsung,exynos5420-tmu"))
-               return SOC_ARCH_EXYNOS5420;
-       else if (of_device_is_compatible(np,
-                                        "samsung,exynos5420-tmu-ext-triminfo"))
-               return SOC_ARCH_EXYNOS5420_TRIMINFO;
-       else if (of_device_is_compatible(np, "samsung,exynos5433-tmu"))
-               return SOC_ARCH_EXYNOS5433;
-       else if (of_device_is_compatible(np, "samsung,exynos5440-tmu"))
-               return SOC_ARCH_EXYNOS5440;
-       else if (of_device_is_compatible(np, "samsung,exynos7-tmu"))
-               return SOC_ARCH_EXYNOS7;
-
-       return -EINVAL;
-}
-
-static int exynos_of_sensor_conf(struct device_node *np,
-                                struct exynos_tmu_platform_data *pdata)
-{
-       u32 value;
-       int ret;
-
-       of_node_get(np);
-
-       ret = of_property_read_u32(np, "samsung,tmu_gain", &value);
-       pdata->gain = (u8)value;
-       of_property_read_u32(np, "samsung,tmu_reference_voltage", &value);
-       pdata->reference_voltage = (u8)value;
-       of_property_read_u32(np, "samsung,tmu_noise_cancel_mode", &value);
-       pdata->noise_cancel_mode = (u8)value;
-
-       of_property_read_u32(np, "samsung,tmu_efuse_value",
-                            &pdata->efuse_value);
-       of_property_read_u32(np, "samsung,tmu_min_efuse_value",
-                            &pdata->min_efuse_value);
-       of_property_read_u32(np, "samsung,tmu_max_efuse_value",
-                            &pdata->max_efuse_value);
-
-       of_property_read_u32(np, "samsung,tmu_first_point_trim", &value);
-       pdata->first_point_trim = (u8)value;
-       of_property_read_u32(np, "samsung,tmu_second_point_trim", &value);
-       pdata->second_point_trim = (u8)value;
-       of_property_read_u32(np, "samsung,tmu_default_temp_offset", &value);
-       pdata->default_temp_offset = (u8)value;
-
-       of_property_read_u32(np, "samsung,tmu_cal_type", &pdata->cal_type);
-
-       of_node_put(np);
-       return 0;
-}
-
 static int exynos_map_dt_data(struct platform_device *pdev)
 {
        struct exynos_tmu_data *data = platform_get_drvdata(pdev);
-       struct exynos_tmu_platform_data *pdata;
        struct resource res;
 
        if (!data || !pdev->dev.of_node)
@@ -1211,23 +910,22 @@ static int exynos_map_dt_data(struct platform_device *pdev)
                return -EADDRNOTAVAIL;
        }
 
-       pdata = devm_kzalloc(&pdev->dev,
-                            sizeof(struct exynos_tmu_platform_data),
-                            GFP_KERNEL);
-       if (!pdata)
-               return -ENOMEM;
-
-       exynos_of_sensor_conf(pdev->dev.of_node, pdata);
-       data->pdata = pdata;
-       data->soc = exynos_of_get_soc_type(pdev->dev.of_node);
+       data->soc = (enum soc_type)of_device_get_match_data(&pdev->dev);
 
        switch (data->soc) {
        case SOC_ARCH_EXYNOS4210:
+               data->tmu_set_trip_temp = exynos4210_tmu_set_trip_temp;
+               data->tmu_set_trip_hyst = exynos4210_tmu_set_trip_hyst;
                data->tmu_initialize = exynos4210_tmu_initialize;
                data->tmu_control = exynos4210_tmu_control;
                data->tmu_read = exynos4210_tmu_read;
                data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
                data->ntrip = 4;
+               data->gain = 15;
+               data->reference_voltage = 7;
+               data->efuse_value = 55;
+               data->min_efuse_value = 40;
+               data->max_efuse_value = 100;
                break;
        case SOC_ARCH_EXYNOS3250:
        case SOC_ARCH_EXYNOS4412:
@@ -1235,48 +933,69 @@ static int exynos_map_dt_data(struct platform_device *pdev)
        case SOC_ARCH_EXYNOS5260:
        case SOC_ARCH_EXYNOS5420:
        case SOC_ARCH_EXYNOS5420_TRIMINFO:
+               data->tmu_set_trip_temp = exynos4412_tmu_set_trip_temp;
+               data->tmu_set_trip_hyst = exynos4412_tmu_set_trip_hyst;
                data->tmu_initialize = exynos4412_tmu_initialize;
                data->tmu_control = exynos4210_tmu_control;
                data->tmu_read = exynos4412_tmu_read;
                data->tmu_set_emulation = exynos4412_tmu_set_emulation;
                data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
                data->ntrip = 4;
+               data->gain = 8;
+               data->reference_voltage = 16;
+               data->efuse_value = 55;
+               if (data->soc != SOC_ARCH_EXYNOS5420 &&
+                   data->soc != SOC_ARCH_EXYNOS5420_TRIMINFO)
+                       data->min_efuse_value = 40;
+               else
+                       data->min_efuse_value = 0;
+               data->max_efuse_value = 100;
                break;
        case SOC_ARCH_EXYNOS5433:
+               data->tmu_set_trip_temp = exynos5433_tmu_set_trip_temp;
+               data->tmu_set_trip_hyst = exynos5433_tmu_set_trip_hyst;
                data->tmu_initialize = exynos5433_tmu_initialize;
                data->tmu_control = exynos5433_tmu_control;
                data->tmu_read = exynos4412_tmu_read;
                data->tmu_set_emulation = exynos4412_tmu_set_emulation;
                data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
                data->ntrip = 8;
-               break;
-       case SOC_ARCH_EXYNOS5440:
-               data->tmu_initialize = exynos5440_tmu_initialize;
-               data->tmu_control = exynos5440_tmu_control;
-               data->tmu_read = exynos5440_tmu_read;
-               data->tmu_set_emulation = exynos5440_tmu_set_emulation;
-               data->tmu_clear_irqs = exynos5440_tmu_clear_irqs;
-               data->ntrip = 4;
+               data->gain = 8;
+               if (res.start == EXYNOS5433_G3D_BASE)
+                       data->reference_voltage = 23;
+               else
+                       data->reference_voltage = 16;
+               data->efuse_value = 75;
+               data->min_efuse_value = 40;
+               data->max_efuse_value = 150;
                break;
        case SOC_ARCH_EXYNOS7:
+               data->tmu_set_trip_temp = exynos7_tmu_set_trip_temp;
+               data->tmu_set_trip_hyst = exynos7_tmu_set_trip_hyst;
                data->tmu_initialize = exynos7_tmu_initialize;
                data->tmu_control = exynos7_tmu_control;
                data->tmu_read = exynos7_tmu_read;
                data->tmu_set_emulation = exynos4412_tmu_set_emulation;
                data->tmu_clear_irqs = exynos4210_tmu_clear_irqs;
                data->ntrip = 8;
+               data->gain = 9;
+               data->reference_voltage = 17;
+               data->efuse_value = 75;
+               data->min_efuse_value = 15;
+               data->max_efuse_value = 100;
                break;
        default:
                dev_err(&pdev->dev, "Platform not supported\n");
                return -EINVAL;
        }
 
+       data->cal_type = TYPE_ONE_POINT_TRIMMING;
+
        /*
         * Check if the TMU shares some registers and then try to map the
         * memory of common registers.
         */
-       if (data->soc != SOC_ARCH_EXYNOS5420_TRIMINFO &&
-           data->soc != SOC_ARCH_EXYNOS5440)
+       if (data->soc != SOC_ARCH_EXYNOS5420_TRIMINFO)
                return 0;
 
        if (of_address_to_resource(pdev->dev.of_node, 1, &res)) {
diff --git a/drivers/thermal/samsung/exynos_tmu.h b/drivers/thermal/samsung/exynos_tmu.h
deleted file mode 100644 (file)
index 5149c2a..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * exynos_tmu.h - Samsung EXYNOS TMU (Thermal Management Unit)
- *
- *  Copyright (C) 2011 Samsung Electronics
- *  Donggeun Kim <dg77.kim@samsung.com>
- *  Amit Daniel Kachhap <amit.daniel@samsung.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- */
-
-#ifndef _EXYNOS_TMU_H
-#define _EXYNOS_TMU_H
-#include <linux/cpu_cooling.h>
-#include <dt-bindings/thermal/thermal_exynos.h>
-
-enum soc_type {
-       SOC_ARCH_EXYNOS3250 = 1,
-       SOC_ARCH_EXYNOS4210,
-       SOC_ARCH_EXYNOS4412,
-       SOC_ARCH_EXYNOS5250,
-       SOC_ARCH_EXYNOS5260,
-       SOC_ARCH_EXYNOS5420,
-       SOC_ARCH_EXYNOS5420_TRIMINFO,
-       SOC_ARCH_EXYNOS5433,
-       SOC_ARCH_EXYNOS5440,
-       SOC_ARCH_EXYNOS7,
-};
-
-/**
- * struct exynos_tmu_platform_data
- * @gain: gain of amplifier in the positive-TC generator block
- *     0 < gain <= 15
- * @reference_voltage: reference voltage of amplifier
- *     in the positive-TC generator block
- *     0 < reference_voltage <= 31
- * @noise_cancel_mode: noise cancellation mode
- *     000, 100, 101, 110 and 111 can be different modes
- * @type: determines the type of SOC
- * @efuse_value: platform defined fuse value
- * @min_efuse_value: minimum valid trimming data
- * @max_efuse_value: maximum valid trimming data
- * @default_temp_offset: default temperature offset in case of no trimming
- * @cal_type: calibration type for temperature
- *
- * This structure is required for configuration of exynos_tmu driver.
- */
-struct exynos_tmu_platform_data {
-       u8 gain;
-       u8 reference_voltage;
-       u8 noise_cancel_mode;
-
-       u32 efuse_value;
-       u32 min_efuse_value;
-       u32 max_efuse_value;
-       u8 first_point_trim;
-       u8 second_point_trim;
-       u8 default_temp_offset;
-
-       enum soc_type type;
-       u32 cal_type;
-};
-
-#endif /* _EXYNOS_TMU_H */
index 455b58ce26527368e06567d86d7982dfa99dcbcd..ed28110a3535e6780eb62b842cd620616834121f 100644 (file)
@@ -240,31 +240,6 @@ struct tegra_soctherm {
        struct dentry *debugfs_dir;
 };
 
-/**
- * clk_writel() - writes a value to a CAR register
- * @ts: pointer to a struct tegra_soctherm
- * @v: the value to write
- * @reg: the register offset
- *
- * Writes @v to @reg.  No return value.
- */
-static inline void clk_writel(struct tegra_soctherm *ts, u32 value, u32 reg)
-{
-       writel(value, (ts->clk_regs + reg));
-}
-
-/**
- * clk_readl() - reads specified register from CAR IP block
- * @ts: pointer to a struct tegra_soctherm
- * @reg: register address to be read
- *
- * Return: the value of the register
- */
-static inline u32 clk_readl(struct tegra_soctherm *ts, u32 reg)
-{
-       return readl(ts->clk_regs + reg);
-}
-
 /**
  * ccroc_writel() - writes a value to a CCROC register
  * @ts: pointer to a struct tegra_soctherm
@@ -926,7 +901,7 @@ static int throt_set_cdev_state(struct thermal_cooling_device *cdev,
        return 0;
 }
 
-static struct thermal_cooling_device_ops throt_cooling_ops = {
+static const struct thermal_cooling_device_ops throt_cooling_ops = {
        .get_max_state = throt_get_cdev_max_state,
        .get_cur_state = throt_get_cdev_cur_state,
        .set_cur_state = throt_set_cdev_state,
@@ -1207,9 +1182,9 @@ static void tegra_soctherm_throttle(struct device *dev)
        } else {
                writel(v, ts->regs + THROT_GLOBAL_CFG);
 
-               v = clk_readl(ts, CAR_SUPER_CCLKG_DIVIDER);
+               v = readl(ts->clk_regs + CAR_SUPER_CCLKG_DIVIDER);
                v = REG_SET_MASK(v, CDIVG_USE_THERM_CONTROLS_MASK, 1);
-               clk_writel(ts, v, CAR_SUPER_CCLKG_DIVIDER);
+               writel(v, ts->clk_regs + CAR_SUPER_CCLKG_DIVIDER);
        }
 
        /* initialize stats collection */
@@ -1343,8 +1318,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
                return PTR_ERR(tegra->clock_soctherm);
        }
 
-       tegra->calib = devm_kzalloc(&pdev->dev,
-                                   sizeof(u32) * soc->num_tsensors,
+       tegra->calib = devm_kcalloc(&pdev->dev,
+                                   soc->num_tsensors, sizeof(u32),
                                    GFP_KERNEL);
        if (!tegra->calib)
                return -ENOMEM;
@@ -1363,8 +1338,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev)
                        return err;
        }
 
-       tegra->thermctl_tzs = devm_kzalloc(&pdev->dev,
-                                          sizeof(*z) * soc->num_ttgs,
+       tegra->thermctl_tzs = devm_kcalloc(&pdev->dev,
+                                          soc->num_ttgs, sizeof(*z),
                                           GFP_KERNEL);
        if (!tegra->thermctl_tzs)
                return -ENOMEM;
index 46d3005335c7485077dbf31951ba67273e3ef6e3..bf1c628d4a7ad3f78454946b736c4bacd7d3dcfb 100644 (file)
@@ -87,8 +87,9 @@ static int gadc_thermal_read_linear_lookup_table(struct device *dev,
                return -EINVAL;
        }
 
-       gti->lookup_table = devm_kzalloc(dev, sizeof(*gti->lookup_table) *
-                                        ntable, GFP_KERNEL);
+       gti->lookup_table = devm_kcalloc(dev,
+                                        ntable, sizeof(*gti->lookup_table),
+                                        GFP_KERNEL);
        if (!gti->lookup_table)
                return -ENOMEM;
 
index d64325e078db81803ae5f49d33315e024a3620fd..6ab982309e6a04cd3c933850d34aabaaf3dd60e4 100644 (file)
@@ -1,13 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *  thermal.c - Generic Thermal Management Sysfs support.
  *
  *  Copyright (C) 2008 Intel Corp
  *  Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com>
  *  Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -736,7 +733,7 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
        sysfs_attr_init(&dev->attr.attr);
        dev->attr.attr.name = dev->attr_name;
        dev->attr.attr.mode = 0444;
-       dev->attr.show = thermal_cooling_device_trip_point_show;
+       dev->attr.show = trip_point_show;
        result = device_create_file(&tz->device, &dev->attr);
        if (result)
                goto remove_symbol_link;
@@ -745,8 +742,8 @@ int thermal_zone_bind_cooling_device(struct thermal_zone_device *tz,
        sysfs_attr_init(&dev->weight_attr.attr);
        dev->weight_attr.attr.name = dev->weight_attr_name;
        dev->weight_attr.attr.mode = S_IWUSR | S_IRUGO;
-       dev->weight_attr.show = thermal_cooling_device_weight_show;
-       dev->weight_attr.store = thermal_cooling_device_weight_store;
+       dev->weight_attr.show = weight_show;
+       dev->weight_attr.store = weight_store;
        result = device_create_file(&tz->device, &dev->weight_attr);
        if (result)
                goto remove_trip_file;
index 5e4150261500a72b201773347fa1aa7628d27f61..0df190ed82a70b342eea53ecca8407e3179df657 100644 (file)
@@ -1,24 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *  thermal_core.h
  *
  *  Copyright (C) 2012  Intel Corp
  *  Author: Durgadoss R <durgadoss.r@intel.com>
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
 #ifndef __THERMAL_CORE_H__
@@ -75,15 +60,10 @@ void thermal_zone_destroy_device_groups(struct thermal_zone_device *);
 void thermal_cooling_device_setup_sysfs(struct thermal_cooling_device *);
 void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev);
 /* used only at binding time */
-ssize_t
-thermal_cooling_device_trip_point_show(struct device *,
-                                      struct device_attribute *, char *);
-ssize_t thermal_cooling_device_weight_show(struct device *,
-                                          struct device_attribute *, char *);
-
-ssize_t thermal_cooling_device_weight_store(struct device *,
-                                           struct device_attribute *,
-                                           const char *, size_t);
+ssize_t trip_point_show(struct device *, struct device_attribute *, char *);
+ssize_t weight_show(struct device *, struct device_attribute *, char *);
+ssize_t weight_store(struct device *, struct device_attribute *, const char *,
+                    size_t);
 
 #ifdef CONFIG_THERMAL_STATISTICS
 void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
index eb03d7e099bb666247c75fa3dadcc0a81366c557..2ba756af76b7ff4ee45b0024a4d575ed928694de 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *  thermal_helpers.c - helper functions to handle thermal devices
  *
@@ -7,10 +8,6 @@
  *  Copyright (C) 2008 Intel Corp
  *  Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com>
  *  Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index c4a508a124dc2b9dca9e7147c3d8dedc69c5016d..11278836ed12adc2e427265342e3e727130b12e8 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *  thermal_hwmon.c - Generic Thermal Management hwmon support.
  *
@@ -8,22 +9,6 @@
  *
  *  Copyright (C) 2013 Texas Instruments
  *  Copyright (C) 2013 Eduardo Valentin <eduardo.valentin@ti.com>
- *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 #include <linux/hwmon.h>
 #include <linux/thermal.h>
index c798fdb2ae436872a6f3dd75842a8292ced3beae..019f6f88224e951a65bb0cfb58baf7c9a19855e4 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *  thermal_hwmon.h - Generic Thermal Management hwmon support.
  *
@@ -8,22 +9,6 @@
  *
  *  Copyright (C) 2013 Texas Instruments
  *  Copyright (C) 2013 Eduardo Valentin <eduardo.valentin@ti.com>
- *  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 #ifndef __THERMAL_HWMON_H__
 #define __THERMAL_HWMON_H__
index 23b5e0a709b077864136a0b5a17afdc69557e48b..2241ceae7d7f15eaf09fa89ae2423ad470dd839f 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  *  thermal.c - sysfs interface of thermal devices
  *
@@ -7,10 +8,6 @@
  *  Copyright (C) 2008 Intel Corp
  *  Copyright (C) 2008 Zhang Rui <rui.zhang@intel.com>
  *  Copyright (C) 2008 Sujith Thomas <sujith.thomas@intel.com>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
@@ -381,7 +378,7 @@ sustainable_power_store(struct device *dev, struct device_attribute *devattr,
                                                                        \
                return count;                                           \
        }                                                               \
-       static DEVICE_ATTR(name, S_IWUSR | S_IRUGO, name##_show, name##_store)
+       static DEVICE_ATTR_RW(name)
 
 create_s32_tzp_attr(k_po);
 create_s32_tzp_attr(k_pu);
@@ -668,17 +665,15 @@ void thermal_zone_destroy_device_groups(struct thermal_zone_device *tz)
 
 /* sys I/F for cooling device */
 static ssize_t
-thermal_cooling_device_type_show(struct device *dev,
-                                struct device_attribute *attr, char *buf)
+cdev_type_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct thermal_cooling_device *cdev = to_cooling_device(dev);
 
        return sprintf(buf, "%s\n", cdev->type);
 }
 
-static ssize_t
-thermal_cooling_device_max_state_show(struct device *dev,
-                                     struct device_attribute *attr, char *buf)
+static ssize_t max_state_show(struct device *dev, struct device_attribute *attr,
+                             char *buf)
 {
        struct thermal_cooling_device *cdev = to_cooling_device(dev);
        unsigned long state;
@@ -690,9 +685,8 @@ thermal_cooling_device_max_state_show(struct device *dev,
        return sprintf(buf, "%ld\n", state);
 }
 
-static ssize_t
-thermal_cooling_device_cur_state_show(struct device *dev,
-                                     struct device_attribute *attr, char *buf)
+static ssize_t cur_state_show(struct device *dev, struct device_attribute *attr,
+                             char *buf)
 {
        struct thermal_cooling_device *cdev = to_cooling_device(dev);
        unsigned long state;
@@ -705,9 +699,8 @@ thermal_cooling_device_cur_state_show(struct device *dev,
 }
 
 static ssize_t
-thermal_cooling_device_cur_state_store(struct device *dev,
-                                      struct device_attribute *attr,
-                                      const char *buf, size_t count)
+cur_state_store(struct device *dev, struct device_attribute *attr,
+               const char *buf, size_t count)
 {
        struct thermal_cooling_device *cdev = to_cooling_device(dev);
        unsigned long state;
@@ -726,13 +719,10 @@ thermal_cooling_device_cur_state_store(struct device *dev,
        return count;
 }
 
-static struct device_attribute dev_attr_cdev_type =
-__ATTR(type, 0444, thermal_cooling_device_type_show, NULL);
-static DEVICE_ATTR(max_state, 0444,
-                  thermal_cooling_device_max_state_show, NULL);
-static DEVICE_ATTR(cur_state, 0644,
-                  thermal_cooling_device_cur_state_show,
-                  thermal_cooling_device_cur_state_store);
+static struct device_attribute
+dev_attr_cdev_type = __ATTR(type, 0444, cdev_type_show, NULL);
+static DEVICE_ATTR_RO(max_state);
+static DEVICE_ATTR_RW(cur_state);
 
 static struct attribute *cooling_device_attrs[] = {
        &dev_attr_cdev_type.attr,
@@ -791,10 +781,8 @@ void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev,
        spin_unlock(&stats->lock);
 }
 
-static ssize_t
-thermal_cooling_device_total_trans_show(struct device *dev,
-                                       struct device_attribute *attr,
-                                       char *buf)
+static ssize_t total_trans_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
 {
        struct thermal_cooling_device *cdev = to_cooling_device(dev);
        struct cooling_dev_stats *stats = cdev->stats;
@@ -808,9 +796,8 @@ thermal_cooling_device_total_trans_show(struct device *dev,
 }
 
 static ssize_t
-thermal_cooling_device_time_in_state_show(struct device *dev,
-                                         struct device_attribute *attr,
-                                         char *buf)
+time_in_state_ms_show(struct device *dev, struct device_attribute *attr,
+                     char *buf)
 {
        struct thermal_cooling_device *cdev = to_cooling_device(dev);
        struct cooling_dev_stats *stats = cdev->stats;
@@ -830,9 +817,8 @@ thermal_cooling_device_time_in_state_show(struct device *dev,
 }
 
 static ssize_t
-thermal_cooling_device_reset_store(struct device *dev,
-                                  struct device_attribute *attr,
-                                  const char *buf, size_t count)
+reset_store(struct device *dev, struct device_attribute *attr, const char *buf,
+           size_t count)
 {
        struct thermal_cooling_device *cdev = to_cooling_device(dev);
        struct cooling_dev_stats *stats = cdev->stats;
@@ -853,10 +839,8 @@ thermal_cooling_device_reset_store(struct device *dev,
        return count;
 }
 
-static ssize_t
-thermal_cooling_device_trans_table_show(struct device *dev,
-                                       struct device_attribute *attr,
-                                       char *buf)
+static ssize_t trans_table_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
 {
        struct thermal_cooling_device *cdev = to_cooling_device(dev);
        struct cooling_dev_stats *stats = cdev->stats;
@@ -899,13 +883,10 @@ thermal_cooling_device_trans_table_show(struct device *dev,
        return len;
 }
 
-static DEVICE_ATTR(total_trans, 0444, thermal_cooling_device_total_trans_show,
-                  NULL);
-static DEVICE_ATTR(time_in_state_ms, 0444,
-                  thermal_cooling_device_time_in_state_show, NULL);
-static DEVICE_ATTR(reset, 0200, NULL, thermal_cooling_device_reset_store);
-static DEVICE_ATTR(trans_table, 0444,
-                  thermal_cooling_device_trans_table_show, NULL);
+static DEVICE_ATTR_RO(total_trans);
+static DEVICE_ATTR_RO(time_in_state_ms);
+static DEVICE_ATTR_WO(reset);
+static DEVICE_ATTR_RO(trans_table);
 
 static struct attribute *cooling_device_stats_attrs[] = {
        &dev_attr_total_trans.attr,
@@ -980,8 +961,7 @@ void thermal_cooling_device_destroy_sysfs(struct thermal_cooling_device *cdev)
 
 /* these helper will be used only at the time of bindig */
 ssize_t
-thermal_cooling_device_trip_point_show(struct device *dev,
-                                      struct device_attribute *attr, char *buf)
+trip_point_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct thermal_instance *instance;
 
@@ -995,8 +975,7 @@ thermal_cooling_device_trip_point_show(struct device *dev,
 }
 
 ssize_t
-thermal_cooling_device_weight_show(struct device *dev,
-                                  struct device_attribute *attr, char *buf)
+weight_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct thermal_instance *instance;
 
@@ -1005,10 +984,8 @@ thermal_cooling_device_weight_show(struct device *dev,
        return sprintf(buf, "%d\n", instance->weight);
 }
 
-ssize_t
-thermal_cooling_device_weight_store(struct device *dev,
-                                   struct device_attribute *attr,
-                                   const char *buf, size_t count)
+ssize_t weight_store(struct device *dev, struct device_attribute *attr,
+                    const char *buf, size_t count)
 {
        struct thermal_instance *instance;
        int ret, weight;
index cd9a304fb571ce7749aebad6d93606b4fce503de..6ac037098b5207b3de1b2e430fe27c33f354decf 100644 (file)
@@ -310,7 +310,7 @@ omap5430_adc_to_temp[
        119800, 120200, 120600, 121000, 121400, 121800, 122400, 122600, 123000,
        123400,
        /* Index 940 - 945 */
-       123800, 1242000, 124600, 124900, 125000, 125000,
+       123800, 124200, 124600, 124900, 125000, 125000,
 };
 
 /* OMAP54xx ES2.0 data */
index 95704732f76050d8c3f3b6f83bc8e4cee08f189a..55477d74d591149ca0db0175f581e575fc433d64 100644 (file)
@@ -365,6 +365,10 @@ static const struct of_device_id uniphier_tm_dt_ids[] = {
                .compatible = "socionext,uniphier-ld20-thermal",
                .data       = &uniphier_ld20_tm_data,
        },
+       {
+               .compatible = "socionext,uniphier-pxs3-thermal",
+               .data       = &uniphier_ld20_tm_data,
+       },
        { /* sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, uniphier_tm_dt_ids);
index 1a6c88b10a396e37ee8ff7a429752fdffd4b9a50..1ef937d799e4f3d200dbfe9fb5a3dc2b08fd1d21 100644 (file)
@@ -516,7 +516,8 @@ static int __init pkg_temp_thermal_init(void)
                return -ENODEV;
 
        max_packages = topology_max_packages();
-       packages = kzalloc(max_packages * sizeof(struct pkg_device *), GFP_KERNEL);
+       packages = kcalloc(max_packages, sizeof(struct pkg_device *),
+                          GFP_KERNEL);
        if (!packages)
                return -ENOMEM;
 
index 47ac56817c43f53ff78faa5c12b79a3e8788d4ed..eea4049b5dcc67836ec99f2f25faa8c4a24ccd4d 100644 (file)
@@ -754,7 +754,7 @@ static int __init ehv_bc_init(void)
         * array, then you can use pointer math (e.g. "bc - bcs") to get its
         * tty index.
         */
-       bcs = kzalloc(count * sizeof(struct ehv_bc_data), GFP_KERNEL);
+       bcs = kcalloc(count, sizeof(struct ehv_bc_data), GFP_KERNEL);
        if (!bcs)
                return -ENOMEM;
 
index 1c1bd0afcd489e5eef35d6c4b32a8d018e1cc25c..37caba7c3affda7c32a76513f5a31518ca3572a8 100644 (file)
@@ -245,8 +245,9 @@ static int goldfish_tty_create_driver(void)
        int ret;
        struct tty_driver *tty;
 
-       goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) *
-                               goldfish_tty_line_count, GFP_KERNEL);
+       goldfish_ttys = kcalloc(goldfish_tty_line_count,
+                               sizeof(*goldfish_ttys),
+                               GFP_KERNEL);
        if (goldfish_ttys == NULL) {
                ret = -ENOMEM;
                goto err_alloc_goldfish_ttys_failed;
index a74680729825ee1fba8f4c85fa2c8f3ef231650b..2af1e5751bd6302463a397cedd68bdccb23d8313 100644 (file)
@@ -1252,7 +1252,7 @@ static int hvc_iucv_setup_filter(const char *val)
        if (size > MAX_VMID_FILTER)
                return -ENOSPC;
 
-       array = kzalloc(size * 8, GFP_KERNEL);
+       array = kcalloc(size, 8, GFP_KERNEL);
        if (!array)
                return -ENOMEM;
 
index 1db1d97e72e7ee13c8bb1d013dcf5e5ceaf261b4..cb4db1b3ca3c0daab51bbc466789dc5d5bc0710f 100644 (file)
@@ -1441,7 +1441,8 @@ static int hvcs_alloc_index_list(int n)
 {
        int i;
 
-       hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL);
+       hvcs_index_list = kmalloc_array(n, sizeof(hvcs_index_count),
+                                       GFP_KERNEL);
        if (!hvcs_index_list)
                return -ENOMEM;
        hvcs_index_count = n;
index bdd3027ef01b6d4dbfdf9cd40f2923410cd82a8f..8d96e86966f1b5ddf2bb43067a4899ee1d4653f4 100644 (file)
@@ -1477,7 +1477,7 @@ static int load_firmware(struct pci_dev *pdev,
                        goto errrelfw;
                }
 
-               data = kmalloc(word_count * 2, GFP_KERNEL);
+               data = kmalloc_array(word_count, 2, GFP_KERNEL);
                if (data == NULL) {
                        dev_err(&pdev->dev, "Card%d, firmware upload "
                                "failed, not enough memory\n", index + 1);
index 55b3eff148b18550215087fd1a862edb94ede6f2..8e4428725848eb0e9917af79123442d6ac751cf2 100644 (file)
@@ -2738,8 +2738,9 @@ static int atmel_serial_probe(struct platform_device *pdev)
 
        if (!atmel_use_pdc_rx(&atmel_port->uart)) {
                ret = -ENOMEM;
-               data = kmalloc(sizeof(struct atmel_uart_char)
-                               * ATMEL_SERIAL_RINGSIZE, GFP_KERNEL);
+               data = kmalloc_array(ATMEL_SERIAL_RINGSIZE,
+                                    sizeof(struct atmel_uart_char),
+                                    GFP_KERNEL);
                if (!data)
                        goto err_alloc_ring;
                atmel_port->rx_ring.buf = data;
index 760d5dd0aada2e34b198c70727741c671ed0ad16..cb85002a10d8d16c9c0b4ec5bc70c1994822e25a 100644 (file)
@@ -991,7 +991,7 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv)
 
        priv->tx_dma_use = 1;
 
-       priv->sg_tx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC);
+       priv->sg_tx_p = kcalloc(num, sizeof(struct scatterlist), GFP_ATOMIC);
        if (!priv->sg_tx_p) {
                dev_err(priv->port.dev, "%s:kzalloc Failed\n", __func__);
                return 0;
index 520b43b235430af110086e673aa304419a810551..5690c09cc0417f3a34d005b804b08e6808ff1d28 100644 (file)
@@ -774,7 +774,7 @@ static int rp2_probe(struct pci_dev *pdev,
 
        rp2_init_card(card);
 
-       ports = devm_kzalloc(&pdev->dev, sizeof(*ports) * card->n_ports,
+       ports = devm_kcalloc(&pdev->dev, card->n_ports, sizeof(*ports),
                             GFP_KERNEL);
        if (!ports)
                return -ENOMEM;
index 890b8832aff20e053567654299379e9a7ec19d84..9c14a453f73c0e8365610809ba742cdd3085311b 100644 (file)
@@ -2445,7 +2445,7 @@ int uart_register_driver(struct uart_driver *drv)
         * Maybe we should be using a slab cache for this, especially if
         * we have a large number of ports to handle.
         */
-       drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
+       drv->state = kcalloc(drv->nr, sizeof(struct uart_state), GFP_KERNEL);
        if (!drv->state)
                goto out;
 
index b93d0225f8c957f97ea1e5ba42fda53829ee54f0..72131b5e132eba262ef67d8bf1e94f18ab05fdda 100644 (file)
@@ -1125,8 +1125,9 @@ static int __init sunsab_init(void)
        }
 
        if (num_channels) {
-               sunsab_ports = kzalloc(sizeof(struct uart_sunsab_port) *
-                                      num_channels, GFP_KERNEL);
+               sunsab_ports = kcalloc(num_channels,
+                                      sizeof(struct uart_sunsab_port),
+                                      GFP_KERNEL);
                if (!sunsab_ports)
                        return -ENOMEM;
 
index 7c838b90a31d636865ce99a84466967d57b777aa..aba59521ad488973d0bee75f88a9d2a0f4f76e00 100644 (file)
@@ -867,8 +867,13 @@ static ssize_t tty_read(struct file *file, char __user *buf, size_t count,
                i = -EIO;
        tty_ldisc_deref(ld);
 
-       if (i > 0)
-               tty_update_time(&inode->i_atime);
+       if (i > 0) {
+               struct timespec ts;
+
+               ts = timespec64_to_timespec(inode->i_atime);
+               tty_update_time(&ts);
+               inode->i_atime = timespec_to_timespec64(ts);
+       }
 
        return i;
 }
@@ -969,7 +974,11 @@ static inline ssize_t do_tty_write(
                cond_resched();
        }
        if (written) {
-               tty_update_time(&file_inode(file)->i_mtime);
+               struct timespec ts;
+
+               ts = timespec64_to_timespec(file_inode(file)->i_mtime);
+               tty_update_time(&ts);
+               file_inode(file)->i_mtime = timespec_to_timespec64(ts);
                ret = written;
        }
 out:
index 722a6690c70dc74fb3f13892d5c9eead4ed978c0..7c7ada0b3ea00d3b43cf4c12dcccc60257535186 100644 (file)
@@ -231,7 +231,7 @@ static void set_inverse_trans_unicode(struct vc_data *conp,
        q = p->inverse_trans_unicode;
        if (!q) {
                q = p->inverse_trans_unicode =
-                       kmalloc(MAX_GLYPH * sizeof(u16), GFP_KERNEL);
+                       kmalloc_array(MAX_GLYPH, sizeof(u16), GFP_KERNEL);
                if (!q)
                        return;
        }
@@ -479,7 +479,8 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos)
 
        p1 = p->uni_pgdir[n = unicode >> 11];
        if (!p1) {
-               p1 = p->uni_pgdir[n] = kmalloc(32*sizeof(u16 *), GFP_KERNEL);
+               p1 = p->uni_pgdir[n] = kmalloc_array(32, sizeof(u16 *),
+                                                    GFP_KERNEL);
                if (!p1) return -ENOMEM;
                for (i = 0; i < 32; i++)
                        p1[i] = NULL;
@@ -487,7 +488,7 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos)
 
        p2 = p1[n = (unicode >> 6) & 0x1f];
        if (!p2) {
-               p2 = p1[n] = kmalloc(64*sizeof(u16), GFP_KERNEL);
+               p2 = p1[n] = kmalloc_array(64, sizeof(u16), GFP_KERNEL);
                if (!p2) return -ENOMEM;
                memset(p2, 0xff, 64*sizeof(u16)); /* No glyphs for the characters (yet) */
        }
index 5d412df8e94372217726271c7f83e1f55444ae21..d5b4a2b44ab8a69d63f9fe768ac3dffa60d7e9c8 100644 (file)
@@ -1624,7 +1624,7 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
                struct kbdiacr *dia;
                int i;
 
-               dia = kmalloc(MAX_DIACR * sizeof(struct kbdiacr),
+               dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
                                                                GFP_KERNEL);
                if (!dia)
                        return -ENOMEM;
@@ -1657,7 +1657,7 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm)
                struct kbdiacrsuc __user *a = udp;
                void *buf;
 
-               buf = kmalloc(MAX_DIACR * sizeof(struct kbdiacruc),
+               buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
                                                                GFP_KERNEL);
                if (buf == NULL)
                        return -ENOMEM;
index 7851383fbd6c7d7cf567085be5165639b845092a..90ea1cc52b7aac91d6552ce161a16dc4036c3563 100644 (file)
@@ -280,7 +280,8 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t
 
        /* Allocate a new buffer before freeing the old one ... */
        multiplier = use_unicode ? 3 : 1;  /* chars can take up to 3 bytes */
-       bp = kmalloc(((sel_end-sel_start)/2+1)*multiplier, GFP_KERNEL);
+       bp = kmalloc_array((sel_end - sel_start) / 2 + 1, multiplier,
+                          GFP_KERNEL);
        if (!bp) {
                printk(KERN_WARNING "selection: kmalloc() failed\n");
                clear_selection();
index 31d5b1d3b5af69a7344653f83c4b07cc99293f12..91aea8823af55ff0e992df9c35e3555995ba14ba 100644 (file)
@@ -129,7 +129,7 @@ static int pruss_probe(struct platform_device *pdev)
        if (!gdev)
                return -ENOMEM;
 
-       gdev->info = kzalloc(sizeof(*p) * MAX_PRUSS_EVT, GFP_KERNEL);
+       gdev->info = kcalloc(MAX_PRUSS_EVT, sizeof(*p), GFP_KERNEL);
        if (!gdev->info) {
                kfree(gdev);
                return -ENOMEM;
index 76e16c5251b9ffe21771e90667184fced5a30867..476dcc5f2da3c3258b2635ab406d09acbd692966 100644 (file)
@@ -897,7 +897,7 @@ static int parse_usbdevfs_streams(struct usb_dev_state *ps,
        if (num_streams_ret && (num_streams < 2 || num_streams > 65536))
                return -EINVAL;
 
-       eps = kmalloc(num_eps * sizeof(*eps), GFP_KERNEL);
+       eps = kmalloc_array(num_eps, sizeof(*eps), GFP_KERNEL);
        if (!eps)
                return -ENOMEM;
 
@@ -1602,8 +1602,9 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb
        as->mem_usage = u;
 
        if (num_sgs) {
-               as->urb->sg = kmalloc(num_sgs * sizeof(struct scatterlist),
-                                     GFP_KERNEL);
+               as->urb->sg = kmalloc_array(num_sgs,
+                                           sizeof(struct scatterlist),
+                                           GFP_KERNEL);
                if (!as->urb->sg) {
                        ret = -ENOMEM;
                        goto error;
index 26c2438d288933c6818d1f36f28b3b9b35e88912..fcae521df29b8de4712e92de725c575f298f567a 100644 (file)
@@ -1376,7 +1376,7 @@ static int hub_configure(struct usb_hub *hub,
        dev_info(hub_dev, "%d port%s detected\n", maxchild,
                        (maxchild == 1) ? "" : "s");
 
-       hub->ports = kzalloc(maxchild * sizeof(struct usb_port *), GFP_KERNEL);
+       hub->ports = kcalloc(maxchild, sizeof(struct usb_port *), GFP_KERNEL);
        if (!hub->ports) {
                ret = -ENOMEM;
                goto fail;
index 7b137003c2be6a14910b9261d3bab28acc982053..1a15392326fca2354d8ad0dde0d0f6b098890854 100644 (file)
@@ -390,7 +390,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev,
        }
 
        /* initialize all the urbs we'll use */
-       io->urbs = kmalloc(io->entries * sizeof(*io->urbs), mem_flags);
+       io->urbs = kmalloc_array(io->entries, sizeof(*io->urbs), mem_flags);
        if (!io->urbs)
                goto nomem;
 
@@ -1824,8 +1824,8 @@ int usb_set_configuration(struct usb_device *dev, int configuration)
        n = nintf = 0;
        if (cp) {
                nintf = cp->desc.bNumInterfaces;
-               new_interfaces = kmalloc(nintf * sizeof(*new_interfaces),
-                               GFP_NOIO);
+               new_interfaces = kmalloc_array(nintf, sizeof(*new_interfaces),
+                                              GFP_NOIO);
                if (!new_interfaces)
                        return -ENOMEM;
 
index 1faefea16cecdb8320774eb4760d9524e7aec499..edaf0b6af4f0491ba192d346c29a792a06a85751 100644 (file)
@@ -5079,13 +5079,14 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg)
        dev_dbg(hsotg->dev, "hcfg=%08x\n", hcfg);
 
 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
-       hsotg->frame_num_array = kzalloc(sizeof(*hsotg->frame_num_array) *
-                                        FRAME_NUM_ARRAY_SIZE, GFP_KERNEL);
+       hsotg->frame_num_array = kcalloc(FRAME_NUM_ARRAY_SIZE,
+                                        sizeof(*hsotg->frame_num_array),
+                                        GFP_KERNEL);
        if (!hsotg->frame_num_array)
                goto error1;
-       hsotg->last_frame_num_array = kzalloc(
-                       sizeof(*hsotg->last_frame_num_array) *
-                       FRAME_NUM_ARRAY_SIZE, GFP_KERNEL);
+       hsotg->last_frame_num_array =
+               kcalloc(FRAME_NUM_ARRAY_SIZE,
+                       sizeof(*hsotg->last_frame_num_array), GFP_KERNEL);
        if (!hsotg->last_frame_num_array)
                goto error1;
 #endif
index 199d2570005051d34c3bee29da4230d4a3364804..dce9d12c7981afb1733be479e9daa43977bd218a 100644 (file)
@@ -1308,7 +1308,7 @@ ffs_sb_make_inode(struct super_block *sb, void *data,
        inode = new_inode(sb);
 
        if (likely(inode)) {
-               struct timespec ts = current_time(inode);
+               struct timespec64 ts = current_time(inode);
 
                inode->i_ino     = get_next_ino();
                inode->i_mode    = perms->mode;
index a4d99bf50f2f866d3ad1a2019dbfe0dce92f0d35..17147b8c771ef04024c2f203ee3636f9620d6f73 100644 (file)
@@ -2036,7 +2036,7 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev,
                udc->num_ep = usba_config_fifo_table(udc);
        }
 
-       eps = devm_kzalloc(&pdev->dev, sizeof(struct usba_ep) * udc->num_ep,
+       eps = devm_kcalloc(&pdev->dev, udc->num_ep, sizeof(struct usba_ep),
                           GFP_KERNEL);
        if (!eps)
                return ERR_PTR(-ENOMEM);
index 03149b9d7ea719748c9d153cc03d9d03dad9bd08..a4d9b5e1e50ea09747edc4b1bb0a4fadf7b440d8 100644 (file)
@@ -138,9 +138,9 @@ static int ep_bd_list_alloc(struct bdc_ep *ep)
                __func__, ep, num_tabs);
 
        /* Allocate memory for table array */
-       ep->bd_list.bd_table_array = kzalloc(
-                                       num_tabs * sizeof(struct bd_table *),
-                                       GFP_ATOMIC);
+       ep->bd_list.bd_table_array = kcalloc(num_tabs,
+                                            sizeof(struct bd_table *),
+                                            GFP_ATOMIC);
        if (!ep->bd_list.bd_table_array)
                return -ENOMEM;
 
index 9a3f7db26a5efb1569fd2a12261a7e8ae63d6923..be59309e848c335fafc8301eaec211f3fec9657e 100644 (file)
@@ -2246,7 +2246,7 @@ static int struct_udc_setup(struct fsl_udc *udc,
        pdata = dev_get_platdata(&pdev->dev);
        udc->phy_mode = pdata->phy_mode;
 
-       udc->eps = kzalloc(sizeof(struct fsl_ep) * udc->max_ep, GFP_KERNEL);
+       udc->eps = kcalloc(udc->max_ep, sizeof(struct fsl_ep), GFP_KERNEL);
        if (!udc->eps)
                return -1;
 
index 977ea1a02cf992a0abaa4af6b51c806a3aa2f2fa..7cf98c793e044724b2b9713866929367fce6f06b 100644 (file)
@@ -2427,7 +2427,8 @@ static int renesas_usb3_init_ep(struct renesas_usb3 *usb3, struct device *dev,
        if (usb3->num_usb3_eps > USB3_MAX_NUM_PIPES)
                usb3->num_usb3_eps = USB3_MAX_NUM_PIPES;
 
-       usb3->usb3_ep = devm_kzalloc(dev, sizeof(*usb3_ep) * usb3->num_usb3_eps,
+       usb3->usb3_ep = devm_kcalloc(dev,
+                                    usb3->num_usb3_eps, sizeof(*usb3_ep),
                                     GFP_KERNEL);
        if (!usb3->usb3_ep)
                return -ENOMEM;
index e56db44708bccd86ac43a870d51fc039224305c8..1d87295682b8ee17e5e697fd861620326fba53f7 100644 (file)
@@ -117,8 +117,9 @@ static struct ehci_tt *find_tt(struct usb_device *udev)
        if (utt->multi) {
                tt_index = utt->hcpriv;
                if (!tt_index) {                /* Create the index array */
-                       tt_index = kzalloc(utt->hub->maxchild *
-                                       sizeof(*tt_index), GFP_ATOMIC);
+                       tt_index = kcalloc(utt->hub->maxchild,
+                                          sizeof(*tt_index),
+                                          GFP_ATOMIC);
                        if (!tt_index)
                                return ERR_PTR(-ENOMEM);
                        utt->hcpriv = tt_index;
index 3a4e8f616751a85de8cac1632683af6936ac32c9..f3308ce2504389851f2591b2d90a4451ecfcc50f 100644 (file)
@@ -189,7 +189,7 @@ u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem,
                        goto err;
                }
 
-               buff = kmalloc(1028 * sizeof(*buff), GFP_KERNEL);
+               buff = kmalloc_array(1028, sizeof(*buff), GFP_KERNEL);
                if (!buff) {
                        kfree(pkt);
                        err_for = "buffer";
index 3a8bbfe43a8eaa25d947469a719ffd7abd44c085..6e3dad19d3696a78054bc809c25ef7c7d6d294a0 100644 (file)
@@ -741,8 +741,8 @@ static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd,
        if (urb_priv == NULL)
                return -ENOMEM;
 
-       urb_priv->isoc_td = kzalloc(
-               sizeof(struct td) * urb->number_of_packets, mem_flags);
+       urb_priv->isoc_td = kcalloc(urb->number_of_packets, sizeof(struct td),
+                                   mem_flags);
        if (urb_priv->isoc_td == NULL) {
                ret = -ENOMEM;
                goto alloc_td_failed;
index d3ee1f52aaab2dc42864fb1e3464fa1b8ff4fa4b..4f267dc93882a52579f265e9df0c442e6395531c 100644 (file)
@@ -492,7 +492,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf)
        char                    *next;
        unsigned                i;
 
-       seen = kmalloc(DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC);
+       seen = kmalloc_array(DBG_SCHED_LIMIT, sizeof(*seen), GFP_ATOMIC);
        if (!seen)
                return 0;
        seen_count = 0;
index 4fe74711938e2efe0e8ef105e03ee02cc1c9f503..acbd3d7b8828693f79a51f19ad70fb1aa4ade050 100644 (file)
@@ -2274,8 +2274,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags)
                xhci->hw_ports[i].hw_portnum = i;
        }
 
-       xhci->rh_bw = kzalloc_node(sizeof(*xhci->rh_bw)*num_ports, flags,
-                       dev_to_node(dev));
+       xhci->rh_bw = kcalloc_node(num_ports, sizeof(*xhci->rh_bw), flags,
+                                  dev_to_node(dev));
        if (!xhci->rh_bw)
                return -ENOMEM;
        for (i = 0; i < num_ports; i++) {
index 236a60f53099e042faa9d804f4c470b1d5b90ef1..c2e255f02a72b822b0d4fe996968abff9477fc5a 100644 (file)
@@ -695,7 +695,10 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
                dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n");
 
        dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);
-       dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL);
+       dev->ring_buffer =
+               kmalloc_array(ring_buffer_size,
+                             sizeof(size_t) + dev->interrupt_in_endpoint_size,
+                             GFP_KERNEL);
        if (!dev->ring_buffer)
                goto error;
        dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);
@@ -706,7 +709,9 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id *
                goto error;
        dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) :
                                                                         udev->descriptor.bMaxPacketSize0;
-       dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);
+       dev->interrupt_out_buffer =
+               kmalloc_array(write_buffer_size,
+                             dev->interrupt_out_endpoint_size, GFP_KERNEL);
        if (!dev->interrupt_out_buffer)
                goto error;
        dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
index a0d6e0af957c26346b64b713939b5f5f944c10ae..c4f017e1d17a0f09a6c73d58d67b0b98a3fa152b 100644 (file)
@@ -1243,7 +1243,7 @@ sisusbcon_font_set(struct vc_data *c, struct console_font *font,
        }
 
        if (!sisusb->font_backup)
-               sisusb->font_backup = vmalloc(charcount * 32);
+               sisusb->font_backup = vmalloc(array_size(charcount, 32));
 
        if (sisusb->font_backup) {
                memcpy(sisusb->font_backup, font->data, charcount * 32);
index 34e866ad4a81bfbf2fb90d5b904117735227b1e0..ad2c082bd0fb6bd657c1ebaccc2f49b5c5306425 100644 (file)
@@ -1024,7 +1024,8 @@ static long mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg
                        return -EINVAL;
 
                size = CHUNK_ALIGN(arg);
-               vec = kzalloc(sizeof(struct mon_pgmap) * (size / CHUNK_SIZE), GFP_KERNEL);
+               vec = kcalloc(size / CHUNK_SIZE, sizeof(struct mon_pgmap),
+                             GFP_KERNEL);
                if (vec == NULL) {
                        ret = -ENOMEM;
                        break;
index 34ee9ebe12a377c5d7ce7fa51fc4b9ff467a97c1..33d059c40616ea604fdb5417c611cfc7a1126f00 100644 (file)
@@ -1068,7 +1068,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv)
        if (!gpriv)
                return -ENOMEM;
 
-       uep = kzalloc(sizeof(struct usbhsg_uep) * pipe_size, GFP_KERNEL);
+       uep = kcalloc(pipe_size, sizeof(struct usbhsg_uep), GFP_KERNEL);
        if (!uep) {
                ret = -ENOMEM;
                goto usbhs_mod_gadget_probe_err_gpriv;
index 9677e0e31475e46cb6267d8f07bb183d96abb5f9..c4922b96c93bcec16e3b60010eed556306914d6c 100644 (file)
@@ -803,7 +803,8 @@ int usbhs_pipe_probe(struct usbhs_priv *priv)
                return -EINVAL;
        }
 
-       info->pipe = kzalloc(sizeof(struct usbhs_pipe) * pipe_size, GFP_KERNEL);
+       info->pipe = kcalloc(pipe_size, sizeof(struct usbhs_pipe),
+                            GFP_KERNEL);
        if (!info->pipe)
                return -ENOMEM;
 
index 62c91e360bafe38e9672abb0df4f100c1ce9cc95..2fb71303ec3ab95b82c6bea40d9604ad4bdc586e 100644 (file)
@@ -736,7 +736,7 @@ static int iuu_uart_on(struct usb_serial_port *port)
        int status;
        u8 *buf;
 
-       buf = kmalloc(sizeof(u8) * 4, GFP_KERNEL);
+       buf = kmalloc(4, GFP_KERNEL);
 
        if (!buf)
                return -ENOMEM;
@@ -790,7 +790,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base,
        unsigned int T1FrekvensHZ = 0;
 
        dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base);
-       dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL);
+       dataout = kmalloc(5, GFP_KERNEL);
 
        if (!dataout)
                return -ENOMEM;
index 900591df8bb2432f2760f9b0a245285f09723cbe..6b8edf6178df36907acc98cf51074d3d5f859273 100644 (file)
@@ -1025,7 +1025,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address,
         * We also need a temporary block buffer, where we read in the old data,
         * overwrite parts with the new data, and manipulate the redundancy data
         */
-       blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO);
+       blockbuffer = kmalloc_array(pagesize + 64, blocksize, GFP_NOIO);
        if (!blockbuffer) {
                kfree(buffer);
                return USB_STOR_TRANSPORT_ERROR;
index 93cf57ac47d67f07d1c2213f006cf442d4b08dd2..4d261e4de9ad3e5b68060628050f01d842c79d75 100644 (file)
@@ -807,8 +807,12 @@ static int ms_lib_alloc_logicalmap(struct us_data *us)
        u32  i;
        struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
 
-       info->MS_Lib.Phy2LogMap = kmalloc(info->MS_Lib.NumberOfPhyBlock * sizeof(u16), GFP_KERNEL);
-       info->MS_Lib.Log2PhyMap = kmalloc(info->MS_Lib.NumberOfLogBlock * sizeof(u16), GFP_KERNEL);
+       info->MS_Lib.Phy2LogMap = kmalloc_array(info->MS_Lib.NumberOfPhyBlock,
+                                               sizeof(u16),
+                                               GFP_KERNEL);
+       info->MS_Lib.Log2PhyMap = kmalloc_array(info->MS_Lib.NumberOfLogBlock,
+                                               sizeof(u16),
+                                               GFP_KERNEL);
 
        if ((info->MS_Lib.Phy2LogMap == NULL) || (info->MS_Lib.Log2PhyMap == NULL)) {
                ms_lib_free_logicalmap(us);
@@ -1113,8 +1117,12 @@ static int ms_lib_alloc_writebuf(struct us_data *us)
 
        info->MS_Lib.wrtblk = (u16)-1;
 
-       info->MS_Lib.blkpag = kmalloc(info->MS_Lib.PagesPerBlock * info->MS_Lib.BytesPerSector, GFP_KERNEL);
-       info->MS_Lib.blkext = kmalloc(info->MS_Lib.PagesPerBlock * sizeof(struct ms_lib_type_extdat), GFP_KERNEL);
+       info->MS_Lib.blkpag = kmalloc_array(info->MS_Lib.PagesPerBlock,
+                                           info->MS_Lib.BytesPerSector,
+                                           GFP_KERNEL);
+       info->MS_Lib.blkext = kmalloc_array(info->MS_Lib.PagesPerBlock,
+                                           sizeof(struct ms_lib_type_extdat),
+                                           GFP_KERNEL);
 
        if ((info->MS_Lib.blkpag == NULL) || (info->MS_Lib.blkext == NULL)) {
                ms_lib_free_writebuf(us);
index 1cf7dbfe277c4d96ecf3b2ccad15720c5f619659..bc9da736bdfc6998a3bb806f8186e072832951c3 100644 (file)
@@ -1231,8 +1231,8 @@ sddr09_read_map(struct us_data *us) {
 
        kfree(info->lba_to_pba);
        kfree(info->pba_to_lba);
-       info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
-       info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
+       info->lba_to_pba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);
+       info->pba_to_lba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);
 
        if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {
                printk(KERN_WARNING "sddr09_read_map: out of memory\n");
index 8c814b2ec9b262289698b8882377d0a58c4553a9..b8527c55335b6e3a977995fa41cc8d7a3337b219 100644 (file)
@@ -651,7 +651,7 @@ static int sddr55_read_map(struct us_data *us) {
 
        numblocks = info->capacity >> (info->blockshift + info->pageshift);
        
-       buffer = kmalloc( numblocks * 2, GFP_NOIO );
+       buffer = kmalloc_array(numblocks, 2, GFP_NOIO );
        
        if (!buffer)
                return -1;
@@ -684,8 +684,8 @@ static int sddr55_read_map(struct us_data *us) {
 
        kfree(info->lba_to_pba);
        kfree(info->pba_to_lba);
-       info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
-       info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
+       info->lba_to_pba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);
+       info->pba_to_lba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);
 
        if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {
                kfree(info->lba_to_pba);
index d0f1a66984607dd0a5ddbfb5d0969709565dc0ea..38884aac862b99f820a9f5fc45813fc02ade7bd6 100644 (file)
@@ -470,7 +470,8 @@ int rpipe_get_by_ep(struct wahc *wa, struct usb_host_endpoint *ep,
 int wa_rpipes_create(struct wahc *wa)
 {
        wa->rpipes = le16_to_cpu(wa->wa_descr->wNumRPipes);
-       wa->rpipe_bm = kzalloc(BITS_TO_LONGS(wa->rpipes)*sizeof(unsigned long),
+       wa->rpipe_bm = kcalloc(BITS_TO_LONGS(wa->rpipes),
+                              sizeof(unsigned long),
                               GFP_KERNEL);
        if (wa->rpipe_bm == NULL)
                return -ENOMEM;
index f3e232584284a906309247e5ed5f3c0fef54e472..ad30ddfe30b32297f546a1df939d01085c50009c 100644 (file)
@@ -217,7 +217,7 @@ static
 int uwb_est_grow(void)
 {
        size_t actual_size = uwb_est_size * sizeof(uwb_est[0]);
-       void *new = kmalloc(2 * actual_size, GFP_ATOMIC);
+       void *new = kmalloc_array(2, actual_size, GFP_ATOMIC);
        if (new == NULL)
                return -ENOMEM;
        memcpy(new, uwb_est, actual_size);
index a50cf45e530f7f0dcc76c111da56d919b9f1f1bf..c0430a41e24b9bb1b716d9fbe26ae5978a570b9e 100644 (file)
@@ -376,7 +376,7 @@ int i1480_usb_probe(struct usb_interface *iface, const struct usb_device_id *id)
 
        i1480 = &i1480_usb->i1480;
        i1480->buf_size = 512;
-       i1480->cmd_buf = kmalloc(2 * i1480->buf_size, GFP_KERNEL);
+       i1480->cmd_buf = kmalloc_array(2, i1480->buf_size, GFP_KERNEL);
        if (i1480->cmd_buf == NULL) {
                dev_err(dev, "Cannot allocate transfer buffers\n");
                result = -ENOMEM;
index 126991046eb739f331d66e33bb56cd9bfb91c986..0212f0ee8aea7577246c01c99821e0ba12cf9373 100644 (file)
@@ -66,34 +66,6 @@ uuid_le mdev_uuid(struct mdev_device *mdev)
 }
 EXPORT_SYMBOL(mdev_uuid);
 
-static int _find_mdev_device(struct device *dev, void *data)
-{
-       struct mdev_device *mdev;
-
-       if (!dev_is_mdev(dev))
-               return 0;
-
-       mdev = to_mdev_device(dev);
-
-       if (uuid_le_cmp(mdev->uuid, *(uuid_le *)data) == 0)
-               return 1;
-
-       return 0;
-}
-
-static bool mdev_device_exist(struct mdev_parent *parent, uuid_le uuid)
-{
-       struct device *dev;
-
-       dev = device_find_child(parent->dev, &uuid, _find_mdev_device);
-       if (dev) {
-               put_device(dev);
-               return true;
-       }
-
-       return false;
-}
-
 /* Should be called holding parent_list_lock */
 static struct mdev_parent *__find_parent_device(struct device *dev)
 {
@@ -221,7 +193,6 @@ int mdev_register_device(struct device *dev, const struct mdev_parent_ops *ops)
        }
 
        kref_init(&parent->ref);
-       mutex_init(&parent->lock);
 
        parent->dev = dev;
        parent->ops = ops;
@@ -297,6 +268,10 @@ static void mdev_device_release(struct device *dev)
 {
        struct mdev_device *mdev = to_mdev_device(dev);
 
+       mutex_lock(&mdev_list_lock);
+       list_del(&mdev->next);
+       mutex_unlock(&mdev_list_lock);
+
        dev_dbg(&mdev->dev, "MDEV: destroying\n");
        kfree(mdev);
 }
@@ -304,7 +279,7 @@ static void mdev_device_release(struct device *dev)
 int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
 {
        int ret;
-       struct mdev_device *mdev;
+       struct mdev_device *mdev, *tmp;
        struct mdev_parent *parent;
        struct mdev_type *type = to_mdev_type(kobj);
 
@@ -312,21 +287,28 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
        if (!parent)
                return -EINVAL;
 
-       mutex_lock(&parent->lock);
+       mutex_lock(&mdev_list_lock);
 
        /* Check for duplicate */
-       if (mdev_device_exist(parent, uuid)) {
-               ret = -EEXIST;
-               goto create_err;
+       list_for_each_entry(tmp, &mdev_list, next) {
+               if (!uuid_le_cmp(tmp->uuid, uuid)) {
+                       mutex_unlock(&mdev_list_lock);
+                       ret = -EEXIST;
+                       goto mdev_fail;
+               }
        }
 
        mdev = kzalloc(sizeof(*mdev), GFP_KERNEL);
        if (!mdev) {
+               mutex_unlock(&mdev_list_lock);
                ret = -ENOMEM;
-               goto create_err;
+               goto mdev_fail;
        }
 
        memcpy(&mdev->uuid, &uuid, sizeof(uuid_le));
+       list_add(&mdev->next, &mdev_list);
+       mutex_unlock(&mdev_list_lock);
+
        mdev->parent = parent;
        kref_init(&mdev->ref);
 
@@ -338,35 +320,28 @@ int mdev_device_create(struct kobject *kobj, struct device *dev, uuid_le uuid)
        ret = device_register(&mdev->dev);
        if (ret) {
                put_device(&mdev->dev);
-               goto create_err;
+               goto mdev_fail;
        }
 
        ret = mdev_device_create_ops(kobj, mdev);
        if (ret)
-               goto create_failed;
+               goto create_fail;
 
        ret = mdev_create_sysfs_files(&mdev->dev, type);
        if (ret) {
                mdev_device_remove_ops(mdev, true);
-               goto create_failed;
+               goto create_fail;
        }
 
        mdev->type_kobj = kobj;
+       mdev->active = true;
        dev_dbg(&mdev->dev, "MDEV: created\n");
 
-       mutex_unlock(&parent->lock);
-
-       mutex_lock(&mdev_list_lock);
-       list_add(&mdev->next, &mdev_list);
-       mutex_unlock(&mdev_list_lock);
-
-       return ret;
+       return 0;
 
-create_failed:
+create_fail:
        device_unregister(&mdev->dev);
-
-create_err:
-       mutex_unlock(&parent->lock);
+mdev_fail:
        mdev_put_parent(parent);
        return ret;
 }
@@ -377,44 +352,39 @@ int mdev_device_remove(struct device *dev, bool force_remove)
        struct mdev_parent *parent;
        struct mdev_type *type;
        int ret;
-       bool found = false;
 
        mdev = to_mdev_device(dev);
 
        mutex_lock(&mdev_list_lock);
        list_for_each_entry(tmp, &mdev_list, next) {
-               if (tmp == mdev) {
-                       found = true;
+               if (tmp == mdev)
                        break;
-               }
        }
 
-       if (found)
-               list_del(&mdev->next);
+       if (tmp != mdev) {
+               mutex_unlock(&mdev_list_lock);
+               return -ENODEV;
+       }
 
-       mutex_unlock(&mdev_list_lock);
+       if (!mdev->active) {
+               mutex_unlock(&mdev_list_lock);
+               return -EAGAIN;
+       }
 
-       if (!found)
-               return -ENODEV;
+       mdev->active = false;
+       mutex_unlock(&mdev_list_lock);
 
        type = to_mdev_type(mdev->type_kobj);
        parent = mdev->parent;
-       mutex_lock(&parent->lock);
 
        ret = mdev_device_remove_ops(mdev, force_remove);
        if (ret) {
-               mutex_unlock(&parent->lock);
-
-               mutex_lock(&mdev_list_lock);
-               list_add(&mdev->next, &mdev_list);
-               mutex_unlock(&mdev_list_lock);
-
+               mdev->active = true;
                return ret;
        }
 
        mdev_remove_sysfs_files(dev, type);
        device_unregister(dev);
-       mutex_unlock(&parent->lock);
        mdev_put_parent(parent);
 
        return 0;
index a9cefd70a7050a45d88b77dfd17efeffd5d3e95f..b5819b7d7ef7016f2467f07b57495be54ce33940 100644 (file)
@@ -20,7 +20,6 @@ struct mdev_parent {
        struct device *dev;
        const struct mdev_parent_ops *ops;
        struct kref ref;
-       struct mutex lock;
        struct list_head next;
        struct kset *mdev_types_kset;
        struct list_head type_list;
@@ -34,6 +33,7 @@ struct mdev_device {
        struct kref ref;
        struct list_head next;
        struct kobject *type_kobj;
+       bool active;
 };
 
 #define to_mdev_device(dev)    container_of(dev, struct mdev_device, dev)
index 802df210929ba5d52924c102867cbe55ba365963..249472f055097eebdebc087dc8d3a6caf56d541b 100644 (file)
@@ -257,24 +257,24 @@ int  mdev_create_sysfs_files(struct device *dev, struct mdev_type *type)
 {
        int ret;
 
-       ret = sysfs_create_files(&dev->kobj, mdev_device_attrs);
-       if (ret)
-               return ret;
-
        ret = sysfs_create_link(type->devices_kobj, &dev->kobj, dev_name(dev));
        if (ret)
-               goto device_link_failed;
+               return ret;
 
        ret = sysfs_create_link(&dev->kobj, &type->kobj, "mdev_type");
        if (ret)
                goto type_link_failed;
 
+       ret = sysfs_create_files(&dev->kobj, mdev_device_attrs);
+       if (ret)
+               goto create_files_failed;
+
        return ret;
 
+create_files_failed:
+       sysfs_remove_link(&dev->kobj, "mdev_type");
 type_link_failed:
        sysfs_remove_link(type->devices_kobj, dev_name(dev));
-device_link_failed:
-       sysfs_remove_files(&dev->kobj, mdev_device_attrs);
        return ret;
 }
 
index 4c27f4be3c3d038598304729dbb1af90c6b2395a..c0cd824be2b767bea76dbea2d8137125762836c2 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/iommu.h>
 #include <linux/module.h>
 #include <linux/mutex.h>
+#include <linux/pm_runtime.h>
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/uaccess.h>
@@ -239,6 +240,7 @@ static void vfio_platform_release(void *device_data)
                                 ret, extra_dbg ? extra_dbg : "");
                        WARN_ON(1);
                }
+               pm_runtime_put(vdev->device);
                vfio_platform_regions_cleanup(vdev);
                vfio_platform_irq_cleanup(vdev);
        }
@@ -269,6 +271,10 @@ static int vfio_platform_open(void *device_data)
                if (ret)
                        goto err_irq;
 
+               ret = pm_runtime_get_sync(vdev->device);
+               if (ret < 0)
+                       goto err_pm;
+
                ret = vfio_platform_call_reset(vdev, &extra_dbg);
                if (ret && vdev->reset_required) {
                        dev_warn(vdev->device, "reset driver is required and reset call failed in open (%d) %s\n",
@@ -283,6 +289,8 @@ static int vfio_platform_open(void *device_data)
        return 0;
 
 err_rst:
+       pm_runtime_put(vdev->device);
+err_pm:
        vfio_platform_irq_cleanup(vdev);
 err_irq:
        vfio_platform_regions_cleanup(vdev);
@@ -630,8 +638,7 @@ static int vfio_platform_of_probe(struct vfio_platform_device *vdev,
        ret = device_property_read_string(dev, "compatible",
                                          &vdev->compat);
        if (ret)
-               pr_err("VFIO: cannot retrieve compat for %s\n",
-                       vdev->name);
+               pr_err("VFIO: Cannot retrieve compat for %s\n", vdev->name);
 
        return ret;
 }
@@ -673,7 +680,7 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
 
        ret = vfio_platform_get_reset(vdev);
        if (ret && vdev->reset_required) {
-               pr_err("vfio: no reset function found for device %s\n",
+               pr_err("VFIO: No reset function found for device %s\n",
                       vdev->name);
                return ret;
        }
@@ -681,18 +688,24 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,
        group = vfio_iommu_group_get(dev);
        if (!group) {
                pr_err("VFIO: No IOMMU group for device %s\n", vdev->name);
-               return -EINVAL;
+               ret = -EINVAL;
+               goto put_reset;
        }
 
        ret = vfio_add_group_dev(dev, &vfio_platform_ops, vdev);
-       if (ret) {
-               vfio_iommu_group_put(group, dev);
-               return ret;
-       }
+       if (ret)
+               goto put_iommu;
 
        mutex_init(&vdev->igate);
 
+       pm_runtime_enable(vdev->device);
        return 0;
+
+put_iommu:
+       vfio_iommu_group_put(group, dev);
+put_reset:
+       vfio_platform_put_reset(vdev);
+       return ret;
 }
 EXPORT_SYMBOL_GPL(vfio_platform_probe_common);
 
@@ -703,6 +716,7 @@ struct vfio_platform_device *vfio_platform_remove_common(struct device *dev)
        vdev = vfio_del_group_dev(dev);
 
        if (vdev) {
+               pm_runtime_disable(vdev->device);
                vfio_platform_put_reset(vdev);
                vfio_iommu_group_put(dev->iommu_group, dev);
        }
index 721f97f8dac1f2c979e846dcd89aa6878e195b59..64833879f75d3cf2d0739f03e4ca4b587c639cca 100644 (file)
@@ -630,8 +630,6 @@ static const char * const vfio_driver_whitelist[] = { "pci-stub" };
 
 static bool vfio_dev_whitelisted(struct device *dev, struct device_driver *drv)
 {
-       int i;
-
        if (dev_is_pci(dev)) {
                struct pci_dev *pdev = to_pci_dev(dev);
 
@@ -639,12 +637,9 @@ static bool vfio_dev_whitelisted(struct device *dev, struct device_driver *drv)
                        return true;
        }
 
-       for (i = 0; i < ARRAY_SIZE(vfio_driver_whitelist); i++) {
-               if (!strcmp(drv->name, vfio_driver_whitelist[i]))
-                       return true;
-       }
-
-       return false;
+       return match_string(vfio_driver_whitelist,
+                           ARRAY_SIZE(vfio_driver_whitelist),
+                           drv->name) >= 0;
 }
 
 /*
index 3c082451ab1a00da8577978a61276c0341930e3d..2c75b33db4ac19768ea77415685b4fac700dc4d3 100644 (file)
@@ -83,6 +83,7 @@ struct vfio_dma {
        size_t                  size;           /* Map size (bytes) */
        int                     prot;           /* IOMMU_READ/WRITE */
        bool                    iommu_mapped;
+       bool                    lock_cap;       /* capable(CAP_IPC_LOCK) */
        struct task_struct      *task;
        struct rb_root          pfn_list;       /* Ex-user pinned pfn list */
 };
@@ -253,29 +254,25 @@ static int vfio_iova_put_vfio_pfn(struct vfio_dma *dma, struct vfio_pfn *vpfn)
        return ret;
 }
 
-static int vfio_lock_acct(struct task_struct *task, long npage, bool *lock_cap)
+static int vfio_lock_acct(struct vfio_dma *dma, long npage, bool async)
 {
        struct mm_struct *mm;
-       bool is_current;
        int ret;
 
        if (!npage)
                return 0;
 
-       is_current = (task->mm == current->mm);
-
-       mm = is_current ? task->mm : get_task_mm(task);
+       mm = async ? get_task_mm(dma->task) : dma->task->mm;
        if (!mm)
                return -ESRCH; /* process exited */
 
        ret = down_write_killable(&mm->mmap_sem);
        if (!ret) {
                if (npage > 0) {
-                       if (lock_cap ? !*lock_cap :
-                           !has_capability(task, CAP_IPC_LOCK)) {
+                       if (!dma->lock_cap) {
                                unsigned long limit;
 
-                               limit = task_rlimit(task,
+                               limit = task_rlimit(dma->task,
                                                RLIMIT_MEMLOCK) >> PAGE_SHIFT;
 
                                if (mm->locked_vm + npage > limit)
@@ -289,7 +286,7 @@ static int vfio_lock_acct(struct task_struct *task, long npage, bool *lock_cap)
                up_write(&mm->mmap_sem);
        }
 
-       if (!is_current)
+       if (async)
                mmput(mm);
 
        return ret;
@@ -400,7 +397,7 @@ static int vaddr_get_pfn(struct mm_struct *mm, unsigned long vaddr,
  */
 static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
                                  long npage, unsigned long *pfn_base,
-                                 bool lock_cap, unsigned long limit)
+                                 unsigned long limit)
 {
        unsigned long pfn = 0;
        long ret, pinned = 0, lock_acct = 0;
@@ -423,7 +420,7 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
         * pages are already counted against the user.
         */
        if (!rsvd && !vfio_find_vpfn(dma, iova)) {
-               if (!lock_cap && current->mm->locked_vm + 1 > limit) {
+               if (!dma->lock_cap && current->mm->locked_vm + 1 > limit) {
                        put_pfn(*pfn_base, dma->prot);
                        pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n", __func__,
                                        limit << PAGE_SHIFT);
@@ -449,7 +446,7 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
                }
 
                if (!rsvd && !vfio_find_vpfn(dma, iova)) {
-                       if (!lock_cap &&
+                       if (!dma->lock_cap &&
                            current->mm->locked_vm + lock_acct + 1 > limit) {
                                put_pfn(pfn, dma->prot);
                                pr_warn("%s: RLIMIT_MEMLOCK (%ld) exceeded\n",
@@ -462,7 +459,7 @@ static long vfio_pin_pages_remote(struct vfio_dma *dma, unsigned long vaddr,
        }
 
 out:
-       ret = vfio_lock_acct(current, lock_acct, &lock_cap);
+       ret = vfio_lock_acct(dma, lock_acct, false);
 
 unpin_out:
        if (ret) {
@@ -493,7 +490,7 @@ static long vfio_unpin_pages_remote(struct vfio_dma *dma, dma_addr_t iova,
        }
 
        if (do_accounting)
-               vfio_lock_acct(dma->task, locked - unlocked, NULL);
+               vfio_lock_acct(dma, locked - unlocked, true);
 
        return unlocked;
 }
@@ -510,7 +507,7 @@ static int vfio_pin_page_external(struct vfio_dma *dma, unsigned long vaddr,
 
        ret = vaddr_get_pfn(mm, vaddr, dma->prot, pfn_base);
        if (!ret && do_accounting && !is_invalid_reserved_pfn(*pfn_base)) {
-               ret = vfio_lock_acct(dma->task, 1, NULL);
+               ret = vfio_lock_acct(dma, 1, true);
                if (ret) {
                        put_pfn(*pfn_base, dma->prot);
                        if (ret == -ENOMEM)
@@ -537,7 +534,7 @@ static int vfio_unpin_page_external(struct vfio_dma *dma, dma_addr_t iova,
        unlocked = vfio_iova_put_vfio_pfn(dma, vpfn);
 
        if (do_accounting)
-               vfio_lock_acct(dma->task, -unlocked, NULL);
+               vfio_lock_acct(dma, -unlocked, true);
 
        return unlocked;
 }
@@ -829,7 +826,7 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma,
                unlocked += vfio_sync_unpin(dma, domain, &unmapped_region_list);
 
        if (do_accounting) {
-               vfio_lock_acct(dma->task, -unlocked, NULL);
+               vfio_lock_acct(dma, -unlocked, true);
                return 0;
        }
        return unlocked;
@@ -1044,14 +1041,12 @@ static int vfio_pin_map_dma(struct vfio_iommu *iommu, struct vfio_dma *dma,
        size_t size = map_size;
        long npage;
        unsigned long pfn, limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
-       bool lock_cap = capable(CAP_IPC_LOCK);
        int ret = 0;
 
        while (size) {
                /* Pin a contiguous chunk of memory */
                npage = vfio_pin_pages_remote(dma, vaddr + dma->size,
-                                             size >> PAGE_SHIFT, &pfn,
-                                             lock_cap, limit);
+                                             size >> PAGE_SHIFT, &pfn, limit);
                if (npage <= 0) {
                        WARN_ON(!npage);
                        ret = (int)npage;
@@ -1126,8 +1121,36 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu,
        dma->iova = iova;
        dma->vaddr = vaddr;
        dma->prot = prot;
-       get_task_struct(current);
-       dma->task = current;
+
+       /*
+        * We need to be able to both add to a task's locked memory and test
+        * against the locked memory limit and we need to be able to do both
+        * outside of this call path as pinning can be asynchronous via the
+        * external interfaces for mdev devices.  RLIMIT_MEMLOCK requires a
+        * task_struct and VM locked pages requires an mm_struct, however
+        * holding an indefinite mm reference is not recommended, therefore we
+        * only hold a reference to a task.  We could hold a reference to
+        * current, however QEMU uses this call path through vCPU threads,
+        * which can be killed resulting in a NULL mm and failure in the unmap
+        * path when called via a different thread.  Avoid this problem by
+        * using the group_leader as threads within the same group require
+        * both CLONE_THREAD and CLONE_VM and will therefore use the same
+        * mm_struct.
+        *
+        * Previously we also used the task for testing CAP_IPC_LOCK at the
+        * time of pinning and accounting, however has_capability() makes use
+        * of real_cred, a copy-on-write field, so we can't guarantee that it
+        * matches group_leader, or in fact that it might not change by the
+        * time it's evaluated.  If a process were to call MAP_DMA with
+        * CAP_IPC_LOCK but later drop it, it doesn't make sense that they
+        * possibly see different results for an iommu_mapped vfio_dma vs
+        * externally mapped.  Therefore track CAP_IPC_LOCK in vfio_dma at the
+        * time of calling MAP_DMA.
+        */
+       get_task_struct(current->group_leader);
+       dma->task = current->group_leader;
+       dma->lock_cap = capable(CAP_IPC_LOCK);
+
        dma->pfn_list = RB_ROOT;
 
        /* Insert zero-sized and grow as we map chunks of it */
@@ -1162,7 +1185,6 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
        struct vfio_domain *d;
        struct rb_node *n;
        unsigned long limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
-       bool lock_cap = capable(CAP_IPC_LOCK);
        int ret;
 
        /* Arbitrarily pick the first domain in the list for lookups */
@@ -1209,8 +1231,7 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
 
                                npage = vfio_pin_pages_remote(dma, vaddr,
                                                              n >> PAGE_SHIFT,
-                                                             &pfn, lock_cap,
-                                                             limit);
+                                                             &pfn, limit);
                                if (npage <= 0) {
                                        WARN_ON(!npage);
                                        ret = (int)npage;
@@ -1487,7 +1508,7 @@ static void vfio_iommu_unmap_unpin_reaccount(struct vfio_iommu *iommu)
                        if (!is_invalid_reserved_pfn(vpfn->pfn))
                                locked++;
                }
-               vfio_lock_acct(dma->task, locked - unlocked, NULL);
+               vfio_lock_acct(dma, locked - unlocked, true);
        }
 }
 
index e7cf7d21cfb5e4e137829123597eb8ff3af6391f..686dc670fd294b3077cf363241338ab871b26244 100644 (file)
@@ -274,8 +274,10 @@ static int vhost_net_set_ubuf_info(struct vhost_net *n)
                zcopy = vhost_net_zcopy_mask & (0x1 << i);
                if (!zcopy)
                        continue;
-               n->vqs[i].ubuf_info = kmalloc(sizeof(*n->vqs[i].ubuf_info) *
-                                             UIO_MAXIOV, GFP_KERNEL);
+               n->vqs[i].ubuf_info =
+                       kmalloc_array(UIO_MAXIOV,
+                                     sizeof(*n->vqs[i].ubuf_info),
+                                     GFP_KERNEL);
                if  (!n->vqs[i].ubuf_info)
                        goto err;
        }
@@ -943,7 +945,7 @@ static int vhost_net_open(struct inode *inode, struct file *f)
        n = kvmalloc(sizeof *n, GFP_KERNEL | __GFP_RETRY_MAYFAIL);
        if (!n)
                return -ENOMEM;
-       vqs = kmalloc(VHOST_NET_VQ_MAX * sizeof(*vqs), GFP_KERNEL);
+       vqs = kmalloc_array(VHOST_NET_VQ_MAX, sizeof(*vqs), GFP_KERNEL);
        if (!vqs) {
                kvfree(n);
                return -ENOMEM;
index 7ad57094d7369278a3f67648bb69f4151fec1fdc..17fcd3b2e68668ec12e51680dde8a04673979555 100644 (file)
@@ -1378,7 +1378,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f)
                        goto err_vs;
        }
 
-       vqs = kmalloc(VHOST_SCSI_MAX_VQ * sizeof(*vqs), GFP_KERNEL);
+       vqs = kmalloc_array(VHOST_SCSI_MAX_VQ, sizeof(*vqs), GFP_KERNEL);
        if (!vqs)
                goto err_vqs;
 
@@ -1685,22 +1685,25 @@ static int vhost_scsi_nexus_cb(struct se_portal_group *se_tpg,
        for (i = 0; i < VHOST_SCSI_DEFAULT_TAGS; i++) {
                tv_cmd = &((struct vhost_scsi_cmd *)se_sess->sess_cmd_map)[i];
 
-               tv_cmd->tvc_sgl = kzalloc(sizeof(struct scatterlist) *
-                                       VHOST_SCSI_PREALLOC_SGLS, GFP_KERNEL);
+               tv_cmd->tvc_sgl = kcalloc(VHOST_SCSI_PREALLOC_SGLS,
+                                         sizeof(struct scatterlist),
+                                         GFP_KERNEL);
                if (!tv_cmd->tvc_sgl) {
                        pr_err("Unable to allocate tv_cmd->tvc_sgl\n");
                        goto out;
                }
 
-               tv_cmd->tvc_upages = kzalloc(sizeof(struct page *) *
-                               VHOST_SCSI_PREALLOC_UPAGES, GFP_KERNEL);
+               tv_cmd->tvc_upages = kcalloc(VHOST_SCSI_PREALLOC_UPAGES,
+                                            sizeof(struct page *),
+                                            GFP_KERNEL);
                if (!tv_cmd->tvc_upages) {
                        pr_err("Unable to allocate tv_cmd->tvc_upages\n");
                        goto out;
                }
 
-               tv_cmd->tvc_prot_sgl = kzalloc(sizeof(struct scatterlist) *
-                               VHOST_SCSI_PREALLOC_PROT_SGLS, GFP_KERNEL);
+               tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS,
+                                              sizeof(struct scatterlist),
+                                              GFP_KERNEL);
                if (!tv_cmd->tvc_prot_sgl) {
                        pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");
                        goto out;
index 906b8f0f19f7be83f5cff44f8797c6795888454c..40589850eb33c83c06d9211fa86aa95af655dd9e 100644 (file)
@@ -107,7 +107,7 @@ static int vhost_test_open(struct inode *inode, struct file *f)
 
        if (!n)
                return -ENOMEM;
-       vqs = kmalloc(VHOST_TEST_VQ_MAX * sizeof(*vqs), GFP_KERNEL);
+       vqs = kmalloc_array(VHOST_TEST_VQ_MAX, sizeof(*vqs), GFP_KERNEL);
        if (!vqs) {
                kfree(n);
                return -ENOMEM;
index 895eaa25807c84e854a19b78a9fbcfafb06dbac7..a502f1af4a213607adec4aa28fa6ae8eb9ce0389 100644 (file)
@@ -385,10 +385,13 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev)
 
        for (i = 0; i < dev->nvqs; ++i) {
                vq = dev->vqs[i];
-               vq->indirect = kmalloc(sizeof *vq->indirect * UIO_MAXIOV,
-                                      GFP_KERNEL);
-               vq->log = kmalloc(sizeof *vq->log * UIO_MAXIOV, GFP_KERNEL);
-               vq->heads = kmalloc(sizeof *vq->heads * UIO_MAXIOV, GFP_KERNEL);
+               vq->indirect = kmalloc_array(UIO_MAXIOV,
+                                            sizeof(*vq->indirect),
+                                            GFP_KERNEL);
+               vq->log = kmalloc_array(UIO_MAXIOV, sizeof(*vq->log),
+                                       GFP_KERNEL);
+               vq->heads = kmalloc_array(UIO_MAXIOV, sizeof(*vq->heads),
+                                         GFP_KERNEL);
                if (!vq->indirect || !vq->log || !vq->heads)
                        goto err_nomem;
        }
@@ -1286,7 +1289,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m)
                return -EOPNOTSUPP;
        if (mem.nregions > max_mem_regions)
                return -E2BIG;
-       newmem = kvzalloc(size + mem.nregions * sizeof(*m->regions), GFP_KERNEL);
+       newmem = kvzalloc(struct_size(newmem, regions, mem.nregions),
+                       GFP_KERNEL);
        if (!newmem)
                return -ENOMEM;
 
@@ -2345,6 +2349,9 @@ struct vhost_msg_node *vhost_new_msg(struct vhost_virtqueue *vq, int type)
        struct vhost_msg_node *node = kmalloc(sizeof *node, GFP_KERNEL);
        if (!node)
                return NULL;
+
+       /* Make sure all padding within the structure is initialized. */
+       memset(&node->msg, 0, sizeof node->msg);
        node->vq = vq;
        node->msg.type = type;
        return node;
index bb8971f2a634bc478a97c672ebde8e7d7c7da3cc..a94d700a45030609ac9a01ee1700ab09c1fc20b1 100644 (file)
@@ -191,7 +191,7 @@ static int resize_iovec(struct vringh_kiov *iov, gfp_t gfp)
        if (flag)
                new = krealloc(iov->iov, new_num * sizeof(struct iovec), gfp);
        else {
-               new = kmalloc(new_num * sizeof(struct iovec), gfp);
+               new = kmalloc_array(new_num, sizeof(struct iovec), gfp);
                if (new) {
                        memcpy(new, iov->iov,
                               iov->max_num * sizeof(struct iovec));
index 4e1d2ad50ba142950e0048d986ab7e0df2eafece..2919e23340527704ea5ca9d1607f76b6e1e45cbc 100644 (file)
@@ -150,6 +150,13 @@ config LCD_HX8357
          If you have a HX-8357 LCD panel, say Y to enable its LCD control
          driver.
 
+  config LCD_OTM3225A
+       tristate "ORISE Technology OTM3225A support"
+       depends on SPI
+       help
+         If you have a panel based on the OTM3225A controller
+         chip then say y to include a driver for it.
+
 endif # LCD_CLASS_DEVICE
 
 #
@@ -467,6 +474,12 @@ config BACKLIGHT_ARCXCNN
          If you have an ARCxCnnnn family backlight say Y to enable
          the backlight driver.
 
+config BACKLIGHT_RAVE_SP
+       tristate "RAVE SP Backlight driver"
+       depends on RAVE_SP_CORE
+       help
+         Support for backlight control on RAVE SP device.
+
 endif # BACKLIGHT_CLASS_DEVICE
 
 endif # BACKLIGHT_LCD_SUPPORT
index 5e28f01c839107ef8e9cca3225181f46b953545e..0dcc2c745c03c4781875f898e3aeb7a41b1264f0 100644 (file)
@@ -13,6 +13,7 @@ obj-$(CONFIG_LCD_LD9040)              += ld9040.o
 obj-$(CONFIG_LCD_LMS283GF05)           += lms283gf05.o
 obj-$(CONFIG_LCD_LMS501KF03)           += lms501kf03.o
 obj-$(CONFIG_LCD_LTV350QV)             += ltv350qv.o
+obj-$(CONFIG_LCD_OTM3225A)             += otm3225a.o
 obj-$(CONFIG_LCD_PLATFORM)             += platform_lcd.o
 obj-$(CONFIG_LCD_S6E63M0)              += s6e63m0.o
 obj-$(CONFIG_LCD_TDO24M)               += tdo24m.o
@@ -57,3 +58,4 @@ obj-$(CONFIG_BACKLIGHT_TOSA)          += tosa_bl.o
 obj-$(CONFIG_BACKLIGHT_TPS65217)       += tps65217_bl.o
 obj-$(CONFIG_BACKLIGHT_WM831X)         += wm831x_bl.o
 obj-$(CONFIG_BACKLIGHT_ARCXCNN)        += arcxcnn_bl.o
+obj-$(CONFIG_BACKLIGHT_RAVE_SP)                += rave-sp-backlight.o
index e7315bf14d60159c3cb3d0915797e8838cd7bc73..16119bde975000118ddc0b36854101c72f1636c6 100644 (file)
@@ -223,7 +223,7 @@ static int adp8860_led_probe(struct i2c_client *client)
        struct led_info *cur_led;
        int ret, i;
 
-       led = devm_kzalloc(&client->dev, sizeof(*led) * pdata->num_leds,
+       led = devm_kcalloc(&client->dev, pdata->num_leds, sizeof(*led),
                                GFP_KERNEL);
        if (led == NULL)
                return -ENOMEM;
index 058d1def2d1f4ba6caa6d2e6a720fb41e206b715..4fec9aa92d9be688d379838c436c83a5db27912f 100644 (file)
@@ -246,7 +246,7 @@ static int adp8870_led_probe(struct i2c_client *client)
        struct led_info *cur_led;
        int ret, i;
 
-       led = devm_kzalloc(&client->dev, pdata->num_leds * sizeof(*led),
+       led = devm_kcalloc(&client->dev, pdata->num_leds, sizeof(*led),
                                GFP_KERNEL);
        if (led == NULL)
                return -ENOMEM;
index 734a9158946b1f805a3738d9e9c31f25cf8b3314..ca544aa764b8e6b6b067395f409494767382bd1d 100644 (file)
@@ -28,8 +28,6 @@ enum as3711_bl_type {
 
 struct as3711_bl_data {
        bool powered;
-       const char *fb_name;
-       struct device *fb_dev;
        enum as3711_bl_type type;
        int brightness;
        struct backlight_device *bl;
@@ -262,10 +260,10 @@ static int as3711_bl_register(struct platform_device *pdev,
 static int as3711_backlight_parse_dt(struct device *dev)
 {
        struct as3711_bl_pdata *pdata = dev_get_platdata(dev);
-       struct device_node *bl =
-               of_find_node_by_name(dev->parent->of_node, "backlight"), *fb;
+       struct device_node *bl, *fb;
        int ret;
 
+       bl = of_get_child_by_name(dev->parent->of_node, "backlight");
        if (!bl) {
                dev_dbg(dev, "backlight node not found\n");
                return -ENODEV;
@@ -273,26 +271,30 @@ static int as3711_backlight_parse_dt(struct device *dev)
 
        fb = of_parse_phandle(bl, "su1-dev", 0);
        if (fb) {
-               pdata->su1_fb = fb->full_name;
+               of_node_put(fb);
+
+               pdata->su1_fb = true;
 
                ret = of_property_read_u32(bl, "su1-max-uA", &pdata->su1_max_uA);
                if (pdata->su1_max_uA <= 0)
                        ret = -EINVAL;
                if (ret < 0)
-                       return ret;
+                       goto err_put_bl;
        }
 
        fb = of_parse_phandle(bl, "su2-dev", 0);
        if (fb) {
                int count = 0;
 
-               pdata->su2_fb = fb->full_name;
+               of_node_put(fb);
+
+               pdata->su2_fb = true;
 
                ret = of_property_read_u32(bl, "su2-max-uA", &pdata->su2_max_uA);
                if (pdata->su2_max_uA <= 0)
                        ret = -EINVAL;
                if (ret < 0)
-                       return ret;
+                       goto err_put_bl;
 
                if (of_find_property(bl, "su2-feedback-voltage", NULL)) {
                        pdata->su2_feedback = AS3711_SU2_VOLTAGE;
@@ -314,8 +316,10 @@ static int as3711_backlight_parse_dt(struct device *dev)
                        pdata->su2_feedback = AS3711_SU2_CURR_AUTO;
                        count++;
                }
-               if (count != 1)
-                       return -EINVAL;
+               if (count != 1) {
+                       ret = -EINVAL;
+                       goto err_put_bl;
+               }
 
                count = 0;
                if (of_find_property(bl, "su2-fbprot-lx-sd4", NULL)) {
@@ -334,8 +338,10 @@ static int as3711_backlight_parse_dt(struct device *dev)
                        pdata->su2_fbprot = AS3711_SU2_GPIO4;
                        count++;
                }
-               if (count != 1)
-                       return -EINVAL;
+               if (count != 1) {
+                       ret = -EINVAL;
+                       goto err_put_bl;
+               }
 
                count = 0;
                if (of_find_property(bl, "su2-auto-curr1", NULL)) {
@@ -355,11 +361,20 @@ static int as3711_backlight_parse_dt(struct device *dev)
                 * At least one su2-auto-curr* must be specified iff
                 * AS3711_SU2_CURR_AUTO is used
                 */
-               if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO))
-                       return -EINVAL;
+               if (!count ^ (pdata->su2_feedback != AS3711_SU2_CURR_AUTO)) {
+                       ret = -EINVAL;
+                       goto err_put_bl;
+               }
        }
 
+       of_node_put(bl);
+
        return 0;
+
+err_put_bl:
+       of_node_put(bl);
+
+       return ret;
 }
 
 static int as3711_backlight_probe(struct platform_device *pdev)
@@ -412,7 +427,6 @@ static int as3711_backlight_probe(struct platform_device *pdev)
 
        if (pdata->su1_fb) {
                su = &supply->su1;
-               su->fb_name = pdata->su1_fb;
                su->type = AS3711_BL_SU1;
 
                max_brightness = min(pdata->su1_max_uA, 31);
@@ -423,7 +437,6 @@ static int as3711_backlight_probe(struct platform_device *pdev)
 
        if (pdata->su2_fb) {
                su = &supply->su2;
-               su->fb_name = pdata->su2_fb;
                su->type = AS3711_BL_SU2;
 
                switch (pdata->su2_fbprot) {
index 67dfb939a51428f1fb1a54381bfde0b56d53fe8e..4dea91acea138037f29f07423375b06cebf7ab9a 100644 (file)
@@ -21,9 +21,6 @@ static int genericbl_intensity;
 static struct backlight_device *generic_backlight_device;
 static struct generic_bl_info *bl_machinfo;
 
-/* Flag to signal when the battery is low */
-#define GENERICBL_BATTLOW       BL_CORE_DRIVER1
-
 static int genericbl_send_intensity(struct backlight_device *bd)
 {
        int intensity = bd->props.brightness;
@@ -34,8 +31,6 @@ static int genericbl_send_intensity(struct backlight_device *bd)
                intensity = 0;
        if (bd->props.state & BL_CORE_SUSPENDED)
                intensity = 0;
-       if (bd->props.state & GENERICBL_BATTLOW)
-               intensity &= bl_machinfo->limit_mask;
 
        bl_machinfo->set_bl_intensity(intensity);
 
index 939f057836e1981223ee1ab0dbaa62288fe7b976..73612485ed07e4af457b0a46c73ab516f4fea5f5 100644 (file)
@@ -374,7 +374,7 @@ static int lp855x_parse_dt(struct lp855x *lp)
                struct device_node *child;
                int i = 0;
 
-               rom = devm_kzalloc(dev, sizeof(*rom) * rom_length, GFP_KERNEL);
+               rom = devm_kcalloc(dev, rom_length, sizeof(*rom), GFP_KERNEL);
                if (!rom)
                        return -ENOMEM;
 
index 7b738d60ecc22e27560e42c9cef0669628e4aa28..f3aa6088f1d97805f23b9780a1db893cf1a46b00 100644 (file)
@@ -116,7 +116,7 @@ static void max8925_backlight_dt_init(struct platform_device *pdev)
        if (!pdata)
                return;
 
-       np = of_find_node_by_name(nproot, "backlight");
+       np = of_get_child_by_name(nproot, "backlight");
        if (!np) {
                dev_err(&pdev->dev, "failed to find backlight node\n");
                return;
@@ -125,6 +125,8 @@ static void max8925_backlight_dt_init(struct platform_device *pdev)
        if (!of_property_read_u32(np, "maxim,max8925-dual-string", &val))
                pdata->dual_string = val;
 
+       of_node_put(np);
+
        pdev->dev.platform_data = pdata;
 }
 
diff --git a/drivers/video/backlight/otm3225a.c b/drivers/video/backlight/otm3225a.c
new file mode 100644 (file)
index 0000000..2472e21
--- /dev/null
@@ -0,0 +1,252 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Driver for ORISE Technology OTM3225A SOC for TFT LCD
+ * Copyright (C) 2017, EETS GmbH, Felix Brack <fb@ltec.ch>
+ *
+ * This driver implements a lcd device for the ORISE OTM3225A display
+ * controller. The control interface to the display is SPI and the display's
+ * memory is updated over the 16-bit RGB interface.
+ * The main source of information for writing this driver was provided by the
+ * OTM3225A datasheet from ORISE Technology. Some information arise from the
+ * ILI9328 datasheet from ILITEK as well as from the datasheets and sample code
+ * provided by Crystalfontz America Inc. who sells the CFAF240320A-032T, a 3.2"
+ * TFT LC display using the OTM3225A controller.
+ */
+
+#include <linux/delay.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/lcd.h>
+#include <linux/module.h>
+#include <linux/spi/spi.h>
+
+#define OTM3225A_INDEX_REG     0x70
+#define OTM3225A_DATA_REG      0x72
+
+/* instruction register list */
+#define DRIVER_OUTPUT_CTRL_1   0x01
+#define DRIVER_WAVEFORM_CTRL   0x02
+#define ENTRY_MODE             0x03
+#define SCALING_CTRL           0x04
+#define DISPLAY_CTRL_1         0x07
+#define DISPLAY_CTRL_2         0x08
+#define DISPLAY_CTRL_3         0x09
+#define FRAME_CYCLE_CTRL       0x0A
+#define EXT_DISP_IFACE_CTRL_1  0x0C
+#define FRAME_MAKER_POS                0x0D
+#define EXT_DISP_IFACE_CTRL_2  0x0F
+#define POWER_CTRL_1           0x10
+#define POWER_CTRL_2           0x11
+#define POWER_CTRL_3           0x12
+#define POWER_CTRL_4           0x13
+#define GRAM_ADDR_HORIZ_SET    0x20
+#define GRAM_ADDR_VERT_SET     0x21
+#define GRAM_READ_WRITE                0x22
+#define POWER_CTRL_7           0x29
+#define FRAME_RATE_CTRL                0x2B
+#define GAMMA_CTRL_1           0x30
+#define GAMMA_CTRL_2           0x31
+#define GAMMA_CTRL_3           0x32
+#define GAMMA_CTRL_4           0x35
+#define GAMMA_CTRL_5           0x36
+#define GAMMA_CTRL_6           0x37
+#define GAMMA_CTRL_7           0x38
+#define GAMMA_CTRL_8           0x39
+#define GAMMA_CTRL_9           0x3C
+#define GAMMA_CTRL_10          0x3D
+#define WINDOW_HORIZ_RAM_START 0x50
+#define WINDOW_HORIZ_RAM_END   0x51
+#define WINDOW_VERT_RAM_START  0x52
+#define WINDOW_VERT_RAM_END    0x53
+#define DRIVER_OUTPUT_CTRL_2   0x60
+#define BASE_IMG_DISPLAY_CTRL  0x61
+#define VERT_SCROLL_CTRL       0x6A
+#define PD1_DISPLAY_POS                0x80
+#define PD1_RAM_START          0x81
+#define PD1_RAM_END            0x82
+#define PD2_DISPLAY_POS                0x83
+#define PD2_RAM_START          0x84
+#define PD2_RAM_END            0x85
+#define PANEL_IFACE_CTRL_1     0x90
+#define PANEL_IFACE_CTRL_2     0x92
+#define PANEL_IFACE_CTRL_4     0x95
+#define PANEL_IFACE_CTRL_5     0x97
+
+struct otm3225a_data {
+       struct spi_device *spi;
+       struct lcd_device *ld;
+       int power;
+};
+
+struct otm3225a_spi_instruction {
+       unsigned char reg;      /* register to write */
+       unsigned short value;   /* data to write to 'reg' */
+       unsigned short delay;   /* delay in ms after write */
+};
+
+static struct otm3225a_spi_instruction display_init[] = {
+       { DRIVER_OUTPUT_CTRL_1,         0x0000, 0 },
+       { DRIVER_WAVEFORM_CTRL,         0x0700, 0 },
+       { ENTRY_MODE,                   0x50A0, 0 },
+       { SCALING_CTRL,                 0x0000, 0 },
+       { DISPLAY_CTRL_2,               0x0606, 0 },
+       { DISPLAY_CTRL_3,               0x0000, 0 },
+       { FRAME_CYCLE_CTRL,             0x0000, 0 },
+       { EXT_DISP_IFACE_CTRL_1,        0x0000, 0 },
+       { FRAME_MAKER_POS,              0x0000, 0 },
+       { EXT_DISP_IFACE_CTRL_2,        0x0002, 0 },
+       { POWER_CTRL_2,                 0x0007, 0 },
+       { POWER_CTRL_3,                 0x0000, 0 },
+       { POWER_CTRL_4,                 0x0000, 200 },
+       { DISPLAY_CTRL_1,               0x0101, 0 },
+       { POWER_CTRL_1,                 0x12B0, 0 },
+       { POWER_CTRL_2,                 0x0007, 0 },
+       { POWER_CTRL_3,                 0x01BB, 50 },
+       { POWER_CTRL_4,                 0x0013, 0 },
+       { POWER_CTRL_7,                 0x0010, 50 },
+       { GAMMA_CTRL_1,                 0x000A, 0 },
+       { GAMMA_CTRL_2,                 0x1326, 0 },
+       { GAMMA_CTRL_3,                 0x0A29, 0 },
+       { GAMMA_CTRL_4,                 0x0A0A, 0 },
+       { GAMMA_CTRL_5,                 0x1E03, 0 },
+       { GAMMA_CTRL_6,                 0x031E, 0 },
+       { GAMMA_CTRL_7,                 0x0706, 0 },
+       { GAMMA_CTRL_8,                 0x0303, 0 },
+       { GAMMA_CTRL_9,                 0x010E, 0 },
+       { GAMMA_CTRL_10,                0x040E, 0 },
+       { WINDOW_HORIZ_RAM_START,       0x0000, 0 },
+       { WINDOW_HORIZ_RAM_END,         0x00EF, 0 },
+       { WINDOW_VERT_RAM_START,        0x0000, 0 },
+       { WINDOW_VERT_RAM_END,          0x013F, 0 },
+       { DRIVER_OUTPUT_CTRL_2,         0x2700, 0 },
+       { BASE_IMG_DISPLAY_CTRL,        0x0001, 0 },
+       { VERT_SCROLL_CTRL,             0x0000, 0 },
+       { PD1_DISPLAY_POS,              0x0000, 0 },
+       { PD1_RAM_START,                0x0000, 0 },
+       { PD1_RAM_END,                  0x0000, 0 },
+       { PD2_DISPLAY_POS,              0x0000, 0 },
+       { PD2_RAM_START,                0x0000, 0 },
+       { PD2_RAM_END,                  0x0000, 0 },
+       { PANEL_IFACE_CTRL_1,           0x0010, 0 },
+       { PANEL_IFACE_CTRL_2,           0x0000, 0 },
+       { PANEL_IFACE_CTRL_4,           0x0210, 0 },
+       { PANEL_IFACE_CTRL_5,           0x0000, 0 },
+       { DISPLAY_CTRL_1,               0x0133, 0 },
+};
+
+static struct otm3225a_spi_instruction display_enable_rgb_interface[] = {
+       { ENTRY_MODE,                   0x1080, 0 },
+       { GRAM_ADDR_HORIZ_SET,          0x0000, 0 },
+       { GRAM_ADDR_VERT_SET,           0x0000, 0 },
+       { EXT_DISP_IFACE_CTRL_1,        0x0111, 500 },
+};
+
+static struct otm3225a_spi_instruction display_off[] = {
+       { DISPLAY_CTRL_1,       0x0131, 100 },
+       { DISPLAY_CTRL_1,       0x0130, 100 },
+       { DISPLAY_CTRL_1,       0x0100, 0 },
+       { POWER_CTRL_1,         0x0280, 0 },
+       { POWER_CTRL_3,         0x018B, 0 },
+};
+
+static struct otm3225a_spi_instruction display_on[] = {
+       { POWER_CTRL_1,         0x1280, 0 },
+       { DISPLAY_CTRL_1,       0x0101, 100 },
+       { DISPLAY_CTRL_1,       0x0121, 0 },
+       { DISPLAY_CTRL_1,       0x0123, 100 },
+       { DISPLAY_CTRL_1,       0x0133, 10 },
+};
+
+static void otm3225a_write(struct spi_device *spi,
+                          struct otm3225a_spi_instruction *instruction,
+                          unsigned int count)
+{
+       unsigned char buf[3];
+
+       while (count--) {
+               /* address register using index register */
+               buf[0] = OTM3225A_INDEX_REG;
+               buf[1] = 0x00;
+               buf[2] = instruction->reg;
+               spi_write(spi, buf, 3);
+
+               /* write data to addressed register */
+               buf[0] = OTM3225A_DATA_REG;
+               buf[1] = (instruction->value >> 8) & 0xff;
+               buf[2] = instruction->value & 0xff;
+               spi_write(spi, buf, 3);
+
+               /* execute delay if any */
+               if (instruction->delay)
+                       msleep(instruction->delay);
+               instruction++;
+       }
+}
+
+static int otm3225a_set_power(struct lcd_device *ld, int power)
+{
+       struct otm3225a_data *dd = lcd_get_data(ld);
+
+       if (power == dd->power)
+               return 0;
+
+       if (power > FB_BLANK_UNBLANK)
+               otm3225a_write(dd->spi, display_off, ARRAY_SIZE(display_off));
+       else
+               otm3225a_write(dd->spi, display_on, ARRAY_SIZE(display_on));
+       dd->power = power;
+
+       return 0;
+}
+
+static int otm3225a_get_power(struct lcd_device *ld)
+{
+       struct otm3225a_data *dd = lcd_get_data(ld);
+
+       return dd->power;
+}
+
+static struct lcd_ops otm3225a_ops = {
+       .set_power = otm3225a_set_power,
+       .get_power = otm3225a_get_power,
+};
+
+static int otm3225a_probe(struct spi_device *spi)
+{
+       struct otm3225a_data *dd;
+       struct lcd_device *ld;
+       struct device *dev = &spi->dev;
+
+       dd = devm_kzalloc(dev, sizeof(struct otm3225a_data), GFP_KERNEL);
+       if (dd == NULL)
+               return -ENOMEM;
+
+       ld = devm_lcd_device_register(dev, dev_name(dev), dev, dd,
+                                     &otm3225a_ops);
+       if (IS_ERR(ld))
+               return PTR_ERR(ld);
+
+       dd->spi = spi;
+       dd->ld = ld;
+       dev_set_drvdata(dev, dd);
+
+       dev_info(dev, "Initializing and switching to RGB interface");
+       otm3225a_write(spi, display_init, ARRAY_SIZE(display_init));
+       otm3225a_write(spi, display_enable_rgb_interface,
+                      ARRAY_SIZE(display_enable_rgb_interface));
+       return 0;
+}
+
+static struct spi_driver otm3225a_driver = {
+       .driver = {
+               .name = "otm3225a",
+               .owner = THIS_MODULE,
+       },
+       .probe = otm3225a_probe,
+};
+
+module_spi_driver(otm3225a_driver);
+
+MODULE_AUTHOR("Felix Brack <fb@ltec.ch>");
+MODULE_DESCRIPTION("OTM3225A TFT LCD driver");
+MODULE_VERSION("1.0.0");
+MODULE_LICENSE("GPL v2");
index a186bc677c7d8071a3bf23c3ef6b8b5b9278031b..9618766e38666d0a9da4fa8124471154f2938c2e 100644 (file)
 #define MAX_VALUE 63
 #define MAX_USER_VALUE (MAX_VALUE - MIN_VALUE)
 
-#define PANDORABL_WAS_OFF BL_CORE_DRIVER1
+struct pandora_private {
+       unsigned old_state;
+#define PANDORABL_WAS_OFF 1
+};
 
 static int pandora_backlight_update_status(struct backlight_device *bl)
 {
        int brightness = bl->props.brightness;
+       struct pandora_private *priv = bl_get_data(bl);
        u8 r;
 
        if (bl->props.power != FB_BLANK_UNBLANK)
@@ -53,7 +57,7 @@ static int pandora_backlight_update_status(struct backlight_device *bl)
                brightness = MAX_USER_VALUE;
 
        if (brightness == 0) {
-               if (bl->props.state & PANDORABL_WAS_OFF)
+               if (priv->old_state == PANDORABL_WAS_OFF)
                        goto done;
 
                /* first disable PWM0 output, then clock */
@@ -66,7 +70,7 @@ static int pandora_backlight_update_status(struct backlight_device *bl)
                goto done;
        }
 
-       if (bl->props.state & PANDORABL_WAS_OFF) {
+       if (priv->old_state == PANDORABL_WAS_OFF) {
                /*
                 * set PWM duty cycle to max. TPS61161 seems to use this
                 * to calibrate it's PWM sensitivity when it starts.
@@ -93,9 +97,9 @@ static int pandora_backlight_update_status(struct backlight_device *bl)
 
 done:
        if (brightness != 0)
-               bl->props.state &= ~PANDORABL_WAS_OFF;
+               priv->old_state = 0;
        else
-               bl->props.state |= PANDORABL_WAS_OFF;
+               priv->old_state = PANDORABL_WAS_OFF;
 
        return 0;
 }
@@ -109,13 +113,20 @@ static int pandora_backlight_probe(struct platform_device *pdev)
 {
        struct backlight_properties props;
        struct backlight_device *bl;
+       struct pandora_private *priv;
        u8 r;
 
+       priv = devm_kmalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+       if (!priv) {
+               dev_err(&pdev->dev, "failed to allocate driver private data\n");
+               return -ENOMEM;
+       }
+
        memset(&props, 0, sizeof(props));
        props.max_brightness = MAX_USER_VALUE;
        props.type = BACKLIGHT_RAW;
        bl = devm_backlight_device_register(&pdev->dev, pdev->name, &pdev->dev,
-                                       NULL, &pandora_backlight_ops, &props);
+                                       priv, &pandora_backlight_ops, &props);
        if (IS_ERR(bl)) {
                dev_err(&pdev->dev, "failed to register backlight\n");
                return PTR_ERR(bl);
@@ -126,7 +137,7 @@ static int pandora_backlight_probe(struct platform_device *pdev)
        /* 64 cycle period, ON position 0 */
        twl_i2c_write_u8(TWL_MODULE_PWM, 0x80, TWL_PWM0_ON);
 
-       bl->props.state |= PANDORABL_WAS_OFF;
+       priv->old_state = PANDORABL_WAS_OFF;
        bl->props.brightness = MAX_USER_VALUE;
        backlight_update_status(bl);
 
index 1c2289ddd555a64a418f29edeaf8e4b5643430b9..44ac5bde4e9d1ad6a39e32c57d3350ffe0bdd8ab 100644 (file)
@@ -10,6 +10,7 @@
  * published by the Free Software Foundation.
  */
 
+#include <linux/delay.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/module.h>
@@ -35,6 +36,8 @@ struct pwm_bl_data {
        struct gpio_desc        *enable_gpio;
        unsigned int            scale;
        bool                    legacy;
+       unsigned int            post_pwm_on_delay;
+       unsigned int            pwm_off_delay;
        int                     (*notify)(struct device *,
                                          int brightness);
        void                    (*notify_after)(struct device *,
@@ -54,10 +57,14 @@ static void pwm_backlight_power_on(struct pwm_bl_data *pb, int brightness)
        if (err < 0)
                dev_err(pb->dev, "failed to enable power supply\n");
 
+       pwm_enable(pb->pwm);
+
+       if (pb->post_pwm_on_delay)
+               msleep(pb->post_pwm_on_delay);
+
        if (pb->enable_gpio)
                gpiod_set_value_cansleep(pb->enable_gpio, 1);
 
-       pwm_enable(pb->pwm);
        pb->enabled = true;
 }
 
@@ -66,12 +73,15 @@ static void pwm_backlight_power_off(struct pwm_bl_data *pb)
        if (!pb->enabled)
                return;
 
-       pwm_config(pb->pwm, 0, pb->period);
-       pwm_disable(pb->pwm);
-
        if (pb->enable_gpio)
                gpiod_set_value_cansleep(pb->enable_gpio, 0);
 
+       if (pb->pwm_off_delay)
+               msleep(pb->pwm_off_delay);
+
+       pwm_config(pb->pwm, 0, pb->period);
+       pwm_disable(pb->pwm);
+
        regulator_disable(pb->power_supply);
        pb->enabled = false;
 }
@@ -177,6 +187,14 @@ static int pwm_backlight_parse_dt(struct device *dev,
                data->max_brightness--;
        }
 
+       /*
+        * These values are optional and set as 0 by default, the out values
+        * are modified only if a valid u32 value can be decoded.
+        */
+       of_property_read_u32(node, "post-pwm-on-delay-ms",
+                            &data->post_pwm_on_delay);
+       of_property_read_u32(node, "pwm-off-delay-ms", &data->pwm_off_delay);
+
        data->enable_gpio = -EINVAL;
        return 0;
 }
@@ -275,6 +293,8 @@ static int pwm_backlight_probe(struct platform_device *pdev)
        pb->exit = data->exit;
        pb->dev = &pdev->dev;
        pb->enabled = false;
+       pb->post_pwm_on_delay = data->post_pwm_on_delay;
+       pb->pwm_off_delay = data->pwm_off_delay;
 
        pb->enable_gpio = devm_gpiod_get_optional(&pdev->dev, "enable",
                                                  GPIOD_ASIS);
@@ -301,14 +321,14 @@ static int pwm_backlight_probe(struct platform_device *pdev)
 
        /*
         * If the GPIO is not known to be already configured as output, that
-        * is, if gpiod_get_direction returns either GPIOF_DIR_IN or -EINVAL,
-        * change the direction to output and set the GPIO as active.
+        * is, if gpiod_get_direction returns either 1 or -EINVAL, change the
+        * direction to output and set the GPIO as active.
         * Do not force the GPIO to active when it was already output as it
         * could cause backlight flickering or we would enable the backlight too
         * early. Leave the decision of the initial backlight state for later.
         */
        if (pb->enable_gpio &&
-           gpiod_get_direction(pb->enable_gpio) != GPIOF_DIR_OUT)
+           gpiod_get_direction(pb->enable_gpio) != 0)
                gpiod_direction_output(pb->enable_gpio, 1);
 
        pb->power_supply = devm_regulator_get(&pdev->dev, "power");
diff --git a/drivers/video/backlight/rave-sp-backlight.c b/drivers/video/backlight/rave-sp-backlight.c
new file mode 100644 (file)
index 0000000..462f14a
--- /dev/null
@@ -0,0 +1,82 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/*
+ * LCD Backlight driver for RAVE SP
+ *
+ * Copyright (C) 2018 Zodiac Inflight Innovations
+ *
+ */
+
+#include <linux/backlight.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/mfd/rave-sp.h>
+#include <linux/platform_device.h>
+
+#define        RAVE_SP_BACKLIGHT_LCD_EN        BIT(7)
+
+static int rave_sp_backlight_update_status(struct backlight_device *bd)
+{
+       const struct backlight_properties *p = &bd->props;
+       const u8 intensity =
+               (p->power == FB_BLANK_UNBLANK) ? p->brightness : 0;
+       struct rave_sp *sp = dev_get_drvdata(&bd->dev);
+       u8 cmd[] = {
+               [0] = RAVE_SP_CMD_SET_BACKLIGHT,
+               [1] = 0,
+               [2] = intensity ? RAVE_SP_BACKLIGHT_LCD_EN | intensity : 0,
+               [3] = 0,
+               [4] = 0,
+       };
+
+       return rave_sp_exec(sp, cmd, sizeof(cmd), NULL, 0);
+}
+
+static const struct backlight_ops rave_sp_backlight_ops = {
+       .options        = BL_CORE_SUSPENDRESUME,
+       .update_status  = rave_sp_backlight_update_status,
+};
+
+static struct backlight_properties rave_sp_backlight_props = {
+       .type           = BACKLIGHT_PLATFORM,
+       .max_brightness = 100,
+       .brightness     = 50,
+};
+
+static int rave_sp_backlight_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct backlight_device *bd;
+
+       bd = devm_backlight_device_register(dev, pdev->name, dev->parent,
+                                           dev_get_drvdata(dev->parent),
+                                           &rave_sp_backlight_ops,
+                                           &rave_sp_backlight_props);
+       if (IS_ERR(bd))
+               return PTR_ERR(bd);
+
+       backlight_update_status(bd);
+
+       return 0;
+}
+
+static const struct of_device_id rave_sp_backlight_of_match[] = {
+       { .compatible = "zii,rave-sp-backlight" },
+       {}
+};
+
+static struct platform_driver rave_sp_backlight_driver = {
+       .probe = rave_sp_backlight_probe,
+       .driver = {
+               .name = KBUILD_MODNAME,
+               .of_match_table = rave_sp_backlight_of_match,
+       },
+};
+module_platform_driver(rave_sp_backlight_driver);
+
+MODULE_DEVICE_TABLE(of, rave_sp_backlight_of_match);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Andrey Vostrikov <andrey.vostrikov@cogentembedded.com>");
+MODULE_AUTHOR("Nikita Yushchenko <nikita.yoush@cogentembedded.com>");
+MODULE_AUTHOR("Andrey Smirnov <andrew.smirnov@gmail.com>");
+MODULE_DESCRIPTION("RAVE SP Backlight driver");
index 380917c862769524c56687c0e5bf86c8fc339914..762e3feed097cbd581f721d389a13dd52aa57aca 100644 (file)
@@ -184,11 +184,11 @@ static struct tps65217_bl_pdata *
 tps65217_bl_parse_dt(struct platform_device *pdev)
 {
        struct tps65217 *tps = dev_get_drvdata(pdev->dev.parent);
-       struct device_node *node = of_node_get(tps->dev->of_node);
+       struct device_node *node;
        struct tps65217_bl_pdata *pdata, *err;
        u32 val;
 
-       node = of_find_node_by_name(node, "backlight");
+       node = of_get_child_by_name(tps->dev->of_node, "backlight");
        if (!node)
                return ERR_PTR(-ENODEV);
 
index 08b822656846cca9072d40f40ea090635c75f1ab..ff45dca3ee46ab3faf3bc1452665708fdc9920af 100644 (file)
@@ -649,7 +649,7 @@ static void *sti_bmode_font_raw(struct sti_cooked_font *f)
        unsigned char *n, *p, *q;
        int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font);
        
-       n = kzalloc(4*size, STI_LOWMEM);
+       n = kcalloc(4, size, STI_LOWMEM);
        if (!n)
                return NULL;
        p = n + 3;
index d94254263ea5caa77887ceef92b9671fd38a4761..591a13a597874ec008430f00d448d9aab4a7b847 100644 (file)
@@ -1437,7 +1437,7 @@ config FB_SIS_315
 
 config FB_VIA
        tristate "VIA UniChrome (Pro) and Chrome9 display support"
-       depends on FB && PCI && X86 && GPIOLIB && I2C
+       depends on FB && PCI && GPIOLIB && I2C && (X86 || COMPILE_TEST)
        select FB_CFB_FILLRECT
        select FB_CFB_COPYAREA
        select FB_CFB_IMAGEBLIT
@@ -1888,7 +1888,6 @@ config FB_W100
 config FB_SH_MOBILE_LCDC
        tristate "SuperH Mobile LCDC framebuffer support"
        depends on FB && (SUPERH || ARCH_RENESAS) && HAVE_CLK
-       depends on FB_SH_MOBILE_MERAM || !FB_SH_MOBILE_MERAM
        select FB_SYS_FILLRECT
        select FB_SYS_COPYAREA
        select FB_SYS_IMAGEBLIT
@@ -2253,39 +2252,6 @@ config FB_BROADSHEET
          and could also have been called by other names when coupled with
          a bridge adapter.
 
-config FB_AUO_K190X
-       tristate "AUO-K190X EPD controller support"
-       depends on FB
-       select FB_SYS_FILLRECT
-       select FB_SYS_COPYAREA
-       select FB_SYS_IMAGEBLIT
-       select FB_SYS_FOPS
-       select FB_DEFERRED_IO
-       help
-         Provides support for epaper controllers from the K190X series
-         of AUO. These controllers can be used to drive epaper displays
-         from Sipix.
-
-         This option enables the common support, shared by the individual
-         controller drivers. You will also have to enable the driver
-         for the controller type used in your device.
-
-config FB_AUO_K1900
-       tristate "AUO-K1900 EPD controller support"
-       depends on FB && FB_AUO_K190X
-       help
-         This driver implements support for the AUO K1900 epd-controller.
-         This controller can drive Sipix epaper displays but can only do
-         serial updates, reducing the number of possible frames per second.
-
-config FB_AUO_K1901
-       tristate "AUO-K1901 EPD controller support"
-       depends on FB && FB_AUO_K190X
-       help
-         This driver implements support for the AUO K1901 epd-controller.
-         This controller can drive Sipix epaper displays and supports
-         concurrent updates, making higher frames per second possible.
-
 config FB_JZ4740
        tristate "JZ4740 LCD framebuffer support"
        depends on FB && MACH_JZ4740
@@ -2346,18 +2312,6 @@ source "drivers/video/fbdev/omap/Kconfig"
 source "drivers/video/fbdev/omap2/Kconfig"
 source "drivers/video/fbdev/mmp/Kconfig"
 
-config FB_SH_MOBILE_MERAM
-       tristate "SuperH Mobile MERAM read ahead support"
-       depends on (SUPERH || ARCH_SHMOBILE)
-       select GENERIC_ALLOCATOR
-       ---help---
-         Enable MERAM support for the SuperH controller.
-
-         This will allow for caching of the framebuffer to provide more
-         reliable access under heavy main memory bus traffic situations.
-         Up to 4 memory channels can be configured, allowing 4 RGB or
-         2 YCbCr framebuffers to be configured.
-
 config FB_SSD1307
        tristate "Solomon SSD1307 framebuffer support"
        depends on FB && I2C
index 55282a21b50031da1b451b7f5911edad59003324..13c900320c2cc375593d02bd0aa99381d03a6f81 100644 (file)
@@ -100,9 +100,6 @@ obj-$(CONFIG_FB_PMAGB_B)      += pmagb-b-fb.o
 obj-$(CONFIG_FB_MAXINE)                  += maxinefb.o
 obj-$(CONFIG_FB_METRONOME)        += metronomefb.o
 obj-$(CONFIG_FB_BROADSHEET)       += broadsheetfb.o
-obj-$(CONFIG_FB_AUO_K190X)       += auo_k190x.o
-obj-$(CONFIG_FB_AUO_K1900)       += auo_k1900fb.o
-obj-$(CONFIG_FB_AUO_K1901)       += auo_k1901fb.o
 obj-$(CONFIG_FB_S1D13XXX)        += s1d13xxxfb.o
 obj-$(CONFIG_FB_SH7760)                  += sh7760fb.o
 obj-$(CONFIG_FB_IMX)              += imxfb.o
@@ -116,7 +113,6 @@ obj-$(CONFIG_FB_SM501)            += sm501fb.o
 obj-$(CONFIG_FB_UDL)             += udlfb.o
 obj-$(CONFIG_FB_SMSCUFX)         += smscufx.o
 obj-$(CONFIG_FB_XILINX)           += xilinxfb.o
-obj-$(CONFIG_FB_SH_MOBILE_MERAM)  += sh_mobile_meram.o
 obj-$(CONFIG_FB_SH_MOBILE_LCDC)          += sh_mobile_lcdcfb.o
 obj-$(CONFIG_FB_OMAP)             += omap/
 obj-y                             += omap2/
index 09b0e558dce81d7eea45f4f38fd148e70341837f..6cc46867ff579432d9112962417689d5ebce0b3f 100644 (file)
@@ -2442,7 +2442,7 @@ static void aty128_set_suspend(struct aty128fb_par *par, int suspend)
                (void)aty_ld_pll(POWER_MANAGEMENT);
                aty_st_le32(BUS_CNTL1, 0x00000010);
                aty_st_le32(MEM_POWER_MISC, 0x0c830000);
-               mdelay(100);
+               msleep(100);
 
                /* Switch PCI power management to D2 */
                pci_set_power_state(pdev, PCI_D2);
index 7137c12cbcee30ce60bbdcc27c62fdaf0c9cfbdc..e695adb0e5733db9e00f0934506a0af57de09601 100644 (file)
@@ -2678,17 +2678,17 @@ int radeonfb_pci_suspend(struct pci_dev *pdev, pm_message_t mesg)
                 * it, we'll restore the dynamic clocks state on wakeup
                 */
                radeon_pm_disable_dynamic_mode(rinfo);
-               mdelay(50);
+               msleep(50);
                radeon_pm_save_regs(rinfo, 1);
 
                if (rinfo->is_mobility && !(rinfo->pm_mode & radeon_pm_d2)) {
                        /* Switch off LVDS interface */
-                       mdelay(1);
+                       usleep_range(1000, 2000);
                        OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_BL_MOD_EN));
-                       mdelay(1);
+                       usleep_range(1000, 2000);
                        OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_EN | LVDS_ON));
                        OUTREG(LVDS_PLL_CNTL, (INREG(LVDS_PLL_CNTL) & ~30000) | 0x20000);
-                       mdelay(20);
+                       msleep(20);
                        OUTREG(LVDS_GEN_CNTL, INREG(LVDS_GEN_CNTL) & ~(LVDS_DIGON));
                }
                pci_disable_device(pdev);
index 7c9a672e9811758f378a328790d5aeae3faf383b..0adf0683cf081f8439935793ebd7ed24fa2cc8a3 100644 (file)
@@ -464,7 +464,7 @@ static int au1100fb_drv_probe(struct platform_device *dev)
                                            PAGE_ALIGN(fbdev->fb_len),
                                            &fbdev->fb_phys, GFP_KERNEL);
        if (!fbdev->fb_mem) {
-               print_err("fail to allocate frambuffer (size: %dK))",
+               print_err("fail to allocate framebuffer (size: %dK))",
                          fbdev->fb_len / 1024);
                return -ENOMEM;
        }
@@ -501,7 +501,7 @@ static int au1100fb_drv_probe(struct platform_device *dev)
        fbdev->info.fix = au1100fb_fix;
 
        fbdev->info.pseudo_palette =
-               devm_kzalloc(&dev->dev, sizeof(u32) * 16, GFP_KERNEL);
+               devm_kcalloc(&dev->dev, 16, sizeof(u32), GFP_KERNEL);
        if (!fbdev->info.pseudo_palette)
                return -ENOMEM;
 
index 87d5a62bf6ca446fb8141b602c38839363dc120e..3872ccef4cb2c429a744e6dc4ea563e1c4b159c7 100644 (file)
@@ -1696,7 +1696,7 @@ static int au1200fb_drv_probe(struct platform_device *dev)
                                &fbdev->fb_phys, GFP_KERNEL,
                                DMA_ATTR_NON_CONSISTENT);
                if (!fbdev->fb_mem) {
-                       print_err("fail to allocate frambuffer (size: %dK))",
+                       print_err("fail to allocate framebuffer (size: %dK))",
                                  fbdev->fb_len / 1024);
                        ret = -ENOMEM;
                        goto failed;
diff --git a/drivers/video/fbdev/auo_k1900fb.c b/drivers/video/fbdev/auo_k1900fb.c
deleted file mode 100644 (file)
index 7637c60..0000000
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
- * auok190xfb.c -- FB driver for AUO-K1900 controllers
- *
- * Copyright (C) 2011, 2012 Heiko Stuebner <heiko@sntech.de>
- *
- * based on broadsheetfb.c
- *
- * Copyright (C) 2008, Jaya Kumar
- *
- * 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.
- *
- * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
- *
- * This driver is written to be used with the AUO-K1900 display controller.
- *
- * It is intended to be architecture independent. A board specific driver
- * must be used to perform all the physical IO interactions.
- *
- * The controller supports different update modes:
- * mode0+1 16 step gray (4bit)
- * mode2 4 step gray (2bit) - FIXME: add strange refresh
- * mode3 2 step gray (1bit) - FIXME: add strange refresh
- * mode4 handwriting mode (strange behaviour)
- * mode5 automatic selection of update mode
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/fb.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/list.h>
-#include <linux/firmware.h>
-#include <linux/gpio.h>
-#include <linux/pm_runtime.h>
-
-#include <video/auo_k190xfb.h>
-
-#include "auo_k190x.h"
-
-/*
- * AUO-K1900 specific commands
- */
-
-#define AUOK1900_CMD_PARTIALDISP       0x1001
-#define AUOK1900_CMD_ROTATION          0x1006
-#define AUOK1900_CMD_LUT_STOP          0x1009
-
-#define AUOK1900_INIT_TEMP_AVERAGE     (1 << 13)
-#define AUOK1900_INIT_ROTATE(_x)       ((_x & 0x3) << 10)
-#define AUOK1900_INIT_RESOLUTION(_res) ((_res & 0x7) << 2)
-
-static void auok1900_init(struct auok190xfb_par *par)
-{
-       struct device *dev = par->info->device;
-       struct auok190x_board *board = par->board;
-       u16 init_param = 0;
-
-       pm_runtime_get_sync(dev);
-
-       init_param |= AUOK1900_INIT_TEMP_AVERAGE;
-       init_param |= AUOK1900_INIT_ROTATE(par->rotation);
-       init_param |= AUOK190X_INIT_INVERSE_WHITE;
-       init_param |= AUOK190X_INIT_FORMAT0;
-       init_param |= AUOK1900_INIT_RESOLUTION(par->resolution);
-       init_param |= AUOK190X_INIT_SHIFT_RIGHT;
-
-       auok190x_send_cmdargs(par, AUOK190X_CMD_INIT, 1, &init_param);
-
-       /* let the controller finish */
-       board->wait_for_rdy(par);
-
-       pm_runtime_mark_last_busy(dev);
-       pm_runtime_put_autosuspend(dev);
-}
-
-static void auok1900_update_region(struct auok190xfb_par *par, int mode,
-                                               u16 y1, u16 y2)
-{
-       struct device *dev = par->info->device;
-       unsigned char *buf = (unsigned char *)par->info->screen_base;
-       int xres = par->info->var.xres;
-       int line_length = par->info->fix.line_length;
-       u16 args[4];
-
-       pm_runtime_get_sync(dev);
-
-       mutex_lock(&(par->io_lock));
-
-       /* y1 and y2 must be a multiple of 2 so drop the lowest bit */
-       y1 &= 0xfffe;
-       y2 &= 0xfffe;
-
-       dev_dbg(dev, "update (x,y,w,h,mode)=(%d,%d,%d,%d,%d)\n",
-               1, y1+1, xres, y2-y1, mode);
-
-       /* to FIX handle different partial update modes */
-       args[0] = mode | 1;
-       args[1] = y1 + 1;
-       args[2] = xres;
-       args[3] = y2 - y1;
-       buf += y1 * line_length;
-       auok190x_send_cmdargs_pixels(par, AUOK1900_CMD_PARTIALDISP, 4, args,
-                                    ((y2 - y1) * line_length)/2, (u16 *) buf);
-       auok190x_send_command(par, AUOK190X_CMD_DATA_STOP);
-
-       par->update_cnt++;
-
-       mutex_unlock(&(par->io_lock));
-
-       pm_runtime_mark_last_busy(dev);
-       pm_runtime_put_autosuspend(dev);
-}
-
-static void auok1900fb_dpy_update_pages(struct auok190xfb_par *par,
-                                               u16 y1, u16 y2)
-{
-       int mode;
-
-       if (par->update_mode < 0) {
-               mode = AUOK190X_UPDATE_MODE(1);
-               par->last_mode = -1;
-       } else {
-               mode = AUOK190X_UPDATE_MODE(par->update_mode);
-               par->last_mode = par->update_mode;
-       }
-
-       if (par->flash)
-               mode |= AUOK190X_UPDATE_NONFLASH;
-
-       auok1900_update_region(par, mode, y1, y2);
-}
-
-static void auok1900fb_dpy_update(struct auok190xfb_par *par)
-{
-       int mode;
-
-       if (par->update_mode < 0) {
-               mode = AUOK190X_UPDATE_MODE(0);
-               par->last_mode = -1;
-       } else {
-               mode = AUOK190X_UPDATE_MODE(par->update_mode);
-               par->last_mode = par->update_mode;
-       }
-
-       if (par->flash)
-               mode |= AUOK190X_UPDATE_NONFLASH;
-
-       auok1900_update_region(par, mode, 0, par->info->var.yres);
-       par->update_cnt = 0;
-}
-
-static bool auok1900fb_need_refresh(struct auok190xfb_par *par)
-{
-       return (par->update_cnt > 10);
-}
-
-static int auok1900fb_probe(struct platform_device *pdev)
-{
-       struct auok190x_init_data init;
-       struct auok190x_board *board;
-
-       /* pick up board specific routines */
-       board = pdev->dev.platform_data;
-       if (!board)
-               return -EINVAL;
-
-       /* fill temporary init struct for common init */
-       init.id = "auo_k1900fb";
-       init.board = board;
-       init.update_partial = auok1900fb_dpy_update_pages;
-       init.update_all = auok1900fb_dpy_update;
-       init.need_refresh = auok1900fb_need_refresh;
-       init.init = auok1900_init;
-
-       return auok190x_common_probe(pdev, &init);
-}
-
-static int auok1900fb_remove(struct platform_device *pdev)
-{
-       return auok190x_common_remove(pdev);
-}
-
-static struct platform_driver auok1900fb_driver = {
-       .probe  = auok1900fb_probe,
-       .remove = auok1900fb_remove,
-       .driver = {
-               .name   = "auo_k1900fb",
-               .pm = &auok190x_pm,
-       },
-};
-module_platform_driver(auok1900fb_driver);
-
-MODULE_DESCRIPTION("framebuffer driver for the AUO-K1900 EPD controller");
-MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
-MODULE_LICENSE("GPL");
diff --git a/drivers/video/fbdev/auo_k1901fb.c b/drivers/video/fbdev/auo_k1901fb.c
deleted file mode 100644 (file)
index 681fe61..0000000
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * auok190xfb.c -- FB driver for AUO-K1901 controllers
- *
- * Copyright (C) 2011, 2012 Heiko Stuebner <heiko@sntech.de>
- *
- * based on broadsheetfb.c
- *
- * Copyright (C) 2008, Jaya Kumar
- *
- * 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.
- *
- * Layout is based on skeletonfb.c by James Simmons and Geert Uytterhoeven.
- *
- * This driver is written to be used with the AUO-K1901 display controller.
- *
- * It is intended to be architecture independent. A board specific driver
- * must be used to perform all the physical IO interactions.
- *
- * The controller supports different update modes:
- * mode0+1 16 step gray (4bit)
- * mode2+3 4 step gray (2bit)
- * mode4+5 2 step gray (1bit)
- * - mode4 is described as "without LUT"
- * mode7 automatic selection of update mode
- *
- * The most interesting difference to the K1900 is the ability to do screen
- * updates in an asynchronous fashion. Where the K1900 needs to wait for the
- * current update to complete, the K1901 can process later updates already.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/errno.h>
-#include <linux/string.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
-#include <linux/delay.h>
-#include <linux/interrupt.h>
-#include <linux/fb.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/list.h>
-#include <linux/firmware.h>
-#include <linux/gpio.h>
-#include <linux/pm_runtime.h>
-
-#include <video/auo_k190xfb.h>
-
-#include "auo_k190x.h"
-
-/*
- * AUO-K1901 specific commands
- */
-
-#define AUOK1901_CMD_LUT_INTERFACE     0x0005
-#define AUOK1901_CMD_DMA_START         0x1001
-#define AUOK1901_CMD_CURSOR_START      0x1007
-#define AUOK1901_CMD_CURSOR_STOP       AUOK190X_CMD_DATA_STOP
-#define AUOK1901_CMD_DDMA_START                0x1009
-
-#define AUOK1901_INIT_GATE_PULSE_LOW   (0 << 14)
-#define AUOK1901_INIT_GATE_PULSE_HIGH  (1 << 14)
-#define AUOK1901_INIT_SINGLE_GATE      (0 << 13)
-#define AUOK1901_INIT_DOUBLE_GATE      (1 << 13)
-
-/* Bits to pixels
- *   Mode      15-12   11-8    7-4     3-0
- *   format2   2       T       1       T
- *   format3   1       T       2       T
- *   format4   T       2       T       1
- *   format5   T       1       T       2
- *
- *   halftone modes:
- *   format6   2       2       1       1
- *   format7   1       1       2       2
- */
-#define AUOK1901_INIT_FORMAT2          (1 << 7)
-#define AUOK1901_INIT_FORMAT3          ((1 << 7) | (1 << 6))
-#define AUOK1901_INIT_FORMAT4          (1 << 8)
-#define AUOK1901_INIT_FORMAT5          ((1 << 8) | (1 << 6))
-#define AUOK1901_INIT_FORMAT6          ((1 << 8) | (1 << 7))
-#define AUOK1901_INIT_FORMAT7          ((1 << 8) | (1 << 7) | (1 << 6))
-
-/* res[4] to bit 10
- * res[3-0] to bits 5-2
- */
-#define AUOK1901_INIT_RESOLUTION(_res) (((_res & (1 << 4)) << 6) \
-                                        | ((_res & 0xf) << 2))
-
-/*
- * portrait / landscape orientation in AUOK1901_CMD_DMA_START
- */
-#define AUOK1901_DMA_ROTATE90(_rot)            ((_rot & 1) << 13)
-
-/*
- * equivalent to 1 << 11, needs the ~ to have same rotation like K1900
- */
-#define AUOK1901_DDMA_ROTATE180(_rot)          ((~_rot & 2) << 10)
-
-static void auok1901_init(struct auok190xfb_par *par)
-{
-       struct device *dev = par->info->device;
-       struct auok190x_board *board = par->board;
-       u16 init_param = 0;
-
-       pm_runtime_get_sync(dev);
-
-       init_param |= AUOK190X_INIT_INVERSE_WHITE;
-       init_param |= AUOK190X_INIT_FORMAT0;
-       init_param |= AUOK1901_INIT_RESOLUTION(par->resolution);
-       init_param |= AUOK190X_INIT_SHIFT_LEFT;
-
-       auok190x_send_cmdargs(par, AUOK190X_CMD_INIT, 1, &init_param);
-
-       /* let the controller finish */
-       board->wait_for_rdy(par);
-
-       pm_runtime_mark_last_busy(dev);
-       pm_runtime_put_autosuspend(dev);
-}
-
-static void auok1901_update_region(struct auok190xfb_par *par, int mode,
-                                               u16 y1, u16 y2)
-{
-       struct device *dev = par->info->device;
-       unsigned char *buf = (unsigned char *)par->info->screen_base;
-       int xres = par->info->var.xres;
-       int line_length = par->info->fix.line_length;
-       u16 args[5];
-
-       pm_runtime_get_sync(dev);
-
-       mutex_lock(&(par->io_lock));
-
-       /* y1 and y2 must be a multiple of 2 so drop the lowest bit */
-       y1 &= 0xfffe;
-       y2 &= 0xfffe;
-
-       dev_dbg(dev, "update (x,y,w,h,mode)=(%d,%d,%d,%d,%d)\n",
-               1, y1+1, xres, y2-y1, mode);
-
-       /* K1901: first transfer the region data */
-       args[0] = AUOK1901_DMA_ROTATE90(par->rotation) | 1;
-       args[1] = y1 + 1;
-       args[2] = xres;
-       args[3] = y2 - y1;
-       buf += y1 * line_length;
-       auok190x_send_cmdargs_pixels_nowait(par, AUOK1901_CMD_DMA_START, 4,
-                                           args, ((y2 - y1) * line_length)/2,
-                                           (u16 *) buf);
-       auok190x_send_command_nowait(par, AUOK190X_CMD_DATA_STOP);
-
-       /* K1901: second tell the controller to update the region with mode */
-       args[0] = mode | AUOK1901_DDMA_ROTATE180(par->rotation);
-       args[1] = 1;
-       args[2] = y1 + 1;
-       args[3] = xres;
-       args[4] = y2 - y1;
-       auok190x_send_cmdargs_nowait(par, AUOK1901_CMD_DDMA_START, 5, args);
-
-       par->update_cnt++;
-
-       mutex_unlock(&(par->io_lock));
-
-       pm_runtime_mark_last_busy(dev);
-       pm_runtime_put_autosuspend(dev);
-}
-
-static void auok1901fb_dpy_update_pages(struct auok190xfb_par *par,
-                                               u16 y1, u16 y2)
-{
-       int mode;
-
-       if (par->update_mode < 0) {
-               mode = AUOK190X_UPDATE_MODE(1);
-               par->last_mode = -1;
-       } else {
-               mode = AUOK190X_UPDATE_MODE(par->update_mode);
-               par->last_mode = par->update_mode;
-       }
-
-       if (par->flash)
-               mode |= AUOK190X_UPDATE_NONFLASH;
-
-       auok1901_update_region(par, mode, y1, y2);
-}
-
-static void auok1901fb_dpy_update(struct auok190xfb_par *par)
-{
-       int mode;
-
-       /* When doing full updates, wait for the controller to be ready
-        * This will hopefully catch some hangs of the K1901
-        */
-       par->board->wait_for_rdy(par);
-
-       if (par->update_mode < 0) {
-               mode = AUOK190X_UPDATE_MODE(0);
-               par->last_mode = -1;
-       } else {
-               mode = AUOK190X_UPDATE_MODE(par->update_mode);
-               par->last_mode = par->update_mode;
-       }
-
-       if (par->flash)
-               mode |= AUOK190X_UPDATE_NONFLASH;
-
-       auok1901_update_region(par, mode, 0, par->info->var.yres);
-       par->update_cnt = 0;
-}
-
-static bool auok1901fb_need_refresh(struct auok190xfb_par *par)
-{
-       return (par->update_cnt > 10);
-}
-
-static int auok1901fb_probe(struct platform_device *pdev)
-{
-       struct auok190x_init_data init;
-       struct auok190x_board *board;
-
-       /* pick up board specific routines */
-       board = pdev->dev.platform_data;
-       if (!board)
-               return -EINVAL;
-
-       /* fill temporary init struct for common init */
-       init.id = "auo_k1901fb";
-       init.board = board;
-       init.update_partial = auok1901fb_dpy_update_pages;
-       init.update_all = auok1901fb_dpy_update;
-       init.need_refresh = auok1901fb_need_refresh;
-       init.init = auok1901_init;
-
-       return auok190x_common_probe(pdev, &init);
-}
-
-static int auok1901fb_remove(struct platform_device *pdev)
-{
-       return auok190x_common_remove(pdev);
-}
-
-static struct platform_driver auok1901fb_driver = {
-       .probe  = auok1901fb_probe,
-       .remove = auok1901fb_remove,
-       .driver = {
-               .name   = "auo_k1901fb",
-               .pm = &auok190x_pm,
-       },
-};
-module_platform_driver(auok1901fb_driver);
-
-MODULE_DESCRIPTION("framebuffer driver for the AUO-K1901 EPD controller");
-MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
-MODULE_LICENSE("GPL");
diff --git a/drivers/video/fbdev/auo_k190x.c b/drivers/video/fbdev/auo_k190x.c
deleted file mode 100644 (file)
index 9d24d1b..0000000
+++ /dev/null
@@ -1,1195 +0,0 @@
-/*
- * Common code for AUO-K190X framebuffer drivers
- *
- * Copyright (C) 2012 Heiko Stuebner <heiko@sntech.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/sched/mm.h>
-#include <linux/kernel.h>
-#include <linux/gpio.h>
-#include <linux/platform_device.h>
-#include <linux/pm_runtime.h>
-#include <linux/fb.h>
-#include <linux/delay.h>
-#include <linux/uaccess.h>
-#include <linux/vmalloc.h>
-#include <linux/regulator/consumer.h>
-
-#include <video/auo_k190xfb.h>
-
-#include "auo_k190x.h"
-
-struct panel_info {
-       int w;
-       int h;
-};
-
-/* table of panel specific parameters to be indexed into by the board drivers */
-static struct panel_info panel_table[] = {
-       /* standard 6" */
-       [AUOK190X_RESOLUTION_800_600] = {
-               .w = 800,
-               .h = 600,
-       },
-       /* standard 9" */
-       [AUOK190X_RESOLUTION_1024_768] = {
-               .w = 1024,
-               .h = 768,
-       },
-       [AUOK190X_RESOLUTION_600_800] = {
-               .w = 600,
-               .h = 800,
-       },
-       [AUOK190X_RESOLUTION_768_1024] = {
-               .w = 768,
-               .h = 1024,
-       },
-};
-
-/*
- * private I80 interface to the board driver
- */
-
-static void auok190x_issue_data(struct auok190xfb_par *par, u16 data)
-{
-       par->board->set_ctl(par, AUOK190X_I80_WR, 0);
-       par->board->set_hdb(par, data);
-       par->board->set_ctl(par, AUOK190X_I80_WR, 1);
-}
-
-static void auok190x_issue_cmd(struct auok190xfb_par *par, u16 data)
-{
-       par->board->set_ctl(par, AUOK190X_I80_DC, 0);
-       auok190x_issue_data(par, data);
-       par->board->set_ctl(par, AUOK190X_I80_DC, 1);
-}
-
-/**
- * Conversion of 16bit color to 4bit grayscale
- * does roughly (0.3 * R + 0.6 G + 0.1 B) / 2
- */
-static inline int rgb565_to_gray4(u16 data, struct fb_var_screeninfo *var)
-{
-       return ((((data & 0xF800) >> var->red.offset) * 77 +
-                ((data & 0x07E0) >> (var->green.offset + 1)) * 151 +
-                ((data & 0x1F) >> var->blue.offset) * 28) >> 8 >> 1);
-}
-
-static int auok190x_issue_pixels_rgb565(struct auok190xfb_par *par, int size,
-                                       u16 *data)
-{
-       struct fb_var_screeninfo *var = &par->info->var;
-       struct device *dev = par->info->device;
-       int i;
-       u16 tmp;
-
-       if (size & 7) {
-               dev_err(dev, "issue_pixels: size %d must be a multiple of 8\n",
-                       size);
-               return -EINVAL;
-       }
-
-       for (i = 0; i < (size >> 2); i++) {
-               par->board->set_ctl(par, AUOK190X_I80_WR, 0);
-
-               tmp  = (rgb565_to_gray4(data[4*i], var) & 0x000F);
-               tmp |= (rgb565_to_gray4(data[4*i+1], var) << 4) & 0x00F0;
-               tmp |= (rgb565_to_gray4(data[4*i+2], var) << 8) & 0x0F00;
-               tmp |= (rgb565_to_gray4(data[4*i+3], var) << 12) & 0xF000;
-
-               par->board->set_hdb(par, tmp);
-               par->board->set_ctl(par, AUOK190X_I80_WR, 1);
-       }
-
-       return 0;
-}
-
-static int auok190x_issue_pixels_gray8(struct auok190xfb_par *par, int size,
-                                      u16 *data)
-{
-       struct device *dev = par->info->device;
-       int i;
-       u16 tmp;
-
-       if (size & 3) {
-               dev_err(dev, "issue_pixels: size %d must be a multiple of 4\n",
-                       size);
-               return -EINVAL;
-       }
-
-       for (i = 0; i < (size >> 1); i++) {
-               par->board->set_ctl(par, AUOK190X_I80_WR, 0);
-
-               /* simple reduction of 8bit staticgray to 4bit gray
-                * combines 4 * 4bit pixel values into a 16bit value
-                */
-               tmp  = (data[2*i] & 0xF0) >> 4;
-               tmp |= (data[2*i] & 0xF000) >> 8;
-               tmp |= (data[2*i+1] & 0xF0) << 4;
-               tmp |= (data[2*i+1] & 0xF000);
-
-               par->board->set_hdb(par, tmp);
-               par->board->set_ctl(par, AUOK190X_I80_WR, 1);
-       }
-
-       return 0;
-}
-
-static int auok190x_issue_pixels(struct auok190xfb_par *par, int size,
-                                u16 *data)
-{
-       struct fb_info *info = par->info;
-       struct device *dev = par->info->device;
-
-       if (info->var.bits_per_pixel == 8 && info->var.grayscale)
-               auok190x_issue_pixels_gray8(par, size, data);
-       else if (info->var.bits_per_pixel == 16)
-               auok190x_issue_pixels_rgb565(par, size, data);
-       else
-               dev_err(dev, "unsupported color mode (bits: %d, gray: %d)\n",
-                       info->var.bits_per_pixel, info->var.grayscale);
-
-       return 0;
-}
-
-static u16 auok190x_read_data(struct auok190xfb_par *par)
-{
-       u16 data;
-
-       par->board->set_ctl(par, AUOK190X_I80_OE, 0);
-       data = par->board->get_hdb(par);
-       par->board->set_ctl(par, AUOK190X_I80_OE, 1);
-
-       return data;
-}
-
-/*
- * Command interface for the controller drivers
- */
-
-void auok190x_send_command_nowait(struct auok190xfb_par *par, u16 data)
-{
-       par->board->set_ctl(par, AUOK190X_I80_CS, 0);
-       auok190x_issue_cmd(par, data);
-       par->board->set_ctl(par, AUOK190X_I80_CS, 1);
-}
-EXPORT_SYMBOL_GPL(auok190x_send_command_nowait);
-
-void auok190x_send_cmdargs_nowait(struct auok190xfb_par *par, u16 cmd,
-                                 int argc, u16 *argv)
-{
-       int i;
-
-       par->board->set_ctl(par, AUOK190X_I80_CS, 0);
-       auok190x_issue_cmd(par, cmd);
-
-       for (i = 0; i < argc; i++)
-               auok190x_issue_data(par, argv[i]);
-       par->board->set_ctl(par, AUOK190X_I80_CS, 1);
-}
-EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_nowait);
-
-int auok190x_send_command(struct auok190xfb_par *par, u16 data)
-{
-       int ret;
-
-       ret = par->board->wait_for_rdy(par);
-       if (ret)
-               return ret;
-
-       auok190x_send_command_nowait(par, data);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(auok190x_send_command);
-
-int auok190x_send_cmdargs(struct auok190xfb_par *par, u16 cmd,
-                          int argc, u16 *argv)
-{
-       int ret;
-
-       ret = par->board->wait_for_rdy(par);
-       if (ret)
-               return ret;
-
-       auok190x_send_cmdargs_nowait(par, cmd, argc, argv);
-       return 0;
-}
-EXPORT_SYMBOL_GPL(auok190x_send_cmdargs);
-
-int auok190x_read_cmdargs(struct auok190xfb_par *par, u16 cmd,
-                          int argc, u16 *argv)
-{
-       int i, ret;
-
-       ret = par->board->wait_for_rdy(par);
-       if (ret)
-               return ret;
-
-       par->board->set_ctl(par, AUOK190X_I80_CS, 0);
-       auok190x_issue_cmd(par, cmd);
-
-       for (i = 0; i < argc; i++)
-               argv[i] = auok190x_read_data(par);
-       par->board->set_ctl(par, AUOK190X_I80_CS, 1);
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(auok190x_read_cmdargs);
-
-void auok190x_send_cmdargs_pixels_nowait(struct auok190xfb_par *par, u16 cmd,
-                                 int argc, u16 *argv, int size, u16 *data)
-{
-       int i;
-
-       par->board->set_ctl(par, AUOK190X_I80_CS, 0);
-
-       auok190x_issue_cmd(par, cmd);
-
-       for (i = 0; i < argc; i++)
-               auok190x_issue_data(par, argv[i]);
-
-       auok190x_issue_pixels(par, size, data);
-
-       par->board->set_ctl(par, AUOK190X_I80_CS, 1);
-}
-EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_pixels_nowait);
-
-int auok190x_send_cmdargs_pixels(struct auok190xfb_par *par, u16 cmd,
-                                 int argc, u16 *argv, int size, u16 *data)
-{
-       int ret;
-
-       ret = par->board->wait_for_rdy(par);
-       if (ret)
-               return ret;
-
-       auok190x_send_cmdargs_pixels_nowait(par, cmd, argc, argv, size, data);
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(auok190x_send_cmdargs_pixels);
-
-/*
- * fbdefio callbacks - common on both controllers.
- */
-
-static void auok190xfb_dpy_first_io(struct fb_info *info)
-{
-       /* tell runtime-pm that we wish to use the device in a short time */
-       pm_runtime_get(info->device);
-}
-
-/* this is called back from the deferred io workqueue */
-static void auok190xfb_dpy_deferred_io(struct fb_info *info,
-                               struct list_head *pagelist)
-{
-       struct fb_deferred_io *fbdefio = info->fbdefio;
-       struct auok190xfb_par *par = info->par;
-       u16 line_length = info->fix.line_length;
-       u16 yres = info->var.yres;
-       u16 y1 = 0, h = 0;
-       int prev_index = -1;
-       struct page *cur;
-       int h_inc;
-       int threshold;
-
-       if (!list_empty(pagelist))
-               /* the device resume should've been requested through first_io,
-                * if the resume did not finish until now, wait for it.
-                */
-               pm_runtime_barrier(info->device);
-       else
-               /* We reached this via the fsync or some other way.
-                * In either case the first_io function did not run,
-                * so we runtime_resume the device here synchronously.
-                */
-               pm_runtime_get_sync(info->device);
-
-       /* Do a full screen update every n updates to prevent
-        * excessive darkening of the Sipix display.
-        * If we do this, there is no need to walk the pages.
-        */
-       if (par->need_refresh(par)) {
-               par->update_all(par);
-               goto out;
-       }
-
-       /* height increment is fixed per page */
-       h_inc = DIV_ROUND_UP(PAGE_SIZE , line_length);
-
-       /* calculate number of pages from pixel height */
-       threshold = par->consecutive_threshold / h_inc;
-       if (threshold < 1)
-               threshold = 1;
-
-       /* walk the written page list and swizzle the data */
-       list_for_each_entry(cur, &fbdefio->pagelist, lru) {
-               if (prev_index < 0) {
-                       /* just starting so assign first page */
-                       y1 = (cur->index << PAGE_SHIFT) / line_length;
-                       h = h_inc;
-               } else if ((cur->index - prev_index) <= threshold) {
-                       /* page is within our threshold for single updates */
-                       h += h_inc * (cur->index - prev_index);
-               } else {
-                       /* page not consecutive, issue previous update first */
-                       par->update_partial(par, y1, y1 + h);
-
-                       /* start over with our non consecutive page */
-                       y1 = (cur->index << PAGE_SHIFT) / line_length;
-                       h = h_inc;
-               }
-               prev_index = cur->index;
-       }
-
-       /* if we still have any pages to update we do so now */
-       if (h >= yres)
-               /* its a full screen update, just do it */
-               par->update_all(par);
-       else
-               par->update_partial(par, y1, min((u16) (y1 + h), yres));
-
-out:
-       pm_runtime_mark_last_busy(info->device);
-       pm_runtime_put_autosuspend(info->device);
-}
-
-/*
- * framebuffer operations
- */
-
-/*
- * this is the slow path from userspace. they can seek and write to
- * the fb. it's inefficient to do anything less than a full screen draw
- */
-static ssize_t auok190xfb_write(struct fb_info *info, const char __user *buf,
-                               size_t count, loff_t *ppos)
-{
-       struct auok190xfb_par *par = info->par;
-       unsigned long p = *ppos;
-       void *dst;
-       int err = 0;
-       unsigned long total_size;
-
-       if (info->state != FBINFO_STATE_RUNNING)
-               return -EPERM;
-
-       total_size = info->fix.smem_len;
-
-       if (p > total_size)
-               return -EFBIG;
-
-       if (count > total_size) {
-               err = -EFBIG;
-               count = total_size;
-       }
-
-       if (count + p > total_size) {
-               if (!err)
-                       err = -ENOSPC;
-
-               count = total_size - p;
-       }
-
-       dst = (void *)(info->screen_base + p);
-
-       if (copy_from_user(dst, buf, count))
-               err = -EFAULT;
-
-       if  (!err)
-               *ppos += count;
-
-       par->update_all(par);
-
-       return (err) ? err : count;
-}
-
-static void auok190xfb_fillrect(struct fb_info *info,
-                                  const struct fb_fillrect *rect)
-{
-       struct auok190xfb_par *par = info->par;
-
-       sys_fillrect(info, rect);
-
-       par->update_all(par);
-}
-
-static void auok190xfb_copyarea(struct fb_info *info,
-                                  const struct fb_copyarea *area)
-{
-       struct auok190xfb_par *par = info->par;
-
-       sys_copyarea(info, area);
-
-       par->update_all(par);
-}
-
-static void auok190xfb_imageblit(struct fb_info *info,
-                               const struct fb_image *image)
-{
-       struct auok190xfb_par *par = info->par;
-
-       sys_imageblit(info, image);
-
-       par->update_all(par);
-}
-
-static int auok190xfb_check_var(struct fb_var_screeninfo *var,
-                                  struct fb_info *info)
-{
-       struct device *dev = info->device;
-       struct auok190xfb_par *par = info->par;
-       struct panel_info *panel = &panel_table[par->resolution];
-       int size;
-
-       /*
-        * Color depth
-        */
-
-       if (var->bits_per_pixel == 8 && var->grayscale == 1) {
-               /*
-                * For 8-bit grayscale, R, G, and B offset are equal.
-                */
-               var->red.length = 8;
-               var->red.offset = 0;
-               var->red.msb_right = 0;
-
-               var->green.length = 8;
-               var->green.offset = 0;
-               var->green.msb_right = 0;
-
-               var->blue.length = 8;
-               var->blue.offset = 0;
-               var->blue.msb_right = 0;
-
-               var->transp.length = 0;
-               var->transp.offset = 0;
-               var->transp.msb_right = 0;
-       } else if (var->bits_per_pixel == 16) {
-               var->red.length = 5;
-               var->red.offset = 11;
-               var->red.msb_right = 0;
-
-               var->green.length = 6;
-               var->green.offset = 5;
-               var->green.msb_right = 0;
-
-               var->blue.length = 5;
-               var->blue.offset = 0;
-               var->blue.msb_right = 0;
-
-               var->transp.length = 0;
-               var->transp.offset = 0;
-               var->transp.msb_right = 0;
-       } else {
-               dev_warn(dev, "unsupported color mode (bits: %d, grayscale: %d)\n",
-                       info->var.bits_per_pixel, info->var.grayscale);
-               return -EINVAL;
-       }
-
-       /*
-        * Dimensions
-        */
-
-       switch (var->rotate) {
-       case FB_ROTATE_UR:
-       case FB_ROTATE_UD:
-               var->xres = panel->w;
-               var->yres = panel->h;
-               break;
-       case FB_ROTATE_CW:
-       case FB_ROTATE_CCW:
-               var->xres = panel->h;
-               var->yres = panel->w;
-               break;
-       default:
-               dev_dbg(dev, "Invalid rotation request\n");
-               return -EINVAL;
-       }
-
-       var->xres_virtual = var->xres;
-       var->yres_virtual = var->yres;
-
-       /*
-        *  Memory limit
-        */
-
-       size = var->xres_virtual * var->yres_virtual * var->bits_per_pixel / 8;
-       if (size > info->fix.smem_len) {
-               dev_err(dev, "Memory limit exceeded, requested %dK\n",
-                       size >> 10);
-               return -ENOMEM;
-       }
-
-       return 0;
-}
-
-static int auok190xfb_set_fix(struct fb_info *info)
-{
-       struct fb_fix_screeninfo *fix = &info->fix;
-       struct fb_var_screeninfo *var = &info->var;
-
-       fix->line_length = var->xres_virtual * var->bits_per_pixel / 8;
-
-       fix->type = FB_TYPE_PACKED_PIXELS;
-       fix->accel = FB_ACCEL_NONE;
-       fix->visual = (var->grayscale) ? FB_VISUAL_STATIC_PSEUDOCOLOR
-                                      : FB_VISUAL_TRUECOLOR;
-       fix->xpanstep = 0;
-       fix->ypanstep = 0;
-       fix->ywrapstep = 0;
-
-       return 0;
-}
-
-static int auok190xfb_set_par(struct fb_info *info)
-{
-       struct auok190xfb_par *par = info->par;
-
-       par->rotation = info->var.rotate;
-       auok190xfb_set_fix(info);
-
-       /* reinit the controller to honor the rotation */
-       par->init(par);
-
-       /* wait for init to complete */
-       par->board->wait_for_rdy(par);
-
-       return 0;
-}
-
-static struct fb_ops auok190xfb_ops = {
-       .owner          = THIS_MODULE,
-       .fb_read        = fb_sys_read,
-       .fb_write       = auok190xfb_write,
-       .fb_fillrect    = auok190xfb_fillrect,
-       .fb_copyarea    = auok190xfb_copyarea,
-       .fb_imageblit   = auok190xfb_imageblit,
-       .fb_check_var   = auok190xfb_check_var,
-       .fb_set_par     = auok190xfb_set_par,
-};
-
-/*
- * Controller-functions common to both K1900 and K1901
- */
-
-static int auok190x_read_temperature(struct auok190xfb_par *par)
-{
-       struct device *dev = par->info->device;
-       u16 data[4];
-       int temp;
-
-       pm_runtime_get_sync(dev);
-
-       mutex_lock(&(par->io_lock));
-
-       auok190x_read_cmdargs(par, AUOK190X_CMD_READ_VERSION, 4, data);
-
-       mutex_unlock(&(par->io_lock));
-
-       pm_runtime_mark_last_busy(dev);
-       pm_runtime_put_autosuspend(dev);
-
-       /* sanitize and split of half-degrees for now */
-       temp = ((data[0] & AUOK190X_VERSION_TEMP_MASK) >> 1);
-
-       /* handle positive and negative temperatures */
-       if (temp >= 201)
-               return (255 - temp + 1) * (-1);
-       else
-               return temp;
-}
-
-static void auok190x_identify(struct auok190xfb_par *par)
-{
-       struct device *dev = par->info->device;
-       u16 data[4];
-
-       pm_runtime_get_sync(dev);
-
-       mutex_lock(&(par->io_lock));
-
-       auok190x_read_cmdargs(par, AUOK190X_CMD_READ_VERSION, 4, data);
-
-       mutex_unlock(&(par->io_lock));
-
-       par->epd_type = data[1] & AUOK190X_VERSION_TEMP_MASK;
-
-       par->panel_size_int = AUOK190X_VERSION_SIZE_INT(data[2]);
-       par->panel_size_float = AUOK190X_VERSION_SIZE_FLOAT(data[2]);
-       par->panel_model = AUOK190X_VERSION_MODEL(data[2]);
-
-       par->tcon_version = AUOK190X_VERSION_TCON(data[3]);
-       par->lut_version = AUOK190X_VERSION_LUT(data[3]);
-
-       dev_dbg(dev, "panel %d.%din, model 0x%x, EPD 0x%x TCON-rev 0x%x, LUT-rev 0x%x",
-               par->panel_size_int, par->panel_size_float, par->panel_model,
-               par->epd_type, par->tcon_version, par->lut_version);
-
-       pm_runtime_mark_last_busy(dev);
-       pm_runtime_put_autosuspend(dev);
-}
-
-/*
- * Sysfs functions
- */
-
-static ssize_t update_mode_show(struct device *dev,
-                               struct device_attribute *attr, char *buf)
-{
-       struct fb_info *info = dev_get_drvdata(dev);
-       struct auok190xfb_par *par = info->par;
-
-       return sprintf(buf, "%d\n", par->update_mode);
-}
-
-static ssize_t update_mode_store(struct device *dev,
-                                struct device_attribute *attr,
-                                const char *buf, size_t count)
-{
-       struct fb_info *info = dev_get_drvdata(dev);
-       struct auok190xfb_par *par = info->par;
-       int mode, ret;
-
-       ret = kstrtoint(buf, 10, &mode);
-       if (ret)
-               return ret;
-
-       par->update_mode = mode;
-
-       /* if we enter a better mode, do a full update */
-       if (par->last_mode > 1 && mode < par->last_mode)
-               par->update_all(par);
-
-       return count;
-}
-
-static ssize_t flash_show(struct device *dev, struct device_attribute *attr,
-                         char *buf)
-{
-       struct fb_info *info = dev_get_drvdata(dev);
-       struct auok190xfb_par *par = info->par;
-
-       return sprintf(buf, "%d\n", par->flash);
-}
-
-static ssize_t flash_store(struct device *dev, struct device_attribute *attr,
-                          const char *buf, size_t count)
-{
-       struct fb_info *info = dev_get_drvdata(dev);
-       struct auok190xfb_par *par = info->par;
-       int flash, ret;
-
-       ret = kstrtoint(buf, 10, &flash);
-       if (ret)
-               return ret;
-
-       if (flash > 0)
-               par->flash = 1;
-       else
-               par->flash = 0;
-
-       return count;
-}
-
-static ssize_t temp_show(struct device *dev, struct device_attribute *attr,
-                        char *buf)
-{
-       struct fb_info *info = dev_get_drvdata(dev);
-       struct auok190xfb_par *par = info->par;
-       int temp;
-
-       temp = auok190x_read_temperature(par);
-       return sprintf(buf, "%d\n", temp);
-}
-
-static DEVICE_ATTR_RW(update_mode);
-static DEVICE_ATTR_RW(flash);
-static DEVICE_ATTR(temp, 0644, temp_show, NULL);
-
-static struct attribute *auok190x_attributes[] = {
-       &dev_attr_update_mode.attr,
-       &dev_attr_flash.attr,
-       &dev_attr_temp.attr,
-       NULL
-};
-
-static const struct attribute_group auok190x_attr_group = {
-       .attrs          = auok190x_attributes,
-};
-
-static int auok190x_power(struct auok190xfb_par *par, bool on)
-{
-       struct auok190x_board *board = par->board;
-       int ret;
-
-       if (on) {
-               /* We should maintain POWER up for at least 80ms before set
-                * RST_N and SLP_N to high (TCON spec 20100803_v35 p59)
-                */
-               ret = regulator_enable(par->regulator);
-               if (ret)
-                       return ret;
-
-               msleep(200);
-               gpio_set_value(board->gpio_nrst, 1);
-               gpio_set_value(board->gpio_nsleep, 1);
-               msleep(200);
-       } else {
-               regulator_disable(par->regulator);
-               gpio_set_value(board->gpio_nrst, 0);
-               gpio_set_value(board->gpio_nsleep, 0);
-       }
-
-       return 0;
-}
-
-/*
- * Recovery - powercycle the controller
- */
-
-static void auok190x_recover(struct auok190xfb_par *par)
-{
-       struct device *dev = par->info->device;
-
-       auok190x_power(par, 0);
-       msleep(100);
-       auok190x_power(par, 1);
-
-       /* after powercycling the device, it's always active */
-       pm_runtime_set_active(dev);
-       par->standby = 0;
-
-       par->init(par);
-
-       /* wait for init to complete */
-       par->board->wait_for_rdy(par);
-}
-
-/*
- * Power-management
- */
-static int __maybe_unused auok190x_runtime_suspend(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct fb_info *info = platform_get_drvdata(pdev);
-       struct auok190xfb_par *par = info->par;
-       struct auok190x_board *board = par->board;
-       u16 standby_param;
-
-       /* take and keep the lock until we are resumed, as the controller
-        * will never reach the non-busy state when in standby mode
-        */
-       mutex_lock(&(par->io_lock));
-
-       if (par->standby) {
-               dev_warn(dev, "already in standby, runtime-pm pairing mismatch\n");
-               mutex_unlock(&(par->io_lock));
-               return 0;
-       }
-
-       /* according to runtime_pm.txt runtime_suspend only means, that the
-        * device will not process data and will not communicate with the CPU
-        * As we hold the lock, this stays true even without standby
-        */
-       if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) {
-               dev_dbg(dev, "runtime suspend without standby\n");
-               goto finish;
-       } else if (board->quirks & AUOK190X_QUIRK_STANDBYPARAM) {
-               /* for some TCON versions STANDBY expects a parameter (0) but
-                * it seems the real tcon version has to be determined yet.
-                */
-               dev_dbg(dev, "runtime suspend with additional empty param\n");
-               standby_param = 0;
-               auok190x_send_cmdargs(par, AUOK190X_CMD_STANDBY, 1,
-                                     &standby_param);
-       } else {
-               dev_dbg(dev, "runtime suspend without param\n");
-               auok190x_send_command(par, AUOK190X_CMD_STANDBY);
-       }
-
-       msleep(64);
-
-finish:
-       par->standby = 1;
-
-       return 0;
-}
-
-static int __maybe_unused auok190x_runtime_resume(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct fb_info *info = platform_get_drvdata(pdev);
-       struct auok190xfb_par *par = info->par;
-       struct auok190x_board *board = par->board;
-
-       if (!par->standby) {
-               dev_warn(dev, "not in standby, runtime-pm pairing mismatch\n");
-               return 0;
-       }
-
-       if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) {
-               dev_dbg(dev, "runtime resume without standby\n");
-       } else {
-               /* when in standby, controller is always busy
-                * and only accepts the wakeup command
-                */
-               dev_dbg(dev, "runtime resume from standby\n");
-               auok190x_send_command_nowait(par, AUOK190X_CMD_WAKEUP);
-
-               msleep(160);
-
-               /* wait for the controller to be ready and release the lock */
-               board->wait_for_rdy(par);
-       }
-
-       par->standby = 0;
-
-       mutex_unlock(&(par->io_lock));
-
-       return 0;
-}
-
-static int __maybe_unused auok190x_suspend(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct fb_info *info = platform_get_drvdata(pdev);
-       struct auok190xfb_par *par = info->par;
-       struct auok190x_board *board = par->board;
-       int ret;
-
-       dev_dbg(dev, "suspend\n");
-       if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) {
-               /* suspend via powering off the ic */
-               dev_dbg(dev, "suspend with broken standby\n");
-
-               auok190x_power(par, 0);
-       } else {
-               dev_dbg(dev, "suspend using sleep\n");
-
-               /* the sleep state can only be entered from the standby state.
-                * pm_runtime_get_noresume gets called before the suspend call.
-                * So the devices usage count is >0 but it is not necessarily
-                * active.
-                */
-               if (!pm_runtime_status_suspended(dev)) {
-                       ret = auok190x_runtime_suspend(dev);
-                       if (ret < 0) {
-                               dev_err(dev, "auok190x_runtime_suspend failed with %d\n",
-                                       ret);
-                               return ret;
-                       }
-                       par->manual_standby = 1;
-               }
-
-               gpio_direction_output(board->gpio_nsleep, 0);
-       }
-
-       msleep(100);
-
-       return 0;
-}
-
-static int __maybe_unused auok190x_resume(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct fb_info *info = platform_get_drvdata(pdev);
-       struct auok190xfb_par *par = info->par;
-       struct auok190x_board *board = par->board;
-
-       dev_dbg(dev, "resume\n");
-       if (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN) {
-               dev_dbg(dev, "resume with broken standby\n");
-
-               auok190x_power(par, 1);
-
-               par->init(par);
-       } else {
-               dev_dbg(dev, "resume from sleep\n");
-
-               /* device should be in runtime suspend when we were suspended
-                * and pm_runtime_put_sync gets called after this function.
-                * So there is no need to touch the standby mode here at all.
-                */
-               gpio_direction_output(board->gpio_nsleep, 1);
-               msleep(100);
-
-               /* an additional init call seems to be necessary after sleep */
-               auok190x_runtime_resume(dev);
-               par->init(par);
-
-               /* if we were runtime-suspended before, suspend again*/
-               if (!par->manual_standby)
-                       auok190x_runtime_suspend(dev);
-               else
-                       par->manual_standby = 0;
-       }
-
-       return 0;
-}
-
-const struct dev_pm_ops auok190x_pm = {
-       SET_RUNTIME_PM_OPS(auok190x_runtime_suspend, auok190x_runtime_resume,
-                          NULL)
-       SET_SYSTEM_SLEEP_PM_OPS(auok190x_suspend, auok190x_resume)
-};
-EXPORT_SYMBOL_GPL(auok190x_pm);
-
-/*
- * Common probe and remove code
- */
-
-int auok190x_common_probe(struct platform_device *pdev,
-                         struct auok190x_init_data *init)
-{
-       struct auok190x_board *board = init->board;
-       struct auok190xfb_par *par;
-       struct fb_info *info;
-       struct panel_info *panel;
-       int videomemorysize, ret;
-       unsigned char *videomemory;
-
-       /* check board contents */
-       if (!board->init || !board->cleanup || !board->wait_for_rdy
-           || !board->set_ctl || !board->set_hdb || !board->get_hdb
-           || !board->setup_irq)
-               return -EINVAL;
-
-       info = framebuffer_alloc(sizeof(struct auok190xfb_par), &pdev->dev);
-       if (!info)
-               return -ENOMEM;
-
-       par = info->par;
-       par->info = info;
-       par->board = board;
-       par->recover = auok190x_recover;
-       par->update_partial = init->update_partial;
-       par->update_all = init->update_all;
-       par->need_refresh = init->need_refresh;
-       par->init = init->init;
-
-       /* init update modes */
-       par->update_cnt = 0;
-       par->update_mode = -1;
-       par->last_mode = -1;
-       par->flash = 0;
-
-       par->regulator = regulator_get(info->device, "vdd");
-       if (IS_ERR(par->regulator)) {
-               ret = PTR_ERR(par->regulator);
-               dev_err(info->device, "Failed to get regulator: %d\n", ret);
-               goto err_reg;
-       }
-
-       ret = board->init(par);
-       if (ret) {
-               dev_err(info->device, "board init failed, %d\n", ret);
-               goto err_board;
-       }
-
-       ret = gpio_request(board->gpio_nsleep, "AUOK190x sleep");
-       if (ret) {
-               dev_err(info->device, "could not request sleep gpio, %d\n",
-                       ret);
-               goto err_gpio1;
-       }
-
-       ret = gpio_direction_output(board->gpio_nsleep, 0);
-       if (ret) {
-               dev_err(info->device, "could not set sleep gpio, %d\n", ret);
-               goto err_gpio2;
-       }
-
-       ret = gpio_request(board->gpio_nrst, "AUOK190x reset");
-       if (ret) {
-               dev_err(info->device, "could not request reset gpio, %d\n",
-                       ret);
-               goto err_gpio2;
-       }
-
-       ret = gpio_direction_output(board->gpio_nrst, 0);
-       if (ret) {
-               dev_err(info->device, "could not set reset gpio, %d\n", ret);
-               goto err_gpio3;
-       }
-
-       ret = auok190x_power(par, 1);
-       if (ret) {
-               dev_err(info->device, "could not power on the device, %d\n",
-                       ret);
-               goto err_gpio3;
-       }
-
-       mutex_init(&par->io_lock);
-
-       init_waitqueue_head(&par->waitq);
-
-       ret = par->board->setup_irq(par->info);
-       if (ret) {
-               dev_err(info->device, "could not setup ready-irq, %d\n", ret);
-               goto err_irq;
-       }
-
-       /* wait for init to complete */
-       par->board->wait_for_rdy(par);
-
-       /*
-        * From here on the controller can talk to us
-        */
-
-       /* initialise fix, var, resolution and rotation */
-
-       strlcpy(info->fix.id, init->id, 16);
-       info->var.bits_per_pixel = 8;
-       info->var.grayscale = 1;
-
-       panel = &panel_table[board->resolution];
-
-       par->resolution = board->resolution;
-       par->rotation = 0;
-
-       /* videomemory handling */
-
-       videomemorysize = roundup((panel->w * panel->h) * 2, PAGE_SIZE);
-       videomemory = vzalloc(videomemorysize);
-       if (!videomemory) {
-               ret = -ENOMEM;
-               goto err_irq;
-       }
-
-       info->screen_base = (char *)videomemory;
-       info->fix.smem_len = videomemorysize;
-
-       info->flags = FBINFO_FLAG_DEFAULT | FBINFO_VIRTFB;
-       info->fbops = &auok190xfb_ops;
-
-       ret = auok190xfb_check_var(&info->var, info);
-       if (ret)
-               goto err_defio;
-
-       auok190xfb_set_fix(info);
-
-       /* deferred io init */
-
-       info->fbdefio = devm_kzalloc(info->device,
-                                    sizeof(struct fb_deferred_io),
-                                    GFP_KERNEL);
-       if (!info->fbdefio) {
-               dev_err(info->device, "Failed to allocate memory\n");
-               ret = -ENOMEM;
-               goto err_defio;
-       }
-
-       dev_dbg(info->device, "targeting %d frames per second\n", board->fps);
-       info->fbdefio->delay = HZ / board->fps;
-       info->fbdefio->first_io = auok190xfb_dpy_first_io,
-       info->fbdefio->deferred_io = auok190xfb_dpy_deferred_io,
-       fb_deferred_io_init(info);
-
-       /* color map */
-
-       ret = fb_alloc_cmap(&info->cmap, 256, 0);
-       if (ret < 0) {
-               dev_err(info->device, "Failed to allocate colormap\n");
-               goto err_cmap;
-       }
-
-       /* controller init */
-
-       par->consecutive_threshold = 100;
-       par->init(par);
-       auok190x_identify(par);
-
-       platform_set_drvdata(pdev, info);
-
-       ret = register_framebuffer(info);
-       if (ret < 0)
-               goto err_regfb;
-
-       ret = sysfs_create_group(&info->device->kobj, &auok190x_attr_group);
-       if (ret)
-               goto err_sysfs;
-
-       dev_info(info->device, "fb%d: %dx%d using %dK of video memory\n",
-                info->node, info->var.xres, info->var.yres,
-                videomemorysize >> 10);
-
-       /* increase autosuspend_delay when we use alternative methods
-        * for runtime_pm
-        */
-       par->autosuspend_delay = (board->quirks & AUOK190X_QUIRK_STANDBYBROKEN)
-                                       ? 1000 : 200;
-
-       pm_runtime_set_active(info->device);
-       pm_runtime_enable(info->device);
-       pm_runtime_set_autosuspend_delay(info->device, par->autosuspend_delay);
-       pm_runtime_use_autosuspend(info->device);
-
-       return 0;
-
-err_sysfs:
-       unregister_framebuffer(info);
-err_regfb:
-       fb_dealloc_cmap(&info->cmap);
-err_cmap:
-       fb_deferred_io_cleanup(info);
-err_defio:
-       vfree((void *)info->screen_base);
-err_irq:
-       auok190x_power(par, 0);
-err_gpio3:
-       gpio_free(board->gpio_nrst);
-err_gpio2:
-       gpio_free(board->gpio_nsleep);
-err_gpio1:
-       board->cleanup(par);
-err_board:
-       regulator_put(par->regulator);
-err_reg:
-       framebuffer_release(info);
-
-       return ret;
-}
-EXPORT_SYMBOL_GPL(auok190x_common_probe);
-
-int  auok190x_common_remove(struct platform_device *pdev)
-{
-       struct fb_info *info = platform_get_drvdata(pdev);
-       struct auok190xfb_par *par = info->par;
-       struct auok190x_board *board = par->board;
-
-       pm_runtime_disable(info->device);
-
-       sysfs_remove_group(&info->device->kobj, &auok190x_attr_group);
-
-       unregister_framebuffer(info);
-
-       fb_dealloc_cmap(&info->cmap);
-
-       fb_deferred_io_cleanup(info);
-
-       vfree((void *)info->screen_base);
-
-       auok190x_power(par, 0);
-
-       gpio_free(board->gpio_nrst);
-       gpio_free(board->gpio_nsleep);
-
-       board->cleanup(par);
-
-       regulator_put(par->regulator);
-
-       framebuffer_release(info);
-
-       return 0;
-}
-EXPORT_SYMBOL_GPL(auok190x_common_remove);
-
-MODULE_DESCRIPTION("Common code for AUO-K190X controllers");
-MODULE_AUTHOR("Heiko Stuebner <heiko@sntech.de>");
-MODULE_LICENSE("GPL");
diff --git a/drivers/video/fbdev/auo_k190x.h b/drivers/video/fbdev/auo_k190x.h
deleted file mode 100644 (file)
index e35af1f..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Private common definitions for AUO-K190X framebuffer drivers
- *
- * Copyright (C) 2012 Heiko Stuebner <heiko@sntech.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-/*
- * I80 interface specific defines
- */
-
-#define AUOK190X_I80_CS                        0x01
-#define AUOK190X_I80_DC                        0x02
-#define AUOK190X_I80_WR                        0x03
-#define AUOK190X_I80_OE                        0x04
-
-/*
- * AUOK190x commands, common to both controllers
- */
-
-#define AUOK190X_CMD_INIT              0x0000
-#define AUOK190X_CMD_STANDBY           0x0001
-#define AUOK190X_CMD_WAKEUP            0x0002
-#define AUOK190X_CMD_TCON_RESET                0x0003
-#define AUOK190X_CMD_DATA_STOP         0x1002
-#define AUOK190X_CMD_LUT_START         0x1003
-#define AUOK190X_CMD_DISP_REFRESH      0x1004
-#define AUOK190X_CMD_DISP_RESET                0x1005
-#define AUOK190X_CMD_PRE_DISPLAY_START 0x100D
-#define AUOK190X_CMD_PRE_DISPLAY_STOP  0x100F
-#define AUOK190X_CMD_FLASH_W           0x2000
-#define AUOK190X_CMD_FLASH_E           0x2001
-#define AUOK190X_CMD_FLASH_STS         0x2002
-#define AUOK190X_CMD_FRAMERATE         0x3000
-#define AUOK190X_CMD_READ_VERSION      0x4000
-#define AUOK190X_CMD_READ_STATUS       0x4001
-#define AUOK190X_CMD_READ_LUT          0x4003
-#define AUOK190X_CMD_DRIVERTIMING      0x5000
-#define AUOK190X_CMD_LBALANCE          0x5001
-#define AUOK190X_CMD_AGINGMODE         0x6000
-#define AUOK190X_CMD_AGINGEXIT         0x6001
-
-/*
- * Common settings for AUOK190X_CMD_INIT
- */
-
-#define AUOK190X_INIT_DATA_FILTER      (0 << 12)
-#define AUOK190X_INIT_DATA_BYPASS      (1 << 12)
-#define AUOK190X_INIT_INVERSE_WHITE    (0 << 9)
-#define AUOK190X_INIT_INVERSE_BLACK    (1 << 9)
-#define AUOK190X_INIT_SCAN_DOWN                (0 << 1)
-#define AUOK190X_INIT_SCAN_UP          (1 << 1)
-#define AUOK190X_INIT_SHIFT_LEFT       (0 << 0)
-#define AUOK190X_INIT_SHIFT_RIGHT      (1 << 0)
-
-/* Common bits to pixels
- *   Mode      15-12   11-8    7-4     3-0
- *   format0   4       3       2       1
- *   format1   3       4       1       2
- */
-
-#define AUOK190X_INIT_FORMAT0          0
-#define AUOK190X_INIT_FORMAT1          (1 << 6)
-
-/*
- * settings for AUOK190X_CMD_RESET
- */
-
-#define AUOK190X_RESET_TCON            (0 << 0)
-#define AUOK190X_RESET_NORMAL          (1 << 0)
-#define AUOK190X_RESET_PON             (1 << 1)
-
-/*
- * AUOK190X_CMD_VERSION
- */
-
-#define AUOK190X_VERSION_TEMP_MASK             (0x1ff)
-#define AUOK190X_VERSION_EPD_MASK              (0xff)
-#define AUOK190X_VERSION_SIZE_INT(_val)                ((_val & 0xfc00) >> 10)
-#define AUOK190X_VERSION_SIZE_FLOAT(_val)      ((_val & 0x3c0) >> 6)
-#define AUOK190X_VERSION_MODEL(_val)           (_val & 0x3f)
-#define AUOK190X_VERSION_LUT(_val)             (_val & 0xff)
-#define AUOK190X_VERSION_TCON(_val)            ((_val & 0xff00) >> 8)
-
-/*
- * update modes for CMD_PARTIALDISP on K1900 and CMD_DDMA on K1901
- */
-
-#define AUOK190X_UPDATE_MODE(_res)             ((_res & 0x7) << 12)
-#define AUOK190X_UPDATE_NONFLASH               (1 << 15)
-
-/*
- * track panel specific parameters for common init
- */
-
-struct auok190x_init_data {
-       char *id;
-       struct auok190x_board *board;
-
-       void (*update_partial)(struct auok190xfb_par *par, u16 y1, u16 y2);
-       void (*update_all)(struct auok190xfb_par *par);
-       bool (*need_refresh)(struct auok190xfb_par *par);
-       void (*init)(struct auok190xfb_par *par);
-};
-
-
-extern void auok190x_send_command_nowait(struct auok190xfb_par *par, u16 data);
-extern int auok190x_send_command(struct auok190xfb_par *par, u16 data);
-extern void auok190x_send_cmdargs_nowait(struct auok190xfb_par *par, u16 cmd,
-                                        int argc, u16 *argv);
-extern int auok190x_send_cmdargs(struct auok190xfb_par *par, u16 cmd,
-                                 int argc, u16 *argv);
-extern void auok190x_send_cmdargs_pixels_nowait(struct auok190xfb_par *par,
-                                               u16 cmd, int argc, u16 *argv,
-                                               int size, u16 *data);
-extern int auok190x_send_cmdargs_pixels(struct auok190xfb_par *par, u16 cmd,
-                                       int argc, u16 *argv, int size,
-                                       u16 *data);
-extern int auok190x_read_cmdargs(struct auok190xfb_par *par, u16 cmd,
-                                 int argc, u16 *argv);
-
-extern int auok190x_common_probe(struct platform_device *pdev,
-                                struct auok190x_init_data *init);
-extern int auok190x_common_remove(struct platform_device *pdev);
-
-extern const struct dev_pm_ops auok190x_pm;
index 9f9a7bef1ff6d46d80fe8cb6dcfeea5a3e26729d..d6ba348deb9fbd74935d0fd2c3aec59785428b64 100644 (file)
@@ -617,7 +617,7 @@ static int broadsheet_spiflash_rewrite_sector(struct broadsheetfb_par *par,
        int tail_start_addr;
        int start_sector_addr;
 
-       sector_buffer = kzalloc(sizeof(char)*sector_size, GFP_KERNEL);
+       sector_buffer = kzalloc(sector_size, GFP_KERNEL);
        if (!sector_buffer)
                return -ENOMEM;
 
index 790900d646c03cf2c96871e9373c367a58edc83e..ca935c09a261c7b5f341b47fe344397b8a9ad3ac 100644 (file)
@@ -269,7 +269,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
        if (attribute) {
                u8 *dst;
 
-               dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC);
+               dst = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC);
                if (!dst)
                        return;
                kfree(ops->cursor_data);
@@ -312,7 +312,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode,
            vc->vc_cursor_type != ops->p->cursor_shape ||
            ops->cursor_state.mask == NULL ||
            ops->cursor_reset) {
-               char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC);
+               char *mask = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC);
                int cur_height, size, i = 0;
                u8 msk = 0xff;
 
index 487d5e336e1b6cdb9f1375577afbdb8fd8a8565d..82c20c6047b0e7020c7a678b557e59e488da87dd 100644 (file)
@@ -37,7 +37,7 @@ static struct page *fb_deferred_io_page(struct fb_info *info, unsigned long offs
 }
 
 /* this is to find and return the vmalloc-ed fb pages */
-static int fb_deferred_io_fault(struct vm_fault *vmf)
+static vm_fault_t fb_deferred_io_fault(struct vm_fault *vmf)
 {
        unsigned long offset;
        struct page *page;
@@ -90,7 +90,7 @@ int fb_deferred_io_fsync(struct file *file, loff_t start, loff_t end, int datasy
 EXPORT_SYMBOL_GPL(fb_deferred_io_fsync);
 
 /* vm_ops->page_mkwrite handler */
-static int fb_deferred_io_mkwrite(struct vm_fault *vmf)
+static vm_fault_t fb_deferred_io_mkwrite(struct vm_fault *vmf)
 {
        struct page *page = vmf->page;
        struct fb_info *info = vmf->vma->vm_private_data;
index 3e330e0f56edc2ba693e3de4e91cd07db8078f7c..c910e74d46ffff43b56c36aae1dedf04494c95af 100644 (file)
@@ -591,7 +591,8 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info,
                if (scr_readw(r) != vc->vc_video_erase_char)
                        break;
        if (r != q && new_rows >= rows + logo_lines) {
-               save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL);
+               save = kmalloc(array3_size(logo_lines, new_cols, 2),
+                              GFP_KERNEL);
                if (save) {
                        int i = cols < new_cols ? cols : new_cols;
                        scr_memsetw(save, erase, logo_lines * new_cols * 2);
index 37a8b0b225663780e6e28dd4ba239a6be9581071..dfa9a8aa4509c1705ec2beeda76ff3cf03e60e65 100644 (file)
@@ -258,7 +258,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
        if (attribute) {
                u8 *dst;
 
-               dst = kmalloc(w * vc->vc_font.width, GFP_ATOMIC);
+               dst = kmalloc_array(w, vc->vc_font.width, GFP_ATOMIC);
                if (!dst)
                        return;
                kfree(ops->cursor_data);
@@ -304,14 +304,15 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
            vc->vc_cursor_type != ops->p->cursor_shape ||
            ops->cursor_state.mask == NULL ||
            ops->cursor_reset) {
-               char *tmp, *mask = kmalloc(w*vc->vc_font.width, GFP_ATOMIC);
+               char *tmp, *mask = kmalloc_array(w, vc->vc_font.width,
+                                                GFP_ATOMIC);
                int cur_height, size, i = 0;
                int width = (vc->vc_font.width + 7)/8;
 
                if (!mask)
                        return;
 
-               tmp = kmalloc(width * vc->vc_font.height, GFP_ATOMIC);
+               tmp = kmalloc_array(width, vc->vc_font.height, GFP_ATOMIC);
 
                if (!tmp) {
                        kfree(mask);
index 1888f8c866e82ecc35571fe9ad35493f0feedef2..ce08251bfd38df4f1c79705a5f64593d1434d667 100644 (file)
@@ -241,7 +241,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
        if (attribute) {
                u8 *dst;
 
-               dst = kmalloc(w * vc->vc_font.width, GFP_ATOMIC);
+               dst = kmalloc_array(w, vc->vc_font.width, GFP_ATOMIC);
                if (!dst)
                        return;
                kfree(ops->cursor_data);
@@ -287,14 +287,15 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode,
            vc->vc_cursor_type != ops->p->cursor_shape ||
            ops->cursor_state.mask == NULL ||
            ops->cursor_reset) {
-               char *tmp, *mask = kmalloc(w*vc->vc_font.width, GFP_ATOMIC);
+               char *tmp, *mask = kmalloc_array(w, vc->vc_font.width,
+                                                GFP_ATOMIC);
                int cur_height, size, i = 0;
                int width = (vc->vc_font.width + 7)/8;
 
                if (!mask)
                        return;
 
-               tmp = kmalloc(width * vc->vc_font.height, GFP_ATOMIC);
+               tmp = kmalloc_array(width, vc->vc_font.height, GFP_ATOMIC);
 
                if (!tmp) {
                        kfree(mask);
index 8a51e4d95cc5062ae9efa6c14ac7433de9e668bd..c0d445294aa7c3521e1045480e2636995d93db6c 100644 (file)
@@ -46,7 +46,7 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc)
                info->fbops->fb_sync(info);
 
        if (ops->fd_size < d_cellsize * len) {
-               dst = kmalloc(d_cellsize * len, GFP_KERNEL);
+               dst = kmalloc_array(len, d_cellsize, GFP_KERNEL);
 
                if (dst == NULL) {
                        err = -ENOMEM;
index f98eee263597b08a9677dc8f0072fc62a2cba022..1936afc78fec5ca0b4b8d1cf17c4cc5f92a1538e 100644 (file)
@@ -289,7 +289,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode,
        if (attribute) {
                u8 *dst;
 
-               dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC);
+               dst = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC);
                if (!dst)
                        return;
                kfree(ops->cursor_data);
@@ -335,7 +335,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode,
            vc->vc_cursor_type != ops->p->cursor_shape ||
            ops->cursor_state.mask == NULL ||
            ops->cursor_reset) {
-               char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC);
+               char *mask = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC);
                int cur_height, size, i = 0;
                u8 msk = 0xff;
 
index 924d0730ffe2a80bba32cd36ea41b7d72f357fea..609438d2465b288f831eb086b9d0ef982bb5ddef 100644 (file)
@@ -489,7 +489,8 @@ static int fb_show_logo_line(struct fb_info *info, int rotate,
        }
 
        if (fb_logo.depth <= 4) {
-               logo_new = kmalloc(logo->width * logo->height, GFP_KERNEL);
+               logo_new = kmalloc_array(logo->width, logo->height,
+                                        GFP_KERNEL);
                if (logo_new == NULL) {
                        kfree(palette);
                        if (saved_pseudo_palette)
@@ -506,8 +507,8 @@ static int fb_show_logo_line(struct fb_info *info, int rotate,
        image.height = logo->height;
 
        if (rotate) {
-               logo_rotate = kmalloc(logo->width *
-                                     logo->height, GFP_KERNEL);
+               logo_rotate = kmalloc_array(logo->width, logo->height,
+                                           GFP_KERNEL);
                if (logo_rotate)
                        fb_rotate_logo(info, logo_rotate, &image, rotate);
        }
index 2b2d673285148bc4dba1eb24c8d0d18f4d8b6a01..852d86c1c527ac26c3987d18d379108849f8060b 100644 (file)
@@ -620,7 +620,7 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize,
        int num = 0, i, first = 1;
        int ver, rev;
 
-       mode = kzalloc(50 * sizeof(struct fb_videomode), GFP_KERNEL);
+       mode = kcalloc(50, sizeof(struct fb_videomode), GFP_KERNEL);
        if (mode == NULL)
                return NULL;
 
@@ -671,7 +671,7 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize,
        }
 
        *dbsize = num;
-       m = kmalloc(num * sizeof(struct fb_videomode), GFP_KERNEL);
+       m = kmalloc_array(num, sizeof(struct fb_videomode), GFP_KERNEL);
        if (!m)
                return mode;
        memmove(m, mode, num * sizeof(struct fb_videomode));
@@ -1055,8 +1055,9 @@ void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs)
        if (!(num + svd_n))
                return;
 
-       m = kzalloc((specs->modedb_len + num + svd_n) *
-                      sizeof(struct fb_videomode), GFP_KERNEL);
+       m = kcalloc(specs->modedb_len + num + svd_n,
+                   sizeof(struct fb_videomode),
+                   GFP_KERNEL);
 
        if (!m)
                return;
index ba82f97fb42b2d10fdbebd227fcb7e5eb19dcbdc..c4eb8661f7516d965d3a988400ce10730a181a4e 100644 (file)
@@ -662,7 +662,7 @@ static int imxfb_init_fbinfo(struct platform_device *pdev)
 
        pr_debug("%s\n",__func__);
 
-       info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL);
+       info->pseudo_palette = kmalloc_array(16, sizeof(u32), GFP_KERNEL);
        if (!info->pseudo_palette)
                return -ENOMEM;
 
index fe92eed6da70c01bb1a96b07c23f87561d5dac18..8dd296d257ddd61a165a229f892fd1d6c2ad9974 100644 (file)
@@ -245,7 +245,7 @@ static void mb86290fb_imageblit(struct fb_info *info,
                return;
        }
 
-       cmd = kmalloc(cmdlen * 4, GFP_DMA);
+       cmd = kmalloc_array(cmdlen, 4, GFP_DMA);
        if (!cmd)
                return cfb_imageblit(info, image);
        cmdfn(cmd, step, dx, dy, width, height, fgcolor, bgcolor, image, info);
index 92279e02dd94bdd4952b79cf31f6e5fad44dfb58..ee212be67dc65eaaffc205af89e0e27ec7a3d5b9 100644 (file)
@@ -493,12 +493,11 @@ static int modes_setup(struct mmpfb_info *fbi)
                return 0;
        }
        /* put videomode list to info structure */
-       videomodes = kzalloc(sizeof(struct fb_videomode) * videomode_num,
-                       GFP_KERNEL);
-       if (!videomodes) {
-               dev_err(fbi->dev, "can't malloc video modes\n");
+       videomodes = kcalloc(videomode_num, sizeof(struct fb_videomode),
+                            GFP_KERNEL);
+       if (!videomodes)
                return -ENOMEM;
-       }
+
        for (i = 0; i < videomode_num; i++)
                mmpmode_to_fbmode(&videomodes[i], &mmp_modes[i]);
        fb_videomode_to_modelist(videomodes, videomode_num, &info->modelist);
index b6f83d5df9fdeab329478d5ccfeb78610da9e532..fcdbb2df137f891e58bcdce792a3a3101daa73d1 100644 (file)
@@ -406,12 +406,10 @@ static int path_init(struct mmphw_path_plat *path_plat,
        dev_info(ctrl->dev, "%s: %s\n", __func__, config->name);
 
        /* init driver data */
-       path_info = kzalloc(sizeof(struct mmp_path_info), GFP_KERNEL);
-       if (!path_info) {
-               dev_err(ctrl->dev, "%s: unable to alloc path_info for %s\n",
-                               __func__, config->name);
+       path_info = kzalloc(sizeof(*path_info), GFP_KERNEL);
+       if (!path_info)
                return 0;
-       }
+
        path_info->name = config->name;
        path_info->id = path_plat->id;
        path_info->dev = ctrl->dev;
index 246bea3a7d9bc40aea75a94dff7274f70cc65833..12c8bd1d24d5321af7106c3738eeffbee056b25d 100644 (file)
@@ -931,7 +931,7 @@ static int mxsfb_probe(struct platform_device *pdev)
        if (IS_ERR(host->reg_lcd))
                host->reg_lcd = NULL;
 
-       fb_info->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16,
+       fb_info->pseudo_palette = devm_kcalloc(&pdev->dev, 16, sizeof(u32),
                                               GFP_KERNEL);
        if (!fb_info->pseudo_palette) {
                ret = -ENOMEM;
index 418a2d0d06a95b7005472983f386a75bc4426abf..fbeeed5afe350deff19eea67c1463ba5ba158fe6 100644 (file)
@@ -566,7 +566,7 @@ static int nvidiafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
                u8 *msk = (u8 *) cursor->mask;
                u8 *src;
 
-               src = kmalloc(s_pitch * cursor->image.height, GFP_ATOMIC);
+               src = kmalloc_array(s_pitch, cursor->image.height, GFP_ATOMIC);
 
                if (src) {
                        switch (cursor->rop) {
@@ -1548,7 +1548,7 @@ MODULE_PARM_DESC(noaccel,
                 "(default=0)");
 module_param(noscale, int, 0);
 MODULE_PARM_DESC(noscale,
-                "Disables screen scaleing. (0 or 1=disable) "
+                "Disables screen scaling. (0 or 1=disable) "
                 "(default=0, do scaling)");
 module_param(paneltweak, int, 0);
 MODULE_PARM_DESC(paneltweak,
index a4ee947006c77c5178161f52df2938db8a45c4cd..e8c748a0dfe25f5113a1fc7ebbbf94614fa88290 100644 (file)
@@ -197,3 +197,7 @@ static struct platform_driver ams_delta_panel_driver = {
 };
 
 module_platform_driver(ams_delta_panel_driver);
+
+MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
+MODULE_DESCRIPTION("LCD panel support for the Amstrad E3 (Delta) videophone");
+MODULE_LICENSE("GPL");
index 796f4634c4c6f157a24769bf1aa34758840c82ec..fd0ac997fb8cd963137ef56fb8a46142d926668e 100644 (file)
@@ -89,3 +89,7 @@ static struct platform_driver h3_panel_driver = {
 };
 
 module_platform_driver(h3_panel_driver);
+
+MODULE_AUTHOR("Imre Deak");
+MODULE_DESCRIPTION("LCD panel support for the TI OMAP H3 board");
+MODULE_LICENSE("GPL");
index 9d692f5b80253c039bc878599f2c082daca5ff54..db4ff1c6add9984596fd89608973c029a8a0db17 100644 (file)
@@ -66,3 +66,7 @@ static struct platform_driver htcherald_panel_driver = {
 };
 
 module_platform_driver(htcherald_panel_driver);
+
+MODULE_AUTHOR("Cory Maccarrone");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("LCD panel support for the HTC Herald");
index b284050f54717b132fdb1bd1f67eb44a19f7b0d3..1ea775f17bc1d73c3b81feca9736a7ee100fe2ee 100644 (file)
@@ -73,3 +73,7 @@ static struct platform_driver innovator1510_panel_driver = {
 };
 
 module_platform_driver(innovator1510_panel_driver);
+
+MODULE_AUTHOR("Imre Deak");
+MODULE_DESCRIPTION("LCD panel support for the TI OMAP1510 Innovator board");
+MODULE_LICENSE("GPL");
index 1841710e796f779453e1fda56fea2a45f78a71df..8d0cf68d2de330af489377f9a6b5c3700576f79d 100644 (file)
@@ -106,3 +106,7 @@ static struct platform_driver innovator1610_panel_driver = {
 };
 
 module_platform_driver(innovator1610_panel_driver);
+
+MODULE_AUTHOR("Imre Deak");
+MODULE_DESCRIPTION("LCD panel support for the TI OMAP1610 Innovator board");
+MODULE_LICENSE("GPL");
index b0be5771fe90ee6704fb0ec2882f2cc133162a62..9fc43a14957d23cec1673adab5e098451614db2d 100644 (file)
@@ -93,3 +93,7 @@ static struct platform_driver osk_panel_driver = {
 };
 
 module_platform_driver(osk_panel_driver);
+
+MODULE_AUTHOR("Imre Deak");
+MODULE_DESCRIPTION("LCD panel support for the TI OMAP OSK board");
+MODULE_LICENSE("GPL");
index cef96386cf8021e0b16118cb017175e00f3a07ed..a0e88864313146300bd78e00a82dfc2beed7f052 100644 (file)
@@ -59,3 +59,7 @@ static struct platform_driver palmte_panel_driver = {
 };
 
 module_platform_driver(palmte_panel_driver);
+
+MODULE_AUTHOR("Romain Goyet <r.goyet@gmail.com>, Laurent Gonzalez <palmte.linux@free.fr>");
+MODULE_DESCRIPTION("LCD panel support for the Palm Tungsten E");
+MODULE_LICENSE("GPL");
index 627f13dae5ad69011e5f5c7e0e783459d6b939ea..2c45375e456f413079aaa7815b2e39a4dea39e5e 100644 (file)
@@ -72,3 +72,7 @@ static struct platform_driver palmtt_panel_driver = {
 };
 
 module_platform_driver(palmtt_panel_driver);
+
+MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
+MODULE_DESCRIPTION("LCD panel support for Palm Tungsten|T");
+MODULE_LICENSE("GPL");
index c46d4db1f839ff83b23a5ae6278e60bad418f681..c99a15ab182633e3b71a5ecaa6f7127764500340 100644 (file)
@@ -66,3 +66,7 @@ static struct platform_driver palmz71_panel_driver = {
 };
 
 module_platform_driver(palmz71_panel_driver);
+
+MODULE_AUTHOR("Romain Goyet, Laurent Gonzalez, Marek Vasut");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("LCD panel support for the Palm Zire71");
index 3479a47a308208f3c414efde067f9cf8cfecd17c..585f39efcff674715575221ce6a3a6ab43c214eb 100644 (file)
@@ -1645,7 +1645,7 @@ static int omapfb_do_probe(struct platform_device *pdev,
                goto cleanup;
        }
 
-       fbdev = kzalloc(sizeof(struct omapfb_device), GFP_KERNEL);
+       fbdev = kzalloc(sizeof(*fbdev), GFP_KERNEL);
        if (fbdev == NULL) {
                dev_err(&pdev->dev,
                        "unable to allocate memory for device info\n");
index e6226aeed17ed7f75407170693bccb2d5fdabdc8..3bf154e676d1cc7cea1f812482fcf135a6d0b088 100644 (file)
@@ -5,6 +5,7 @@ menuconfig FB_OMAP2
         tristate "OMAP2+ frame buffer support"
         depends on FB
         depends on DRM_OMAP = n
+       depends on GPIOLIB
 
         select FB_OMAP2_DSS
        select OMAP2_VRFB if ARCH_OMAP2 || ARCH_OMAP3
index bef4315300905a691c32373feb29e70ab1ff421e..87497a00241fdb0cb69882a94ca94d8df1bed91a 100644 (file)
@@ -387,8 +387,7 @@ static void dsicm_get_resolution(struct omap_dss_device *dssdev,
 static ssize_t dsicm_num_errors_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
+       struct panel_drv_data *ddata = dev_get_drvdata(dev);
        struct omap_dss_device *in = ddata->in;
        u8 errors = 0;
        int r;
@@ -419,8 +418,7 @@ static ssize_t dsicm_num_errors_show(struct device *dev,
 static ssize_t dsicm_hw_revision_show(struct device *dev,
                struct device_attribute *attr, char *buf)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
+       struct panel_drv_data *ddata = dev_get_drvdata(dev);
        struct omap_dss_device *in = ddata->in;
        u8 id1, id2, id3;
        int r;
@@ -451,8 +449,7 @@ static ssize_t dsicm_store_ulps(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t count)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
+       struct panel_drv_data *ddata = dev_get_drvdata(dev);
        struct omap_dss_device *in = ddata->in;
        unsigned long t;
        int r;
@@ -486,8 +483,7 @@ static ssize_t dsicm_show_ulps(struct device *dev,
                struct device_attribute *attr,
                char *buf)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
+       struct panel_drv_data *ddata = dev_get_drvdata(dev);
        unsigned t;
 
        mutex_lock(&ddata->lock);
@@ -501,8 +497,7 @@ static ssize_t dsicm_store_ulps_timeout(struct device *dev,
                struct device_attribute *attr,
                const char *buf, size_t count)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
+       struct panel_drv_data *ddata = dev_get_drvdata(dev);
        struct omap_dss_device *in = ddata->in;
        unsigned long t;
        int r;
@@ -533,8 +528,7 @@ static ssize_t dsicm_show_ulps_timeout(struct device *dev,
                struct device_attribute *attr,
                char *buf)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct panel_drv_data *ddata = platform_get_drvdata(pdev);
+       struct panel_drv_data *ddata = dev_get_drvdata(dev);
        unsigned t;
 
        mutex_lock(&ddata->lock);
index 69f86d2cc274db90070abccbe248b3924adab7fd..d21c641e1f3c8008e41a752ad66eb131a6c02822 100644 (file)
@@ -42,8 +42,8 @@ int dss_init_overlay_managers(void)
 
        num_managers = dss_feat_get_num_mgrs();
 
-       managers = kzalloc(sizeof(struct omap_overlay_manager) * num_managers,
-                       GFP_KERNEL);
+       managers = kcalloc(num_managers, sizeof(struct omap_overlay_manager),
+                          GFP_KERNEL);
 
        BUG_ON(managers == NULL);
 
index d6c5d75d2ef8262d6b13f8286ad912dd33dfce4e..be17a4785a5eab20f22197d15ff7d8fd2fd18b29 100644 (file)
@@ -59,8 +59,8 @@ void dss_init_overlays(struct platform_device *pdev)
 
        num_overlays = dss_feat_get_num_ovls();
 
-       overlays = kzalloc(sizeof(struct omap_overlay) * num_overlays,
-                       GFP_KERNEL);
+       overlays = kcalloc(num_overlays, sizeof(struct omap_overlay),
+                          GFP_KERNEL);
 
        BUG_ON(overlays == NULL);
 
index f346b02eee1d84c2d8da77b15e3d64c72aa4fa17..f355ecfac3b1877e607237c22f79d3a60b335ddf 100644 (file)
@@ -359,8 +359,8 @@ static int __init vrfb_probe(struct platform_device *pdev)
 
        num_ctxs = pdev->num_resources - 1;
 
-       ctxs = devm_kzalloc(&pdev->dev,
-                       sizeof(struct vrfb_ctx) * num_ctxs,
+       ctxs = devm_kcalloc(&pdev->dev,
+                       num_ctxs, sizeof(struct vrfb_ctx),
                        GFP_KERNEL);
 
        if (!ctxs)
index a582d3ae7ac1d6812bd6c736160c94ecf4c7d5e4..8a53d1de611d5cdd99f58ddbef03ca8ba73dcc09 100644 (file)
@@ -682,7 +682,7 @@ static ssize_t pvr2fb_write(struct fb_info *info, const char *buf,
 
        nr_pages = (count + PAGE_SIZE - 1) >> PAGE_SHIFT;
 
-       pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL);
+       pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL);
        if (!pages)
                return -ENOMEM;
 
index c3d49e13643cd21504d7ffa62f1231d6a9a8ef38..76722a59f55e34c83ec948d77c2c0df5c936fa16 100644 (file)
@@ -2115,12 +2115,10 @@ static int of_get_pxafb_display(struct device *dev, struct device_node *disp,
        if (ret)
                s = "color-tft";
 
-       for (i = 0; lcd_types[i]; i++)
-               if (!strcmp(s, lcd_types[i]))
-                       break;
-       if (!i || !lcd_types[i]) {
+       i = match_string(lcd_types, -1, s);
+       if (i < 0) {
                dev_err(dev, "lcd-type %s is unknown\n", s);
-               return -EINVAL;
+               return i;
        }
        info->lcd_conn |= LCD_CONN_TYPE(i);
        info->lcd_conn |= LCD_CONN_WIDTH(bus_width);
index ff8282374f37b098f2bf1e1d211eae4bae201b16..cc242ba057d3ea0dcf613ea17246c3a2a683c127 100644 (file)
@@ -1615,7 +1615,7 @@ static int rivafb_cursor(struct fb_info *info, struct fb_cursor *cursor)
                u8 *msk = (u8 *) cursor->mask;
                u8 *src;
                
-               src = kmalloc(s_pitch * cursor->image.height, GFP_ATOMIC);
+               src = kmalloc_array(s_pitch, cursor->image.height, GFP_ATOMIC);
 
                if (src) {
                        switch (cursor->rop) {
index c20468362f11ce58a535ca9648b9397f6b6d6eef..c09d7426cd92505f9418d17ba852ea0aaef2fa0a 100644 (file)
@@ -1892,11 +1892,11 @@ static int savage_init_hw(struct savagefb_par *par)
        vga_out8(0x3d4, 0x66, par);
        cr66 = vga_in8(0x3d5, par);
        vga_out8(0x3d5, cr66 | 0x02, par);
-       mdelay(10);
+       usleep_range(10000, 11000);
 
        vga_out8(0x3d4, 0x66, par);
        vga_out8(0x3d5, cr66 & ~0x02, par);     /* clear reset flag */
-       mdelay(10);
+       usleep_range(10000, 11000);
 
 
        /*
@@ -1906,11 +1906,11 @@ static int savage_init_hw(struct savagefb_par *par)
        vga_out8(0x3d4, 0x3f, par);
        cr3f = vga_in8(0x3d5, par);
        vga_out8(0x3d5, cr3f | 0x08, par);
-       mdelay(10);
+       usleep_range(10000, 11000);
 
        vga_out8(0x3d4, 0x3f, par);
        vga_out8(0x3d5, cr3f & ~0x08, par);     /* clear reset flags */
-       mdelay(10);
+       usleep_range(10000, 11000);
 
        /* Savage ramdac speeds */
        par->numClocks = 4;
index c3a46506e47e2997122e54c36510f8aca8c2f066..dc46be38c9706f4b0ef8e562475de1dd08a02ef2 100644 (file)
@@ -29,7 +29,6 @@
 #include <linux/vmalloc.h>
 
 #include <video/sh_mobile_lcdc.h>
-#include <video/sh_mobile_meram.h>
 
 #include "sh_mobile_lcdcfb.h"
 
@@ -217,7 +216,6 @@ struct sh_mobile_lcdc_priv {
        struct notifier_block notifier;
        int started;
        int forced_fourcc; /* 2 channel LCDC must share fourcc setting */
-       struct sh_mobile_meram_info *meram_dev;
 };
 
 /* -----------------------------------------------------------------------------
@@ -346,16 +344,12 @@ static void sh_mobile_lcdc_clk_on(struct sh_mobile_lcdc_priv *priv)
                if (priv->dot_clk)
                        clk_prepare_enable(priv->dot_clk);
                pm_runtime_get_sync(priv->dev);
-               if (priv->meram_dev && priv->meram_dev->pdev)
-                       pm_runtime_get_sync(&priv->meram_dev->pdev->dev);
        }
 }
 
 static void sh_mobile_lcdc_clk_off(struct sh_mobile_lcdc_priv *priv)
 {
        if (atomic_sub_return(1, &priv->hw_usecnt) == -1) {
-               if (priv->meram_dev && priv->meram_dev->pdev)
-                       pm_runtime_put_sync(&priv->meram_dev->pdev->dev);
                pm_runtime_put(priv->dev);
                if (priv->dot_clk)
                        clk_disable_unprepare(priv->dot_clk);
@@ -1073,7 +1067,6 @@ static void __sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 
 static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 {
-       struct sh_mobile_meram_info *mdev = priv->meram_dev;
        struct sh_mobile_lcdc_chan *ch;
        unsigned long tmp;
        int ret;
@@ -1106,9 +1099,6 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
 
        /* Compute frame buffer base address and pitch for each channel. */
        for (k = 0; k < ARRAY_SIZE(priv->ch); k++) {
-               int pixelformat;
-               void *cache;
-
                ch = &priv->ch[k];
                if (!ch->enabled)
                        continue;
@@ -1117,45 +1107,6 @@ static int sh_mobile_lcdc_start(struct sh_mobile_lcdc_priv *priv)
                ch->base_addr_c = ch->dma_handle
                                + ch->xres_virtual * ch->yres_virtual;
                ch->line_size = ch->pitch;
-
-               /* Enable MERAM if possible. */
-               if (mdev == NULL || ch->cfg->meram_cfg == NULL)
-                       continue;
-
-               /* Free the allocated MERAM cache. */
-               if (ch->cache) {
-                       sh_mobile_meram_cache_free(mdev, ch->cache);
-                       ch->cache = NULL;
-               }
-
-               switch (ch->format->fourcc) {
-               case V4L2_PIX_FMT_NV12:
-               case V4L2_PIX_FMT_NV21:
-               case V4L2_PIX_FMT_NV16:
-               case V4L2_PIX_FMT_NV61:
-                       pixelformat = SH_MOBILE_MERAM_PF_NV;
-                       break;
-               case V4L2_PIX_FMT_NV24:
-               case V4L2_PIX_FMT_NV42:
-                       pixelformat = SH_MOBILE_MERAM_PF_NV24;
-                       break;
-               case V4L2_PIX_FMT_RGB565:
-               case V4L2_PIX_FMT_BGR24:
-               case V4L2_PIX_FMT_BGR32:
-               default:
-                       pixelformat = SH_MOBILE_MERAM_PF_RGB;
-                       break;
-               }
-
-               cache = sh_mobile_meram_cache_alloc(mdev, ch->cfg->meram_cfg,
-                                       ch->pitch, ch->yres, pixelformat,
-                                       &ch->line_size);
-               if (!IS_ERR(cache)) {
-                       sh_mobile_meram_cache_update(mdev, cache,
-                                       ch->base_addr_y, ch->base_addr_c,
-                                       &ch->base_addr_y, &ch->base_addr_c);
-                       ch->cache = cache;
-               }
        }
 
        for (k = 0; k < ARRAY_SIZE(priv->overlays); ++k) {
@@ -1223,13 +1174,6 @@ static void sh_mobile_lcdc_stop(struct sh_mobile_lcdc_priv *priv)
                }
 
                sh_mobile_lcdc_display_off(ch);
-
-               /* Free the MERAM cache. */
-               if (ch->cache) {
-                       sh_mobile_meram_cache_free(priv->meram_dev, ch->cache);
-                       ch->cache = NULL;
-               }
-
        }
 
        /* stop the lcdc */
@@ -1851,11 +1795,6 @@ static int sh_mobile_lcdc_pan(struct fb_var_screeninfo *var,
        base_addr_c = ch->dma_handle + ch->xres_virtual * ch->yres_virtual
                    + c_offset;
 
-       if (ch->cache)
-               sh_mobile_meram_cache_update(priv->meram_dev, ch->cache,
-                                            base_addr_y, base_addr_c,
-                                            &base_addr_y, &base_addr_c);
-
        ch->base_addr_y = base_addr_y;
        ch->base_addr_c = base_addr_c;
        ch->pan_y_offset = y_offset;
@@ -2149,10 +2088,8 @@ sh_mobile_lcdc_channel_fb_register(struct sh_mobile_lcdc_chan *ch)
        if (info->fbdefio) {
                ch->sglist = vmalloc(sizeof(struct scatterlist) *
                                     ch->fb_size >> PAGE_SHIFT);
-               if (!ch->sglist) {
-                       dev_err(ch->lcdc->dev, "cannot allocate sglist\n");
+               if (!ch->sglist)
                        return -ENOMEM;
-               }
        }
 
        info->bl_dev = ch->bl;
@@ -2354,8 +2291,7 @@ static int sh_mobile_lcdc_resume(struct device *dev)
 
 static int sh_mobile_lcdc_runtime_suspend(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct sh_mobile_lcdc_priv *priv = platform_get_drvdata(pdev);
+       struct sh_mobile_lcdc_priv *priv = dev_get_drvdata(dev);
 
        /* turn off LCDC hardware */
        lcdc_write(priv, _LDCNT1R, 0);
@@ -2365,8 +2301,7 @@ static int sh_mobile_lcdc_runtime_suspend(struct device *dev)
 
 static int sh_mobile_lcdc_runtime_resume(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct sh_mobile_lcdc_priv *priv = platform_get_drvdata(pdev);
+       struct sh_mobile_lcdc_priv *priv = dev_get_drvdata(dev);
 
        __sh_mobile_lcdc_start(priv);
 
@@ -2718,13 +2653,11 @@ static int sh_mobile_lcdc_probe(struct platform_device *pdev)
        }
 
        priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-       if (!priv) {
-               dev_err(&pdev->dev, "cannot allocate device data\n");
+       if (!priv)
                return -ENOMEM;
-       }
 
        priv->dev = &pdev->dev;
-       priv->meram_dev = pdata->meram_dev;
+
        for (i = 0; i < ARRAY_SIZE(priv->ch); i++)
                mutex_init(&priv->ch[i].open_lock);
        platform_set_drvdata(pdev, priv);
index cc52c74721fe98570e03d9195aa407265c13e12d..b8e47a8bd8abb57418f5a9bbad7eecadce8d074a 100644 (file)
@@ -61,7 +61,6 @@ struct sh_mobile_lcdc_chan {
        unsigned long *reg_offs;
        unsigned long ldmt1r_value;
        unsigned long enabled; /* ME and SE in LDCNT2R */
-       void *cache;
 
        struct mutex open_lock;         /* protects the use counter */
        int use_count;
diff --git a/drivers/video/fbdev/sh_mobile_meram.c b/drivers/video/fbdev/sh_mobile_meram.c
deleted file mode 100644 (file)
index baadfb2..0000000
+++ /dev/null
@@ -1,758 +0,0 @@
-/*
- * SuperH Mobile MERAM Driver for SuperH Mobile LCDC Driver
- *
- * Copyright (c) 2011  Damian Hobson-Garcia <dhobsong@igel.co.jp>
- *                      Takanari Hayama <taki@igel.co.jp>
- *
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- */
-
-#include <linux/device.h>
-#include <linux/err.h>
-#include <linux/export.h>
-#include <linux/genalloc.h>
-#include <linux/io.h>
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/platform_device.h>
-#include <linux/pm_runtime.h>
-#include <linux/slab.h>
-
-#include <video/sh_mobile_meram.h>
-
-/* -----------------------------------------------------------------------------
- * MERAM registers
- */
-
-#define MEVCR1                 0x4
-#define MEVCR1_RST             (1 << 31)
-#define MEVCR1_WD              (1 << 30)
-#define MEVCR1_AMD1            (1 << 29)
-#define MEVCR1_AMD0            (1 << 28)
-#define MEQSEL1                        0x40
-#define MEQSEL2                        0x44
-
-#define MExxCTL                        0x400
-#define MExxCTL_BV             (1 << 31)
-#define MExxCTL_BSZ_SHIFT      28
-#define MExxCTL_MSAR_MASK      (0x7ff << MExxCTL_MSAR_SHIFT)
-#define MExxCTL_MSAR_SHIFT     16
-#define MExxCTL_NXT_MASK       (0x1f << MExxCTL_NXT_SHIFT)
-#define MExxCTL_NXT_SHIFT      11
-#define MExxCTL_WD1            (1 << 10)
-#define MExxCTL_WD0            (1 << 9)
-#define MExxCTL_WS             (1 << 8)
-#define MExxCTL_CB             (1 << 7)
-#define MExxCTL_WBF            (1 << 6)
-#define MExxCTL_WF             (1 << 5)
-#define MExxCTL_RF             (1 << 4)
-#define MExxCTL_CM             (1 << 3)
-#define MExxCTL_MD_READ                (1 << 0)
-#define MExxCTL_MD_WRITE       (2 << 0)
-#define MExxCTL_MD_ICB_WB      (3 << 0)
-#define MExxCTL_MD_ICB         (4 << 0)
-#define MExxCTL_MD_FB          (7 << 0)
-#define MExxCTL_MD_MASK                (7 << 0)
-#define MExxBSIZE              0x404
-#define MExxBSIZE_RCNT_SHIFT   28
-#define MExxBSIZE_YSZM1_SHIFT  16
-#define MExxBSIZE_XSZM1_SHIFT  0
-#define MExxMNCF               0x408
-#define MExxMNCF_KWBNM_SHIFT   28
-#define MExxMNCF_KRBNM_SHIFT   24
-#define MExxMNCF_BNM_SHIFT     16
-#define MExxMNCF_XBV           (1 << 15)
-#define MExxMNCF_CPL_YCBCR444  (1 << 12)
-#define MExxMNCF_CPL_YCBCR420  (2 << 12)
-#define MExxMNCF_CPL_YCBCR422  (3 << 12)
-#define MExxMNCF_CPL_MSK       (3 << 12)
-#define MExxMNCF_BL            (1 << 2)
-#define MExxMNCF_LNM_SHIFT     0
-#define MExxSARA               0x410
-#define MExxSARB               0x414
-#define MExxSBSIZE             0x418
-#define MExxSBSIZE_HDV         (1 << 31)
-#define MExxSBSIZE_HSZ16       (0 << 28)
-#define MExxSBSIZE_HSZ32       (1 << 28)
-#define MExxSBSIZE_HSZ64       (2 << 28)
-#define MExxSBSIZE_HSZ128      (3 << 28)
-#define MExxSBSIZE_SBSIZZ_SHIFT        0
-
-#define MERAM_MExxCTL_VAL(next, addr)  \
-       ((((next) << MExxCTL_NXT_SHIFT) & MExxCTL_NXT_MASK) | \
-        (((addr) << MExxCTL_MSAR_SHIFT) & MExxCTL_MSAR_MASK))
-#define        MERAM_MExxBSIZE_VAL(rcnt, yszm1, xszm1) \
-       (((rcnt) << MExxBSIZE_RCNT_SHIFT) | \
-        ((yszm1) << MExxBSIZE_YSZM1_SHIFT) | \
-        ((xszm1) << MExxBSIZE_XSZM1_SHIFT))
-
-static const unsigned long common_regs[] = {
-       MEVCR1,
-       MEQSEL1,
-       MEQSEL2,
-};
-#define MERAM_REGS_SIZE ARRAY_SIZE(common_regs)
-
-static const unsigned long icb_regs[] = {
-       MExxCTL,
-       MExxBSIZE,
-       MExxMNCF,
-       MExxSARA,
-       MExxSARB,
-       MExxSBSIZE,
-};
-#define ICB_REGS_SIZE ARRAY_SIZE(icb_regs)
-
-/*
- * sh_mobile_meram_icb - MERAM ICB information
- * @regs: Registers cache
- * @index: ICB index
- * @offset: MERAM block offset
- * @size: MERAM block size in KiB
- * @cache_unit: Bytes to cache per ICB
- * @pixelformat: Video pixel format of the data stored in the ICB
- * @current_reg: Which of Start Address Register A (0) or B (1) is in use
- */
-struct sh_mobile_meram_icb {
-       unsigned long regs[ICB_REGS_SIZE];
-       unsigned int index;
-       unsigned long offset;
-       unsigned int size;
-
-       unsigned int cache_unit;
-       unsigned int pixelformat;
-       unsigned int current_reg;
-};
-
-#define MERAM_ICB_NUM                  32
-
-struct sh_mobile_meram_fb_plane {
-       struct sh_mobile_meram_icb *marker;
-       struct sh_mobile_meram_icb *cache;
-};
-
-struct sh_mobile_meram_fb_cache {
-       unsigned int nplanes;
-       struct sh_mobile_meram_fb_plane planes[2];
-};
-
-/*
- * sh_mobile_meram_priv - MERAM device
- * @base: Registers base address
- * @meram: MERAM physical address
- * @regs: Registers cache
- * @lock: Protects used_icb and icbs
- * @used_icb: Bitmask of used ICBs
- * @icbs: ICBs
- * @pool: Allocation pool to manage the MERAM
- */
-struct sh_mobile_meram_priv {
-       void __iomem *base;
-       unsigned long meram;
-       unsigned long regs[MERAM_REGS_SIZE];
-
-       struct mutex lock;
-       unsigned long used_icb;
-       struct sh_mobile_meram_icb icbs[MERAM_ICB_NUM];
-
-       struct gen_pool *pool;
-};
-
-/* settings */
-#define MERAM_GRANULARITY              1024
-#define MERAM_SEC_LINE                 15
-#define MERAM_LINE_WIDTH               2048
-
-/* -----------------------------------------------------------------------------
- * Registers access
- */
-
-#define MERAM_ICB_OFFSET(base, idx, off)       ((base) + (off) + (idx) * 0x20)
-
-static inline void meram_write_icb(void __iomem *base, unsigned int idx,
-                                  unsigned int off, unsigned long val)
-{
-       iowrite32(val, MERAM_ICB_OFFSET(base, idx, off));
-}
-
-static inline unsigned long meram_read_icb(void __iomem *base, unsigned int idx,
-                                          unsigned int off)
-{
-       return ioread32(MERAM_ICB_OFFSET(base, idx, off));
-}
-
-static inline void meram_write_reg(void __iomem *base, unsigned int off,
-                                  unsigned long val)
-{
-       iowrite32(val, base + off);
-}
-
-static inline unsigned long meram_read_reg(void __iomem *base, unsigned int off)
-{
-       return ioread32(base + off);
-}
-
-/* -----------------------------------------------------------------------------
- * MERAM allocation and free
- */
-
-static unsigned long meram_alloc(struct sh_mobile_meram_priv *priv, size_t size)
-{
-       return gen_pool_alloc(priv->pool, size);
-}
-
-static void meram_free(struct sh_mobile_meram_priv *priv, unsigned long mem,
-                      size_t size)
-{
-       gen_pool_free(priv->pool, mem, size);
-}
-
-/* -----------------------------------------------------------------------------
- * LCDC cache planes allocation, init, cleanup and free
- */
-
-/* Allocate ICBs and MERAM for a plane. */
-static int meram_plane_alloc(struct sh_mobile_meram_priv *priv,
-                            struct sh_mobile_meram_fb_plane *plane,
-                            size_t size)
-{
-       unsigned long mem;
-       unsigned long idx;
-
-       idx = find_first_zero_bit(&priv->used_icb, 28);
-       if (idx == 28)
-               return -ENOMEM;
-       plane->cache = &priv->icbs[idx];
-
-       idx = find_next_zero_bit(&priv->used_icb, 32, 28);
-       if (idx == 32)
-               return -ENOMEM;
-       plane->marker = &priv->icbs[idx];
-
-       mem = meram_alloc(priv, size * 1024);
-       if (mem == 0)
-               return -ENOMEM;
-
-       __set_bit(plane->marker->index, &priv->used_icb);
-       __set_bit(plane->cache->index, &priv->used_icb);
-
-       plane->marker->offset = mem - priv->meram;
-       plane->marker->size = size;
-
-       return 0;
-}
-
-/* Free ICBs and MERAM for a plane. */
-static void meram_plane_free(struct sh_mobile_meram_priv *priv,
-                            struct sh_mobile_meram_fb_plane *plane)
-{
-       meram_free(priv, priv->meram + plane->marker->offset,
-                  plane->marker->size * 1024);
-
-       __clear_bit(plane->marker->index, &priv->used_icb);
-       __clear_bit(plane->cache->index, &priv->used_icb);
-}
-
-/* Is this a YCbCr(NV12, NV16 or NV24) colorspace? */
-static int is_nvcolor(int cspace)
-{
-       if (cspace == SH_MOBILE_MERAM_PF_NV ||
-           cspace == SH_MOBILE_MERAM_PF_NV24)
-               return 1;
-       return 0;
-}
-
-/* Set the next address to fetch. */
-static void meram_set_next_addr(struct sh_mobile_meram_priv *priv,
-                               struct sh_mobile_meram_fb_cache *cache,
-                               unsigned long base_addr_y,
-                               unsigned long base_addr_c)
-{
-       struct sh_mobile_meram_icb *icb = cache->planes[0].marker;
-       unsigned long target;
-
-       icb->current_reg ^= 1;
-       target = icb->current_reg ? MExxSARB : MExxSARA;
-
-       /* set the next address to fetch */
-       meram_write_icb(priv->base, cache->planes[0].cache->index, target,
-                       base_addr_y);
-       meram_write_icb(priv->base, cache->planes[0].marker->index, target,
-                       base_addr_y + cache->planes[0].marker->cache_unit);
-
-       if (cache->nplanes == 2) {
-               meram_write_icb(priv->base, cache->planes[1].cache->index,
-                               target, base_addr_c);
-               meram_write_icb(priv->base, cache->planes[1].marker->index,
-                               target, base_addr_c +
-                               cache->planes[1].marker->cache_unit);
-       }
-}
-
-/* Get the next ICB address. */
-static void
-meram_get_next_icb_addr(struct sh_mobile_meram_info *pdata,
-                       struct sh_mobile_meram_fb_cache *cache,
-                       unsigned long *icb_addr_y, unsigned long *icb_addr_c)
-{
-       struct sh_mobile_meram_icb *icb = cache->planes[0].marker;
-       unsigned long icb_offset;
-
-       if (pdata->addr_mode == SH_MOBILE_MERAM_MODE0)
-               icb_offset = 0x80000000 | (icb->current_reg << 29);
-       else
-               icb_offset = 0xc0000000 | (icb->current_reg << 23);
-
-       *icb_addr_y = icb_offset | (cache->planes[0].marker->index << 24);
-       if (cache->nplanes == 2)
-               *icb_addr_c = icb_offset
-                           | (cache->planes[1].marker->index << 24);
-}
-
-#define MERAM_CALC_BYTECOUNT(x, y) \
-       (((x) * (y) + (MERAM_LINE_WIDTH - 1)) & ~(MERAM_LINE_WIDTH - 1))
-
-/* Initialize MERAM. */
-static int meram_plane_init(struct sh_mobile_meram_priv *priv,
-                           struct sh_mobile_meram_fb_plane *plane,
-                           unsigned int xres, unsigned int yres,
-                           unsigned int *out_pitch)
-{
-       struct sh_mobile_meram_icb *marker = plane->marker;
-       unsigned long total_byte_count = MERAM_CALC_BYTECOUNT(xres, yres);
-       unsigned long bnm;
-       unsigned int lcdc_pitch;
-       unsigned int xpitch;
-       unsigned int line_cnt;
-       unsigned int save_lines;
-
-       /* adjust pitch to 1024, 2048, 4096 or 8192 */
-       lcdc_pitch = (xres - 1) | 1023;
-       lcdc_pitch = lcdc_pitch | (lcdc_pitch >> 1);
-       lcdc_pitch = lcdc_pitch | (lcdc_pitch >> 2);
-       lcdc_pitch += 1;
-
-       /* derive settings */
-       if (lcdc_pitch == 8192 && yres >= 1024) {
-               lcdc_pitch = xpitch = MERAM_LINE_WIDTH;
-               line_cnt = total_byte_count >> 11;
-               *out_pitch = xres;
-               save_lines = plane->marker->size / 16 / MERAM_SEC_LINE;
-               save_lines *= MERAM_SEC_LINE;
-       } else {
-               xpitch = xres;
-               line_cnt = yres;
-               *out_pitch = lcdc_pitch;
-               save_lines = plane->marker->size / (lcdc_pitch >> 10) / 2;
-               save_lines &= 0xff;
-       }
-       bnm = (save_lines - 1) << 16;
-
-       /* TODO: we better to check if we have enough MERAM buffer size */
-
-       /* set up ICB */
-       meram_write_icb(priv->base, plane->cache->index,  MExxBSIZE,
-                       MERAM_MExxBSIZE_VAL(0x0, line_cnt - 1, xpitch - 1));
-       meram_write_icb(priv->base, plane->marker->index, MExxBSIZE,
-                       MERAM_MExxBSIZE_VAL(0xf, line_cnt - 1, xpitch - 1));
-
-       meram_write_icb(priv->base, plane->cache->index,  MExxMNCF, bnm);
-       meram_write_icb(priv->base, plane->marker->index, MExxMNCF, bnm);
-
-       meram_write_icb(priv->base, plane->cache->index,  MExxSBSIZE, xpitch);
-       meram_write_icb(priv->base, plane->marker->index, MExxSBSIZE, xpitch);
-
-       /* save a cache unit size */
-       plane->cache->cache_unit = xres * save_lines;
-       plane->marker->cache_unit = xres * save_lines;
-
-       /*
-        * Set MERAM for framebuffer
-        *
-        * we also chain the cache_icb and the marker_icb.
-        * we also split the allocated MERAM buffer between two ICBs.
-        */
-       meram_write_icb(priv->base, plane->cache->index, MExxCTL,
-                       MERAM_MExxCTL_VAL(plane->marker->index, marker->offset)
-                       | MExxCTL_WD1 | MExxCTL_WD0 | MExxCTL_WS | MExxCTL_CM |
-                       MExxCTL_MD_FB);
-       meram_write_icb(priv->base, plane->marker->index, MExxCTL,
-                       MERAM_MExxCTL_VAL(plane->cache->index, marker->offset +
-                                         plane->marker->size / 2) |
-                       MExxCTL_WD1 | MExxCTL_WD0 | MExxCTL_WS | MExxCTL_CM |
-                       MExxCTL_MD_FB);
-
-       return 0;
-}
-
-static void meram_plane_cleanup(struct sh_mobile_meram_priv *priv,
-                               struct sh_mobile_meram_fb_plane *plane)
-{
-       /* disable ICB */
-       meram_write_icb(priv->base, plane->cache->index,  MExxCTL,
-                       MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF);
-       meram_write_icb(priv->base, plane->marker->index, MExxCTL,
-                       MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF);
-
-       plane->cache->cache_unit = 0;
-       plane->marker->cache_unit = 0;
-}
-
-/* -----------------------------------------------------------------------------
- * MERAM operations
- */
-
-unsigned long sh_mobile_meram_alloc(struct sh_mobile_meram_info *pdata,
-                                   size_t size)
-{
-       struct sh_mobile_meram_priv *priv = pdata->priv;
-
-       return meram_alloc(priv, size);
-}
-EXPORT_SYMBOL_GPL(sh_mobile_meram_alloc);
-
-void sh_mobile_meram_free(struct sh_mobile_meram_info *pdata, unsigned long mem,
-                         size_t size)
-{
-       struct sh_mobile_meram_priv *priv = pdata->priv;
-
-       meram_free(priv, mem, size);
-}
-EXPORT_SYMBOL_GPL(sh_mobile_meram_free);
-
-/* Allocate memory for the ICBs and mark them as used. */
-static struct sh_mobile_meram_fb_cache *
-meram_cache_alloc(struct sh_mobile_meram_priv *priv,
-                 const struct sh_mobile_meram_cfg *cfg,
-                 int pixelformat)
-{
-       unsigned int nplanes = is_nvcolor(pixelformat) ? 2 : 1;
-       struct sh_mobile_meram_fb_cache *cache;
-       int ret;
-
-       cache = kzalloc(sizeof(*cache), GFP_KERNEL);
-       if (cache == NULL)
-               return ERR_PTR(-ENOMEM);
-
-       cache->nplanes = nplanes;
-
-       ret = meram_plane_alloc(priv, &cache->planes[0],
-                               cfg->icb[0].meram_size);
-       if (ret < 0)
-               goto error;
-
-       cache->planes[0].marker->current_reg = 1;
-       cache->planes[0].marker->pixelformat = pixelformat;
-
-       if (cache->nplanes == 1)
-               return cache;
-
-       ret = meram_plane_alloc(priv, &cache->planes[1],
-                               cfg->icb[1].meram_size);
-       if (ret < 0) {
-               meram_plane_free(priv, &cache->planes[0]);
-               goto error;
-       }
-
-       return cache;
-
-error:
-       kfree(cache);
-       return ERR_PTR(-ENOMEM);
-}
-
-void *sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *pdata,
-                                 const struct sh_mobile_meram_cfg *cfg,
-                                 unsigned int xres, unsigned int yres,
-                                 unsigned int pixelformat, unsigned int *pitch)
-{
-       struct sh_mobile_meram_fb_cache *cache;
-       struct sh_mobile_meram_priv *priv = pdata->priv;
-       struct platform_device *pdev = pdata->pdev;
-       unsigned int nplanes = is_nvcolor(pixelformat) ? 2 : 1;
-       unsigned int out_pitch;
-
-       if (priv == NULL)
-               return ERR_PTR(-ENODEV);
-
-       if (pixelformat != SH_MOBILE_MERAM_PF_NV &&
-           pixelformat != SH_MOBILE_MERAM_PF_NV24 &&
-           pixelformat != SH_MOBILE_MERAM_PF_RGB)
-               return ERR_PTR(-EINVAL);
-
-       dev_dbg(&pdev->dev, "registering %dx%d (%s)", xres, yres,
-               !pixelformat ? "yuv" : "rgb");
-
-       /* we can't handle wider than 8192px */
-       if (xres > 8192) {
-               dev_err(&pdev->dev, "width exceeding the limit (> 8192).");
-               return ERR_PTR(-EINVAL);
-       }
-
-       if (cfg->icb[0].meram_size == 0)
-               return ERR_PTR(-EINVAL);
-
-       if (nplanes == 2 && cfg->icb[1].meram_size == 0)
-               return ERR_PTR(-EINVAL);
-
-       mutex_lock(&priv->lock);
-
-       /* We now register the ICBs and allocate the MERAM regions. */
-       cache = meram_cache_alloc(priv, cfg, pixelformat);
-       if (IS_ERR(cache)) {
-               dev_err(&pdev->dev, "MERAM allocation failed (%ld).",
-                       PTR_ERR(cache));
-               goto err;
-       }
-
-       /* initialize MERAM */
-       meram_plane_init(priv, &cache->planes[0], xres, yres, &out_pitch);
-       *pitch = out_pitch;
-       if (pixelformat == SH_MOBILE_MERAM_PF_NV)
-               meram_plane_init(priv, &cache->planes[1],
-                                xres, (yres + 1) / 2, &out_pitch);
-       else if (pixelformat == SH_MOBILE_MERAM_PF_NV24)
-               meram_plane_init(priv, &cache->planes[1],
-                                2 * xres, (yres + 1) / 2, &out_pitch);
-
-err:
-       mutex_unlock(&priv->lock);
-       return cache;
-}
-EXPORT_SYMBOL_GPL(sh_mobile_meram_cache_alloc);
-
-void
-sh_mobile_meram_cache_free(struct sh_mobile_meram_info *pdata, void *data)
-{
-       struct sh_mobile_meram_fb_cache *cache = data;
-       struct sh_mobile_meram_priv *priv = pdata->priv;
-
-       mutex_lock(&priv->lock);
-
-       /* Cleanup and free. */
-       meram_plane_cleanup(priv, &cache->planes[0]);
-       meram_plane_free(priv, &cache->planes[0]);
-
-       if (cache->nplanes == 2) {
-               meram_plane_cleanup(priv, &cache->planes[1]);
-               meram_plane_free(priv, &cache->planes[1]);
-       }
-
-       kfree(cache);
-
-       mutex_unlock(&priv->lock);
-}
-EXPORT_SYMBOL_GPL(sh_mobile_meram_cache_free);
-
-void
-sh_mobile_meram_cache_update(struct sh_mobile_meram_info *pdata, void *data,
-                            unsigned long base_addr_y,
-                            unsigned long base_addr_c,
-                            unsigned long *icb_addr_y,
-                            unsigned long *icb_addr_c)
-{
-       struct sh_mobile_meram_fb_cache *cache = data;
-       struct sh_mobile_meram_priv *priv = pdata->priv;
-
-       mutex_lock(&priv->lock);
-
-       meram_set_next_addr(priv, cache, base_addr_y, base_addr_c);
-       meram_get_next_icb_addr(pdata, cache, icb_addr_y, icb_addr_c);
-
-       mutex_unlock(&priv->lock);
-}
-EXPORT_SYMBOL_GPL(sh_mobile_meram_cache_update);
-
-/* -----------------------------------------------------------------------------
- * Power management
- */
-
-#ifdef CONFIG_PM
-static int sh_mobile_meram_suspend(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev);
-       unsigned int i, j;
-
-       for (i = 0; i < MERAM_REGS_SIZE; i++)
-               priv->regs[i] = meram_read_reg(priv->base, common_regs[i]);
-
-       for (i = 0; i < 32; i++) {
-               if (!test_bit(i, &priv->used_icb))
-                       continue;
-               for (j = 0; j < ICB_REGS_SIZE; j++) {
-                       priv->icbs[i].regs[j] =
-                               meram_read_icb(priv->base, i, icb_regs[j]);
-                       /* Reset ICB on resume */
-                       if (icb_regs[j] == MExxCTL)
-                               priv->icbs[i].regs[j] |=
-                                       MExxCTL_WBF | MExxCTL_WF | MExxCTL_RF;
-               }
-       }
-       return 0;
-}
-
-static int sh_mobile_meram_resume(struct device *dev)
-{
-       struct platform_device *pdev = to_platform_device(dev);
-       struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev);
-       unsigned int i, j;
-
-       for (i = 0; i < 32; i++) {
-               if (!test_bit(i, &priv->used_icb))
-                       continue;
-               for (j = 0; j < ICB_REGS_SIZE; j++)
-                       meram_write_icb(priv->base, i, icb_regs[j],
-                                       priv->icbs[i].regs[j]);
-       }
-
-       for (i = 0; i < MERAM_REGS_SIZE; i++)
-               meram_write_reg(priv->base, common_regs[i], priv->regs[i]);
-       return 0;
-}
-#endif /* CONFIG_PM */
-
-static UNIVERSAL_DEV_PM_OPS(sh_mobile_meram_dev_pm_ops,
-                           sh_mobile_meram_suspend,
-                           sh_mobile_meram_resume, NULL);
-
-/* -----------------------------------------------------------------------------
- * Probe/remove and driver init/exit
- */
-
-static int sh_mobile_meram_probe(struct platform_device *pdev)
-{
-       struct sh_mobile_meram_priv *priv;
-       struct sh_mobile_meram_info *pdata = pdev->dev.platform_data;
-       struct resource *regs;
-       struct resource *meram;
-       unsigned int i;
-       int error;
-
-       if (!pdata) {
-               dev_err(&pdev->dev, "no platform data defined\n");
-               return -EINVAL;
-       }
-
-       regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       meram = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-       if (regs == NULL || meram == NULL) {
-               dev_err(&pdev->dev, "cannot get platform resources\n");
-               return -ENOENT;
-       }
-
-       priv = kzalloc(sizeof(*priv), GFP_KERNEL);
-       if (!priv) {
-               dev_err(&pdev->dev, "cannot allocate device data\n");
-               return -ENOMEM;
-       }
-
-       /* Initialize private data. */
-       mutex_init(&priv->lock);
-       priv->used_icb = pdata->reserved_icbs;
-
-       for (i = 0; i < MERAM_ICB_NUM; ++i)
-               priv->icbs[i].index = i;
-
-       pdata->priv = priv;
-       pdata->pdev = pdev;
-
-       /* Request memory regions and remap the registers. */
-       if (!request_mem_region(regs->start, resource_size(regs), pdev->name)) {
-               dev_err(&pdev->dev, "MERAM registers region already claimed\n");
-               error = -EBUSY;
-               goto err_req_regs;
-       }
-
-       if (!request_mem_region(meram->start, resource_size(meram),
-                               pdev->name)) {
-               dev_err(&pdev->dev, "MERAM memory region already claimed\n");
-               error = -EBUSY;
-               goto err_req_meram;
-       }
-
-       priv->base = ioremap_nocache(regs->start, resource_size(regs));
-       if (!priv->base) {
-               dev_err(&pdev->dev, "ioremap failed\n");
-               error = -EFAULT;
-               goto err_ioremap;
-       }
-
-       priv->meram = meram->start;
-
-       /* Create and initialize the MERAM memory pool. */
-       priv->pool = gen_pool_create(ilog2(MERAM_GRANULARITY), -1);
-       if (priv->pool == NULL) {
-               error = -ENOMEM;
-               goto err_genpool;
-       }
-
-       error = gen_pool_add(priv->pool, meram->start, resource_size(meram),
-                            -1);
-       if (error < 0)
-               goto err_genpool;
-
-       /* initialize ICB addressing mode */
-       if (pdata->addr_mode == SH_MOBILE_MERAM_MODE1)
-               meram_write_reg(priv->base, MEVCR1, MEVCR1_AMD1);
-
-       platform_set_drvdata(pdev, priv);
-       pm_runtime_enable(&pdev->dev);
-
-       dev_info(&pdev->dev, "sh_mobile_meram initialized.");
-
-       return 0;
-
-err_genpool:
-       if (priv->pool)
-               gen_pool_destroy(priv->pool);
-       iounmap(priv->base);
-err_ioremap:
-       release_mem_region(meram->start, resource_size(meram));
-err_req_meram:
-       release_mem_region(regs->start, resource_size(regs));
-err_req_regs:
-       mutex_destroy(&priv->lock);
-       kfree(priv);
-
-       return error;
-}
-
-
-static int sh_mobile_meram_remove(struct platform_device *pdev)
-{
-       struct sh_mobile_meram_priv *priv = platform_get_drvdata(pdev);
-       struct resource *regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-       struct resource *meram = platform_get_resource(pdev, IORESOURCE_MEM, 1);
-
-       pm_runtime_disable(&pdev->dev);
-
-       gen_pool_destroy(priv->pool);
-
-       iounmap(priv->base);
-       release_mem_region(meram->start, resource_size(meram));
-       release_mem_region(regs->start, resource_size(regs));
-
-       mutex_destroy(&priv->lock);
-
-       kfree(priv);
-
-       return 0;
-}
-
-static struct platform_driver sh_mobile_meram_driver = {
-       .driver = {
-               .name           = "sh_mobile_meram",
-               .pm             = &sh_mobile_meram_dev_pm_ops,
-       },
-       .probe          = sh_mobile_meram_probe,
-       .remove         = sh_mobile_meram_remove,
-};
-
-module_platform_driver(sh_mobile_meram_driver);
-
-MODULE_DESCRIPTION("SuperH Mobile MERAM driver");
-MODULE_AUTHOR("Damian Hobson-Garcia / Takanari Hayama");
-MODULE_LICENSE("GPL v2");
index 7f4e908330bf0509014612a1fa2a3bf4be1e2e7c..812a36cb60c3efa932a7d305a7d111a5cd49ed3a 100644 (file)
@@ -836,7 +836,7 @@ static void xxxfb_remove(struct pci_dev *dev)
  *     @dev: PCI device
  *     @msg: the suspend event code.
  *
- *      See Documentation/power/admin-guide/devices.rst for more information
+ *      See Documentation/driver-api/pm/devices.rst for more information
  */
 static int xxxfb_suspend(struct pci_dev *dev, pm_message_t msg)
 {
@@ -851,7 +851,7 @@ static int xxxfb_suspend(struct pci_dev *dev, pm_message_t msg)
  *     xxxfb_resume - Optional but recommended function. Resume the device.
  *     @dev: PCI device
  *
- *      See Documentation/power/admin-guide/devices.rst for more information
+ *      See Documentation/driver-api/pm/devices.rst for more information
  */
 static int xxxfb_resume(struct pci_dev *dev)
 {
@@ -915,7 +915,7 @@ static void __exit xxxfb_exit(void)
  *     @dev: platform device
  *     @msg: the suspend event code.
  *
- *      See Documentation/power/admin-guide/devices.rst for more information
+ *      See Documentation/driver-api/pm/devices.rst for more information
  */
 static int xxxfb_suspend(struct platform_device *dev, pm_message_t msg)
 {
@@ -930,7 +930,7 @@ static int xxxfb_suspend(struct platform_device *dev, pm_message_t msg)
  *     xxxfb_resume - Optional but recommended function. Resume the device.
  *     @dev: platform device
  *
- *      See Documentation/power/admin-guide/devices.rst for more information
+ *      See Documentation/driver-api/pm/devices.rst for more information
  */
 static int xxxfb_resume(struct platform_dev *dev)
 {
index 6f0a19501c6a8d959e1f4a994e705934808d4c77..dde52d0274168dde174a3cafb16cb9ba532ecb97 100644 (file)
@@ -1932,8 +1932,7 @@ static int sm501fb_probe(struct platform_device *pdev)
        int ret;
 
        /* allocate our framebuffers */
-
-       info = kzalloc(sizeof(struct sm501fb_info), GFP_KERNEL);
+       info = kzalloc(sizeof(*info), GFP_KERNEL);
        if (!info) {
                dev_err(dev, "failed to allocate state\n");
                return -ENOMEM;
index 73676eb0244a7bd63d294619563d723992a93183..440a6636d8f0a894648efcfbd15f38ea8f80ddea 100644 (file)
@@ -486,8 +486,9 @@ static int uvesafb_vbe_getmodes(struct uvesafb_ktask *task,
                mode++;
        }
 
-       par->vbe_modes = kzalloc(sizeof(struct vbe_mode_ib) *
-                               par->vbe_modes_cnt, GFP_KERNEL);
+       par->vbe_modes = kcalloc(par->vbe_modes_cnt,
+                                sizeof(struct vbe_mode_ib),
+                                GFP_KERNEL);
        if (!par->vbe_modes)
                return -ENOMEM;
 
@@ -858,7 +859,7 @@ static int uvesafb_vbe_init_mode(struct fb_info *info)
         * Convert the modelist into a modedb so that we can use it with
         * fb_find_mode().
         */
-       mode = kzalloc(i * sizeof(*mode), GFP_KERNEL);
+       mode = kcalloc(i, sizeof(*mode), GFP_KERNEL);
        if (mode) {
                i = 0;
                list_for_each(pos, &info->modelist) {
@@ -1044,7 +1045,8 @@ static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info)
                    info->cmap.len || cmap->start < info->cmap.start)
                        return -EINVAL;
 
-               entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL);
+               entries = kmalloc_array(cmap->len, sizeof(*entries),
+                                       GFP_KERNEL);
                if (!entries)
                        return -ENOMEM;
 
index 275dbbbd6b81227ac690028588ac24c7691ffe8a..649d2ca5516ead7cfa521401fec9ac661849b1f7 100644 (file)
 #include <linux/console.h>
 #include <linux/timer.h>
 
+#ifdef CONFIG_X86
+#include <asm/olpc.h>
+#else
+#define machine_is_olpc(x) 0
+#endif
+
 #include "debug.h"
 
 #include "viafbdev.h"
index 22450908306c3f77b454a6396d82c6363f60943d..48969c6445998a43fbfdd2654e539bf5c4a3a63c 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #include <linux/via-core.h>
-#include <asm/olpc.h>
 #include "global.h"
 #include "via_clock.h"
 
index 77774d8abf94dff3bb24d94552630a9ecb63c754..b041eb27a9bff7aac488968306c83102b6c4edfd 100644 (file)
@@ -17,7 +17,6 @@
 #include <linux/platform_device.h>
 #include <linux/list.h>
 #include <linux/pm.h>
-#include <asm/olpc.h>
 
 /*
  * The default port config.
index bf269fa43977e6d7a83dda2269b2d191a08221ef..3d0efdbaea58086c476a2914ade60bdcc7e7f723 100644 (file)
@@ -25,7 +25,7 @@
 
 #include <linux/kernel.h>
 #include <linux/via-core.h>
-#include <asm/olpc.h>
+
 #include "via_clock.h"
 #include "global.h"
 #include "debug.h"
index 9b45125988fbcab1af7a77a7bcddb74e1b6fd725..d2f785068ef4bb97fbc7228a684eae00d0688280 100644 (file)
@@ -25,7 +25,6 @@
 #include <linux/stat.h>
 #include <linux/via-core.h>
 #include <linux/via_i2c.h>
-#include <asm/olpc.h>
 
 #define _MASTER_FILE
 #include "global.h"
@@ -596,7 +595,8 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg)
                break;
 
        case VIAFB_GET_GAMMA_LUT:
-               viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
+               viafb_gamma_table = kmalloc_array(256, sizeof(u32),
+                                                 GFP_KERNEL);
                if (!viafb_gamma_table)
                        return -ENOMEM;
                viafb_get_gamma_table(viafb_gamma_table);
index 035ff6e0289496df8f00712785237be418fa4ecd..696106ecdff07c93268c7c3f8092b54317b95b00 100644 (file)
@@ -693,7 +693,8 @@ int w100fb_probe(struct platform_device *pdev)
                goto out;
        }
 
-       info->pseudo_palette = kmalloc(sizeof (u32) * MAX_PALETTES, GFP_KERNEL);
+       info->pseudo_palette = kmalloc_array(MAX_PALETTES, sizeof(u32),
+                                            GFP_KERNEL);
        if (!info->pseudo_palette) {
                err = -ENOMEM;
                goto out;
index 46f63960fa9e6aa2913be8b804c1de24ce1245be..6a4bbc9e1fb095e3444085cddcaf67340809454a 100644 (file)
@@ -412,7 +412,7 @@ static int xenfb_probe(struct xenbus_device *dev,
 
        info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
 
-       info->gfns = vmalloc(sizeof(unsigned long) * info->nr_pages);
+       info->gfns = vmalloc(array_size(sizeof(unsigned long), info->nr_pages));
        if (!info->gfns)
                goto error_nomem;
 
index 83b8963c9657c6a2ff83bb24bbc6f56e1bf6baad..5244e93ceafc5c0b520ad0f849dadf1d70e09dbb 100644 (file)
@@ -181,8 +181,9 @@ struct display_timings *of_get_display_timings(const struct device_node *np)
                goto entryfail;
        }
 
-       disp->timings = kzalloc(sizeof(struct display_timing *) *
-                               disp->num_timings, GFP_KERNEL);
+       disp->timings = kcalloc(disp->num_timings,
+                               sizeof(struct display_timing *),
+                               GFP_KERNEL);
        if (!disp->timings) {
                pr_err("%pOF: could not allocate timings array\n", np);
                goto entryfail;
index 4e05d7f711fefede62fe047ffcfda573dc8f67c7..8ba726e600e9a9c1a17278783f8b95ed0699ff9b 100644 (file)
@@ -223,7 +223,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p)
         * 'pages' is an array of struct page pointers that's initialized by
         * get_user_pages().
         */
-       pages = kzalloc(num_pages * sizeof(struct page *), GFP_KERNEL);
+       pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
        if (!pages) {
                pr_debug("fsl-hv: could not allocate page list\n");
                return -ENOMEM;
index 2f3856a95856be43bcbfc6a4c3865f7099045368..3093655c7b92718b9c384f2f9791c221eaf258ab 100644 (file)
@@ -69,7 +69,7 @@ static void vbg_guest_mappings_init(struct vbg_dev *gdev)
        /* Add 4M so that we can align the vmap to 4MiB as the host requires. */
        size = PAGE_ALIGN(req->hypervisor_size) + SZ_4M;
 
-       pages = kmalloc(sizeof(*pages) * (size >> PAGE_SHIFT), GFP_KERNEL);
+       pages = kmalloc_array(size >> PAGE_SHIFT, sizeof(*pages), GFP_KERNEL);
        if (!pages)
                goto out;
 
@@ -262,8 +262,9 @@ static int vbg_balloon_inflate(struct vbg_dev *gdev, u32 chunk_idx)
        struct page **pages;
        int i, rc, ret;
 
-       pages = kmalloc(sizeof(*pages) * VMMDEV_MEMORY_BALLOON_CHUNK_PAGES,
-                       GFP_KERNEL | __GFP_NOWARN);
+       pages = kmalloc_array(VMMDEV_MEMORY_BALLOON_CHUNK_PAGES,
+                             sizeof(*pages),
+                             GFP_KERNEL | __GFP_NOWARN);
        if (!pages)
                return -ENOMEM;
 
index 48d4d1cf1cb63f7b67f58f17e3d7874d14a00b09..705aebd74e560cd8d125cee28537e9734dabe518 100644 (file)
@@ -113,12 +113,13 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors,
 
        vp_dev->msix_vectors = nvectors;
 
-       vp_dev->msix_names = kmalloc(nvectors * sizeof *vp_dev->msix_names,
-                                    GFP_KERNEL);
+       vp_dev->msix_names = kmalloc_array(nvectors,
+                                          sizeof(*vp_dev->msix_names),
+                                          GFP_KERNEL);
        if (!vp_dev->msix_names)
                goto error;
        vp_dev->msix_affinity_masks
-               = kzalloc(nvectors * sizeof *vp_dev->msix_affinity_masks,
+               = kcalloc(nvectors, sizeof(*vp_dev->msix_affinity_masks),
                          GFP_KERNEL);
        if (!vp_dev->msix_affinity_masks)
                goto error;
@@ -577,6 +578,8 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
        struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
        struct device *dev = get_device(&vp_dev->vdev.dev);
 
+       pci_disable_sriov(pci_dev);
+
        unregister_virtio_device(&vp_dev->vdev);
 
        if (vp_dev->ioaddr)
@@ -588,6 +591,33 @@ static void virtio_pci_remove(struct pci_dev *pci_dev)
        put_device(dev);
 }
 
+static int virtio_pci_sriov_configure(struct pci_dev *pci_dev, int num_vfs)
+{
+       struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
+       struct virtio_device *vdev = &vp_dev->vdev;
+       int ret;
+
+       if (!(vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_DRIVER_OK))
+               return -EBUSY;
+
+       if (!__virtio_test_bit(vdev, VIRTIO_F_SR_IOV))
+               return -EINVAL;
+
+       if (pci_vfs_assigned(pci_dev))
+               return -EPERM;
+
+       if (num_vfs == 0) {
+               pci_disable_sriov(pci_dev);
+               return 0;
+       }
+
+       ret = pci_enable_sriov(pci_dev, num_vfs);
+       if (ret < 0)
+               return ret;
+
+       return num_vfs;
+}
+
 static struct pci_driver virtio_pci_driver = {
        .name           = "virtio-pci",
        .id_table       = virtio_pci_id_table,
@@ -596,6 +626,7 @@ static struct pci_driver virtio_pci_driver = {
 #ifdef CONFIG_PM_SLEEP
        .driver.pm      = &virtio_pci_pm_ops,
 #endif
+       .sriov_configure = virtio_pci_sriov_configure,
 };
 
 module_pci_driver(virtio_pci_driver);
index 2555d80f6eec4b4a78860b46f453092051b50a24..07571daccfec13581a7e5ce59c242de4e2ef1bb6 100644 (file)
@@ -153,14 +153,28 @@ static u64 vp_get_features(struct virtio_device *vdev)
        return features;
 }
 
+static void vp_transport_features(struct virtio_device *vdev, u64 features)
+{
+       struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+       struct pci_dev *pci_dev = vp_dev->pci_dev;
+
+       if ((features & BIT_ULL(VIRTIO_F_SR_IOV)) &&
+                       pci_find_ext_capability(pci_dev, PCI_EXT_CAP_ID_SRIOV))
+               __virtio_set_bit(vdev, VIRTIO_F_SR_IOV);
+}
+
 /* virtio config->finalize_features() implementation */
 static int vp_finalize_features(struct virtio_device *vdev)
 {
        struct virtio_pci_device *vp_dev = to_vp_device(vdev);
+       u64 features = vdev->features;
 
        /* Give virtio_ring a chance to accept features. */
        vring_transport_features(vdev);
 
+       /* Give virtio_pci a chance to accept features. */
+       vp_transport_features(vdev, features);
+
        if (!__virtio_test_bit(vdev, VIRTIO_F_VERSION_1)) {
                dev_err(&vdev->dev, "virtio: device uses modern interface "
                        "but does not have VIRTIO_F_VERSION_1\n");
index 21d464a29cf8d637db6ccff38e2c146b4296c4d4..814b395007b2c35e694519c173d47143f12e277b 100644 (file)
@@ -247,7 +247,7 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq,
         */
        gfp &= ~__GFP_HIGHMEM;
 
-       desc = kmalloc(total_sg * sizeof(struct vring_desc), gfp);
+       desc = kmalloc_array(total_sg, sizeof(struct vring_desc), gfp);
        if (!desc)
                return NULL;
 
index 3ec1f418837d1af8f3e0eb325e7198ce7ae39939..c3924356d1731153847b82147b58f70f76a5a382 100644 (file)
@@ -418,8 +418,7 @@ static void cdns_wdt_shutdown(struct platform_device *pdev)
  */
 static int __maybe_unused cdns_wdt_suspend(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct cdns_wdt *wdt = platform_get_drvdata(pdev);
+       struct cdns_wdt *wdt = dev_get_drvdata(dev);
 
        if (watchdog_active(&wdt->cdns_wdt_device)) {
                cdns_wdt_stop(&wdt->cdns_wdt_device);
@@ -438,8 +437,7 @@ static int __maybe_unused cdns_wdt_suspend(struct device *dev)
 static int __maybe_unused cdns_wdt_resume(struct device *dev)
 {
        int ret;
-       struct platform_device *pdev = to_platform_device(dev);
-       struct cdns_wdt *wdt = platform_get_drvdata(pdev);
+       struct cdns_wdt *wdt = dev_get_drvdata(dev);
 
        if (watchdog_active(&wdt->cdns_wdt_device)) {
                ret = clk_prepare_enable(wdt->clk);
index a001782bbfdb1a066a5528a36d529f85ec051562..fe169d8e1fb2f2c75b4dca8d8af6e83dd462123b 100644 (file)
@@ -30,14 +30,8 @@ static const unsigned int wdt_timeout[] = { 0, 2, 4, 8, 16, 32, 65, 131 };
 struct da9062_watchdog {
        struct da9062 *hw;
        struct watchdog_device wdtdev;
-       unsigned long j_time_stamp;
 };
 
-static void da9062_set_window_start(struct da9062_watchdog *wdt)
-{
-       wdt->j_time_stamp = jiffies;
-}
-
 static unsigned int da9062_wdt_timeout_to_sel(unsigned int secs)
 {
        unsigned int i;
@@ -59,8 +53,6 @@ static int da9062_reset_watchdog_timer(struct da9062_watchdog *wdt)
                           DA9062AA_WATCHDOG_MASK,
                           DA9062AA_WATCHDOG_MASK);
 
-       da9062_set_window_start(wdt);
-
        return ret;
 }
 
@@ -232,8 +224,6 @@ static int da9062_wdt_probe(struct platform_device *pdev)
                return ret;
        }
 
-       da9062_set_window_start(wdt);
-
        return da9062_wdt_ping(&wdt->wdtdev);
 }
 
index b17ac1bb1f28eda4525093664a846bc2317c4ca5..384dca16af8b36bf2e51f8ed6bfeb5ca82e30e06 100644 (file)
@@ -45,8 +45,46 @@ static unsigned int da9063_wdt_timeout_to_sel(unsigned int secs)
        return DA9063_TWDSCALE_MAX;
 }
 
-static int _da9063_wdt_set_timeout(struct da9063 *da9063, unsigned int regval)
+/*
+ * Return 0 if watchdog is disabled, else non zero.
+ */
+static unsigned int da9063_wdt_is_running(struct da9063 *da9063)
+{
+       unsigned int val;
+
+       regmap_read(da9063->regmap, DA9063_REG_CONTROL_D, &val);
+
+       return val & DA9063_TWDSCALE_MASK;
+}
+
+static int da9063_wdt_disable_timer(struct da9063 *da9063)
 {
+       return regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
+                                 DA9063_TWDSCALE_MASK,
+                                 DA9063_TWDSCALE_DISABLE);
+}
+
+static int
+da9063_wdt_update_timeout(struct da9063 *da9063, unsigned int timeout)
+{
+       unsigned int regval;
+       int ret;
+
+       /*
+        * The watchdog triggers a reboot if a timeout value is already
+        * programmed because the timeout value combines two functions
+        * in one: indicating the counter limit and starting the watchdog.
+        * The watchdog must be disabled to be able to change the timeout
+        * value if the watchdog is already running. Then we can set the
+        * new timeout value which enables the watchdog again.
+        */
+       ret = da9063_wdt_disable_timer(da9063);
+       if (ret)
+               return ret;
+
+       usleep_range(150, 300);
+       regval = da9063_wdt_timeout_to_sel(timeout);
+
        return regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
                                  DA9063_TWDSCALE_MASK, regval);
 }
@@ -54,11 +92,9 @@ static int _da9063_wdt_set_timeout(struct da9063 *da9063, unsigned int regval)
 static int da9063_wdt_start(struct watchdog_device *wdd)
 {
        struct da9063 *da9063 = watchdog_get_drvdata(wdd);
-       unsigned int selector;
        int ret;
 
-       selector = da9063_wdt_timeout_to_sel(wdd->timeout);
-       ret = _da9063_wdt_set_timeout(da9063, selector);
+       ret = da9063_wdt_update_timeout(da9063, wdd->timeout);
        if (ret)
                dev_err(da9063->dev, "Watchdog failed to start (err = %d)\n",
                        ret);
@@ -71,8 +107,7 @@ static int da9063_wdt_stop(struct watchdog_device *wdd)
        struct da9063 *da9063 = watchdog_get_drvdata(wdd);
        int ret;
 
-       ret = regmap_update_bits(da9063->regmap, DA9063_REG_CONTROL_D,
-                                DA9063_TWDSCALE_MASK, DA9063_TWDSCALE_DISABLE);
+       ret = da9063_wdt_disable_timer(da9063);
        if (ret)
                dev_alert(da9063->dev, "Watchdog failed to stop (err = %d)\n",
                          ret);
@@ -98,16 +133,26 @@ static int da9063_wdt_set_timeout(struct watchdog_device *wdd,
                                  unsigned int timeout)
 {
        struct da9063 *da9063 = watchdog_get_drvdata(wdd);
-       unsigned int selector;
-       int ret;
+       int ret = 0;
+
+       /*
+        * There are two cases when a set_timeout() will be called:
+        * 1. The watchdog is off and someone wants to set the timeout for the
+        *    further use.
+        * 2. The watchdog is already running and a new timeout value should be
+        *    set.
+        *
+        * The watchdog can't store a timeout value not equal zero without
+        * enabling the watchdog, so the timeout must be buffered by the driver.
+        */
+       if (watchdog_active(wdd))
+               ret = da9063_wdt_update_timeout(da9063, timeout);
 
-       selector = da9063_wdt_timeout_to_sel(timeout);
-       ret = _da9063_wdt_set_timeout(da9063, selector);
        if (ret)
                dev_err(da9063->dev, "Failed to set watchdog timeout (err = %d)\n",
                        ret);
        else
-               wdd->timeout = wdt_timeout[selector];
+               wdd->timeout = wdt_timeout[da9063_wdt_timeout_to_sel(timeout)];
 
        return ret;
 }
@@ -171,6 +216,12 @@ static int da9063_wdt_probe(struct platform_device *pdev)
 
        watchdog_set_drvdata(wdd, da9063);
 
+       /* Change the timeout to the default value if the watchdog is running */
+       if (da9063_wdt_is_running(da9063)) {
+               da9063_wdt_update_timeout(da9063, DA9063_WDG_TIMEOUT);
+               set_bit(WDOG_HW_RUNNING, &wdd->status);
+       }
+
        return devm_watchdog_register_device(&pdev->dev, wdd);
 }
 
index a43ab2cecca2748d23e3d064ca55390ddffe386f..9dc62a4614512fb8faeb2e937bc085d2bec16f3c 100644 (file)
@@ -159,7 +159,7 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs)
                "3. OA Forward Progress Log\n"
                "4. iLO Event Log";
 
-       if (ilo5 && ulReason == NMI_UNKNOWN && mynmi)
+       if (ilo5 && ulReason == NMI_UNKNOWN && !mynmi)
                return NMI_DONE;
 
        if (ilo5 && !pretimeout)
index aafbeb96561b506c1053162eb76f119e110cedbc..ec4d99a830ba61b53c3963afba9fddf749de70af 100644 (file)
@@ -124,12 +124,20 @@ static int jz4740_wdt_stop(struct watchdog_device *wdt_dev)
 {
        struct jz4740_wdt_drvdata *drvdata = watchdog_get_drvdata(wdt_dev);
 
-       jz4740_timer_disable_watchdog();
        writeb(0x0, drvdata->base + JZ_REG_WDT_COUNTER_ENABLE);
+       jz4740_timer_disable_watchdog();
 
        return 0;
 }
 
+static int jz4740_wdt_restart(struct watchdog_device *wdt_dev,
+                             unsigned long action, void *data)
+{
+       wdt_dev->timeout = 0;
+       jz4740_wdt_start(wdt_dev);
+       return 0;
+}
+
 static const struct watchdog_info jz4740_wdt_info = {
        .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE,
        .identity = "jz4740 Watchdog",
@@ -141,6 +149,7 @@ static const struct watchdog_ops jz4740_wdt_ops = {
        .stop = jz4740_wdt_stop,
        .ping = jz4740_wdt_ping,
        .set_timeout = jz4740_wdt_set_timeout,
+       .restart = jz4740_wdt_restart,
 };
 
 #ifdef CONFIG_OF
@@ -179,45 +188,26 @@ static int jz4740_wdt_probe(struct platform_device *pdev)
 
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        drvdata->base = devm_ioremap_resource(&pdev->dev, res);
-       if (IS_ERR(drvdata->base)) {
-               ret = PTR_ERR(drvdata->base);
-               goto err_out;
-       }
+       if (IS_ERR(drvdata->base))
+               return PTR_ERR(drvdata->base);
 
-       drvdata->rtc_clk = clk_get(&pdev->dev, "rtc");
+       drvdata->rtc_clk = devm_clk_get(&pdev->dev, "rtc");
        if (IS_ERR(drvdata->rtc_clk)) {
                dev_err(&pdev->dev, "cannot find RTC clock\n");
-               ret = PTR_ERR(drvdata->rtc_clk);
-               goto err_out;
+               return PTR_ERR(drvdata->rtc_clk);
        }
 
-       ret = watchdog_register_device(&drvdata->wdt);
+       ret = devm_watchdog_register_device(&pdev->dev, &drvdata->wdt);
        if (ret < 0)
-               goto err_disable_clk;
+               return ret;
 
        platform_set_drvdata(pdev, drvdata);
-       return 0;
-
-err_disable_clk:
-       clk_put(drvdata->rtc_clk);
-err_out:
-       return ret;
-}
-
-static int jz4740_wdt_remove(struct platform_device *pdev)
-{
-       struct jz4740_wdt_drvdata *drvdata = platform_get_drvdata(pdev);
-
-       jz4740_wdt_stop(&drvdata->wdt);
-       watchdog_unregister_device(&drvdata->wdt);
-       clk_put(drvdata->rtc_clk);
 
        return 0;
 }
 
 static struct platform_driver jz4740_wdt_driver = {
        .probe = jz4740_wdt_probe,
-       .remove = jz4740_wdt_remove,
        .driver = {
                .name = "jz4740-wdt",
                .of_match_table = of_match_ptr(jz4740_wdt_of_matches),
index 25d5d2b8cfbe98b9b1654eaacae855fdc79efa35..0be7f50e8ff940d441feac339f8f106d805c91a3 100644 (file)
@@ -31,7 +31,6 @@ enum a21_wdt_gpios {
 
 struct a21_wdt_drv {
        struct watchdog_device wdt;
-       struct mutex lock;
        unsigned gpios[NUM_GPIOS];
 };
 
@@ -55,12 +54,8 @@ static int a21_wdt_start(struct watchdog_device *wdt)
 {
        struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
 
-       mutex_lock(&drv->lock);
-
        gpio_set_value(drv->gpios[GPIO_WD_ENAB], 1);
 
-       mutex_unlock(&drv->lock);
-
        return 0;
 }
 
@@ -68,12 +63,8 @@ static int a21_wdt_stop(struct watchdog_device *wdt)
 {
        struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
 
-       mutex_lock(&drv->lock);
-
        gpio_set_value(drv->gpios[GPIO_WD_ENAB], 0);
 
-       mutex_unlock(&drv->lock);
-
        return 0;
 }
 
@@ -81,14 +72,10 @@ static int a21_wdt_ping(struct watchdog_device *wdt)
 {
        struct a21_wdt_drv *drv = watchdog_get_drvdata(wdt);
 
-       mutex_lock(&drv->lock);
-
        gpio_set_value(drv->gpios[GPIO_WD_TRIG], 0);
        ndelay(10);
        gpio_set_value(drv->gpios[GPIO_WD_TRIG], 1);
 
-       mutex_unlock(&drv->lock);
-
        return 0;
 }
 
@@ -108,8 +95,6 @@ static int a21_wdt_set_timeout(struct watchdog_device *wdt,
                return -EINVAL;
        }
 
-       mutex_lock(&drv->lock);
-
        if (timeout == 1)
                gpio_set_value(drv->gpios[GPIO_WD_FAST], 1);
        else
@@ -117,8 +102,6 @@ static int a21_wdt_set_timeout(struct watchdog_device *wdt,
 
        wdt->timeout = timeout;
 
-       mutex_unlock(&drv->lock);
-
        return 0;
 }
 
@@ -191,7 +174,6 @@ static int a21_wdt_probe(struct platform_device *pdev)
                        return ret;
        }
 
-       mutex_init(&drv->lock);
        watchdog_init_timeout(&a21_wdt, 30, &pdev->dev);
        watchdog_set_nowayout(&a21_wdt, nowayout);
        watchdog_set_drvdata(&a21_wdt, drv);
index 4acbe05e27bb809923dcab3512753624ad6c6c6c..d3f7eb0466782f4b386895cf509c54213a31819d 100644 (file)
@@ -268,8 +268,7 @@ static int xwdt_remove(struct platform_device *pdev)
  */
 static int __maybe_unused xwdt_suspend(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct xwdt_device *xdev = platform_get_drvdata(pdev);
+       struct xwdt_device *xdev = dev_get_drvdata(dev);
 
        if (watchdog_active(&xdev->xilinx_wdt_wdd))
                xilinx_wdt_stop(&xdev->xilinx_wdt_wdd);
@@ -285,8 +284,7 @@ static int __maybe_unused xwdt_suspend(struct device *dev)
  */
 static int __maybe_unused xwdt_resume(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct xwdt_device *xdev = platform_get_drvdata(pdev);
+       struct xwdt_device *xdev = dev_get_drvdata(dev);
        int ret = 0;
 
        if (watchdog_active(&xdev->xilinx_wdt_wdd))
index 514db5cc159511254f62c2eb86714a2ecddb978f..88d81feba4e60087fe52b85b7438b83f0dbc07a8 100644 (file)
@@ -146,7 +146,7 @@ static const struct soc_device_attribute rwdt_quirks_match[] = {
                .data = (void *)1,      /* needs single CPU */
        }, {
                .soc_id = "r8a7791",
-               .revision = "ES[12].*",
+               .revision = "ES1.*",
                .data = (void *)1,      /* needs single CPU */
        }, {
                .soc_id = "r8a7792",
index 03805bc5d67ad515769b29be60bb722355fa0da9..9849db0743a75cd5739294eb71fa2af1aedb467c 100644 (file)
@@ -121,6 +121,18 @@ static unsigned int wdt_timeleft(struct watchdog_device *wdd)
        return div_u64(load, rate);
 }
 
+static int
+wdt_restart(struct watchdog_device *wdd, unsigned long mode, void *cmd)
+{
+       struct sp805_wdt *wdt = watchdog_get_drvdata(wdd);
+
+       writel_relaxed(0, wdt->base + WDTCONTROL);
+       writel_relaxed(0, wdt->base + WDTLOAD);
+       writel_relaxed(INT_ENABLE | RESET_ENABLE, wdt->base + WDTCONTROL);
+
+       return 0;
+}
+
 static int wdt_config(struct watchdog_device *wdd, bool ping)
 {
        struct sp805_wdt *wdt = watchdog_get_drvdata(wdd);
@@ -197,6 +209,7 @@ static const struct watchdog_ops wdt_ops = {
        .ping           = wdt_ping,
        .set_timeout    = wdt_setload,
        .get_timeleft   = wdt_timeleft,
+       .restart        = wdt_restart,
 };
 
 static int
@@ -230,6 +243,7 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id)
        spin_lock_init(&wdt->lock);
        watchdog_set_nowayout(&wdt->wdd, nowayout);
        watchdog_set_drvdata(&wdt->wdd, wdt);
+       watchdog_set_restart_priority(&wdt->wdd, 128);
        wdt_setload(&wdt->wdd, DEFAULT_TIMEOUT);
 
        ret = watchdog_register_device(&wdt->wdd);
index 0da9943d405f8ff89efc87a0cf6df5ff43df9d6f..56ad19608a9bed0ae43ffaa87e59c71ee85d104e 100644 (file)
@@ -447,8 +447,7 @@ static int wdat_wdt_probe(struct platform_device *pdev)
 #ifdef CONFIG_PM_SLEEP
 static int wdat_wdt_suspend_noirq(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct wdat_wdt *wdat = platform_get_drvdata(pdev);
+       struct wdat_wdt *wdat = dev_get_drvdata(dev);
        int ret;
 
        if (!watchdog_active(&wdat->wdd))
@@ -475,8 +474,7 @@ static int wdat_wdt_suspend_noirq(struct device *dev)
 
 static int wdat_wdt_resume_noirq(struct device *dev)
 {
-       struct platform_device *pdev = to_platform_device(dev);
-       struct wdat_wdt *wdat = platform_get_drvdata(pdev);
+       struct wdat_wdt *wdat = dev_get_drvdata(dev);
        int ret;
 
        if (!watchdog_active(&wdat->wdd))
index 85dd20e0572678581ffa03a8ff6b734773230d1e..3e789c77f568dadb3f88070f3a016d726d37eeec 100644 (file)
@@ -70,9 +70,9 @@ static int xen_map_device_mmio(const struct resource *resources,
                if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
                        continue;
 
-               gpfns = kzalloc(sizeof(xen_pfn_t) * nr, GFP_KERNEL);
-               idxs = kzalloc(sizeof(xen_ulong_t) * nr, GFP_KERNEL);
-               errs = kzalloc(sizeof(int) * nr, GFP_KERNEL);
+               gpfns = kcalloc(nr, sizeof(xen_pfn_t), GFP_KERNEL);
+               idxs = kcalloc(nr, sizeof(xen_ulong_t), GFP_KERNEL);
+               errs = kcalloc(nr, sizeof(int), GFP_KERNEL);
                if (!gpfns || !idxs || !errs) {
                        kfree(gpfns);
                        kfree(idxs);
index 8cac07ab60abd4bc2c200be8bfd63fc5aa70b477..6d1a5e58968ffdfb42a71e5f984a52475ea0ca9c 100644 (file)
@@ -322,7 +322,7 @@ static int evtchn_resize_ring(struct per_user_data *u)
        else
                new_size = 2 * u->ring_size;
 
-       new_ring = kvmalloc(new_size * sizeof(*new_ring), GFP_KERNEL);
+       new_ring = kvmalloc_array(new_size, sizeof(*new_ring), GFP_KERNEL);
        if (!new_ring)
                return -ENOMEM;
 
index 27be107d648020a1faf69f2feb3ee118f884411f..2473b0a9e6e41d5d51b47e318d7e3b26d81ec5f6 100644 (file)
@@ -1137,7 +1137,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
        /* No need for kzalloc as it is initialized in following hypercall
         * GNTTABOP_setup_table.
         */
-       frames = kmalloc(nr_gframes * sizeof(unsigned long), GFP_ATOMIC);
+       frames = kmalloc_array(nr_gframes, sizeof(unsigned long), GFP_ATOMIC);
        if (!frames)
                return -ENOMEM;
 
@@ -1300,8 +1300,9 @@ int gnttab_init(void)
        max_nr_glist_frames = (max_nr_grant_frames *
                               gnttab_interface->grefs_per_grant_frame / RPP);
 
-       gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *),
-                             GFP_KERNEL);
+       gnttab_list = kmalloc_array(max_nr_glist_frames,
+                                   sizeof(grant_ref_t *),
+                                   GFP_KERNEL);
        if (gnttab_list == NULL)
                return -ENOMEM;
 
index ee2c891b55c6bf46e97e6e529f65e478a12e7c3e..ea4a08b83fa099ae04ed8486a6cff98a602f1e57 100644 (file)
@@ -234,7 +234,7 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev,
        if (dev->msi_enabled || !(cmd & PCI_COMMAND_MEMORY))
                return -ENXIO;
 
-       entries = kmalloc(op->value * sizeof(*entries), GFP_KERNEL);
+       entries = kmalloc_array(op->value, sizeof(*entries), GFP_KERNEL);
        if (entries == NULL)
                return -ENOMEM;
 
index ed4f8519b6270656b1e1c899cdf31dd4d451ded8..a9ef46f02354f465ca013ff048b4591b928bade6 100644 (file)
@@ -100,7 +100,7 @@ static int build_path_from_dentry(struct v9fs_session_info *v9ses,
        for (ds = dentry; !IS_ROOT(ds); ds = ds->d_parent)
                n++;
 
-       wnames = kmalloc(sizeof(char *) * n, GFP_KERNEL);
+       wnames = kmalloc_array(n, sizeof(char *), GFP_KERNEL);
        if (!wnames)
                goto err_out;
 
index ab2d96d1abee3b44c73b1cf4b280a05778fc5d8c..ac474a61be37951a4484522eaa2ae0377d8d02b2 100644 (file)
@@ -110,7 +110,6 @@ source "fs/notify/Kconfig"
 source "fs/quota/Kconfig"
 
 source "fs/autofs/Kconfig"
-source "fs/autofs4/Kconfig"
 source "fs/fuse/Kconfig"
 source "fs/overlayfs/Kconfig"
 
index 57a27c42b5aca07bf40d649025047fa758b3df5c..56df483de619cc44ca8c25c2b7daf6f3783de937 100644 (file)
@@ -168,7 +168,7 @@ config BINFMT_MISC
          will automatically feed it to the correct interpreter.
 
          You can do other nice things, too. Read the file
-         <file:Documentation/binfmt_misc.txt> to learn how to use this
+         <file:Documentation/admin-guide/binfmt-misc.rst> to learn how to use this
          feature, <file:Documentation/admin-guide/java.rst> for information about how
          to include Java support. and <file:Documentation/admin-guide/mono.rst> for
           information about how to include Mono-based .NET support.
index 2e005525cc19136e4d1149a51fa623393b385e78..293733f61594bc073fcd98ed94bb19fd8a93da21 100644 (file)
@@ -103,7 +103,6 @@ obj-$(CONFIG_ROMFS_FS)              += romfs/
 obj-$(CONFIG_QNX4FS_FS)                += qnx4/
 obj-$(CONFIG_QNX6FS_FS)                += qnx6/
 obj-$(CONFIG_AUTOFS_FS)                += autofs/
-obj-$(CONFIG_AUTOFS4_FS)       += autofs4/
 obj-$(CONFIG_ADFS_FS)          += adfs/
 obj-$(CONFIG_FUSE_FS)          += fuse/
 obj-$(CONFIG_OVERLAY_FS)       += overlayfs/
index 8dbd36f5e5811626ff71806d62c983e7ea35e288..c836c425ca94587e381fc9c9a867594717d88cd6 100644 (file)
@@ -199,7 +199,7 @@ adfs_adfs2unix_time(struct timespec *tv, struct inode *inode)
        return;
 
  cur_time:
-       *tv = current_time(inode);
+       *tv = timespec64_to_timespec(current_time(inode));
        return;
 
  too_early:
@@ -242,6 +242,7 @@ adfs_unix2adfs_time(struct inode *inode, unsigned int secs)
 struct inode *
 adfs_iget(struct super_block *sb, struct object_info *obj)
 {
+       struct timespec ts;
        struct inode *inode;
 
        inode = new_inode(sb);
@@ -270,7 +271,9 @@ adfs_iget(struct super_block *sb, struct object_info *obj)
        ADFS_I(inode)->stamped   = ((obj->loadaddr & 0xfff00000) == 0xfff00000);
 
        inode->i_mode    = adfs_atts2mode(sb, inode);
-       adfs_adfs2unix_time(&inode->i_mtime, inode);
+       ts = timespec64_to_timespec(inode->i_mtime);
+       adfs_adfs2unix_time(&ts, inode);
+       inode->i_mtime = timespec_to_timespec64(ts);
        inode->i_atime = inode->i_mtime;
        inode->i_ctime = inode->i_mtime;
 
index cfda2c7caedcec8b53d738f7c93924a723515370..71fa525d63a06c5f3b4196ddad6dcea517c4f4da 100644 (file)
@@ -313,7 +313,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di
 
        asb->s_ids_per_zone = zone_size / (asb->s_idlen + 1);
 
-       dm = kmalloc(nzones * sizeof(*dm), GFP_KERNEL);
+       dm = kmalloc_array(nzones, sizeof(*dm), GFP_KERNEL);
        if (dm == NULL) {
                adfs_error(sb, "not enough memory");
                return ERR_PTR(-ENOMEM);
index 532acae25453268477d7bc3e7a399e6e4a0c2ad8..546874057bd3594bd0997d37b8801fd866461077 100644 (file)
@@ -5,7 +5,7 @@
 
 afs-cache-$(CONFIG_AFS_FSCACHE) := cache.o
 
-kafs-objs := \
+kafs-y := \
        $(afs-cache-y) \
        addr_list.o \
        callback.o \
@@ -21,7 +21,6 @@ kafs-objs := \
        main.o \
        misc.o \
        mntpt.o \
-       proc.o \
        rotate.o \
        rxrpc.o \
        security.o \
@@ -34,4 +33,5 @@ kafs-objs := \
        write.o \
        xattr.o
 
+kafs-$(CONFIG_PROC_FS) += proc.o
 obj-$(CONFIG_AFS_FS)  := kafs.o
index 2c46c46f3a6d2ed362b2de1e8106044a80caedfb..025a9a5e1c32c29c4daf3cd40aba8537475af250 100644 (file)
@@ -215,7 +215,7 @@ struct afs_addr_list *afs_dns_query(struct afs_cell *cell, time64_t *_expiry)
        _enter("%s", cell->name);
 
        ret = dns_query("afsdb", cell->name, cell->name_len,
-                       "ipv4", &vllist, _expiry);
+                       "", &vllist, _expiry);
        if (ret < 0)
                return ERR_PTR(ret);
 
index 571437dcb252842578b92a6f3b5b60a574703b94..5f261fbf2182b22a47fc93b7c6fee35f113e0097 100644 (file)
 #include <linux/sched.h>
 #include "internal.h"
 
+/*
+ * Create volume and callback interests on a server.
+ */
+static struct afs_cb_interest *afs_create_interest(struct afs_server *server,
+                                                  struct afs_vnode *vnode)
+{
+       struct afs_vol_interest *new_vi, *vi;
+       struct afs_cb_interest *new;
+       struct hlist_node **pp;
+
+       new_vi = kzalloc(sizeof(struct afs_vol_interest), GFP_KERNEL);
+       if (!new_vi)
+               return NULL;
+
+       new = kzalloc(sizeof(struct afs_cb_interest), GFP_KERNEL);
+       if (!new) {
+               kfree(new_vi);
+               return NULL;
+       }
+
+       new_vi->usage = 1;
+       new_vi->vid = vnode->volume->vid;
+       INIT_HLIST_NODE(&new_vi->srv_link);
+       INIT_HLIST_HEAD(&new_vi->cb_interests);
+
+       refcount_set(&new->usage, 1);
+       new->sb = vnode->vfs_inode.i_sb;
+       new->vid = vnode->volume->vid;
+       new->server = afs_get_server(server);
+       INIT_HLIST_NODE(&new->cb_vlink);
+
+       write_lock(&server->cb_break_lock);
+
+       for (pp = &server->cb_volumes.first; *pp; pp = &(*pp)->next) {
+               vi = hlist_entry(*pp, struct afs_vol_interest, srv_link);
+               if (vi->vid < new_vi->vid)
+                       continue;
+               if (vi->vid > new_vi->vid)
+                       break;
+               vi->usage++;
+               goto found_vi;
+       }
+
+       new_vi->srv_link.pprev = pp;
+       new_vi->srv_link.next = *pp;
+       if (*pp)
+               (*pp)->pprev = &new_vi->srv_link.next;
+       *pp = &new_vi->srv_link;
+       vi = new_vi;
+       new_vi = NULL;
+found_vi:
+
+       new->vol_interest = vi;
+       hlist_add_head(&new->cb_vlink, &vi->cb_interests);
+
+       write_unlock(&server->cb_break_lock);
+       kfree(new_vi);
+       return new;
+}
+
 /*
  * Set up an interest-in-callbacks record for a volume on a server and
  * register it with the server.
@@ -77,20 +137,10 @@ int afs_register_server_cb_interest(struct afs_vnode *vnode,
        }
 
        if (!cbi) {
-               new = kzalloc(sizeof(struct afs_cb_interest), GFP_KERNEL);
+               new = afs_create_interest(server, vnode);
                if (!new)
                        return -ENOMEM;
 
-               refcount_set(&new->usage, 1);
-               new->sb = vnode->vfs_inode.i_sb;
-               new->vid = vnode->volume->vid;
-               new->server = afs_get_server(server);
-               INIT_LIST_HEAD(&new->cb_link);
-
-               write_lock(&server->cb_break_lock);
-               list_add_tail(&new->cb_link, &server->cb_interests);
-               write_unlock(&server->cb_break_lock);
-
                write_lock(&slist->lock);
                if (!entry->cb_interest) {
                        entry->cb_interest = afs_get_cb_interest(new);
@@ -126,11 +176,22 @@ int afs_register_server_cb_interest(struct afs_vnode *vnode,
  */
 void afs_put_cb_interest(struct afs_net *net, struct afs_cb_interest *cbi)
 {
+       struct afs_vol_interest *vi;
+
        if (cbi && refcount_dec_and_test(&cbi->usage)) {
-               if (!list_empty(&cbi->cb_link)) {
+               if (!hlist_unhashed(&cbi->cb_vlink)) {
                        write_lock(&cbi->server->cb_break_lock);
-                       list_del_init(&cbi->cb_link);
+
+                       hlist_del_init(&cbi->cb_vlink);
+                       vi = cbi->vol_interest;
+                       cbi->vol_interest = NULL;
+                       if (--vi->usage == 0)
+                               hlist_del(&vi->srv_link);
+                       else
+                               vi = NULL;
+
                        write_unlock(&cbi->server->cb_break_lock);
+                       kfree(vi);
                        afs_put_server(net, cbi->server);
                }
                kfree(cbi);
@@ -182,20 +243,34 @@ void afs_break_callback(struct afs_vnode *vnode)
 static void afs_break_one_callback(struct afs_server *server,
                                   struct afs_fid *fid)
 {
+       struct afs_vol_interest *vi;
        struct afs_cb_interest *cbi;
        struct afs_iget_data data;
        struct afs_vnode *vnode;
        struct inode *inode;
 
        read_lock(&server->cb_break_lock);
+       hlist_for_each_entry(vi, &server->cb_volumes, srv_link) {
+               if (vi->vid < fid->vid)
+                       continue;
+               if (vi->vid > fid->vid) {
+                       vi = NULL;
+                       break;
+               }
+               //atomic_inc(&vi->usage);
+               break;
+       }
+
+       /* TODO: Find all matching volumes if we couldn't match the server and
+        * break them anyway.
+        */
+       if (!vi)
+               goto out;
 
        /* Step through all interested superblocks.  There may be more than one
         * because of cell aliasing.
         */
-       list_for_each_entry(cbi, &server->cb_interests, cb_link) {
-               if (cbi->vid != fid->vid)
-                       continue;
-
+       hlist_for_each_entry(cbi, &vi->cb_interests, cb_vlink) {
                if (fid->vnode == 0 && fid->unique == 0) {
                        /* The callback break applies to an entire volume. */
                        struct afs_super_info *as = AFS_FS_S(cbi->sb);
@@ -217,6 +292,7 @@ static void afs_break_one_callback(struct afs_server *server,
                }
        }
 
+out:
        read_unlock(&server->cb_break_lock);
 }
 
index fdf4c36cff79ead65acf11a36b99614db924fe9b..f3d0bef16d78b99291c28e39fc266fa59098572d 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/dns_resolver.h>
 #include <linux/sched.h>
 #include <linux/inet.h>
+#include <linux/namei.h>
 #include <keys/rxrpc-type.h>
 #include "internal.h"
 
@@ -341,8 +342,8 @@ int afs_cell_init(struct afs_net *net, const char *rootcell)
 
        /* install the new cell */
        write_seqlock(&net->cells_lock);
-       old_root = net->ws_cell;
-       net->ws_cell = new_root;
+       old_root = rcu_access_pointer(net->ws_cell);
+       rcu_assign_pointer(net->ws_cell, new_root);
        write_sequnlock(&net->cells_lock);
 
        afs_put_cell(net, old_root);
@@ -528,12 +529,14 @@ static int afs_activate_cell(struct afs_net *net, struct afs_cell *cell)
                                             NULL, 0,
                                             cell, 0, true);
 #endif
-       ret = afs_proc_cell_setup(net, cell);
+       ret = afs_proc_cell_setup(cell);
        if (ret < 0)
                return ret;
-       spin_lock(&net->proc_cells_lock);
+
+       mutex_lock(&net->proc_cells_lock);
        list_add_tail(&cell->proc_link, &net->proc_cells);
-       spin_unlock(&net->proc_cells_lock);
+       afs_dynroot_mkdir(net, cell);
+       mutex_unlock(&net->proc_cells_lock);
        return 0;
 }
 
@@ -544,11 +547,12 @@ static void afs_deactivate_cell(struct afs_net *net, struct afs_cell *cell)
 {
        _enter("%s", cell->name);
 
-       afs_proc_cell_remove(net, cell);
+       afs_proc_cell_remove(cell);
 
-       spin_lock(&net->proc_cells_lock);
+       mutex_lock(&net->proc_cells_lock);
        list_del_init(&cell->proc_link);
-       spin_unlock(&net->proc_cells_lock);
+       afs_dynroot_rmdir(net, cell);
+       mutex_unlock(&net->proc_cells_lock);
 
 #ifdef CONFIG_AFS_FSCACHE
        fscache_relinquish_cookie(cell->cache, NULL, false);
@@ -755,8 +759,8 @@ void afs_cell_purge(struct afs_net *net)
        _enter("");
 
        write_seqlock(&net->cells_lock);
-       ws = net->ws_cell;
-       net->ws_cell = NULL;
+       ws = rcu_access_pointer(net->ws_cell);
+       RCU_INIT_POINTER(net->ws_cell, NULL);
        write_sequnlock(&net->cells_lock);
        afs_put_cell(net, ws);
 
index c332c95a6940f50fe3a9e220ebbb6928b0f5d27c..9e51d6fe7e8f975f34f877217a28a8e99bcfa5e4 100644 (file)
@@ -191,7 +191,8 @@ static int afs_deliver_cb_callback(struct afs_call *call)
                if (call->count > AFSCBMAX)
                        return afs_protocol_error(call, -EBADMSG);
 
-               call->buffer = kmalloc(call->count * 3 * 4, GFP_KERNEL);
+               call->buffer = kmalloc(array3_size(call->count, 3, 4),
+                                      GFP_KERNEL);
                if (!call->buffer)
                        return -ENOMEM;
                call->offset = 0;
@@ -330,7 +331,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call)
        switch (call->unmarshall) {
        case 0:
                call->offset = 0;
-               call->buffer = kmalloc(11 * sizeof(__be32), GFP_KERNEL);
+               call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
                if (!call->buffer)
                        return -ENOMEM;
                call->unmarshall++;
@@ -453,7 +454,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call)
        switch (call->unmarshall) {
        case 0:
                call->offset = 0;
-               call->buffer = kmalloc(11 * sizeof(__be32), GFP_KERNEL);
+               call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
                if (!call->buffer)
                        return -ENOMEM;
                call->unmarshall++;
@@ -525,7 +526,7 @@ static void SRXAFSCB_TellMeAboutYourself(struct work_struct *work)
        nifs = 0;
        ifs = kcalloc(32, sizeof(*ifs), GFP_KERNEL);
        if (ifs) {
-               nifs = afs_get_ipv4_interfaces(ifs, 32, false);
+               nifs = afs_get_ipv4_interfaces(call->net, ifs, 32, false);
                if (nifs < 0) {
                        kfree(ifs);
                        ifs = NULL;
index 983f3946ab576927850bd62e84308cf565de456f..174e843f06330187e3da4d5f1132493511dd4f5b 100644 (file)
@@ -1,4 +1,4 @@
-/* dir.c: AFS dynamic root handling
+/* AFS dynamic root handling
  *
  * Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
@@ -46,7 +46,7 @@ static int afs_probe_cell_name(struct dentry *dentry)
                return 0;
        }
 
-       ret = dns_query("afsdb", name, len, "ipv4", NULL, NULL);
+       ret = dns_query("afsdb", name, len, "", NULL, NULL);
        if (ret == -ENODATA)
                ret = -EDESTADDRREQ;
        return ret;
@@ -207,3 +207,125 @@ const struct dentry_operations afs_dynroot_dentry_operations = {
        .d_release      = afs_d_release,
        .d_automount    = afs_d_automount,
 };
+
+/*
+ * Create a manually added cell mount directory.
+ * - The caller must hold net->proc_cells_lock
+ */
+int afs_dynroot_mkdir(struct afs_net *net, struct afs_cell *cell)
+{
+       struct super_block *sb = net->dynroot_sb;
+       struct dentry *root, *subdir;
+       int ret;
+
+       if (!sb || atomic_read(&sb->s_active) == 0)
+               return 0;
+
+       /* Let the ->lookup op do the creation */
+       root = sb->s_root;
+       inode_lock(root->d_inode);
+       subdir = lookup_one_len(cell->name, root, cell->name_len);
+       if (IS_ERR(subdir)) {
+               ret = PTR_ERR(subdir);
+               goto unlock;
+       }
+
+       /* Note that we're retaining an extra ref on the dentry */
+       subdir->d_fsdata = (void *)1UL;
+       ret = 0;
+unlock:
+       inode_unlock(root->d_inode);
+       return ret;
+}
+
+/*
+ * Remove a manually added cell mount directory.
+ * - The caller must hold net->proc_cells_lock
+ */
+void afs_dynroot_rmdir(struct afs_net *net, struct afs_cell *cell)
+{
+       struct super_block *sb = net->dynroot_sb;
+       struct dentry *root, *subdir;
+
+       if (!sb || atomic_read(&sb->s_active) == 0)
+               return;
+
+       root = sb->s_root;
+       inode_lock(root->d_inode);
+
+       /* Don't want to trigger a lookup call, which will re-add the cell */
+       subdir = try_lookup_one_len(cell->name, root, cell->name_len);
+       if (IS_ERR_OR_NULL(subdir)) {
+               _debug("lookup %ld", PTR_ERR(subdir));
+               goto no_dentry;
+       }
+
+       _debug("rmdir %pd %u", subdir, d_count(subdir));
+
+       if (subdir->d_fsdata) {
+               _debug("unpin %u", d_count(subdir));
+               subdir->d_fsdata = NULL;
+               dput(subdir);
+       }
+       dput(subdir);
+no_dentry:
+       inode_unlock(root->d_inode);
+       _leave("");
+}
+
+/*
+ * Populate a newly created dynamic root with cell names.
+ */
+int afs_dynroot_populate(struct super_block *sb)
+{
+       struct afs_cell *cell;
+       struct afs_net *net = afs_sb2net(sb);
+       int ret;
+
+       if (mutex_lock_interruptible(&net->proc_cells_lock) < 0)
+               return -ERESTARTSYS;
+
+       net->dynroot_sb = sb;
+       list_for_each_entry(cell, &net->proc_cells, proc_link) {
+               ret = afs_dynroot_mkdir(net, cell);
+               if (ret < 0)
+                       goto error;
+       }
+
+       ret = 0;
+out:
+       mutex_unlock(&net->proc_cells_lock);
+       return ret;
+
+error:
+       net->dynroot_sb = NULL;
+       goto out;
+}
+
+/*
+ * When a dynamic root that's in the process of being destroyed, depopulate it
+ * of pinned directories.
+ */
+void afs_dynroot_depopulate(struct super_block *sb)
+{
+       struct afs_net *net = afs_sb2net(sb);
+       struct dentry *root = sb->s_root, *subdir, *tmp;
+
+       /* Prevent more subdirs from being created */
+       mutex_lock(&net->proc_cells_lock);
+       if (net->dynroot_sb == sb)
+               net->dynroot_sb = NULL;
+       mutex_unlock(&net->proc_cells_lock);
+
+       inode_lock(root->d_inode);
+
+       /* Remove all the pins for dirs created for manually added cells */
+       list_for_each_entry_safe(subdir, tmp, &root->d_subdirs, d_child) {
+               if (subdir->d_fsdata) {
+                       subdir->d_fsdata = NULL;
+                       dput(subdir);
+               }
+       }
+
+       inode_unlock(root->d_inode);
+}
index b273e1d60478c3c9f89a84a7b85fb6325a9a2c84..50929cb91732f5adec19706788e6a31aeb8beb03 100644 (file)
@@ -72,7 +72,7 @@ void afs_update_inode_from_status(struct afs_vnode *vnode,
                                  const afs_dataversion_t *expected_version,
                                  u8 flags)
 {
-       struct timespec t;
+       struct timespec64 t;
        umode_t mode;
 
        t.tv_sec = status->mtime_client;
@@ -138,10 +138,6 @@ static int xdr_decode_AFSFetchStatus(struct afs_call *call,
        u64 data_version, size;
        u32 type, abort_code;
        u8 flags = 0;
-       int ret;
-
-       if (vnode)
-               write_seqlock(&vnode->cb_lock);
 
        abort_code = ntohl(xdr->abort_code);
 
@@ -154,8 +150,7 @@ static int xdr_decode_AFSFetchStatus(struct afs_call *call,
                         * case.
                         */
                        status->abort_code = abort_code;
-                       ret = 0;
-                       goto out;
+                       return 0;
                }
 
                pr_warn("Unknown AFSFetchStatus version %u\n", ntohl(xdr->if_version));
@@ -164,8 +159,7 @@ static int xdr_decode_AFSFetchStatus(struct afs_call *call,
 
        if (abort_code != 0 && inline_error) {
                status->abort_code = abort_code;
-               ret = 0;
-               goto out;
+               return 0;
        }
 
        type = ntohl(xdr->type);
@@ -235,17 +229,35 @@ static int xdr_decode_AFSFetchStatus(struct afs_call *call,
                                             flags);
        }
 
-       ret = 0;
-
-out:
-       if (vnode)
-               write_sequnlock(&vnode->cb_lock);
-       return ret;
+       return 0;
 
 bad:
        xdr_dump_bad(*_bp);
-       ret = afs_protocol_error(call, -EBADMSG);
-       goto out;
+       return afs_protocol_error(call, -EBADMSG);
+}
+
+/*
+ * Decode the file status.  We need to lock the target vnode if we're going to
+ * update its status so that stat() sees the attributes update atomically.
+ */
+static int afs_decode_status(struct afs_call *call,
+                            const __be32 **_bp,
+                            struct afs_file_status *status,
+                            struct afs_vnode *vnode,
+                            const afs_dataversion_t *expected_version,
+                            struct afs_read *read_req)
+{
+       int ret;
+
+       if (!vnode)
+               return xdr_decode_AFSFetchStatus(call, _bp, status, vnode,
+                                                expected_version, read_req);
+
+       write_seqlock(&vnode->cb_lock);
+       ret = xdr_decode_AFSFetchStatus(call, _bp, status, vnode,
+                                       expected_version, read_req);
+       write_sequnlock(&vnode->cb_lock);
+       return ret;
 }
 
 /*
@@ -387,8 +399,8 @@ static int afs_deliver_fs_fetch_status_vnode(struct afs_call *call)
 
        /* unmarshall the reply once we've received all of it */
        bp = call->buffer;
-       if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
-                                     &call->expected_version, NULL) < 0)
+       if (afs_decode_status(call, &bp, &vnode->status, vnode,
+                             &call->expected_version, NULL) < 0)
                return afs_protocol_error(call, -EBADMSG);
        xdr_decode_AFSCallBack(call, vnode, &bp);
        if (call->reply[1])
@@ -568,8 +580,8 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call)
                        return ret;
 
                bp = call->buffer;
-               if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
-                                             &vnode->status.data_version, req) < 0)
+               if (afs_decode_status(call, &bp, &vnode->status, vnode,
+                                     &vnode->status.data_version, req) < 0)
                        return afs_protocol_error(call, -EBADMSG);
                xdr_decode_AFSCallBack(call, vnode, &bp);
                if (call->reply[1])
@@ -721,9 +733,9 @@ static int afs_deliver_fs_create_vnode(struct afs_call *call)
        /* unmarshall the reply once we've received all of it */
        bp = call->buffer;
        xdr_decode_AFSFid(&bp, call->reply[1]);
-       if (xdr_decode_AFSFetchStatus(call, &bp, call->reply[2], NULL, NULL, NULL) < 0 ||
-           xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
-                                     &call->expected_version, NULL) < 0)
+       if (afs_decode_status(call, &bp, call->reply[2], NULL, NULL, NULL) < 0 ||
+           afs_decode_status(call, &bp, &vnode->status, vnode,
+                             &call->expected_version, NULL) < 0)
                return afs_protocol_error(call, -EBADMSG);
        xdr_decode_AFSCallBack_raw(&bp, call->reply[3]);
        /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
@@ -827,8 +839,8 @@ static int afs_deliver_fs_remove(struct afs_call *call)
 
        /* unmarshall the reply once we've received all of it */
        bp = call->buffer;
-       if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
-                                     &call->expected_version, NULL) < 0)
+       if (afs_decode_status(call, &bp, &vnode->status, vnode,
+                             &call->expected_version, NULL) < 0)
                return afs_protocol_error(call, -EBADMSG);
        /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
 
@@ -917,9 +929,9 @@ static int afs_deliver_fs_link(struct afs_call *call)
 
        /* unmarshall the reply once we've received all of it */
        bp = call->buffer;
-       if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode, NULL, NULL) < 0 ||
-           xdr_decode_AFSFetchStatus(call, &bp, &dvnode->status, dvnode,
-                                     &call->expected_version, NULL) < 0)
+       if (afs_decode_status(call, &bp, &vnode->status, vnode, NULL, NULL) < 0 ||
+           afs_decode_status(call, &bp, &dvnode->status, dvnode,
+                             &call->expected_version, NULL) < 0)
                return afs_protocol_error(call, -EBADMSG);
        /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
 
@@ -1004,9 +1016,9 @@ static int afs_deliver_fs_symlink(struct afs_call *call)
        /* unmarshall the reply once we've received all of it */
        bp = call->buffer;
        xdr_decode_AFSFid(&bp, call->reply[1]);
-       if (xdr_decode_AFSFetchStatus(call, &bp, call->reply[2], NULL, NULL, NULL) ||
-           xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
-                                     &call->expected_version, NULL) < 0)
+       if (afs_decode_status(call, &bp, call->reply[2], NULL, NULL, NULL) ||
+           afs_decode_status(call, &bp, &vnode->status, vnode,
+                             &call->expected_version, NULL) < 0)
                return afs_protocol_error(call, -EBADMSG);
        /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
 
@@ -1110,12 +1122,12 @@ static int afs_deliver_fs_rename(struct afs_call *call)
 
        /* unmarshall the reply once we've received all of it */
        bp = call->buffer;
-       if (xdr_decode_AFSFetchStatus(call, &bp, &orig_dvnode->status, orig_dvnode,
-                                     &call->expected_version, NULL) < 0)
+       if (afs_decode_status(call, &bp, &orig_dvnode->status, orig_dvnode,
+                             &call->expected_version, NULL) < 0)
                return afs_protocol_error(call, -EBADMSG);
        if (new_dvnode != orig_dvnode &&
-           xdr_decode_AFSFetchStatus(call, &bp, &new_dvnode->status, new_dvnode,
-                                     &call->expected_version_2, NULL) < 0)
+           afs_decode_status(call, &bp, &new_dvnode->status, new_dvnode,
+                             &call->expected_version_2, NULL) < 0)
                return afs_protocol_error(call, -EBADMSG);
        /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
 
@@ -1219,8 +1231,8 @@ static int afs_deliver_fs_store_data(struct afs_call *call)
 
        /* unmarshall the reply once we've received all of it */
        bp = call->buffer;
-       if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
-                                     &call->expected_version, NULL) < 0)
+       if (afs_decode_status(call, &bp, &vnode->status, vnode,
+                             &call->expected_version, NULL) < 0)
                return afs_protocol_error(call, -EBADMSG);
        /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
 
@@ -1395,8 +1407,8 @@ static int afs_deliver_fs_store_status(struct afs_call *call)
 
        /* unmarshall the reply once we've received all of it */
        bp = call->buffer;
-       if (xdr_decode_AFSFetchStatus(call, &bp, &vnode->status, vnode,
-                                     &call->expected_version, NULL) < 0)
+       if (afs_decode_status(call, &bp, &vnode->status, vnode,
+                             &call->expected_version, NULL) < 0)
                return afs_protocol_error(call, -EBADMSG);
        /* xdr_decode_AFSVolSync(&bp, call->reply[X]); */
 
@@ -2097,8 +2109,8 @@ static int afs_deliver_fs_fetch_status(struct afs_call *call)
 
        /* unmarshall the reply once we've received all of it */
        bp = call->buffer;
-       xdr_decode_AFSFetchStatus(call, &bp, status, vnode,
-                                 &call->expected_version, NULL);
+       afs_decode_status(call, &bp, status, vnode,
+                         &call->expected_version, NULL);
        callback[call->count].version   = ntohl(bp[0]);
        callback[call->count].expiry    = ntohl(bp[1]);
        callback[call->count].type      = ntohl(bp[2]);
@@ -2209,9 +2221,9 @@ static int afs_deliver_fs_inline_bulk_status(struct afs_call *call)
 
                bp = call->buffer;
                statuses = call->reply[1];
-               if (xdr_decode_AFSFetchStatus(call, &bp, &statuses[call->count],
-                                             call->count == 0 ? vnode : NULL,
-                                             NULL, NULL) < 0)
+               if (afs_decode_status(call, &bp, &statuses[call->count],
+                                     call->count == 0 ? vnode : NULL,
+                                     NULL, NULL) < 0)
                        return afs_protocol_error(call, -EBADMSG);
 
                call->count++;
index e3f8a46663dbade0149d44e0d543bb7f171170a7..9778df1357179d14238cfa52e7394886206a1f1d 100644 (file)
@@ -22,6 +22,8 @@
 #include <linux/backing-dev.h>
 #include <linux/uuid.h>
 #include <net/net_namespace.h>
+#include <net/netns/generic.h>
+#include <net/sock.h>
 #include <net/af_rxrpc.h>
 
 #include "afs.h"
@@ -40,7 +42,8 @@ struct afs_mount_params {
        afs_voltype_t           type;           /* type of volume requested */
        int                     volnamesz;      /* size of volume name */
        const char              *volname;       /* name of volume to mount */
-       struct afs_net          *net;           /* Network namespace in effect */
+       struct net              *net_ns;        /* Network namespace in effect */
+       struct afs_net          *net;           /* the AFS net namespace stuff */
        struct afs_cell         *cell;          /* cell in which to find volume */
        struct afs_volume       *volume;        /* volume record */
        struct key              *key;           /* key to use for secure mounting */
@@ -189,7 +192,7 @@ struct afs_read {
  * - there's one superblock per volume
  */
 struct afs_super_info {
-       struct afs_net          *net;           /* Network namespace */
+       struct net              *net_ns;        /* Network namespace */
        struct afs_cell         *cell;          /* The cell in which the volume resides */
        struct afs_volume       *volume;        /* volume record */
        bool                    dyn_root;       /* True if dynamic root */
@@ -210,7 +213,6 @@ struct afs_sysnames {
        char                    *subs[AFS_NR_SYSNAME];
        refcount_t              usage;
        unsigned short          nr;
-       short                   error;
        char                    blank[1];
 };
 
@@ -218,6 +220,7 @@ struct afs_sysnames {
  * AFS network namespace record.
  */
 struct afs_net {
+       struct net              *net;           /* Backpointer to the owning net namespace */
        struct afs_uuid         uuid;
        bool                    live;           /* F if this namespace is being removed */
 
@@ -231,13 +234,13 @@ struct afs_net {
 
        /* Cell database */
        struct rb_root          cells;
-       struct afs_cell         *ws_cell;
+       struct afs_cell __rcu   *ws_cell;
        struct work_struct      cells_manager;
        struct timer_list       cells_timer;
        atomic_t                cells_outstanding;
        seqlock_t               cells_lock;
 
-       spinlock_t              proc_cells_lock;
+       struct mutex            proc_cells_lock;
        struct list_head        proc_cells;
 
        /* Known servers.  Theoretically each fileserver can only be in one
@@ -261,6 +264,7 @@ struct afs_net {
        struct mutex            lock_manager_mutex;
 
        /* Misc */
+       struct super_block      *dynroot_sb;    /* Dynamic root mount superblock */
        struct proc_dir_entry   *proc_afs;      /* /proc/net/afs directory */
        struct afs_sysnames     *sysnames;
        rwlock_t                sysnames_lock;
@@ -280,7 +284,6 @@ struct afs_net {
 };
 
 extern const char afs_init_sysname[];
-extern struct afs_net __afs_net;// Dummy AFS network namespace; TODO: replace with real netns
 
 enum afs_cell_state {
        AFS_CELL_UNSET,
@@ -404,16 +407,27 @@ struct afs_server {
        rwlock_t                fs_lock;        /* access lock */
 
        /* callback promise management */
-       struct list_head        cb_interests;   /* List of superblocks using this server */
+       struct hlist_head       cb_volumes;     /* List of volume interests on this server */
        unsigned                cb_s_break;     /* Break-everything counter. */
        rwlock_t                cb_break_lock;  /* Volume finding lock */
 };
 
+/*
+ * Volume collation in the server's callback interest list.
+ */
+struct afs_vol_interest {
+       struct hlist_node       srv_link;       /* Link in server->cb_volumes */
+       struct hlist_head       cb_interests;   /* List of callback interests on the server */
+       afs_volid_t             vid;            /* Volume ID to match */
+       unsigned int            usage;
+};
+
 /*
  * Interest by a superblock on a server.
  */
 struct afs_cb_interest {
-       struct list_head        cb_link;        /* Link in server->cb_interests */
+       struct hlist_node       cb_vlink;       /* Link in vol_interest->cb_interests */
+       struct afs_vol_interest *vol_interest;
        struct afs_server       *server;        /* Server on which this interest resides */
        struct super_block      *sb;            /* Superblock on which inodes reside */
        afs_volid_t             vid;            /* Volume ID to match */
@@ -720,6 +734,10 @@ extern const struct inode_operations afs_dynroot_inode_operations;
 extern const struct dentry_operations afs_dynroot_dentry_operations;
 
 extern struct inode *afs_try_auto_mntpt(struct dentry *, struct inode *);
+extern int afs_dynroot_mkdir(struct afs_net *, struct afs_cell *);
+extern void afs_dynroot_rmdir(struct afs_net *, struct afs_cell *);
+extern int afs_dynroot_populate(struct super_block *);
+extern void afs_dynroot_depopulate(struct super_block *);
 
 /*
  * file.c
@@ -806,34 +824,36 @@ extern int afs_drop_inode(struct inode *);
  * main.c
  */
 extern struct workqueue_struct *afs_wq;
+extern int afs_net_id;
 
-static inline struct afs_net *afs_d2net(struct dentry *dentry)
+static inline struct afs_net *afs_net(struct net *net)
 {
-       return &__afs_net;
+       return net_generic(net, afs_net_id);
 }
 
-static inline struct afs_net *afs_i2net(struct inode *inode)
+static inline struct afs_net *afs_sb2net(struct super_block *sb)
 {
-       return &__afs_net;
+       return afs_net(AFS_FS_S(sb)->net_ns);
 }
 
-static inline struct afs_net *afs_v2net(struct afs_vnode *vnode)
+static inline struct afs_net *afs_d2net(struct dentry *dentry)
 {
-       return &__afs_net;
+       return afs_sb2net(dentry->d_sb);
 }
 
-static inline struct afs_net *afs_sock2net(struct sock *sk)
+static inline struct afs_net *afs_i2net(struct inode *inode)
 {
-       return &__afs_net;
+       return afs_sb2net(inode->i_sb);
 }
 
-static inline struct afs_net *afs_get_net(struct afs_net *net)
+static inline struct afs_net *afs_v2net(struct afs_vnode *vnode)
 {
-       return net;
+       return afs_i2net(&vnode->vfs_inode);
 }
 
-static inline void afs_put_net(struct afs_net *net)
+static inline struct afs_net *afs_sock2net(struct sock *sk)
 {
+       return net_generic(sock_net(sk), afs_net_id);
 }
 
 static inline void __afs_stat(atomic_t *s)
@@ -861,16 +881,25 @@ extern void afs_mntpt_kill_timer(void);
 /*
  * netdevices.c
  */
-extern int afs_get_ipv4_interfaces(struct afs_interface *, size_t, bool);
+extern int afs_get_ipv4_interfaces(struct afs_net *, struct afs_interface *,
+                                  size_t, bool);
 
 /*
  * proc.c
  */
+#ifdef CONFIG_PROC_FS
 extern int __net_init afs_proc_init(struct afs_net *);
 extern void __net_exit afs_proc_cleanup(struct afs_net *);
-extern int afs_proc_cell_setup(struct afs_net *, struct afs_cell *);
-extern void afs_proc_cell_remove(struct afs_net *, struct afs_cell *);
+extern int afs_proc_cell_setup(struct afs_cell *);
+extern void afs_proc_cell_remove(struct afs_cell *);
 extern void afs_put_sysnames(struct afs_sysnames *);
+#else
+static inline int afs_proc_init(struct afs_net *net) { return 0; }
+static inline void afs_proc_cleanup(struct afs_net *net) {}
+static inline int afs_proc_cell_setup(struct afs_cell *cell) { return 0; }
+static inline void afs_proc_cell_remove(struct afs_cell *cell) {}
+static inline void afs_put_sysnames(struct afs_sysnames *sysnames) {}
+#endif
 
 /*
  * rotate.c
@@ -1002,7 +1031,7 @@ extern bool afs_annotate_server_list(struct afs_server_list *, struct afs_server
  * super.c
  */
 extern int __init afs_fs_init(void);
-extern void __exit afs_fs_exit(void);
+extern void afs_fs_exit(void);
 
 /*
  * vlclient.c
index d7560168b3bf7fa8887fa77cd7bd982e06af49f0..e84fe822a960714c8b274435dddbb66f4ba3275a 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/completion.h>
 #include <linux/sched.h>
 #include <linux/random.h>
+#include <linux/proc_fs.h>
 #define CREATE_TRACE_POINTS
 #include "internal.h"
 
@@ -32,7 +33,7 @@ module_param(rootcell, charp, 0);
 MODULE_PARM_DESC(rootcell, "root AFS cell name and VL server IP addr list");
 
 struct workqueue_struct *afs_wq;
-struct afs_net __afs_net;
+static struct proc_dir_entry *afs_proc_symlink;
 
 #if defined(CONFIG_ALPHA)
 const char afs_init_sysname[] = "alpha_linux26";
@@ -67,11 +68,13 @@ const char afs_init_sysname[] = "unknown_linux26";
 /*
  * Initialise an AFS network namespace record.
  */
-static int __net_init afs_net_init(struct afs_net *net)
+static int __net_init afs_net_init(struct net *net_ns)
 {
        struct afs_sysnames *sysnames;
+       struct afs_net *net = afs_net(net_ns);
        int ret;
 
+       net->net = net_ns;
        net->live = true;
        generate_random_uuid((unsigned char *)&net->uuid);
 
@@ -83,7 +86,7 @@ static int __net_init afs_net_init(struct afs_net *net)
        INIT_WORK(&net->cells_manager, afs_manage_cells);
        timer_setup(&net->cells_timer, afs_cells_timer, 0);
 
-       spin_lock_init(&net->proc_cells_lock);
+       mutex_init(&net->proc_cells_lock);
        INIT_LIST_HEAD(&net->proc_cells);
 
        seqlock_init(&net->fs_lock);
@@ -142,8 +145,10 @@ static int __net_init afs_net_init(struct afs_net *net)
 /*
  * Clean up and destroy an AFS network namespace record.
  */
-static void __net_exit afs_net_exit(struct afs_net *net)
+static void __net_exit afs_net_exit(struct net *net_ns)
 {
+       struct afs_net *net = afs_net(net_ns);
+
        net->live = false;
        afs_cell_purge(net);
        afs_purge_servers(net);
@@ -152,6 +157,13 @@ static void __net_exit afs_net_exit(struct afs_net *net)
        afs_put_sysnames(net->sysnames);
 }
 
+static struct pernet_operations afs_net_ops = {
+       .init   = afs_net_init,
+       .exit   = afs_net_exit,
+       .id     = &afs_net_id,
+       .size   = sizeof(struct afs_net),
+};
+
 /*
  * initialise the AFS client FS module
  */
@@ -178,7 +190,7 @@ static int __init afs_init(void)
                goto error_cache;
 #endif
 
-       ret = afs_net_init(&__afs_net);
+       ret = register_pernet_subsys(&afs_net_ops);
        if (ret < 0)
                goto error_net;
 
@@ -187,10 +199,18 @@ static int __init afs_init(void)
        if (ret < 0)
                goto error_fs;
 
+       afs_proc_symlink = proc_symlink("fs/afs", NULL, "../self/net/afs");
+       if (IS_ERR(afs_proc_symlink)) {
+               ret = PTR_ERR(afs_proc_symlink);
+               goto error_proc;
+       }
+
        return ret;
 
+error_proc:
+       afs_fs_exit();
 error_fs:
-       afs_net_exit(&__afs_net);
+       unregister_pernet_subsys(&afs_net_ops);
 error_net:
 #ifdef CONFIG_AFS_FSCACHE
        fscache_unregister_netfs(&afs_cache_netfs);
@@ -219,8 +239,9 @@ static void __exit afs_exit(void)
 {
        printk(KERN_INFO "kAFS: Red Hat AFS client v0.1 unregistering.\n");
 
+       proc_remove(afs_proc_symlink);
        afs_fs_exit();
-       afs_net_exit(&__afs_net);
+       unregister_pernet_subsys(&afs_net_ops);
 #ifdef CONFIG_AFS_FSCACHE
        fscache_unregister_netfs(&afs_cache_netfs);
 #endif
index 50bd5bb1c4fb1b4b91c25980f5f1452509c540e6..2a009d1939d7ffbd4047818b9f0bf0da3ffabc85 100644 (file)
@@ -17,8 +17,8 @@
  * - maxbufs must be at least 1
  * - returns the number of interface records in the buffer
  */
-int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs,
-                           bool wantloopback)
+int afs_get_ipv4_interfaces(struct afs_net *net, struct afs_interface *bufs,
+                           size_t maxbufs, bool wantloopback)
 {
        struct net_device *dev;
        struct in_device *idev;
@@ -27,7 +27,7 @@ int afs_get_ipv4_interfaces(struct afs_interface *bufs, size_t maxbufs,
        ASSERT(maxbufs > 0);
 
        rtnl_lock();
-       for_each_netdev(&init_net, dev) {
+       for_each_netdev(net->net, dev) {
                if (dev->type == ARPHRD_LOOPBACK && !wantloopback)
                        continue;
                idev = __in_dev_get_rtnl(dev);
index 3aad32762989434798e02e6cf365a8211b8348c9..0c3285c8db95b4ec6457fdfe759e1997c9c69a7f 100644 (file)
 #include <linux/uaccess.h>
 #include "internal.h"
 
-static inline struct afs_net *afs_proc2net(struct file *f)
+static inline struct afs_net *afs_seq2net(struct seq_file *m)
 {
-       return &__afs_net;
+       return afs_net(seq_file_net(m));
 }
 
-static inline struct afs_net *afs_seq2net(struct seq_file *m)
+static inline struct afs_net *afs_seq2net_single(struct seq_file *m)
 {
-       return &__afs_net; // TODO: use seq_file_net(m)
+       return afs_net(seq_file_single_net(m));
 }
 
-static int afs_proc_cells_open(struct inode *inode, struct file *file);
-static void *afs_proc_cells_start(struct seq_file *p, loff_t *pos);
-static void *afs_proc_cells_next(struct seq_file *p, void *v, loff_t *pos);
-static void afs_proc_cells_stop(struct seq_file *p, void *v);
-static int afs_proc_cells_show(struct seq_file *m, void *v);
-static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
-                                   size_t size, loff_t *_pos);
-
-static const struct seq_operations afs_proc_cells_ops = {
-       .start  = afs_proc_cells_start,
-       .next   = afs_proc_cells_next,
-       .stop   = afs_proc_cells_stop,
-       .show   = afs_proc_cells_show,
-};
-
-static const struct file_operations afs_proc_cells_fops = {
-       .open           = afs_proc_cells_open,
-       .read           = seq_read,
-       .write          = afs_proc_cells_write,
-       .llseek         = seq_lseek,
-       .release        = seq_release,
-};
-
-static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,
-                                     size_t size, loff_t *_pos);
-static ssize_t afs_proc_rootcell_write(struct file *file,
-                                      const char __user *buf,
-                                      size_t size, loff_t *_pos);
-
-static const struct file_operations afs_proc_rootcell_fops = {
-       .read           = afs_proc_rootcell_read,
-       .write          = afs_proc_rootcell_write,
-       .llseek         = no_llseek,
-};
-
-static void *afs_proc_cell_volumes_start(struct seq_file *p, loff_t *pos);
-static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
-                                       loff_t *pos);
-static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v);
-static int afs_proc_cell_volumes_show(struct seq_file *m, void *v);
-
-static const struct seq_operations afs_proc_cell_volumes_ops = {
-       .start  = afs_proc_cell_volumes_start,
-       .next   = afs_proc_cell_volumes_next,
-       .stop   = afs_proc_cell_volumes_stop,
-       .show   = afs_proc_cell_volumes_show,
-};
-
-static void *afs_proc_cell_vlservers_start(struct seq_file *p, loff_t *pos);
-static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
-                                         loff_t *pos);
-static void afs_proc_cell_vlservers_stop(struct seq_file *p, void *v);
-static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v);
-
-static const struct seq_operations afs_proc_cell_vlservers_ops = {
-       .start  = afs_proc_cell_vlservers_start,
-       .next   = afs_proc_cell_vlservers_next,
-       .stop   = afs_proc_cell_vlservers_stop,
-       .show   = afs_proc_cell_vlservers_show,
-};
-
-static void *afs_proc_servers_start(struct seq_file *p, loff_t *pos);
-static void *afs_proc_servers_next(struct seq_file *p, void *v,
-                                       loff_t *pos);
-static void afs_proc_servers_stop(struct seq_file *p, void *v);
-static int afs_proc_servers_show(struct seq_file *m, void *v);
-
-static const struct seq_operations afs_proc_servers_ops = {
-       .start  = afs_proc_servers_start,
-       .next   = afs_proc_servers_next,
-       .stop   = afs_proc_servers_stop,
-       .show   = afs_proc_servers_show,
-};
-
-static int afs_proc_sysname_open(struct inode *inode, struct file *file);
-static int afs_proc_sysname_release(struct inode *inode, struct file *file);
-static void *afs_proc_sysname_start(struct seq_file *p, loff_t *pos);
-static void *afs_proc_sysname_next(struct seq_file *p, void *v,
-                                       loff_t *pos);
-static void afs_proc_sysname_stop(struct seq_file *p, void *v);
-static int afs_proc_sysname_show(struct seq_file *m, void *v);
-static ssize_t afs_proc_sysname_write(struct file *file,
-                                     const char __user *buf,
-                                     size_t size, loff_t *_pos);
-
-static const struct seq_operations afs_proc_sysname_ops = {
-       .start  = afs_proc_sysname_start,
-       .next   = afs_proc_sysname_next,
-       .stop   = afs_proc_sysname_stop,
-       .show   = afs_proc_sysname_show,
-};
-
-static const struct file_operations afs_proc_sysname_fops = {
-       .open           = afs_proc_sysname_open,
-       .read           = seq_read,
-       .llseek         = seq_lseek,
-       .release        = afs_proc_sysname_release,
-       .write          = afs_proc_sysname_write,
-};
-
-static int afs_proc_stats_show(struct seq_file *m, void *v);
-
 /*
- * initialise the /proc/fs/afs/ directory
+ * Display the list of cells known to the namespace.
  */
-int afs_proc_init(struct afs_net *net)
+static int afs_proc_cells_show(struct seq_file *m, void *v)
 {
-       _enter("");
-
-       net->proc_afs = proc_mkdir("fs/afs", NULL);
-       if (!net->proc_afs)
-               goto error_dir;
+       struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link);
+       struct afs_net *net = afs_seq2net(m);
 
-       if (!proc_create("cells", 0644, net->proc_afs, &afs_proc_cells_fops) ||
-           !proc_create("rootcell", 0644, net->proc_afs, &afs_proc_rootcell_fops) ||
-           !proc_create_seq("servers", 0644, net->proc_afs, &afs_proc_servers_ops) ||
-           !proc_create_single("stats", 0644, net->proc_afs, afs_proc_stats_show) ||
-           !proc_create("sysname", 0644, net->proc_afs, &afs_proc_sysname_fops))
-               goto error_tree;
+       if (v == &net->proc_cells) {
+               /* display header on line 1 */
+               seq_puts(m, "USE NAME\n");
+               return 0;
+       }
 
-       _leave(" = 0");
+       /* display one cell per line on subsequent lines */
+       seq_printf(m, "%3u %s\n", atomic_read(&cell->usage), cell->name);
        return 0;
-
-error_tree:
-       proc_remove(net->proc_afs);
-error_dir:
-       _leave(" = -ENOMEM");
-       return -ENOMEM;
-}
-
-/*
- * clean up the /proc/fs/afs/ directory
- */
-void afs_proc_cleanup(struct afs_net *net)
-{
-       proc_remove(net->proc_afs);
-       net->proc_afs = NULL;
-}
-
-/*
- * open "/proc/fs/afs/cells" which provides a summary of extant cells
- */
-static int afs_proc_cells_open(struct inode *inode, struct file *file)
-{
-       return seq_open(file, &afs_proc_cells_ops);
 }
 
-/*
- * set up the iterator to start reading from the cells list and return the
- * first item
- */
 static void *afs_proc_cells_start(struct seq_file *m, loff_t *_pos)
        __acquires(rcu)
 {
-       struct afs_net *net = afs_seq2net(m);
-
        rcu_read_lock();
-       return seq_list_start_head(&net->proc_cells, *_pos);
+       return seq_list_start_head(&afs_seq2net(m)->proc_cells, *_pos);
 }
 
-/*
- * move to next cell in cells list
- */
 static void *afs_proc_cells_next(struct seq_file *m, void *v, loff_t *pos)
 {
-       struct afs_net *net = afs_seq2net(m);
-
-       return seq_list_next(v, &net->proc_cells, pos);
+       return seq_list_next(v, &afs_seq2net(m)->proc_cells, pos);
 }
 
-/*
- * clean up after reading from the cells list
- */
 static void afs_proc_cells_stop(struct seq_file *m, void *v)
        __releases(rcu)
 {
        rcu_read_unlock();
 }
 
-/*
- * display a header line followed by a load of cell lines
- */
-static int afs_proc_cells_show(struct seq_file *m, void *v)
-{
-       struct afs_cell *cell = list_entry(v, struct afs_cell, proc_link);
-       struct afs_net *net = afs_seq2net(m);
-
-       if (v == &net->proc_cells) {
-               /* display header on line 1 */
-               seq_puts(m, "USE NAME\n");
-               return 0;
-       }
-
-       /* display one cell per line on subsequent lines */
-       seq_printf(m, "%3u %s\n", atomic_read(&cell->usage), cell->name);
-       return 0;
-}
+static const struct seq_operations afs_proc_cells_ops = {
+       .start  = afs_proc_cells_start,
+       .next   = afs_proc_cells_next,
+       .stop   = afs_proc_cells_stop,
+       .show   = afs_proc_cells_show,
+};
 
 /*
  * handle writes to /proc/fs/afs/cells
  * - to add cells: echo "add <cellname> <IP>[:<IP>][:<IP>]"
  */
-static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
-                                   size_t size, loff_t *_pos)
+static int afs_proc_cells_write(struct file *file, char *buf, size_t size)
 {
-       struct afs_net *net = afs_proc2net(file);
-       char *kbuf, *name, *args;
+       struct seq_file *m = file->private_data;
+       struct afs_net *net = afs_seq2net(m);
+       char *name, *args;
        int ret;
 
-       /* start by dragging the command into memory */
-       if (size <= 1 || size >= PAGE_SIZE)
-               return -EINVAL;
-
-       kbuf = memdup_user_nul(buf, size);
-       if (IS_ERR(kbuf))
-               return PTR_ERR(kbuf);
-
        /* trim to first NL */
-       name = memchr(kbuf, '\n', size);
+       name = memchr(buf, '\n', size);
        if (name)
                *name = 0;
 
        /* split into command, name and argslist */
-       name = strchr(kbuf, ' ');
+       name = strchr(buf, ' ');
        if (!name)
                goto inval;
        do {
@@ -269,9 +107,9 @@ static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
                goto inval;
 
        /* determine command to perform */
-       _debug("cmd=%s name=%s args=%s", kbuf, name, args);
+       _debug("cmd=%s name=%s args=%s", buf, name, args);
 
-       if (strcmp(kbuf, "add") == 0) {
+       if (strcmp(buf, "add") == 0) {
                struct afs_cell *cell;
 
                cell = afs_lookup_cell(net, name, strlen(name), args, true);
@@ -287,10 +125,9 @@ static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
                goto inval;
        }
 
-       ret = size;
+       ret = 0;
 
 done:
-       kfree(kbuf);
        _leave(" = %d", ret);
        return ret;
 
@@ -300,200 +137,136 @@ static ssize_t afs_proc_cells_write(struct file *file, const char __user *buf,
        goto done;
 }
 
-static ssize_t afs_proc_rootcell_read(struct file *file, char __user *buf,
-                                     size_t size, loff_t *_pos)
+/*
+ * Display the name of the current workstation cell.
+ */
+static int afs_proc_rootcell_show(struct seq_file *m, void *v)
 {
        struct afs_cell *cell;
-       struct afs_net *net = afs_proc2net(file);
-       unsigned int seq = 0;
-       char name[AFS_MAXCELLNAME + 1];
-       int len;
-
-       if (*_pos > 0)
-               return 0;
-       if (!net->ws_cell)
-               return 0;
-
-       rcu_read_lock();
-       do {
-               read_seqbegin_or_lock(&net->cells_lock, &seq);
-               len = 0;
-               cell = rcu_dereference_raw(net->ws_cell);
-               if (cell) {
-                       len = cell->name_len;
-                       memcpy(name, cell->name, len);
-               }
-       } while (need_seqretry(&net->cells_lock, seq));
-       done_seqretry(&net->cells_lock, seq);
-       rcu_read_unlock();
-
-       if (!len)
-               return 0;
-
-       name[len++] = '\n';
-       if (len > size)
-               len = size;
-       if (copy_to_user(buf, name, len) != 0)
-               return -EFAULT;
-       *_pos = 1;
-       return len;
+       struct afs_net *net;
+
+       net = afs_seq2net_single(m);
+       if (rcu_access_pointer(net->ws_cell)) {
+               rcu_read_lock();
+               cell = rcu_dereference(net->ws_cell);
+               if (cell)
+                       seq_printf(m, "%s\n", cell->name);
+               rcu_read_unlock();
+       }
+       return 0;
 }
 
 /*
- * handle writes to /proc/fs/afs/rootcell
- * - to initialize rootcell: echo "cell.name:192.168.231.14"
+ * Set the current workstation cell and optionally supply its list of volume
+ * location servers.
+ *
+ *     echo "cell.name:192.168.231.14" >/proc/fs/afs/rootcell
  */
-static ssize_t afs_proc_rootcell_write(struct file *file,
-                                      const char __user *buf,
-                                      size_t size, loff_t *_pos)
+static int afs_proc_rootcell_write(struct file *file, char *buf, size_t size)
 {
-       struct afs_net *net = afs_proc2net(file);
-       char *kbuf, *s;
+       struct seq_file *m = file->private_data;
+       struct afs_net *net = afs_seq2net_single(m);
+       char *s;
        int ret;
 
-       /* start by dragging the command into memory */
-       if (size <= 1 || size >= PAGE_SIZE)
-               return -EINVAL;
-
-       kbuf = memdup_user_nul(buf, size);
-       if (IS_ERR(kbuf))
-               return PTR_ERR(kbuf);
-
        ret = -EINVAL;
-       if (kbuf[0] == '.')
+       if (buf[0] == '.')
                goto out;
-       if (memchr(kbuf, '/', size))
+       if (memchr(buf, '/', size))
                goto out;
 
        /* trim to first NL */
-       s = memchr(kbuf, '\n', size);
+       s = memchr(buf, '\n', size);
        if (s)
                *s = 0;
 
        /* determine command to perform */
-       _debug("rootcell=%s", kbuf);
+       _debug("rootcell=%s", buf);
 
-       ret = afs_cell_init(net, kbuf);
-       if (ret >= 0)
-               ret = size;     /* consume everything, always */
+       ret = afs_cell_init(net, buf);
 
 out:
-       kfree(kbuf);
        _leave(" = %d", ret);
        return ret;
 }
 
+static const char afs_vol_types[3][3] = {
+       [AFSVL_RWVOL]   = "RW",
+       [AFSVL_ROVOL]   = "RO",
+       [AFSVL_BACKVOL] = "BK",
+};
+
 /*
- * initialise /proc/fs/afs/<cell>/
+ * Display the list of volumes known to a cell.
  */
-int afs_proc_cell_setup(struct afs_net *net, struct afs_cell *cell)
+static int afs_proc_cell_volumes_show(struct seq_file *m, void *v)
 {
-       struct proc_dir_entry *dir;
-
-       _enter("%p{%s},%p", cell, cell->name, net->proc_afs);
+       struct afs_cell *cell = PDE_DATA(file_inode(m->file));
+       struct afs_volume *vol = list_entry(v, struct afs_volume, proc_link);
 
-       dir = proc_mkdir(cell->name, net->proc_afs);
-       if (!dir)
-               goto error_dir;
+       /* Display header on line 1 */
+       if (v == &cell->proc_volumes) {
+               seq_puts(m, "USE VID      TY\n");
+               return 0;
+       }
 
-       if (!proc_create_seq_data("vlservers", 0, dir,
-                       &afs_proc_cell_vlservers_ops, cell))
-               goto error_tree;
-       if (!proc_create_seq_data("volumes", 0, dir, &afs_proc_cell_volumes_ops,
-                       cell))
-               goto error_tree;
+       seq_printf(m, "%3d %08x %s\n",
+                  atomic_read(&vol->usage), vol->vid,
+                  afs_vol_types[vol->type]);
 
-       _leave(" = 0");
        return 0;
-
-error_tree:
-       remove_proc_subtree(cell->name, net->proc_afs);
-error_dir:
-       _leave(" = -ENOMEM");
-       return -ENOMEM;
 }
 
-/*
- * remove /proc/fs/afs/<cell>/
- */
-void afs_proc_cell_remove(struct afs_net *net, struct afs_cell *cell)
-{
-       _enter("");
-
-       remove_proc_subtree(cell->name, net->proc_afs);
-
-       _leave("");
-}
-
-/*
- * set up the iterator to start reading from the cells list and return the
- * first item
- */
 static void *afs_proc_cell_volumes_start(struct seq_file *m, loff_t *_pos)
        __acquires(cell->proc_lock)
 {
        struct afs_cell *cell = PDE_DATA(file_inode(m->file));
 
-       _enter("cell=%p pos=%Ld", cell, *_pos);
-
        read_lock(&cell->proc_lock);
        return seq_list_start_head(&cell->proc_volumes, *_pos);
 }
 
-/*
- * move to next cell in cells list
- */
-static void *afs_proc_cell_volumes_next(struct seq_file *p, void *v,
+static void *afs_proc_cell_volumes_next(struct seq_file *m, void *v,
                                        loff_t *_pos)
 {
-       struct afs_cell *cell = PDE_DATA(file_inode(p->file));
+       struct afs_cell *cell = PDE_DATA(file_inode(m->file));
 
-       _enter("cell=%p pos=%Ld", cell, *_pos);
        return seq_list_next(v, &cell->proc_volumes, _pos);
 }
 
-/*
- * clean up after reading from the cells list
- */
-static void afs_proc_cell_volumes_stop(struct seq_file *p, void *v)
+static void afs_proc_cell_volumes_stop(struct seq_file *m, void *v)
        __releases(cell->proc_lock)
 {
-       struct afs_cell *cell = PDE_DATA(file_inode(p->file));
+       struct afs_cell *cell = PDE_DATA(file_inode(m->file));
 
        read_unlock(&cell->proc_lock);
 }
 
-static const char afs_vol_types[3][3] = {
-       [AFSVL_RWVOL]   = "RW",
-       [AFSVL_ROVOL]   = "RO",
-       [AFSVL_BACKVOL] = "BK",
+static const struct seq_operations afs_proc_cell_volumes_ops = {
+       .start  = afs_proc_cell_volumes_start,
+       .next   = afs_proc_cell_volumes_next,
+       .stop   = afs_proc_cell_volumes_stop,
+       .show   = afs_proc_cell_volumes_show,
 };
 
 /*
- * display a header line followed by a load of volume lines
+ * Display the list of Volume Location servers we're using for a cell.
  */
-static int afs_proc_cell_volumes_show(struct seq_file *m, void *v)
+static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)
 {
-       struct afs_cell *cell = PDE_DATA(file_inode(m->file));
-       struct afs_volume *vol = list_entry(v, struct afs_volume, proc_link);
+       struct sockaddr_rxrpc *addr = v;
 
-       /* Display header on line 1 */
-       if (v == &cell->proc_volumes) {
-               seq_puts(m, "USE VID      TY\n");
+       /* display header on line 1 */
+       if (v == (void *)1) {
+               seq_puts(m, "ADDRESS\n");
                return 0;
        }
 
-       seq_printf(m, "%3d %08x %s\n",
-                  atomic_read(&vol->usage), vol->vid,
-                  afs_vol_types[vol->type]);
-
+       /* display one cell per line on subsequent lines */
+       seq_printf(m, "%pISp\n", &addr->transport);
        return 0;
 }
 
-/*
- * set up the iterator to start reading from the cells list and return the
- * first item
- */
 static void *afs_proc_cell_vlservers_start(struct seq_file *m, loff_t *_pos)
        __acquires(rcu)
 {
@@ -516,14 +289,11 @@ static void *afs_proc_cell_vlservers_start(struct seq_file *m, loff_t *_pos)
        return alist->addrs + pos;
 }
 
-/*
- * move to next cell in cells list
- */
-static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
+static void *afs_proc_cell_vlservers_next(struct seq_file *m, void *v,
                                          loff_t *_pos)
 {
        struct afs_addr_list *alist;
-       struct afs_cell *cell = PDE_DATA(file_inode(p->file));
+       struct afs_cell *cell = PDE_DATA(file_inode(m->file));
        loff_t pos;
 
        alist = rcu_dereference(cell->vl_addrs);
@@ -536,161 +306,145 @@ static void *afs_proc_cell_vlservers_next(struct seq_file *p, void *v,
        return alist->addrs + pos;
 }
 
-/*
- * clean up after reading from the cells list
- */
-static void afs_proc_cell_vlservers_stop(struct seq_file *p, void *v)
+static void afs_proc_cell_vlservers_stop(struct seq_file *m, void *v)
        __releases(rcu)
 {
        rcu_read_unlock();
 }
 
+static const struct seq_operations afs_proc_cell_vlservers_ops = {
+       .start  = afs_proc_cell_vlservers_start,
+       .next   = afs_proc_cell_vlservers_next,
+       .stop   = afs_proc_cell_vlservers_stop,
+       .show   = afs_proc_cell_vlservers_show,
+};
+
 /*
- * display a header line followed by a load of volume lines
+ * Display the list of fileservers we're using within a namespace.
  */
-static int afs_proc_cell_vlservers_show(struct seq_file *m, void *v)
+static int afs_proc_servers_show(struct seq_file *m, void *v)
 {
-       struct sockaddr_rxrpc *addr = v;
+       struct afs_server *server;
+       struct afs_addr_list *alist;
+       int i;
 
-       /* display header on line 1 */
-       if (v == (void *)1) {
-               seq_puts(m, "ADDRESS\n");
+       if (v == SEQ_START_TOKEN) {
+               seq_puts(m, "UUID                                 USE ADDR\n");
                return 0;
        }
 
-       /* display one cell per line on subsequent lines */
-       seq_printf(m, "%pISp\n", &addr->transport);
+       server = list_entry(v, struct afs_server, proc_link);
+       alist = rcu_dereference(server->addresses);
+       seq_printf(m, "%pU %3d %pISpc%s\n",
+                  &server->uuid,
+                  atomic_read(&server->usage),
+                  &alist->addrs[0].transport,
+                  alist->index == 0 ? "*" : "");
+       for (i = 1; i < alist->nr_addrs; i++)
+               seq_printf(m, "                                         %pISpc%s\n",
+                          &alist->addrs[i].transport,
+                          alist->index == i ? "*" : "");
        return 0;
 }
 
-/*
- * Set up the iterator to start reading from the server list and return the
- * first item.
- */
 static void *afs_proc_servers_start(struct seq_file *m, loff_t *_pos)
        __acquires(rcu)
 {
-       struct afs_net *net = afs_seq2net(m);
-
        rcu_read_lock();
-       return seq_hlist_start_head_rcu(&net->fs_proc, *_pos);
+       return seq_hlist_start_head_rcu(&afs_seq2net(m)->fs_proc, *_pos);
 }
 
-/*
- * move to next cell in cells list
- */
 static void *afs_proc_servers_next(struct seq_file *m, void *v, loff_t *_pos)
 {
-       struct afs_net *net = afs_seq2net(m);
-
-       return seq_hlist_next_rcu(v, &net->fs_proc, _pos);
+       return seq_hlist_next_rcu(v, &afs_seq2net(m)->fs_proc, _pos);
 }
 
-/*
- * clean up after reading from the cells list
- */
-static void afs_proc_servers_stop(struct seq_file *p, void *v)
+static void afs_proc_servers_stop(struct seq_file *m, void *v)
        __releases(rcu)
 {
        rcu_read_unlock();
 }
 
+static const struct seq_operations afs_proc_servers_ops = {
+       .start  = afs_proc_servers_start,
+       .next   = afs_proc_servers_next,
+       .stop   = afs_proc_servers_stop,
+       .show   = afs_proc_servers_show,
+};
+
 /*
- * display a header line followed by a load of volume lines
+ * Display the list of strings that may be substituted for the @sys pathname
+ * macro.
  */
-static int afs_proc_servers_show(struct seq_file *m, void *v)
+static int afs_proc_sysname_show(struct seq_file *m, void *v)
 {
-       struct afs_server *server;
-       struct afs_addr_list *alist;
-
-       if (v == SEQ_START_TOKEN) {
-               seq_puts(m, "UUID                                 USE ADDR\n");
-               return 0;
-       }
+       struct afs_net *net = afs_seq2net(m);
+       struct afs_sysnames *sysnames = net->sysnames;
+       unsigned int i = (unsigned long)v - 1;
 
-       server = list_entry(v, struct afs_server, proc_link);
-       alist = rcu_dereference(server->addresses);
-       seq_printf(m, "%pU %3d %pISp\n",
-                  &server->uuid,
-                  atomic_read(&server->usage),
-                  &alist->addrs[alist->index].transport);
+       if (i < sysnames->nr)
+               seq_printf(m, "%s\n", sysnames->subs[i]);
        return 0;
 }
 
-void afs_put_sysnames(struct afs_sysnames *sysnames)
+static void *afs_proc_sysname_start(struct seq_file *m, loff_t *pos)
+       __acquires(&net->sysnames_lock)
 {
-       int i;
+       struct afs_net *net = afs_seq2net(m);
+       struct afs_sysnames *names;
 
-       if (sysnames && refcount_dec_and_test(&sysnames->usage)) {
-               for (i = 0; i < sysnames->nr; i++)
-                       if (sysnames->subs[i] != afs_init_sysname &&
-                           sysnames->subs[i] != sysnames->blank)
-                               kfree(sysnames->subs[i]);
-       }
+       read_lock(&net->sysnames_lock);
+
+       names = net->sysnames;
+       if (*pos >= names->nr)
+               return NULL;
+       return (void *)(unsigned long)(*pos + 1);
 }
 
-/*
- * Handle opening of /proc/fs/afs/sysname.  If it is opened for writing, we
- * assume the caller wants to change the substitution list and we allocate a
- * buffer to hold the list.
- */
-static int afs_proc_sysname_open(struct inode *inode, struct file *file)
+static void *afs_proc_sysname_next(struct seq_file *m, void *v, loff_t *pos)
 {
-       struct afs_sysnames *sysnames;
-       struct seq_file *m;
-       int ret;
-
-       ret = seq_open(file, &afs_proc_sysname_ops);
-       if (ret < 0)
-               return ret;
+       struct afs_net *net = afs_seq2net(m);
+       struct afs_sysnames *names = net->sysnames;
 
-       if (file->f_mode & FMODE_WRITE) {
-               sysnames = kzalloc(sizeof(*sysnames), GFP_KERNEL);
-               if (!sysnames) {
-                       seq_release(inode, file);
-                       return -ENOMEM;
-               }
+       *pos += 1;
+       if (*pos >= names->nr)
+               return NULL;
+       return (void *)(unsigned long)(*pos + 1);
+}
 
-               refcount_set(&sysnames->usage, 1);
-               m = file->private_data;
-               m->private = sysnames;
-       }
+static void afs_proc_sysname_stop(struct seq_file *m, void *v)
+       __releases(&net->sysnames_lock)
+{
+       struct afs_net *net = afs_seq2net(m);
 
-       return 0;
+       read_unlock(&net->sysnames_lock);
 }
 
+static const struct seq_operations afs_proc_sysname_ops = {
+       .start  = afs_proc_sysname_start,
+       .next   = afs_proc_sysname_next,
+       .stop   = afs_proc_sysname_stop,
+       .show   = afs_proc_sysname_show,
+};
+
 /*
- * Handle writes to /proc/fs/afs/sysname to set the @sys substitution.
+ * Allow the @sys substitution to be configured.
  */
-static ssize_t afs_proc_sysname_write(struct file *file,
-                                     const char __user *buf,
-                                     size_t size, loff_t *_pos)
+static int afs_proc_sysname_write(struct file *file, char *buf, size_t size)
 {
-       struct afs_sysnames *sysnames;
+       struct afs_sysnames *sysnames, *kill;
        struct seq_file *m = file->private_data;
-       char *kbuf = NULL, *s, *p, *sub;
+       struct afs_net *net = afs_seq2net(m);
+       char *s, *p, *sub;
        int ret, len;
 
-       sysnames = m->private;
+       sysnames = kzalloc(sizeof(*sysnames), GFP_KERNEL);
        if (!sysnames)
-               return -EINVAL;
-       if (sysnames->error)
-               return sysnames->error;
-
-       if (size >= PAGE_SIZE - 1) {
-               sysnames->error = -EINVAL;
-               return -EINVAL;
-       }
-       if (size == 0)
-               return 0;
-
-       kbuf = memdup_user_nul(buf, size);
-       if (IS_ERR(kbuf))
-               return PTR_ERR(kbuf);
-
-       inode_lock(file_inode(file));
+               return -ENOMEM;
+       refcount_set(&sysnames->usage, 1);
+       kill = sysnames;
 
-       p = kbuf;
+       p = buf;
        while ((s = strsep(&p, " \t\n"))) {
                len = strlen(s);
                if (len == 0)
@@ -731,85 +485,36 @@ static ssize_t afs_proc_sysname_write(struct file *file,
                sysnames->nr++;
        }
 
-       ret = size;     /* consume everything, always */
+       if (sysnames->nr == 0) {
+               sysnames->subs[0] = sysnames->blank;
+               sysnames->nr++;
+       }
+
+       write_lock(&net->sysnames_lock);
+       kill = net->sysnames;
+       net->sysnames = sysnames;
+       write_unlock(&net->sysnames_lock);
+       ret = 0;
 out:
-       inode_unlock(file_inode(file));
-       kfree(kbuf);
+       afs_put_sysnames(kill);
        return ret;
 
 invalid:
        ret = -EINVAL;
 error:
-       sysnames->error = ret;
        goto out;
 }
 
-static int afs_proc_sysname_release(struct inode *inode, struct file *file)
+void afs_put_sysnames(struct afs_sysnames *sysnames)
 {
-       struct afs_sysnames *sysnames, *kill = NULL;
-       struct seq_file *m = file->private_data;
-       struct afs_net *net = afs_seq2net(m);
+       int i;
 
-       sysnames = m->private;
-       if (sysnames) {
-               if (!sysnames->error) {
-                       kill = sysnames;
-                       if (sysnames->nr == 0) {
-                               sysnames->subs[0] = sysnames->blank;
-                               sysnames->nr++;
-                       }
-                       write_lock(&net->sysnames_lock);
-                       kill = net->sysnames;
-                       net->sysnames = sysnames;
-                       write_unlock(&net->sysnames_lock);
-               }
-               afs_put_sysnames(kill);
+       if (sysnames && refcount_dec_and_test(&sysnames->usage)) {
+               for (i = 0; i < sysnames->nr; i++)
+                       if (sysnames->subs[i] != afs_init_sysname &&
+                           sysnames->subs[i] != sysnames->blank)
+                               kfree(sysnames->subs[i]);
        }
-
-       return seq_release(inode, file);
-}
-
-static void *afs_proc_sysname_start(struct seq_file *m, loff_t *pos)
-       __acquires(&net->sysnames_lock)
-{
-       struct afs_net *net = afs_seq2net(m);
-       struct afs_sysnames *names = net->sysnames;
-
-       read_lock(&net->sysnames_lock);
-
-       if (*pos >= names->nr)
-               return NULL;
-       return (void *)(unsigned long)(*pos + 1);
-}
-
-static void *afs_proc_sysname_next(struct seq_file *m, void *v, loff_t *pos)
-{
-       struct afs_net *net = afs_seq2net(m);
-       struct afs_sysnames *names = net->sysnames;
-
-       *pos += 1;
-       if (*pos >= names->nr)
-               return NULL;
-       return (void *)(unsigned long)(*pos + 1);
-}
-
-static void afs_proc_sysname_stop(struct seq_file *m, void *v)
-       __releases(&net->sysnames_lock)
-{
-       struct afs_net *net = afs_seq2net(m);
-
-       read_unlock(&net->sysnames_lock);
-}
-
-static int afs_proc_sysname_show(struct seq_file *m, void *v)
-{
-       struct afs_net *net = afs_seq2net(m);
-       struct afs_sysnames *sysnames = net->sysnames;
-       unsigned int i = (unsigned long)v - 1;
-
-       if (i < sysnames->nr)
-               seq_printf(m, "%s\n", sysnames->subs[i]);
-       return 0;
 }
 
 /*
@@ -817,7 +522,7 @@ static int afs_proc_sysname_show(struct seq_file *m, void *v)
  */
 static int afs_proc_stats_show(struct seq_file *m, void *v)
 {
-       struct afs_net *net = afs_seq2net(m);
+       struct afs_net *net = afs_seq2net_single(m);
 
        seq_puts(m, "kAFS statistics\n");
 
@@ -842,3 +547,101 @@ static int afs_proc_stats_show(struct seq_file *m, void *v)
                   atomic_long_read(&net->n_store_bytes));
        return 0;
 }
+
+/*
+ * initialise /proc/fs/afs/<cell>/
+ */
+int afs_proc_cell_setup(struct afs_cell *cell)
+{
+       struct proc_dir_entry *dir;
+       struct afs_net *net = cell->net;
+
+       _enter("%p{%s},%p", cell, cell->name, net->proc_afs);
+
+       dir = proc_net_mkdir(net->net, cell->name, net->proc_afs);
+       if (!dir)
+               goto error_dir;
+
+       if (!proc_create_net_data("vlservers", 0444, dir,
+                                 &afs_proc_cell_vlservers_ops,
+                                 sizeof(struct seq_net_private),
+                                 cell) ||
+           !proc_create_net_data("volumes", 0444, dir,
+                                 &afs_proc_cell_volumes_ops,
+                                 sizeof(struct seq_net_private),
+                                 cell))
+               goto error_tree;
+
+       _leave(" = 0");
+       return 0;
+
+error_tree:
+       remove_proc_subtree(cell->name, net->proc_afs);
+error_dir:
+       _leave(" = -ENOMEM");
+       return -ENOMEM;
+}
+
+/*
+ * remove /proc/fs/afs/<cell>/
+ */
+void afs_proc_cell_remove(struct afs_cell *cell)
+{
+       struct afs_net *net = cell->net;
+
+       _enter("");
+       remove_proc_subtree(cell->name, net->proc_afs);
+       _leave("");
+}
+
+/*
+ * initialise the /proc/fs/afs/ directory
+ */
+int afs_proc_init(struct afs_net *net)
+{
+       struct proc_dir_entry *p;
+
+       _enter("");
+
+       p = proc_net_mkdir(net->net, "afs", net->net->proc_net);
+       if (!p)
+               goto error_dir;
+
+       if (!proc_create_net_data_write("cells", 0644, p,
+                                       &afs_proc_cells_ops,
+                                       afs_proc_cells_write,
+                                       sizeof(struct seq_net_private),
+                                       NULL) ||
+           !proc_create_net_single_write("rootcell", 0644, p,
+                                         afs_proc_rootcell_show,
+                                         afs_proc_rootcell_write,
+                                         NULL) ||
+           !proc_create_net("servers", 0444, p, &afs_proc_servers_ops,
+                            sizeof(struct seq_net_private)) ||
+           !proc_create_net_single("stats", 0444, p, afs_proc_stats_show, NULL) ||
+           !proc_create_net_data_write("sysname", 0644, p,
+                                       &afs_proc_sysname_ops,
+                                       afs_proc_sysname_write,
+                                       sizeof(struct seq_net_private),
+                                       NULL))
+               goto error_tree;
+
+       net->proc_afs = p;
+       _leave(" = 0");
+       return 0;
+
+error_tree:
+       proc_remove(p);
+error_dir:
+       _leave(" = -ENOMEM");
+       return -ENOMEM;
+}
+
+/*
+ * clean up the /proc/fs/afs/ directory
+ */
+void afs_proc_cleanup(struct afs_net *net)
+{
+       proc_remove(net->proc_afs);
+       net->proc_afs = NULL;
+}
index 08735948f15d4caec78be59d5e1c4623591e92d4..a1b18082991b2088711a2bca42f173fa951e49e8 100644 (file)
@@ -46,7 +46,7 @@ int afs_open_socket(struct afs_net *net)
 
        _enter("");
 
-       ret = sock_create_kern(&init_net, AF_RXRPC, SOCK_DGRAM, PF_INET6, &socket);
+       ret = sock_create_kern(net->net, AF_RXRPC, SOCK_DGRAM, PF_INET6, &socket);
        if (ret < 0)
                goto error_1;
 
index 3af4625e2f8cc7049185048a602826c53a169c03..1d329e6981d515c06bb5b711a1e3880226c2cce8 100644 (file)
@@ -228,7 +228,7 @@ static struct afs_server *afs_alloc_server(struct afs_net *net,
        server->flags = (1UL << AFS_SERVER_FL_NEW);
        server->update_at = ktime_get_real_seconds() + afs_server_update_delay;
        rwlock_init(&server->fs_lock);
-       INIT_LIST_HEAD(&server->cb_interests);
+       INIT_HLIST_HEAD(&server->cb_volumes);
        rwlock_init(&server->cb_break_lock);
 
        afs_inc_servers_outstanding(net);
index 9e5d7966621c4abaa5cdc51f278a1a05a7e6afac..4d3e274207fb7aa05aa320b957a03911984cf67d 100644 (file)
@@ -48,6 +48,8 @@ struct file_system_type afs_fs_type = {
 };
 MODULE_ALIAS_FS("afs");
 
+int afs_net_id;
+
 static const struct super_operations afs_super_ops = {
        .statfs         = afs_statfs,
        .alloc_inode    = afs_alloc_inode,
@@ -117,7 +119,7 @@ int __init afs_fs_init(void)
 /*
  * clean up the filesystem
  */
-void __exit afs_fs_exit(void)
+void afs_fs_exit(void)
 {
        _enter("");
 
@@ -351,14 +353,19 @@ static int afs_test_super(struct super_block *sb, void *data)
        struct afs_super_info *as1 = data;
        struct afs_super_info *as = AFS_FS_S(sb);
 
-       return (as->net == as1->net &&
+       return (as->net_ns == as1->net_ns &&
                as->volume &&
-               as->volume->vid == as1->volume->vid);
+               as->volume->vid == as1->volume->vid &&
+               !as->dyn_root);
 }
 
 static int afs_dynroot_test_super(struct super_block *sb, void *data)
 {
-       return false;
+       struct afs_super_info *as1 = data;
+       struct afs_super_info *as = AFS_FS_S(sb);
+
+       return (as->net_ns == as1->net_ns &&
+               as->dyn_root);
 }
 
 static int afs_set_super(struct super_block *sb, void *data)
@@ -418,10 +425,14 @@ static int afs_fill_super(struct super_block *sb,
        if (!sb->s_root)
                goto error;
 
-       if (params->dyn_root)
+       if (as->dyn_root) {
                sb->s_d_op = &afs_dynroot_dentry_operations;
-       else
+               ret = afs_dynroot_populate(sb);
+               if (ret < 0)
+                       goto error;
+       } else {
                sb->s_d_op = &afs_fs_dentry_operations;
+       }
 
        _leave(" = 0");
        return 0;
@@ -437,7 +448,7 @@ static struct afs_super_info *afs_alloc_sbi(struct afs_mount_params *params)
 
        as = kzalloc(sizeof(struct afs_super_info), GFP_KERNEL);
        if (as) {
-               as->net = afs_get_net(params->net);
+               as->net_ns = get_net(params->net_ns);
                if (params->dyn_root)
                        as->dyn_root = true;
                else
@@ -450,12 +461,31 @@ static void afs_destroy_sbi(struct afs_super_info *as)
 {
        if (as) {
                afs_put_volume(as->cell, as->volume);
-               afs_put_cell(as->net, as->cell);
-               afs_put_net(as->net);
+               afs_put_cell(afs_net(as->net_ns), as->cell);
+               put_net(as->net_ns);
                kfree(as);
        }
 }
 
+static void afs_kill_super(struct super_block *sb)
+{
+       struct afs_super_info *as = AFS_FS_S(sb);
+       struct afs_net *net = afs_net(as->net_ns);
+
+       if (as->dyn_root)
+               afs_dynroot_depopulate(sb);
+       
+       /* Clear the callback interests (which will do ilookup5) before
+        * deactivating the superblock.
+        */
+       if (as->volume)
+               afs_clear_callback_interests(net, as->volume->servers);
+       kill_anon_super(sb);
+       if (as->volume)
+               afs_deactivate_volume(as->volume);
+       afs_destroy_sbi(as);
+}
+
 /*
  * get an AFS superblock
  */
@@ -472,12 +502,13 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
        _enter(",,%s,%p", dev_name, options);
 
        memset(&params, 0, sizeof(params));
-       params.net = &__afs_net;
 
        ret = -EINVAL;
        if (current->nsproxy->net_ns != &init_net)
                goto error;
-
+       params.net_ns = current->nsproxy->net_ns;
+       params.net = afs_net(params.net_ns);
+       
        /* parse the options and device name */
        if (options) {
                ret = afs_parse_options(&params, options, &dev_name);
@@ -563,21 +594,6 @@ static struct dentry *afs_mount(struct file_system_type *fs_type,
        return ERR_PTR(ret);
 }
 
-static void afs_kill_super(struct super_block *sb)
-{
-       struct afs_super_info *as = AFS_FS_S(sb);
-
-       /* Clear the callback interests (which will do ilookup5) before
-        * deactivating the superblock.
-        */
-       if (as->volume)
-               afs_clear_callback_interests(as->net, as->volume->servers);
-       kill_anon_super(sb);
-       if (as->volume)
-               afs_deactivate_volume(as->volume);
-       afs_destroy_sbi(as);
-}
-
 /*
  * Initialise an inode cache slab element prior to any use.  Note that
  * afs_alloc_inode() *must* reset anything that could incorrectly leak from one
index 134e5b635d643da8868b477a0990e5d3cdb4077e..e1d20124ec0e8698a1e8a5940537ff45f2e57d2c 100644 (file)
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -1661,7 +1661,7 @@ static int aio_poll_wake(struct wait_queue_entry *wait, unsigned mode, int sync,
        if (mask && !(mask & req->events))
                return 0;
 
-       mask = file->f_op->poll_mask(file, req->events);
+       mask = file->f_op->poll_mask(file, req->events) & req->events;
        if (!mask)
                return 0;
 
@@ -1719,7 +1719,7 @@ static ssize_t aio_poll(struct aio_kiocb *aiocb, struct iocb *iocb)
 
        spin_lock_irq(&ctx->ctx_lock);
        spin_lock(&req->head->lock);
-       mask = req->file->f_op->poll_mask(req->file, req->events);
+       mask = req->file->f_op->poll_mask(req->file, req->events) & req->events;
        if (!mask) {
                __add_wait_queue(req->head, &req->wait);
                list_add_tail(&aiocb->ki_list, &ctx->active_reqs);
index d0b4d34878fbab70059b364ae6eb0d7c3a118abe..e3d53bf1224008858c7cd95c620b8a0eca0f8a48 100644 (file)
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -183,14 +183,14 @@ void setattr_copy(struct inode *inode, const struct iattr *attr)
        if (ia_valid & ATTR_GID)
                inode->i_gid = attr->ia_gid;
        if (ia_valid & ATTR_ATIME)
-               inode->i_atime = timespec_trunc(attr->ia_atime,
-                                               inode->i_sb->s_time_gran);
+               inode->i_atime = timespec64_trunc(attr->ia_atime,
+                                                 inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_MTIME)
-               inode->i_mtime = timespec_trunc(attr->ia_mtime,
-                                               inode->i_sb->s_time_gran);
+               inode->i_mtime = timespec64_trunc(attr->ia_mtime,
+                                                 inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_CTIME)
-               inode->i_ctime = timespec_trunc(attr->ia_ctime,
-                                               inode->i_sb->s_time_gran);
+               inode->i_ctime = timespec64_trunc(attr->ia_ctime,
+                                                 inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_MODE) {
                umode_t mode = attr->ia_mode;
 
@@ -227,7 +227,7 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de
        struct inode *inode = dentry->d_inode;
        umode_t mode = inode->i_mode;
        int error;
-       struct timespec now;
+       struct timespec64 now;
        unsigned int ia_valid = attr->ia_valid;
 
        WARN_ON_ONCE(!inode_is_locked(inode));
index 6a2064eb3b272ca0633586fdd57083cc10a4e689..eaebcd430cc3d40489f5ed13c74ce34fc436f5d1 100644 (file)
@@ -1,3 +1,14 @@
+config AUTOFS4_FS
+       tristate "Old Kconfig name for Kernel automounter support"
+       select AUTOFS_FS
+       help
+          This name exists for people to just automatically pick up the
+          new name of the autofs Kconfig option. All it does is select
+          the new option name.
+
+          It will go away in a release or two as people have
+          transitioned to just plain AUTOFS_FS.
+
 config AUTOFS_FS
        tristate "Kernel automounter support (supports v3, v4 and v5)"
        default n
index 16fb61315843da2ea4ca8064ea4eadddde391b88..cc9447e1903f7a16d023067c0098c4123e764351 100644 (file)
@@ -23,6 +23,7 @@ static struct file_system_type autofs_fs_type = {
        .kill_sb        = autofs_kill_sb,
 };
 MODULE_ALIAS_FS("autofs");
+MODULE_ALIAS("autofs4");
 
 static int __init init_autofs_fs(void)
 {
diff --git a/fs/autofs4/Kconfig b/fs/autofs4/Kconfig
deleted file mode 100644 (file)
index 99fda4d..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-config AUTOFS4_FS
-       tristate "Kernel automounter version 4 support (also supports v3 and v5)"
-       default n
-       depends on AUTOFS_FS = n
-       help
-         The automounter is a tool to automatically mount remote file systems
-         on demand. This implementation is partially kernel-based to reduce
-         overhead in the already-mounted case; this is unlike the BSD
-         automounter (amd), which is a pure user space daemon.
-
-         To use the automounter you need the user-space tools from
-         <https://www.kernel.org/pub/linux/daemons/autofs/>; you also want
-         to answer Y to "NFS file system support", below.
-
-         This module is in the process of being renamed from autofs4 to
-         autofs. Since autofs is now the only module that provides the
-         autofs file system the module is not version 4 specific.
-
-         The autofs4 module is now built from the source located in
-         fs/autofs. The autofs4 directory and its configuration entry
-         will be removed two kernel versions from the inclusion of this
-         change.
-
-         Changes that will need to be made should be limited to:
-         - source include statments should be changed from autofs_fs4.h to
-           autofs_fs.h since these two header files have been merged.
-         - user space scripts that manually load autofs4.ko should be
-           changed to load autofs.ko. But since the module directory name
-           and the module name are the same as the file system name there
-           is no need to manually load module.
-         - any "alias autofs autofs4" will need to be removed.
-         - due to the autofs4 module directory name not being the same as
-           its file system name autoloading didn't work properly. Because
-           of this kernel configurations would often build the module into
-           the kernel. This may have resulted in selinux policies that will
-           prevent the autofs module from autoloading and will need to be
-           updated.
-
-         Please configure AUTOFS_FS instead of AUTOFS4_FS from now on.
-
-         NOTE: Since the modules autofs and autofs4 use the same file system
-               type name of "autofs" only one can be built. The "depends"
-               above will result in AUTOFS4_FS not appearing in .config for
-               any setting of AUTOFS_FS other than n and AUTOFS4_FS will
-               appear under the AUTOFS_FS entry otherwise which is intended
-               to draw attention to the module rename change.
diff --git a/fs/autofs4/Makefile b/fs/autofs4/Makefile
deleted file mode 100644 (file)
index 417dd72..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Makefile for the linux autofs-filesystem routines.
-#
-
-obj-$(CONFIG_AUTOFS4_FS) += autofs4.o
-
-autofs4-objs := ../autofs/init.o ../autofs/inode.o ../autofs/root.o \
-       ../autofs/symlink.o ../autofs/waitq.o ../autofs/expire.o \
-       ../autofs/dev-ioctl.o
index 213b51dbbb607251d0f5c131843cc6af68ce3f6d..125e8bbd22a250e3ea1c7710f29f942f7eaef150 100644 (file)
@@ -126,7 +126,7 @@ static int bad_inode_fiemap(struct inode *inode,
        return -EIO;
 }
 
-static int bad_inode_update_time(struct inode *inode, struct timespec *time,
+static int bad_inode_update_time(struct inode *inode, struct timespec64 *time,
                                 int flags)
 {
        return -EIO;
index 16f2dfe8c2f742e4264bf60bc96562d5a6e8292d..aff7eec8f327f3bd16f8685ed1eaf8c40dc59465 100644 (file)
@@ -389,7 +389,7 @@ Version 0.4 (2001-10-28)
        (fs/nls/Config.in)
 
 * Added Configure.help entries for CONFIG_BEFS_FS and CONFIG_DEBUG_BEFS
-       (Documentation/Configure.help)
+       (currently at fs/befs/Kconfig)
 
 2001-08-??
 ==========
index 4ad6f669fe34b21ec592cdd25b7b284fb0f74398..0ac456b52bddb62e9c817d61bccc886c7c8cde85 100644 (file)
@@ -1621,8 +1621,8 @@ static int fill_files_note(struct memelfnote *note)
        if (size >= MAX_FILE_NOTE_SIZE) /* paranoia check */
                return -EINVAL;
        size = round_up(size, PAGE_SIZE);
-       data = vmalloc(size);
-       if (!data)
+       data = kvmalloc(size, GFP_KERNEL);
+       if (ZERO_OR_NULL_PTR(data))
                return -ENOMEM;
 
        start_end_ofs = data + 2;
@@ -1639,7 +1639,7 @@ static int fill_files_note(struct memelfnote *note)
                filename = file_path(file, name_curpos, remaining);
                if (IS_ERR(filename)) {
                        if (PTR_ERR(filename) == -ENAMETOOLONG) {
-                               vfree(data);
+                               kvfree(data);
                                size = size * 5 / 4;
                                goto alloc;
                        }
@@ -1932,7 +1932,7 @@ static void free_note_info(struct elf_note_info *info)
                kfree(t);
        }
        kfree(info->psinfo.data);
-       vfree(info->files.data);
+       kvfree(info->files.data);
 }
 
 #else
@@ -2010,7 +2010,7 @@ static int elf_note_info_init(struct elf_note_info *info)
        INIT_LIST_HEAD(&info->thread_list);
 
        /* Allocate space for ELF notes */
-       info->notes = kmalloc(8 * sizeof(struct memelfnote), GFP_KERNEL);
+       info->notes = kmalloc_array(8, sizeof(struct memelfnote), GFP_KERNEL);
        if (!info->notes)
                return 0;
        info->psinfo = kmalloc(sizeof(*info->psinfo), GFP_KERNEL);
@@ -2148,7 +2148,7 @@ static void free_note_info(struct elf_note_info *info)
 
        /* Free data possibly allocated by fill_files_note(): */
        if (info->notes_files)
-               vfree(info->notes_files->data);
+               kvfree(info->notes_files->data);
 
        kfree(info->prstatus);
        kfree(info->psinfo);
@@ -2294,8 +2294,9 @@ static int elf_core_dump(struct coredump_params *cprm)
 
        if (segs - 1 > ULONG_MAX / sizeof(*vma_filesz))
                goto end_coredump;
-       vma_filesz = vmalloc((segs - 1) * sizeof(*vma_filesz));
-       if (!vma_filesz)
+       vma_filesz = kvmalloc(array_size(sizeof(*vma_filesz), (segs - 1)),
+                             GFP_KERNEL);
+       if (ZERO_OR_NULL_PTR(vma_filesz))
                goto end_coredump;
 
        for (i = 0, vma = first_vma(current, gate_vma); vma != NULL;
@@ -2402,7 +2403,7 @@ static int elf_core_dump(struct coredump_params *cprm)
 cleanup:
        free_note_info(&info);
        kfree(shdr4extnum);
-       vfree(vma_filesz);
+       kvfree(vma_filesz);
        kfree(phdr4note);
        kfree(elf);
 out:
index d90993adeffa3d19186bcb50aeb85110bf971a7f..b53bb3729ac1ef91e7105cea04b7a27d1e4553f8 100644 (file)
@@ -1600,7 +1600,8 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm)
        psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
        if (!psinfo)
                goto cleanup;
-       notes = kmalloc(NUM_NOTES * sizeof(struct memelfnote), GFP_KERNEL);
+       notes = kmalloc_array(NUM_NOTES, sizeof(struct memelfnote),
+                             GFP_KERNEL);
        if (!notes)
                goto cleanup;
        fpu = kmalloc(sizeof(*fpu), GFP_KERNEL);
index 4de1915632611a5b4ebb99f74e996a07d13c8e03..4b5fff31ef279eb739a37ccba610eaf7a6a98787 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (C) 1997 Richard Günther
  *
  * binfmt_misc detects binaries via a magic or filename extension and invokes
- * a specified wrapper. See Documentation/binfmt_misc.txt for more details.
+ * a specified wrapper. See Documentation/admin-guide/binfmt-misc.rst for more details.
  */
 
 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
index 05e12aea24043dac01826bcc833be0e9e8c2e13b..0dd87aaeb39a7d05bbec28ce01536b106c4f76c2 100644 (file)
@@ -205,7 +205,8 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter,
        if (nr_pages <= DIO_INLINE_BIO_VECS)
                vecs = inline_vecs;
        else {
-               vecs = kmalloc(nr_pages * sizeof(struct bio_vec), GFP_KERNEL);
+               vecs = kmalloc_array(nr_pages, sizeof(struct bio_vec),
+                                    GFP_KERNEL);
                if (!vecs)
                        return -ENOMEM;
        }
index dc062b195c4654820e484fe25ce4ac722a836415..a3fdb4fe967d29cc87a4e2402d7898ddeb3b5670 100644 (file)
@@ -1603,8 +1603,8 @@ static int btrfsic_read_block(struct btrfsic_state *state,
 
        num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >>
                    PAGE_SHIFT;
-       block_ctx->mem_to_free = kzalloc((sizeof(*block_ctx->datav) +
-                                         sizeof(*block_ctx->pagev)) *
+       block_ctx->mem_to_free = kcalloc(sizeof(*block_ctx->datav) +
+                                               sizeof(*block_ctx->pagev),
                                         num_pages, GFP_NOFS);
        if (!block_ctx->mem_to_free)
                return -ENOMEM;
index f4bf7874c24a4d63609a30a966d14f9db0a323e0..118346aceea9607ff98410df2764614f24f4505d 100644 (file)
@@ -3197,7 +3197,7 @@ int btrfs_merge_bio_hook(struct page *page, unsigned long offset,
                         size_t size, struct bio *bio,
                         unsigned long bio_flags);
 void btrfs_set_range_writeback(void *private_data, u64 start, u64 end);
-int btrfs_page_mkwrite(struct vm_fault *vmf);
+vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf);
 int btrfs_readpage(struct file *file, struct page *page);
 void btrfs_evict_inode(struct inode *inode);
 int btrfs_write_inode(struct inode *inode, struct writeback_control *wbc);
index 51fc015c7d2c69bd198e94c3ffc4b2ef267f7ef2..cce6087d6880fa4c1673dbc8aab0026fc62391f4 100644 (file)
@@ -4542,7 +4542,7 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                        offset_in_extent = em_start - em->start;
                em_end = extent_map_end(em);
                em_len = em_end - em_start;
-               disko = 0;
+               disko = em->block_start + offset_in_extent;
                flags = 0;
 
                /*
@@ -4565,8 +4565,6 @@ int extent_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                        u64 bytenr = em->block_start -
                                (em->start - em->orig_start);
 
-                       disko = em->block_start + offset_in_extent;
-
                        /*
                         * As btrfs supports shared space, this information
                         * can be exported to userspace tools via
index f660ba1e5e58ef30f5c72555d7408b686e507e0e..51e77d72068af0ba3f9ffdfd624409c00d51978e 100644 (file)
@@ -1842,16 +1842,16 @@ static ssize_t __btrfs_direct_write(struct kiocb *iocb, struct iov_iter *from)
 
 static void update_time_for_write(struct inode *inode)
 {
-       struct timespec now;
+       struct timespec64 now;
 
        if (IS_NOCMTIME(inode))
                return;
 
        now = current_time(inode);
-       if (!timespec_equal(&inode->i_mtime, &now))
+       if (!timespec64_equal(&inode->i_mtime, &now))
                inode->i_mtime = now;
 
-       if (!timespec_equal(&inode->i_ctime, &now))
+       if (!timespec64_equal(&inode->i_ctime, &now))
                inode->i_ctime = now;
 
        if (IS_I_VERSION(inode))
index 89b2082017830942e040063a2ca000d1a10f75df..e9482f0db9d08ffd79a117f0d6f08b6eb94cae99 100644 (file)
@@ -5745,7 +5745,7 @@ static struct inode *new_simple_dir(struct super_block *s,
        inode->i_mtime = current_time(inode);
        inode->i_atime = inode->i_mtime;
        inode->i_ctime = inode->i_mtime;
-       BTRFS_I(inode)->i_otime = inode->i_mtime;
+       BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime);
 
        return inode;
 }
@@ -6094,7 +6094,7 @@ static int btrfs_dirty_inode(struct inode *inode)
  * This is a copy of file_update_time.  We need this so we can return error on
  * ENOSPC for updating the inode in the case of file write and mmap writes.
  */
-static int btrfs_update_time(struct inode *inode, struct timespec *now,
+static int btrfs_update_time(struct inode *inode, struct timespec64 *now,
                             int flags)
 {
        struct btrfs_root *root = BTRFS_I(inode)->root;
@@ -6349,7 +6349,7 @@ static struct inode *btrfs_new_inode(struct btrfs_trans_handle *trans,
        inode->i_mtime = current_time(inode);
        inode->i_atime = inode->i_mtime;
        inode->i_ctime = inode->i_mtime;
-       BTRFS_I(inode)->i_otime = inode->i_mtime;
+       BTRFS_I(inode)->i_otime = timespec64_to_timespec(inode->i_mtime);
 
        inode_item = btrfs_item_ptr(path->nodes[0], path->slots[0],
                                  struct btrfs_inode_item);
@@ -8872,7 +8872,7 @@ static void btrfs_invalidatepage(struct page *page, unsigned int offset,
  * beyond EOF, then the page is guaranteed safe against truncation until we
  * unlock the page.
  */
-int btrfs_page_mkwrite(struct vm_fault *vmf)
+vm_fault_t btrfs_page_mkwrite(struct vm_fault *vmf)
 {
        struct page *page = vmf->page;
        struct inode *inode = file_inode(vmf->vma->vm_file);
@@ -8884,7 +8884,8 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)
        char *kaddr;
        unsigned long zero_start;
        loff_t size;
-       int ret;
+       vm_fault_t ret;
+       int ret2;
        int reserved = 0;
        u64 reserved_space;
        u64 page_start;
@@ -8906,17 +8907,14 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)
         * end up waiting indefinitely to get a lock on the page currently
         * being processed by btrfs_page_mkwrite() function.
         */
-       ret = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start,
+       ret2 = btrfs_delalloc_reserve_space(inode, &data_reserved, page_start,
                                           reserved_space);
-       if (!ret) {
-               ret = file_update_time(vmf->vma->vm_file);
+       if (!ret2) {
+               ret2 = file_update_time(vmf->vma->vm_file);
                reserved = 1;
        }
-       if (ret) {
-               if (ret == -ENOMEM)
-                       ret = VM_FAULT_OOM;
-               else /* -ENOSPC, -EIO, etc */
-                       ret = VM_FAULT_SIGBUS;
+       if (ret2) {
+               ret = vmf_error(ret2);
                if (reserved)
                        goto out;
                goto out_noreserve;
@@ -8975,15 +8973,15 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)
                          EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
                          0, 0, &cached_state);
 
-       ret = btrfs_set_extent_delalloc(inode, page_start, end, 0,
+       ret2 = btrfs_set_extent_delalloc(inode, page_start, end, 0,
                                        &cached_state, 0);
-       if (ret) {
+       if (ret2) {
                unlock_extent_cached(io_tree, page_start, page_end,
                                     &cached_state);
                ret = VM_FAULT_SIGBUS;
                goto out_unlock;
        }
-       ret = 0;
+       ret2 = 0;
 
        /* page is wholly or partially inside EOF */
        if (page_start + PAGE_SIZE > size)
@@ -9008,7 +9006,7 @@ int btrfs_page_mkwrite(struct vm_fault *vmf)
        unlock_extent_cached(io_tree, page_start, page_end, &cached_state);
 
 out_unlock:
-       if (!ret) {
+       if (!ret2) {
                btrfs_delalloc_release_extents(BTRFS_I(inode), PAGE_SIZE, true);
                sb_end_pagefault(inode->i_sb);
                extent_changeset_free(data_reserved);
@@ -9437,7 +9435,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
        struct btrfs_root *dest = BTRFS_I(new_dir)->root;
        struct inode *new_inode = new_dentry->d_inode;
        struct inode *old_inode = old_dentry->d_inode;
-       struct timespec ctime = current_time(old_inode);
+       struct timespec64 ctime = current_time(old_inode);
        struct dentry *parent;
        u64 old_ino = btrfs_ino(BTRFS_I(old_inode));
        u64 new_ino = btrfs_ino(BTRFS_I(new_inode));
index d29992f7dc6356b2de853f5dde76cebedc3e30d0..c2837a32d689de9a7d5d3bfc96d7d861cd221dfb 100644 (file)
@@ -562,7 +562,7 @@ static noinline int create_subvol(struct inode *dir,
        struct btrfs_root *root = BTRFS_I(dir)->root;
        struct btrfs_root *new_root;
        struct btrfs_block_rsv block_rsv;
-       struct timespec cur_time = current_time(dir);
+       struct timespec64 cur_time = current_time(dir);
        struct inode *inode;
        int ret;
        int err;
@@ -2438,6 +2438,10 @@ static int btrfs_search_path_in_tree_user(struct inode *inode,
                        }
 
                        temp_inode = btrfs_iget(sb, &key2, root, NULL);
+                       if (IS_ERR(temp_inode)) {
+                               ret = PTR_ERR(temp_inode);
+                               goto out;
+                       }
                        ret = inode_permission(temp_inode, MAY_READ | MAY_EXEC);
                        iput(temp_inode);
                        if (ret) {
@@ -5391,7 +5395,7 @@ static long _btrfs_ioctl_set_received_subvol(struct file *file,
        struct btrfs_root *root = BTRFS_I(inode)->root;
        struct btrfs_root_item *root_item = &root->root_item;
        struct btrfs_trans_handle *trans;
-       struct timespec ct = current_time(inode);
+       struct timespec64 ct = current_time(inode);
        int ret = 0;
        int received_uuid_changed;
 
index 6db3bda44aa55f4be73c554d9f4fc961dc290841..c451285976acbf0dd91202dfe9644eeb03e4ef53 100644 (file)
@@ -485,9 +485,9 @@ void btrfs_update_root_times(struct btrfs_trans_handle *trans,
                             struct btrfs_root *root)
 {
        struct btrfs_root_item *item = &root->root_item;
-       struct timespec ct;
+       struct timespec64 ct;
 
-       ktime_get_real_ts(&ct);
+       ktime_get_real_ts64(&ct);
        spin_lock(&root->root_item_lock);
        btrfs_set_root_ctransid(item, trans->transid);
        btrfs_set_stack_timespec_sec(&item->ctime, ct.tv_sec);
index a5900586201056f0c7429a35ad1b2255c917f40a..5723060364776d1fd3e3e1e09bdfc09d4bb7eadb 100644 (file)
@@ -2799,7 +2799,7 @@ static int scrub_extent(struct scrub_ctx *sctx, struct map_lookup *map,
                        have_csum = scrub_find_csum(sctx, logical, csum);
                        if (have_csum == 0)
                                ++sctx->stat.no_csum;
-                       if (sctx->is_dev_replace && !have_csum) {
+                       if (0 && sctx->is_dev_replace && !have_csum) {
                                ret = copy_nocow_pages(sctx, logical, l,
                                                       mirror_num,
                                                      physical_for_dev_replace);
index 4485eae41e88ad7a487c5bb2e8aa58f950cf7e36..ff5f6c719976699429599d780d71feec2868aa8f 100644 (file)
@@ -1422,7 +1422,7 @@ static noinline int create_pending_snapshot(struct btrfs_trans_handle *trans,
        struct dentry *dentry;
        struct extent_buffer *tmp;
        struct extent_buffer *old;
-       struct timespec cur_time;
+       struct timespec64 cur_time;
        int ret = 0;
        u64 to_reserve = 0;
        u64 index = 0;
index 5f7ad3d0df2ea69121acded120e26d05515fd79a..292b3d72d72505579d3b642083e57983927ee1bc 100644 (file)
@@ -370,7 +370,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx,
 
        /* build page vector */
        nr_pages = calc_pages_for(0, len);
-       pages = kmalloc(sizeof(*pages) * nr_pages, GFP_KERNEL);
+       pages = kmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL);
        if (!pages) {
                ret = -ENOMEM;
                goto out_put;
@@ -574,6 +574,7 @@ static u64 get_writepages_data_length(struct inode *inode,
  */
 static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
 {
+       struct timespec ts;
        struct inode *inode;
        struct ceph_inode_info *ci;
        struct ceph_fs_client *fsc;
@@ -624,11 +625,12 @@ static int writepage_nounlock(struct page *page, struct writeback_control *wbc)
                set_bdi_congested(inode_to_bdi(inode), BLK_RW_ASYNC);
 
        set_page_writeback(page);
+       ts = timespec64_to_timespec(inode->i_mtime);
        err = ceph_osdc_writepages(&fsc->client->osdc, ceph_vino(inode),
                                   &ci->i_layout, snapc, page_off, len,
                                   ceph_wbc.truncate_seq,
                                   ceph_wbc.truncate_size,
-                                  &inode->i_mtime, &page, 1);
+                                  &ts, &page, 1);
        if (err < 0) {
                struct writeback_control tmp_wbc;
                if (!wbc)
@@ -966,8 +968,9 @@ static int ceph_writepages_start(struct address_space *mapping,
 
                                BUG_ON(pages);
                                max_pages = calc_pages_for(0, (u64)len);
-                               pages = kmalloc(max_pages * sizeof (*pages),
-                                               GFP_NOFS);
+                               pages = kmalloc_array(max_pages,
+                                                     sizeof(*pages),
+                                                     GFP_NOFS);
                                if (!pages) {
                                        pool = fsc->wb_pagevec_pool;
                                        pages = mempool_alloc(pool, GFP_NOFS);
@@ -1113,8 +1116,8 @@ static int ceph_writepages_start(struct address_space *mapping,
 
                        /* allocate new pages array for next request */
                        data_pages = pages;
-                       pages = kmalloc(locked_pages * sizeof (*pages),
-                                       GFP_NOFS);
+                       pages = kmalloc_array(locked_pages, sizeof(*pages),
+                                             GFP_NOFS);
                        if (!pages) {
                                pool = fsc->wb_pagevec_pool;
                                pages = mempool_alloc(pool, GFP_NOFS);
@@ -1131,7 +1134,7 @@ static int ceph_writepages_start(struct address_space *mapping,
                        pages = NULL;
                }
 
-               req->r_mtime = inode->i_mtime;
+               req->r_mtime = timespec64_to_timespec(inode->i_mtime);
                rc = ceph_osdc_start_request(&fsc->client->osdc, req, true);
                BUG_ON(rc);
                req = NULL;
@@ -1731,7 +1734,7 @@ int ceph_uninline_data(struct file *filp, struct page *locked_page)
                goto out;
        }
 
-       req->r_mtime = inode->i_mtime;
+       req->r_mtime = timespec64_to_timespec(inode->i_mtime);
        err = ceph_osdc_start_request(&fsc->client->osdc, req, false);
        if (!err)
                err = ceph_osdc_wait_request(&fsc->client->osdc, req);
@@ -1773,7 +1776,7 @@ int ceph_uninline_data(struct file *filp, struct page *locked_page)
                        goto out_put;
        }
 
-       req->r_mtime = inode->i_mtime;
+       req->r_mtime = timespec64_to_timespec(inode->i_mtime);
        err = ceph_osdc_start_request(&fsc->client->osdc, req, false);
        if (!err)
                err = ceph_osdc_wait_request(&fsc->client->osdc, req);
@@ -1934,8 +1937,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci,
                                     0, false, true);
        err = ceph_osdc_start_request(&fsc->client->osdc, rd_req, false);
 
-       wr_req->r_mtime = ci->vfs_inode.i_mtime;
-       wr_req->r_abort_on_full = true;
+       wr_req->r_mtime = timespec64_to_timespec(ci->vfs_inode.i_mtime);
        err2 = ceph_osdc_start_request(&fsc->client->osdc, wr_req, false);
 
        if (!err)
index bb524c880b1eadf2915a0a551eb01730871dee9a..362900e424245bd7c5714fde340f9b6a286ce6f3 100644 (file)
@@ -130,7 +130,7 @@ static enum fscache_checkaux ceph_fscache_inode_check_aux(
 
        memset(&aux, 0, sizeof(aux));
        aux.version = ci->i_version;
-       aux.mtime = inode->i_mtime;
+       aux.mtime = timespec64_to_timespec(inode->i_mtime);
 
        if (memcmp(data, &aux, sizeof(aux)) != 0)
                return FSCACHE_CHECKAUX_OBSOLETE;
@@ -163,7 +163,7 @@ void ceph_fscache_register_inode_cookie(struct inode *inode)
        if (!ci->fscache) {
                memset(&aux, 0, sizeof(aux));
                aux.version = ci->i_version;
-               aux.mtime = inode->i_mtime;
+               aux.mtime = timespec64_to_timespec(inode->i_mtime);
                ci->fscache = fscache_acquire_cookie(fsc->fscache,
                                                     &ceph_fscache_inode_object_def,
                                                     &ci->i_vino, sizeof(ci->i_vino),
index 23dbfae1615685dde002b8fa4e77ed54f6a01c0e..990258cbd836c810df88bb4949d897fca1b7f043 100644 (file)
@@ -69,6 +69,8 @@ static char *gcap_string(char *s, int c)
                *s++ = 'w';
        if (c & CEPH_CAP_GBUFFER)
                *s++ = 'b';
+       if (c & CEPH_CAP_GWREXTEND)
+               *s++ = 'a';
        if (c & CEPH_CAP_GLAZYIO)
                *s++ = 'l';
        return s;
@@ -1358,9 +1360,9 @@ static int __send_cap(struct ceph_mds_client *mdsc, struct ceph_cap *cap,
                arg.xattr_buf = NULL;
        }
 
-       arg.mtime = inode->i_mtime;
-       arg.atime = inode->i_atime;
-       arg.ctime = inode->i_ctime;
+       arg.mtime = timespec64_to_timespec(inode->i_mtime);
+       arg.atime = timespec64_to_timespec(inode->i_atime);
+       arg.ctime = timespec64_to_timespec(inode->i_ctime);
 
        arg.op = op;
        arg.caps = cap->implemented;
@@ -3022,30 +3024,41 @@ static void invalidate_aliases(struct inode *inode)
                dput(prev);
 }
 
+struct cap_extra_info {
+       struct ceph_string *pool_ns;
+       /* inline data */
+       u64 inline_version;
+       void *inline_data;
+       u32 inline_len;
+       /* dirstat */
+       bool dirstat_valid;
+       u64 nfiles;
+       u64 nsubdirs;
+       /* currently issued */
+       int issued;
+};
+
 /*
  * Handle a cap GRANT message from the MDS.  (Note that a GRANT may
  * actually be a revocation if it specifies a smaller cap set.)
  *
  * caller holds s_mutex and i_ceph_lock, we drop both.
  */
-static void handle_cap_grant(struct ceph_mds_client *mdsc,
-                            struct inode *inode, struct ceph_mds_caps *grant,
-                            struct ceph_string **pns, u64 inline_version,
-                            void *inline_data, u32 inline_len,
-                            struct ceph_buffer *xattr_buf,
+static void handle_cap_grant(struct inode *inode,
                             struct ceph_mds_session *session,
-                            struct ceph_cap *cap, int issued)
+                            struct ceph_cap *cap,
+                            struct ceph_mds_caps *grant,
+                            struct ceph_buffer *xattr_buf,
+                            struct cap_extra_info *extra_info)
        __releases(ci->i_ceph_lock)
-       __releases(mdsc->snap_rwsem)
+       __releases(session->s_mdsc->snap_rwsem)
 {
        struct ceph_inode_info *ci = ceph_inode(inode);
-       int mds = session->s_mds;
        int seq = le32_to_cpu(grant->seq);
        int newcaps = le32_to_cpu(grant->caps);
        int used, wanted, dirty;
        u64 size = le64_to_cpu(grant->size);
        u64 max_size = le64_to_cpu(grant->max_size);
-       struct timespec mtime, atime, ctime;
        int check_caps = 0;
        bool wake = false;
        bool writeback = false;
@@ -3055,7 +3068,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
        bool fill_inline = false;
 
        dout("handle_cap_grant inode %p cap %p mds%d seq %d %s\n",
-            inode, cap, mds, seq, ceph_cap_string(newcaps));
+            inode, cap, session->s_mds, seq, ceph_cap_string(newcaps));
        dout(" size %llu max_size %llu, i_size %llu\n", size, max_size,
                inode->i_size);
 
@@ -3101,7 +3114,7 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
        __check_cap_issue(ci, cap, newcaps);
 
        if ((newcaps & CEPH_CAP_AUTH_SHARED) &&
-           (issued & CEPH_CAP_AUTH_EXCL) == 0) {
+           (extra_info->issued & CEPH_CAP_AUTH_EXCL) == 0) {
                inode->i_mode = le32_to_cpu(grant->mode);
                inode->i_uid = make_kuid(&init_user_ns, le32_to_cpu(grant->uid));
                inode->i_gid = make_kgid(&init_user_ns, le32_to_cpu(grant->gid));
@@ -3110,15 +3123,16 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
                     from_kgid(&init_user_ns, inode->i_gid));
        }
 
-       if ((newcaps & CEPH_CAP_AUTH_SHARED) &&
-           (issued & CEPH_CAP_LINK_EXCL) == 0) {
+       if ((newcaps & CEPH_CAP_LINK_SHARED) &&
+           (extra_info->issued & CEPH_CAP_LINK_EXCL) == 0) {
                set_nlink(inode, le32_to_cpu(grant->nlink));
                if (inode->i_nlink == 0 &&
                    (newcaps & (CEPH_CAP_LINK_SHARED | CEPH_CAP_LINK_EXCL)))
                        deleted_inode = true;
        }
 
-       if ((issued & CEPH_CAP_XATTR_EXCL) == 0 && grant->xattr_len) {
+       if ((extra_info->issued & CEPH_CAP_XATTR_EXCL) == 0 &&
+           grant->xattr_len) {
                int len = le32_to_cpu(grant->xattr_len);
                u64 version = le64_to_cpu(grant->xattr_version);
 
@@ -3134,15 +3148,21 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
        }
 
        if (newcaps & CEPH_CAP_ANY_RD) {
+               struct timespec mtime, atime, ctime;
                /* ctime/mtime/atime? */
                ceph_decode_timespec(&mtime, &grant->mtime);
                ceph_decode_timespec(&atime, &grant->atime);
                ceph_decode_timespec(&ctime, &grant->ctime);
-               ceph_fill_file_time(inode, issued,
+               ceph_fill_file_time(inode, extra_info->issued,
                                    le32_to_cpu(grant->time_warp_seq),
                                    &ctime, &mtime, &atime);
        }
 
+       if ((newcaps & CEPH_CAP_FILE_SHARED) && extra_info->dirstat_valid) {
+               ci->i_files = extra_info->nfiles;
+               ci->i_subdirs = extra_info->nsubdirs;
+       }
+
        if (newcaps & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR)) {
                /* file layout may have changed */
                s64 old_pool = ci->i_layout.pool_id;
@@ -3151,15 +3171,16 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
                ceph_file_layout_from_legacy(&ci->i_layout, &grant->layout);
                old_ns = rcu_dereference_protected(ci->i_layout.pool_ns,
                                        lockdep_is_held(&ci->i_ceph_lock));
-               rcu_assign_pointer(ci->i_layout.pool_ns, *pns);
+               rcu_assign_pointer(ci->i_layout.pool_ns, extra_info->pool_ns);
 
-               if (ci->i_layout.pool_id != old_pool || *pns != old_ns)
+               if (ci->i_layout.pool_id != old_pool ||
+                   extra_info->pool_ns != old_ns)
                        ci->i_ceph_flags &= ~CEPH_I_POOL_PERM;
 
-               *pns = old_ns;
+               extra_info->pool_ns = old_ns;
 
                /* size/truncate_seq? */
-               queue_trunc = ceph_fill_file_size(inode, issued,
+               queue_trunc = ceph_fill_file_size(inode, extra_info->issued,
                                        le32_to_cpu(grant->truncate_seq),
                                        le64_to_cpu(grant->truncate_size),
                                        size);
@@ -3238,24 +3259,26 @@ static void handle_cap_grant(struct ceph_mds_client *mdsc,
        }
        BUG_ON(cap->issued & ~cap->implemented);
 
-       if (inline_version > 0 && inline_version >= ci->i_inline_version) {
-               ci->i_inline_version = inline_version;
+       if (extra_info->inline_version > 0 &&
+           extra_info->inline_version >= ci->i_inline_version) {
+               ci->i_inline_version = extra_info->inline_version;
                if (ci->i_inline_version != CEPH_INLINE_NONE &&
                    (newcaps & (CEPH_CAP_FILE_CACHE|CEPH_CAP_FILE_LAZYIO)))
                        fill_inline = true;
        }
 
        if (le32_to_cpu(grant->op) == CEPH_CAP_OP_IMPORT) {
-               if (newcaps & ~issued)
+               if (newcaps & ~extra_info->issued)
                        wake = true;
-               kick_flushing_inode_caps(mdsc, session, inode);
-               up_read(&mdsc->snap_rwsem);
+               kick_flushing_inode_caps(session->s_mdsc, session, inode);
+               up_read(&session->s_mdsc->snap_rwsem);
        } else {
                spin_unlock(&ci->i_ceph_lock);
        }
 
        if (fill_inline)
-               ceph_fill_inline_data(inode, NULL, inline_data, inline_len);
+               ceph_fill_inline_data(inode, NULL, extra_info->inline_data,
+                                     extra_info->inline_len);
 
        if (queue_trunc)
                ceph_queue_vmtruncate(inode);
@@ -3720,31 +3743,25 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                      struct ceph_msg *msg)
 {
        struct ceph_mds_client *mdsc = session->s_mdsc;
-       struct super_block *sb = mdsc->fsc->sb;
        struct inode *inode;
        struct ceph_inode_info *ci;
        struct ceph_cap *cap;
        struct ceph_mds_caps *h;
        struct ceph_mds_cap_peer *peer = NULL;
        struct ceph_snap_realm *realm = NULL;
-       struct ceph_string *pool_ns = NULL;
-       int mds = session->s_mds;
-       int op, issued;
+       int op;
+       int msg_version = le16_to_cpu(msg->hdr.version);
        u32 seq, mseq;
        struct ceph_vino vino;
-       u64 tid;
-       u64 inline_version = 0;
-       void *inline_data = NULL;
-       u32  inline_len = 0;
        void *snaptrace;
        size_t snaptrace_len;
        void *p, *end;
+       struct cap_extra_info extra_info = {};
 
-       dout("handle_caps from mds%d\n", mds);
+       dout("handle_caps from mds%d\n", session->s_mds);
 
        /* decode */
        end = msg->front.iov_base + msg->front.iov_len;
-       tid = le64_to_cpu(msg->hdr.tid);
        if (msg->front.iov_len < sizeof(*h))
                goto bad;
        h = msg->front.iov_base;
@@ -3758,7 +3775,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
        snaptrace_len = le32_to_cpu(h->snap_trace_len);
        p = snaptrace + snaptrace_len;
 
-       if (le16_to_cpu(msg->hdr.version) >= 2) {
+       if (msg_version >= 2) {
                u32 flock_len;
                ceph_decode_32_safe(&p, end, flock_len, bad);
                if (p + flock_len > end)
@@ -3766,7 +3783,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                p += flock_len;
        }
 
-       if (le16_to_cpu(msg->hdr.version) >= 3) {
+       if (msg_version >= 3) {
                if (op == CEPH_CAP_OP_IMPORT) {
                        if (p + sizeof(*peer) > end)
                                goto bad;
@@ -3778,16 +3795,16 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                }
        }
 
-       if (le16_to_cpu(msg->hdr.version) >= 4) {
-               ceph_decode_64_safe(&p, end, inline_version, bad);
-               ceph_decode_32_safe(&p, end, inline_len, bad);
-               if (p + inline_len > end)
+       if (msg_version >= 4) {
+               ceph_decode_64_safe(&p, end, extra_info.inline_version, bad);
+               ceph_decode_32_safe(&p, end, extra_info.inline_len, bad);
+               if (p + extra_info.inline_len > end)
                        goto bad;
-               inline_data = p;
-               p += inline_len;
+               extra_info.inline_data = p;
+               p += extra_info.inline_len;
        }
 
-       if (le16_to_cpu(msg->hdr.version) >= 5) {
+       if (msg_version >= 5) {
                struct ceph_osd_client  *osdc = &mdsc->fsc->client->osdc;
                u32                     epoch_barrier;
 
@@ -3795,7 +3812,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                ceph_osdc_update_epoch_barrier(osdc, epoch_barrier);
        }
 
-       if (le16_to_cpu(msg->hdr.version) >= 8) {
+       if (msg_version >= 8) {
                u64 flush_tid;
                u32 caller_uid, caller_gid;
                u32 pool_ns_len;
@@ -3809,13 +3826,33 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                ceph_decode_32_safe(&p, end, pool_ns_len, bad);
                if (pool_ns_len > 0) {
                        ceph_decode_need(&p, end, pool_ns_len, bad);
-                       pool_ns = ceph_find_or_create_string(p, pool_ns_len);
+                       extra_info.pool_ns =
+                               ceph_find_or_create_string(p, pool_ns_len);
                        p += pool_ns_len;
                }
        }
 
+       if (msg_version >= 11) {
+               struct ceph_timespec *btime;
+               u64 change_attr;
+               u32 flags;
+
+               /* version >= 9 */
+               if (p + sizeof(*btime) > end)
+                       goto bad;
+               btime = p;
+               p += sizeof(*btime);
+               ceph_decode_64_safe(&p, end, change_attr, bad);
+               /* version >= 10 */
+               ceph_decode_32_safe(&p, end, flags, bad);
+               /* version >= 11 */
+               extra_info.dirstat_valid = true;
+               ceph_decode_64_safe(&p, end, extra_info.nfiles, bad);
+               ceph_decode_64_safe(&p, end, extra_info.nsubdirs, bad);
+       }
+
        /* lookup ino */
-       inode = ceph_find_inode(sb, vino);
+       inode = ceph_find_inode(mdsc->fsc->sb, vino);
        ci = ceph_inode(inode);
        dout(" op %s ino %llx.%llx inode %p\n", ceph_cap_op_name(op), vino.ino,
             vino.snap, inode);
@@ -3848,7 +3885,8 @@ void ceph_handle_caps(struct ceph_mds_session *session,
        /* these will work even if we don't have a cap yet */
        switch (op) {
        case CEPH_CAP_OP_FLUSHSNAP_ACK:
-               handle_cap_flushsnap_ack(inode, tid, h, session);
+               handle_cap_flushsnap_ack(inode, le64_to_cpu(msg->hdr.tid),
+                                        h, session);
                goto done;
 
        case CEPH_CAP_OP_EXPORT:
@@ -3867,10 +3905,9 @@ void ceph_handle_caps(struct ceph_mds_session *session,
                        down_read(&mdsc->snap_rwsem);
                }
                handle_cap_import(mdsc, inode, h, peer, session,
-                                 &cap, &issued);
-               handle_cap_grant(mdsc, inode, h, &pool_ns,
-                                inline_version, inline_data, inline_len,
-                                msg->middle, session, cap, issued);
+                                 &cap, &extra_info.issued);
+               handle_cap_grant(inode, session, cap,
+                                h, msg->middle, &extra_info);
                if (realm)
                        ceph_put_snap_realm(mdsc, realm);
                goto done_unlocked;
@@ -3878,10 +3915,11 @@ void ceph_handle_caps(struct ceph_mds_session *session,
 
        /* the rest require a cap */
        spin_lock(&ci->i_ceph_lock);
-       cap = __get_cap_for_mds(ceph_inode(inode), mds);
+       cap = __get_cap_for_mds(ceph_inode(inode), session->s_mds);
        if (!cap) {
                dout(" no cap on %p ino %llx.%llx from mds%d\n",
-                    inode, ceph_ino(inode), ceph_snap(inode), mds);
+                    inode, ceph_ino(inode), ceph_snap(inode),
+                    session->s_mds);
                spin_unlock(&ci->i_ceph_lock);
                goto flush_cap_releases;
        }
@@ -3890,15 +3928,15 @@ void ceph_handle_caps(struct ceph_mds_session *session,
        switch (op) {
        case CEPH_CAP_OP_REVOKE:
        case CEPH_CAP_OP_GRANT:
-               __ceph_caps_issued(ci, &issued);
-               issued |= __ceph_caps_dirty(ci);
-               handle_cap_grant(mdsc, inode, h, &pool_ns,
-                                inline_version, inline_data, inline_len,
-                                msg->middle, session, cap, issued);
+               __ceph_caps_issued(ci, &extra_info.issued);
+               extra_info.issued |= __ceph_caps_dirty(ci);
+               handle_cap_grant(inode, session, cap,
+                                h, msg->middle, &extra_info);
                goto done_unlocked;
 
        case CEPH_CAP_OP_FLUSH_ACK:
-               handle_cap_flush_ack(inode, tid, h, session, cap);
+               handle_cap_flush_ack(inode, le64_to_cpu(msg->hdr.tid),
+                                    h, session, cap);
                break;
 
        case CEPH_CAP_OP_TRUNC:
@@ -3925,7 +3963,7 @@ void ceph_handle_caps(struct ceph_mds_session *session,
        mutex_unlock(&session->s_mutex);
 done_unlocked:
        iput(inode);
-       ceph_put_string(pool_ns);
+       ceph_put_string(extra_info.pool_ns);
        return;
 
 bad:
index 1a78dd6f8bf27655b03161de2617f7fc57f8f1b7..036ac0f3a393afe98278cd388de4e68b7e4b286c 100644 (file)
@@ -1486,6 +1486,8 @@ const struct file_operations ceph_dir_fops = {
        .release = ceph_release,
        .unlocked_ioctl = ceph_ioctl,
        .fsync = ceph_fsync,
+       .lock = ceph_lock,
+       .flock = ceph_flock,
 };
 
 const struct file_operations ceph_snapdir_fops = {
index cf0e45b10121aa8323ca7d6a86a109d6f8675c08..ad0bed99b1d5ab0c61922ae561cab24d2e9d4933 100644 (file)
@@ -895,7 +895,6 @@ static void ceph_aio_retry_work(struct work_struct *work)
        req->r_callback = ceph_aio_complete_req;
        req->r_inode = inode;
        req->r_priv = aio_req;
-       req->r_abort_on_full = true;
 
        ret = ceph_osdc_start_request(req->r_osdc, req, false);
 out:
@@ -924,7 +923,7 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter,
        int num_pages = 0;
        int flags;
        int ret;
-       struct timespec mtime = current_time(inode);
+       struct timespec mtime = timespec64_to_timespec(current_time(inode));
        size_t count = iov_iter_count(iter);
        loff_t pos = iocb->ki_pos;
        bool write = iov_iter_rw(iter) == WRITE;
@@ -1132,7 +1131,7 @@ ceph_sync_write(struct kiocb *iocb, struct iov_iter *from, loff_t pos,
        int flags;
        int ret;
        bool check_caps = false;
-       struct timespec mtime = current_time(inode);
+       struct timespec mtime = timespec64_to_timespec(current_time(inode));
        size_t count = iov_iter_count(from);
 
        if (ceph_snap(file_inode(file)) != CEPH_NOSNAP)
@@ -1664,7 +1663,7 @@ static int ceph_zero_partial_object(struct inode *inode,
                goto out;
        }
 
-       req->r_mtime = inode->i_mtime;
+       req->r_mtime = timespec64_to_timespec(inode->i_mtime);
        ret = ceph_osdc_start_request(&fsc->client->osdc, req, false);
        if (!ret) {
                ret = ceph_osdc_wait_request(&fsc->client->osdc, req);
index ae056927080d28cf3eff14697ded16acdf33f38d..ee764ac352ab7b855165b797c1daf579fbaa45e1 100644 (file)
@@ -662,6 +662,9 @@ void ceph_fill_file_time(struct inode *inode, int issued,
                         struct timespec *mtime, struct timespec *atime)
 {
        struct ceph_inode_info *ci = ceph_inode(inode);
+       struct timespec64 ctime64 = timespec_to_timespec64(*ctime);
+       struct timespec64 mtime64 = timespec_to_timespec64(*mtime);
+       struct timespec64 atime64 = timespec_to_timespec64(*atime);
        int warn = 0;
 
        if (issued & (CEPH_CAP_FILE_EXCL|
@@ -670,39 +673,39 @@ void ceph_fill_file_time(struct inode *inode, int issued,
                      CEPH_CAP_AUTH_EXCL|
                      CEPH_CAP_XATTR_EXCL)) {
                if (ci->i_version == 0 ||
-                   timespec_compare(ctime, &inode->i_ctime) > 0) {
-                       dout("ctime %ld.%09ld -> %ld.%09ld inc w/ cap\n",
-                            inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
-                            ctime->tv_sec, ctime->tv_nsec);
-                       inode->i_ctime = *ctime;
+                   timespec64_compare(&ctime64, &inode->i_ctime) > 0) {
+                       dout("ctime %lld.%09ld -> %lld.%09ld inc w/ cap\n",
+                            (long long)inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
+                            (long long)ctime->tv_sec, ctime->tv_nsec);
+                       inode->i_ctime = ctime64;
                }
                if (ci->i_version == 0 ||
                    ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) > 0) {
                        /* the MDS did a utimes() */
-                       dout("mtime %ld.%09ld -> %ld.%09ld "
+                       dout("mtime %lld.%09ld -> %lld.%09ld "
                             "tw %d -> %d\n",
-                            inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
-                            mtime->tv_sec, mtime->tv_nsec,
+                            (long long)inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
+                            (long long)mtime->tv_sec, mtime->tv_nsec,
                             ci->i_time_warp_seq, (int)time_warp_seq);
 
-                       inode->i_mtime = *mtime;
-                       inode->i_atime = *atime;
+                       inode->i_mtime = mtime64;
+                       inode->i_atime = atime64;
                        ci->i_time_warp_seq = time_warp_seq;
                } else if (time_warp_seq == ci->i_time_warp_seq) {
                        /* nobody did utimes(); take the max */
-                       if (timespec_compare(mtime, &inode->i_mtime) > 0) {
-                               dout("mtime %ld.%09ld -> %ld.%09ld inc\n",
-                                    inode->i_mtime.tv_sec,
+                       if (timespec64_compare(&mtime64, &inode->i_mtime) > 0) {
+                               dout("mtime %lld.%09ld -> %lld.%09ld inc\n",
+                                    (long long)inode->i_mtime.tv_sec,
                                     inode->i_mtime.tv_nsec,
-                                    mtime->tv_sec, mtime->tv_nsec);
-                               inode->i_mtime = *mtime;
+                                    (long long)mtime->tv_sec, mtime->tv_nsec);
+                               inode->i_mtime = mtime64;
                        }
-                       if (timespec_compare(atime, &inode->i_atime) > 0) {
-                               dout("atime %ld.%09ld -> %ld.%09ld inc\n",
-                                    inode->i_atime.tv_sec,
+                       if (timespec64_compare(&atime64, &inode->i_atime) > 0) {
+                               dout("atime %lld.%09ld -> %lld.%09ld inc\n",
+                                    (long long)inode->i_atime.tv_sec,
                                     inode->i_atime.tv_nsec,
-                                    atime->tv_sec, atime->tv_nsec);
-                               inode->i_atime = *atime;
+                                    (long long)atime->tv_sec, atime->tv_nsec);
+                               inode->i_atime = atime64;
                        }
                } else if (issued & CEPH_CAP_FILE_EXCL) {
                        /* we did a utimes(); ignore mds values */
@@ -712,9 +715,9 @@ void ceph_fill_file_time(struct inode *inode, int issued,
        } else {
                /* we have no write|excl caps; whatever the MDS says is true */
                if (ceph_seq_cmp(time_warp_seq, ci->i_time_warp_seq) >= 0) {
-                       inode->i_ctime = *ctime;
-                       inode->i_mtime = *mtime;
-                       inode->i_atime = *atime;
+                       inode->i_ctime = ctime64;
+                       inode->i_mtime = mtime64;
+                       inode->i_atime = atime64;
                        ci->i_time_warp_seq = time_warp_seq;
                } else {
                        warn = 1;
@@ -739,7 +742,7 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
        struct ceph_mds_client *mdsc = ceph_inode_to_client(inode)->mdsc;
        struct ceph_mds_reply_inode *info = iinfo->in;
        struct ceph_inode_info *ci = ceph_inode(inode);
-       int issued = 0, implemented, new_issued;
+       int issued, new_issued, info_caps;
        struct timespec mtime, atime, ctime;
        struct ceph_buffer *xattr_blob = NULL;
        struct ceph_string *pool_ns = NULL;
@@ -754,8 +757,10 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
             inode, ceph_vinop(inode), le64_to_cpu(info->version),
             ci->i_version);
 
+       info_caps = le32_to_cpu(info->cap.caps);
+
        /* prealloc new cap struct */
-       if (info->cap.caps && ceph_snap(inode) == CEPH_NOSNAP)
+       if (info_caps && ceph_snap(inode) == CEPH_NOSNAP)
                new_cap = ceph_get_cap(mdsc, caps_reservation);
 
        /*
@@ -792,9 +797,9 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
             le64_to_cpu(info->version) > (ci->i_version & ~1)))
                new_version = true;
 
-       issued = __ceph_caps_issued(ci, &implemented);
-       issued |= implemented | __ceph_caps_dirty(ci);
-       new_issued = ~issued & le32_to_cpu(info->cap.caps);
+       __ceph_caps_issued(ci, &issued);
+       issued |= __ceph_caps_dirty(ci);
+       new_issued = ~issued & info_caps;
 
        /* update inode */
        inode->i_rdev = le32_to_cpu(info->rdev);
@@ -826,6 +831,11 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
                                &ctime, &mtime, &atime);
        }
 
+       if (new_version || (info_caps & CEPH_CAP_FILE_SHARED)) {
+               ci->i_files = le64_to_cpu(info->files);
+               ci->i_subdirs = le64_to_cpu(info->subdirs);
+       }
+
        if (new_version ||
            (new_issued & (CEPH_CAP_ANY_FILE_RD | CEPH_CAP_ANY_FILE_WR))) {
                s64 old_pool = ci->i_layout.pool_id;
@@ -854,6 +864,18 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
                }
        }
 
+       /* layout and rstat are not tracked by capability, update them if
+        * the inode info is from auth mds */
+       if (new_version || (info->cap.flags & CEPH_CAP_FLAG_AUTH)) {
+               if (S_ISDIR(inode->i_mode)) {
+                       ci->i_dir_layout = iinfo->dir_layout;
+                       ci->i_rbytes = le64_to_cpu(info->rbytes);
+                       ci->i_rfiles = le64_to_cpu(info->rfiles);
+                       ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
+                       ceph_decode_timespec(&ci->i_rctime, &info->rctime);
+               }
+       }
+
        /* xattrs */
        /* note that if i_xattrs.len <= 4, i_xattrs.data will still be NULL. */
        if ((ci->i_xattrs.version == 0 || !(issued & CEPH_CAP_XATTR_EXCL))  &&
@@ -870,7 +892,8 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
        }
 
        /* finally update i_version */
-       ci->i_version = le64_to_cpu(info->version);
+       if (le64_to_cpu(info->version) > ci->i_version)
+               ci->i_version = le64_to_cpu(info->version);
 
        inode->i_mapping->a_ops = &ceph_aops;
 
@@ -918,15 +941,6 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
        case S_IFDIR:
                inode->i_op = &ceph_dir_iops;
                inode->i_fop = &ceph_dir_fops;
-
-               ci->i_dir_layout = iinfo->dir_layout;
-
-               ci->i_files = le64_to_cpu(info->files);
-               ci->i_subdirs = le64_to_cpu(info->subdirs);
-               ci->i_rbytes = le64_to_cpu(info->rbytes);
-               ci->i_rfiles = le64_to_cpu(info->rfiles);
-               ci->i_rsubdirs = le64_to_cpu(info->rsubdirs);
-               ceph_decode_timespec(&ci->i_rctime, &info->rctime);
                break;
        default:
                pr_err("fill_inode %llx.%llx BAD mode 0%o\n",
@@ -934,12 +948,11 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
        }
 
        /* were we issued a capability? */
-       if (info->cap.caps) {
+       if (info_caps) {
                if (ceph_snap(inode) == CEPH_NOSNAP) {
-                       unsigned caps = le32_to_cpu(info->cap.caps);
                        ceph_add_cap(inode, session,
                                     le64_to_cpu(info->cap.cap_id),
-                                    cap_fmode, caps,
+                                    cap_fmode, info_caps,
                                     le32_to_cpu(info->cap.wanted),
                                     le32_to_cpu(info->cap.seq),
                                     le32_to_cpu(info->cap.mseq),
@@ -949,7 +962,7 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
                        /* set dir completion flag? */
                        if (S_ISDIR(inode->i_mode) &&
                            ci->i_files == 0 && ci->i_subdirs == 0 &&
-                           (caps & CEPH_CAP_FILE_SHARED) &&
+                           (info_caps & CEPH_CAP_FILE_SHARED) &&
                            (issued & CEPH_CAP_FILE_EXCL) == 0 &&
                            !__ceph_dir_is_complete(ci)) {
                                dout(" marking %p complete (empty)\n", inode);
@@ -962,8 +975,8 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
                        wake = true;
                } else {
                        dout(" %p got snap_caps %s\n", inode,
-                            ceph_cap_string(le32_to_cpu(info->cap.caps)));
-                       ci->i_snap_caps |= le32_to_cpu(info->cap.caps);
+                            ceph_cap_string(info_caps));
+                       ci->i_snap_caps |= info_caps;
                        if (cap_fmode >= 0)
                                __ceph_get_fmode(ci, cap_fmode);
                }
@@ -978,8 +991,7 @@ static int fill_inode(struct inode *inode, struct page *locked_page,
                int cache_caps = CEPH_CAP_FILE_CACHE | CEPH_CAP_FILE_LAZYIO;
                ci->i_inline_version = iinfo->inline_version;
                if (ci->i_inline_version != CEPH_INLINE_NONE &&
-                   (locked_page ||
-                    (le32_to_cpu(info->cap.caps) & cache_caps)))
+                   (locked_page || (info_caps & cache_caps)))
                        fill_inline = true;
        }
 
@@ -1941,6 +1953,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
        int err = 0;
        int inode_dirty_flags = 0;
        bool lock_snap_rwsem = false;
+       struct timespec ts;
 
        prealloc_cf = ceph_alloc_cap_flush();
        if (!prealloc_cf)
@@ -2015,44 +2028,44 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
        }
 
        if (ia_valid & ATTR_ATIME) {
-               dout("setattr %p atime %ld.%ld -> %ld.%ld\n", inode,
-                    inode->i_atime.tv_sec, inode->i_atime.tv_nsec,
-                    attr->ia_atime.tv_sec, attr->ia_atime.tv_nsec);
+               dout("setattr %p atime %lld.%ld -> %lld.%ld\n", inode,
+                    (long long)inode->i_atime.tv_sec, inode->i_atime.tv_nsec,
+                    (long long)attr->ia_atime.tv_sec, attr->ia_atime.tv_nsec);
                if (issued & CEPH_CAP_FILE_EXCL) {
                        ci->i_time_warp_seq++;
                        inode->i_atime = attr->ia_atime;
                        dirtied |= CEPH_CAP_FILE_EXCL;
                } else if ((issued & CEPH_CAP_FILE_WR) &&
-                          timespec_compare(&inode->i_atime,
+                          timespec64_compare(&inode->i_atime,
                                            &attr->ia_atime) < 0) {
                        inode->i_atime = attr->ia_atime;
                        dirtied |= CEPH_CAP_FILE_WR;
                } else if ((issued & CEPH_CAP_FILE_SHARED) == 0 ||
-                          !timespec_equal(&inode->i_atime, &attr->ia_atime)) {
-                       ceph_encode_timespec(&req->r_args.setattr.atime,
-                                            &attr->ia_atime);
+                          !timespec64_equal(&inode->i_atime, &attr->ia_atime)) {
+                       ts = timespec64_to_timespec(attr->ia_atime);
+                       ceph_encode_timespec(&req->r_args.setattr.atime, &ts);
                        mask |= CEPH_SETATTR_ATIME;
                        release |= CEPH_CAP_FILE_SHARED |
                                   CEPH_CAP_FILE_RD | CEPH_CAP_FILE_WR;
                }
        }
        if (ia_valid & ATTR_MTIME) {
-               dout("setattr %p mtime %ld.%ld -> %ld.%ld\n", inode,
-                    inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
-                    attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec);
+               dout("setattr %p mtime %lld.%ld -> %lld.%ld\n", inode,
+                    (long long)inode->i_mtime.tv_sec, inode->i_mtime.tv_nsec,
+                    (long long)attr->ia_mtime.tv_sec, attr->ia_mtime.tv_nsec);
                if (issued & CEPH_CAP_FILE_EXCL) {
                        ci->i_time_warp_seq++;
                        inode->i_mtime = attr->ia_mtime;
                        dirtied |= CEPH_CAP_FILE_EXCL;
                } else if ((issued & CEPH_CAP_FILE_WR) &&
-                          timespec_compare(&inode->i_mtime,
+                          timespec64_compare(&inode->i_mtime,
                                            &attr->ia_mtime) < 0) {
                        inode->i_mtime = attr->ia_mtime;
                        dirtied |= CEPH_CAP_FILE_WR;
                } else if ((issued & CEPH_CAP_FILE_SHARED) == 0 ||
-                          !timespec_equal(&inode->i_mtime, &attr->ia_mtime)) {
-                       ceph_encode_timespec(&req->r_args.setattr.mtime,
-                                            &attr->ia_mtime);
+                          !timespec64_equal(&inode->i_mtime, &attr->ia_mtime)) {
+                       ts = timespec64_to_timespec(attr->ia_mtime);
+                       ceph_encode_timespec(&req->r_args.setattr.mtime, &ts);
                        mask |= CEPH_SETATTR_MTIME;
                        release |= CEPH_CAP_FILE_SHARED |
                                   CEPH_CAP_FILE_RD | CEPH_CAP_FILE_WR;
@@ -2082,9 +2095,9 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
        if (ia_valid & ATTR_CTIME) {
                bool only = (ia_valid & (ATTR_SIZE|ATTR_MTIME|ATTR_ATIME|
                                         ATTR_MODE|ATTR_UID|ATTR_GID)) == 0;
-               dout("setattr %p ctime %ld.%ld -> %ld.%ld (%s)\n", inode,
-                    inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
-                    attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec,
+               dout("setattr %p ctime %lld.%ld -> %lld.%ld (%s)\n", inode,
+                    (long long)inode->i_ctime.tv_sec, inode->i_ctime.tv_nsec,
+                    (long long)attr->ia_ctime.tv_sec, attr->ia_ctime.tv_nsec,
                     only ? "ctime only" : "ignored");
                if (only) {
                        /*
@@ -2126,7 +2139,7 @@ int __ceph_setattr(struct inode *inode, struct iattr *attr)
                req->r_inode_drop = release;
                req->r_args.setattr.mask = cpu_to_le32(mask);
                req->r_num_caps = 1;
-               req->r_stamp = attr->ia_ctime;
+               req->r_stamp = timespec64_to_timespec(attr->ia_ctime);
                err = ceph_mdsc_do_request(mdsc, NULL, req);
        }
        dout("setattr %p result=%d (%s locally, %d remote)\n", inode, err,
@@ -2178,6 +2191,7 @@ int __ceph_do_getattr(struct inode *inode, struct page *locked_page,
        struct ceph_fs_client *fsc = ceph_sb_to_client(inode->i_sb);
        struct ceph_mds_client *mdsc = fsc->mdsc;
        struct ceph_mds_request *req;
+       int mode;
        int err;
 
        if (ceph_snap(inode) == CEPH_SNAPDIR) {
@@ -2190,7 +2204,8 @@ int __ceph_do_getattr(struct inode *inode, struct page *locked_page,
        if (!force && ceph_caps_issued_mask(ceph_inode(inode), mask, 1))
                return 0;
 
-       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, USE_ANY_MDS);
+       mode = (mask & CEPH_STAT_RSTAT) ? USE_AUTH_MDS : USE_ANY_MDS;
+       req = ceph_mdsc_create_request(mdsc, CEPH_MDS_OP_GETATTR, mode);
        if (IS_ERR(req))
                return PTR_ERR(req);
        req->r_inode = inode;
@@ -2261,6 +2276,14 @@ int ceph_getattr(const struct path *path, struct kstat *stat,
                                stat->size = ci->i_files + ci->i_subdirs;
                        stat->blocks = 0;
                        stat->blksize = 65536;
+                       /*
+                        * Some applications rely on the number of st_nlink
+                        * value on directories to be either 0 (if unlinked)
+                        * or 2 + number of subdirectories.
+                        */
+                       if (stat->nlink == 1)
+                               /* '.' + '..' + subdirs */
+                               stat->nlink = 1 + 1 + ci->i_subdirs;
                }
        }
        return err;
index 5ece2e6ad1548e0893ee9734132a64bb66ffc89e..dc8bc664a8716a5c946c70efa2dc5911cfb32962 100644 (file)
@@ -2958,12 +2958,15 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap,
                rec.v2.flock_len = (__force __le32)
                        ((ci->i_ceph_flags & CEPH_I_ERROR_FILELOCK) ? 0 : 1);
        } else {
+               struct timespec ts;
                rec.v1.cap_id = cpu_to_le64(cap->cap_id);
                rec.v1.wanted = cpu_to_le32(__ceph_caps_wanted(ci));
                rec.v1.issued = cpu_to_le32(cap->issued);
                rec.v1.size = cpu_to_le64(inode->i_size);
-               ceph_encode_timespec(&rec.v1.mtime, &inode->i_mtime);
-               ceph_encode_timespec(&rec.v1.atime, &inode->i_atime);
+               ts = timespec64_to_timespec(inode->i_mtime);
+               ceph_encode_timespec(&rec.v1.mtime, &ts);
+               ts = timespec64_to_timespec(inode->i_atime);
+               ceph_encode_timespec(&rec.v1.atime, &ts);
                rec.v1.snaprealm = cpu_to_le64(ci->i_snap_realm->ino);
                rec.v1.pathbase = cpu_to_le64(pathbase);
        }
@@ -2992,8 +2995,9 @@ static int encode_caps_cb(struct inode *inode, struct ceph_cap *cap,
                        num_flock_locks = 0;
                }
                if (num_fcntl_locks + num_flock_locks > 0) {
-                       flocks = kmalloc((num_fcntl_locks + num_flock_locks) *
-                                        sizeof(struct ceph_filelock), GFP_NOFS);
+                       flocks = kmalloc_array(num_fcntl_locks + num_flock_locks,
+                                              sizeof(struct ceph_filelock),
+                                              GFP_NOFS);
                        if (!flocks) {
                                err = -ENOMEM;
                                goto out_free;
index 041c27ea8de155a0002bdb5af25eb2fc5f8e6efa..af81555c14fd00a006ee360c95edf7335fc1f1fe 100644 (file)
@@ -594,9 +594,9 @@ int __ceph_finish_cap_snap(struct ceph_inode_info *ci,
 
        BUG_ON(capsnap->writing);
        capsnap->size = inode->i_size;
-       capsnap->mtime = inode->i_mtime;
-       capsnap->atime = inode->i_atime;
-       capsnap->ctime = inode->i_ctime;
+       capsnap->mtime = timespec64_to_timespec(inode->i_mtime);
+       capsnap->atime = timespec64_to_timespec(inode->i_atime);
+       capsnap->ctime = timespec64_to_timespec(inode->i_ctime);
        capsnap->time_warp_seq = ci->i_time_warp_seq;
        capsnap->truncate_size = ci->i_truncate_size;
        capsnap->truncate_seq = ci->i_truncate_seq;
index b33082e6878f1ca1ba8820716dafb1924d77855d..95a3b3ac9b6e251437d978d4fc7d513d2ea59507 100644 (file)
@@ -45,7 +45,7 @@ static void ceph_put_super(struct super_block *s)
 static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
 {
        struct ceph_fs_client *fsc = ceph_inode_to_client(d_inode(dentry));
-       struct ceph_monmap *monmap = fsc->client->monc.monmap;
+       struct ceph_mon_client *monc = &fsc->client->monc;
        struct ceph_statfs st;
        u64 fsid;
        int err;
@@ -58,7 +58,7 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
        }
 
        dout("statfs\n");
-       err = ceph_monc_do_statfs(&fsc->client->monc, data_pool, &st);
+       err = ceph_monc_do_statfs(monc, data_pool, &st);
        if (err < 0)
                return err;
 
@@ -94,8 +94,11 @@ static int ceph_statfs(struct dentry *dentry, struct kstatfs *buf)
        buf->f_namelen = NAME_MAX;
 
        /* Must convert the fsid, for consistent values across arches */
-       fsid = le64_to_cpu(*(__le64 *)(&monmap->fsid)) ^
-              le64_to_cpu(*((__le64 *)&monmap->fsid + 1));
+       mutex_lock(&monc->mutex);
+       fsid = le64_to_cpu(*(__le64 *)(&monc->monmap->fsid)) ^
+              le64_to_cpu(*((__le64 *)&monc->monmap->fsid + 1));
+       mutex_unlock(&monc->mutex);
+
        buf->f_fsid.val[0] = fsid & 0xffffffff;
        buf->f_fsid.val[1] = fsid >> 32;
 
@@ -256,19 +259,19 @@ static int parse_fsopt_token(char *c, void *private)
                break;
                /* misc */
        case Opt_wsize:
-               if (intval < PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)
+               if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_WRITE_SIZE)
                        return -EINVAL;
                fsopt->wsize = ALIGN(intval, PAGE_SIZE);
                break;
        case Opt_rsize:
-               if (intval < PAGE_SIZE || intval > CEPH_MAX_READ_SIZE)
+               if (intval < (int)PAGE_SIZE || intval > CEPH_MAX_READ_SIZE)
                        return -EINVAL;
                fsopt->rsize = ALIGN(intval, PAGE_SIZE);
                break;
        case Opt_rasize:
                if (intval < 0)
                        return -EINVAL;
-               fsopt->rasize = ALIGN(intval + PAGE_SIZE - 1, PAGE_SIZE);
+               fsopt->rasize = ALIGN(intval, PAGE_SIZE);
                break;
        case Opt_caps_wanted_delay_min:
                if (intval < 1)
@@ -286,7 +289,7 @@ static int parse_fsopt_token(char *c, void *private)
                fsopt->max_readdir = intval;
                break;
        case Opt_readdir_max_bytes:
-               if (intval < PAGE_SIZE && intval != 0)
+               if (intval < (int)PAGE_SIZE && intval != 0)
                        return -EINVAL;
                fsopt->max_readdir_bytes = intval;
                break;
@@ -534,6 +537,8 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root)
                seq_puts(m, ",noasyncreaddir");
        if ((fsopt->flags & CEPH_MOUNT_OPT_DCACHE) == 0)
                seq_puts(m, ",nodcache");
+       if (fsopt->flags & CEPH_MOUNT_OPT_INO32)
+               seq_puts(m, ",ino32");
        if (fsopt->flags & CEPH_MOUNT_OPT_FSCACHE) {
                seq_show_option(m, "fsc", fsopt->fscache_uniq);
        }
@@ -551,7 +556,7 @@ static int ceph_show_options(struct seq_file *m, struct dentry *root)
 
        if (fsopt->mds_namespace)
                seq_show_option(m, "mds_namespace", fsopt->mds_namespace);
-       if (fsopt->wsize)
+       if (fsopt->wsize != CEPH_MAX_WRITE_SIZE)
                seq_printf(m, ",wsize=%d", fsopt->wsize);
        if (fsopt->rsize != CEPH_MAX_READ_SIZE)
                seq_printf(m, ",rsize=%d", fsopt->rsize);
@@ -616,7 +621,9 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
                err = PTR_ERR(fsc->client);
                goto fail;
        }
+
        fsc->client->extra_mon_dispatch = extra_mon_dispatch;
+       fsc->client->osdc.abort_on_full = true;
 
        if (!fsopt->mds_namespace) {
                ceph_monc_want_map(&fsc->client->monc, CEPH_SUB_MDSMAP,
@@ -674,6 +681,13 @@ static struct ceph_fs_client *create_fs_client(struct ceph_mount_options *fsopt,
        return ERR_PTR(err);
 }
 
+static void flush_fs_workqueues(struct ceph_fs_client *fsc)
+{
+       flush_workqueue(fsc->wb_wq);
+       flush_workqueue(fsc->pg_inv_wq);
+       flush_workqueue(fsc->trunc_wq);
+}
+
 static void destroy_fs_client(struct ceph_fs_client *fsc)
 {
        dout("destroy_fs_client %p\n", fsc);
@@ -793,6 +807,7 @@ static void ceph_umount_begin(struct super_block *sb)
        if (!fsc)
                return;
        fsc->mount_state = CEPH_MOUNT_SHUTDOWN;
+       ceph_osdc_abort_requests(&fsc->client->osdc, -EIO);
        ceph_mdsc_force_umount(fsc->mdsc);
        return;
 }
@@ -1088,6 +1103,8 @@ static void ceph_kill_sb(struct super_block *s)
        dout("kill_sb %p\n", s);
 
        ceph_mdsc_pre_umount(fsc->mdsc);
+       flush_fs_workqueues(fsc);
+
        generic_shutdown_super(s);
 
        fsc->client->extra_mon_dispatch = NULL;
index 315f7e63e7cca3b64eed882e8dc0c5fefbebe645..5bc8edb4c2a60ce82bfd03ac55b48c7f3003fde3 100644 (file)
@@ -50,10 +50,14 @@ struct ceph_vxattr {
        size_t name_size;       /* strlen(name) + 1 (for '\0') */
        size_t (*getxattr_cb)(struct ceph_inode_info *ci, char *val,
                              size_t size);
-       bool readonly, hidden;
        bool (*exists_cb)(struct ceph_inode_info *ci);
+       unsigned int flags;
 };
 
+#define VXATTR_FLAG_READONLY           (1<<0)
+#define VXATTR_FLAG_HIDDEN             (1<<1)
+#define VXATTR_FLAG_RSTAT              (1<<2)
+
 /* layouts */
 
 static bool ceph_vxattrcb_layout_exists(struct ceph_inode_info *ci)
@@ -262,32 +266,31 @@ static size_t ceph_vxattrcb_quota_max_files(struct ceph_inode_info *ci,
 #define CEPH_XATTR_NAME2(_type, _name, _name2) \
        XATTR_CEPH_PREFIX #_type "." #_name "." #_name2
 
-#define XATTR_NAME_CEPH(_type, _name)                                  \
+#define XATTR_NAME_CEPH(_type, _name, _flags)                          \
        {                                                               \
                .name = CEPH_XATTR_NAME(_type, _name),                  \
                .name_size = sizeof (CEPH_XATTR_NAME(_type, _name)), \
                .getxattr_cb = ceph_vxattrcb_ ## _type ## _ ## _name, \
-               .readonly = true,                               \
-               .hidden = false,                                \
-               .exists_cb = NULL,                      \
+               .exists_cb = NULL,                                      \
+               .flags = (VXATTR_FLAG_READONLY | _flags),               \
        }
+#define XATTR_RSTAT_FIELD(_type, _name)                        \
+       XATTR_NAME_CEPH(_type, _name, VXATTR_FLAG_RSTAT)
 #define XATTR_LAYOUT_FIELD(_type, _name, _field)                       \
        {                                                               \
                .name = CEPH_XATTR_NAME2(_type, _name, _field), \
                .name_size = sizeof (CEPH_XATTR_NAME2(_type, _name, _field)), \
                .getxattr_cb = ceph_vxattrcb_ ## _name ## _ ## _field, \
-               .readonly = false,                              \
-               .hidden = true,                 \
                .exists_cb = ceph_vxattrcb_layout_exists,       \
+               .flags = VXATTR_FLAG_HIDDEN,                    \
        }
 #define XATTR_QUOTA_FIELD(_type, _name)                                        \
        {                                                               \
                .name = CEPH_XATTR_NAME(_type, _name),                  \
                .name_size = sizeof(CEPH_XATTR_NAME(_type, _name)),     \
                .getxattr_cb = ceph_vxattrcb_ ## _type ## _ ## _name,   \
-               .readonly = false,                                      \
-               .hidden = true,                                         \
                .exists_cb = ceph_vxattrcb_quota_exists,                \
+               .flags = VXATTR_FLAG_HIDDEN,                            \
        }
 
 static struct ceph_vxattr ceph_dir_vxattrs[] = {
@@ -295,30 +298,28 @@ static struct ceph_vxattr ceph_dir_vxattrs[] = {
                .name = "ceph.dir.layout",
                .name_size = sizeof("ceph.dir.layout"),
                .getxattr_cb = ceph_vxattrcb_layout,
-               .readonly = false,
-               .hidden = true,
                .exists_cb = ceph_vxattrcb_layout_exists,
+               .flags = VXATTR_FLAG_HIDDEN,
        },
        XATTR_LAYOUT_FIELD(dir, layout, stripe_unit),
        XATTR_LAYOUT_FIELD(dir, layout, stripe_count),
        XATTR_LAYOUT_FIELD(dir, layout, object_size),
        XATTR_LAYOUT_FIELD(dir, layout, pool),
        XATTR_LAYOUT_FIELD(dir, layout, pool_namespace),
-       XATTR_NAME_CEPH(dir, entries),
-       XATTR_NAME_CEPH(dir, files),
-       XATTR_NAME_CEPH(dir, subdirs),
-       XATTR_NAME_CEPH(dir, rentries),
-       XATTR_NAME_CEPH(dir, rfiles),
-       XATTR_NAME_CEPH(dir, rsubdirs),
-       XATTR_NAME_CEPH(dir, rbytes),
-       XATTR_NAME_CEPH(dir, rctime),
+       XATTR_NAME_CEPH(dir, entries, 0),
+       XATTR_NAME_CEPH(dir, files, 0),
+       XATTR_NAME_CEPH(dir, subdirs, 0),
+       XATTR_RSTAT_FIELD(dir, rentries),
+       XATTR_RSTAT_FIELD(dir, rfiles),
+       XATTR_RSTAT_FIELD(dir, rsubdirs),
+       XATTR_RSTAT_FIELD(dir, rbytes),
+       XATTR_RSTAT_FIELD(dir, rctime),
        {
                .name = "ceph.quota",
                .name_size = sizeof("ceph.quota"),
                .getxattr_cb = ceph_vxattrcb_quota,
-               .readonly = false,
-               .hidden = true,
                .exists_cb = ceph_vxattrcb_quota_exists,
+               .flags = VXATTR_FLAG_HIDDEN,
        },
        XATTR_QUOTA_FIELD(quota, max_bytes),
        XATTR_QUOTA_FIELD(quota, max_files),
@@ -333,9 +334,8 @@ static struct ceph_vxattr ceph_file_vxattrs[] = {
                .name = "ceph.file.layout",
                .name_size = sizeof("ceph.file.layout"),
                .getxattr_cb = ceph_vxattrcb_layout,
-               .readonly = false,
-               .hidden = true,
                .exists_cb = ceph_vxattrcb_layout_exists,
+               .flags = VXATTR_FLAG_HIDDEN,
        },
        XATTR_LAYOUT_FIELD(file, layout, stripe_unit),
        XATTR_LAYOUT_FIELD(file, layout, stripe_count),
@@ -374,9 +374,10 @@ static size_t __init vxattrs_name_size(struct ceph_vxattr *vxattrs)
        struct ceph_vxattr *vxattr;
        size_t size = 0;
 
-       for (vxattr = vxattrs; vxattr->name; vxattr++)
-               if (!vxattr->hidden)
+       for (vxattr = vxattrs; vxattr->name; vxattr++) {
+               if (!(vxattr->flags & VXATTR_FLAG_HIDDEN))
                        size += vxattr->name_size;
+       }
 
        return size;
 }
@@ -809,7 +810,10 @@ ssize_t __ceph_getxattr(struct inode *inode, const char *name, void *value,
        /* let's see if a virtual xattr was requested */
        vxattr = ceph_match_vxattr(inode, name);
        if (vxattr) {
-               err = ceph_do_getattr(inode, 0, true);
+               int mask = 0;
+               if (vxattr->flags & VXATTR_FLAG_RSTAT)
+                       mask |= CEPH_STAT_RSTAT;
+               err = ceph_do_getattr(inode, mask, true);
                if (err)
                        return err;
                err = -ENODATA;
@@ -919,7 +923,7 @@ ssize_t ceph_listxattr(struct dentry *dentry, char *names, size_t size)
        err = namelen;
        if (vxattrs) {
                for (i = 0; vxattrs[i].name; i++) {
-                       if (!vxattrs[i].hidden &&
+                       if (!(vxattrs[i].flags & VXATTR_FLAG_HIDDEN) &&
                            !(vxattrs[i].exists_cb &&
                              !vxattrs[i].exists_cb(ci))) {
                                len = sprintf(names, "%s", vxattrs[i].name);
@@ -1024,7 +1028,7 @@ int __ceph_setxattr(struct inode *inode, const char *name,
 
        vxattr = ceph_match_vxattr(inode, name);
        if (vxattr) {
-               if (vxattr->readonly)
+               if (vxattr->flags & VXATTR_FLAG_READONLY)
                        return -EOPNOTSUPP;
                if (value && !strncmp(vxattr->name, "ceph.quota", 10))
                        check_realm = true;
index a3b56544c21b96599fa97f0df02a5fd2c6317678..3d19595eb35216a8c32501d34200fa8061cff512 100644 (file)
@@ -428,7 +428,7 @@ asn1_oid_decode(struct asn1_ctx *ctx,
        if (size < 2 || size > UINT_MAX/sizeof(unsigned long))
                return 0;
 
-       *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
+       *oid = kmalloc_array(size, sizeof(unsigned long), GFP_ATOMIC);
        if (*oid == NULL)
                return 0;
 
index edf5f40898bf07d53ac781ade9f6470c621c97e5..e1553d1e0e504335f186e55d11410478cf56459c 100644 (file)
@@ -128,8 +128,8 @@ fscache_checkaux cifs_fscache_inode_check_aux(void *cookie_netfs_data,
 
        memset(&auxdata, 0, sizeof(auxdata));
        auxdata.eof = cifsi->server_eof;
-       auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
-       auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+       auxdata.last_write_time = timespec64_to_timespec(cifsi->vfs_inode.i_mtime);
+       auxdata.last_change_time = timespec64_to_timespec(cifsi->vfs_inode.i_ctime);
 
        if (memcmp(data, &auxdata, datalen) != 0)
                return FSCACHE_CHECKAUX_OBSOLETE;
index 13a8a77322c98f3e17e3b53bd689e95fc0ee3ffe..1d377b7f286055fa0b8c2117c89f843704fb9c3c 100644 (file)
@@ -747,8 +747,8 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
 
                if (num_aces > ULONG_MAX / sizeof(struct cifs_ace *))
                        return;
-               ppace = kmalloc(num_aces * sizeof(struct cifs_ace *),
-                               GFP_KERNEL);
+               ppace = kmalloc_array(num_aces, sizeof(struct cifs_ace *),
+                                     GFP_KERNEL);
                if (!ppace)
                        return;
 
index 5aca336642c0acd7cafa9d6a7ef3f80b6cfb0ab9..42329b25877db2b3de349b0ce5723f70bebad92b 100644 (file)
@@ -2077,7 +2077,7 @@ struct cifs_writedata *
 cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete)
 {
        struct page **pages =
-               kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
+               kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
        if (pages)
                return cifs_writedata_direct_alloc(pages, complete);
 
index 87eece6fbd488669c6557c30f3631f29b88e9a01..8d41ca7bfcf1fe8f0eb0e3e8c6272547e09cc16c 100644 (file)
@@ -2900,7 +2900,7 @@ static struct cifs_readdata *
 cifs_readdata_alloc(unsigned int nr_pages, work_func_t complete)
 {
        struct page **pages =
-               kzalloc(sizeof(struct page *) * nr_pages, GFP_KERNEL);
+               kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
        struct cifs_readdata *ret = NULL;
 
        if (pages) {
index 25d3f66b2d50899186a4b4e4f78dd7f66fe2035d..85145a7630216b0941d71d8cc5b9bb8d6f409af1 100644 (file)
@@ -129,8 +129,8 @@ static void cifs_fscache_acquire_inode_cookie(struct cifsInodeInfo *cifsi,
 
        memset(&auxdata, 0, sizeof(auxdata));
        auxdata.eof = cifsi->server_eof;
-       auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
-       auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+       auxdata.last_write_time = timespec64_to_timespec(cifsi->vfs_inode.i_mtime);
+       auxdata.last_change_time = timespec64_to_timespec(cifsi->vfs_inode.i_ctime);
 
        cifsi->fscache =
                fscache_acquire_cookie(tcon->fscache,
@@ -166,8 +166,8 @@ void cifs_fscache_release_inode_cookie(struct inode *inode)
        if (cifsi->fscache) {
                memset(&auxdata, 0, sizeof(auxdata));
                auxdata.eof = cifsi->server_eof;
-               auxdata.last_write_time = cifsi->vfs_inode.i_mtime;
-               auxdata.last_change_time = cifsi->vfs_inode.i_ctime;
+               auxdata.last_write_time = timespec64_to_timespec(cifsi->vfs_inode.i_mtime);
+               auxdata.last_change_time = timespec64_to_timespec(cifsi->vfs_inode.i_ctime);
 
                cifs_dbg(FYI, "%s: (0x%p)\n", __func__, cifsi->fscache);
                fscache_relinquish_cookie(cifsi->fscache, &auxdata, false);
index 745fd7fe8d0ef595ade32f79ea6e1dcb60b32c9e..f4697f548a394dbf5c42f731bf13bd529c9aaea0 100644 (file)
@@ -95,6 +95,7 @@ static void
 cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
 {
        struct cifsInodeInfo *cifs_i = CIFS_I(inode);
+       struct timespec ts;
 
        cifs_dbg(FYI, "%s: revalidating inode %llu\n",
                 __func__, cifs_i->uniqueid);
@@ -113,7 +114,8 @@ cifs_revalidate_cache(struct inode *inode, struct cifs_fattr *fattr)
        }
 
         /* revalidate if mtime or size have changed */
-       if (timespec_equal(&inode->i_mtime, &fattr->cf_mtime) &&
+       ts = timespec64_to_timespec(inode->i_mtime);
+       if (timespec_equal(&ts, &fattr->cf_mtime) &&
            cifs_i->server_eof == fattr->cf_eof) {
                cifs_dbg(FYI, "%s: inode %llu is unchanged\n",
                         __func__, cifs_i->uniqueid);
@@ -162,9 +164,9 @@ cifs_fattr_to_inode(struct inode *inode, struct cifs_fattr *fattr)
        cifs_revalidate_cache(inode, fattr);
 
        spin_lock(&inode->i_lock);
-       inode->i_atime = fattr->cf_atime;
-       inode->i_mtime = fattr->cf_mtime;
-       inode->i_ctime = fattr->cf_ctime;
+       inode->i_atime = timespec_to_timespec64(fattr->cf_atime);
+       inode->i_mtime = timespec_to_timespec64(fattr->cf_mtime);
+       inode->i_ctime = timespec_to_timespec64(fattr->cf_ctime);
        inode->i_rdev = fattr->cf_rdev;
        cifs_nlink_fattr_to_inode(inode, fattr);
        inode->i_uid = fattr->cf_uid;
@@ -1123,14 +1125,14 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
        if (attrs->ia_valid & ATTR_ATIME) {
                set_time = true;
                info_buf.LastAccessTime =
-                       cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_atime));
+                       cpu_to_le64(cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_atime)));
        } else
                info_buf.LastAccessTime = 0;
 
        if (attrs->ia_valid & ATTR_MTIME) {
                set_time = true;
                info_buf.LastWriteTime =
-                   cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_mtime));
+                   cpu_to_le64(cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_mtime)));
        } else
                info_buf.LastWriteTime = 0;
 
@@ -1143,7 +1145,7 @@ cifs_set_file_info(struct inode *inode, struct iattr *attrs, unsigned int xid,
        if (set_time && (attrs->ia_valid & ATTR_CTIME)) {
                cifs_dbg(FYI, "CIFS - CTIME changed\n");
                info_buf.ChangeTime =
-                   cpu_to_le64(cifs_UnixTimeToNT(attrs->ia_ctime));
+                   cpu_to_le64(cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_ctime)));
        } else
                info_buf.ChangeTime = 0;
 
@@ -1792,7 +1794,7 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry,
                 * with unix extensions enabled.
                 */
                info_buf_source =
-                       kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO),
+                       kmalloc_array(2, sizeof(FILE_UNIX_BASIC_INFO),
                                        GFP_KERNEL);
                if (info_buf_source == NULL) {
                        rc = -ENOMEM;
@@ -2060,8 +2062,8 @@ int cifs_getattr(const struct path *path, struct kstat *stat,
        /* old CIFS Unix Extensions doesn't return create time */
        if (CIFS_I(inode)->createtime) {
                stat->result_mask |= STATX_BTIME;
-               stat->btime =
-                     cifs_NTtimeToUnix(cpu_to_le64(CIFS_I(inode)->createtime));
+               stat->btime = timespec_to_timespec64(
+                     cifs_NTtimeToUnix(cpu_to_le64(CIFS_I(inode)->createtime)));
        }
 
        stat->attributes_mask |= (STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED);
@@ -2267,17 +2269,17 @@ cifs_setattr_unix(struct dentry *direntry, struct iattr *attrs)
                args->gid = INVALID_GID; /* no change */
 
        if (attrs->ia_valid & ATTR_ATIME)
-               args->atime = cifs_UnixTimeToNT(attrs->ia_atime);
+               args->atime = cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_atime));
        else
                args->atime = NO_CHANGE_64;
 
        if (attrs->ia_valid & ATTR_MTIME)
-               args->mtime = cifs_UnixTimeToNT(attrs->ia_mtime);
+               args->mtime = cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_mtime));
        else
                args->mtime = NO_CHANGE_64;
 
        if (attrs->ia_valid & ATTR_CTIME)
-               args->ctime = cifs_UnixTimeToNT(attrs->ia_ctime);
+               args->ctime = cifs_UnixTimeToNT(timespec64_to_timespec(attrs->ia_ctime));
        else
                args->ctime = NO_CHANGE_64;
 
index f90d4ad6624c323815ecdf3b1f40ac9320fd33ac..af29ade195c002c0323d855edb391a155f1620f7 100644 (file)
@@ -789,7 +789,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw)
                                   GFP_KERNEL);
 
        if (!bv) {
-               bv = vmalloc(max_pages * sizeof(struct bio_vec));
+               bv = vmalloc(array_size(max_pages, sizeof(struct bio_vec)));
                if (!bv)
                        return -ENOMEM;
        }
@@ -799,7 +799,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw)
                                      GFP_KERNEL);
 
        if (!pages) {
-               pages = vmalloc(max_pages * sizeof(struct page *));
+               pages = vmalloc(array_size(max_pages, sizeof(struct page *)));
                if (!pages) {
                        kvfree(bv);
                        return -ENOMEM;
index 48e2004c75fb447671ad695e6abd756b888303fa..af032e1a3eac7adaf0570f5923e0ba6164e8ed6b 100644 (file)
@@ -3471,7 +3471,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon,
        if (!num)
                return -EINVAL;
 
-       iov = kmalloc(sizeof(struct kvec) * num, GFP_KERNEL);
+       iov = kmalloc_array(num, sizeof(struct kvec), GFP_KERNEL);
        if (!iov)
                return -ENOMEM;
 
@@ -3535,7 +3535,7 @@ SMB2_rename(const unsigned int xid, struct cifs_tcon *tcon,
        int rc;
        int len = (2 * UniStrnlen((wchar_t *)target_file, PATH_MAX));
 
-       data = kmalloc(sizeof(void *) * 2, GFP_KERNEL);
+       data = kmalloc_array(2, sizeof(void *), GFP_KERNEL);
        if (!data)
                return -ENOMEM;
 
@@ -3583,7 +3583,7 @@ SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon,
        int rc;
        int len = (2 * UniStrnlen((wchar_t *)target_file, PATH_MAX));
 
-       data = kmalloc(sizeof(void *) * 2, GFP_KERNEL);
+       data = kmalloc_array(2, sizeof(void *), GFP_KERNEL);
        if (!data)
                return -ENOMEM;
 
index 24887a0898c05dbc92f59d4034d7a2c1a9a0d382..1f1a68f8911001bae86976171e44a09402982d92 100644 (file)
@@ -844,8 +844,8 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses,
        int rc;
 
        if (n_vec + 1 > CIFS_MAX_IOV_SIZE) {
-               new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1),
-                                 GFP_KERNEL);
+               new_iov = kmalloc_array(n_vec + 1, sizeof(struct kvec),
+                                       GFP_KERNEL);
                if (!new_iov) {
                        /* otherwise cifs_send_recv below sets resp_buf_type */
                        *resp_buf_type = CIFS_NO_BUFFER;
@@ -886,8 +886,8 @@ smb2_send_recv(const unsigned int xid, struct cifs_ses *ses,
        __be32 rfc1002_marker;
 
        if (n_vec + 1 > CIFS_MAX_IOV_SIZE) {
-               new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1),
-                                 GFP_KERNEL);
+               new_iov = kmalloc_array(n_vec + 1, sizeof(struct kvec),
+                                       GFP_KERNEL);
                if (!new_iov)
                        return -ENOMEM;
        } else
index ca599df0dcb1e18da08c50cf6406d6203b974e92..f3d543dd9a980282e723f8034771c14e88f9f4de 100644 (file)
@@ -105,11 +105,11 @@ void coda_vattr_to_iattr(struct inode *inode, struct coda_vattr *attr)
        if (attr->va_size != -1)
                inode->i_blocks = (attr->va_size + 511) >> 9;
        if (attr->va_atime.tv_sec != -1) 
-               inode->i_atime = attr->va_atime;
+               inode->i_atime = timespec_to_timespec64(attr->va_atime);
        if (attr->va_mtime.tv_sec != -1)
-               inode->i_mtime = attr->va_mtime;
+               inode->i_mtime = timespec_to_timespec64(attr->va_mtime);
         if (attr->va_ctime.tv_sec != -1)
-               inode->i_ctime = attr->va_ctime;
+               inode->i_ctime = timespec_to_timespec64(attr->va_ctime);
 }
 
 
@@ -175,13 +175,13 @@ void coda_iattr_to_vattr(struct iattr *iattr, struct coda_vattr *vattr)
                 vattr->va_size = iattr->ia_size;
        }
         if ( valid & ATTR_ATIME ) {
-                vattr->va_atime = iattr->ia_atime;
+               vattr->va_atime = timespec64_to_timespec(iattr->ia_atime);
        }
         if ( valid & ATTR_MTIME ) {
-                vattr->va_mtime = iattr->ia_mtime;
+               vattr->va_mtime = timespec64_to_timespec(iattr->ia_mtime);
        }
         if ( valid & ATTR_CTIME ) {
-                vattr->va_ctime = iattr->ia_ctime;
+               vattr->va_ctime = timespec64_to_timespec(iattr->ia_ctime);
        }
 }
 
index ad718e5e37bb6415e3a8de5f5d7c98e31c90a425..28ef9e5288532dc16a74f634bea6f2cdec1a384d 100644 (file)
@@ -90,14 +90,14 @@ int configfs_setattr(struct dentry * dentry, struct iattr * iattr)
        if (ia_valid & ATTR_GID)
                sd_iattr->ia_gid = iattr->ia_gid;
        if (ia_valid & ATTR_ATIME)
-               sd_iattr->ia_atime = timespec_trunc(iattr->ia_atime,
-                                               inode->i_sb->s_time_gran);
+               sd_iattr->ia_atime = timespec64_trunc(iattr->ia_atime,
+                                                     inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_MTIME)
-               sd_iattr->ia_mtime = timespec_trunc(iattr->ia_mtime,
-                                               inode->i_sb->s_time_gran);
+               sd_iattr->ia_mtime = timespec64_trunc(iattr->ia_mtime,
+                                                     inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_CTIME)
-               sd_iattr->ia_ctime = timespec_trunc(iattr->ia_ctime,
-                                               inode->i_sb->s_time_gran);
+               sd_iattr->ia_ctime = timespec64_trunc(iattr->ia_ctime,
+                                                     inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_MODE) {
                umode_t mode = iattr->ia_mode;
 
index c4fb9ad7c808175d0a4b358bb3bb13da9e42dabb..f408994fc632129dcbdceca43cedf2fd14705205 100644 (file)
@@ -90,7 +90,7 @@ static struct inode *get_cramfs_inode(struct super_block *sb,
        const struct cramfs_inode *cramfs_inode, unsigned int offset)
 {
        struct inode *inode;
-       static struct timespec zerotime;
+       static struct timespec64 zerotime;
 
        inode = iget_locked(sb, cramino(cramfs_inode, offset));
        if (!inode)
index 0d5e6a569d58ae2c775aad617200ca4fd1b88518..0959044c5ceecb37168743784df8d6d269f6301b 100644 (file)
 #include <linux/namei.h>
 #include "fscrypt_private.h"
 
-/*
- * Call fscrypt_decrypt_page on every single page, reusing the encryption
- * context.
- */
-static void completion_pages(struct work_struct *work)
+static void __fscrypt_decrypt_bio(struct bio *bio, bool done)
 {
-       struct fscrypt_ctx *ctx =
-               container_of(work, struct fscrypt_ctx, r.work);
-       struct bio *bio = ctx->r.bio;
        struct bio_vec *bv;
        int i;
 
@@ -46,22 +39,38 @@ static void completion_pages(struct work_struct *work)
                if (ret) {
                        WARN_ON_ONCE(1);
                        SetPageError(page);
-               } else {
+               } else if (done) {
                        SetPageUptodate(page);
                }
-               unlock_page(page);
+               if (done)
+                       unlock_page(page);
        }
+}
+
+void fscrypt_decrypt_bio(struct bio *bio)
+{
+       __fscrypt_decrypt_bio(bio, false);
+}
+EXPORT_SYMBOL(fscrypt_decrypt_bio);
+
+static void completion_pages(struct work_struct *work)
+{
+       struct fscrypt_ctx *ctx =
+               container_of(work, struct fscrypt_ctx, r.work);
+       struct bio *bio = ctx->r.bio;
+
+       __fscrypt_decrypt_bio(bio, true);
        fscrypt_release_ctx(ctx);
        bio_put(bio);
 }
 
-void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx, struct bio *bio)
+void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx, struct bio *bio)
 {
        INIT_WORK(&ctx->r.work, completion_pages);
        ctx->r.bio = bio;
-       queue_work(fscrypt_read_workqueue, &ctx->r.work);
+       fscrypt_enqueue_decrypt_work(&ctx->r.work);
 }
-EXPORT_SYMBOL(fscrypt_decrypt_bio_pages);
+EXPORT_SYMBOL(fscrypt_enqueue_decrypt_bio);
 
 void fscrypt_pullback_bio_page(struct page **page, bool restore)
 {
index 243a269e6c5fe3d8b41aa8c8ad6777aaea3258af..0f46cf550907fcc4a0675b85df9e3331f010e744 100644 (file)
@@ -45,12 +45,18 @@ static mempool_t *fscrypt_bounce_page_pool = NULL;
 static LIST_HEAD(fscrypt_free_ctxs);
 static DEFINE_SPINLOCK(fscrypt_ctx_lock);
 
-struct workqueue_struct *fscrypt_read_workqueue;
+static struct workqueue_struct *fscrypt_read_workqueue;
 static DEFINE_MUTEX(fscrypt_init_mutex);
 
 static struct kmem_cache *fscrypt_ctx_cachep;
 struct kmem_cache *fscrypt_info_cachep;
 
+void fscrypt_enqueue_decrypt_work(struct work_struct *work)
+{
+       queue_work(fscrypt_read_workqueue, work);
+}
+EXPORT_SYMBOL(fscrypt_enqueue_decrypt_work);
+
 /**
  * fscrypt_release_ctx() - Releases an encryption context
  * @ctx: The encryption context to release.
index 37562394c5deb577ebbe4f5c964848987e1ab537..39c20ef26db41ca8ab819723d87110273ced1a6e 100644 (file)
@@ -93,7 +93,6 @@ static inline bool fscrypt_valid_enc_modes(u32 contents_mode,
 /* crypto.c */
 extern struct kmem_cache *fscrypt_info_cachep;
 extern int fscrypt_initialize(unsigned int cop_flags);
-extern struct workqueue_struct *fscrypt_read_workqueue;
 extern int fscrypt_do_page_crypto(const struct inode *inode,
                                  fscrypt_direction_t rw, u64 lblk_num,
                                  struct page *src_page,
index a913b12fc7f8db787e7b63a488cfe18733b27212..13b01351dd1cb3f8381dbddd2ee70717792b9ac7 100644 (file)
@@ -512,9 +512,7 @@ struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
        if (unlikely(!inode))
                return failed_creating(dentry);
 
-       if (!parent)
-               parent = debugfs_mount->mnt_root;
-       inode->i_mode = S_IFDIR | ((d_inode(parent)->i_mode & 0770));
+       inode->i_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
        inode->i_op = &simple_dir_inode_operations;
        inode->i_fop = &simple_dir_operations;
 
index 78a7c855b06b374f87223b41282cdae1c8f798e8..5ba94be006eec06e49c21b1638113930a835e658 100644 (file)
@@ -517,7 +517,7 @@ static int new_lockspace(const char *name, const char *cluster,
        size = dlm_config.ci_rsbtbl_size;
        ls->ls_rsbtbl_size = size;
 
-       ls->ls_rsbtbl = vmalloc(sizeof(struct dlm_rsbtable) * size);
+       ls->ls_rsbtbl = vmalloc(array_size(size, sizeof(struct dlm_rsbtable)));
        if (!ls->ls_rsbtbl)
                goto out_lsfree;
        for (i = 0; i < size; i++) {
index 61c9514da5e956a36a90e9df601eccfc01b9595a..ceb1031f1cac948e74a970f02058cfeb52d7a351 100644 (file)
@@ -156,11 +156,11 @@ static __poll_t eventfd_poll_mask(struct file *file, __poll_t eventmask)
        count = READ_ONCE(ctx->count);
 
        if (count > 0)
-               events |= EPOLLIN;
+               events |= (EPOLLIN & eventmask);
        if (count == ULLONG_MAX)
                events |= EPOLLERR;
        if (ULLONG_MAX - 1 > count)
-               events |= EPOLLOUT;
+               events |= (EPOLLOUT & eventmask);
 
        return events;
 }
index 67db22fe99c5ce8bf0ba606c0a45f221cbf69b38..ea4436f409fb005a16edeca3f49f29f955db0171 100644 (file)
@@ -922,13 +922,17 @@ static __poll_t ep_read_events_proc(struct eventpoll *ep, struct list_head *head
        return 0;
 }
 
-static __poll_t ep_eventpoll_poll(struct file *file, poll_table *wait)
+static struct wait_queue_head *ep_eventpoll_get_poll_head(struct file *file,
+               __poll_t eventmask)
 {
        struct eventpoll *ep = file->private_data;
-       int depth = 0;
+       return &ep->poll_wait;
+}
 
-       /* Insert inside our poll wait queue */
-       poll_wait(file, &ep->poll_wait, wait);
+static __poll_t ep_eventpoll_poll_mask(struct file *file, __poll_t eventmask)
+{
+       struct eventpoll *ep = file->private_data;
+       int depth = 0;
 
        /*
         * Proceed to find out if wanted events are really available inside
@@ -968,7 +972,8 @@ static const struct file_operations eventpoll_fops = {
        .show_fdinfo    = ep_show_fdinfo,
 #endif
        .release        = ep_eventpoll_release,
-       .poll           = ep_eventpoll_poll,
+       .get_poll_head  = ep_eventpoll_get_poll_head,
+       .poll_mask      = ep_eventpoll_poll_mask,
        .llseek         = noop_llseek,
 };
 
index 0ac62811b34118ab4889d4ee8807706818efadff..5f81fcd383a4d42c2887b01bbd467251f220d7e3 100644 (file)
@@ -110,8 +110,8 @@ static int pcol_try_alloc(struct page_collect *pcol)
        pages =  exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages);
 
        for (; pages; pages >>= 1) {
-               pcol->pages = kmalloc(pages * sizeof(struct page *),
-                                     GFP_KERNEL);
+               pcol->pages = kmalloc_array(pages, sizeof(struct page *),
+                                           GFP_KERNEL);
                if (likely(pcol->pages)) {
                        pcol->alloc_pages = pages;
                        return 0;
index ddbf87246898252b19f4df4de696434d35fed67d..1b8b44637e7065b9bc7ffdf17f0228fc84814860 100644 (file)
@@ -146,68 +146,82 @@ int  _ore_get_io_state(struct ore_layout *layout,
                        struct ore_io_state **pios)
 {
        struct ore_io_state *ios;
-       struct page **pages;
-       struct osd_sg_entry *sgilist;
+       size_t size_ios, size_extra, size_total;
+       void *ios_extra;
+
+       /*
+        * The desired layout looks like this, with the extra_allocation
+        * items pointed at from fields within ios or per_dev:
+
        struct __alloc_all_io_state {
                struct ore_io_state ios;
                struct ore_per_dev_state per_dev[numdevs];
                union {
                        struct osd_sg_entry sglist[sgs_per_dev * numdevs];
                        struct page *pages[num_par_pages];
-               };
-       } *_aios;
-
-       if (likely(sizeof(*_aios) <= PAGE_SIZE)) {
-               _aios = kzalloc(sizeof(*_aios), GFP_KERNEL);
-               if (unlikely(!_aios)) {
-                       ORE_DBGMSG("Failed kzalloc bytes=%zd\n",
-                                  sizeof(*_aios));
+               } extra_allocation;
+       } whole_allocation;
+
+       */
+
+       /* This should never happen, so abort early if it ever does. */
+       if (sgs_per_dev && num_par_pages) {
+               ORE_DBGMSG("Tried to use both pages and sglist\n");
+               *pios = NULL;
+               return -EINVAL;
+       }
+
+       if (numdevs > (INT_MAX - sizeof(*ios)) /
+                      sizeof(struct ore_per_dev_state))
+               return -ENOMEM;
+       size_ios = sizeof(*ios) + sizeof(struct ore_per_dev_state) * numdevs;
+
+       if (sgs_per_dev * numdevs > INT_MAX / sizeof(struct osd_sg_entry))
+               return -ENOMEM;
+       if (num_par_pages > INT_MAX / sizeof(struct page *))
+               return -ENOMEM;
+       size_extra = max(sizeof(struct osd_sg_entry) * (sgs_per_dev * numdevs),
+                        sizeof(struct page *) * num_par_pages);
+
+       size_total = size_ios + size_extra;
+
+       if (likely(size_total <= PAGE_SIZE)) {
+               ios = kzalloc(size_total, GFP_KERNEL);
+               if (unlikely(!ios)) {
+                       ORE_DBGMSG("Failed kzalloc bytes=%zd\n", size_total);
                        *pios = NULL;
                        return -ENOMEM;
                }
-               pages = num_par_pages ? _aios->pages : NULL;
-               sgilist = sgs_per_dev ? _aios->sglist : NULL;
-               ios = &_aios->ios;
+               ios_extra = (char *)ios + size_ios;
        } else {
-               struct __alloc_small_io_state {
-                       struct ore_io_state ios;
-                       struct ore_per_dev_state per_dev[numdevs];
-               } *_aio_small;
-               union __extra_part {
-                       struct osd_sg_entry sglist[sgs_per_dev * numdevs];
-                       struct page *pages[num_par_pages];
-               } *extra_part;
-
-               _aio_small = kzalloc(sizeof(*_aio_small), GFP_KERNEL);
-               if (unlikely(!_aio_small)) {
+               ios = kzalloc(size_ios, GFP_KERNEL);
+               if (unlikely(!ios)) {
                        ORE_DBGMSG("Failed alloc first part bytes=%zd\n",
-                                  sizeof(*_aio_small));
+                                  size_ios);
                        *pios = NULL;
                        return -ENOMEM;
                }
-               extra_part = kzalloc(sizeof(*extra_part), GFP_KERNEL);
-               if (unlikely(!extra_part)) {
+               ios_extra = kzalloc(size_extra, GFP_KERNEL);
+               if (unlikely(!ios_extra)) {
                        ORE_DBGMSG("Failed alloc second part bytes=%zd\n",
-                                  sizeof(*extra_part));
-                       kfree(_aio_small);
+                                  size_extra);
+                       kfree(ios);
                        *pios = NULL;
                        return -ENOMEM;
                }
 
-               pages = num_par_pages ? extra_part->pages : NULL;
-               sgilist = sgs_per_dev ? extra_part->sglist : NULL;
                /* In this case the per_dev[0].sgilist holds the pointer to
                 * be freed
                 */
-               ios = &_aio_small->ios;
                ios->extra_part_alloc = true;
        }
 
-       if (pages) {
-               ios->parity_pages = pages;
+       if (num_par_pages) {
+               ios->parity_pages = ios_extra;
                ios->max_par_pages = num_par_pages;
        }
-       if (sgilist) {
+       if (sgs_per_dev) {
+               struct osd_sg_entry *sgilist = ios_extra;
                unsigned d;
 
                for (d = 0; d < numdevs; ++d) {
index 27cbdb6976495f5f830ca473e9b844fb1a2bd29d..199590f362030d2c4dad33968b2e0a12ef90299a 100644 (file)
@@ -71,6 +71,11 @@ static int _sp2d_alloc(unsigned pages_in_unit, unsigned group_width,
 {
        struct __stripe_pages_2d *sp2d;
        unsigned data_devs = group_width - parity;
+
+       /*
+        * Desired allocation layout is, though when larger than PAGE_SIZE,
+        * each struct __alloc_1p_arrays is separately allocated:
+
        struct _alloc_all_bytes {
                struct __alloc_stripe_pages_2d {
                        struct __stripe_pages_2d sp2d;
@@ -82,55 +87,85 @@ static int _sp2d_alloc(unsigned pages_in_unit, unsigned group_width,
                        char page_is_read[data_devs];
                } __a1pa[pages_in_unit];
        } *_aab;
+
        struct __alloc_1p_arrays *__a1pa;
        struct __alloc_1p_arrays *__a1pa_end;
-       const unsigned sizeof__a1pa = sizeof(_aab->__a1pa[0]);
+
+       */
+
+       char *__a1pa;
+       char *__a1pa_end;
+
+       const size_t sizeof_stripe_pages_2d =
+               sizeof(struct __stripe_pages_2d) +
+               sizeof(struct __1_page_stripe) * pages_in_unit;
+       const size_t sizeof__a1pa =
+               ALIGN(sizeof(struct page *) * (2 * group_width) + data_devs,
+                     sizeof(void *));
+       const size_t sizeof__a1pa_arrays = sizeof__a1pa * pages_in_unit;
+       const size_t alloc_total = sizeof_stripe_pages_2d +
+                                  sizeof__a1pa_arrays;
+
        unsigned num_a1pa, alloc_size, i;
 
        /* FIXME: check these numbers in ore_verify_layout */
-       BUG_ON(sizeof(_aab->__asp2d) > PAGE_SIZE);
+       BUG_ON(sizeof_stripe_pages_2d > PAGE_SIZE);
        BUG_ON(sizeof__a1pa > PAGE_SIZE);
 
-       if (sizeof(*_aab) > PAGE_SIZE) {
-               num_a1pa = (PAGE_SIZE - sizeof(_aab->__asp2d)) / sizeof__a1pa;
-               alloc_size = sizeof(_aab->__asp2d) + sizeof__a1pa * num_a1pa;
+       /*
+        * If alloc_total would be larger than PAGE_SIZE, only allocate
+        * as many a1pa items as would fill the rest of the page, instead
+        * of the full pages_in_unit count.
+        */
+       if (alloc_total > PAGE_SIZE) {
+               num_a1pa = (PAGE_SIZE - sizeof_stripe_pages_2d) / sizeof__a1pa;
+               alloc_size = sizeof_stripe_pages_2d + sizeof__a1pa * num_a1pa;
        } else {
                num_a1pa = pages_in_unit;
-               alloc_size = sizeof(*_aab);
+               alloc_size = alloc_total;
        }
 
-       _aab = kzalloc(alloc_size, GFP_KERNEL);
-       if (unlikely(!_aab)) {
+       *psp2d = sp2d = kzalloc(alloc_size, GFP_KERNEL);
+       if (unlikely(!sp2d)) {
                ORE_DBGMSG("!! Failed to alloc sp2d size=%d\n", alloc_size);
                return -ENOMEM;
        }
+       /* From here Just call _sp2d_free */
 
-       sp2d = &_aab->__asp2d.sp2d;
-       *psp2d = sp2d; /* From here Just call _sp2d_free */
-
-       __a1pa = _aab->__a1pa;
-       __a1pa_end = __a1pa + num_a1pa;
+       /* Find start of a1pa area. */
+       __a1pa = (char *)sp2d + sizeof_stripe_pages_2d;
+       /* Find end of the _allocated_ a1pa area. */
+       __a1pa_end = __a1pa + alloc_size;
 
+       /* Allocate additionally needed a1pa items in PAGE_SIZE chunks. */
        for (i = 0; i < pages_in_unit; ++i) {
+               struct __1_page_stripe *stripe = &sp2d->_1p_stripes[i];
+
                if (unlikely(__a1pa >= __a1pa_end)) {
                        num_a1pa = min_t(unsigned, PAGE_SIZE / sizeof__a1pa,
                                                        pages_in_unit - i);
+                       alloc_size = sizeof__a1pa * num_a1pa;
 
-                       __a1pa = kcalloc(num_a1pa, sizeof__a1pa, GFP_KERNEL);
+                       __a1pa = kzalloc(alloc_size, GFP_KERNEL);
                        if (unlikely(!__a1pa)) {
                                ORE_DBGMSG("!! Failed to _alloc_1p_arrays=%d\n",
                                           num_a1pa);
                                return -ENOMEM;
                        }
-                       __a1pa_end = __a1pa + num_a1pa;
+                       __a1pa_end = __a1pa + alloc_size;
                        /* First *pages is marked for kfree of the buffer */
-                       sp2d->_1p_stripes[i].alloc = true;
+                       stripe->alloc = true;
                }
 
-               sp2d->_1p_stripes[i].pages = __a1pa->pages;
-               sp2d->_1p_stripes[i].scribble = __a1pa->scribble ;
-               sp2d->_1p_stripes[i].page_is_read = __a1pa->page_is_read;
-               ++__a1pa;
+               /*
+                * Attach all _lp_stripes pointers to the allocation for
+                * it which was either part of the original PAGE_SIZE
+                * allocation or the subsequent allocation in this loop.
+                */
+               stripe->pages = (void *)__a1pa;
+               stripe->scribble = stripe->pages + group_width;
+               stripe->page_is_read = (char *)stripe->scribble + group_width;
+               __a1pa += sizeof__a1pa;
        }
 
        sp2d->parity = parity;
index 719a3152da80589a858c89b5260331246fce70bf..41cf2fbee50da4cb9ec0999a967d7d777fb7fc45 100644 (file)
@@ -549,27 +549,26 @@ static int exofs_devs_2_odi(struct exofs_dt_device_info *dt_dev,
 static int __alloc_dev_table(struct exofs_sb_info *sbi, unsigned numdevs,
                      struct exofs_dev **peds)
 {
-       struct __alloc_ore_devs_and_exofs_devs {
-               /* Twice bigger table: See exofs_init_comps() and comment at
-                * exofs_read_lookup_dev_table()
-                */
-               struct ore_dev *oreds[numdevs * 2 - 1];
-               struct exofs_dev eds[numdevs];
-       } *aoded;
+       /* Twice bigger table: See exofs_init_comps() and comment at
+        * exofs_read_lookup_dev_table()
+        */
+       const size_t numores = numdevs * 2 - 1;
        struct exofs_dev *eds;
        unsigned i;
 
-       aoded = kzalloc(sizeof(*aoded), GFP_KERNEL);
-       if (unlikely(!aoded)) {
+       sbi->oc.ods = kzalloc(numores * sizeof(struct ore_dev *) +
+                             numdevs * sizeof(struct exofs_dev), GFP_KERNEL);
+       if (unlikely(!sbi->oc.ods)) {
                EXOFS_ERR("ERROR: failed allocating Device array[%d]\n",
                          numdevs);
                return -ENOMEM;
        }
 
-       sbi->oc.ods = aoded->oreds;
-       *peds = eds = aoded->eds;
+       /* Start of allocated struct exofs_dev entries */
+       *peds = eds = (void *)sbi->oc.ods[numores];
+       /* Initialize pointers into struct exofs_dev */
        for (i = 0; i < numdevs; ++i)
-               aoded->oreds[i] = &eds[i].ored;
+               sbi->oc.ods[i] = &eds[i].ored;
        return 0;
 }
 
index c09289a42dc553df2fdc9658faed3ceb463714fb..25ab1274090f8532254e783def084bccd24a21c4 100644 (file)
@@ -1082,7 +1082,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
                                        / EXT2_BLOCKS_PER_GROUP(sb)) + 1;
        db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
                   EXT2_DESC_PER_BLOCK(sb);
-       sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
+       sbi->s_group_desc = kmalloc_array (db_count,
+                                          sizeof(struct buffer_head *),
+                                          GFP_KERNEL);
        if (sbi->s_group_desc == NULL) {
                ext2_msg(sb, KERN_ERR, "error: not enough memory");
                goto failed_mount;
index df95412915eaa7fc1df7113734dded459eab5601..0b127853c5845aef5bcfeaa9ec2485f47d7939fb 100644 (file)
@@ -817,12 +817,14 @@ static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra)
        time->tv_nsec = (le32_to_cpu(extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS;
 }
 
-#define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode)                         \
-do {                                                                          \
-       (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec);               \
-       if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))     \
-               (raw_inode)->xtime ## _extra =                                 \
-                               ext4_encode_extra_time(&(inode)->xtime);       \
+#define EXT4_INODE_SET_XTIME(xtime, inode, raw_inode)                          \
+do {                                                                           \
+       (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec);                \
+       if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))     {\
+               struct timespec ts = timespec64_to_timespec((inode)->xtime);    \
+               (raw_inode)->xtime ## _extra =                                  \
+                               ext4_encode_extra_time(&ts);                    \
+               }                                                               \
 } while (0)
 
 #define EXT4_EINODE_SET_XTIME(xtime, einode, raw_inode)                               \
@@ -834,16 +836,20 @@ do {                                                                             \
                                ext4_encode_extra_time(&(einode)->xtime);      \
 } while (0)
 
-#define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)                         \
-do {                                                                          \
-       (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);       \
-       if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra))     \
-               ext4_decode_extra_time(&(inode)->xtime,                        \
-                                      raw_inode->xtime ## _extra);            \
-       else                                                                   \
-               (inode)->xtime.tv_nsec = 0;                                    \
+#define EXT4_INODE_GET_XTIME(xtime, inode, raw_inode)                          \
+do {                                                                           \
+       (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime);        \
+       if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {    \
+               struct timespec ts = timespec64_to_timespec((inode)->xtime);    \
+               ext4_decode_extra_time(&ts,                                     \
+                                      raw_inode->xtime ## _extra);             \
+               (inode)->xtime = timespec_to_timespec64(ts);                    \
+               }                                                               \
+       else                                                                    \
+               (inode)->xtime.tv_nsec = 0;                                     \
 } while (0)
 
+
 #define EXT4_EINODE_GET_XTIME(xtime, einode, raw_inode)                               \
 do {                                                                          \
        if (EXT4_FITS_IN_INODE(raw_inode, einode, xtime))                      \
index c969275ce3ee7469167a6921e8fa22e4c91ed3a2..0057fe3f248d195736ee58ec40131dadd98d59bb 100644 (file)
@@ -577,7 +577,7 @@ int ext4_ext_precache(struct inode *inode)
        down_read(&ei->i_data_sem);
        depth = ext_depth(inode);
 
-       path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1),
+       path = kcalloc(depth + 1, sizeof(struct ext4_ext_path),
                       GFP_NOFS);
        if (path == NULL) {
                up_read(&ei->i_data_sem);
@@ -879,7 +879,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block,
        }
        if (!path) {
                /* account possible depth increase */
-               path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2),
+               path = kcalloc(depth + 2, sizeof(struct ext4_ext_path),
                                GFP_NOFS);
                if (unlikely(!path))
                        return ERR_PTR(-ENOMEM);
@@ -1063,7 +1063,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
         * We need this to handle errors and free blocks
         * upon them.
         */
-       ablocks = kzalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS);
+       ablocks = kcalloc(depth, sizeof(ext4_fsblk_t), GFP_NOFS);
        if (!ablocks)
                return -ENOMEM;
 
@@ -2921,7 +2921,7 @@ int ext4_ext_remove_space(struct inode *inode, ext4_lblk_t start,
                        path[k].p_block =
                                le16_to_cpu(path[k].p_hdr->eh_entries)+1;
        } else {
-               path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1),
+               path = kcalloc(depth + 1, sizeof(struct ext4_ext_path),
                               GFP_NOFS);
                if (path == NULL) {
                        ext4_journal_stop(handle);
index 4d6e007f3569a5440398e2c0f5e88fc1fea7225e..f525f909b559c8c12e361f0750b56717a972ffb1 100644 (file)
@@ -1072,8 +1072,8 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
        inode->i_ino = ino + group * EXT4_INODES_PER_GROUP(sb);
        /* This is the optimal IO size (for stat), not the fs block size */
        inode->i_blocks = 0;
-       inode->i_mtime = inode->i_atime = inode->i_ctime = ei->i_crtime =
-                                                      current_time(inode);
+       inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+       ei->i_crtime = timespec64_to_timespec(inode->i_mtime);
 
        memset(ei->i_data, 0, sizeof(ei->i_data));
        ei->i_dir_start_lookup = 0;
index 4a09063ce1d215492c313a2ce54a10418cf63d8b..2a4c25c4681da5fac6f61edc848ce45ee2e42218 100644 (file)
@@ -3673,7 +3673,7 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
        };
        u8 new_file_type;
        int retval;
-       struct timespec ctime;
+       struct timespec64 ctime;
 
        if ((ext4_test_inode_flag(new_dir, EXT4_INODE_PROJINHERIT) &&
             !projid_eq(EXT4_I(new_dir)->i_projid,
index 9ffa6fad18dbef1528f3ddbacc67fafff370cf03..19b87a8de6ff3659aaaa22dae4c32f73800f6777 100644 (file)
@@ -77,7 +77,7 @@ static void mpage_end_io(struct bio *bio)
                if (bio->bi_status) {
                        fscrypt_release_ctx(bio->bi_private);
                } else {
-                       fscrypt_decrypt_bio_pages(bio->bi_private, bio);
+                       fscrypt_enqueue_decrypt_bio(bio->bi_private, bio);
                        return;
                }
        }
index d792b7689d92c23234cbc6d3158d75d307d8ba3b..e5fb38451a733cc947a5c9f77c478545b5699013 100644 (file)
@@ -204,12 +204,14 @@ static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned long flexbg_size)
                goto out2;
        flex_gd->count = flexbg_size;
 
-       flex_gd->groups = kmalloc(sizeof(struct ext4_new_group_data) *
-                                 flexbg_size, GFP_NOFS);
+       flex_gd->groups = kmalloc_array(flexbg_size,
+                                       sizeof(struct ext4_new_group_data),
+                                       GFP_NOFS);
        if (flex_gd->groups == NULL)
                goto out2;
 
-       flex_gd->bg_flags = kmalloc(flexbg_size * sizeof(__u16), GFP_NOFS);
+       flex_gd->bg_flags = kmalloc_array(flexbg_size, sizeof(__u16),
+                                         GFP_NOFS);
        if (flex_gd->bg_flags == NULL)
                goto out1;
 
@@ -969,7 +971,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode,
        int res, i;
        int err;
 
-       primary = kmalloc(reserved_gdb * sizeof(*primary), GFP_NOFS);
+       primary = kmalloc_array(reserved_gdb, sizeof(*primary), GFP_NOFS);
        if (!primary)
                return -ENOMEM;
 
index 00fe75a71c4b6a2bd6b6afb7c49e8dd02e67c963..0c4c2201b3aa2ee9680478f8fd11685e66634f50 100644 (file)
@@ -3993,9 +3993,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent)
                        goto failed_mount;
                }
        }
-       sbi->s_group_desc = kvmalloc(db_count *
-                                         sizeof(struct buffer_head *),
-                                         GFP_KERNEL);
+       sbi->s_group_desc = kvmalloc_array(db_count,
+                                          sizeof(struct buffer_head *),
+                                          GFP_KERNEL);
        if (sbi->s_group_desc == NULL) {
                ext4_msg(sb, KERN_ERR, "not enough memory");
                ret = -ENOMEM;
index bf779461df13dee9232eb9ff057b6c4c3572a0c3..9f1c96caebda1b63a3703d08742fc2309b7be349 100644 (file)
@@ -24,7 +24,7 @@
 #include <trace/events/f2fs.h>
 
 static struct kmem_cache *ino_entry_slab;
-struct kmem_cache *inode_entry_slab;
+struct kmem_cache *f2fs_inode_entry_slab;
 
 void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
 {
@@ -36,7 +36,7 @@ void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
 /*
  * We guarantee no failure on the returned page.
  */
-struct page *grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
+struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
 {
        struct address_space *mapping = META_MAPPING(sbi);
        struct page *page = NULL;
@@ -100,24 +100,27 @@ static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
         * readonly and make sure do not write checkpoint with non-uptodate
         * meta page.
         */
-       if (unlikely(!PageUptodate(page)))
+       if (unlikely(!PageUptodate(page))) {
+               memset(page_address(page), 0, PAGE_SIZE);
                f2fs_stop_checkpoint(sbi, false);
+       }
 out:
        return page;
 }
 
-struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
+struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
 {
        return __get_meta_page(sbi, index, true);
 }
 
 /* for POR only */
-struct page *get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index)
+struct page *f2fs_get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index)
 {
        return __get_meta_page(sbi, index, false);
 }
 
-bool is_valid_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr, int type)
+bool f2fs_is_valid_meta_blkaddr(struct f2fs_sb_info *sbi,
+                                       block_t blkaddr, int type)
 {
        switch (type) {
        case META_NAT:
@@ -151,7 +154,7 @@ bool is_valid_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr, int type)
 /*
  * Readahead CP/NAT/SIT/SSA pages
  */
-int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
+int f2fs_ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
                                                        int type, bool sync)
 {
        struct page *page;
@@ -173,7 +176,7 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
        blk_start_plug(&plug);
        for (; nrpages-- > 0; blkno++) {
 
-               if (!is_valid_blkaddr(sbi, blkno, type))
+               if (!f2fs_is_valid_meta_blkaddr(sbi, blkno, type))
                        goto out;
 
                switch (type) {
@@ -217,7 +220,7 @@ int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
        return blkno - start;
 }
 
-void ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index)
+void f2fs_ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index)
 {
        struct page *page;
        bool readahead = false;
@@ -228,7 +231,7 @@ void ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index)
        f2fs_put_page(page, 0);
 
        if (readahead)
-               ra_meta_pages(sbi, index, BIO_MAX_PAGES, META_POR, true);
+               f2fs_ra_meta_pages(sbi, index, BIO_MAX_PAGES, META_POR, true);
 }
 
 static int __f2fs_write_meta_page(struct page *page,
@@ -249,7 +252,7 @@ static int __f2fs_write_meta_page(struct page *page,
        if (wbc->for_reclaim && page->index < GET_SUM_BLOCK(sbi, 0))
                goto redirty_out;
 
-       write_meta_page(sbi, page, io_type);
+       f2fs_do_write_meta_page(sbi, page, io_type);
        dec_page_count(sbi, F2FS_DIRTY_META);
 
        if (wbc->for_reclaim)
@@ -294,7 +297,7 @@ static int f2fs_write_meta_pages(struct address_space *mapping,
 
        trace_f2fs_writepages(mapping->host, wbc, META);
        diff = nr_pages_to_write(sbi, META, wbc);
-       written = sync_meta_pages(sbi, META, wbc->nr_to_write, FS_META_IO);
+       written = f2fs_sync_meta_pages(sbi, META, wbc->nr_to_write, FS_META_IO);
        mutex_unlock(&sbi->cp_mutex);
        wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff);
        return 0;
@@ -305,7 +308,7 @@ static int f2fs_write_meta_pages(struct address_space *mapping,
        return 0;
 }
 
-long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
+long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
                                long nr_to_write, enum iostat_type io_type)
 {
        struct address_space *mapping = META_MAPPING(sbi);
@@ -382,7 +385,7 @@ static int f2fs_set_meta_page_dirty(struct page *page)
        if (!PageUptodate(page))
                SetPageUptodate(page);
        if (!PageDirty(page)) {
-               f2fs_set_page_dirty_nobuffers(page);
+               __set_page_dirty_nobuffers(page);
                inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_META);
                SetPagePrivate(page);
                f2fs_trace_pid(page);
@@ -455,20 +458,20 @@ static void __remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
        spin_unlock(&im->ino_lock);
 }
 
-void add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
+void f2fs_add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
 {
        /* add new dirty ino entry into list */
        __add_ino_entry(sbi, ino, 0, type);
 }
 
-void remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
+void f2fs_remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
 {
        /* remove dirty ino entry from list */
        __remove_ino_entry(sbi, ino, type);
 }
 
 /* mode should be APPEND_INO or UPDATE_INO */
-bool exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode)
+bool f2fs_exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode)
 {
        struct inode_management *im = &sbi->im[mode];
        struct ino_entry *e;
@@ -479,7 +482,7 @@ bool exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode)
        return e ? true : false;
 }
 
-void release_ino_entry(struct f2fs_sb_info *sbi, bool all)
+void f2fs_release_ino_entry(struct f2fs_sb_info *sbi, bool all)
 {
        struct ino_entry *e, *tmp;
        int i;
@@ -498,13 +501,13 @@ void release_ino_entry(struct f2fs_sb_info *sbi, bool all)
        }
 }
 
-void set_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
+void f2fs_set_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
                                        unsigned int devidx, int type)
 {
        __add_ino_entry(sbi, ino, devidx, type);
 }
 
-bool is_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
+bool f2fs_is_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
                                        unsigned int devidx, int type)
 {
        struct inode_management *im = &sbi->im[type];
@@ -519,7 +522,7 @@ bool is_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
        return is_dirty;
 }
 
-int acquire_orphan_inode(struct f2fs_sb_info *sbi)
+int f2fs_acquire_orphan_inode(struct f2fs_sb_info *sbi)
 {
        struct inode_management *im = &sbi->im[ORPHAN_INO];
        int err = 0;
@@ -542,7 +545,7 @@ int acquire_orphan_inode(struct f2fs_sb_info *sbi)
        return err;
 }
 
-void release_orphan_inode(struct f2fs_sb_info *sbi)
+void f2fs_release_orphan_inode(struct f2fs_sb_info *sbi)
 {
        struct inode_management *im = &sbi->im[ORPHAN_INO];
 
@@ -552,14 +555,14 @@ void release_orphan_inode(struct f2fs_sb_info *sbi)
        spin_unlock(&im->ino_lock);
 }
 
-void add_orphan_inode(struct inode *inode)
+void f2fs_add_orphan_inode(struct inode *inode)
 {
        /* add new orphan ino entry into list */
        __add_ino_entry(F2FS_I_SB(inode), inode->i_ino, 0, ORPHAN_INO);
-       update_inode_page(inode);
+       f2fs_update_inode_page(inode);
 }
 
-void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
+void f2fs_remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
 {
        /* remove orphan entry from orphan list */
        __remove_ino_entry(sbi, ino, ORPHAN_INO);
@@ -569,7 +572,7 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
 {
        struct inode *inode;
        struct node_info ni;
-       int err = acquire_orphan_inode(sbi);
+       int err = f2fs_acquire_orphan_inode(sbi);
 
        if (err)
                goto err_out;
@@ -587,16 +590,17 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
        }
 
        err = dquot_initialize(inode);
-       if (err)
+       if (err) {
+               iput(inode);
                goto err_out;
+       }
 
-       dquot_initialize(inode);
        clear_nlink(inode);
 
        /* truncate all the data during iput */
        iput(inode);
 
-       get_node_info(sbi, ino, &ni);
+       f2fs_get_node_info(sbi, ino, &ni);
 
        /* ENOMEM was fully retried in f2fs_evict_inode. */
        if (ni.blk_addr != NULL_ADDR) {
@@ -614,7 +618,7 @@ static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
        return err;
 }
 
-int recover_orphan_inodes(struct f2fs_sb_info *sbi)
+int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
 {
        block_t start_blk, orphan_blocks, i, j;
        unsigned int s_flags = sbi->sb->s_flags;
@@ -642,10 +646,10 @@ int recover_orphan_inodes(struct f2fs_sb_info *sbi)
        start_blk = __start_cp_addr(sbi) + 1 + __cp_payload(sbi);
        orphan_blocks = __start_sum_addr(sbi) - 1 - __cp_payload(sbi);
 
-       ra_meta_pages(sbi, start_blk, orphan_blocks, META_CP, true);
+       f2fs_ra_meta_pages(sbi, start_blk, orphan_blocks, META_CP, true);
 
        for (i = 0; i < orphan_blocks; i++) {
-               struct page *page = get_meta_page(sbi, start_blk + i);
+               struct page *page = f2fs_get_meta_page(sbi, start_blk + i);
                struct f2fs_orphan_block *orphan_blk;
 
                orphan_blk = (struct f2fs_orphan_block *)page_address(page);
@@ -695,7 +699,7 @@ static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
        /* loop for each orphan inode entry and write them in Jornal block */
        list_for_each_entry(orphan, head, list) {
                if (!page) {
-                       page = grab_meta_page(sbi, start_blk++);
+                       page = f2fs_grab_meta_page(sbi, start_blk++);
                        orphan_blk =
                                (struct f2fs_orphan_block *)page_address(page);
                        memset(orphan_blk, 0, sizeof(*orphan_blk));
@@ -737,7 +741,7 @@ static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
        size_t crc_offset = 0;
        __u32 crc = 0;
 
-       *cp_page = get_meta_page(sbi, cp_addr);
+       *cp_page = f2fs_get_meta_page(sbi, cp_addr);
        *cp_block = (struct f2fs_checkpoint *)page_address(*cp_page);
 
        crc_offset = le32_to_cpu((*cp_block)->checksum_offset);
@@ -790,7 +794,7 @@ static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
        return NULL;
 }
 
-int get_valid_checkpoint(struct f2fs_sb_info *sbi)
+int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi)
 {
        struct f2fs_checkpoint *cp_block;
        struct f2fs_super_block *fsb = sbi->raw_super;
@@ -802,7 +806,8 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi)
        block_t cp_blk_no;
        int i;
 
-       sbi->ckpt = f2fs_kzalloc(sbi, cp_blks * blk_size, GFP_KERNEL);
+       sbi->ckpt = f2fs_kzalloc(sbi, array_size(blk_size, cp_blks),
+                                GFP_KERNEL);
        if (!sbi->ckpt)
                return -ENOMEM;
        /*
@@ -834,7 +839,7 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi)
        memcpy(sbi->ckpt, cp_block, blk_size);
 
        /* Sanity checking of checkpoint */
-       if (sanity_check_ckpt(sbi))
+       if (f2fs_sanity_check_ckpt(sbi))
                goto free_fail_no_cp;
 
        if (cur_page == cp1)
@@ -853,7 +858,7 @@ int get_valid_checkpoint(struct f2fs_sb_info *sbi)
                void *sit_bitmap_ptr;
                unsigned char *ckpt = (unsigned char *)sbi->ckpt;
 
-               cur_page = get_meta_page(sbi, cp_blk_no + i);
+               cur_page = f2fs_get_meta_page(sbi, cp_blk_no + i);
                sit_bitmap_ptr = page_address(cur_page);
                memcpy(ckpt + i * blk_size, sit_bitmap_ptr, blk_size);
                f2fs_put_page(cur_page, 1);
@@ -898,7 +903,7 @@ static void __remove_dirty_inode(struct inode *inode, enum inode_type type)
        stat_dec_dirty_inode(F2FS_I_SB(inode), type);
 }
 
-void update_dirty_page(struct inode *inode, struct page *page)
+void f2fs_update_dirty_page(struct inode *inode, struct page *page)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        enum inode_type type = S_ISDIR(inode->i_mode) ? DIR_INODE : FILE_INODE;
@@ -917,7 +922,7 @@ void update_dirty_page(struct inode *inode, struct page *page)
        f2fs_trace_pid(page);
 }
 
-void remove_dirty_inode(struct inode *inode)
+void f2fs_remove_dirty_inode(struct inode *inode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        enum inode_type type = S_ISDIR(inode->i_mode) ? DIR_INODE : FILE_INODE;
@@ -934,7 +939,7 @@ void remove_dirty_inode(struct inode *inode)
        spin_unlock(&sbi->inode_lock[type]);
 }
 
-int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
+int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
 {
        struct list_head *head;
        struct inode *inode;
@@ -1017,7 +1022,7 @@ int f2fs_sync_inode_meta(struct f2fs_sb_info *sbi)
 
                        /* it's on eviction */
                        if (is_inode_flag_set(inode, FI_DIRTY_INODE))
-                               update_inode_page(inode);
+                               f2fs_update_inode_page(inode);
                        iput(inode);
                }
        }
@@ -1057,7 +1062,7 @@ static int block_operations(struct f2fs_sb_info *sbi)
        /* write all the dirty dentry pages */
        if (get_pages(sbi, F2FS_DIRTY_DENTS)) {
                f2fs_unlock_all(sbi);
-               err = sync_dirty_inodes(sbi, DIR_INODE);
+               err = f2fs_sync_dirty_inodes(sbi, DIR_INODE);
                if (err)
                        goto out;
                cond_resched();
@@ -1085,7 +1090,9 @@ static int block_operations(struct f2fs_sb_info *sbi)
 
        if (get_pages(sbi, F2FS_DIRTY_NODES)) {
                up_write(&sbi->node_write);
-               err = sync_node_pages(sbi, &wbc, false, FS_CP_NODE_IO);
+               atomic_inc(&sbi->wb_sync_req[NODE]);
+               err = f2fs_sync_node_pages(sbi, &wbc, false, FS_CP_NODE_IO);
+               atomic_dec(&sbi->wb_sync_req[NODE]);
                if (err) {
                        up_write(&sbi->node_change);
                        f2fs_unlock_all(sbi);
@@ -1179,10 +1186,10 @@ static void commit_checkpoint(struct f2fs_sb_info *sbi,
 
        /*
         * pagevec_lookup_tag and lock_page again will take
-        * some extra time. Therefore, update_meta_pages and
-        * sync_meta_pages are combined in this function.
+        * some extra time. Therefore, f2fs_update_meta_pages and
+        * f2fs_sync_meta_pages are combined in this function.
         */
-       struct page *page = grab_meta_page(sbi, blk_addr);
+       struct page *page = f2fs_grab_meta_page(sbi, blk_addr);
        int err;
 
        memcpy(page_address(page), src, PAGE_SIZE);
@@ -1220,7 +1227,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
        /* Flush all the NAT/SIT pages */
        while (get_pages(sbi, F2FS_DIRTY_META)) {
-               sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
+               f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
                if (unlikely(f2fs_cp_error(sbi)))
                        return -EIO;
        }
@@ -1229,7 +1236,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
         * modify checkpoint
         * version number is already updated
         */
-       ckpt->elapsed_time = cpu_to_le64(get_mtime(sbi));
+       ckpt->elapsed_time = cpu_to_le64(get_mtime(sbi, true));
        ckpt->free_segment_count = cpu_to_le32(free_segments(sbi));
        for (i = 0; i < NR_CURSEG_NODE_TYPE; i++) {
                ckpt->cur_node_segno[i] =
@@ -1249,7 +1256,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
        }
 
        /* 2 cp  + n data seg summary + orphan inode blocks */
-       data_sum_blocks = npages_for_summary_flush(sbi, false);
+       data_sum_blocks = f2fs_npages_for_summary_flush(sbi, false);
        spin_lock_irqsave(&sbi->cp_lock, flags);
        if (data_sum_blocks < NR_CURSEG_DATA_TYPE)
                __set_ckpt_flags(ckpt, CP_COMPACT_SUM_FLAG);
@@ -1294,22 +1301,23 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
                blk = start_blk + sbi->blocks_per_seg - nm_i->nat_bits_blocks;
                for (i = 0; i < nm_i->nat_bits_blocks; i++)
-                       update_meta_page(sbi, nm_i->nat_bits +
+                       f2fs_update_meta_page(sbi, nm_i->nat_bits +
                                        (i << F2FS_BLKSIZE_BITS), blk + i);
 
                /* Flush all the NAT BITS pages */
                while (get_pages(sbi, F2FS_DIRTY_META)) {
-                       sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
+                       f2fs_sync_meta_pages(sbi, META, LONG_MAX,
+                                                       FS_CP_META_IO);
                        if (unlikely(f2fs_cp_error(sbi)))
                                return -EIO;
                }
        }
 
        /* write out checkpoint buffer at block 0 */
-       update_meta_page(sbi, ckpt, start_blk++);
+       f2fs_update_meta_page(sbi, ckpt, start_blk++);
 
        for (i = 1; i < 1 + cp_payload_blks; i++)
-               update_meta_page(sbi, (char *)ckpt + i * F2FS_BLKSIZE,
+               f2fs_update_meta_page(sbi, (char *)ckpt + i * F2FS_BLKSIZE,
                                                        start_blk++);
 
        if (orphan_num) {
@@ -1317,7 +1325,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
                start_blk += orphan_blocks;
        }
 
-       write_data_summaries(sbi, start_blk);
+       f2fs_write_data_summaries(sbi, start_blk);
        start_blk += data_sum_blocks;
 
        /* Record write statistics in the hot node summary */
@@ -1328,7 +1336,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
        seg_i->journal->info.kbytes_written = cpu_to_le64(kbytes_written);
 
        if (__remain_node_summaries(cpc->reason)) {
-               write_node_summaries(sbi, start_blk);
+               f2fs_write_node_summaries(sbi, start_blk);
                start_blk += NR_CURSEG_NODE_TYPE;
        }
 
@@ -1337,7 +1345,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
        percpu_counter_set(&sbi->alloc_valid_block_count, 0);
 
        /* Here, we have one bio having CP pack except cp pack 2 page */
-       sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
+       f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
 
        /* wait for previous submitted meta pages writeback */
        wait_on_all_pages_writeback(sbi);
@@ -1354,7 +1362,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
        commit_checkpoint(sbi, ckpt, start_blk);
        wait_on_all_pages_writeback(sbi);
 
-       release_ino_entry(sbi, false);
+       f2fs_release_ino_entry(sbi, false);
 
        if (unlikely(f2fs_cp_error(sbi)))
                return -EIO;
@@ -1379,7 +1387,7 @@ static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 /*
  * We guarantee that this checkpoint procedure will not fail.
  */
-int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
+int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 {
        struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
        unsigned long long ckpt_ver;
@@ -1412,7 +1420,7 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
        /* this is the case of multiple fstrims without any changes */
        if (cpc->reason & CP_DISCARD) {
-               if (!exist_trim_candidates(sbi, cpc)) {
+               if (!f2fs_exist_trim_candidates(sbi, cpc)) {
                        unblock_operations(sbi);
                        goto out;
                }
@@ -1420,8 +1428,8 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
                if (NM_I(sbi)->dirty_nat_cnt == 0 &&
                                SIT_I(sbi)->dirty_sentries == 0 &&
                                prefree_segments(sbi) == 0) {
-                       flush_sit_entries(sbi, cpc);
-                       clear_prefree_segments(sbi, cpc);
+                       f2fs_flush_sit_entries(sbi, cpc);
+                       f2fs_clear_prefree_segments(sbi, cpc);
                        unblock_operations(sbi);
                        goto out;
                }
@@ -1436,15 +1444,15 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
        ckpt->checkpoint_ver = cpu_to_le64(++ckpt_ver);
 
        /* write cached NAT/SIT entries to NAT/SIT area */
-       flush_nat_entries(sbi, cpc);
-       flush_sit_entries(sbi, cpc);
+       f2fs_flush_nat_entries(sbi, cpc);
+       f2fs_flush_sit_entries(sbi, cpc);
 
        /* unlock all the fs_lock[] in do_checkpoint() */
        err = do_checkpoint(sbi, cpc);
        if (err)
-               release_discard_addrs(sbi);
+               f2fs_release_discard_addrs(sbi);
        else
-               clear_prefree_segments(sbi, cpc);
+               f2fs_clear_prefree_segments(sbi, cpc);
 
        unblock_operations(sbi);
        stat_inc_cp_count(sbi->stat_info);
@@ -1461,7 +1469,7 @@ int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
        return err;
 }
 
-void init_ino_entry_info(struct f2fs_sb_info *sbi)
+void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi)
 {
        int i;
 
@@ -1479,23 +1487,23 @@ void init_ino_entry_info(struct f2fs_sb_info *sbi)
                                F2FS_ORPHANS_PER_BLOCK;
 }
 
-int __init create_checkpoint_caches(void)
+int __init f2fs_create_checkpoint_caches(void)
 {
        ino_entry_slab = f2fs_kmem_cache_create("f2fs_ino_entry",
                        sizeof(struct ino_entry));
        if (!ino_entry_slab)
                return -ENOMEM;
-       inode_entry_slab = f2fs_kmem_cache_create("f2fs_inode_entry",
+       f2fs_inode_entry_slab = f2fs_kmem_cache_create("f2fs_inode_entry",
                        sizeof(struct inode_entry));
-       if (!inode_entry_slab) {
+       if (!f2fs_inode_entry_slab) {
                kmem_cache_destroy(ino_entry_slab);
                return -ENOMEM;
        }
        return 0;
 }
 
-void destroy_checkpoint_caches(void)
+void f2fs_destroy_checkpoint_caches(void)
 {
        kmem_cache_destroy(ino_entry_slab);
-       kmem_cache_destroy(inode_entry_slab);
+       kmem_cache_destroy(f2fs_inode_entry_slab);
 }
index 02237d4d91f5a3e459114516cf7797f72ddc1daf..8f931d699287af894e0101f7aedd4f4f2ef75d72 100644 (file)
@@ -19,8 +19,6 @@
 #include <linux/bio.h>
 #include <linux/prefetch.h>
 #include <linux/uio.h>
-#include <linux/mm.h>
-#include <linux/memcontrol.h>
 #include <linux/cleancache.h>
 #include <linux/sched/signal.h>
 
 #include "trace.h"
 #include <trace/events/f2fs.h>
 
+#define NUM_PREALLOC_POST_READ_CTXS    128
+
+static struct kmem_cache *bio_post_read_ctx_cache;
+static mempool_t *bio_post_read_ctx_pool;
+
 static bool __is_cp_guaranteed(struct page *page)
 {
        struct address_space *mapping = page->mapping;
@@ -45,16 +48,84 @@ static bool __is_cp_guaranteed(struct page *page)
        if (inode->i_ino == F2FS_META_INO(sbi) ||
                        inode->i_ino ==  F2FS_NODE_INO(sbi) ||
                        S_ISDIR(inode->i_mode) ||
+                       (S_ISREG(inode->i_mode) &&
+                       is_inode_flag_set(inode, FI_ATOMIC_FILE)) ||
                        is_cold_data(page))
                return true;
        return false;
 }
 
-static void f2fs_read_end_io(struct bio *bio)
+/* postprocessing steps for read bios */
+enum bio_post_read_step {
+       STEP_INITIAL = 0,
+       STEP_DECRYPT,
+};
+
+struct bio_post_read_ctx {
+       struct bio *bio;
+       struct work_struct work;
+       unsigned int cur_step;
+       unsigned int enabled_steps;
+};
+
+static void __read_end_io(struct bio *bio)
 {
-       struct bio_vec *bvec;
+       struct page *page;
+       struct bio_vec *bv;
        int i;
 
+       bio_for_each_segment_all(bv, bio, i) {
+               page = bv->bv_page;
+
+               /* PG_error was set if any post_read step failed */
+               if (bio->bi_status || PageError(page)) {
+                       ClearPageUptodate(page);
+                       SetPageError(page);
+               } else {
+                       SetPageUptodate(page);
+               }
+               unlock_page(page);
+       }
+       if (bio->bi_private)
+               mempool_free(bio->bi_private, bio_post_read_ctx_pool);
+       bio_put(bio);
+}
+
+static void bio_post_read_processing(struct bio_post_read_ctx *ctx);
+
+static void decrypt_work(struct work_struct *work)
+{
+       struct bio_post_read_ctx *ctx =
+               container_of(work, struct bio_post_read_ctx, work);
+
+       fscrypt_decrypt_bio(ctx->bio);
+
+       bio_post_read_processing(ctx);
+}
+
+static void bio_post_read_processing(struct bio_post_read_ctx *ctx)
+{
+       switch (++ctx->cur_step) {
+       case STEP_DECRYPT:
+               if (ctx->enabled_steps & (1 << STEP_DECRYPT)) {
+                       INIT_WORK(&ctx->work, decrypt_work);
+                       fscrypt_enqueue_decrypt_work(&ctx->work);
+                       return;
+               }
+               ctx->cur_step++;
+               /* fall-through */
+       default:
+               __read_end_io(ctx->bio);
+       }
+}
+
+static bool f2fs_bio_post_read_required(struct bio *bio)
+{
+       return bio->bi_private && !bio->bi_status;
+}
+
+static void f2fs_read_end_io(struct bio *bio)
+{
 #ifdef CONFIG_F2FS_FAULT_INJECTION
        if (time_to_inject(F2FS_P_SB(bio_first_page_all(bio)), FAULT_IO)) {
                f2fs_show_injection_info(FAULT_IO);
@@ -62,28 +133,15 @@ static void f2fs_read_end_io(struct bio *bio)
        }
 #endif
 
-       if (f2fs_bio_encrypted(bio)) {
-               if (bio->bi_status) {
-                       fscrypt_release_ctx(bio->bi_private);
-               } else {
-                       fscrypt_decrypt_bio_pages(bio->bi_private, bio);
-                       return;
-               }
-       }
-
-       bio_for_each_segment_all(bvec, bio, i) {
-               struct page *page = bvec->bv_page;
+       if (f2fs_bio_post_read_required(bio)) {
+               struct bio_post_read_ctx *ctx = bio->bi_private;
 
-               if (!bio->bi_status) {
-                       if (!PageUptodate(page))
-                               SetPageUptodate(page);
-               } else {
-                       ClearPageUptodate(page);
-                       SetPageError(page);
-               }
-               unlock_page(page);
+               ctx->cur_step = STEP_INITIAL;
+               bio_post_read_processing(ctx);
+               return;
        }
-       bio_put(bio);
+
+       __read_end_io(bio);
 }
 
 static void f2fs_write_end_io(struct bio *bio)
@@ -189,7 +247,7 @@ static struct bio *__bio_alloc(struct f2fs_sb_info *sbi, block_t blk_addr,
        } else {
                bio->bi_end_io = f2fs_write_end_io;
                bio->bi_private = sbi;
-               bio->bi_write_hint = io_type_to_rw_hint(sbi, type, temp);
+               bio->bi_write_hint = f2fs_io_type_to_rw_hint(sbi, type, temp);
        }
        if (wbc)
                wbc_init_bio(wbc, bio);
@@ -404,13 +462,12 @@ int f2fs_submit_page_bio(struct f2fs_io_info *fio)
        return 0;
 }
 
-int f2fs_submit_page_write(struct f2fs_io_info *fio)
+void f2fs_submit_page_write(struct f2fs_io_info *fio)
 {
        struct f2fs_sb_info *sbi = fio->sbi;
        enum page_type btype = PAGE_TYPE_OF_BIO(fio->type);
        struct f2fs_bio_info *io = sbi->write_io[btype] + fio->temp;
        struct page *bio_page;
-       int err = 0;
 
        f2fs_bug_on(sbi, is_read_io(fio->op));
 
@@ -420,7 +477,7 @@ int f2fs_submit_page_write(struct f2fs_io_info *fio)
                spin_lock(&io->io_lock);
                if (list_empty(&io->io_list)) {
                        spin_unlock(&io->io_lock);
-                       goto out_fail;
+                       goto out;
                }
                fio = list_first_entry(&io->io_list,
                                                struct f2fs_io_info, list);
@@ -428,7 +485,7 @@ int f2fs_submit_page_write(struct f2fs_io_info *fio)
                spin_unlock(&io->io_lock);
        }
 
-       if (fio->old_blkaddr != NEW_ADDR)
+       if (is_valid_blkaddr(fio->old_blkaddr))
                verify_block_addr(fio, fio->old_blkaddr);
        verify_block_addr(fio, fio->new_blkaddr);
 
@@ -447,9 +504,9 @@ int f2fs_submit_page_write(struct f2fs_io_info *fio)
        if (io->bio == NULL) {
                if ((fio->type == DATA || fio->type == NODE) &&
                                fio->new_blkaddr & F2FS_IO_SIZE_MASK(sbi)) {
-                       err = -EAGAIN;
                        dec_page_count(sbi, WB_DATA_TYPE(bio_page));
-                       goto out_fail;
+                       fio->retry = true;
+                       goto skip;
                }
                io->bio = __bio_alloc(sbi, fio->new_blkaddr, fio->io_wbc,
                                                BIO_MAX_PAGES, false,
@@ -469,41 +526,44 @@ int f2fs_submit_page_write(struct f2fs_io_info *fio)
        f2fs_trace_ios(fio, 0);
 
        trace_f2fs_submit_page_write(fio->page, fio);
-
+skip:
        if (fio->in_list)
                goto next;
-out_fail:
+out:
        up_write(&io->io_rwsem);
-       return err;
 }
 
 static struct bio *f2fs_grab_read_bio(struct inode *inode, block_t blkaddr,
                                                         unsigned nr_pages)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
-       struct fscrypt_ctx *ctx = NULL;
        struct bio *bio;
-
-       if (f2fs_encrypted_file(inode)) {
-               ctx = fscrypt_get_ctx(inode, GFP_NOFS);
-               if (IS_ERR(ctx))
-                       return ERR_CAST(ctx);
-
-               /* wait the page to be moved by cleaning */
-               f2fs_wait_on_block_writeback(sbi, blkaddr);
-       }
+       struct bio_post_read_ctx *ctx;
+       unsigned int post_read_steps = 0;
 
        bio = f2fs_bio_alloc(sbi, min_t(int, nr_pages, BIO_MAX_PAGES), false);
-       if (!bio) {
-               if (ctx)
-                       fscrypt_release_ctx(ctx);
+       if (!bio)
                return ERR_PTR(-ENOMEM);
-       }
        f2fs_target_device(sbi, blkaddr, bio);
        bio->bi_end_io = f2fs_read_end_io;
-       bio->bi_private = ctx;
        bio_set_op_attrs(bio, REQ_OP_READ, 0);
 
+       if (f2fs_encrypted_file(inode))
+               post_read_steps |= 1 << STEP_DECRYPT;
+       if (post_read_steps) {
+               ctx = mempool_alloc(bio_post_read_ctx_pool, GFP_NOFS);
+               if (!ctx) {
+                       bio_put(bio);
+                       return ERR_PTR(-ENOMEM);
+               }
+               ctx->bio = bio;
+               ctx->enabled_steps = post_read_steps;
+               bio->bi_private = ctx;
+
+               /* wait the page to be moved by cleaning */
+               f2fs_wait_on_block_writeback(sbi, blkaddr);
+       }
+
        return bio;
 }
 
@@ -544,7 +604,7 @@ static void __set_data_blkaddr(struct dnode_of_data *dn)
  *  ->node_page
  *    update block addresses in the node page
  */
-void set_data_blkaddr(struct dnode_of_data *dn)
+void f2fs_set_data_blkaddr(struct dnode_of_data *dn)
 {
        f2fs_wait_on_page_writeback(dn->node_page, NODE, true);
        __set_data_blkaddr(dn);
@@ -555,12 +615,12 @@ void set_data_blkaddr(struct dnode_of_data *dn)
 void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr)
 {
        dn->data_blkaddr = blkaddr;
-       set_data_blkaddr(dn);
+       f2fs_set_data_blkaddr(dn);
        f2fs_update_extent_cache(dn);
 }
 
 /* dn->ofs_in_node will be returned with up-to-date last block pointer */
-int reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)
+int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
        int err;
@@ -594,12 +654,12 @@ int reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count)
 }
 
 /* Should keep dn->ofs_in_node unchanged */
-int reserve_new_block(struct dnode_of_data *dn)
+int f2fs_reserve_new_block(struct dnode_of_data *dn)
 {
        unsigned int ofs_in_node = dn->ofs_in_node;
        int ret;
 
-       ret = reserve_new_blocks(dn, 1);
+       ret = f2fs_reserve_new_blocks(dn, 1);
        dn->ofs_in_node = ofs_in_node;
        return ret;
 }
@@ -609,12 +669,12 @@ int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index)
        bool need_put = dn->inode_page ? false : true;
        int err;
 
-       err = get_dnode_of_data(dn, index, ALLOC_NODE);
+       err = f2fs_get_dnode_of_data(dn, index, ALLOC_NODE);
        if (err)
                return err;
 
        if (dn->data_blkaddr == NULL_ADDR)
-               err = reserve_new_block(dn);
+               err = f2fs_reserve_new_block(dn);
        if (err || need_put)
                f2fs_put_dnode(dn);
        return err;
@@ -633,7 +693,7 @@ int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index)
        return f2fs_reserve_block(dn, index);
 }
 
-struct page *get_read_data_page(struct inode *inode, pgoff_t index,
+struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
                                                int op_flags, bool for_write)
 {
        struct address_space *mapping = inode->i_mapping;
@@ -652,7 +712,7 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index,
        }
 
        set_new_dnode(&dn, inode, NULL, NULL, 0);
-       err = get_dnode_of_data(&dn, index, LOOKUP_NODE);
+       err = f2fs_get_dnode_of_data(&dn, index, LOOKUP_NODE);
        if (err)
                goto put_err;
        f2fs_put_dnode(&dn);
@@ -671,7 +731,8 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index,
         * A new dentry page is allocated but not able to be written, since its
         * new inode page couldn't be allocated due to -ENOSPC.
         * In such the case, its blkaddr can be remained as NEW_ADDR.
-        * see, f2fs_add_link -> get_new_data_page -> init_inode_metadata.
+        * see, f2fs_add_link -> f2fs_get_new_data_page ->
+        * f2fs_init_inode_metadata.
         */
        if (dn.data_blkaddr == NEW_ADDR) {
                zero_user_segment(page, 0, PAGE_SIZE);
@@ -691,7 +752,7 @@ struct page *get_read_data_page(struct inode *inode, pgoff_t index,
        return ERR_PTR(err);
 }
 
-struct page *find_data_page(struct inode *inode, pgoff_t index)
+struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index)
 {
        struct address_space *mapping = inode->i_mapping;
        struct page *page;
@@ -701,7 +762,7 @@ struct page *find_data_page(struct inode *inode, pgoff_t index)
                return page;
        f2fs_put_page(page, 0);
 
-       page = get_read_data_page(inode, index, 0, false);
+       page = f2fs_get_read_data_page(inode, index, 0, false);
        if (IS_ERR(page))
                return page;
 
@@ -721,13 +782,13 @@ struct page *find_data_page(struct inode *inode, pgoff_t index)
  * Because, the callers, functions in dir.c and GC, should be able to know
  * whether this page exists or not.
  */
-struct page *get_lock_data_page(struct inode *inode, pgoff_t index,
+struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
                                                        bool for_write)
 {
        struct address_space *mapping = inode->i_mapping;
        struct page *page;
 repeat:
-       page = get_read_data_page(inode, index, 0, for_write);
+       page = f2fs_get_read_data_page(inode, index, 0, for_write);
        if (IS_ERR(page))
                return page;
 
@@ -753,7 +814,7 @@ struct page *get_lock_data_page(struct inode *inode, pgoff_t index,
  * Note that, ipage is set only by make_empty_dir, and if any error occur,
  * ipage should be released by this function.
  */
-struct page *get_new_data_page(struct inode *inode,
+struct page *f2fs_get_new_data_page(struct inode *inode,
                struct page *ipage, pgoff_t index, bool new_i_size)
 {
        struct address_space *mapping = inode->i_mapping;
@@ -792,7 +853,7 @@ struct page *get_new_data_page(struct inode *inode,
 
                /* if ipage exists, blkaddr should be NEW_ADDR */
                f2fs_bug_on(F2FS_I_SB(inode), ipage);
-               page = get_lock_data_page(inode, index, true);
+               page = f2fs_get_lock_data_page(inode, index, true);
                if (IS_ERR(page))
                        return page;
        }
@@ -824,15 +885,15 @@ static int __allocate_data_block(struct dnode_of_data *dn, int seg_type)
                return err;
 
 alloc:
-       get_node_info(sbi, dn->nid, &ni);
+       f2fs_get_node_info(sbi, dn->nid, &ni);
        set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version);
 
-       allocate_data_block(sbi, NULL, dn->data_blkaddr, &dn->data_blkaddr,
+       f2fs_allocate_data_block(sbi, NULL, dn->data_blkaddr, &dn->data_blkaddr,
                                        &sum, seg_type, NULL, false);
-       set_data_blkaddr(dn);
+       f2fs_set_data_blkaddr(dn);
 
        /* update i_size */
-       fofs = start_bidx_of_node(ofs_of_node(dn->node_page), dn->inode) +
+       fofs = f2fs_start_bidx_of_node(ofs_of_node(dn->node_page), dn->inode) +
                                                        dn->ofs_in_node;
        if (i_size_read(dn->inode) < ((loff_t)(fofs + 1) << PAGE_SHIFT))
                f2fs_i_size_write(dn->inode,
@@ -870,7 +931,7 @@ int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from)
        map.m_seg_type = NO_CHECK_TYPE;
 
        if (direct_io) {
-               map.m_seg_type = rw_hint_to_seg_type(iocb->ki_hint);
+               map.m_seg_type = f2fs_rw_hint_to_seg_type(iocb->ki_hint);
                flag = f2fs_force_buffered_io(inode, WRITE) ?
                                        F2FS_GET_BLOCK_PRE_AIO :
                                        F2FS_GET_BLOCK_PRE_DIO;
@@ -960,7 +1021,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
 
        /* When reading holes, we need its node page */
        set_new_dnode(&dn, inode, NULL, NULL, 0);
-       err = get_dnode_of_data(&dn, pgofs, mode);
+       err = f2fs_get_dnode_of_data(&dn, pgofs, mode);
        if (err) {
                if (flag == F2FS_GET_BLOCK_BMAP)
                        map->m_pblk = 0;
@@ -968,10 +1029,10 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
                        err = 0;
                        if (map->m_next_pgofs)
                                *map->m_next_pgofs =
-                                       get_next_page_offset(&dn, pgofs);
+                                       f2fs_get_next_page_offset(&dn, pgofs);
                        if (map->m_next_extent)
                                *map->m_next_extent =
-                                       get_next_page_offset(&dn, pgofs);
+                                       f2fs_get_next_page_offset(&dn, pgofs);
                }
                goto unlock_out;
        }
@@ -984,7 +1045,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
 next_block:
        blkaddr = datablock_addr(dn.inode, dn.node_page, dn.ofs_in_node);
 
-       if (blkaddr == NEW_ADDR || blkaddr == NULL_ADDR) {
+       if (!is_valid_blkaddr(blkaddr)) {
                if (create) {
                        if (unlikely(f2fs_cp_error(sbi))) {
                                err = -EIO;
@@ -1057,7 +1118,7 @@ int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
                        (pgofs == end || dn.ofs_in_node == end_offset)) {
 
                dn.ofs_in_node = ofs_in_node;
-               err = reserve_new_blocks(&dn, prealloc);
+               err = f2fs_reserve_new_blocks(&dn, prealloc);
                if (err)
                        goto sync_out;
 
@@ -1176,7 +1237,7 @@ static int get_data_block_dio(struct inode *inode, sector_t iblock,
 {
        return __get_data_block(inode, iblock, bh_result, create,
                                                F2FS_GET_BLOCK_DEFAULT, NULL,
-                                               rw_hint_to_seg_type(
+                                               f2fs_rw_hint_to_seg_type(
                                                        inode->i_write_hint));
 }
 
@@ -1221,7 +1282,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
                if (!page)
                        return -ENOMEM;
 
-               get_node_info(sbi, inode->i_ino, &ni);
+               f2fs_get_node_info(sbi, inode->i_ino, &ni);
 
                phys = (__u64)blk_to_logical(inode, ni.blk_addr);
                offset = offsetof(struct f2fs_inode, i_addr) +
@@ -1248,7 +1309,7 @@ static int f2fs_xattr_fiemap(struct inode *inode,
                if (!page)
                        return -ENOMEM;
 
-               get_node_info(sbi, xnid, &ni);
+               f2fs_get_node_info(sbi, xnid, &ni);
 
                phys = (__u64)blk_to_logical(inode, ni.blk_addr);
                len = inode->i_sb->s_blocksize;
@@ -1525,7 +1586,7 @@ static int encrypt_one_page(struct f2fs_io_info *fio)
        if (!f2fs_encrypted_file(inode))
                return 0;
 
-       /* wait for GCed encrypted page writeback */
+       /* wait for GCed page writeback via META_MAPPING */
        f2fs_wait_on_block_writeback(fio->sbi, fio->old_blkaddr);
 
 retry_encrypt:
@@ -1552,12 +1613,12 @@ static inline bool check_inplace_update_policy(struct inode *inode,
 
        if (policy & (0x1 << F2FS_IPU_FORCE))
                return true;
-       if (policy & (0x1 << F2FS_IPU_SSR) && need_SSR(sbi))
+       if (policy & (0x1 << F2FS_IPU_SSR) && f2fs_need_SSR(sbi))
                return true;
        if (policy & (0x1 << F2FS_IPU_UTIL) &&
                        utilization(sbi) > SM_I(sbi)->min_ipu_util)
                return true;
-       if (policy & (0x1 << F2FS_IPU_SSR_UTIL) && need_SSR(sbi) &&
+       if (policy & (0x1 << F2FS_IPU_SSR_UTIL) && f2fs_need_SSR(sbi) &&
                        utilization(sbi) > SM_I(sbi)->min_ipu_util)
                return true;
 
@@ -1578,7 +1639,7 @@ static inline bool check_inplace_update_policy(struct inode *inode,
        return false;
 }
 
-bool should_update_inplace(struct inode *inode, struct f2fs_io_info *fio)
+bool f2fs_should_update_inplace(struct inode *inode, struct f2fs_io_info *fio)
 {
        if (f2fs_is_pinned_file(inode))
                return true;
@@ -1590,7 +1651,7 @@ bool should_update_inplace(struct inode *inode, struct f2fs_io_info *fio)
        return check_inplace_update_policy(inode, fio);
 }
 
-bool should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
+bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
 
@@ -1613,22 +1674,13 @@ static inline bool need_inplace_update(struct f2fs_io_info *fio)
 {
        struct inode *inode = fio->page->mapping->host;
 
-       if (should_update_outplace(inode, fio))
+       if (f2fs_should_update_outplace(inode, fio))
                return false;
 
-       return should_update_inplace(inode, fio);
+       return f2fs_should_update_inplace(inode, fio);
 }
 
-static inline bool valid_ipu_blkaddr(struct f2fs_io_info *fio)
-{
-       if (fio->old_blkaddr == NEW_ADDR)
-               return false;
-       if (fio->old_blkaddr == NULL_ADDR)
-               return false;
-       return true;
-}
-
-int do_write_data_page(struct f2fs_io_info *fio)
+int f2fs_do_write_data_page(struct f2fs_io_info *fio)
 {
        struct page *page = fio->page;
        struct inode *inode = page->mapping->host;
@@ -1642,7 +1694,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
                        f2fs_lookup_extent_cache(inode, page->index, &ei)) {
                fio->old_blkaddr = ei.blk + page->index - ei.fofs;
 
-               if (valid_ipu_blkaddr(fio)) {
+               if (is_valid_blkaddr(fio->old_blkaddr)) {
                        ipu_force = true;
                        fio->need_lock = LOCK_DONE;
                        goto got_it;
@@ -1653,7 +1705,7 @@ int do_write_data_page(struct f2fs_io_info *fio)
        if (fio->need_lock == LOCK_REQ && !f2fs_trylock_op(fio->sbi))
                return -EAGAIN;
 
-       err = get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
+       err = f2fs_get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
        if (err)
                goto out;
 
@@ -1669,16 +1721,18 @@ int do_write_data_page(struct f2fs_io_info *fio)
         * If current allocation needs SSR,
         * it had better in-place writes for updated data.
         */
-       if (ipu_force || (valid_ipu_blkaddr(fio) && need_inplace_update(fio))) {
+       if (ipu_force || (is_valid_blkaddr(fio->old_blkaddr) &&
+                                       need_inplace_update(fio))) {
                err = encrypt_one_page(fio);
                if (err)
                        goto out_writepage;
 
                set_page_writeback(page);
+               ClearPageError(page);
                f2fs_put_dnode(&dn);
                if (fio->need_lock == LOCK_REQ)
                        f2fs_unlock_op(fio->sbi);
-               err = rewrite_data_page(fio);
+               err = f2fs_inplace_write_data(fio);
                trace_f2fs_do_write_data_page(fio->page, IPU);
                set_inode_flag(inode, FI_UPDATE_WRITE);
                return err;
@@ -1697,9 +1751,10 @@ int do_write_data_page(struct f2fs_io_info *fio)
                goto out_writepage;
 
        set_page_writeback(page);
+       ClearPageError(page);
 
        /* LFS mode write path */
-       write_data_page(&dn, fio);
+       f2fs_outplace_write_data(&dn, fio);
        trace_f2fs_do_write_data_page(page, OPU);
        set_inode_flag(inode, FI_APPEND_WRITE);
        if (page->index == 0)
@@ -1745,6 +1800,12 @@ static int __write_data_page(struct page *page, bool *submitted,
        /* we should bypass data pages to proceed the kworkder jobs */
        if (unlikely(f2fs_cp_error(sbi))) {
                mapping_set_error(page->mapping, -EIO);
+               /*
+                * don't drop any dirty dentry pages for keeping lastest
+                * directory structure.
+                */
+               if (S_ISDIR(inode->i_mode))
+                       goto redirty_out;
                goto out;
        }
 
@@ -1769,13 +1830,13 @@ static int __write_data_page(struct page *page, bool *submitted,
        /* we should not write 0'th page having journal header */
        if (f2fs_is_volatile_file(inode) && (!page->index ||
                        (!wbc->for_reclaim &&
-                       available_free_memory(sbi, BASE_CHECK))))
+                       f2fs_available_free_memory(sbi, BASE_CHECK))))
                goto redirty_out;
 
        /* Dentry blocks are controlled by checkpoint */
        if (S_ISDIR(inode->i_mode)) {
                fio.need_lock = LOCK_DONE;
-               err = do_write_data_page(&fio);
+               err = f2fs_do_write_data_page(&fio);
                goto done;
        }
 
@@ -1794,10 +1855,10 @@ static int __write_data_page(struct page *page, bool *submitted,
        }
 
        if (err == -EAGAIN) {
-               err = do_write_data_page(&fio);
+               err = f2fs_do_write_data_page(&fio);
                if (err == -EAGAIN) {
                        fio.need_lock = LOCK_REQ;
-                       err = do_write_data_page(&fio);
+                       err = f2fs_do_write_data_page(&fio);
                }
        }
 
@@ -1822,7 +1883,7 @@ static int __write_data_page(struct page *page, bool *submitted,
        if (wbc->for_reclaim) {
                f2fs_submit_merged_write_cond(sbi, inode, 0, page->index, DATA);
                clear_inode_flag(inode, FI_HOT_DATA);
-               remove_dirty_inode(inode);
+               f2fs_remove_dirty_inode(inode);
                submitted = NULL;
        }
 
@@ -1842,7 +1903,13 @@ static int __write_data_page(struct page *page, bool *submitted,
 
 redirty_out:
        redirty_page_for_writepage(wbc, page);
-       if (!err)
+       /*
+        * pageout() in MM traslates EAGAIN, so calls handle_write_error()
+        * -> mapping_set_error() -> set_bit(AS_EIO, ...).
+        * file_write_and_wait_range() will see EIO error, which is critical
+        * to return value of fsync() followed by atomic_write failure to user.
+        */
+       if (!err || wbc->for_reclaim)
                return AOP_WRITEPAGE_ACTIVATE;
        unlock_page(page);
        return err;
@@ -1866,6 +1933,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
        int ret = 0;
        int done = 0;
        struct pagevec pvec;
+       struct f2fs_sb_info *sbi = F2FS_M_SB(mapping);
        int nr_pages;
        pgoff_t uninitialized_var(writeback_index);
        pgoff_t index;
@@ -1919,6 +1987,13 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
                        struct page *page = pvec.pages[i];
                        bool submitted = false;
 
+                       /* give a priority to WB_SYNC threads */
+                       if (atomic_read(&sbi->wb_sync_req[DATA]) &&
+                                       wbc->sync_mode == WB_SYNC_NONE) {
+                               done = 1;
+                               break;
+                       }
+
                        done_index = page->index;
 retry_write:
                        lock_page(page);
@@ -1973,9 +2048,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
                                last_idx = page->index;
                        }
 
-                       /* give a priority to WB_SYNC threads */
-                       if ((atomic_read(&F2FS_M_SB(mapping)->wb_sync_req) ||
-                                       --wbc->nr_to_write <= 0) &&
+                       if (--wbc->nr_to_write <= 0 &&
                                        wbc->sync_mode == WB_SYNC_NONE) {
                                done = 1;
                                break;
@@ -2001,7 +2074,7 @@ static int f2fs_write_cache_pages(struct address_space *mapping,
        return ret;
 }
 
-int __f2fs_write_data_pages(struct address_space *mapping,
+static int __f2fs_write_data_pages(struct address_space *mapping,
                                                struct writeback_control *wbc,
                                                enum iostat_type io_type)
 {
@@ -2024,7 +2097,7 @@ int __f2fs_write_data_pages(struct address_space *mapping,
 
        if (S_ISDIR(inode->i_mode) && wbc->sync_mode == WB_SYNC_NONE &&
                        get_dirty_pages(inode) < nr_pages_to_skip(sbi, DATA) &&
-                       available_free_memory(sbi, DIRTY_DENTS))
+                       f2fs_available_free_memory(sbi, DIRTY_DENTS))
                goto skip_write;
 
        /* skip writing during file defragment */
@@ -2035,8 +2108,8 @@ int __f2fs_write_data_pages(struct address_space *mapping,
 
        /* to avoid spliting IOs due to mixed WB_SYNC_ALL and WB_SYNC_NONE */
        if (wbc->sync_mode == WB_SYNC_ALL)
-               atomic_inc(&sbi->wb_sync_req);
-       else if (atomic_read(&sbi->wb_sync_req))
+               atomic_inc(&sbi->wb_sync_req[DATA]);
+       else if (atomic_read(&sbi->wb_sync_req[DATA]))
                goto skip_write;
 
        blk_start_plug(&plug);
@@ -2044,13 +2117,13 @@ int __f2fs_write_data_pages(struct address_space *mapping,
        blk_finish_plug(&plug);
 
        if (wbc->sync_mode == WB_SYNC_ALL)
-               atomic_dec(&sbi->wb_sync_req);
+               atomic_dec(&sbi->wb_sync_req[DATA]);
        /*
         * if some pages were truncated, we cannot guarantee its mapping->host
         * to detect pending bios.
         */
 
-       remove_dirty_inode(inode);
+       f2fs_remove_dirty_inode(inode);
        return ret;
 
 skip_write:
@@ -2077,7 +2150,7 @@ static void f2fs_write_failed(struct address_space *mapping, loff_t to)
        if (to > i_size) {
                down_write(&F2FS_I(inode)->i_mmap_sem);
                truncate_pagecache(inode, i_size);
-               truncate_blocks(inode, i_size, true);
+               f2fs_truncate_blocks(inode, i_size, true);
                up_write(&F2FS_I(inode)->i_mmap_sem);
        }
 }
@@ -2109,7 +2182,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
        }
 restart:
        /* check inline_data */
-       ipage = get_node_page(sbi, inode->i_ino);
+       ipage = f2fs_get_node_page(sbi, inode->i_ino);
        if (IS_ERR(ipage)) {
                err = PTR_ERR(ipage);
                goto unlock_out;
@@ -2119,7 +2192,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
 
        if (f2fs_has_inline_data(inode)) {
                if (pos + len <= MAX_INLINE_DATA(inode)) {
-                       read_inline_data(page, ipage);
+                       f2fs_do_read_inline_data(page, ipage);
                        set_inode_flag(inode, FI_DATA_EXIST);
                        if (inode->i_nlink)
                                set_inline_node(ipage);
@@ -2137,7 +2210,7 @@ static int prepare_write_begin(struct f2fs_sb_info *sbi,
                        dn.data_blkaddr = ei.blk + index - ei.fofs;
                } else {
                        /* hole case */
-                       err = get_dnode_of_data(&dn, index, LOOKUP_NODE);
+                       err = f2fs_get_dnode_of_data(&dn, index, LOOKUP_NODE);
                        if (err || dn.data_blkaddr == NULL_ADDR) {
                                f2fs_put_dnode(&dn);
                                __do_map_lock(sbi, F2FS_GET_BLOCK_PRE_AIO,
@@ -2174,7 +2247,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
        trace_f2fs_write_begin(inode, pos, len, flags);
 
        if (f2fs_is_atomic_file(inode) &&
-                       !available_free_memory(sbi, INMEM_PAGES)) {
+                       !f2fs_available_free_memory(sbi, INMEM_PAGES)) {
                err = -ENOMEM;
                drop_atomic = true;
                goto fail;
@@ -2222,8 +2295,8 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
 
        f2fs_wait_on_page_writeback(page, DATA, false);
 
-       /* wait for GCed encrypted page writeback */
-       if (f2fs_encrypted_file(inode))
+       /* wait for GCed page writeback via META_MAPPING */
+       if (f2fs_post_read_required(inode))
                f2fs_wait_on_block_writeback(sbi, blkaddr);
 
        if (len == PAGE_SIZE || PageUptodate(page))
@@ -2258,7 +2331,7 @@ static int f2fs_write_begin(struct file *file, struct address_space *mapping,
        f2fs_put_page(page, 1);
        f2fs_write_failed(mapping, pos + len);
        if (drop_atomic)
-               drop_inmem_pages_all(sbi);
+               f2fs_drop_inmem_pages_all(sbi, false);
        return err;
 }
 
@@ -2333,17 +2406,17 @@ static ssize_t f2fs_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
        if (rw == WRITE && whint_mode == WHINT_MODE_OFF)
                iocb->ki_hint = WRITE_LIFE_NOT_SET;
 
-       if (!down_read_trylock(&F2FS_I(inode)->dio_rwsem[rw])) {
+       if (!down_read_trylock(&F2FS_I(inode)->i_gc_rwsem[rw])) {
                if (iocb->ki_flags & IOCB_NOWAIT) {
                        iocb->ki_hint = hint;
                        err = -EAGAIN;
                        goto out;
                }
-               down_read(&F2FS_I(inode)->dio_rwsem[rw]);
+               down_read(&F2FS_I(inode)->i_gc_rwsem[rw]);
        }
 
        err = blockdev_direct_IO(iocb, inode, iter, get_data_block_dio);
-       up_read(&F2FS_I(inode)->dio_rwsem[rw]);
+       up_read(&F2FS_I(inode)->i_gc_rwsem[rw]);
 
        if (rw == WRITE) {
                if (whint_mode == WHINT_MODE_OFF)
@@ -2380,13 +2453,13 @@ void f2fs_invalidate_page(struct page *page, unsigned int offset,
                        dec_page_count(sbi, F2FS_DIRTY_NODES);
                } else {
                        inode_dec_dirty_pages(inode);
-                       remove_dirty_inode(inode);
+                       f2fs_remove_dirty_inode(inode);
                }
        }
 
        /* This is atomic written page, keep Private */
        if (IS_ATOMIC_WRITTEN_PAGE(page))
-               return drop_inmem_page(inode, page);
+               return f2fs_drop_inmem_page(inode, page);
 
        set_page_private(page, 0);
        ClearPagePrivate(page);
@@ -2407,35 +2480,6 @@ int f2fs_release_page(struct page *page, gfp_t wait)
        return 1;
 }
 
-/*
- * This was copied from __set_page_dirty_buffers which gives higher performance
- * in very high speed storages. (e.g., pmem)
- */
-void f2fs_set_page_dirty_nobuffers(struct page *page)
-{
-       struct address_space *mapping = page->mapping;
-       unsigned long flags;
-
-       if (unlikely(!mapping))
-               return;
-
-       spin_lock(&mapping->private_lock);
-       lock_page_memcg(page);
-       SetPageDirty(page);
-       spin_unlock(&mapping->private_lock);
-
-       xa_lock_irqsave(&mapping->i_pages, flags);
-       WARN_ON_ONCE(!PageUptodate(page));
-       account_page_dirtied(page, mapping);
-       radix_tree_tag_set(&mapping->i_pages,
-                       page_index(page), PAGECACHE_TAG_DIRTY);
-       xa_unlock_irqrestore(&mapping->i_pages, flags);
-       unlock_page_memcg(page);
-
-       __mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
-       return;
-}
-
 static int f2fs_set_data_page_dirty(struct page *page)
 {
        struct address_space *mapping = page->mapping;
@@ -2448,7 +2492,7 @@ static int f2fs_set_data_page_dirty(struct page *page)
 
        if (f2fs_is_atomic_file(inode) && !f2fs_is_commit_atomic_write(inode)) {
                if (!IS_ATOMIC_WRITTEN_PAGE(page)) {
-                       register_inmem_page(inode, page);
+                       f2fs_register_inmem_page(inode, page);
                        return 1;
                }
                /*
@@ -2459,8 +2503,8 @@ static int f2fs_set_data_page_dirty(struct page *page)
        }
 
        if (!PageDirty(page)) {
-               f2fs_set_page_dirty_nobuffers(page);
-               update_dirty_page(inode, page);
+               __set_page_dirty_nobuffers(page);
+               f2fs_update_dirty_page(inode, page);
                return 1;
        }
        return 0;
@@ -2555,3 +2599,38 @@ const struct address_space_operations f2fs_dblock_aops = {
        .migratepage    = f2fs_migrate_page,
 #endif
 };
+
+void f2fs_clear_radix_tree_dirty_tag(struct page *page)
+{
+       struct address_space *mapping = page_mapping(page);
+       unsigned long flags;
+
+       xa_lock_irqsave(&mapping->i_pages, flags);
+       radix_tree_tag_clear(&mapping->i_pages, page_index(page),
+                                               PAGECACHE_TAG_DIRTY);
+       xa_unlock_irqrestore(&mapping->i_pages, flags);
+}
+
+int __init f2fs_init_post_read_processing(void)
+{
+       bio_post_read_ctx_cache = KMEM_CACHE(bio_post_read_ctx, 0);
+       if (!bio_post_read_ctx_cache)
+               goto fail;
+       bio_post_read_ctx_pool =
+               mempool_create_slab_pool(NUM_PREALLOC_POST_READ_CTXS,
+                                        bio_post_read_ctx_cache);
+       if (!bio_post_read_ctx_pool)
+               goto fail_free_cache;
+       return 0;
+
+fail_free_cache:
+       kmem_cache_destroy(bio_post_read_ctx_cache);
+fail:
+       return -ENOMEM;
+}
+
+void __exit f2fs_destroy_post_read_processing(void)
+{
+       mempool_destroy(bio_post_read_ctx_pool);
+       kmem_cache_destroy(bio_post_read_ctx_cache);
+}
index a66107b5cfff98dc5796aac5c7d7b57e5eb26bcb..2d65e77ae5cf92ac17227d532cff1337b10ea2d2 100644 (file)
@@ -104,6 +104,8 @@ static void update_general_status(struct f2fs_sb_info *sbi)
        si->avail_nids = NM_I(sbi)->available_nids;
        si->alloc_nids = NM_I(sbi)->nid_cnt[PREALLOC_NID];
        si->bg_gc = sbi->bg_gc;
+       si->skipped_atomic_files[BG_GC] = sbi->skipped_atomic_files[BG_GC];
+       si->skipped_atomic_files[FG_GC] = sbi->skipped_atomic_files[FG_GC];
        si->util_free = (int)(free_user_blocks(sbi) >> sbi->log_blocks_per_seg)
                * 100 / (int)(sbi->user_block_count >> sbi->log_blocks_per_seg)
                / 2;
@@ -342,6 +344,10 @@ static int stat_show(struct seq_file *s, void *v)
                                si->bg_data_blks);
                seq_printf(s, "  - node blocks : %d (%d)\n", si->node_blks,
                                si->bg_node_blks);
+               seq_printf(s, "Skipped : atomic write %llu (%llu)\n",
+                               si->skipped_atomic_files[BG_GC] +
+                               si->skipped_atomic_files[FG_GC],
+                               si->skipped_atomic_files[BG_GC]);
                seq_puts(s, "\nExtent Cache:\n");
                seq_printf(s, "  - Hit Count: L1-1:%llu L1-2:%llu L2:%llu\n",
                                si->hit_largest, si->hit_cached,
index 8c9c2f31b253cffdacb95984f38513b5cd775ecc..7f955c4e86a45e56a870c2f014ab9eee71fef84b 100644 (file)
@@ -60,12 +60,12 @@ static unsigned char f2fs_type_by_mode[S_IFMT >> S_SHIFT] = {
        [S_IFLNK >> S_SHIFT]    = F2FS_FT_SYMLINK,
 };
 
-void set_de_type(struct f2fs_dir_entry *de, umode_t mode)
+static void set_de_type(struct f2fs_dir_entry *de, umode_t mode)
 {
        de->file_type = f2fs_type_by_mode[(mode & S_IFMT) >> S_SHIFT];
 }
 
-unsigned char get_de_type(struct f2fs_dir_entry *de)
+unsigned char f2fs_get_de_type(struct f2fs_dir_entry *de)
 {
        if (de->file_type < F2FS_FT_MAX)
                return f2fs_filetype_table[de->file_type];
@@ -97,14 +97,14 @@ static struct f2fs_dir_entry *find_in_block(struct page *dentry_page,
        dentry_blk = (struct f2fs_dentry_block *)page_address(dentry_page);
 
        make_dentry_ptr_block(NULL, &d, dentry_blk);
-       de = find_target_dentry(fname, namehash, max_slots, &d);
+       de = f2fs_find_target_dentry(fname, namehash, max_slots, &d);
        if (de)
                *res_page = dentry_page;
 
        return de;
 }
 
-struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *fname,
+struct f2fs_dir_entry *f2fs_find_target_dentry(struct fscrypt_name *fname,
                        f2fs_hash_t namehash, int *max_slots,
                        struct f2fs_dentry_ptr *d)
 {
@@ -171,7 +171,7 @@ static struct f2fs_dir_entry *find_in_level(struct inode *dir,
 
        for (; bidx < end_block; bidx++) {
                /* no need to allocate new dentry pages to all the indices */
-               dentry_page = find_data_page(dir, bidx);
+               dentry_page = f2fs_find_data_page(dir, bidx);
                if (IS_ERR(dentry_page)) {
                        if (PTR_ERR(dentry_page) == -ENOENT) {
                                room = true;
@@ -210,7 +210,7 @@ struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir,
 
        if (f2fs_has_inline_dentry(dir)) {
                *res_page = NULL;
-               de = find_in_inline_dir(dir, fname, res_page);
+               de = f2fs_find_in_inline_dir(dir, fname, res_page);
                goto out;
        }
 
@@ -319,7 +319,7 @@ static void init_dent_inode(const struct qstr *name, struct page *ipage)
        set_page_dirty(ipage);
 }
 
-void do_make_empty_dir(struct inode *inode, struct inode *parent,
+void f2fs_do_make_empty_dir(struct inode *inode, struct inode *parent,
                                        struct f2fs_dentry_ptr *d)
 {
        struct qstr dot = QSTR_INIT(".", 1);
@@ -340,23 +340,23 @@ static int make_empty_dir(struct inode *inode,
        struct f2fs_dentry_ptr d;
 
        if (f2fs_has_inline_dentry(inode))
-               return make_empty_inline_dir(inode, parent, page);
+               return f2fs_make_empty_inline_dir(inode, parent, page);
 
-       dentry_page = get_new_data_page(inode, page, 0, true);
+       dentry_page = f2fs_get_new_data_page(inode, page, 0, true);
        if (IS_ERR(dentry_page))
                return PTR_ERR(dentry_page);
 
        dentry_blk = page_address(dentry_page);
 
        make_dentry_ptr_block(NULL, &d, dentry_blk);
-       do_make_empty_dir(inode, parent, &d);
+       f2fs_do_make_empty_dir(inode, parent, &d);
 
        set_page_dirty(dentry_page);
        f2fs_put_page(dentry_page, 1);
        return 0;
 }
 
-struct page *init_inode_metadata(struct inode *inode, struct inode *dir,
+struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir,
                        const struct qstr *new_name, const struct qstr *orig_name,
                        struct page *dpage)
 {
@@ -365,7 +365,7 @@ struct page *init_inode_metadata(struct inode *inode, struct inode *dir,
        int err;
 
        if (is_inode_flag_set(inode, FI_NEW_INODE)) {
-               page = new_inode_page(inode);
+               page = f2fs_new_inode_page(inode);
                if (IS_ERR(page))
                        return page;
 
@@ -395,7 +395,7 @@ struct page *init_inode_metadata(struct inode *inode, struct inode *dir,
                                goto put_error;
                }
        } else {
-               page = get_node_page(F2FS_I_SB(dir), inode->i_ino);
+               page = f2fs_get_node_page(F2FS_I_SB(dir), inode->i_ino);
                if (IS_ERR(page))
                        return page;
        }
@@ -418,19 +418,19 @@ struct page *init_inode_metadata(struct inode *inode, struct inode *dir,
                 * we should remove this inode from orphan list.
                 */
                if (inode->i_nlink == 0)
-                       remove_orphan_inode(F2FS_I_SB(dir), inode->i_ino);
+                       f2fs_remove_orphan_inode(F2FS_I_SB(dir), inode->i_ino);
                f2fs_i_links_write(inode, true);
        }
        return page;
 
 put_error:
        clear_nlink(inode);
-       update_inode(inode, page);
+       f2fs_update_inode(inode, page);
        f2fs_put_page(page, 1);
        return ERR_PTR(err);
 }
 
-void update_parent_metadata(struct inode *dir, struct inode *inode,
+void f2fs_update_parent_metadata(struct inode *dir, struct inode *inode,
                                                unsigned int current_depth)
 {
        if (inode && is_inode_flag_set(inode, FI_NEW_INODE)) {
@@ -448,7 +448,7 @@ void update_parent_metadata(struct inode *dir, struct inode *inode,
                clear_inode_flag(inode, FI_INC_LINK);
 }
 
-int room_for_filename(const void *bitmap, int slots, int max_slots)
+int f2fs_room_for_filename(const void *bitmap, int slots, int max_slots)
 {
        int bit_start = 0;
        int zero_start, zero_end;
@@ -537,12 +537,12 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
                                (le32_to_cpu(dentry_hash) % nbucket));
 
        for (block = bidx; block <= (bidx + nblock - 1); block++) {
-               dentry_page = get_new_data_page(dir, NULL, block, true);
+               dentry_page = f2fs_get_new_data_page(dir, NULL, block, true);
                if (IS_ERR(dentry_page))
                        return PTR_ERR(dentry_page);
 
                dentry_blk = page_address(dentry_page);
-               bit_pos = room_for_filename(&dentry_blk->dentry_bitmap,
+               bit_pos = f2fs_room_for_filename(&dentry_blk->dentry_bitmap,
                                                slots, NR_DENTRY_IN_BLOCK);
                if (bit_pos < NR_DENTRY_IN_BLOCK)
                        goto add_dentry;
@@ -558,7 +558,7 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
 
        if (inode) {
                down_write(&F2FS_I(inode)->i_sem);
-               page = init_inode_metadata(inode, dir, new_name,
+               page = f2fs_init_inode_metadata(inode, dir, new_name,
                                                orig_name, NULL);
                if (IS_ERR(page)) {
                        err = PTR_ERR(page);
@@ -576,7 +576,7 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
                f2fs_put_page(page, 1);
        }
 
-       update_parent_metadata(dir, inode, current_depth);
+       f2fs_update_parent_metadata(dir, inode, current_depth);
 fail:
        if (inode)
                up_write(&F2FS_I(inode)->i_sem);
@@ -586,7 +586,7 @@ int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
        return err;
 }
 
-int __f2fs_do_add_link(struct inode *dir, struct fscrypt_name *fname,
+int f2fs_add_dentry(struct inode *dir, struct fscrypt_name *fname,
                                struct inode *inode, nid_t ino, umode_t mode)
 {
        struct qstr new_name;
@@ -610,7 +610,7 @@ int __f2fs_do_add_link(struct inode *dir, struct fscrypt_name *fname,
  * Caller should grab and release a rwsem by calling f2fs_lock_op() and
  * f2fs_unlock_op().
  */
-int __f2fs_add_link(struct inode *dir, const struct qstr *name,
+int f2fs_do_add_link(struct inode *dir, const struct qstr *name,
                                struct inode *inode, nid_t ino, umode_t mode)
 {
        struct fscrypt_name fname;
@@ -639,7 +639,7 @@ int __f2fs_add_link(struct inode *dir, const struct qstr *name,
        } else if (IS_ERR(page)) {
                err = PTR_ERR(page);
        } else {
-               err = __f2fs_do_add_link(dir, &fname, inode, ino, mode);
+               err = f2fs_add_dentry(dir, &fname, inode, ino, mode);
        }
        fscrypt_free_filename(&fname);
        return err;
@@ -651,7 +651,7 @@ int f2fs_do_tmpfile(struct inode *inode, struct inode *dir)
        int err = 0;
 
        down_write(&F2FS_I(inode)->i_sem);
-       page = init_inode_metadata(inode, dir, NULL, NULL, NULL);
+       page = f2fs_init_inode_metadata(inode, dir, NULL, NULL, NULL);
        if (IS_ERR(page)) {
                err = PTR_ERR(page);
                goto fail;
@@ -683,9 +683,9 @@ void f2fs_drop_nlink(struct inode *dir, struct inode *inode)
        up_write(&F2FS_I(inode)->i_sem);
 
        if (inode->i_nlink == 0)
-               add_orphan_inode(inode);
+               f2fs_add_orphan_inode(inode);
        else
-               release_orphan_inode(sbi);
+               f2fs_release_orphan_inode(sbi);
 }
 
 /*
@@ -698,14 +698,12 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
        struct  f2fs_dentry_block *dentry_blk;
        unsigned int bit_pos;
        int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
-       struct address_space *mapping = page_mapping(page);
-       unsigned long flags;
        int i;
 
        f2fs_update_time(F2FS_I_SB(dir), REQ_TIME);
 
        if (F2FS_OPTION(F2FS_I_SB(dir)).fsync_mode == FSYNC_MODE_STRICT)
-               add_ino_entry(F2FS_I_SB(dir), dir->i_ino, TRANS_DIR_INO);
+               f2fs_add_ino_entry(F2FS_I_SB(dir), dir->i_ino, TRANS_DIR_INO);
 
        if (f2fs_has_inline_dentry(dir))
                return f2fs_delete_inline_entry(dentry, page, dir, inode);
@@ -731,17 +729,13 @@ void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
                f2fs_drop_nlink(dir, inode);
 
        if (bit_pos == NR_DENTRY_IN_BLOCK &&
-                       !truncate_hole(dir, page->index, page->index + 1)) {
-               xa_lock_irqsave(&mapping->i_pages, flags);
-               radix_tree_tag_clear(&mapping->i_pages, page_index(page),
-                                    PAGECACHE_TAG_DIRTY);
-               xa_unlock_irqrestore(&mapping->i_pages, flags);
-
+               !f2fs_truncate_hole(dir, page->index, page->index + 1)) {
+               f2fs_clear_radix_tree_dirty_tag(page);
                clear_page_dirty_for_io(page);
                ClearPagePrivate(page);
                ClearPageUptodate(page);
                inode_dec_dirty_pages(dir);
-               remove_dirty_inode(dir);
+               f2fs_remove_dirty_inode(dir);
        }
        f2fs_put_page(page, 1);
 }
@@ -758,7 +752,7 @@ bool f2fs_empty_dir(struct inode *dir)
                return f2fs_empty_inline_dir(dir);
 
        for (bidx = 0; bidx < nblock; bidx++) {
-               dentry_page = get_lock_data_page(dir, bidx, false);
+               dentry_page = f2fs_get_lock_data_page(dir, bidx, false);
                if (IS_ERR(dentry_page)) {
                        if (PTR_ERR(dentry_page) == -ENOENT)
                                continue;
@@ -806,7 +800,7 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
                        continue;
                }
 
-               d_type = get_de_type(de);
+               d_type = f2fs_get_de_type(de);
 
                de_name.name = d->filename[bit_pos];
                de_name.len = le16_to_cpu(de->name_len);
@@ -830,7 +824,7 @@ int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
                        return 1;
 
                if (sbi->readdir_ra == 1)
-                       ra_node_page(sbi, le32_to_cpu(de->ino));
+                       f2fs_ra_node_page(sbi, le32_to_cpu(de->ino));
 
                bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
                ctx->pos = start_pos + bit_pos;
@@ -880,7 +874,7 @@ static int f2fs_readdir(struct file *file, struct dir_context *ctx)
                        page_cache_sync_readahead(inode->i_mapping, ra, file, n,
                                min(npages - n, (pgoff_t)MAX_DIR_RA_PAGES));
 
-               dentry_page = get_lock_data_page(inode, n, false);
+               dentry_page = f2fs_get_lock_data_page(inode, n, false);
                if (IS_ERR(dentry_page)) {
                        err = PTR_ERR(dentry_page);
                        if (err == -ENOENT) {
index d5a861bf2b42ad1a931ca2de3bd26586e1843e90..231b77ef5a53bffef1e9ce8ab5cfe98a99b6c8c3 100644 (file)
@@ -49,7 +49,7 @@ static struct rb_entry *__lookup_rb_tree_slow(struct rb_root *root,
        return NULL;
 }
 
-struct rb_entry *__lookup_rb_tree(struct rb_root *root,
+struct rb_entry *f2fs_lookup_rb_tree(struct rb_root *root,
                                struct rb_entry *cached_re, unsigned int ofs)
 {
        struct rb_entry *re;
@@ -61,7 +61,7 @@ struct rb_entry *__lookup_rb_tree(struct rb_root *root,
        return re;
 }
 
-struct rb_node **__lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,
+struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,
                                struct rb_root *root, struct rb_node **parent,
                                unsigned int ofs)
 {
@@ -92,7 +92,7 @@ struct rb_node **__lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,
  * in order to simpfy the insertion after.
  * tree must stay unchanged between lookup and insertion.
  */
-struct rb_entry *__lookup_rb_tree_ret(struct rb_root *root,
+struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root *root,
                                struct rb_entry *cached_re,
                                unsigned int ofs,
                                struct rb_entry **prev_entry,
@@ -159,7 +159,7 @@ struct rb_entry *__lookup_rb_tree_ret(struct rb_root *root,
        return re;
 }
 
-bool __check_rb_tree_consistence(struct f2fs_sb_info *sbi,
+bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi,
                                                struct rb_root *root)
 {
 #ifdef CONFIG_F2FS_CHECK_FS
@@ -390,7 +390,7 @@ static bool f2fs_lookup_extent_tree(struct inode *inode, pgoff_t pgofs,
                goto out;
        }
 
-       en = (struct extent_node *)__lookup_rb_tree(&et->root,
+       en = (struct extent_node *)f2fs_lookup_rb_tree(&et->root,
                                (struct rb_entry *)et->cached_en, pgofs);
        if (!en)
                goto out;
@@ -470,7 +470,7 @@ static struct extent_node *__insert_extent_tree(struct inode *inode,
                goto do_insert;
        }
 
-       p = __lookup_rb_tree_for_insert(sbi, &et->root, &parent, ei->fofs);
+       p = f2fs_lookup_rb_tree_for_insert(sbi, &et->root, &parent, ei->fofs);
 do_insert:
        en = __attach_extent_node(sbi, et, ei, parent, p);
        if (!en)
@@ -520,7 +520,7 @@ static void f2fs_update_extent_tree_range(struct inode *inode,
        __drop_largest_extent(inode, fofs, len);
 
        /* 1. lookup first extent node in range [fofs, fofs + len - 1] */
-       en = (struct extent_node *)__lookup_rb_tree_ret(&et->root,
+       en = (struct extent_node *)f2fs_lookup_rb_tree_ret(&et->root,
                                        (struct rb_entry *)et->cached_en, fofs,
                                        (struct rb_entry **)&prev_en,
                                        (struct rb_entry **)&next_en,
@@ -773,7 +773,7 @@ void f2fs_update_extent_cache(struct dnode_of_data *dn)
        else
                blkaddr = dn->data_blkaddr;
 
-       fofs = start_bidx_of_node(ofs_of_node(dn->node_page), dn->inode) +
+       fofs = f2fs_start_bidx_of_node(ofs_of_node(dn->node_page), dn->inode) +
                                                                dn->ofs_in_node;
        f2fs_update_extent_tree_range(dn->inode, fofs, blkaddr, 1);
 }
@@ -788,7 +788,7 @@ void f2fs_update_extent_cache_range(struct dnode_of_data *dn,
        f2fs_update_extent_tree_range(dn->inode, fofs, blkaddr, len);
 }
 
-void init_extent_cache_info(struct f2fs_sb_info *sbi)
+void f2fs_init_extent_cache_info(struct f2fs_sb_info *sbi)
 {
        INIT_RADIX_TREE(&sbi->extent_tree_root, GFP_NOIO);
        mutex_init(&sbi->extent_tree_lock);
@@ -800,7 +800,7 @@ void init_extent_cache_info(struct f2fs_sb_info *sbi)
        atomic_set(&sbi->total_ext_node, 0);
 }
 
-int __init create_extent_cache(void)
+int __init f2fs_create_extent_cache(void)
 {
        extent_tree_slab = f2fs_kmem_cache_create("f2fs_extent_tree",
                        sizeof(struct extent_tree));
@@ -815,7 +815,7 @@ int __init create_extent_cache(void)
        return 0;
 }
 
-void destroy_extent_cache(void)
+void f2fs_destroy_extent_cache(void)
 {
        kmem_cache_destroy(extent_node_slab);
        kmem_cache_destroy(extent_tree_slab);
index 1df7f10476d6852a4f054243cb44af8c3bb2c835..4d8b1de831439ae8b6e4c493a388ef5045224225 100644 (file)
@@ -176,15 +176,13 @@ enum {
 #define        CP_DISCARD      0x00000010
 #define CP_TRIMMED     0x00000020
 
-#define DEF_BATCHED_TRIM_SECTIONS      2048
-#define BATCHED_TRIM_SEGMENTS(sbi)     \
-               (GET_SEG_FROM_SEC(sbi, SM_I(sbi)->trim_sections))
-#define BATCHED_TRIM_BLOCKS(sbi)       \
-               (BATCHED_TRIM_SEGMENTS(sbi) << (sbi)->log_blocks_per_seg)
 #define MAX_DISCARD_BLOCKS(sbi)                BLKS_PER_SEC(sbi)
 #define DEF_MAX_DISCARD_REQUEST                8       /* issue 8 discards per round */
+#define DEF_MAX_DISCARD_LEN            512     /* Max. 2MB per discard */
 #define DEF_MIN_DISCARD_ISSUE_TIME     50      /* 50 ms, if exists */
+#define DEF_MID_DISCARD_ISSUE_TIME     500     /* 500 ms, if device busy */
 #define DEF_MAX_DISCARD_ISSUE_TIME     60000   /* 60 s, if no candidates */
+#define DEF_DISCARD_URGENT_UTIL                80      /* do more discard over 80% */
 #define DEF_CP_INTERVAL                        60      /* 60 secs */
 #define DEF_IDLE_INTERVAL              5       /* 5 secs */
 
@@ -285,6 +283,7 @@ enum {
 struct discard_policy {
        int type;                       /* type of discard */
        unsigned int min_interval;      /* used for candidates exist */
+       unsigned int mid_interval;      /* used for device busy */
        unsigned int max_interval;      /* used for candidates not exist */
        unsigned int max_requests;      /* # of discards issued per round */
        unsigned int io_aware_gran;     /* minimum granularity discard not be aware of I/O */
@@ -620,15 +619,20 @@ enum {
 
 #define DEF_DIR_LEVEL          0
 
+enum {
+       GC_FAILURE_PIN,
+       GC_FAILURE_ATOMIC,
+       MAX_GC_FAILURE
+};
+
 struct f2fs_inode_info {
        struct inode vfs_inode;         /* serve a vfs inode */
        unsigned long i_flags;          /* keep an inode flags for ioctl */
        unsigned char i_advise;         /* use to give file attribute hints */
        unsigned char i_dir_level;      /* use for dentry level for large dir */
-       union {
-               unsigned int i_current_depth;   /* only for directory depth */
-               unsigned short i_gc_failures;   /* only for regular file */
-       };
+       unsigned int i_current_depth;   /* only for directory depth */
+       /* for gc failure statistic */
+       unsigned int i_gc_failures[MAX_GC_FAILURE];
        unsigned int i_pino;            /* parent inode number */
        umode_t i_acl_mode;             /* keep file acl mode temporarily */
 
@@ -656,7 +660,9 @@ struct f2fs_inode_info {
        struct task_struct *inmem_task; /* store inmemory task */
        struct mutex inmem_lock;        /* lock for inmemory pages */
        struct extent_tree *extent_tree;        /* cached extent_tree entry */
-       struct rw_semaphore dio_rwsem[2];/* avoid racing between dio and gc */
+
+       /* avoid racing between foreground op and gc */
+       struct rw_semaphore i_gc_rwsem[2];
        struct rw_semaphore i_mmap_sem;
        struct rw_semaphore i_xattr_sem; /* avoid racing between reading and changing EAs */
 
@@ -694,7 +700,8 @@ static inline void set_extent_info(struct extent_info *ei, unsigned int fofs,
 static inline bool __is_discard_mergeable(struct discard_info *back,
                                                struct discard_info *front)
 {
-       return back->lstart + back->len == front->lstart;
+       return (back->lstart + back->len == front->lstart) &&
+               (back->len + front->len < DEF_MAX_DISCARD_LEN);
 }
 
 static inline bool __is_discard_back_mergeable(struct discard_info *cur,
@@ -1005,6 +1012,7 @@ struct f2fs_io_info {
        int need_lock;          /* indicate we need to lock cp_rwsem */
        bool in_list;           /* indicate fio is in io_list */
        bool is_meta;           /* indicate borrow meta inode mapping or not */
+       bool retry;             /* need to reallocate block address */
        enum iostat_type io_type;       /* io type */
        struct writeback_control *io_wbc; /* writeback control */
 };
@@ -1066,6 +1074,13 @@ enum {
        MAX_TIME,
 };
 
+enum {
+       GC_NORMAL,
+       GC_IDLE_CB,
+       GC_IDLE_GREEDY,
+       GC_URGENT,
+};
+
 enum {
        WHINT_MODE_OFF,         /* not pass down write hints */
        WHINT_MODE_USER,        /* try to pass down hints given by users */
@@ -1080,6 +1095,7 @@ enum {
 enum fsync_mode {
        FSYNC_MODE_POSIX,       /* fsync follows posix semantics */
        FSYNC_MODE_STRICT,      /* fsync behaves in line with ext4 */
+       FSYNC_MODE_NOBARRIER,   /* fsync behaves nobarrier based on posix */
 };
 
 #ifdef CONFIG_F2FS_FS_ENCRYPTION
@@ -1113,6 +1129,8 @@ struct f2fs_sb_info {
        struct f2fs_bio_info *write_io[NR_PAGE_TYPE];   /* for write bios */
        struct mutex wio_mutex[NR_PAGE_TYPE - 1][NR_TEMP_TYPE];
                                                /* bio ordering for NODE/DATA */
+       /* keep migration IO order for LFS mode */
+       struct rw_semaphore io_order_lock;
        mempool_t *write_io_dummy;              /* Dummy pages */
 
        /* for checkpoint */
@@ -1183,7 +1201,7 @@ struct f2fs_sb_info {
        struct percpu_counter alloc_valid_block_count;
 
        /* writeback control */
-       atomic_t wb_sync_req;                   /* count # of WB_SYNC threads */
+       atomic_t wb_sync_req[META];     /* count # of WB_SYNC threads */
 
        /* valid inode count */
        struct percpu_counter total_valid_inode_count;
@@ -1194,9 +1212,9 @@ struct f2fs_sb_info {
        struct mutex gc_mutex;                  /* mutex for GC */
        struct f2fs_gc_kthread  *gc_thread;     /* GC thread */
        unsigned int cur_victim_sec;            /* current victim section num */
-
-       /* threshold for converting bg victims for fg */
-       u64 fggc_threshold;
+       unsigned int gc_mode;                   /* current GC state */
+       /* for skip statistic */
+       unsigned long long skipped_atomic_files[2];     /* FG_GC and BG_GC */
 
        /* threshold for gc trials on pinned files */
        u64 gc_pin_file_threshold;
@@ -1586,18 +1604,6 @@ static inline bool __exist_node_summaries(struct f2fs_sb_info *sbi)
                        is_set_ckpt_flags(sbi, CP_FASTBOOT_FLAG));
 }
 
-/*
- * Check whether the given nid is within node id range.
- */
-static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
-{
-       if (unlikely(nid < F2FS_ROOT_INO(sbi)))
-               return -EINVAL;
-       if (unlikely(nid >= NM_I(sbi)->max_nid))
-               return -EINVAL;
-       return 0;
-}
-
 /*
  * Check whether the inode has blocks or not
  */
@@ -1614,7 +1620,7 @@ static inline bool f2fs_has_xattr_block(unsigned int ofs)
 }
 
 static inline bool __allow_reserved_blocks(struct f2fs_sb_info *sbi,
-                                       struct inode *inode)
+                                       struct inode *inode, bool cap)
 {
        if (!inode)
                return true;
@@ -1627,7 +1633,7 @@ static inline bool __allow_reserved_blocks(struct f2fs_sb_info *sbi,
        if (!gid_eq(F2FS_OPTION(sbi).s_resgid, GLOBAL_ROOT_GID) &&
                                        in_group_p(F2FS_OPTION(sbi).s_resgid))
                return true;
-       if (capable(CAP_SYS_RESOURCE))
+       if (cap && capable(CAP_SYS_RESOURCE))
                return true;
        return false;
 }
@@ -1662,7 +1668,7 @@ static inline int inc_valid_block_count(struct f2fs_sb_info *sbi,
        avail_user_block_count = sbi->user_block_count -
                                        sbi->current_reserved_blocks;
 
-       if (!__allow_reserved_blocks(sbi, inode))
+       if (!__allow_reserved_blocks(sbi, inode, true))
                avail_user_block_count -= F2FS_OPTION(sbi).root_reserved_blocks;
 
        if (unlikely(sbi->total_valid_block_count > avail_user_block_count)) {
@@ -1869,7 +1875,7 @@ static inline int inc_valid_node_count(struct f2fs_sb_info *sbi,
        valid_block_count = sbi->total_valid_block_count +
                                        sbi->current_reserved_blocks + 1;
 
-       if (!__allow_reserved_blocks(sbi, inode))
+       if (!__allow_reserved_blocks(sbi, inode, false))
                valid_block_count += F2FS_OPTION(sbi).root_reserved_blocks;
 
        if (unlikely(valid_block_count > sbi->user_block_count)) {
@@ -2156,9 +2162,60 @@ static inline void f2fs_change_bit(unsigned int nr, char *addr)
        *addr ^= mask;
 }
 
-#define F2FS_REG_FLMASK                (~(FS_DIRSYNC_FL | FS_TOPDIR_FL))
-#define F2FS_OTHER_FLMASK      (FS_NODUMP_FL | FS_NOATIME_FL)
-#define F2FS_FL_INHERITED      (FS_PROJINHERIT_FL)
+/*
+ * Inode flags
+ */
+#define F2FS_SECRM_FL                  0x00000001 /* Secure deletion */
+#define F2FS_UNRM_FL                   0x00000002 /* Undelete */
+#define F2FS_COMPR_FL                  0x00000004 /* Compress file */
+#define F2FS_SYNC_FL                   0x00000008 /* Synchronous updates */
+#define F2FS_IMMUTABLE_FL              0x00000010 /* Immutable file */
+#define F2FS_APPEND_FL                 0x00000020 /* writes to file may only append */
+#define F2FS_NODUMP_FL                 0x00000040 /* do not dump file */
+#define F2FS_NOATIME_FL                        0x00000080 /* do not update atime */
+/* Reserved for compression usage... */
+#define F2FS_DIRTY_FL                  0x00000100
+#define F2FS_COMPRBLK_FL               0x00000200 /* One or more compressed clusters */
+#define F2FS_NOCOMPR_FL                        0x00000400 /* Don't compress */
+#define F2FS_ENCRYPT_FL                        0x00000800 /* encrypted file */
+/* End compression flags --- maybe not all used */
+#define F2FS_INDEX_FL                  0x00001000 /* hash-indexed directory */
+#define F2FS_IMAGIC_FL                 0x00002000 /* AFS directory */
+#define F2FS_JOURNAL_DATA_FL           0x00004000 /* file data should be journaled */
+#define F2FS_NOTAIL_FL                 0x00008000 /* file tail should not be merged */
+#define F2FS_DIRSYNC_FL                        0x00010000 /* dirsync behaviour (directories only) */
+#define F2FS_TOPDIR_FL                 0x00020000 /* Top of directory hierarchies*/
+#define F2FS_HUGE_FILE_FL               0x00040000 /* Set to each huge file */
+#define F2FS_EXTENTS_FL                        0x00080000 /* Inode uses extents */
+#define F2FS_EA_INODE_FL               0x00200000 /* Inode used for large EA */
+#define F2FS_EOFBLOCKS_FL              0x00400000 /* Blocks allocated beyond EOF */
+#define F2FS_INLINE_DATA_FL            0x10000000 /* Inode has inline data. */
+#define F2FS_PROJINHERIT_FL            0x20000000 /* Create with parents projid */
+#define F2FS_RESERVED_FL               0x80000000 /* reserved for ext4 lib */
+
+#define F2FS_FL_USER_VISIBLE           0x304BDFFF /* User visible flags */
+#define F2FS_FL_USER_MODIFIABLE                0x204BC0FF /* User modifiable flags */
+
+/* Flags we can manipulate with through F2FS_IOC_FSSETXATTR */
+#define F2FS_FL_XFLAG_VISIBLE          (F2FS_SYNC_FL | \
+                                        F2FS_IMMUTABLE_FL | \
+                                        F2FS_APPEND_FL | \
+                                        F2FS_NODUMP_FL | \
+                                        F2FS_NOATIME_FL | \
+                                        F2FS_PROJINHERIT_FL)
+
+/* Flags that should be inherited by new inodes from their parent. */
+#define F2FS_FL_INHERITED (F2FS_SECRM_FL | F2FS_UNRM_FL | F2FS_COMPR_FL |\
+                          F2FS_SYNC_FL | F2FS_NODUMP_FL | F2FS_NOATIME_FL |\
+                          F2FS_NOCOMPR_FL | F2FS_JOURNAL_DATA_FL |\
+                          F2FS_NOTAIL_FL | F2FS_DIRSYNC_FL |\
+                          F2FS_PROJINHERIT_FL)
+
+/* Flags that are appropriate for regular files (all but dir-specific ones). */
+#define F2FS_REG_FLMASK                (~(F2FS_DIRSYNC_FL | F2FS_TOPDIR_FL))
+
+/* Flags that are appropriate for non-directories/regular files. */
+#define F2FS_OTHER_FLMASK      (F2FS_NODUMP_FL | F2FS_NOATIME_FL)
 
 static inline __u32 f2fs_mask_flags(umode_t mode, __u32 flags)
 {
@@ -2201,6 +2258,7 @@ enum {
        FI_EXTRA_ATTR,          /* indicate file has extra attribute */
        FI_PROJ_INHERIT,        /* indicate file inherits projectid */
        FI_PIN_FILE,            /* indicate file should not be gced */
+       FI_ATOMIC_REVOKE_REQUEST, /* request to drop atomic data */
 };
 
 static inline void __mark_inode_dirty_flag(struct inode *inode,
@@ -2299,7 +2357,7 @@ static inline void f2fs_i_depth_write(struct inode *inode, unsigned int depth)
 static inline void f2fs_i_gc_failures_write(struct inode *inode,
                                        unsigned int count)
 {
-       F2FS_I(inode)->i_gc_failures = count;
+       F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN] = count;
        f2fs_mark_inode_dirty_sync(inode, true);
 }
 
@@ -2460,6 +2518,7 @@ static inline void clear_file(struct inode *inode, int type)
 
 static inline bool f2fs_skip_inode_update(struct inode *inode, int dsync)
 {
+       struct timespec ts;
        bool ret;
 
        if (dsync) {
@@ -2475,11 +2534,14 @@ static inline bool f2fs_skip_inode_update(struct inode *inode, int dsync)
                        i_size_read(inode) & ~PAGE_MASK)
                return false;
 
-       if (!timespec_equal(F2FS_I(inode)->i_disk_time, &inode->i_atime))
+       ts = timespec64_to_timespec(inode->i_atime);
+       if (!timespec_equal(F2FS_I(inode)->i_disk_time, &ts))
                return false;
-       if (!timespec_equal(F2FS_I(inode)->i_disk_time + 1, &inode->i_ctime))
+       ts = timespec64_to_timespec(inode->i_ctime);
+       if (!timespec_equal(F2FS_I(inode)->i_disk_time + 1, &ts))
                return false;
-       if (!timespec_equal(F2FS_I(inode)->i_disk_time + 2, &inode->i_mtime))
+       ts = timespec64_to_timespec(inode->i_mtime);
+       if (!timespec_equal(F2FS_I(inode)->i_disk_time + 2, &ts))
                return false;
        if (!timespec_equal(F2FS_I(inode)->i_disk_time + 3,
                                                &F2FS_I(inode)->i_crtime))
@@ -2568,7 +2630,7 @@ static inline int get_inline_xattr_addrs(struct inode *inode)
        return F2FS_I(inode)->i_inline_xattr_size;
 }
 
-#define get_inode_mode(i) \
+#define f2fs_get_inode_mode(i) \
        ((is_inode_flag_set(i, FI_ACL_MODE)) ? \
         (F2FS_I(i)->i_acl_mode) : ((i)->i_mode))
 
@@ -2607,18 +2669,25 @@ static inline void f2fs_update_iostat(struct f2fs_sb_info *sbi,
        spin_unlock(&sbi->iostat_lock);
 }
 
+static inline bool is_valid_blkaddr(block_t blkaddr)
+{
+       if (blkaddr == NEW_ADDR || blkaddr == NULL_ADDR)
+               return false;
+       return true;
+}
+
 /*
  * file.c
  */
 int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);
-void truncate_data_blocks(struct dnode_of_data *dn);
-int truncate_blocks(struct inode *inode, u64 from, bool lock);
+void f2fs_truncate_data_blocks(struct dnode_of_data *dn);
+int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock);
 int f2fs_truncate(struct inode *inode);
 int f2fs_getattr(const struct path *path, struct kstat *stat,
                        u32 request_mask, unsigned int flags);
 int f2fs_setattr(struct dentry *dentry, struct iattr *attr);
-int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end);
-void truncate_data_blocks_range(struct dnode_of_data *dn, int count);
+int f2fs_truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end);
+void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count);
 int f2fs_precache_extents(struct inode *inode);
 long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
 long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
@@ -2632,38 +2701,37 @@ bool f2fs_inode_chksum_verify(struct f2fs_sb_info *sbi, struct page *page);
 void f2fs_inode_chksum_set(struct f2fs_sb_info *sbi, struct page *page);
 struct inode *f2fs_iget(struct super_block *sb, unsigned long ino);
 struct inode *f2fs_iget_retry(struct super_block *sb, unsigned long ino);
-int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink);
-void update_inode(struct inode *inode, struct page *node_page);
-void update_inode_page(struct inode *inode);
+int f2fs_try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink);
+void f2fs_update_inode(struct inode *inode, struct page *node_page);
+void f2fs_update_inode_page(struct inode *inode);
 int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc);
 void f2fs_evict_inode(struct inode *inode);
-void handle_failed_inode(struct inode *inode);
+void f2fs_handle_failed_inode(struct inode *inode);
 
 /*
  * namei.c
  */
-int update_extension_list(struct f2fs_sb_info *sbi, const char *name,
+int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
                                                        bool hot, bool set);
 struct dentry *f2fs_get_parent(struct dentry *child);
 
 /*
  * dir.c
  */
-void set_de_type(struct f2fs_dir_entry *de, umode_t mode);
-unsigned char get_de_type(struct f2fs_dir_entry *de);
-struct f2fs_dir_entry *find_target_dentry(struct fscrypt_name *fname,
+unsigned char f2fs_get_de_type(struct f2fs_dir_entry *de);
+struct f2fs_dir_entry *f2fs_find_target_dentry(struct fscrypt_name *fname,
                        f2fs_hash_t namehash, int *max_slots,
                        struct f2fs_dentry_ptr *d);
 int f2fs_fill_dentries(struct dir_context *ctx, struct f2fs_dentry_ptr *d,
                        unsigned int start_pos, struct fscrypt_str *fstr);
-void do_make_empty_dir(struct inode *inode, struct inode *parent,
+void f2fs_do_make_empty_dir(struct inode *inode, struct inode *parent,
                        struct f2fs_dentry_ptr *d);
-struct page *init_inode_metadata(struct inode *inode, struct inode *dir,
+struct page *f2fs_init_inode_metadata(struct inode *inode, struct inode *dir,
                        const struct qstr *new_name,
                        const struct qstr *orig_name, struct page *dpage);
-void update_parent_metadata(struct inode *dir, struct inode *inode,
+void f2fs_update_parent_metadata(struct inode *dir, struct inode *inode,
                        unsigned int current_depth);
-int room_for_filename(const void *bitmap, int slots, int max_slots);
+int f2fs_room_for_filename(const void *bitmap, int slots, int max_slots);
 void f2fs_drop_nlink(struct inode *dir, struct inode *inode);
 struct f2fs_dir_entry *__f2fs_find_entry(struct inode *dir,
                        struct fscrypt_name *fname, struct page **res_page);
@@ -2680,9 +2748,9 @@ void f2fs_update_dentry(nid_t ino, umode_t mode, struct f2fs_dentry_ptr *d,
 int f2fs_add_regular_entry(struct inode *dir, const struct qstr *new_name,
                        const struct qstr *orig_name,
                        struct inode *inode, nid_t ino, umode_t mode);
-int __f2fs_do_add_link(struct inode *dir, struct fscrypt_name *fname,
+int f2fs_add_dentry(struct inode *dir, struct fscrypt_name *fname,
                        struct inode *inode, nid_t ino, umode_t mode);
-int __f2fs_add_link(struct inode *dir, const struct qstr *name,
+int f2fs_do_add_link(struct inode *dir, const struct qstr *name,
                        struct inode *inode, nid_t ino, umode_t mode);
 void f2fs_delete_entry(struct f2fs_dir_entry *dentry, struct page *page,
                        struct inode *dir, struct inode *inode);
@@ -2691,7 +2759,7 @@ bool f2fs_empty_dir(struct inode *dir);
 
 static inline int f2fs_add_link(struct dentry *dentry, struct inode *inode)
 {
-       return __f2fs_add_link(d_inode(dentry->d_parent), &dentry->d_name,
+       return f2fs_do_add_link(d_inode(dentry->d_parent), &dentry->d_name,
                                inode, inode->i_ino, inode->i_mode);
 }
 
@@ -2706,7 +2774,7 @@ int f2fs_commit_super(struct f2fs_sb_info *sbi, bool recover);
 int f2fs_sync_fs(struct super_block *sb, int sync);
 extern __printf(3, 4)
 void f2fs_msg(struct super_block *sb, const char *level, const char *fmt, ...);
-int sanity_check_ckpt(struct f2fs_sb_info *sbi);
+int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi);
 
 /*
  * hash.c
@@ -2720,179 +2788,183 @@ f2fs_hash_t f2fs_dentry_hash(const struct qstr *name_info,
 struct dnode_of_data;
 struct node_info;
 
-bool available_free_memory(struct f2fs_sb_info *sbi, int type);
-int need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid);
-bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid);
-bool need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino);
-void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni);
-pgoff_t get_next_page_offset(struct dnode_of_data *dn, pgoff_t pgofs);
-int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode);
-int truncate_inode_blocks(struct inode *inode, pgoff_t from);
-int truncate_xattr_node(struct inode *inode);
-int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino);
-int remove_inode_page(struct inode *inode);
-struct page *new_inode_page(struct inode *inode);
-struct page *new_node_page(struct dnode_of_data *dn, unsigned int ofs);
-void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid);
-struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid);
-struct page *get_node_page_ra(struct page *parent, int start);
-void move_node_page(struct page *node_page, int gc_type);
-int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
+int f2fs_check_nid_range(struct f2fs_sb_info *sbi, nid_t nid);
+bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type);
+int f2fs_need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid);
+bool f2fs_is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid);
+bool f2fs_need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino);
+void f2fs_get_node_info(struct f2fs_sb_info *sbi, nid_t nid,
+                                               struct node_info *ni);
+pgoff_t f2fs_get_next_page_offset(struct dnode_of_data *dn, pgoff_t pgofs);
+int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode);
+int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from);
+int f2fs_truncate_xattr_node(struct inode *inode);
+int f2fs_wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino);
+int f2fs_remove_inode_page(struct inode *inode);
+struct page *f2fs_new_inode_page(struct inode *inode);
+struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs);
+void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid);
+struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid);
+struct page *f2fs_get_node_page_ra(struct page *parent, int start);
+void f2fs_move_node_page(struct page *node_page, int gc_type);
+int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
                        struct writeback_control *wbc, bool atomic);
-int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc,
+int f2fs_sync_node_pages(struct f2fs_sb_info *sbi,
+                       struct writeback_control *wbc,
                        bool do_balance, enum iostat_type io_type);
-void build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount);
-bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid);
-void alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid);
-void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid);
-int try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink);
-void recover_inline_xattr(struct inode *inode, struct page *page);
-int recover_xattr_data(struct inode *inode, struct page *page);
-int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page);
-void restore_node_summary(struct f2fs_sb_info *sbi,
+void f2fs_build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount);
+bool f2fs_alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid);
+void f2fs_alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid);
+void f2fs_alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid);
+int f2fs_try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink);
+void f2fs_recover_inline_xattr(struct inode *inode, struct page *page);
+int f2fs_recover_xattr_data(struct inode *inode, struct page *page);
+int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page);
+void f2fs_restore_node_summary(struct f2fs_sb_info *sbi,
                        unsigned int segno, struct f2fs_summary_block *sum);
-void flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc);
-int build_node_manager(struct f2fs_sb_info *sbi);
-void destroy_node_manager(struct f2fs_sb_info *sbi);
-int __init create_node_manager_caches(void);
-void destroy_node_manager_caches(void);
+void f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc);
+int f2fs_build_node_manager(struct f2fs_sb_info *sbi);
+void f2fs_destroy_node_manager(struct f2fs_sb_info *sbi);
+int __init f2fs_create_node_manager_caches(void);
+void f2fs_destroy_node_manager_caches(void);
 
 /*
  * segment.c
  */
-bool need_SSR(struct f2fs_sb_info *sbi);
-void register_inmem_page(struct inode *inode, struct page *page);
-void drop_inmem_pages_all(struct f2fs_sb_info *sbi);
-void drop_inmem_pages(struct inode *inode);
-void drop_inmem_page(struct inode *inode, struct page *page);
-int commit_inmem_pages(struct inode *inode);
+bool f2fs_need_SSR(struct f2fs_sb_info *sbi);
+void f2fs_register_inmem_page(struct inode *inode, struct page *page);
+void f2fs_drop_inmem_pages_all(struct f2fs_sb_info *sbi, bool gc_failure);
+void f2fs_drop_inmem_pages(struct inode *inode);
+void f2fs_drop_inmem_page(struct inode *inode, struct page *page);
+int f2fs_commit_inmem_pages(struct inode *inode);
 void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need);
 void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi);
 int f2fs_issue_flush(struct f2fs_sb_info *sbi, nid_t ino);
-int create_flush_cmd_control(struct f2fs_sb_info *sbi);
+int f2fs_create_flush_cmd_control(struct f2fs_sb_info *sbi);
 int f2fs_flush_device_cache(struct f2fs_sb_info *sbi);
-void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free);
-void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr);
-bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr);
-void init_discard_policy(struct discard_policy *dpolicy, int discard_type,
-                                               unsigned int granularity);
-void drop_discard_cmd(struct f2fs_sb_info *sbi);
-void stop_discard_thread(struct f2fs_sb_info *sbi);
+void f2fs_destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free);
+void f2fs_invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr);
+bool f2fs_is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr);
+void f2fs_drop_discard_cmd(struct f2fs_sb_info *sbi);
+void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi);
 bool f2fs_wait_discard_bios(struct f2fs_sb_info *sbi);
-void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc);
-void release_discard_addrs(struct f2fs_sb_info *sbi);
-int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra);
-void allocate_new_segments(struct f2fs_sb_info *sbi);
+void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
+                                       struct cp_control *cpc);
+void f2fs_release_discard_addrs(struct f2fs_sb_info *sbi);
+int f2fs_npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra);
+void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi);
 int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range);
-bool exist_trim_candidates(struct f2fs_sb_info *sbi, struct cp_control *cpc);
-struct page *get_sum_page(struct f2fs_sb_info *sbi, unsigned int segno);
-void update_meta_page(struct f2fs_sb_info *sbi, void *src, block_t blk_addr);
-void write_meta_page(struct f2fs_sb_info *sbi, struct page *page,
+bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi,
+                                       struct cp_control *cpc);
+struct page *f2fs_get_sum_page(struct f2fs_sb_info *sbi, unsigned int segno);
+void f2fs_update_meta_page(struct f2fs_sb_info *sbi, void *src,
+                                       block_t blk_addr);
+void f2fs_do_write_meta_page(struct f2fs_sb_info *sbi, struct page *page,
                                                enum iostat_type io_type);
-void write_node_page(unsigned int nid, struct f2fs_io_info *fio);
-void write_data_page(struct dnode_of_data *dn, struct f2fs_io_info *fio);
-int rewrite_data_page(struct f2fs_io_info *fio);
-void __f2fs_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
+void f2fs_do_write_node_page(unsigned int nid, struct f2fs_io_info *fio);
+void f2fs_outplace_write_data(struct dnode_of_data *dn,
+                       struct f2fs_io_info *fio);
+int f2fs_inplace_write_data(struct f2fs_io_info *fio);
+void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
                        block_t old_blkaddr, block_t new_blkaddr,
                        bool recover_curseg, bool recover_newaddr);
 void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,
                        block_t old_addr, block_t new_addr,
                        unsigned char version, bool recover_curseg,
                        bool recover_newaddr);
-void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
+void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
                        block_t old_blkaddr, block_t *new_blkaddr,
                        struct f2fs_summary *sum, int type,
                        struct f2fs_io_info *fio, bool add_list);
 void f2fs_wait_on_page_writeback(struct page *page,
                        enum page_type type, bool ordered);
 void f2fs_wait_on_block_writeback(struct f2fs_sb_info *sbi, block_t blkaddr);
-void write_data_summaries(struct f2fs_sb_info *sbi, block_t start_blk);
-void write_node_summaries(struct f2fs_sb_info *sbi, block_t start_blk);
-int lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
+void f2fs_write_data_summaries(struct f2fs_sb_info *sbi, block_t start_blk);
+void f2fs_write_node_summaries(struct f2fs_sb_info *sbi, block_t start_blk);
+int f2fs_lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
                        unsigned int val, int alloc);
-void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc);
-int build_segment_manager(struct f2fs_sb_info *sbi);
-void destroy_segment_manager(struct f2fs_sb_info *sbi);
-int __init create_segment_manager_caches(void);
-void destroy_segment_manager_caches(void);
-int rw_hint_to_seg_type(enum rw_hint hint);
-enum rw_hint io_type_to_rw_hint(struct f2fs_sb_info *sbi, enum page_type type,
-                               enum temp_type temp);
+void f2fs_flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc);
+int f2fs_build_segment_manager(struct f2fs_sb_info *sbi);
+void f2fs_destroy_segment_manager(struct f2fs_sb_info *sbi);
+int __init f2fs_create_segment_manager_caches(void);
+void f2fs_destroy_segment_manager_caches(void);
+int f2fs_rw_hint_to_seg_type(enum rw_hint hint);
+enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi,
+                       enum page_type type, enum temp_type temp);
 
 /*
  * checkpoint.c
  */
 void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io);
-struct page *grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
-struct page *get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
-struct page *get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index);
-bool is_valid_blkaddr(struct f2fs_sb_info *sbi, block_t blkaddr, int type);
-int ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
+struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
+struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index);
+struct page *f2fs_get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index);
+bool f2fs_is_valid_meta_blkaddr(struct f2fs_sb_info *sbi,
+                       block_t blkaddr, int type);
+int f2fs_ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
                        int type, bool sync);
-void ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index);
-long sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
+void f2fs_ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index);
+long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
                        long nr_to_write, enum iostat_type io_type);
-void add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
-void remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
-void release_ino_entry(struct f2fs_sb_info *sbi, bool all);
-bool exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode);
-void set_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
+void f2fs_add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
+void f2fs_remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type);
+void f2fs_release_ino_entry(struct f2fs_sb_info *sbi, bool all);
+bool f2fs_exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode);
+void f2fs_set_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
                                        unsigned int devidx, int type);
-bool is_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
+bool f2fs_is_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
                                        unsigned int devidx, int type);
 int f2fs_sync_inode_meta(struct f2fs_sb_info *sbi);
-int acquire_orphan_inode(struct f2fs_sb_info *sbi);
-void release_orphan_inode(struct f2fs_sb_info *sbi);
-void add_orphan_inode(struct inode *inode);
-void remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino);
-int recover_orphan_inodes(struct f2fs_sb_info *sbi);
-int get_valid_checkpoint(struct f2fs_sb_info *sbi);
-void update_dirty_page(struct inode *inode, struct page *page);
-void remove_dirty_inode(struct inode *inode);
-int sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type);
-int write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc);
-void init_ino_entry_info(struct f2fs_sb_info *sbi);
-int __init create_checkpoint_caches(void);
-void destroy_checkpoint_caches(void);
+int f2fs_acquire_orphan_inode(struct f2fs_sb_info *sbi);
+void f2fs_release_orphan_inode(struct f2fs_sb_info *sbi);
+void f2fs_add_orphan_inode(struct inode *inode);
+void f2fs_remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino);
+int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi);
+int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi);
+void f2fs_update_dirty_page(struct inode *inode, struct page *page);
+void f2fs_remove_dirty_inode(struct inode *inode);
+int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type);
+int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc);
+void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi);
+int __init f2fs_create_checkpoint_caches(void);
+void f2fs_destroy_checkpoint_caches(void);
 
 /*
  * data.c
  */
+int f2fs_init_post_read_processing(void);
+void f2fs_destroy_post_read_processing(void);
 void f2fs_submit_merged_write(struct f2fs_sb_info *sbi, enum page_type type);
 void f2fs_submit_merged_write_cond(struct f2fs_sb_info *sbi,
                                struct inode *inode, nid_t ino, pgoff_t idx,
                                enum page_type type);
 void f2fs_flush_merged_writes(struct f2fs_sb_info *sbi);
 int f2fs_submit_page_bio(struct f2fs_io_info *fio);
-int f2fs_submit_page_write(struct f2fs_io_info *fio);
+void f2fs_submit_page_write(struct f2fs_io_info *fio);
 struct block_device *f2fs_target_device(struct f2fs_sb_info *sbi,
                        block_t blk_addr, struct bio *bio);
 int f2fs_target_device_index(struct f2fs_sb_info *sbi, block_t blkaddr);
-void set_data_blkaddr(struct dnode_of_data *dn);
+void f2fs_set_data_blkaddr(struct dnode_of_data *dn);
 void f2fs_update_data_blkaddr(struct dnode_of_data *dn, block_t blkaddr);
-int reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count);
-int reserve_new_block(struct dnode_of_data *dn);
+int f2fs_reserve_new_blocks(struct dnode_of_data *dn, blkcnt_t count);
+int f2fs_reserve_new_block(struct dnode_of_data *dn);
 int f2fs_get_block(struct dnode_of_data *dn, pgoff_t index);
 int f2fs_preallocate_blocks(struct kiocb *iocb, struct iov_iter *from);
 int f2fs_reserve_block(struct dnode_of_data *dn, pgoff_t index);
-struct page *get_read_data_page(struct inode *inode, pgoff_t index,
+struct page *f2fs_get_read_data_page(struct inode *inode, pgoff_t index,
                        int op_flags, bool for_write);
-struct page *find_data_page(struct inode *inode, pgoff_t index);
-struct page *get_lock_data_page(struct inode *inode, pgoff_t index,
+struct page *f2fs_find_data_page(struct inode *inode, pgoff_t index);
+struct page *f2fs_get_lock_data_page(struct inode *inode, pgoff_t index,
                        bool for_write);
-struct page *get_new_data_page(struct inode *inode,
+struct page *f2fs_get_new_data_page(struct inode *inode,
                        struct page *ipage, pgoff_t index, bool new_i_size);
-int do_write_data_page(struct f2fs_io_info *fio);
+int f2fs_do_write_data_page(struct f2fs_io_info *fio);
 int f2fs_map_blocks(struct inode *inode, struct f2fs_map_blocks *map,
                        int create, int flag);
 int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
                        u64 start, u64 len);
-bool should_update_inplace(struct inode *inode, struct f2fs_io_info *fio);
-bool should_update_outplace(struct inode *inode, struct f2fs_io_info *fio);
-void f2fs_set_page_dirty_nobuffers(struct page *page);
-int __f2fs_write_data_pages(struct address_space *mapping,
-                                               struct writeback_control *wbc,
-                                               enum iostat_type io_type);
+bool f2fs_should_update_inplace(struct inode *inode, struct f2fs_io_info *fio);
+bool f2fs_should_update_outplace(struct inode *inode, struct f2fs_io_info *fio);
 void f2fs_invalidate_page(struct page *page, unsigned int offset,
                        unsigned int length);
 int f2fs_release_page(struct page *page, gfp_t wait);
@@ -2901,22 +2973,23 @@ int f2fs_migrate_page(struct address_space *mapping, struct page *newpage,
                        struct page *page, enum migrate_mode mode);
 #endif
 bool f2fs_overwrite_io(struct inode *inode, loff_t pos, size_t len);
+void f2fs_clear_radix_tree_dirty_tag(struct page *page);
 
 /*
  * gc.c
  */
-int start_gc_thread(struct f2fs_sb_info *sbi);
-void stop_gc_thread(struct f2fs_sb_info *sbi);
-block_t start_bidx_of_node(unsigned int node_ofs, struct inode *inode);
+int f2fs_start_gc_thread(struct f2fs_sb_info *sbi);
+void f2fs_stop_gc_thread(struct f2fs_sb_info *sbi);
+block_t f2fs_start_bidx_of_node(unsigned int node_ofs, struct inode *inode);
 int f2fs_gc(struct f2fs_sb_info *sbi, bool sync, bool background,
                        unsigned int segno);
-void build_gc_manager(struct f2fs_sb_info *sbi);
+void f2fs_build_gc_manager(struct f2fs_sb_info *sbi);
 
 /*
  * recovery.c
  */
-int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only);
-bool space_for_roll_forward(struct f2fs_sb_info *sbi);
+int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only);
+bool f2fs_space_for_roll_forward(struct f2fs_sb_info *sbi);
 
 /*
  * debug.c
@@ -2954,6 +3027,7 @@ struct f2fs_stat_info {
        int bg_node_segs, bg_data_segs;
        int tot_blks, data_blks, node_blks;
        int bg_data_blks, bg_node_blks;
+       unsigned long long skipped_atomic_files[2];
        int curseg[NR_CURSEG_TYPE];
        int cursec[NR_CURSEG_TYPE];
        int curzone[NR_CURSEG_TYPE];
@@ -3120,29 +3194,31 @@ extern const struct inode_operations f2fs_dir_inode_operations;
 extern const struct inode_operations f2fs_symlink_inode_operations;
 extern const struct inode_operations f2fs_encrypted_symlink_inode_operations;
 extern const struct inode_operations f2fs_special_inode_operations;
-extern struct kmem_cache *inode_entry_slab;
+extern struct kmem_cache *f2fs_inode_entry_slab;
 
 /*
  * inline.c
  */
 bool f2fs_may_inline_data(struct inode *inode);
 bool f2fs_may_inline_dentry(struct inode *inode);
-void read_inline_data(struct page *page, struct page *ipage);
-void truncate_inline_inode(struct inode *inode, struct page *ipage, u64 from);
+void f2fs_do_read_inline_data(struct page *page, struct page *ipage);
+void f2fs_truncate_inline_inode(struct inode *inode,
+                                               struct page *ipage, u64 from);
 int f2fs_read_inline_data(struct inode *inode, struct page *page);
 int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page);
 int f2fs_convert_inline_inode(struct inode *inode);
 int f2fs_write_inline_data(struct inode *inode, struct page *page);
-bool recover_inline_data(struct inode *inode, struct page *npage);
-struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
+bool f2fs_recover_inline_data(struct inode *inode, struct page *npage);
+struct f2fs_dir_entry *f2fs_find_in_inline_dir(struct inode *dir,
                        struct fscrypt_name *fname, struct page **res_page);
-int make_empty_inline_dir(struct inode *inode, struct inode *parent,
+int f2fs_make_empty_inline_dir(struct inode *inode, struct inode *parent,
                        struct page *ipage);
 int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name,
                        const struct qstr *orig_name,
                        struct inode *inode, nid_t ino, umode_t mode);
-void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,
-                       struct inode *dir, struct inode *inode);
+void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry,
+                               struct page *page, struct inode *dir,
+                               struct inode *inode);
 bool f2fs_empty_inline_dir(struct inode *dir);
 int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx,
                        struct fscrypt_str *fstr);
@@ -3163,17 +3239,17 @@ void f2fs_leave_shrinker(struct f2fs_sb_info *sbi);
 /*
  * extent_cache.c
  */
-struct rb_entry *__lookup_rb_tree(struct rb_root *root,
+struct rb_entry *f2fs_lookup_rb_tree(struct rb_root *root,
                                struct rb_entry *cached_re, unsigned int ofs);
-struct rb_node **__lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,
+struct rb_node **f2fs_lookup_rb_tree_for_insert(struct f2fs_sb_info *sbi,
                                struct rb_root *root, struct rb_node **parent,
                                unsigned int ofs);
-struct rb_entry *__lookup_rb_tree_ret(struct rb_root *root,
+struct rb_entry *f2fs_lookup_rb_tree_ret(struct rb_root *root,
                struct rb_entry *cached_re, unsigned int ofs,
                struct rb_entry **prev_entry, struct rb_entry **next_entry,
                struct rb_node ***insert_p, struct rb_node **insert_parent,
                bool force);
-bool __check_rb_tree_consistence(struct f2fs_sb_info *sbi,
+bool f2fs_check_rb_tree_consistence(struct f2fs_sb_info *sbi,
                                                struct rb_root *root);
 unsigned int f2fs_shrink_extent_tree(struct f2fs_sb_info *sbi, int nr_shrink);
 bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext);
@@ -3185,9 +3261,9 @@ bool f2fs_lookup_extent_cache(struct inode *inode, pgoff_t pgofs,
 void f2fs_update_extent_cache(struct dnode_of_data *dn);
 void f2fs_update_extent_cache_range(struct dnode_of_data *dn,
                        pgoff_t fofs, block_t blkaddr, unsigned int len);
-void init_extent_cache_info(struct f2fs_sb_info *sbi);
-int __init create_extent_cache(void);
-void destroy_extent_cache(void);
+void f2fs_init_extent_cache_info(struct f2fs_sb_info *sbi);
+int __init f2fs_create_extent_cache(void);
+void f2fs_destroy_extent_cache(void);
 
 /*
  * sysfs.c
@@ -3218,9 +3294,13 @@ static inline void f2fs_set_encrypted_inode(struct inode *inode)
 #endif
 }
 
-static inline bool f2fs_bio_encrypted(struct bio *bio)
+/*
+ * Returns true if the reads of the inode's data need to undergo some
+ * postprocessing step, like decryption or authenticity verification.
+ */
+static inline bool f2fs_post_read_required(struct inode *inode)
 {
-       return bio->bi_private != NULL;
+       return f2fs_encrypted_file(inode);
 }
 
 #define F2FS_FEATURE_FUNCS(name, flagname) \
@@ -3288,7 +3368,7 @@ static inline bool f2fs_may_encrypt(struct inode *inode)
 
 static inline bool f2fs_force_buffered_io(struct inode *inode, int rw)
 {
-       return (f2fs_encrypted_file(inode) ||
+       return (f2fs_post_read_required(inode) ||
                        (rw == WRITE && test_opt(F2FS_I_SB(inode), LFS)) ||
                        F2FS_I_SB(inode)->s_ndevs);
 }
index 6b94f19b3fa8d40a9e7da5151e19064ccca50d7d..6880c6f78d58d0670bf28863d53de0c1e6afb3b0 100644 (file)
 #include "trace.h"
 #include <trace/events/f2fs.h>
 
-static int f2fs_filemap_fault(struct vm_fault *vmf)
+static vm_fault_t f2fs_filemap_fault(struct vm_fault *vmf)
 {
        struct inode *inode = file_inode(vmf->vma->vm_file);
-       int err;
+       vm_fault_t ret;
 
        down_read(&F2FS_I(inode)->i_mmap_sem);
-       err = filemap_fault(vmf);
+       ret = filemap_fault(vmf);
        up_read(&F2FS_I(inode)->i_mmap_sem);
 
-       return err;
+       return ret;
 }
 
-static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
+static vm_fault_t f2fs_vm_page_mkwrite(struct vm_fault *vmf)
 {
        struct page *page = vmf->page;
        struct inode *inode = file_inode(vmf->vma->vm_file);
@@ -95,7 +95,8 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
        /* page is wholly or partially inside EOF */
        if (((loff_t)(page->index + 1) << PAGE_SHIFT) >
                                                i_size_read(inode)) {
-               unsigned offset;
+               loff_t offset;
+
                offset = i_size_read(inode) & ~PAGE_MASK;
                zero_user_segment(page, offset, PAGE_SIZE);
        }
@@ -110,8 +111,8 @@ static int f2fs_vm_page_mkwrite(struct vm_fault *vmf)
        /* fill the page */
        f2fs_wait_on_page_writeback(page, DATA, false);
 
-       /* wait for GCed encrypted page writeback */
-       if (f2fs_encrypted_file(inode))
+       /* wait for GCed page writeback via META_MAPPING */
+       if (f2fs_post_read_required(inode))
                f2fs_wait_on_block_writeback(sbi, dn.data_blkaddr);
 
 out_sem:
@@ -157,17 +158,18 @@ static inline enum cp_reason_type need_do_checkpoint(struct inode *inode)
                cp_reason = CP_SB_NEED_CP;
        else if (file_wrong_pino(inode))
                cp_reason = CP_WRONG_PINO;
-       else if (!space_for_roll_forward(sbi))
+       else if (!f2fs_space_for_roll_forward(sbi))
                cp_reason = CP_NO_SPC_ROLL;
-       else if (!is_checkpointed_node(sbi, F2FS_I(inode)->i_pino))
+       else if (!f2fs_is_checkpointed_node(sbi, F2FS_I(inode)->i_pino))
                cp_reason = CP_NODE_NEED_CP;
        else if (test_opt(sbi, FASTBOOT))
                cp_reason = CP_FASTBOOT_MODE;
        else if (F2FS_OPTION(sbi).active_logs == 2)
                cp_reason = CP_SPEC_LOG_NUM;
        else if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT &&
-               need_dentry_mark(sbi, inode->i_ino) &&
-               exist_written_data(sbi, F2FS_I(inode)->i_pino, TRANS_DIR_INO))
+               f2fs_need_dentry_mark(sbi, inode->i_ino) &&
+               f2fs_exist_written_data(sbi, F2FS_I(inode)->i_pino,
+                                                       TRANS_DIR_INO))
                cp_reason = CP_RECOVER_DIR;
 
        return cp_reason;
@@ -178,7 +180,7 @@ static bool need_inode_page_update(struct f2fs_sb_info *sbi, nid_t ino)
        struct page *i = find_get_page(NODE_MAPPING(sbi), ino);
        bool ret = false;
        /* But we need to avoid that there are some inode updates */
-       if ((i && PageDirty(i)) || need_inode_block_update(sbi, ino))
+       if ((i && PageDirty(i)) || f2fs_need_inode_block_update(sbi, ino))
                ret = true;
        f2fs_put_page(i, 0);
        return ret;
@@ -238,14 +240,14 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
         * if there is no written data, don't waste time to write recovery info.
         */
        if (!is_inode_flag_set(inode, FI_APPEND_WRITE) &&
-                       !exist_written_data(sbi, ino, APPEND_INO)) {
+                       !f2fs_exist_written_data(sbi, ino, APPEND_INO)) {
 
                /* it may call write_inode just prior to fsync */
                if (need_inode_page_update(sbi, ino))
                        goto go_write;
 
                if (is_inode_flag_set(inode, FI_UPDATE_WRITE) ||
-                               exist_written_data(sbi, ino, UPDATE_INO))
+                               f2fs_exist_written_data(sbi, ino, UPDATE_INO))
                        goto flush_out;
                goto out;
        }
@@ -272,7 +274,9 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
                goto out;
        }
 sync_nodes:
-       ret = fsync_node_pages(sbi, inode, &wbc, atomic);
+       atomic_inc(&sbi->wb_sync_req[NODE]);
+       ret = f2fs_fsync_node_pages(sbi, inode, &wbc, atomic);
+       atomic_dec(&sbi->wb_sync_req[NODE]);
        if (ret)
                goto out;
 
@@ -282,7 +286,7 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
                goto out;
        }
 
-       if (need_inode_block_update(sbi, ino)) {
+       if (f2fs_need_inode_block_update(sbi, ino)) {
                f2fs_mark_inode_dirty_sync(inode, true);
                f2fs_write_inode(inode, NULL);
                goto sync_nodes;
@@ -297,21 +301,21 @@ static int f2fs_do_sync_file(struct file *file, loff_t start, loff_t end,
         * given fsync mark.
         */
        if (!atomic) {
-               ret = wait_on_node_pages_writeback(sbi, ino);
+               ret = f2fs_wait_on_node_pages_writeback(sbi, ino);
                if (ret)
                        goto out;
        }
 
        /* once recovery info is written, don't need to tack this */
-       remove_ino_entry(sbi, ino, APPEND_INO);
+       f2fs_remove_ino_entry(sbi, ino, APPEND_INO);
        clear_inode_flag(inode, FI_APPEND_WRITE);
 flush_out:
-       if (!atomic)
+       if (!atomic && F2FS_OPTION(sbi).fsync_mode != FSYNC_MODE_NOBARRIER)
                ret = f2fs_issue_flush(sbi, inode->i_ino);
        if (!ret) {
-               remove_ino_entry(sbi, ino, UPDATE_INO);
+               f2fs_remove_ino_entry(sbi, ino, UPDATE_INO);
                clear_inode_flag(inode, FI_UPDATE_WRITE);
-               remove_ino_entry(sbi, ino, FLUSH_INO);
+               f2fs_remove_ino_entry(sbi, ino, FLUSH_INO);
        }
        f2fs_update_time(sbi, REQ_TIME);
 out:
@@ -352,7 +356,7 @@ static bool __found_offset(block_t blkaddr, pgoff_t dirty, pgoff_t pgofs,
        switch (whence) {
        case SEEK_DATA:
                if ((blkaddr == NEW_ADDR && dirty == pgofs) ||
-                       (blkaddr != NEW_ADDR && blkaddr != NULL_ADDR))
+                       is_valid_blkaddr(blkaddr))
                        return true;
                break;
        case SEEK_HOLE:
@@ -392,13 +396,13 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
 
        for (; data_ofs < isize; data_ofs = (loff_t)pgofs << PAGE_SHIFT) {
                set_new_dnode(&dn, inode, NULL, NULL, 0);
-               err = get_dnode_of_data(&dn, pgofs, LOOKUP_NODE);
+               err = f2fs_get_dnode_of_data(&dn, pgofs, LOOKUP_NODE);
                if (err && err != -ENOENT) {
                        goto fail;
                } else if (err == -ENOENT) {
                        /* direct node does not exists */
                        if (whence == SEEK_DATA) {
-                               pgofs = get_next_page_offset(&dn, pgofs);
+                               pgofs = f2fs_get_next_page_offset(&dn, pgofs);
                                continue;
                        } else {
                                goto found;
@@ -412,6 +416,7 @@ static loff_t f2fs_seek_block(struct file *file, loff_t offset, int whence)
                                dn.ofs_in_node++, pgofs++,
                                data_ofs = (loff_t)pgofs << PAGE_SHIFT) {
                        block_t blkaddr;
+
                        blkaddr = datablock_addr(dn.inode,
                                        dn.node_page, dn.ofs_in_node);
 
@@ -486,7 +491,7 @@ static int f2fs_file_open(struct inode *inode, struct file *filp)
        return dquot_file_open(inode, filp);
 }
 
-void truncate_data_blocks_range(struct dnode_of_data *dn, int count)
+void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
        struct f2fs_node *raw_node;
@@ -502,12 +507,13 @@ void truncate_data_blocks_range(struct dnode_of_data *dn, int count)
 
        for (; count > 0; count--, addr++, dn->ofs_in_node++) {
                block_t blkaddr = le32_to_cpu(*addr);
+
                if (blkaddr == NULL_ADDR)
                        continue;
 
                dn->data_blkaddr = NULL_ADDR;
-               set_data_blkaddr(dn);
-               invalidate_blocks(sbi, blkaddr);
+               f2fs_set_data_blkaddr(dn);
+               f2fs_invalidate_blocks(sbi, blkaddr);
                if (dn->ofs_in_node == 0 && IS_INODE(dn->node_page))
                        clear_inode_flag(dn->inode, FI_FIRST_BLOCK_WRITTEN);
                nr_free++;
@@ -519,7 +525,7 @@ void truncate_data_blocks_range(struct dnode_of_data *dn, int count)
                 * once we invalidate valid blkaddr in range [ofs, ofs + count],
                 * we will invalidate all blkaddr in the whole range.
                 */
-               fofs = start_bidx_of_node(ofs_of_node(dn->node_page),
+               fofs = f2fs_start_bidx_of_node(ofs_of_node(dn->node_page),
                                                        dn->inode) + ofs;
                f2fs_update_extent_cache_range(dn, fofs, 0, len);
                dec_valid_block_count(sbi, dn->inode, nr_free);
@@ -531,15 +537,15 @@ void truncate_data_blocks_range(struct dnode_of_data *dn, int count)
                                         dn->ofs_in_node, nr_free);
 }
 
-void truncate_data_blocks(struct dnode_of_data *dn)
+void f2fs_truncate_data_blocks(struct dnode_of_data *dn)
 {
-       truncate_data_blocks_range(dn, ADDRS_PER_BLOCK);
+       f2fs_truncate_data_blocks_range(dn, ADDRS_PER_BLOCK);
 }
 
 static int truncate_partial_data_page(struct inode *inode, u64 from,
                                                                bool cache_only)
 {
-       unsigned offset = from & (PAGE_SIZE - 1);
+       loff_t offset = from & (PAGE_SIZE - 1);
        pgoff_t index = from >> PAGE_SHIFT;
        struct address_space *mapping = inode->i_mapping;
        struct page *page;
@@ -555,7 +561,7 @@ static int truncate_partial_data_page(struct inode *inode, u64 from,
                return 0;
        }
 
-       page = get_lock_data_page(inode, index, true);
+       page = f2fs_get_lock_data_page(inode, index, true);
        if (IS_ERR(page))
                return PTR_ERR(page) == -ENOENT ? 0 : PTR_ERR(page);
 truncate_out:
@@ -570,7 +576,7 @@ static int truncate_partial_data_page(struct inode *inode, u64 from,
        return 0;
 }
 
-int truncate_blocks(struct inode *inode, u64 from, bool lock)
+int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        struct dnode_of_data dn;
@@ -589,21 +595,21 @@ int truncate_blocks(struct inode *inode, u64 from, bool lock)
        if (lock)
                f2fs_lock_op(sbi);
 
-       ipage = get_node_page(sbi, inode->i_ino);
+       ipage = f2fs_get_node_page(sbi, inode->i_ino);
        if (IS_ERR(ipage)) {
                err = PTR_ERR(ipage);
                goto out;
        }
 
        if (f2fs_has_inline_data(inode)) {
-               truncate_inline_inode(inode, ipage, from);
+               f2fs_truncate_inline_inode(inode, ipage, from);
                f2fs_put_page(ipage, 1);
                truncate_page = true;
                goto out;
        }
 
        set_new_dnode(&dn, inode, ipage, NULL, 0);
-       err = get_dnode_of_data(&dn, free_from, LOOKUP_NODE_RA);
+       err = f2fs_get_dnode_of_data(&dn, free_from, LOOKUP_NODE_RA);
        if (err) {
                if (err == -ENOENT)
                        goto free_next;
@@ -616,13 +622,13 @@ int truncate_blocks(struct inode *inode, u64 from, bool lock)
        f2fs_bug_on(sbi, count < 0);
 
        if (dn.ofs_in_node || IS_INODE(dn.node_page)) {
-               truncate_data_blocks_range(&dn, count);
+               f2fs_truncate_data_blocks_range(&dn, count);
                free_from += count;
        }
 
        f2fs_put_dnode(&dn);
 free_next:
-       err = truncate_inode_blocks(inode, free_from);
+       err = f2fs_truncate_inode_blocks(inode, free_from);
 out:
        if (lock)
                f2fs_unlock_op(sbi);
@@ -661,7 +667,7 @@ int f2fs_truncate(struct inode *inode)
                        return err;
        }
 
-       err = truncate_blocks(inode, i_size_read(inode), true);
+       err = f2fs_truncate_blocks(inode, i_size_read(inode), true);
        if (err)
                return err;
 
@@ -686,16 +692,16 @@ int f2fs_getattr(const struct path *path, struct kstat *stat,
                stat->btime.tv_nsec = fi->i_crtime.tv_nsec;
        }
 
-       flags = fi->i_flags & (FS_FL_USER_VISIBLE | FS_PROJINHERIT_FL);
-       if (flags & FS_APPEND_FL)
+       flags = fi->i_flags & F2FS_FL_USER_VISIBLE;
+       if (flags & F2FS_APPEND_FL)
                stat->attributes |= STATX_ATTR_APPEND;
-       if (flags & FS_COMPR_FL)
+       if (flags & F2FS_COMPR_FL)
                stat->attributes |= STATX_ATTR_COMPRESSED;
        if (f2fs_encrypted_inode(inode))
                stat->attributes |= STATX_ATTR_ENCRYPTED;
-       if (flags & FS_IMMUTABLE_FL)
+       if (flags & F2FS_IMMUTABLE_FL)
                stat->attributes |= STATX_ATTR_IMMUTABLE;
-       if (flags & FS_NODUMP_FL)
+       if (flags & F2FS_NODUMP_FL)
                stat->attributes |= STATX_ATTR_NODUMP;
 
        stat->attributes_mask |= (STATX_ATTR_APPEND |
@@ -724,14 +730,14 @@ static void __setattr_copy(struct inode *inode, const struct iattr *attr)
        if (ia_valid & ATTR_GID)
                inode->i_gid = attr->ia_gid;
        if (ia_valid & ATTR_ATIME)
-               inode->i_atime = timespec_trunc(attr->ia_atime,
-                                               inode->i_sb->s_time_gran);
+               inode->i_atime = timespec64_trunc(attr->ia_atime,
+                                                 inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_MTIME)
-               inode->i_mtime = timespec_trunc(attr->ia_mtime,
-                                               inode->i_sb->s_time_gran);
+               inode->i_mtime = timespec64_trunc(attr->ia_mtime,
+                                                 inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_CTIME)
-               inode->i_ctime = timespec_trunc(attr->ia_ctime,
-                                               inode->i_sb->s_time_gran);
+               inode->i_ctime = timespec64_trunc(attr->ia_ctime,
+                                                 inode->i_sb->s_time_gran);
        if (ia_valid & ATTR_MODE) {
                umode_t mode = attr->ia_mode;
 
@@ -811,7 +817,7 @@ int f2fs_setattr(struct dentry *dentry, struct iattr *attr)
        __setattr_copy(inode, attr);
 
        if (attr->ia_valid & ATTR_MODE) {
-               err = posix_acl_chmod(inode, get_inode_mode(inode));
+               err = posix_acl_chmod(inode, f2fs_get_inode_mode(inode));
                if (err || is_inode_flag_set(inode, FI_ACL_MODE)) {
                        inode->i_mode = F2FS_I(inode)->i_acl_mode;
                        clear_inode_flag(inode, FI_ACL_MODE);
@@ -850,7 +856,7 @@ static int fill_zero(struct inode *inode, pgoff_t index,
        f2fs_balance_fs(sbi, true);
 
        f2fs_lock_op(sbi);
-       page = get_new_data_page(inode, NULL, index, false);
+       page = f2fs_get_new_data_page(inode, NULL, index, false);
        f2fs_unlock_op(sbi);
 
        if (IS_ERR(page))
@@ -863,7 +869,7 @@ static int fill_zero(struct inode *inode, pgoff_t index,
        return 0;
 }
 
-int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end)
+int f2fs_truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end)
 {
        int err;
 
@@ -872,10 +878,11 @@ int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end)
                pgoff_t end_offset, count;
 
                set_new_dnode(&dn, inode, NULL, NULL, 0);
-               err = get_dnode_of_data(&dn, pg_start, LOOKUP_NODE);
+               err = f2fs_get_dnode_of_data(&dn, pg_start, LOOKUP_NODE);
                if (err) {
                        if (err == -ENOENT) {
-                               pg_start = get_next_page_offset(&dn, pg_start);
+                               pg_start = f2fs_get_next_page_offset(&dn,
+                                                               pg_start);
                                continue;
                        }
                        return err;
@@ -886,7 +893,7 @@ int truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end)
 
                f2fs_bug_on(F2FS_I_SB(inode), count == 0 || count > end_offset);
 
-               truncate_data_blocks_range(&dn, count);
+               f2fs_truncate_data_blocks_range(&dn, count);
                f2fs_put_dnode(&dn);
 
                pg_start += count;
@@ -942,7 +949,7 @@ static int punch_hole(struct inode *inode, loff_t offset, loff_t len)
                                        blk_end - 1);
 
                        f2fs_lock_op(sbi);
-                       ret = truncate_hole(inode, pg_start, pg_end);
+                       ret = f2fs_truncate_hole(inode, pg_start, pg_end);
                        f2fs_unlock_op(sbi);
                        up_write(&F2FS_I(inode)->i_mmap_sem);
                }
@@ -960,7 +967,7 @@ static int __read_out_blkaddrs(struct inode *inode, block_t *blkaddr,
 
 next_dnode:
        set_new_dnode(&dn, inode, NULL, NULL, 0);
-       ret = get_dnode_of_data(&dn, off, LOOKUP_NODE_RA);
+       ret = f2fs_get_dnode_of_data(&dn, off, LOOKUP_NODE_RA);
        if (ret && ret != -ENOENT) {
                return ret;
        } else if (ret == -ENOENT) {
@@ -977,7 +984,7 @@ static int __read_out_blkaddrs(struct inode *inode, block_t *blkaddr,
        for (i = 0; i < done; i++, blkaddr++, do_replace++, dn.ofs_in_node++) {
                *blkaddr = datablock_addr(dn.inode,
                                        dn.node_page, dn.ofs_in_node);
-               if (!is_checkpointed_data(sbi, *blkaddr)) {
+               if (!f2fs_is_checkpointed_data(sbi, *blkaddr)) {
 
                        if (test_opt(sbi, LFS)) {
                                f2fs_put_dnode(&dn);
@@ -1010,10 +1017,10 @@ static int __roll_back_blkaddrs(struct inode *inode, block_t *blkaddr,
                        continue;
 
                set_new_dnode(&dn, inode, NULL, NULL, 0);
-               ret = get_dnode_of_data(&dn, off + i, LOOKUP_NODE_RA);
+               ret = f2fs_get_dnode_of_data(&dn, off + i, LOOKUP_NODE_RA);
                if (ret) {
                        dec_valid_block_count(sbi, inode, 1);
-                       invalidate_blocks(sbi, *blkaddr);
+                       f2fs_invalidate_blocks(sbi, *blkaddr);
                } else {
                        f2fs_update_data_blkaddr(&dn, *blkaddr);
                }
@@ -1043,18 +1050,18 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode,
                        pgoff_t ilen;
 
                        set_new_dnode(&dn, dst_inode, NULL, NULL, 0);
-                       ret = get_dnode_of_data(&dn, dst + i, ALLOC_NODE);
+                       ret = f2fs_get_dnode_of_data(&dn, dst + i, ALLOC_NODE);
                        if (ret)
                                return ret;
 
-                       get_node_info(sbi, dn.nid, &ni);
+                       f2fs_get_node_info(sbi, dn.nid, &ni);
                        ilen = min((pgoff_t)
                                ADDRS_PER_PAGE(dn.node_page, dst_inode) -
                                                dn.ofs_in_node, len - i);
                        do {
                                dn.data_blkaddr = datablock_addr(dn.inode,
                                                dn.node_page, dn.ofs_in_node);
-                               truncate_data_blocks_range(&dn, 1);
+                               f2fs_truncate_data_blocks_range(&dn, 1);
 
                                if (do_replace[i]) {
                                        f2fs_i_blocks_write(src_inode,
@@ -1077,10 +1084,11 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode,
                } else {
                        struct page *psrc, *pdst;
 
-                       psrc = get_lock_data_page(src_inode, src + i, true);
+                       psrc = f2fs_get_lock_data_page(src_inode,
+                                                       src + i, true);
                        if (IS_ERR(psrc))
                                return PTR_ERR(psrc);
-                       pdst = get_new_data_page(dst_inode, NULL, dst + i,
+                       pdst = f2fs_get_new_data_page(dst_inode, NULL, dst + i,
                                                                true);
                        if (IS_ERR(pdst)) {
                                f2fs_put_page(psrc, 1);
@@ -1091,7 +1099,8 @@ static int __clone_blkaddrs(struct inode *src_inode, struct inode *dst_inode,
                        f2fs_put_page(pdst, 1);
                        f2fs_put_page(psrc, 1);
 
-                       ret = truncate_hole(src_inode, src + i, src + i + 1);
+                       ret = f2fs_truncate_hole(src_inode,
+                                               src + i, src + i + 1);
                        if (ret)
                                return ret;
                        i++;
@@ -1113,12 +1122,14 @@ static int __exchange_data_block(struct inode *src_inode,
                olen = min((pgoff_t)4 * ADDRS_PER_BLOCK, len);
 
                src_blkaddr = f2fs_kvzalloc(F2FS_I_SB(src_inode),
-                                       sizeof(block_t) * olen, GFP_KERNEL);
+                                       array_size(olen, sizeof(block_t)),
+                                       GFP_KERNEL);
                if (!src_blkaddr)
                        return -ENOMEM;
 
                do_replace = f2fs_kvzalloc(F2FS_I_SB(src_inode),
-                                       sizeof(int) * olen, GFP_KERNEL);
+                                       array_size(olen, sizeof(int)),
+                                       GFP_KERNEL);
                if (!do_replace) {
                        kvfree(src_blkaddr);
                        return -ENOMEM;
@@ -1144,7 +1155,7 @@ static int __exchange_data_block(struct inode *src_inode,
        return 0;
 
 roll_back:
-       __roll_back_blkaddrs(src_inode, src_blkaddr, do_replace, src, len);
+       __roll_back_blkaddrs(src_inode, src_blkaddr, do_replace, src, olen);
        kvfree(src_blkaddr);
        kvfree(do_replace);
        return ret;
@@ -1187,7 +1198,7 @@ static int f2fs_collapse_range(struct inode *inode, loff_t offset, loff_t len)
        pg_end = (offset + len) >> PAGE_SHIFT;
 
        /* avoid gc operation during block exchange */
-       down_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
+       down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
 
        down_write(&F2FS_I(inode)->i_mmap_sem);
        /* write out all dirty pages from offset */
@@ -1208,12 +1219,12 @@ static int f2fs_collapse_range(struct inode *inode, loff_t offset, loff_t len)
        new_size = i_size_read(inode) - len;
        truncate_pagecache(inode, new_size);
 
-       ret = truncate_blocks(inode, new_size, true);
+       ret = f2fs_truncate_blocks(inode, new_size, true);
        if (!ret)
                f2fs_i_size_write(inode, new_size);
 out_unlock:
        up_write(&F2FS_I(inode)->i_mmap_sem);
-       up_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
+       up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
        return ret;
 }
 
@@ -1233,7 +1244,7 @@ static int f2fs_do_zero_range(struct dnode_of_data *dn, pgoff_t start,
        }
 
        dn->ofs_in_node = ofs_in_node;
-       ret = reserve_new_blocks(dn, count);
+       ret = f2fs_reserve_new_blocks(dn, count);
        if (ret)
                return ret;
 
@@ -1242,7 +1253,7 @@ static int f2fs_do_zero_range(struct dnode_of_data *dn, pgoff_t start,
                dn->data_blkaddr = datablock_addr(dn->inode,
                                        dn->node_page, dn->ofs_in_node);
                /*
-                * reserve_new_blocks will not guarantee entire block
+                * f2fs_reserve_new_blocks will not guarantee entire block
                 * allocation.
                 */
                if (dn->data_blkaddr == NULL_ADDR) {
@@ -1250,9 +1261,9 @@ static int f2fs_do_zero_range(struct dnode_of_data *dn, pgoff_t start,
                        break;
                }
                if (dn->data_blkaddr != NEW_ADDR) {
-                       invalidate_blocks(sbi, dn->data_blkaddr);
+                       f2fs_invalidate_blocks(sbi, dn->data_blkaddr);
                        dn->data_blkaddr = NEW_ADDR;
-                       set_data_blkaddr(dn);
+                       f2fs_set_data_blkaddr(dn);
                }
        }
 
@@ -1318,7 +1329,7 @@ static int f2fs_zero_range(struct inode *inode, loff_t offset, loff_t len,
                        f2fs_lock_op(sbi);
 
                        set_new_dnode(&dn, inode, NULL, NULL, 0);
-                       ret = get_dnode_of_data(&dn, index, ALLOC_NODE);
+                       ret = f2fs_get_dnode_of_data(&dn, index, ALLOC_NODE);
                        if (ret) {
                                f2fs_unlock_op(sbi);
                                goto out;
@@ -1389,10 +1400,10 @@ static int f2fs_insert_range(struct inode *inode, loff_t offset, loff_t len)
        f2fs_balance_fs(sbi, true);
 
        /* avoid gc operation during block exchange */
-       down_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
+       down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
 
        down_write(&F2FS_I(inode)->i_mmap_sem);
-       ret = truncate_blocks(inode, i_size_read(inode), true);
+       ret = f2fs_truncate_blocks(inode, i_size_read(inode), true);
        if (ret)
                goto out;
 
@@ -1430,7 +1441,7 @@ static int f2fs_insert_range(struct inode *inode, loff_t offset, loff_t len)
                f2fs_i_size_write(inode, new_size);
 out:
        up_write(&F2FS_I(inode)->i_mmap_sem);
-       up_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
+       up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
        return ret;
 }
 
@@ -1473,7 +1484,7 @@ static int expand_inode_data(struct inode *inode, loff_t offset,
                last_off = map.m_lblk + map.m_len - 1;
 
                /* update new size to the failed position */
-               new_size = (last_off == pg_end) ? offset + len:
+               new_size = (last_off == pg_end) ? offset + len :
                                        (loff_t)(last_off + 1) << PAGE_SHIFT;
        } else {
                new_size = ((loff_t)pg_end << PAGE_SHIFT) + off_end;
@@ -1553,13 +1564,13 @@ static int f2fs_release_file(struct inode *inode, struct file *filp)
 
        /* some remained atomic pages should discarded */
        if (f2fs_is_atomic_file(inode))
-               drop_inmem_pages(inode);
+               f2fs_drop_inmem_pages(inode);
        if (f2fs_is_volatile_file(inode)) {
-               clear_inode_flag(inode, FI_VOLATILE_FILE);
-               stat_dec_volatile_write(inode);
                set_inode_flag(inode, FI_DROP_CACHE);
                filemap_fdatawrite(inode->i_mapping);
                clear_inode_flag(inode, FI_DROP_CACHE);
+               clear_inode_flag(inode, FI_VOLATILE_FILE);
+               stat_dec_volatile_write(inode);
        }
        return 0;
 }
@@ -1576,7 +1587,7 @@ static int f2fs_file_flush(struct file *file, fl_owner_t id)
         */
        if (f2fs_is_atomic_file(inode) &&
                        F2FS_I(inode)->inmem_task == current)
-               drop_inmem_pages(inode);
+               f2fs_drop_inmem_pages(inode);
        return 0;
 }
 
@@ -1584,8 +1595,15 @@ static int f2fs_ioc_getflags(struct file *filp, unsigned long arg)
 {
        struct inode *inode = file_inode(filp);
        struct f2fs_inode_info *fi = F2FS_I(inode);
-       unsigned int flags = fi->i_flags &
-                       (FS_FL_USER_VISIBLE | FS_PROJINHERIT_FL);
+       unsigned int flags = fi->i_flags;
+
+       if (file_is_encrypt(inode))
+               flags |= F2FS_ENCRYPT_FL;
+       if (f2fs_has_inline_data(inode) || f2fs_has_inline_dentry(inode))
+               flags |= F2FS_INLINE_DATA_FL;
+
+       flags &= F2FS_FL_USER_VISIBLE;
+
        return put_user(flags, (int __user *)arg);
 }
 
@@ -1602,15 +1620,15 @@ static int __f2fs_ioc_setflags(struct inode *inode, unsigned int flags)
 
        oldflags = fi->i_flags;
 
-       if ((flags ^ oldflags) & (FS_APPEND_FL | FS_IMMUTABLE_FL))
+       if ((flags ^ oldflags) & (F2FS_APPEND_FL | F2FS_IMMUTABLE_FL))
                if (!capable(CAP_LINUX_IMMUTABLE))
                        return -EPERM;
 
-       flags = flags & (FS_FL_USER_MODIFIABLE | FS_PROJINHERIT_FL);
-       flags |= oldflags & ~(FS_FL_USER_MODIFIABLE | FS_PROJINHERIT_FL);
+       flags = flags & F2FS_FL_USER_MODIFIABLE;
+       flags |= oldflags & ~F2FS_FL_USER_MODIFIABLE;
        fi->i_flags = flags;
 
-       if (fi->i_flags & FS_PROJINHERIT_FL)
+       if (fi->i_flags & F2FS_PROJINHERIT_FL)
                set_inode_flag(inode, FI_PROJ_INHERIT);
        else
                clear_inode_flag(inode, FI_PROJ_INHERIT);
@@ -1670,6 +1688,8 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
 
        inode_lock(inode);
 
+       down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
+
        if (f2fs_is_atomic_file(inode))
                goto out;
 
@@ -1677,28 +1697,25 @@ static int f2fs_ioc_start_atomic_write(struct file *filp)
        if (ret)
                goto out;
 
-       set_inode_flag(inode, FI_ATOMIC_FILE);
-       set_inode_flag(inode, FI_HOT_DATA);
-       f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
-
        if (!get_dirty_pages(inode))
-               goto inc_stat;
+               goto skip_flush;
 
        f2fs_msg(F2FS_I_SB(inode)->sb, KERN_WARNING,
                "Unexpected flush for atomic writes: ino=%lu, npages=%u",
                                        inode->i_ino, get_dirty_pages(inode));
        ret = filemap_write_and_wait_range(inode->i_mapping, 0, LLONG_MAX);
-       if (ret) {
-               clear_inode_flag(inode, FI_ATOMIC_FILE);
-               clear_inode_flag(inode, FI_HOT_DATA);
+       if (ret)
                goto out;
-       }
+skip_flush:
+       set_inode_flag(inode, FI_ATOMIC_FILE);
+       clear_inode_flag(inode, FI_ATOMIC_REVOKE_REQUEST);
+       f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
 
-inc_stat:
        F2FS_I(inode)->inmem_task = current;
        stat_inc_atomic_write(inode);
        stat_update_max_atomic_write(inode);
 out:
+       up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
        inode_unlock(inode);
        mnt_drop_write_file(filp);
        return ret;
@@ -1718,27 +1735,33 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)
 
        inode_lock(inode);
 
-       down_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
+       down_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
 
-       if (f2fs_is_volatile_file(inode))
+       if (f2fs_is_volatile_file(inode)) {
+               ret = -EINVAL;
                goto err_out;
+       }
 
        if (f2fs_is_atomic_file(inode)) {
-               ret = commit_inmem_pages(inode);
+               ret = f2fs_commit_inmem_pages(inode);
                if (ret)
                        goto err_out;
 
                ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 0, true);
                if (!ret) {
                        clear_inode_flag(inode, FI_ATOMIC_FILE);
-                       clear_inode_flag(inode, FI_HOT_DATA);
+                       F2FS_I(inode)->i_gc_failures[GC_FAILURE_ATOMIC] = 0;
                        stat_dec_atomic_write(inode);
                }
        } else {
                ret = f2fs_do_sync_file(filp, 0, LLONG_MAX, 1, false);
        }
 err_out:
-       up_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
+       if (is_inode_flag_set(inode, FI_ATOMIC_REVOKE_REQUEST)) {
+               clear_inode_flag(inode, FI_ATOMIC_REVOKE_REQUEST);
+               ret = -EINVAL;
+       }
+       up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
        inode_unlock(inode);
        mnt_drop_write_file(filp);
        return ret;
@@ -1823,7 +1846,7 @@ static int f2fs_ioc_abort_volatile_write(struct file *filp)
        inode_lock(inode);
 
        if (f2fs_is_atomic_file(inode))
-               drop_inmem_pages(inode);
+               f2fs_drop_inmem_pages(inode);
        if (f2fs_is_volatile_file(inode)) {
                clear_inode_flag(inode, FI_VOLATILE_FILE);
                stat_dec_volatile_write(inode);
@@ -1851,9 +1874,11 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
        if (get_user(in, (__u32 __user *)arg))
                return -EFAULT;
 
-       ret = mnt_want_write_file(filp);
-       if (ret)
-               return ret;
+       if (in != F2FS_GOING_DOWN_FULLSYNC) {
+               ret = mnt_want_write_file(filp);
+               if (ret)
+                       return ret;
+       }
 
        switch (in) {
        case F2FS_GOING_DOWN_FULLSYNC:
@@ -1878,7 +1903,7 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
                f2fs_stop_checkpoint(sbi, false);
                break;
        case F2FS_GOING_DOWN_METAFLUSH:
-               sync_meta_pages(sbi, META, LONG_MAX, FS_META_IO);
+               f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_META_IO);
                f2fs_stop_checkpoint(sbi, false);
                break;
        default:
@@ -1886,15 +1911,16 @@ static int f2fs_ioc_shutdown(struct file *filp, unsigned long arg)
                goto out;
        }
 
-       stop_gc_thread(sbi);
-       stop_discard_thread(sbi);
+       f2fs_stop_gc_thread(sbi);
+       f2fs_stop_discard_thread(sbi);
 
-       drop_discard_cmd(sbi);
+       f2fs_drop_discard_cmd(sbi);
        clear_opt(sbi, DISCARD);
 
        f2fs_update_time(sbi, REQ_TIME);
 out:
-       mnt_drop_write_file(filp);
+       if (in != F2FS_GOING_DOWN_FULLSYNC)
+               mnt_drop_write_file(filp);
        return ret;
 }
 
@@ -2053,15 +2079,15 @@ static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg)
        if (f2fs_readonly(sbi->sb))
                return -EROFS;
 
+       end = range.start + range.len;
+       if (range.start < MAIN_BLKADDR(sbi) || end >= MAX_BLKADDR(sbi)) {
+               return -EINVAL;
+       }
+
        ret = mnt_want_write_file(filp);
        if (ret)
                return ret;
 
-       end = range.start + range.len;
-       if (range.start < MAIN_BLKADDR(sbi) || end >= MAX_BLKADDR(sbi)) {
-               ret = -EINVAL;
-               goto out;
-       }
 do_more:
        if (!range.sync) {
                if (!mutex_trylock(&sbi->gc_mutex)) {
@@ -2081,7 +2107,7 @@ static int f2fs_ioc_gc_range(struct file *filp, unsigned long arg)
        return ret;
 }
 
-static int f2fs_ioc_write_checkpoint(struct file *filp, unsigned long arg)
+static int f2fs_ioc_f2fs_write_checkpoint(struct file *filp, unsigned long arg)
 {
        struct inode *inode = file_inode(filp);
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -2110,7 +2136,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
        struct inode *inode = file_inode(filp);
        struct f2fs_map_blocks map = { .m_next_extent = NULL,
                                        .m_seg_type = NO_CHECK_TYPE };
-       struct extent_info ei = {0,0,0};
+       struct extent_info ei = {0, 0, 0};
        pgoff_t pg_start, pg_end, next_pgofs;
        unsigned int blk_per_seg = sbi->blocks_per_seg;
        unsigned int total = 0, sec_num;
@@ -2119,7 +2145,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
        int err;
 
        /* if in-place-update policy is enabled, don't waste time here */
-       if (should_update_inplace(inode, NULL))
+       if (f2fs_should_update_inplace(inode, NULL))
                return -EINVAL;
 
        pg_start = range->start >> PAGE_SHIFT;
@@ -2214,7 +2240,7 @@ static int f2fs_defragment_range(struct f2fs_sb_info *sbi,
                while (idx < map.m_lblk + map.m_len && cnt < blk_per_seg) {
                        struct page *page;
 
-                       page = get_lock_data_page(inode, idx, true);
+                       page = f2fs_get_lock_data_page(inode, idx, true);
                        if (IS_ERR(page)) {
                                err = PTR_ERR(page);
                                goto clear_out;
@@ -2325,12 +2351,12 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
        }
 
        inode_lock(src);
-       down_write(&F2FS_I(src)->dio_rwsem[WRITE]);
+       down_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);
        if (src != dst) {
                ret = -EBUSY;
                if (!inode_trylock(dst))
                        goto out;
-               if (!down_write_trylock(&F2FS_I(dst)->dio_rwsem[WRITE])) {
+               if (!down_write_trylock(&F2FS_I(dst)->i_gc_rwsem[WRITE])) {
                        inode_unlock(dst);
                        goto out;
                }
@@ -2392,11 +2418,11 @@ static int f2fs_move_file_range(struct file *file_in, loff_t pos_in,
        f2fs_unlock_op(sbi);
 out_unlock:
        if (src != dst) {
-               up_write(&F2FS_I(dst)->dio_rwsem[WRITE]);
+               up_write(&F2FS_I(dst)->i_gc_rwsem[WRITE]);
                inode_unlock(dst);
        }
 out:
-       up_write(&F2FS_I(src)->dio_rwsem[WRITE]);
+       up_write(&F2FS_I(src)->i_gc_rwsem[WRITE]);
        inode_unlock(src);
        return ret;
 }
@@ -2554,7 +2580,7 @@ static int f2fs_ioc_setproject(struct file *filp, __u32 projid)
        if (IS_NOQUOTA(inode))
                goto out_unlock;
 
-       ipage = get_node_page(sbi, inode->i_ino);
+       ipage = f2fs_get_node_page(sbi, inode->i_ino);
        if (IS_ERR(ipage)) {
                err = PTR_ERR(ipage);
                goto out_unlock;
@@ -2568,7 +2594,9 @@ static int f2fs_ioc_setproject(struct file *filp, __u32 projid)
        }
        f2fs_put_page(ipage, 1);
 
-       dquot_initialize(inode);
+       err = dquot_initialize(inode);
+       if (err)
+               goto out_unlock;
 
        transfer_to[PRJQUOTA] = dqget(sb, make_kqid_projid(kprojid));
        if (!IS_ERR(transfer_to[PRJQUOTA])) {
@@ -2601,17 +2629,17 @@ static inline __u32 f2fs_iflags_to_xflags(unsigned long iflags)
 {
        __u32 xflags = 0;
 
-       if (iflags & FS_SYNC_FL)
+       if (iflags & F2FS_SYNC_FL)
                xflags |= FS_XFLAG_SYNC;
-       if (iflags & FS_IMMUTABLE_FL)
+       if (iflags & F2FS_IMMUTABLE_FL)
                xflags |= FS_XFLAG_IMMUTABLE;
-       if (iflags & FS_APPEND_FL)
+       if (iflags & F2FS_APPEND_FL)
                xflags |= FS_XFLAG_APPEND;
-       if (iflags & FS_NODUMP_FL)
+       if (iflags & F2FS_NODUMP_FL)
                xflags |= FS_XFLAG_NODUMP;
-       if (iflags & FS_NOATIME_FL)
+       if (iflags & F2FS_NOATIME_FL)
                xflags |= FS_XFLAG_NOATIME;
-       if (iflags & FS_PROJINHERIT_FL)
+       if (iflags & F2FS_PROJINHERIT_FL)
                xflags |= FS_XFLAG_PROJINHERIT;
        return xflags;
 }
@@ -2620,31 +2648,23 @@ static inline __u32 f2fs_iflags_to_xflags(unsigned long iflags)
                                  FS_XFLAG_APPEND | FS_XFLAG_NODUMP | \
                                  FS_XFLAG_NOATIME | FS_XFLAG_PROJINHERIT)
 
-/* Flags we can manipulate with through EXT4_IOC_FSSETXATTR */
-#define F2FS_FL_XFLAG_VISIBLE          (FS_SYNC_FL | \
-                                        FS_IMMUTABLE_FL | \
-                                        FS_APPEND_FL | \
-                                        FS_NODUMP_FL | \
-                                        FS_NOATIME_FL | \
-                                        FS_PROJINHERIT_FL)
-
 /* Transfer xflags flags to internal */
 static inline unsigned long f2fs_xflags_to_iflags(__u32 xflags)
 {
        unsigned long iflags = 0;
 
        if (xflags & FS_XFLAG_SYNC)
-               iflags |= FS_SYNC_FL;
+               iflags |= F2FS_SYNC_FL;
        if (xflags & FS_XFLAG_IMMUTABLE)
-               iflags |= FS_IMMUTABLE_FL;
+               iflags |= F2FS_IMMUTABLE_FL;
        if (xflags & FS_XFLAG_APPEND)
-               iflags |= FS_APPEND_FL;
+               iflags |= F2FS_APPEND_FL;
        if (xflags & FS_XFLAG_NODUMP)
-               iflags |= FS_NODUMP_FL;
+               iflags |= F2FS_NODUMP_FL;
        if (xflags & FS_XFLAG_NOATIME)
-               iflags |= FS_NOATIME_FL;
+               iflags |= F2FS_NOATIME_FL;
        if (xflags & FS_XFLAG_PROJINHERIT)
-               iflags |= FS_PROJINHERIT_FL;
+               iflags |= F2FS_PROJINHERIT_FL;
 
        return iflags;
 }
@@ -2657,7 +2677,7 @@ static int f2fs_ioc_fsgetxattr(struct file *filp, unsigned long arg)
 
        memset(&fa, 0, sizeof(struct fsxattr));
        fa.fsx_xflags = f2fs_iflags_to_xflags(fi->i_flags &
-                               (FS_FL_USER_VISIBLE | FS_PROJINHERIT_FL));
+                               F2FS_FL_USER_VISIBLE);
 
        if (f2fs_sb_has_project_quota(inode->i_sb))
                fa.fsx_projid = (__u32)from_kprojid(&init_user_ns,
@@ -2717,12 +2737,14 @@ int f2fs_pin_file_control(struct inode *inode, bool inc)
 
        /* Use i_gc_failures for normal file as a risk signal. */
        if (inc)
-               f2fs_i_gc_failures_write(inode, fi->i_gc_failures + 1);
+               f2fs_i_gc_failures_write(inode,
+                               fi->i_gc_failures[GC_FAILURE_PIN] + 1);
 
-       if (fi->i_gc_failures > sbi->gc_pin_file_threshold) {
+       if (fi->i_gc_failures[GC_FAILURE_PIN] > sbi->gc_pin_file_threshold) {
                f2fs_msg(sbi->sb, KERN_WARNING,
                        "%s: Enable GC = ino %lx after %x GC trials\n",
-                       __func__, inode->i_ino, fi->i_gc_failures);
+                       __func__, inode->i_ino,
+                       fi->i_gc_failures[GC_FAILURE_PIN]);
                clear_inode_flag(inode, FI_PIN_FILE);
                return -EAGAIN;
        }
@@ -2753,14 +2775,14 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)
 
        inode_lock(inode);
 
-       if (should_update_outplace(inode, NULL)) {
+       if (f2fs_should_update_outplace(inode, NULL)) {
                ret = -EINVAL;
                goto out;
        }
 
        if (!pin) {
                clear_inode_flag(inode, FI_PIN_FILE);
-               F2FS_I(inode)->i_gc_failures = 1;
+               F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN] = 1;
                goto done;
        }
 
@@ -2773,7 +2795,7 @@ static int f2fs_ioc_set_pin_file(struct file *filp, unsigned long arg)
                goto out;
 
        set_inode_flag(inode, FI_PIN_FILE);
-       ret = F2FS_I(inode)->i_gc_failures;
+       ret = F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN];
 done:
        f2fs_update_time(F2FS_I_SB(inode), REQ_TIME);
 out:
@@ -2788,7 +2810,7 @@ static int f2fs_ioc_get_pin_file(struct file *filp, unsigned long arg)
        __u32 pin = 0;
 
        if (is_inode_flag_set(inode, FI_PIN_FILE))
-               pin = F2FS_I(inode)->i_gc_failures;
+               pin = F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN];
        return put_user(pin, (u32 __user *)arg);
 }
 
@@ -2812,9 +2834,9 @@ int f2fs_precache_extents(struct inode *inode)
        while (map.m_lblk < end) {
                map.m_len = end - map.m_lblk;
 
-               down_write(&fi->dio_rwsem[WRITE]);
+               down_write(&fi->i_gc_rwsem[WRITE]);
                err = f2fs_map_blocks(inode, &map, 0, F2FS_GET_BLOCK_PRECACHE);
-               up_write(&fi->dio_rwsem[WRITE]);
+               up_write(&fi->i_gc_rwsem[WRITE]);
                if (err)
                        return err;
 
@@ -2866,7 +2888,7 @@ long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
        case F2FS_IOC_GARBAGE_COLLECT_RANGE:
                return f2fs_ioc_gc_range(filp, arg);
        case F2FS_IOC_WRITE_CHECKPOINT:
-               return f2fs_ioc_write_checkpoint(filp, arg);
+               return f2fs_ioc_f2fs_write_checkpoint(filp, arg);
        case F2FS_IOC_DEFRAGMENT:
                return f2fs_ioc_defragment(filp, arg);
        case F2FS_IOC_MOVE_RANGE:
@@ -2894,7 +2916,6 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
 {
        struct file *file = iocb->ki_filp;
        struct inode *inode = file_inode(file);
-       struct blk_plug plug;
        ssize_t ret;
 
        if (unlikely(f2fs_cp_error(F2FS_I_SB(inode))))
@@ -2924,6 +2945,8 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
                                                iov_iter_count(from)) ||
                                        f2fs_has_inline_data(inode) ||
                                        f2fs_force_buffered_io(inode, WRITE)) {
+                                               clear_inode_flag(inode,
+                                                               FI_NO_PREALLOC);
                                                inode_unlock(inode);
                                                return -EAGAIN;
                                }
@@ -2939,9 +2962,7 @@ static ssize_t f2fs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
                                return err;
                        }
                }
-               blk_start_plug(&plug);
                ret = __generic_file_write_iter(iocb, from);
-               blk_finish_plug(&plug);
                clear_inode_flag(inode, FI_NO_PREALLOC);
 
                /* if we couldn't write data, we should deallocate blocks. */
index 9327411fd93b232bb18fc515d06e6122c7a608fa..9093be6e7a7db80ca8c1f07f391875541ec99e13 100644 (file)
@@ -76,7 +76,7 @@ static int gc_thread_func(void *data)
                 * invalidated soon after by user update or deletion.
                 * So, I'd like to wait some time to collect dirty segments.
                 */
-               if (gc_th->gc_urgent) {
+               if (sbi->gc_mode == GC_URGENT) {
                        wait_ms = gc_th->urgent_sleep_time;
                        mutex_lock(&sbi->gc_mutex);
                        goto do_gc;
@@ -114,7 +114,7 @@ static int gc_thread_func(void *data)
        return 0;
 }
 
-int start_gc_thread(struct f2fs_sb_info *sbi)
+int f2fs_start_gc_thread(struct f2fs_sb_info *sbi)
 {
        struct f2fs_gc_kthread *gc_th;
        dev_t dev = sbi->sb->s_bdev->bd_dev;
@@ -131,8 +131,6 @@ int start_gc_thread(struct f2fs_sb_info *sbi)
        gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME;
        gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME;
 
-       gc_th->gc_idle = 0;
-       gc_th->gc_urgent = 0;
        gc_th->gc_wake= 0;
 
        sbi->gc_thread = gc_th;
@@ -148,7 +146,7 @@ int start_gc_thread(struct f2fs_sb_info *sbi)
        return err;
 }
 
-void stop_gc_thread(struct f2fs_sb_info *sbi)
+void f2fs_stop_gc_thread(struct f2fs_sb_info *sbi)
 {
        struct f2fs_gc_kthread *gc_th = sbi->gc_thread;
        if (!gc_th)
@@ -158,21 +156,19 @@ void stop_gc_thread(struct f2fs_sb_info *sbi)
        sbi->gc_thread = NULL;
 }
 
-static int select_gc_type(struct f2fs_gc_kthread *gc_th, int gc_type)
+static int select_gc_type(struct f2fs_sb_info *sbi, int gc_type)
 {
        int gc_mode = (gc_type == BG_GC) ? GC_CB : GC_GREEDY;
 
-       if (!gc_th)
-               return gc_mode;
-
-       if (gc_th->gc_idle) {
-               if (gc_th->gc_idle == 1)
-                       gc_mode = GC_CB;
-               else if (gc_th->gc_idle == 2)
-                       gc_mode = GC_GREEDY;
-       }
-       if (gc_th->gc_urgent)
+       switch (sbi->gc_mode) {
+       case GC_IDLE_CB:
+               gc_mode = GC_CB;
+               break;
+       case GC_IDLE_GREEDY:
+       case GC_URGENT:
                gc_mode = GC_GREEDY;
+               break;
+       }
        return gc_mode;
 }
 
@@ -187,7 +183,7 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
                p->max_search = dirty_i->nr_dirty[type];
                p->ofs_unit = 1;
        } else {
-               p->gc_mode = select_gc_type(sbi->gc_thread, gc_type);
+               p->gc_mode = select_gc_type(sbi, gc_type);
                p->dirty_segmap = dirty_i->dirty_segmap[DIRTY];
                p->max_search = dirty_i->nr_dirty[DIRTY];
                p->ofs_unit = sbi->segs_per_sec;
@@ -195,7 +191,7 @@ static void select_policy(struct f2fs_sb_info *sbi, int gc_type,
 
        /* we need to check every dirty segments in the FG_GC case */
        if (gc_type != FG_GC &&
-                       (sbi->gc_thread && !sbi->gc_thread->gc_urgent) &&
+                       (sbi->gc_mode != GC_URGENT) &&
                        p->max_search > sbi->max_victim_search)
                p->max_search = sbi->max_victim_search;
 
@@ -234,10 +230,6 @@ static unsigned int check_bg_victims(struct f2fs_sb_info *sbi)
        for_each_set_bit(secno, dirty_i->victim_secmap, MAIN_SECS(sbi)) {
                if (sec_usage_check(sbi, secno))
                        continue;
-
-               if (no_fggc_candidate(sbi, secno))
-                       continue;
-
                clear_bit(secno, dirty_i->victim_secmap);
                return GET_SEG_FROM_SEC(sbi, secno);
        }
@@ -377,9 +369,6 @@ static int get_victim_by_default(struct f2fs_sb_info *sbi,
                        goto next;
                if (gc_type == BG_GC && test_bit(secno, dirty_i->victim_secmap))
                        goto next;
-               if (gc_type == FG_GC && p.alloc_mode == LFS &&
-                                       no_fggc_candidate(sbi, secno))
-                       goto next;
 
                cost = get_gc_cost(sbi, segno, &p);
 
@@ -440,7 +429,7 @@ static void add_gc_inode(struct gc_inode_list *gc_list, struct inode *inode)
                iput(inode);
                return;
        }
-       new_ie = f2fs_kmem_cache_alloc(inode_entry_slab, GFP_NOFS);
+       new_ie = f2fs_kmem_cache_alloc(f2fs_inode_entry_slab, GFP_NOFS);
        new_ie->inode = inode;
 
        f2fs_radix_tree_insert(&gc_list->iroot, inode->i_ino, new_ie);
@@ -454,7 +443,7 @@ static void put_gc_inode(struct gc_inode_list *gc_list)
                radix_tree_delete(&gc_list->iroot, ie->inode->i_ino);
                iput(ie->inode);
                list_del(&ie->list);
-               kmem_cache_free(inode_entry_slab, ie);
+               kmem_cache_free(f2fs_inode_entry_slab, ie);
        }
 }
 
@@ -484,12 +473,16 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
        block_t start_addr;
        int off;
        int phase = 0;
+       bool fggc = (gc_type == FG_GC);
 
        start_addr = START_BLOCK(sbi, segno);
 
 next_step:
        entry = sum;
 
+       if (fggc && phase == 2)
+               atomic_inc(&sbi->wb_sync_req[NODE]);
+
        for (off = 0; off < sbi->blocks_per_seg; off++, entry++) {
                nid_t nid = le32_to_cpu(entry->nid);
                struct page *node_page;
@@ -503,39 +496,42 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
                        continue;
 
                if (phase == 0) {
-                       ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), 1,
+                       f2fs_ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), 1,
                                                        META_NAT, true);
                        continue;
                }
 
                if (phase == 1) {
-                       ra_node_page(sbi, nid);
+                       f2fs_ra_node_page(sbi, nid);
                        continue;
                }
 
                /* phase == 2 */
-               node_page = get_node_page(sbi, nid);
+               node_page = f2fs_get_node_page(sbi, nid);
                if (IS_ERR(node_page))
                        continue;
 
-               /* block may become invalid during get_node_page */
+               /* block may become invalid during f2fs_get_node_page */
                if (check_valid_map(sbi, segno, off) == 0) {
                        f2fs_put_page(node_page, 1);
                        continue;
                }
 
-               get_node_info(sbi, nid, &ni);
+               f2fs_get_node_info(sbi, nid, &ni);
                if (ni.blk_addr != start_addr + off) {
                        f2fs_put_page(node_page, 1);
                        continue;
                }
 
-               move_node_page(node_page, gc_type);
+               f2fs_move_node_page(node_page, gc_type);
                stat_inc_node_blk_count(sbi, 1, gc_type);
        }
 
        if (++phase < 3)
                goto next_step;
+
+       if (fggc)
+               atomic_dec(&sbi->wb_sync_req[NODE]);
 }
 
 /*
@@ -545,7 +541,7 @@ static void gc_node_segment(struct f2fs_sb_info *sbi,
  * as indirect or double indirect node blocks, are given, it must be a caller's
  * bug.
  */
-block_t start_bidx_of_node(unsigned int node_ofs, struct inode *inode)
+block_t f2fs_start_bidx_of_node(unsigned int node_ofs, struct inode *inode)
 {
        unsigned int indirect_blks = 2 * NIDS_PER_BLOCK + 4;
        unsigned int bidx;
@@ -576,11 +572,11 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
        nid = le32_to_cpu(sum->nid);
        ofs_in_node = le16_to_cpu(sum->ofs_in_node);
 
-       node_page = get_node_page(sbi, nid);
+       node_page = f2fs_get_node_page(sbi, nid);
        if (IS_ERR(node_page))
                return false;
 
-       get_node_info(sbi, nid, dni);
+       f2fs_get_node_info(sbi, nid, dni);
 
        if (sum->version != dni->version) {
                f2fs_msg(sbi->sb, KERN_WARNING,
@@ -603,7 +599,7 @@ static bool is_alive(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
  * This can be used to move blocks, aka LBAs, directly on disk.
  */
 static void move_data_block(struct inode *inode, block_t bidx,
-                                       unsigned int segno, int off)
+                               int gc_type, unsigned int segno, int off)
 {
        struct f2fs_io_info fio = {
                .sbi = F2FS_I_SB(inode),
@@ -614,6 +610,7 @@ static void move_data_block(struct inode *inode, block_t bidx,
                .op_flags = 0,
                .encrypted_page = NULL,
                .in_list = false,
+               .retry = false,
        };
        struct dnode_of_data dn;
        struct f2fs_summary sum;
@@ -621,6 +618,7 @@ static void move_data_block(struct inode *inode, block_t bidx,
        struct page *page;
        block_t newaddr;
        int err;
+       bool lfs_mode = test_opt(fio.sbi, LFS);
 
        /* do not read out */
        page = f2fs_grab_cache_page(inode->i_mapping, bidx, false);
@@ -630,8 +628,11 @@ static void move_data_block(struct inode *inode, block_t bidx,
        if (!check_valid_map(F2FS_I_SB(inode), segno, off))
                goto out;
 
-       if (f2fs_is_atomic_file(inode))
+       if (f2fs_is_atomic_file(inode)) {
+               F2FS_I(inode)->i_gc_failures[GC_FAILURE_ATOMIC]++;
+               F2FS_I_SB(inode)->skipped_atomic_files[gc_type]++;
                goto out;
+       }
 
        if (f2fs_is_pinned_file(inode)) {
                f2fs_pin_file_control(inode, true);
@@ -639,7 +640,7 @@ static void move_data_block(struct inode *inode, block_t bidx,
        }
 
        set_new_dnode(&dn, inode, NULL, NULL, 0);
-       err = get_dnode_of_data(&dn, bidx, LOOKUP_NODE);
+       err = f2fs_get_dnode_of_data(&dn, bidx, LOOKUP_NODE);
        if (err)
                goto out;
 
@@ -654,14 +655,17 @@ static void move_data_block(struct inode *inode, block_t bidx,
         */
        f2fs_wait_on_page_writeback(page, DATA, true);
 
-       get_node_info(fio.sbi, dn.nid, &ni);
+       f2fs_get_node_info(fio.sbi, dn.nid, &ni);
        set_summary(&sum, dn.nid, dn.ofs_in_node, ni.version);
 
        /* read page */
        fio.page = page;
        fio.new_blkaddr = fio.old_blkaddr = dn.data_blkaddr;
 
-       allocate_data_block(fio.sbi, NULL, fio.old_blkaddr, &newaddr,
+       if (lfs_mode)
+               down_write(&fio.sbi->io_order_lock);
+
+       f2fs_allocate_data_block(fio.sbi, NULL, fio.old_blkaddr, &newaddr,
                                        &sum, CURSEG_COLD_DATA, NULL, false);
 
        fio.encrypted_page = f2fs_pagecache_get_page(META_MAPPING(fio.sbi),
@@ -693,6 +697,7 @@ static void move_data_block(struct inode *inode, block_t bidx,
                dec_page_count(fio.sbi, F2FS_DIRTY_META);
 
        set_page_writeback(fio.encrypted_page);
+       ClearPageError(page);
 
        /* allocate block address */
        f2fs_wait_on_page_writeback(dn.node_page, NODE, true);
@@ -700,8 +705,8 @@ static void move_data_block(struct inode *inode, block_t bidx,
        fio.op = REQ_OP_WRITE;
        fio.op_flags = REQ_SYNC;
        fio.new_blkaddr = newaddr;
-       err = f2fs_submit_page_write(&fio);
-       if (err) {
+       f2fs_submit_page_write(&fio);
+       if (fio.retry) {
                if (PageWriteback(fio.encrypted_page))
                        end_page_writeback(fio.encrypted_page);
                goto put_page_out;
@@ -716,8 +721,10 @@ static void move_data_block(struct inode *inode, block_t bidx,
 put_page_out:
        f2fs_put_page(fio.encrypted_page, 1);
 recover_block:
+       if (lfs_mode)
+               up_write(&fio.sbi->io_order_lock);
        if (err)
-               __f2fs_replace_block(fio.sbi, &sum, newaddr, fio.old_blkaddr,
+               f2fs_do_replace_block(fio.sbi, &sum, newaddr, fio.old_blkaddr,
                                                                true, true);
 put_out:
        f2fs_put_dnode(&dn);
@@ -730,15 +737,18 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type,
 {
        struct page *page;
 
-       page = get_lock_data_page(inode, bidx, true);
+       page = f2fs_get_lock_data_page(inode, bidx, true);
        if (IS_ERR(page))
                return;
 
        if (!check_valid_map(F2FS_I_SB(inode), segno, off))
                goto out;
 
-       if (f2fs_is_atomic_file(inode))
+       if (f2fs_is_atomic_file(inode)) {
+               F2FS_I(inode)->i_gc_failures[GC_FAILURE_ATOMIC]++;
+               F2FS_I_SB(inode)->skipped_atomic_files[gc_type]++;
                goto out;
+       }
        if (f2fs_is_pinned_file(inode)) {
                if (gc_type == FG_GC)
                        f2fs_pin_file_control(inode, true);
@@ -772,15 +782,20 @@ static void move_data_page(struct inode *inode, block_t bidx, int gc_type,
                f2fs_wait_on_page_writeback(page, DATA, true);
                if (clear_page_dirty_for_io(page)) {
                        inode_dec_dirty_pages(inode);
-                       remove_dirty_inode(inode);
+                       f2fs_remove_dirty_inode(inode);
                }
 
                set_cold_data(page);
 
-               err = do_write_data_page(&fio);
-               if (err == -ENOMEM && is_dirty) {
-                       congestion_wait(BLK_RW_ASYNC, HZ/50);
-                       goto retry;
+               err = f2fs_do_write_data_page(&fio);
+               if (err) {
+                       clear_cold_data(page);
+                       if (err == -ENOMEM) {
+                               congestion_wait(BLK_RW_ASYNC, HZ/50);
+                               goto retry;
+                       }
+                       if (is_dirty)
+                               set_page_dirty(page);
                }
        }
 out:
@@ -824,13 +839,13 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
                        continue;
 
                if (phase == 0) {
-                       ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), 1,
+                       f2fs_ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), 1,
                                                        META_NAT, true);
                        continue;
                }
 
                if (phase == 1) {
-                       ra_node_page(sbi, nid);
+                       f2fs_ra_node_page(sbi, nid);
                        continue;
                }
 
@@ -839,7 +854,7 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
                        continue;
 
                if (phase == 2) {
-                       ra_node_page(sbi, dni.ino);
+                       f2fs_ra_node_page(sbi, dni.ino);
                        continue;
                }
 
@@ -850,23 +865,23 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
                        if (IS_ERR(inode) || is_bad_inode(inode))
                                continue;
 
-                       /* if encrypted inode, let's go phase 3 */
-                       if (f2fs_encrypted_file(inode)) {
+                       /* if inode uses special I/O path, let's go phase 3 */
+                       if (f2fs_post_read_required(inode)) {
                                add_gc_inode(gc_list, inode);
                                continue;
                        }
 
                        if (!down_write_trylock(
-                               &F2FS_I(inode)->dio_rwsem[WRITE])) {
+                               &F2FS_I(inode)->i_gc_rwsem[WRITE])) {
                                iput(inode);
                                continue;
                        }
 
-                       start_bidx = start_bidx_of_node(nofs, inode);
-                       data_page = get_read_data_page(inode,
+                       start_bidx = f2fs_start_bidx_of_node(nofs, inode);
+                       data_page = f2fs_get_read_data_page(inode,
                                        start_bidx + ofs_in_node, REQ_RAHEAD,
                                        true);
-                       up_write(&F2FS_I(inode)->dio_rwsem[WRITE]);
+                       up_write(&F2FS_I(inode)->i_gc_rwsem[WRITE]);
                        if (IS_ERR(data_page)) {
                                iput(inode);
                                continue;
@@ -884,11 +899,11 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
                        bool locked = false;
 
                        if (S_ISREG(inode->i_mode)) {
-                               if (!down_write_trylock(&fi->dio_rwsem[READ]))
+                               if (!down_write_trylock(&fi->i_gc_rwsem[READ]))
                                        continue;
                                if (!down_write_trylock(
-                                               &fi->dio_rwsem[WRITE])) {
-                                       up_write(&fi->dio_rwsem[READ]);
+                                               &fi->i_gc_rwsem[WRITE])) {
+                                       up_write(&fi->i_gc_rwsem[READ]);
                                        continue;
                                }
                                locked = true;
@@ -897,17 +912,18 @@ static void gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
                                inode_dio_wait(inode);
                        }
 
-                       start_bidx = start_bidx_of_node(nofs, inode)
+                       start_bidx = f2fs_start_bidx_of_node(nofs, inode)
                                                                + ofs_in_node;
-                       if (f2fs_encrypted_file(inode))
-                               move_data_block(inode, start_bidx, segno, off);
+                       if (f2fs_post_read_required(inode))
+                               move_data_block(inode, start_bidx, gc_type,
+                                                               segno, off);
                        else
                                move_data_page(inode, start_bidx, gc_type,
                                                                segno, off);
 
                        if (locked) {
-                               up_write(&fi->dio_rwsem[WRITE]);
-                               up_write(&fi->dio_rwsem[READ]);
+                               up_write(&fi->i_gc_rwsem[WRITE]);
+                               up_write(&fi->i_gc_rwsem[READ]);
                        }
 
                        stat_inc_data_blk_count(sbi, 1, gc_type);
@@ -946,12 +962,12 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi,
 
        /* readahead multi ssa blocks those have contiguous address */
        if (sbi->segs_per_sec > 1)
-               ra_meta_pages(sbi, GET_SUM_BLOCK(sbi, segno),
+               f2fs_ra_meta_pages(sbi, GET_SUM_BLOCK(sbi, segno),
                                        sbi->segs_per_sec, META_SSA, true);
 
        /* reference all summary page */
        while (segno < end_segno) {
-               sum_page = get_sum_page(sbi, segno++);
+               sum_page = f2fs_get_sum_page(sbi, segno++);
                unlock_page(sum_page);
        }
 
@@ -1017,6 +1033,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
                .ilist = LIST_HEAD_INIT(gc_list.ilist),
                .iroot = RADIX_TREE_INIT(gc_list.iroot, GFP_NOFS),
        };
+       unsigned long long last_skipped = sbi->skipped_atomic_files[FG_GC];
+       unsigned int skipped_round = 0, round = 0;
 
        trace_f2fs_gc_begin(sbi->sb, sync, background,
                                get_pages(sbi, F2FS_DIRTY_NODES),
@@ -1045,7 +1063,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
                 * secure free segments which doesn't need fggc any more.
                 */
                if (prefree_segments(sbi)) {
-                       ret = write_checkpoint(sbi, &cpc);
+                       ret = f2fs_write_checkpoint(sbi, &cpc);
                        if (ret)
                                goto stop;
                }
@@ -1068,17 +1086,27 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
                sec_freed++;
        total_freed += seg_freed;
 
+       if (gc_type == FG_GC) {
+               if (sbi->skipped_atomic_files[FG_GC] > last_skipped)
+                       skipped_round++;
+               last_skipped = sbi->skipped_atomic_files[FG_GC];
+               round++;
+       }
+
        if (gc_type == FG_GC)
                sbi->cur_victim_sec = NULL_SEGNO;
 
        if (!sync) {
                if (has_not_enough_free_secs(sbi, sec_freed, 0)) {
+                       if (skipped_round > MAX_SKIP_ATOMIC_COUNT &&
+                               skipped_round * 2 >= round)
+                               f2fs_drop_inmem_pages_all(sbi, true);
                        segno = NULL_SEGNO;
                        goto gc_more;
                }
 
                if (gc_type == FG_GC)
-                       ret = write_checkpoint(sbi, &cpc);
+                       ret = f2fs_write_checkpoint(sbi, &cpc);
        }
 stop:
        SIT_I(sbi)->last_victim[ALLOC_NEXT] = 0;
@@ -1102,19 +1130,10 @@ int f2fs_gc(struct f2fs_sb_info *sbi, bool sync,
        return ret;
 }
 
-void build_gc_manager(struct f2fs_sb_info *sbi)
+void f2fs_build_gc_manager(struct f2fs_sb_info *sbi)
 {
-       u64 main_count, resv_count, ovp_count;
-
        DIRTY_I(sbi)->v_ops = &default_v_ops;
 
-       /* threshold of # of valid blocks in a section for victims of FG_GC */
-       main_count = SM_I(sbi)->main_segments << sbi->log_blocks_per_seg;
-       resv_count = SM_I(sbi)->reserved_segments << sbi->log_blocks_per_seg;
-       ovp_count = SM_I(sbi)->ovp_segments << sbi->log_blocks_per_seg;
-
-       sbi->fggc_threshold = div64_u64((main_count - ovp_count) *
-                               BLKS_PER_SEC(sbi), (main_count - resv_count));
        sbi->gc_pin_file_threshold = DEF_GC_FAILED_PINNED_FILES;
 
        /* give warm/cold data area from slower device */
index b0045d4c8d1e6f74f0da0e0ee1ef9376e0289f33..c8619e408009068c63ff37d35eecc84797eb8130 100644 (file)
@@ -36,8 +36,6 @@ struct f2fs_gc_kthread {
        unsigned int no_gc_sleep_time;
 
        /* for changing gc mode */
-       unsigned int gc_idle;
-       unsigned int gc_urgent;
        unsigned int gc_wake;
 };
 
index 265da200daa8b161e5abe466c992a03629c109ba..043830be5662f865b3c5824da2be23a7641dc6d5 100644 (file)
@@ -25,7 +25,7 @@ bool f2fs_may_inline_data(struct inode *inode)
        if (i_size_read(inode) > MAX_INLINE_DATA(inode))
                return false;
 
-       if (f2fs_encrypted_file(inode))
+       if (f2fs_post_read_required(inode))
                return false;
 
        return true;
@@ -42,7 +42,7 @@ bool f2fs_may_inline_dentry(struct inode *inode)
        return true;
 }
 
-void read_inline_data(struct page *page, struct page *ipage)
+void f2fs_do_read_inline_data(struct page *page, struct page *ipage)
 {
        struct inode *inode = page->mapping->host;
        void *src_addr, *dst_addr;
@@ -64,7 +64,8 @@ void read_inline_data(struct page *page, struct page *ipage)
                SetPageUptodate(page);
 }
 
-void truncate_inline_inode(struct inode *inode, struct page *ipage, u64 from)
+void f2fs_truncate_inline_inode(struct inode *inode,
+                                       struct page *ipage, u64 from)
 {
        void *addr;
 
@@ -85,7 +86,7 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page)
 {
        struct page *ipage;
 
-       ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
+       ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino);
        if (IS_ERR(ipage)) {
                unlock_page(page);
                return PTR_ERR(ipage);
@@ -99,7 +100,7 @@ int f2fs_read_inline_data(struct inode *inode, struct page *page)
        if (page->index)
                zero_user_segment(page, 0, PAGE_SIZE);
        else
-               read_inline_data(page, ipage);
+               f2fs_do_read_inline_data(page, ipage);
 
        if (!PageUptodate(page))
                SetPageUptodate(page);
@@ -131,7 +132,7 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
 
        f2fs_bug_on(F2FS_P_SB(page), PageWriteback(page));
 
-       read_inline_data(page, dn->inode_page);
+       f2fs_do_read_inline_data(page, dn->inode_page);
        set_page_dirty(page);
 
        /* clear dirty state */
@@ -139,20 +140,21 @@ int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
 
        /* write data page to try to make data consistent */
        set_page_writeback(page);
+       ClearPageError(page);
        fio.old_blkaddr = dn->data_blkaddr;
        set_inode_flag(dn->inode, FI_HOT_DATA);
-       write_data_page(dn, &fio);
+       f2fs_outplace_write_data(dn, &fio);
        f2fs_wait_on_page_writeback(page, DATA, true);
        if (dirty) {
                inode_dec_dirty_pages(dn->inode);
-               remove_dirty_inode(dn->inode);
+               f2fs_remove_dirty_inode(dn->inode);
        }
 
        /* this converted inline_data should be recovered. */
        set_inode_flag(dn->inode, FI_APPEND_WRITE);
 
        /* clear inline data and flag after data writeback */
-       truncate_inline_inode(dn->inode, dn->inode_page, 0);
+       f2fs_truncate_inline_inode(dn->inode, dn->inode_page, 0);
        clear_inline_node(dn->inode_page);
 clear_out:
        stat_dec_inline_inode(dn->inode);
@@ -177,7 +179,7 @@ int f2fs_convert_inline_inode(struct inode *inode)
 
        f2fs_lock_op(sbi);
 
-       ipage = get_node_page(sbi, inode->i_ino);
+       ipage = f2fs_get_node_page(sbi, inode->i_ino);
        if (IS_ERR(ipage)) {
                err = PTR_ERR(ipage);
                goto out;
@@ -203,12 +205,10 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
 {
        void *src_addr, *dst_addr;
        struct dnode_of_data dn;
-       struct address_space *mapping = page_mapping(page);
-       unsigned long flags;
        int err;
 
        set_new_dnode(&dn, inode, NULL, NULL, 0);
-       err = get_dnode_of_data(&dn, 0, LOOKUP_NODE);
+       err = f2fs_get_dnode_of_data(&dn, 0, LOOKUP_NODE);
        if (err)
                return err;
 
@@ -226,10 +226,7 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
        kunmap_atomic(src_addr);
        set_page_dirty(dn.inode_page);
 
-       xa_lock_irqsave(&mapping->i_pages, flags);
-       radix_tree_tag_clear(&mapping->i_pages, page_index(page),
-                            PAGECACHE_TAG_DIRTY);
-       xa_unlock_irqrestore(&mapping->i_pages, flags);
+       f2fs_clear_radix_tree_dirty_tag(page);
 
        set_inode_flag(inode, FI_APPEND_WRITE);
        set_inode_flag(inode, FI_DATA_EXIST);
@@ -239,7 +236,7 @@ int f2fs_write_inline_data(struct inode *inode, struct page *page)
        return 0;
 }
 
-bool recover_inline_data(struct inode *inode, struct page *npage)
+bool f2fs_recover_inline_data(struct inode *inode, struct page *npage)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        struct f2fs_inode *ri = NULL;
@@ -260,7 +257,7 @@ bool recover_inline_data(struct inode *inode, struct page *npage)
        if (f2fs_has_inline_data(inode) &&
                        ri && (ri->i_inline & F2FS_INLINE_DATA)) {
 process_inline:
-               ipage = get_node_page(sbi, inode->i_ino);
+               ipage = f2fs_get_node_page(sbi, inode->i_ino);
                f2fs_bug_on(sbi, IS_ERR(ipage));
 
                f2fs_wait_on_page_writeback(ipage, NODE, true);
@@ -278,20 +275,20 @@ bool recover_inline_data(struct inode *inode, struct page *npage)
        }
 
        if (f2fs_has_inline_data(inode)) {
-               ipage = get_node_page(sbi, inode->i_ino);
+               ipage = f2fs_get_node_page(sbi, inode->i_ino);
                f2fs_bug_on(sbi, IS_ERR(ipage));
-               truncate_inline_inode(inode, ipage, 0);
+               f2fs_truncate_inline_inode(inode, ipage, 0);
                clear_inode_flag(inode, FI_INLINE_DATA);
                f2fs_put_page(ipage, 1);
        } else if (ri && (ri->i_inline & F2FS_INLINE_DATA)) {
-               if (truncate_blocks(inode, 0, false))
+               if (f2fs_truncate_blocks(inode, 0, false))
                        return false;
                goto process_inline;
        }
        return false;
 }
 
-struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
+struct f2fs_dir_entry *f2fs_find_in_inline_dir(struct inode *dir,
                        struct fscrypt_name *fname, struct page **res_page)
 {
        struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
@@ -302,7 +299,7 @@ struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
        void *inline_dentry;
        f2fs_hash_t namehash;
 
-       ipage = get_node_page(sbi, dir->i_ino);
+       ipage = f2fs_get_node_page(sbi, dir->i_ino);
        if (IS_ERR(ipage)) {
                *res_page = ipage;
                return NULL;
@@ -313,7 +310,7 @@ struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
        inline_dentry = inline_data_addr(dir, ipage);
 
        make_dentry_ptr_inline(dir, &d, inline_dentry);
-       de = find_target_dentry(fname, namehash, NULL, &d);
+       de = f2fs_find_target_dentry(fname, namehash, NULL, &d);
        unlock_page(ipage);
        if (de)
                *res_page = ipage;
@@ -323,7 +320,7 @@ struct f2fs_dir_entry *find_in_inline_dir(struct inode *dir,
        return de;
 }
 
-int make_empty_inline_dir(struct inode *inode, struct inode *parent,
+int f2fs_make_empty_inline_dir(struct inode *inode, struct inode *parent,
                                                        struct page *ipage)
 {
        struct f2fs_dentry_ptr d;
@@ -332,7 +329,7 @@ int make_empty_inline_dir(struct inode *inode, struct inode *parent,
        inline_dentry = inline_data_addr(inode, ipage);
 
        make_dentry_ptr_inline(inode, &d, inline_dentry);
-       do_make_empty_dir(inode, parent, &d);
+       f2fs_do_make_empty_dir(inode, parent, &d);
 
        set_page_dirty(ipage);
 
@@ -367,7 +364,6 @@ static int f2fs_move_inline_dirents(struct inode *dir, struct page *ipage,
                goto out;
 
        f2fs_wait_on_page_writeback(page, DATA, true);
-       zero_user_segment(page, MAX_INLINE_DATA(dir), PAGE_SIZE);
 
        dentry_blk = page_address(page);
 
@@ -391,7 +387,7 @@ static int f2fs_move_inline_dirents(struct inode *dir, struct page *ipage,
        set_page_dirty(page);
 
        /* clear inline dir and flag after data writeback */
-       truncate_inline_inode(dir, ipage, 0);
+       f2fs_truncate_inline_inode(dir, ipage, 0);
 
        stat_dec_inline_dir(dir);
        clear_inode_flag(dir, FI_INLINE_DENTRY);
@@ -434,7 +430,7 @@ static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry)
                new_name.len = le16_to_cpu(de->name_len);
 
                ino = le32_to_cpu(de->ino);
-               fake_mode = get_de_type(de) << S_SHIFT;
+               fake_mode = f2fs_get_de_type(de) << S_SHIFT;
 
                err = f2fs_add_regular_entry(dir, &new_name, NULL, NULL,
                                                        ino, fake_mode);
@@ -446,8 +442,8 @@ static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry)
        return 0;
 punch_dentry_pages:
        truncate_inode_pages(&dir->i_data, 0);
-       truncate_blocks(dir, 0, false);
-       remove_dirty_inode(dir);
+       f2fs_truncate_blocks(dir, 0, false);
+       f2fs_remove_dirty_inode(dir);
        return err;
 }
 
@@ -465,7 +461,7 @@ static int f2fs_move_rehashed_dirents(struct inode *dir, struct page *ipage,
        }
 
        memcpy(backup_dentry, inline_dentry, MAX_INLINE_DATA(dir));
-       truncate_inline_inode(dir, ipage, 0);
+       f2fs_truncate_inline_inode(dir, ipage, 0);
 
        unlock_page(ipage);
 
@@ -514,14 +510,14 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name,
        struct page *page = NULL;
        int err = 0;
 
-       ipage = get_node_page(sbi, dir->i_ino);
+       ipage = f2fs_get_node_page(sbi, dir->i_ino);
        if (IS_ERR(ipage))
                return PTR_ERR(ipage);
 
        inline_dentry = inline_data_addr(dir, ipage);
        make_dentry_ptr_inline(dir, &d, inline_dentry);
 
-       bit_pos = room_for_filename(d.bitmap, slots, d.max);
+       bit_pos = f2fs_room_for_filename(d.bitmap, slots, d.max);
        if (bit_pos >= d.max) {
                err = f2fs_convert_inline_dir(dir, ipage, inline_dentry);
                if (err)
@@ -532,7 +528,7 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name,
 
        if (inode) {
                down_write(&F2FS_I(inode)->i_sem);
-               page = init_inode_metadata(inode, dir, new_name,
+               page = f2fs_init_inode_metadata(inode, dir, new_name,
                                                orig_name, ipage);
                if (IS_ERR(page)) {
                        err = PTR_ERR(page);
@@ -553,7 +549,7 @@ int f2fs_add_inline_entry(struct inode *dir, const struct qstr *new_name,
                f2fs_put_page(page, 1);
        }
 
-       update_parent_metadata(dir, inode, 0);
+       f2fs_update_parent_metadata(dir, inode, 0);
 fail:
        if (inode)
                up_write(&F2FS_I(inode)->i_sem);
@@ -599,7 +595,7 @@ bool f2fs_empty_inline_dir(struct inode *dir)
        void *inline_dentry;
        struct f2fs_dentry_ptr d;
 
-       ipage = get_node_page(sbi, dir->i_ino);
+       ipage = f2fs_get_node_page(sbi, dir->i_ino);
        if (IS_ERR(ipage))
                return false;
 
@@ -630,7 +626,7 @@ int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx,
        if (ctx->pos == d.max)
                return 0;
 
-       ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
+       ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino);
        if (IS_ERR(ipage))
                return PTR_ERR(ipage);
 
@@ -656,7 +652,7 @@ int f2fs_inline_data_fiemap(struct inode *inode,
        struct page *ipage;
        int err = 0;
 
-       ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
+       ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino);
        if (IS_ERR(ipage))
                return PTR_ERR(ipage);
 
@@ -672,7 +668,7 @@ int f2fs_inline_data_fiemap(struct inode *inode,
                ilen = start + len;
        ilen -= start;
 
-       get_node_info(F2FS_I_SB(inode), inode->i_ino, &ni);
+       f2fs_get_node_info(F2FS_I_SB(inode), inode->i_ino, &ni);
        byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits;
        byteaddr += (char *)inline_data_addr(inode, ipage) -
                                        (char *)F2FS_INODE(ipage);
index e0d9e8f27ed2b1ea3bf2f92f883d07caa7fde7a8..f121c864f4c0d9cfe5f7c6601d23b8af4fe88501 100644 (file)
@@ -36,15 +36,15 @@ void f2fs_set_inode_flags(struct inode *inode)
        unsigned int flags = F2FS_I(inode)->i_flags;
        unsigned int new_fl = 0;
 
-       if (flags & FS_SYNC_FL)
+       if (flags & F2FS_SYNC_FL)
                new_fl |= S_SYNC;
-       if (flags & FS_APPEND_FL)
+       if (flags & F2FS_APPEND_FL)
                new_fl |= S_APPEND;
-       if (flags & FS_IMMUTABLE_FL)
+       if (flags & F2FS_IMMUTABLE_FL)
                new_fl |= S_IMMUTABLE;
-       if (flags & FS_NOATIME_FL)
+       if (flags & F2FS_NOATIME_FL)
                new_fl |= S_NOATIME;
-       if (flags & FS_DIRSYNC_FL)
+       if (flags & F2FS_DIRSYNC_FL)
                new_fl |= S_DIRSYNC;
        if (f2fs_encrypted_inode(inode))
                new_fl |= S_ENCRYPTED;
@@ -72,7 +72,7 @@ static bool __written_first_block(struct f2fs_inode *ri)
 {
        block_t addr = le32_to_cpu(ri->i_addr[offset_in_addr(ri)]);
 
-       if (addr != NEW_ADDR && addr != NULL_ADDR)
+       if (is_valid_blkaddr(addr))
                return true;
        return false;
 }
@@ -117,7 +117,6 @@ static void __recover_inline_status(struct inode *inode, struct page *ipage)
 static bool f2fs_enable_inode_chksum(struct f2fs_sb_info *sbi, struct page *page)
 {
        struct f2fs_inode *ri = &F2FS_NODE(page)->i;
-       int extra_isize = le32_to_cpu(ri->i_extra_isize);
 
        if (!f2fs_sb_has_inode_chksum(sbi->sb))
                return false;
@@ -125,7 +124,8 @@ static bool f2fs_enable_inode_chksum(struct f2fs_sb_info *sbi, struct page *page
        if (!RAW_IS_INODE(F2FS_NODE(page)) || !(ri->i_inline & F2FS_EXTRA_ATTR))
                return false;
 
-       if (!F2FS_FITS_IN_INODE(ri, extra_isize, i_inode_checksum))
+       if (!F2FS_FITS_IN_INODE(ri, le16_to_cpu(ri->i_extra_isize),
+                               i_inode_checksum))
                return false;
 
        return true;
@@ -185,6 +185,21 @@ void f2fs_inode_chksum_set(struct f2fs_sb_info *sbi, struct page *page)
        ri->i_inode_checksum = cpu_to_le32(f2fs_inode_chksum(sbi, page));
 }
 
+static bool sanity_check_inode(struct inode *inode)
+{
+       struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
+
+       if (f2fs_sb_has_flexible_inline_xattr(sbi->sb)
+                       && !f2fs_has_extra_attr(inode)) {
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+               f2fs_msg(sbi->sb, KERN_WARNING,
+                       "%s: corrupted inode ino=%lx, run fsck to fix.",
+                       __func__, inode->i_ino);
+               return false;
+       }
+       return true;
+}
+
 static int do_read_inode(struct inode *inode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -194,14 +209,10 @@ static int do_read_inode(struct inode *inode)
        projid_t i_projid;
 
        /* Check if ino is within scope */
-       if (check_nid_range(sbi, inode->i_ino)) {
-               f2fs_msg(inode->i_sb, KERN_ERR, "bad inode number: %lu",
-                        (unsigned long) inode->i_ino);
-               WARN_ON(1);
+       if (f2fs_check_nid_range(sbi, inode->i_ino))
                return -EINVAL;
-       }
 
-       node_page = get_node_page(sbi, inode->i_ino);
+       node_page = f2fs_get_node_page(sbi, inode->i_ino);
        if (IS_ERR(node_page))
                return PTR_ERR(node_page);
 
@@ -221,8 +232,11 @@ static int do_read_inode(struct inode *inode)
        inode->i_ctime.tv_nsec = le32_to_cpu(ri->i_ctime_nsec);
        inode->i_mtime.tv_nsec = le32_to_cpu(ri->i_mtime_nsec);
        inode->i_generation = le32_to_cpu(ri->i_generation);
-
-       fi->i_current_depth = le32_to_cpu(ri->i_current_depth);
+       if (S_ISDIR(inode->i_mode))
+               fi->i_current_depth = le32_to_cpu(ri->i_current_depth);
+       else if (S_ISREG(inode->i_mode))
+               fi->i_gc_failures[GC_FAILURE_PIN] =
+                                       le16_to_cpu(ri->i_gc_failures);
        fi->i_xattr_nid = le32_to_cpu(ri->i_xattr_nid);
        fi->i_flags = le32_to_cpu(ri->i_flags);
        fi->flags = 0;
@@ -239,7 +253,6 @@ static int do_read_inode(struct inode *inode)
                                        le16_to_cpu(ri->i_extra_isize) : 0;
 
        if (f2fs_sb_has_flexible_inline_xattr(sbi->sb)) {
-               f2fs_bug_on(sbi, !f2fs_has_extra_attr(inode));
                fi->i_inline_xattr_size = le16_to_cpu(ri->i_inline_xattr_size);
        } else if (f2fs_has_inline_xattr(inode) ||
                                f2fs_has_inline_dentry(inode)) {
@@ -265,10 +278,10 @@ static int do_read_inode(struct inode *inode)
        if (__written_first_block(ri))
                set_inode_flag(inode, FI_FIRST_BLOCK_WRITTEN);
 
-       if (!need_inode_block_update(sbi, inode->i_ino))
+       if (!f2fs_need_inode_block_update(sbi, inode->i_ino))
                fi->last_disk_size = inode->i_size;
 
-       if (fi->i_flags & FS_PROJINHERIT_FL)
+       if (fi->i_flags & F2FS_PROJINHERIT_FL)
                set_inode_flag(inode, FI_PROJ_INHERIT);
 
        if (f2fs_has_extra_attr(inode) && f2fs_sb_has_project_quota(sbi->sb) &&
@@ -284,9 +297,9 @@ static int do_read_inode(struct inode *inode)
                fi->i_crtime.tv_nsec = le32_to_cpu(ri->i_crtime_nsec);
        }
 
-       F2FS_I(inode)->i_disk_time[0] = inode->i_atime;
-       F2FS_I(inode)->i_disk_time[1] = inode->i_ctime;
-       F2FS_I(inode)->i_disk_time[2] = inode->i_mtime;
+       F2FS_I(inode)->i_disk_time[0] = timespec64_to_timespec(inode->i_atime);
+       F2FS_I(inode)->i_disk_time[1] = timespec64_to_timespec(inode->i_ctime);
+       F2FS_I(inode)->i_disk_time[2] = timespec64_to_timespec(inode->i_mtime);
        F2FS_I(inode)->i_disk_time[3] = F2FS_I(inode)->i_crtime;
        f2fs_put_page(node_page, 1);
 
@@ -317,13 +330,17 @@ struct inode *f2fs_iget(struct super_block *sb, unsigned long ino)
        ret = do_read_inode(inode);
        if (ret)
                goto bad_inode;
+       if (!sanity_check_inode(inode)) {
+               ret = -EINVAL;
+               goto bad_inode;
+       }
 make_now:
        if (ino == F2FS_NODE_INO(sbi)) {
                inode->i_mapping->a_ops = &f2fs_node_aops;
-               mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_ZERO);
+               mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
        } else if (ino == F2FS_META_INO(sbi)) {
                inode->i_mapping->a_ops = &f2fs_meta_aops;
-               mapping_set_gfp_mask(inode->i_mapping, GFP_F2FS_ZERO);
+               mapping_set_gfp_mask(inode->i_mapping, GFP_NOFS);
        } else if (S_ISREG(inode->i_mode)) {
                inode->i_op = &f2fs_file_inode_operations;
                inode->i_fop = &f2fs_file_operations;
@@ -373,7 +390,7 @@ struct inode *f2fs_iget_retry(struct super_block *sb, unsigned long ino)
        return inode;
 }
 
-void update_inode(struct inode *inode, struct page *node_page)
+void f2fs_update_inode(struct inode *inode, struct page *node_page)
 {
        struct f2fs_inode *ri;
        struct extent_tree *et = F2FS_I(inode)->extent_tree;
@@ -408,7 +425,12 @@ void update_inode(struct inode *inode, struct page *node_page)
        ri->i_atime_nsec = cpu_to_le32(inode->i_atime.tv_nsec);
        ri->i_ctime_nsec = cpu_to_le32(inode->i_ctime.tv_nsec);
        ri->i_mtime_nsec = cpu_to_le32(inode->i_mtime.tv_nsec);
-       ri->i_current_depth = cpu_to_le32(F2FS_I(inode)->i_current_depth);
+       if (S_ISDIR(inode->i_mode))
+               ri->i_current_depth =
+                       cpu_to_le32(F2FS_I(inode)->i_current_depth);
+       else if (S_ISREG(inode->i_mode))
+               ri->i_gc_failures =
+                       cpu_to_le16(F2FS_I(inode)->i_gc_failures[GC_FAILURE_PIN]);
        ri->i_xattr_nid = cpu_to_le32(F2FS_I(inode)->i_xattr_nid);
        ri->i_flags = cpu_to_le32(F2FS_I(inode)->i_flags);
        ri->i_pino = cpu_to_le32(F2FS_I(inode)->i_pino);
@@ -448,18 +470,18 @@ void update_inode(struct inode *inode, struct page *node_page)
        if (inode->i_nlink == 0)
                clear_inline_node(node_page);
 
-       F2FS_I(inode)->i_disk_time[0] = inode->i_atime;
-       F2FS_I(inode)->i_disk_time[1] = inode->i_ctime;
-       F2FS_I(inode)->i_disk_time[2] = inode->i_mtime;
+       F2FS_I(inode)->i_disk_time[0] = timespec64_to_timespec(inode->i_atime);
+       F2FS_I(inode)->i_disk_time[1] = timespec64_to_timespec(inode->i_ctime);
+       F2FS_I(inode)->i_disk_time[2] = timespec64_to_timespec(inode->i_mtime);
        F2FS_I(inode)->i_disk_time[3] = F2FS_I(inode)->i_crtime;
 }
 
-void update_inode_page(struct inode *inode)
+void f2fs_update_inode_page(struct inode *inode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        struct page *node_page;
 retry:
-       node_page = get_node_page(sbi, inode->i_ino);
+       node_page = f2fs_get_node_page(sbi, inode->i_ino);
        if (IS_ERR(node_page)) {
                int err = PTR_ERR(node_page);
                if (err == -ENOMEM) {
@@ -470,7 +492,7 @@ void update_inode_page(struct inode *inode)
                }
                return;
        }
-       update_inode(inode, node_page);
+       f2fs_update_inode(inode, node_page);
        f2fs_put_page(node_page, 1);
 }
 
@@ -489,7 +511,7 @@ int f2fs_write_inode(struct inode *inode, struct writeback_control *wbc)
         * We need to balance fs here to prevent from producing dirty node pages
         * during the urgent cleaning time when runing out of free sections.
         */
-       update_inode_page(inode);
+       f2fs_update_inode_page(inode);
        if (wbc && wbc->nr_to_write)
                f2fs_balance_fs(sbi, true);
        return 0;
@@ -506,7 +528,7 @@ void f2fs_evict_inode(struct inode *inode)
 
        /* some remained atomic pages should discarded */
        if (f2fs_is_atomic_file(inode))
-               drop_inmem_pages(inode);
+               f2fs_drop_inmem_pages(inode);
 
        trace_f2fs_evict_inode(inode);
        truncate_inode_pages_final(&inode->i_data);
@@ -516,7 +538,7 @@ void f2fs_evict_inode(struct inode *inode)
                goto out_clear;
 
        f2fs_bug_on(sbi, get_dirty_pages(inode));
-       remove_dirty_inode(inode);
+       f2fs_remove_dirty_inode(inode);
 
        f2fs_destroy_extent_tree(inode);
 
@@ -525,9 +547,9 @@ void f2fs_evict_inode(struct inode *inode)
 
        dquot_initialize(inode);
 
-       remove_ino_entry(sbi, inode->i_ino, APPEND_INO);
-       remove_ino_entry(sbi, inode->i_ino, UPDATE_INO);
-       remove_ino_entry(sbi, inode->i_ino, FLUSH_INO);
+       f2fs_remove_ino_entry(sbi, inode->i_ino, APPEND_INO);
+       f2fs_remove_ino_entry(sbi, inode->i_ino, UPDATE_INO);
+       f2fs_remove_ino_entry(sbi, inode->i_ino, FLUSH_INO);
 
        sb_start_intwrite(inode->i_sb);
        set_inode_flag(inode, FI_NO_ALLOC);
@@ -544,7 +566,7 @@ void f2fs_evict_inode(struct inode *inode)
 #endif
        if (!err) {
                f2fs_lock_op(sbi);
-               err = remove_inode_page(inode);
+               err = f2fs_remove_inode_page(inode);
                f2fs_unlock_op(sbi);
                if (err == -ENOENT)
                        err = 0;
@@ -557,7 +579,7 @@ void f2fs_evict_inode(struct inode *inode)
        }
 
        if (err)
-               update_inode_page(inode);
+               f2fs_update_inode_page(inode);
        dquot_free_inode(inode);
        sb_end_intwrite(inode->i_sb);
 no_delete:
@@ -580,16 +602,19 @@ void f2fs_evict_inode(struct inode *inode)
                invalidate_mapping_pages(NODE_MAPPING(sbi), xnid, xnid);
        if (inode->i_nlink) {
                if (is_inode_flag_set(inode, FI_APPEND_WRITE))
-                       add_ino_entry(sbi, inode->i_ino, APPEND_INO);
+                       f2fs_add_ino_entry(sbi, inode->i_ino, APPEND_INO);
                if (is_inode_flag_set(inode, FI_UPDATE_WRITE))
-                       add_ino_entry(sbi, inode->i_ino, UPDATE_INO);
+                       f2fs_add_ino_entry(sbi, inode->i_ino, UPDATE_INO);
        }
        if (is_inode_flag_set(inode, FI_FREE_NID)) {
-               alloc_nid_failed(sbi, inode->i_ino);
+               f2fs_alloc_nid_failed(sbi, inode->i_ino);
                clear_inode_flag(inode, FI_FREE_NID);
        } else {
-               f2fs_bug_on(sbi, err &&
-                       !exist_written_data(sbi, inode->i_ino, ORPHAN_INO));
+               /*
+                * If xattr nid is corrupted, we can reach out error condition,
+                * err & !f2fs_exist_written_data(sbi, inode->i_ino, ORPHAN_INO)).
+                * In that case, f2fs_check_nid_range() is enough to give a clue.
+                */
        }
 out_clear:
        fscrypt_put_encryption_info(inode);
@@ -597,7 +622,7 @@ void f2fs_evict_inode(struct inode *inode)
 }
 
 /* caller should call f2fs_lock_op() */
-void handle_failed_inode(struct inode *inode)
+void f2fs_handle_failed_inode(struct inode *inode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        struct node_info ni;
@@ -612,7 +637,7 @@ void handle_failed_inode(struct inode *inode)
         * we must call this to avoid inode being remained as dirty, resulting
         * in a panic when flushing dirty inodes in gdirty_list.
         */
-       update_inode_page(inode);
+       f2fs_update_inode_page(inode);
        f2fs_inode_synced(inode);
 
        /* don't make bad inode, since it becomes a regular file. */
@@ -623,18 +648,18 @@ void handle_failed_inode(struct inode *inode)
         * so we can prevent losing this orphan when encoutering checkpoint
         * and following suddenly power-off.
         */
-       get_node_info(sbi, inode->i_ino, &ni);
+       f2fs_get_node_info(sbi, inode->i_ino, &ni);
 
        if (ni.blk_addr != NULL_ADDR) {
-               int err = acquire_orphan_inode(sbi);
+               int err = f2fs_acquire_orphan_inode(sbi);
                if (err) {
                        set_sbi_flag(sbi, SBI_NEED_FSCK);
                        f2fs_msg(sbi->sb, KERN_WARNING,
                                "Too many orphan inodes, run fsck to fix.");
                } else {
-                       add_orphan_inode(inode);
+                       f2fs_add_orphan_inode(inode);
                }
-               alloc_nid_done(sbi, inode->i_ino);
+               f2fs_alloc_nid_done(sbi, inode->i_ino);
        } else {
                set_inode_flag(inode, FI_FREE_NID);
        }
index 75e37fd720b2ba999c05dbb0219f7f4850d6f25e..231b7f3ea7d3f0e27863bebf4b7886df753bf805 100644 (file)
@@ -37,7 +37,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
                return ERR_PTR(-ENOMEM);
 
        f2fs_lock_op(sbi);
-       if (!alloc_nid(sbi, &ino)) {
+       if (!f2fs_alloc_nid(sbi, &ino)) {
                f2fs_unlock_op(sbi);
                err = -ENOSPC;
                goto fail;
@@ -50,10 +50,13 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
 
        inode->i_ino = ino;
        inode->i_blocks = 0;
-       inode->i_mtime = inode->i_atime = inode->i_ctime =
-                       F2FS_I(inode)->i_crtime = current_time(inode);
+       inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+       F2FS_I(inode)->i_crtime = timespec64_to_timespec(inode->i_mtime);
        inode->i_generation = sbi->s_next_generation++;
 
+       if (S_ISDIR(inode->i_mode))
+               F2FS_I(inode)->i_current_depth = 1;
+
        err = insert_inode_locked(inode);
        if (err) {
                err = -EINVAL;
@@ -61,7 +64,7 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
        }
 
        if (f2fs_sb_has_project_quota(sbi->sb) &&
-               (F2FS_I(dir)->i_flags & FS_PROJINHERIT_FL))
+               (F2FS_I(dir)->i_flags & F2FS_PROJINHERIT_FL))
                F2FS_I(inode)->i_projid = F2FS_I(dir)->i_projid;
        else
                F2FS_I(inode)->i_projid = make_kprojid(&init_user_ns,
@@ -116,9 +119,9 @@ static struct inode *f2fs_new_inode(struct inode *dir, umode_t mode)
                f2fs_mask_flags(mode, F2FS_I(dir)->i_flags & F2FS_FL_INHERITED);
 
        if (S_ISDIR(inode->i_mode))
-               F2FS_I(inode)->i_flags |= FS_INDEX_FL;
+               F2FS_I(inode)->i_flags |= F2FS_INDEX_FL;
 
-       if (F2FS_I(inode)->i_flags & FS_PROJINHERIT_FL)
+       if (F2FS_I(inode)->i_flags & F2FS_PROJINHERIT_FL)
                set_inode_flag(inode, FI_PROJ_INHERIT);
 
        trace_f2fs_new_inode(inode, 0);
@@ -193,7 +196,7 @@ static inline void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *
        up_read(&sbi->sb_lock);
 }
 
-int update_extension_list(struct f2fs_sb_info *sbi, const char *name,
+int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
                                                        bool hot, bool set)
 {
        __u8 (*extlist)[F2FS_EXTENSION_LEN] = sbi->raw_super->extension_list;
@@ -292,7 +295,7 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
                goto out;
        f2fs_unlock_op(sbi);
 
-       alloc_nid_done(sbi, ino);
+       f2fs_alloc_nid_done(sbi, ino);
 
        d_instantiate_new(dentry, inode);
 
@@ -302,7 +305,7 @@ static int f2fs_create(struct inode *dir, struct dentry *dentry, umode_t mode,
        f2fs_balance_fs(sbi, true);
        return 0;
 out:
-       handle_failed_inode(inode);
+       f2fs_handle_failed_inode(inode);
        return err;
 }
 
@@ -397,7 +400,7 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino)
                err = PTR_ERR(page);
                goto out;
        } else {
-               err = __f2fs_add_link(dir, &dot, NULL, dir->i_ino, S_IFDIR);
+               err = f2fs_do_add_link(dir, &dot, NULL, dir->i_ino, S_IFDIR);
                if (err)
                        goto out;
        }
@@ -408,7 +411,7 @@ static int __recover_dot_dentries(struct inode *dir, nid_t pino)
        else if (IS_ERR(page))
                err = PTR_ERR(page);
        else
-               err = __f2fs_add_link(dir, &dotdot, NULL, pino, S_IFDIR);
+               err = f2fs_do_add_link(dir, &dotdot, NULL, pino, S_IFDIR);
 out:
        if (!err)
                clear_inode_flag(dir, FI_INLINE_DOTS);
@@ -520,7 +523,7 @@ static int f2fs_unlink(struct inode *dir, struct dentry *dentry)
        f2fs_balance_fs(sbi, true);
 
        f2fs_lock_op(sbi);
-       err = acquire_orphan_inode(sbi);
+       err = f2fs_acquire_orphan_inode(sbi);
        if (err) {
                f2fs_unlock_op(sbi);
                f2fs_put_page(page, 0);
@@ -585,9 +588,9 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
        f2fs_lock_op(sbi);
        err = f2fs_add_link(dentry, inode);
        if (err)
-               goto out_handle_failed_inode;
+               goto out_f2fs_handle_failed_inode;
        f2fs_unlock_op(sbi);
-       alloc_nid_done(sbi, inode->i_ino);
+       f2fs_alloc_nid_done(sbi, inode->i_ino);
 
        err = fscrypt_encrypt_symlink(inode, symname, len, &disk_link);
        if (err)
@@ -620,8 +623,8 @@ static int f2fs_symlink(struct inode *dir, struct dentry *dentry,
        f2fs_balance_fs(sbi, true);
        goto out_free_encrypted_link;
 
-out_handle_failed_inode:
-       handle_failed_inode(inode);
+out_f2fs_handle_failed_inode:
+       f2fs_handle_failed_inode(inode);
 out_free_encrypted_link:
        if (disk_link.name != (unsigned char *)symname)
                kfree(disk_link.name);
@@ -657,7 +660,7 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
                goto out_fail;
        f2fs_unlock_op(sbi);
 
-       alloc_nid_done(sbi, inode->i_ino);
+       f2fs_alloc_nid_done(sbi, inode->i_ino);
 
        d_instantiate_new(dentry, inode);
 
@@ -669,7 +672,7 @@ static int f2fs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
 
 out_fail:
        clear_inode_flag(inode, FI_INC_LINK);
-       handle_failed_inode(inode);
+       f2fs_handle_failed_inode(inode);
        return err;
 }
 
@@ -708,7 +711,7 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
                goto out;
        f2fs_unlock_op(sbi);
 
-       alloc_nid_done(sbi, inode->i_ino);
+       f2fs_alloc_nid_done(sbi, inode->i_ino);
 
        d_instantiate_new(dentry, inode);
 
@@ -718,7 +721,7 @@ static int f2fs_mknod(struct inode *dir, struct dentry *dentry,
        f2fs_balance_fs(sbi, true);
        return 0;
 out:
-       handle_failed_inode(inode);
+       f2fs_handle_failed_inode(inode);
        return err;
 }
 
@@ -747,7 +750,7 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
        }
 
        f2fs_lock_op(sbi);
-       err = acquire_orphan_inode(sbi);
+       err = f2fs_acquire_orphan_inode(sbi);
        if (err)
                goto out;
 
@@ -759,8 +762,8 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
         * add this non-linked tmpfile to orphan list, in this way we could
         * remove all unused data of tmpfile after abnormal power-off.
         */
-       add_orphan_inode(inode);
-       alloc_nid_done(sbi, inode->i_ino);
+       f2fs_add_orphan_inode(inode);
+       f2fs_alloc_nid_done(sbi, inode->i_ino);
 
        if (whiteout) {
                f2fs_i_links_write(inode, false);
@@ -776,9 +779,9 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry,
        return 0;
 
 release_out:
-       release_orphan_inode(sbi);
+       f2fs_release_orphan_inode(sbi);
 out:
-       handle_failed_inode(inode);
+       f2fs_handle_failed_inode(inode);
        return err;
 }
 
@@ -885,7 +888,7 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
 
                f2fs_lock_op(sbi);
 
-               err = acquire_orphan_inode(sbi);
+               err = f2fs_acquire_orphan_inode(sbi);
                if (err)
                        goto put_out_dir;
 
@@ -899,9 +902,9 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
                up_write(&F2FS_I(new_inode)->i_sem);
 
                if (!new_inode->i_nlink)
-                       add_orphan_inode(new_inode);
+                       f2fs_add_orphan_inode(new_inode);
                else
-                       release_orphan_inode(sbi);
+                       f2fs_release_orphan_inode(sbi);
        } else {
                f2fs_balance_fs(sbi, true);
 
@@ -969,8 +972,12 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry,
                        f2fs_put_page(old_dir_page, 0);
                f2fs_i_links_write(old_dir, false);
        }
-       if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT)
-               add_ino_entry(sbi, new_dir->i_ino, TRANS_DIR_INO);
+       if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT) {
+               f2fs_add_ino_entry(sbi, new_dir->i_ino, TRANS_DIR_INO);
+               if (S_ISDIR(old_inode->i_mode))
+                       f2fs_add_ino_entry(sbi, old_inode->i_ino,
+                                                       TRANS_DIR_INO);
+       }
 
        f2fs_unlock_op(sbi);
 
@@ -1121,8 +1128,8 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
        f2fs_mark_inode_dirty_sync(new_dir, false);
 
        if (F2FS_OPTION(sbi).fsync_mode == FSYNC_MODE_STRICT) {
-               add_ino_entry(sbi, old_dir->i_ino, TRANS_DIR_INO);
-               add_ino_entry(sbi, new_dir->i_ino, TRANS_DIR_INO);
+               f2fs_add_ino_entry(sbi, old_dir->i_ino, TRANS_DIR_INO);
+               f2fs_add_ino_entry(sbi, new_dir->i_ino, TRANS_DIR_INO);
        }
 
        f2fs_unlock_op(sbi);
index f202398e20eaaec752c9f5736b047748cee39c65..10643b11bd591d16f8b1e55ff5a8bdae648e5a10 100644 (file)
 #include "trace.h"
 #include <trace/events/f2fs.h>
 
-#define on_build_free_nids(nmi) mutex_is_locked(&(nm_i)->build_lock)
+#define on_f2fs_build_free_nids(nmi) mutex_is_locked(&(nm_i)->build_lock)
 
 static struct kmem_cache *nat_entry_slab;
 static struct kmem_cache *free_nid_slab;
 static struct kmem_cache *nat_entry_set_slab;
 
-bool available_free_memory(struct f2fs_sb_info *sbi, int type)
+/*
+ * Check whether the given nid is within node id range.
+ */
+int f2fs_check_nid_range(struct f2fs_sb_info *sbi, nid_t nid)
+{
+       if (unlikely(nid < F2FS_ROOT_INO(sbi) || nid >= NM_I(sbi)->max_nid)) {
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+               f2fs_msg(sbi->sb, KERN_WARNING,
+                               "%s: out-of-range nid=%x, run fsck to fix.",
+                               __func__, nid);
+               return -EINVAL;
+       }
+       return 0;
+}
+
+bool f2fs_available_free_memory(struct f2fs_sb_info *sbi, int type)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct sysinfo val;
@@ -87,18 +102,10 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type)
 
 static void clear_node_page_dirty(struct page *page)
 {
-       struct address_space *mapping = page->mapping;
-       unsigned int long flags;
-
        if (PageDirty(page)) {
-               xa_lock_irqsave(&mapping->i_pages, flags);
-               radix_tree_tag_clear(&mapping->i_pages,
-                               page_index(page),
-                               PAGECACHE_TAG_DIRTY);
-               xa_unlock_irqrestore(&mapping->i_pages, flags);
-
+               f2fs_clear_radix_tree_dirty_tag(page);
                clear_page_dirty_for_io(page);
-               dec_page_count(F2FS_M_SB(mapping), F2FS_DIRTY_NODES);
+               dec_page_count(F2FS_P_SB(page), F2FS_DIRTY_NODES);
        }
        ClearPageUptodate(page);
 }
@@ -106,7 +113,7 @@ static void clear_node_page_dirty(struct page *page)
 static struct page *get_current_nat_page(struct f2fs_sb_info *sbi, nid_t nid)
 {
        pgoff_t index = current_nat_addr(sbi, nid);
-       return get_meta_page(sbi, index);
+       return f2fs_get_meta_page(sbi, index);
 }
 
 static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid)
@@ -123,8 +130,8 @@ static struct page *get_next_nat_page(struct f2fs_sb_info *sbi, nid_t nid)
        dst_off = next_nat_addr(sbi, src_off);
 
        /* get current nat block page with lock */
-       src_page = get_meta_page(sbi, src_off);
-       dst_page = grab_meta_page(sbi, dst_off);
+       src_page = f2fs_get_meta_page(sbi, src_off);
+       dst_page = f2fs_grab_meta_page(sbi, dst_off);
        f2fs_bug_on(sbi, PageDirty(src_page));
 
        src_addr = page_address(src_page);
@@ -260,7 +267,7 @@ static unsigned int __gang_lookup_nat_set(struct f2fs_nm_info *nm_i,
                                                        start, nr);
 }
 
-int need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid)
+int f2fs_need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct nat_entry *e;
@@ -277,7 +284,7 @@ int need_dentry_mark(struct f2fs_sb_info *sbi, nid_t nid)
        return need;
 }
 
-bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
+bool f2fs_is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct nat_entry *e;
@@ -291,7 +298,7 @@ bool is_checkpointed_node(struct f2fs_sb_info *sbi, nid_t nid)
        return is_cp;
 }
 
-bool need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino)
+bool f2fs_need_inode_block_update(struct f2fs_sb_info *sbi, nid_t ino)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct nat_entry *e;
@@ -364,8 +371,7 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni,
                        new_blkaddr == NULL_ADDR);
        f2fs_bug_on(sbi, nat_get_blkaddr(e) == NEW_ADDR &&
                        new_blkaddr == NEW_ADDR);
-       f2fs_bug_on(sbi, nat_get_blkaddr(e) != NEW_ADDR &&
-                       nat_get_blkaddr(e) != NULL_ADDR &&
+       f2fs_bug_on(sbi, is_valid_blkaddr(nat_get_blkaddr(e)) &&
                        new_blkaddr == NEW_ADDR);
 
        /* increment version no as node is removed */
@@ -376,7 +382,7 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni,
 
        /* change address */
        nat_set_blkaddr(e, new_blkaddr);
-       if (new_blkaddr == NEW_ADDR || new_blkaddr == NULL_ADDR)
+       if (!is_valid_blkaddr(new_blkaddr))
                set_nat_flag(e, IS_CHECKPOINTED, false);
        __set_nat_cache_dirty(nm_i, e);
 
@@ -391,7 +397,7 @@ static void set_node_addr(struct f2fs_sb_info *sbi, struct node_info *ni,
        up_write(&nm_i->nat_tree_lock);
 }
 
-int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink)
+int f2fs_try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        int nr = nr_shrink;
@@ -413,7 +419,8 @@ int try_to_free_nats(struct f2fs_sb_info *sbi, int nr_shrink)
 /*
  * This function always returns success
  */
-void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni)
+void f2fs_get_node_info(struct f2fs_sb_info *sbi, nid_t nid,
+                                               struct node_info *ni)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
@@ -443,7 +450,7 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni)
 
        /* Check current segment summary */
        down_read(&curseg->journal_rwsem);
-       i = lookup_journal_in_cursum(journal, NAT_JOURNAL, nid, 0);
+       i = f2fs_lookup_journal_in_cursum(journal, NAT_JOURNAL, nid, 0);
        if (i >= 0) {
                ne = nat_in_journal(journal, i);
                node_info_from_raw_nat(ni, &ne);
@@ -458,7 +465,7 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni)
        index = current_nat_addr(sbi, nid);
        up_read(&nm_i->nat_tree_lock);
 
-       page = get_meta_page(sbi, index);
+       page = f2fs_get_meta_page(sbi, index);
        nat_blk = (struct f2fs_nat_block *)page_address(page);
        ne = nat_blk->entries[nid - start_nid];
        node_info_from_raw_nat(ni, &ne);
@@ -471,7 +478,7 @@ void get_node_info(struct f2fs_sb_info *sbi, nid_t nid, struct node_info *ni)
 /*
  * readahead MAX_RA_NODE number of node pages.
  */
-static void ra_node_pages(struct page *parent, int start, int n)
+static void f2fs_ra_node_pages(struct page *parent, int start, int n)
 {
        struct f2fs_sb_info *sbi = F2FS_P_SB(parent);
        struct blk_plug plug;
@@ -485,13 +492,13 @@ static void ra_node_pages(struct page *parent, int start, int n)
        end = min(end, NIDS_PER_BLOCK);
        for (i = start; i < end; i++) {
                nid = get_nid(parent, i, false);
-               ra_node_page(sbi, nid);
+               f2fs_ra_node_page(sbi, nid);
        }
 
        blk_finish_plug(&plug);
 }
 
-pgoff_t get_next_page_offset(struct dnode_of_data *dn, pgoff_t pgofs)
+pgoff_t f2fs_get_next_page_offset(struct dnode_of_data *dn, pgoff_t pgofs)
 {
        const long direct_index = ADDRS_PER_INODE(dn->inode);
        const long direct_blks = ADDRS_PER_BLOCK;
@@ -606,7 +613,7 @@ static int get_node_path(struct inode *inode, long block,
  * f2fs_unlock_op() only if ro is not set RDONLY_NODE.
  * In the case of RDONLY_NODE, we don't need to care about mutex.
  */
-int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)
+int f2fs_get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
        struct page *npage[4];
@@ -625,7 +632,7 @@ int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)
        npage[0] = dn->inode_page;
 
        if (!npage[0]) {
-               npage[0] = get_node_page(sbi, nids[0]);
+               npage[0] = f2fs_get_node_page(sbi, nids[0]);
                if (IS_ERR(npage[0]))
                        return PTR_ERR(npage[0]);
        }
@@ -649,24 +656,24 @@ int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)
 
                if (!nids[i] && mode == ALLOC_NODE) {
                        /* alloc new node */
-                       if (!alloc_nid(sbi, &(nids[i]))) {
+                       if (!f2fs_alloc_nid(sbi, &(nids[i]))) {
                                err = -ENOSPC;
                                goto release_pages;
                        }
 
                        dn->nid = nids[i];
-                       npage[i] = new_node_page(dn, noffset[i]);
+                       npage[i] = f2fs_new_node_page(dn, noffset[i]);
                        if (IS_ERR(npage[i])) {
-                               alloc_nid_failed(sbi, nids[i]);
+                               f2fs_alloc_nid_failed(sbi, nids[i]);
                                err = PTR_ERR(npage[i]);
                                goto release_pages;
                        }
 
                        set_nid(parent, offset[i - 1], nids[i], i == 1);
-                       alloc_nid_done(sbi, nids[i]);
+                       f2fs_alloc_nid_done(sbi, nids[i]);
                        done = true;
                } else if (mode == LOOKUP_NODE_RA && i == level && level > 1) {
-                       npage[i] = get_node_page_ra(parent, offset[i - 1]);
+                       npage[i] = f2fs_get_node_page_ra(parent, offset[i - 1]);
                        if (IS_ERR(npage[i])) {
                                err = PTR_ERR(npage[i]);
                                goto release_pages;
@@ -681,7 +688,7 @@ int get_dnode_of_data(struct dnode_of_data *dn, pgoff_t index, int mode)
                }
 
                if (!done) {
-                       npage[i] = get_node_page(sbi, nids[i]);
+                       npage[i] = f2fs_get_node_page(sbi, nids[i]);
                        if (IS_ERR(npage[i])) {
                                err = PTR_ERR(npage[i]);
                                f2fs_put_page(npage[0], 0);
@@ -720,15 +727,15 @@ static void truncate_node(struct dnode_of_data *dn)
        struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
        struct node_info ni;
 
-       get_node_info(sbi, dn->nid, &ni);
+       f2fs_get_node_info(sbi, dn->nid, &ni);
 
        /* Deallocate node address */
-       invalidate_blocks(sbi, ni.blk_addr);
+       f2fs_invalidate_blocks(sbi, ni.blk_addr);
        dec_valid_node_count(sbi, dn->inode, dn->nid == dn->inode->i_ino);
        set_node_addr(sbi, &ni, NULL_ADDR, false);
 
        if (dn->nid == dn->inode->i_ino) {
-               remove_orphan_inode(sbi, dn->nid);
+               f2fs_remove_orphan_inode(sbi, dn->nid);
                dec_valid_inode_count(sbi);
                f2fs_inode_synced(dn->inode);
        }
@@ -753,7 +760,7 @@ static int truncate_dnode(struct dnode_of_data *dn)
                return 1;
 
        /* get direct node */
-       page = get_node_page(F2FS_I_SB(dn->inode), dn->nid);
+       page = f2fs_get_node_page(F2FS_I_SB(dn->inode), dn->nid);
        if (IS_ERR(page) && PTR_ERR(page) == -ENOENT)
                return 1;
        else if (IS_ERR(page))
@@ -762,7 +769,7 @@ static int truncate_dnode(struct dnode_of_data *dn)
        /* Make dnode_of_data for parameter */
        dn->node_page = page;
        dn->ofs_in_node = 0;
-       truncate_data_blocks(dn);
+       f2fs_truncate_data_blocks(dn);
        truncate_node(dn);
        return 1;
 }
@@ -783,13 +790,13 @@ static int truncate_nodes(struct dnode_of_data *dn, unsigned int nofs,
 
        trace_f2fs_truncate_nodes_enter(dn->inode, dn->nid, dn->data_blkaddr);
 
-       page = get_node_page(F2FS_I_SB(dn->inode), dn->nid);
+       page = f2fs_get_node_page(F2FS_I_SB(dn->inode), dn->nid);
        if (IS_ERR(page)) {
                trace_f2fs_truncate_nodes_exit(dn->inode, PTR_ERR(page));
                return PTR_ERR(page);
        }
 
-       ra_node_pages(page, ofs, NIDS_PER_BLOCK);
+       f2fs_ra_node_pages(page, ofs, NIDS_PER_BLOCK);
 
        rn = F2FS_NODE(page);
        if (depth < 3) {
@@ -859,7 +866,7 @@ static int truncate_partial_nodes(struct dnode_of_data *dn,
        /* get indirect nodes in the path */
        for (i = 0; i < idx + 1; i++) {
                /* reference count'll be increased */
-               pages[i] = get_node_page(F2FS_I_SB(dn->inode), nid[i]);
+               pages[i] = f2fs_get_node_page(F2FS_I_SB(dn->inode), nid[i]);
                if (IS_ERR(pages[i])) {
                        err = PTR_ERR(pages[i]);
                        idx = i - 1;
@@ -868,7 +875,7 @@ static int truncate_partial_nodes(struct dnode_of_data *dn,
                nid[i + 1] = get_nid(pages[i], offset[i + 1], false);
        }
 
-       ra_node_pages(pages[idx], offset[idx + 1], NIDS_PER_BLOCK);
+       f2fs_ra_node_pages(pages[idx], offset[idx + 1], NIDS_PER_BLOCK);
 
        /* free direct nodes linked to a partial indirect node */
        for (i = offset[idx + 1]; i < NIDS_PER_BLOCK; i++) {
@@ -905,7 +912,7 @@ static int truncate_partial_nodes(struct dnode_of_data *dn,
 /*
  * All the block addresses of data and nodes should be nullified.
  */
-int truncate_inode_blocks(struct inode *inode, pgoff_t from)
+int f2fs_truncate_inode_blocks(struct inode *inode, pgoff_t from)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        int err = 0, cont = 1;
@@ -921,7 +928,7 @@ int truncate_inode_blocks(struct inode *inode, pgoff_t from)
        if (level < 0)
                return level;
 
-       page = get_node_page(sbi, inode->i_ino);
+       page = f2fs_get_node_page(sbi, inode->i_ino);
        if (IS_ERR(page)) {
                trace_f2fs_truncate_inode_blocks_exit(inode, PTR_ERR(page));
                return PTR_ERR(page);
@@ -1001,7 +1008,7 @@ int truncate_inode_blocks(struct inode *inode, pgoff_t from)
 }
 
 /* caller must lock inode page */
-int truncate_xattr_node(struct inode *inode)
+int f2fs_truncate_xattr_node(struct inode *inode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        nid_t nid = F2FS_I(inode)->i_xattr_nid;
@@ -1011,7 +1018,7 @@ int truncate_xattr_node(struct inode *inode)
        if (!nid)
                return 0;
 
-       npage = get_node_page(sbi, nid);
+       npage = f2fs_get_node_page(sbi, nid);
        if (IS_ERR(npage))
                return PTR_ERR(npage);
 
@@ -1026,17 +1033,17 @@ int truncate_xattr_node(struct inode *inode)
  * Caller should grab and release a rwsem by calling f2fs_lock_op() and
  * f2fs_unlock_op().
  */
-int remove_inode_page(struct inode *inode)
+int f2fs_remove_inode_page(struct inode *inode)
 {
        struct dnode_of_data dn;
        int err;
 
        set_new_dnode(&dn, inode, NULL, NULL, inode->i_ino);
-       err = get_dnode_of_data(&dn, 0, LOOKUP_NODE);
+       err = f2fs_get_dnode_of_data(&dn, 0, LOOKUP_NODE);
        if (err)
                return err;
 
-       err = truncate_xattr_node(inode);
+       err = f2fs_truncate_xattr_node(inode);
        if (err) {
                f2fs_put_dnode(&dn);
                return err;
@@ -1045,7 +1052,7 @@ int remove_inode_page(struct inode *inode)
        /* remove potential inline_data blocks */
        if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode) ||
                                S_ISLNK(inode->i_mode))
-               truncate_data_blocks_range(&dn, 1);
+               f2fs_truncate_data_blocks_range(&dn, 1);
 
        /* 0 is possible, after f2fs_new_inode() has failed */
        f2fs_bug_on(F2FS_I_SB(inode),
@@ -1056,7 +1063,7 @@ int remove_inode_page(struct inode *inode)
        return 0;
 }
 
-struct page *new_inode_page(struct inode *inode)
+struct page *f2fs_new_inode_page(struct inode *inode)
 {
        struct dnode_of_data dn;
 
@@ -1064,10 +1071,10 @@ struct page *new_inode_page(struct inode *inode)
        set_new_dnode(&dn, inode, NULL, NULL, inode->i_ino);
 
        /* caller should f2fs_put_page(page, 1); */
-       return new_node_page(&dn, 0);
+       return f2fs_new_node_page(&dn, 0);
 }
 
-struct page *new_node_page(struct dnode_of_data *dn, unsigned int ofs)
+struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
        struct node_info new_ni;
@@ -1085,7 +1092,7 @@ struct page *new_node_page(struct dnode_of_data *dn, unsigned int ofs)
                goto fail;
 
 #ifdef CONFIG_F2FS_CHECK_FS
-       get_node_info(sbi, dn->nid, &new_ni);
+       f2fs_get_node_info(sbi, dn->nid, &new_ni);
        f2fs_bug_on(sbi, new_ni.blk_addr != NULL_ADDR);
 #endif
        new_ni.nid = dn->nid;
@@ -1137,7 +1144,7 @@ static int read_node_page(struct page *page, int op_flags)
        if (PageUptodate(page))
                return LOCKED_PAGE;
 
-       get_node_info(sbi, page->index, &ni);
+       f2fs_get_node_info(sbi, page->index, &ni);
 
        if (unlikely(ni.blk_addr == NULL_ADDR)) {
                ClearPageUptodate(page);
@@ -1151,14 +1158,15 @@ static int read_node_page(struct page *page, int op_flags)
 /*
  * Readahead a node page
  */
-void ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
+void f2fs_ra_node_page(struct f2fs_sb_info *sbi, nid_t nid)
 {
        struct page *apage;
        int err;
 
        if (!nid)
                return;
-       f2fs_bug_on(sbi, check_nid_range(sbi, nid));
+       if (f2fs_check_nid_range(sbi, nid))
+               return;
 
        rcu_read_lock();
        apage = radix_tree_lookup(&NODE_MAPPING(sbi)->i_pages, nid);
@@ -1182,7 +1190,8 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
 
        if (!nid)
                return ERR_PTR(-ENOENT);
-       f2fs_bug_on(sbi, check_nid_range(sbi, nid));
+       if (f2fs_check_nid_range(sbi, nid))
+               return ERR_PTR(-EINVAL);
 repeat:
        page = f2fs_grab_cache_page(NODE_MAPPING(sbi), nid, false);
        if (!page)
@@ -1198,7 +1207,7 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
        }
 
        if (parent)
-               ra_node_pages(parent, start + 1, MAX_RA_NODE);
+               f2fs_ra_node_pages(parent, start + 1, MAX_RA_NODE);
 
        lock_page(page);
 
@@ -1232,12 +1241,12 @@ static struct page *__get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid,
        return page;
 }
 
-struct page *get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
+struct page *f2fs_get_node_page(struct f2fs_sb_info *sbi, pgoff_t nid)
 {
        return __get_node_page(sbi, nid, NULL, 0);
 }
 
-struct page *get_node_page_ra(struct page *parent, int start)
+struct page *f2fs_get_node_page_ra(struct page *parent, int start)
 {
        struct f2fs_sb_info *sbi = F2FS_P_SB(parent);
        nid_t nid = get_nid(parent, start, false);
@@ -1272,7 +1281,7 @@ static void flush_inline_data(struct f2fs_sb_info *sbi, nid_t ino)
 
        ret = f2fs_write_inline_data(inode, page);
        inode_dec_dirty_pages(inode);
-       remove_dirty_inode(inode);
+       f2fs_remove_dirty_inode(inode);
        if (ret)
                set_page_dirty(page);
 page_out:
@@ -1359,11 +1368,8 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
 
        trace_f2fs_writepage(page, NODE);
 
-       if (unlikely(f2fs_cp_error(sbi))) {
-               dec_page_count(sbi, F2FS_DIRTY_NODES);
-               unlock_page(page);
-               return 0;
-       }
+       if (unlikely(f2fs_cp_error(sbi)))
+               goto redirty_out;
 
        if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
                goto redirty_out;
@@ -1379,7 +1385,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
                down_read(&sbi->node_write);
        }
 
-       get_node_info(sbi, nid, &ni);
+       f2fs_get_node_info(sbi, nid, &ni);
 
        /* This page is already truncated */
        if (unlikely(ni.blk_addr == NULL_ADDR)) {
@@ -1394,8 +1400,9 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
                fio.op_flags |= REQ_PREFLUSH | REQ_FUA;
 
        set_page_writeback(page);
+       ClearPageError(page);
        fio.old_blkaddr = ni.blk_addr;
-       write_node_page(nid, &fio);
+       f2fs_do_write_node_page(nid, &fio);
        set_node_addr(sbi, &ni, fio.new_blkaddr, is_fsync_dnode(page));
        dec_page_count(sbi, F2FS_DIRTY_NODES);
        up_read(&sbi->node_write);
@@ -1424,7 +1431,7 @@ static int __write_node_page(struct page *page, bool atomic, bool *submitted,
        return AOP_WRITEPAGE_ACTIVATE;
 }
 
-void move_node_page(struct page *node_page, int gc_type)
+void f2fs_move_node_page(struct page *node_page, int gc_type)
 {
        if (gc_type == FG_GC) {
                struct writeback_control wbc = {
@@ -1461,7 +1468,7 @@ static int f2fs_write_node_page(struct page *page,
        return __write_node_page(page, false, NULL, wbc, false, FS_NODE_IO);
 }
 
-int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
+int f2fs_fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
                        struct writeback_control *wbc, bool atomic)
 {
        pgoff_t index;
@@ -1528,9 +1535,9 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
                                if (IS_INODE(page)) {
                                        if (is_inode_flag_set(inode,
                                                                FI_DIRTY_INODE))
-                                               update_inode(inode, page);
+                                               f2fs_update_inode(inode, page);
                                        set_dentry_mark(page,
-                                               need_dentry_mark(sbi, ino));
+                                               f2fs_need_dentry_mark(sbi, ino));
                                }
                                /*  may be written by other thread */
                                if (!PageDirty(page))
@@ -1580,7 +1587,8 @@ int fsync_node_pages(struct f2fs_sb_info *sbi, struct inode *inode,
        return ret ? -EIO: 0;
 }
 
-int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc,
+int f2fs_sync_node_pages(struct f2fs_sb_info *sbi,
+                               struct writeback_control *wbc,
                                bool do_balance, enum iostat_type io_type)
 {
        pgoff_t index;
@@ -1588,21 +1596,28 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc,
        int step = 0;
        int nwritten = 0;
        int ret = 0;
-       int nr_pages;
+       int nr_pages, done = 0;
 
        pagevec_init(&pvec);
 
 next_step:
        index = 0;
 
-       while ((nr_pages = pagevec_lookup_tag(&pvec, NODE_MAPPING(sbi), &index,
-                               PAGECACHE_TAG_DIRTY))) {
+       while (!done && (nr_pages = pagevec_lookup_tag(&pvec,
+                       NODE_MAPPING(sbi), &index, PAGECACHE_TAG_DIRTY))) {
                int i;
 
                for (i = 0; i < nr_pages; i++) {
                        struct page *page = pvec.pages[i];
                        bool submitted = false;
 
+                       /* give a priority to WB_SYNC threads */
+                       if (atomic_read(&sbi->wb_sync_req[NODE]) &&
+                                       wbc->sync_mode == WB_SYNC_NONE) {
+                               done = 1;
+                               break;
+                       }
+
                        /*
                         * flushing sequence with step:
                         * 0. indirect nodes
@@ -1681,7 +1696,7 @@ int sync_node_pages(struct f2fs_sb_info *sbi, struct writeback_control *wbc,
        return ret;
 }
 
-int wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
+int f2fs_wait_on_node_pages_writeback(struct f2fs_sb_info *sbi, nid_t ino)
 {
        pgoff_t index = 0;
        struct pagevec pvec;
@@ -1730,14 +1745,21 @@ static int f2fs_write_node_pages(struct address_space *mapping,
        if (get_pages(sbi, F2FS_DIRTY_NODES) < nr_pages_to_skip(sbi, NODE))
                goto skip_write;
 
+       if (wbc->sync_mode == WB_SYNC_ALL)
+               atomic_inc(&sbi->wb_sync_req[NODE]);
+       else if (atomic_read(&sbi->wb_sync_req[NODE]))
+               goto skip_write;
+
        trace_f2fs_writepages(mapping->host, wbc, NODE);
 
        diff = nr_pages_to_write(sbi, NODE, wbc);
-       wbc->sync_mode = WB_SYNC_NONE;
        blk_start_plug(&plug);
-       sync_node_pages(sbi, wbc, true, FS_NODE_IO);
+       f2fs_sync_node_pages(sbi, wbc, true, FS_NODE_IO);
        blk_finish_plug(&plug);
        wbc->nr_to_write = max((long)0, wbc->nr_to_write - diff);
+
+       if (wbc->sync_mode == WB_SYNC_ALL)
+               atomic_dec(&sbi->wb_sync_req[NODE]);
        return 0;
 
 skip_write:
@@ -1753,7 +1775,7 @@ static int f2fs_set_node_page_dirty(struct page *page)
        if (!PageUptodate(page))
                SetPageUptodate(page);
        if (!PageDirty(page)) {
-               f2fs_set_page_dirty_nobuffers(page);
+               __set_page_dirty_nobuffers(page);
                inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_NODES);
                SetPagePrivate(page);
                f2fs_trace_pid(page);
@@ -1883,20 +1905,20 @@ static bool add_free_nid(struct f2fs_sb_info *sbi,
                 *   Thread A             Thread B
                 *  - f2fs_create
                 *   - f2fs_new_inode
-                *    - alloc_nid
+                *    - f2fs_alloc_nid
                 *     - __insert_nid_to_list(PREALLOC_NID)
                 *                     - f2fs_balance_fs_bg
-                *                      - build_free_nids
-                *                       - __build_free_nids
+                *                      - f2fs_build_free_nids
+                *                       - __f2fs_build_free_nids
                 *                        - scan_nat_page
                 *                         - add_free_nid
                 *                          - __lookup_nat_cache
                 *  - f2fs_add_link
-                *   - init_inode_metadata
-                *    - new_inode_page
-                *     - new_node_page
+                *   - f2fs_init_inode_metadata
+                *    - f2fs_new_inode_page
+                *     - f2fs_new_node_page
                 *      - set_node_addr
-                *  - alloc_nid_done
+                *  - f2fs_alloc_nid_done
                 *   - __remove_nid_from_list(PREALLOC_NID)
                 *                         - __insert_nid_to_list(FREE_NID)
                 */
@@ -2028,7 +2050,8 @@ static void scan_free_nid_bits(struct f2fs_sb_info *sbi)
        up_read(&nm_i->nat_tree_lock);
 }
 
-static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
+static void __f2fs_build_free_nids(struct f2fs_sb_info *sbi,
+                                               bool sync, bool mount)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        int i = 0;
@@ -2041,7 +2064,7 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
        if (nm_i->nid_cnt[FREE_NID] >= NAT_ENTRY_PER_BLOCK)
                return;
 
-       if (!sync && !available_free_memory(sbi, FREE_NIDS))
+       if (!sync && !f2fs_available_free_memory(sbi, FREE_NIDS))
                return;
 
        if (!mount) {
@@ -2053,7 +2076,7 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
        }
 
        /* readahead nat pages to be scanned */
-       ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES,
+       f2fs_ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nid), FREE_NID_PAGES,
                                                        META_NAT, true);
 
        down_read(&nm_i->nat_tree_lock);
@@ -2083,14 +2106,14 @@ static void __build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
 
        up_read(&nm_i->nat_tree_lock);
 
-       ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nm_i->next_scan_nid),
+       f2fs_ra_meta_pages(sbi, NAT_BLOCK_OFFSET(nm_i->next_scan_nid),
                                        nm_i->ra_nid_pages, META_NAT, false);
 }
 
-void build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
+void f2fs_build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
 {
        mutex_lock(&NM_I(sbi)->build_lock);
-       __build_free_nids(sbi, sync, mount);
+       __f2fs_build_free_nids(sbi, sync, mount);
        mutex_unlock(&NM_I(sbi)->build_lock);
 }
 
@@ -2099,7 +2122,7 @@ void build_free_nids(struct f2fs_sb_info *sbi, bool sync, bool mount)
  * from second parameter of this function.
  * The returned nid could be used ino as well as nid when inode is created.
  */
-bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
+bool f2fs_alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct free_nid *i = NULL;
@@ -2117,8 +2140,8 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
                return false;
        }
 
-       /* We should not use stale free nids created by build_free_nids */
-       if (nm_i->nid_cnt[FREE_NID] && !on_build_free_nids(nm_i)) {
+       /* We should not use stale free nids created by f2fs_build_free_nids */
+       if (nm_i->nid_cnt[FREE_NID] && !on_f2fs_build_free_nids(nm_i)) {
                f2fs_bug_on(sbi, list_empty(&nm_i->free_nid_list));
                i = list_first_entry(&nm_i->free_nid_list,
                                        struct free_nid, list);
@@ -2135,14 +2158,14 @@ bool alloc_nid(struct f2fs_sb_info *sbi, nid_t *nid)
        spin_unlock(&nm_i->nid_list_lock);
 
        /* Let's scan nat pages and its caches to get free nids */
-       build_free_nids(sbi, true, false);
+       f2fs_build_free_nids(sbi, true, false);
        goto retry;
 }
 
 /*
- * alloc_nid() should be called prior to this function.
+ * f2fs_alloc_nid() should be called prior to this function.
  */
-void alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid)
+void f2fs_alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct free_nid *i;
@@ -2157,9 +2180,9 @@ void alloc_nid_done(struct f2fs_sb_info *sbi, nid_t nid)
 }
 
 /*
- * alloc_nid() should be called prior to this function.
+ * f2fs_alloc_nid() should be called prior to this function.
  */
-void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
+void f2fs_alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct free_nid *i;
@@ -2172,7 +2195,7 @@ void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
        i = __lookup_free_nid_list(nm_i, nid);
        f2fs_bug_on(sbi, !i);
 
-       if (!available_free_memory(sbi, FREE_NIDS)) {
+       if (!f2fs_available_free_memory(sbi, FREE_NIDS)) {
                __remove_free_nid(sbi, i, PREALLOC_NID);
                need_free = true;
        } else {
@@ -2189,7 +2212,7 @@ void alloc_nid_failed(struct f2fs_sb_info *sbi, nid_t nid)
                kmem_cache_free(free_nid_slab, i);
 }
 
-int try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
+int f2fs_try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct free_nid *i, *next;
@@ -2217,14 +2240,14 @@ int try_to_free_nids(struct f2fs_sb_info *sbi, int nr_shrink)
        return nr - nr_shrink;
 }
 
-void recover_inline_xattr(struct inode *inode, struct page *page)
+void f2fs_recover_inline_xattr(struct inode *inode, struct page *page)
 {
        void *src_addr, *dst_addr;
        size_t inline_size;
        struct page *ipage;
        struct f2fs_inode *ri;
 
-       ipage = get_node_page(F2FS_I_SB(inode), inode->i_ino);
+       ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino);
        f2fs_bug_on(F2FS_I_SB(inode), IS_ERR(ipage));
 
        ri = F2FS_INODE(page);
@@ -2242,11 +2265,11 @@ void recover_inline_xattr(struct inode *inode, struct page *page)
        f2fs_wait_on_page_writeback(ipage, NODE, true);
        memcpy(dst_addr, src_addr, inline_size);
 update_inode:
-       update_inode(inode, ipage);
+       f2fs_update_inode(inode, ipage);
        f2fs_put_page(ipage, 1);
 }
 
-int recover_xattr_data(struct inode *inode, struct page *page)
+int f2fs_recover_xattr_data(struct inode *inode, struct page *page)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        nid_t prev_xnid = F2FS_I(inode)->i_xattr_nid;
@@ -2259,25 +2282,25 @@ int recover_xattr_data(struct inode *inode, struct page *page)
                goto recover_xnid;
 
        /* 1: invalidate the previous xattr nid */
-       get_node_info(sbi, prev_xnid, &ni);
-       invalidate_blocks(sbi, ni.blk_addr);
+       f2fs_get_node_info(sbi, prev_xnid, &ni);
+       f2fs_invalidate_blocks(sbi, ni.blk_addr);
        dec_valid_node_count(sbi, inode, false);
        set_node_addr(sbi, &ni, NULL_ADDR, false);
 
 recover_xnid:
        /* 2: update xattr nid in inode */
-       if (!alloc_nid(sbi, &new_xnid))
+       if (!f2fs_alloc_nid(sbi, &new_xnid))
                return -ENOSPC;
 
        set_new_dnode(&dn, inode, NULL, NULL, new_xnid);
-       xpage = new_node_page(&dn, XATTR_NODE_OFFSET);
+       xpage = f2fs_new_node_page(&dn, XATTR_NODE_OFFSET);
        if (IS_ERR(xpage)) {
-               alloc_nid_failed(sbi, new_xnid);
+               f2fs_alloc_nid_failed(sbi, new_xnid);
                return PTR_ERR(xpage);
        }
 
-       alloc_nid_done(sbi, new_xnid);
-       update_inode_page(inode);
+       f2fs_alloc_nid_done(sbi, new_xnid);
+       f2fs_update_inode_page(inode);
 
        /* 3: update and set xattr node page dirty */
        memcpy(F2FS_NODE(xpage), F2FS_NODE(page), VALID_XATTR_BLOCK_SIZE);
@@ -2288,14 +2311,14 @@ int recover_xattr_data(struct inode *inode, struct page *page)
        return 0;
 }
 
-int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
+int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
 {
        struct f2fs_inode *src, *dst;
        nid_t ino = ino_of_node(page);
        struct node_info old_ni, new_ni;
        struct page *ipage;
 
-       get_node_info(sbi, ino, &old_ni);
+       f2fs_get_node_info(sbi, ino, &old_ni);
 
        if (unlikely(old_ni.blk_addr != NULL_ADDR))
                return -EINVAL;
@@ -2349,7 +2372,7 @@ int recover_inode_page(struct f2fs_sb_info *sbi, struct page *page)
        return 0;
 }
 
-void restore_node_summary(struct f2fs_sb_info *sbi,
+void f2fs_restore_node_summary(struct f2fs_sb_info *sbi,
                        unsigned int segno, struct f2fs_summary_block *sum)
 {
        struct f2fs_node *rn;
@@ -2366,10 +2389,10 @@ void restore_node_summary(struct f2fs_sb_info *sbi,
                nrpages = min(last_offset - i, BIO_MAX_PAGES);
 
                /* readahead node pages */
-               ra_meta_pages(sbi, addr, nrpages, META_POR, true);
+               f2fs_ra_meta_pages(sbi, addr, nrpages, META_POR, true);
 
                for (idx = addr; idx < addr + nrpages; idx++) {
-                       struct page *page = get_tmp_page(sbi, idx);
+                       struct page *page = f2fs_get_tmp_page(sbi, idx);
 
                        rn = F2FS_NODE(page);
                        sum_entry->nid = rn->footer.nid;
@@ -2511,7 +2534,7 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
                f2fs_bug_on(sbi, nat_get_blkaddr(ne) == NEW_ADDR);
 
                if (to_journal) {
-                       offset = lookup_journal_in_cursum(journal,
+                       offset = f2fs_lookup_journal_in_cursum(journal,
                                                        NAT_JOURNAL, nid, 1);
                        f2fs_bug_on(sbi, offset < 0);
                        raw_ne = &nat_in_journal(journal, offset);
@@ -2548,7 +2571,7 @@ static void __flush_nat_entry_set(struct f2fs_sb_info *sbi,
 /*
  * This function is called during the checkpointing process.
  */
-void flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
+void f2fs_flush_nat_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct curseg_info *curseg = CURSEG_I(sbi, CURSEG_HOT_DATA);
@@ -2611,7 +2634,7 @@ static int __get_nat_bitmaps(struct f2fs_sb_info *sbi)
        nat_bits_addr = __start_cp_addr(sbi) + sbi->blocks_per_seg -
                                                nm_i->nat_bits_blocks;
        for (i = 0; i < nm_i->nat_bits_blocks; i++) {
-               struct page *page = get_meta_page(sbi, nat_bits_addr++);
+               struct page *page = f2fs_get_meta_page(sbi, nat_bits_addr++);
 
                memcpy(nm_i->nat_bits + (i << F2FS_BLKSIZE_BITS),
                                        page_address(page), F2FS_BLKSIZE);
@@ -2730,8 +2753,10 @@ static int init_free_nid_cache(struct f2fs_sb_info *sbi)
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        int i;
 
-       nm_i->free_nid_bitmap = f2fs_kzalloc(sbi, nm_i->nat_blocks *
-                               sizeof(unsigned char *), GFP_KERNEL);
+       nm_i->free_nid_bitmap =
+               f2fs_kzalloc(sbi, array_size(sizeof(unsigned char *),
+                                            nm_i->nat_blocks),
+                            GFP_KERNEL);
        if (!nm_i->free_nid_bitmap)
                return -ENOMEM;
 
@@ -2747,14 +2772,16 @@ static int init_free_nid_cache(struct f2fs_sb_info *sbi)
        if (!nm_i->nat_block_bitmap)
                return -ENOMEM;
 
-       nm_i->free_nid_count = f2fs_kvzalloc(sbi, nm_i->nat_blocks *
-                                       sizeof(unsigned short), GFP_KERNEL);
+       nm_i->free_nid_count =
+               f2fs_kvzalloc(sbi, array_size(sizeof(unsigned short),
+                                             nm_i->nat_blocks),
+                             GFP_KERNEL);
        if (!nm_i->free_nid_count)
                return -ENOMEM;
        return 0;
 }
 
-int build_node_manager(struct f2fs_sb_info *sbi)
+int f2fs_build_node_manager(struct f2fs_sb_info *sbi)
 {
        int err;
 
@@ -2774,11 +2801,11 @@ int build_node_manager(struct f2fs_sb_info *sbi)
        /* load free nid status from nat_bits table */
        load_free_nid_bitmap(sbi);
 
-       build_free_nids(sbi, true, true);
+       f2fs_build_free_nids(sbi, true, true);
        return 0;
 }
 
-void destroy_node_manager(struct f2fs_sb_info *sbi)
+void f2fs_destroy_node_manager(struct f2fs_sb_info *sbi)
 {
        struct f2fs_nm_info *nm_i = NM_I(sbi);
        struct free_nid *i, *next_i;
@@ -2850,7 +2877,7 @@ void destroy_node_manager(struct f2fs_sb_info *sbi)
        kfree(nm_i);
 }
 
-int __init create_node_manager_caches(void)
+int __init f2fs_create_node_manager_caches(void)
 {
        nat_entry_slab = f2fs_kmem_cache_create("nat_entry",
                        sizeof(struct nat_entry));
@@ -2876,7 +2903,7 @@ int __init create_node_manager_caches(void)
        return -ENOMEM;
 }
 
-void destroy_node_manager_caches(void)
+void f2fs_destroy_node_manager_caches(void)
 {
        kmem_cache_destroy(nat_entry_set_slab);
        kmem_cache_destroy(free_nid_slab);
index 1b23d3febe4c78df46b18eab78cf6632c94c47a6..38f25f0b193a18f7d8d489092029fd2dc13634d0 100644 (file)
@@ -47,7 +47,7 @@
 
 static struct kmem_cache *fsync_entry_slab;
 
-bool space_for_roll_forward(struct f2fs_sb_info *sbi)
+bool f2fs_space_for_roll_forward(struct f2fs_sb_info *sbi)
 {
        s64 nalloc = percpu_counter_sum_positive(&sbi->alloc_valid_block_count);
 
@@ -162,7 +162,7 @@ static int recover_dentry(struct inode *inode, struct page *ipage,
                        goto out_put;
                }
 
-               err = acquire_orphan_inode(F2FS_I_SB(inode));
+               err = f2fs_acquire_orphan_inode(F2FS_I_SB(inode));
                if (err) {
                        iput(einode);
                        goto out_put;
@@ -173,7 +173,7 @@ static int recover_dentry(struct inode *inode, struct page *ipage,
        } else if (IS_ERR(page)) {
                err = PTR_ERR(page);
        } else {
-               err = __f2fs_do_add_link(dir, &fname, inode,
+               err = f2fs_add_dentry(dir, &fname, inode,
                                        inode->i_ino, inode->i_mode);
        }
        if (err == -ENOMEM)
@@ -204,8 +204,6 @@ static void recover_inline_flags(struct inode *inode, struct f2fs_inode *ri)
                set_inode_flag(inode, FI_DATA_EXIST);
        else
                clear_inode_flag(inode, FI_DATA_EXIST);
-       if (!(ri->i_inline & F2FS_INLINE_DOTS))
-               clear_inode_flag(inode, FI_INLINE_DOTS);
 }
 
 static void recover_inode(struct inode *inode, struct page *page)
@@ -254,10 +252,10 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head,
        while (1) {
                struct fsync_inode_entry *entry;
 
-               if (!is_valid_blkaddr(sbi, blkaddr, META_POR))
+               if (!f2fs_is_valid_meta_blkaddr(sbi, blkaddr, META_POR))
                        return 0;
 
-               page = get_tmp_page(sbi, blkaddr);
+               page = f2fs_get_tmp_page(sbi, blkaddr);
 
                if (!is_recoverable_dnode(page))
                        break;
@@ -271,7 +269,7 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head,
 
                        if (!check_only &&
                                        IS_INODE(page) && is_dent_dnode(page)) {
-                               err = recover_inode_page(sbi, page);
+                               err = f2fs_recover_inode_page(sbi, page);
                                if (err)
                                        break;
                                quota_inode = true;
@@ -312,7 +310,7 @@ static int find_fsync_dnodes(struct f2fs_sb_info *sbi, struct list_head *head,
                blkaddr = next_blkaddr_of_node(page);
                f2fs_put_page(page, 1);
 
-               ra_meta_pages_cond(sbi, blkaddr);
+               f2fs_ra_meta_pages_cond(sbi, blkaddr);
        }
        f2fs_put_page(page, 1);
        return err;
@@ -355,7 +353,7 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
                }
        }
 
-       sum_page = get_sum_page(sbi, segno);
+       sum_page = f2fs_get_sum_page(sbi, segno);
        sum_node = (struct f2fs_summary_block *)page_address(sum_page);
        sum = sum_node->entries[blkoff];
        f2fs_put_page(sum_page, 1);
@@ -375,7 +373,7 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
        }
 
        /* Get the node page */
-       node_page = get_node_page(sbi, nid);
+       node_page = f2fs_get_node_page(sbi, nid);
        if (IS_ERR(node_page))
                return PTR_ERR(node_page);
 
@@ -400,7 +398,8 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
                inode = dn->inode;
        }
 
-       bidx = start_bidx_of_node(offset, inode) + le16_to_cpu(sum.ofs_in_node);
+       bidx = f2fs_start_bidx_of_node(offset, inode) +
+                               le16_to_cpu(sum.ofs_in_node);
 
        /*
         * if inode page is locked, unlock temporarily, but its reference
@@ -410,11 +409,11 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
                unlock_page(dn->inode_page);
 
        set_new_dnode(&tdn, inode, NULL, NULL, 0);
-       if (get_dnode_of_data(&tdn, bidx, LOOKUP_NODE))
+       if (f2fs_get_dnode_of_data(&tdn, bidx, LOOKUP_NODE))
                goto out;
 
        if (tdn.data_blkaddr == blkaddr)
-               truncate_data_blocks_range(&tdn, 1);
+               f2fs_truncate_data_blocks_range(&tdn, 1);
 
        f2fs_put_dnode(&tdn);
 out:
@@ -427,7 +426,7 @@ static int check_index_in_prev_nodes(struct f2fs_sb_info *sbi,
 truncate_out:
        if (datablock_addr(tdn.inode, tdn.node_page,
                                        tdn.ofs_in_node) == blkaddr)
-               truncate_data_blocks_range(&tdn, 1);
+               f2fs_truncate_data_blocks_range(&tdn, 1);
        if (dn->inode->i_ino == nid && !dn->inode_page_locked)
                unlock_page(dn->inode_page);
        return 0;
@@ -443,25 +442,25 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
 
        /* step 1: recover xattr */
        if (IS_INODE(page)) {
-               recover_inline_xattr(inode, page);
+               f2fs_recover_inline_xattr(inode, page);
        } else if (f2fs_has_xattr_block(ofs_of_node(page))) {
-               err = recover_xattr_data(inode, page);
+               err = f2fs_recover_xattr_data(inode, page);
                if (!err)
                        recovered++;
                goto out;
        }
 
        /* step 2: recover inline data */
-       if (recover_inline_data(inode, page))
+       if (f2fs_recover_inline_data(inode, page))
                goto out;
 
        /* step 3: recover data indices */
-       start = start_bidx_of_node(ofs_of_node(page), inode);
+       start = f2fs_start_bidx_of_node(ofs_of_node(page), inode);
        end = start + ADDRS_PER_PAGE(page, inode);
 
        set_new_dnode(&dn, inode, NULL, NULL, 0);
 retry_dn:
-       err = get_dnode_of_data(&dn, start, ALLOC_NODE);
+       err = f2fs_get_dnode_of_data(&dn, start, ALLOC_NODE);
        if (err) {
                if (err == -ENOMEM) {
                        congestion_wait(BLK_RW_ASYNC, HZ/50);
@@ -472,7 +471,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
 
        f2fs_wait_on_page_writeback(dn.node_page, NODE, true);
 
-       get_node_info(sbi, dn.nid, &ni);
+       f2fs_get_node_info(sbi, dn.nid, &ni);
        f2fs_bug_on(sbi, ni.ino != ino_of_node(page));
        f2fs_bug_on(sbi, ofs_of_node(dn.node_page) != ofs_of_node(page));
 
@@ -488,7 +487,7 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
 
                /* dest is invalid, just invalidate src block */
                if (dest == NULL_ADDR) {
-                       truncate_data_blocks_range(&dn, 1);
+                       f2fs_truncate_data_blocks_range(&dn, 1);
                        continue;
                }
 
@@ -502,19 +501,19 @@ static int do_recover_data(struct f2fs_sb_info *sbi, struct inode *inode,
                 * and then reserve one new block in dnode page.
                 */
                if (dest == NEW_ADDR) {
-                       truncate_data_blocks_range(&dn, 1);
-                       reserve_new_block(&dn);
+                       f2fs_truncate_data_blocks_range(&dn, 1);
+                       f2fs_reserve_new_block(&dn);
                        continue;
                }
 
                /* dest is valid block, try to recover from src to dest */
-               if (is_valid_blkaddr(sbi, dest, META_POR)) {
+               if (f2fs_is_valid_meta_blkaddr(sbi, dest, META_POR)) {
 
                        if (src == NULL_ADDR) {
-                               err = reserve_new_block(&dn);
+                               err = f2fs_reserve_new_block(&dn);
 #ifdef CONFIG_F2FS_FAULT_INJECTION
                                while (err)
-                                       err = reserve_new_block(&dn);
+                                       err = f2fs_reserve_new_block(&dn);
 #endif
                                /* We should not get -ENOSPC */
                                f2fs_bug_on(sbi, err);
@@ -569,12 +568,12 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list,
        while (1) {
                struct fsync_inode_entry *entry;
 
-               if (!is_valid_blkaddr(sbi, blkaddr, META_POR))
+               if (!f2fs_is_valid_meta_blkaddr(sbi, blkaddr, META_POR))
                        break;
 
-               ra_meta_pages_cond(sbi, blkaddr);
+               f2fs_ra_meta_pages_cond(sbi, blkaddr);
 
-               page = get_tmp_page(sbi, blkaddr);
+               page = f2fs_get_tmp_page(sbi, blkaddr);
 
                if (!is_recoverable_dnode(page)) {
                        f2fs_put_page(page, 1);
@@ -612,11 +611,11 @@ static int recover_data(struct f2fs_sb_info *sbi, struct list_head *inode_list,
                f2fs_put_page(page, 1);
        }
        if (!err)
-               allocate_new_segments(sbi);
+               f2fs_allocate_new_segments(sbi);
        return err;
 }
 
-int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
+int f2fs_recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
 {
        struct list_head inode_list;
        struct list_head dir_list;
@@ -691,7 +690,7 @@ int recover_fsync_data(struct f2fs_sb_info *sbi, bool check_only)
                struct cp_control cpc = {
                        .reason = CP_RECOVERY,
                };
-               err = write_checkpoint(sbi, &cpc);
+               err = f2fs_write_checkpoint(sbi, &cpc);
        }
 
        kmem_cache_destroy(fsync_entry_slab);
index 5854cc4e1d67c01045f41b99403aaaefbfc27894..9efce174c51a9001a5679c6911c7e7e45e34eb81 100644 (file)
@@ -169,7 +169,7 @@ static unsigned long __find_rev_next_zero_bit(const unsigned long *addr,
        return result - size + __reverse_ffz(tmp);
 }
 
-bool need_SSR(struct f2fs_sb_info *sbi)
+bool f2fs_need_SSR(struct f2fs_sb_info *sbi)
 {
        int node_secs = get_blocktype_secs(sbi, F2FS_DIRTY_NODES);
        int dent_secs = get_blocktype_secs(sbi, F2FS_DIRTY_DENTS);
@@ -177,14 +177,14 @@ bool need_SSR(struct f2fs_sb_info *sbi)
 
        if (test_opt(sbi, LFS))
                return false;
-       if (sbi->gc_thread && sbi->gc_thread->gc_urgent)
+       if (sbi->gc_mode == GC_URGENT)
                return true;
 
        return free_sections(sbi) <= (node_secs + 2 * dent_secs + imeta_secs +
                        SM_I(sbi)->min_ssr_sections + reserved_sections(sbi));
 }
 
-void register_inmem_page(struct inode *inode, struct page *page)
+void f2fs_register_inmem_page(struct inode *inode, struct page *page)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        struct f2fs_inode_info *fi = F2FS_I(inode);
@@ -230,6 +230,8 @@ static int __revoke_inmem_pages(struct inode *inode,
 
                lock_page(page);
 
+               f2fs_wait_on_page_writeback(page, DATA, true);
+
                if (recover) {
                        struct dnode_of_data dn;
                        struct node_info ni;
@@ -237,7 +239,8 @@ static int __revoke_inmem_pages(struct inode *inode,
                        trace_f2fs_commit_inmem_page(page, INMEM_REVOKE);
 retry:
                        set_new_dnode(&dn, inode, NULL, NULL, 0);
-                       err = get_dnode_of_data(&dn, page->index, LOOKUP_NODE);
+                       err = f2fs_get_dnode_of_data(&dn, page->index,
+                                                               LOOKUP_NODE);
                        if (err) {
                                if (err == -ENOMEM) {
                                        congestion_wait(BLK_RW_ASYNC, HZ/50);
@@ -247,9 +250,9 @@ static int __revoke_inmem_pages(struct inode *inode,
                                err = -EAGAIN;
                                goto next;
                        }
-                       get_node_info(sbi, dn.nid, &ni);
+                       f2fs_get_node_info(sbi, dn.nid, &ni);
                        if (cur->old_addr == NEW_ADDR) {
-                               invalidate_blocks(sbi, dn.data_blkaddr);
+                               f2fs_invalidate_blocks(sbi, dn.data_blkaddr);
                                f2fs_update_data_blkaddr(&dn, NEW_ADDR);
                        } else
                                f2fs_replace_block(sbi, &dn, dn.data_blkaddr,
@@ -271,7 +274,7 @@ static int __revoke_inmem_pages(struct inode *inode,
        return err;
 }
 
-void drop_inmem_pages_all(struct f2fs_sb_info *sbi)
+void f2fs_drop_inmem_pages_all(struct f2fs_sb_info *sbi, bool gc_failure)
 {
        struct list_head *head = &sbi->inode_list[ATOMIC_FILE];
        struct inode *inode;
@@ -287,15 +290,23 @@ void drop_inmem_pages_all(struct f2fs_sb_info *sbi)
        spin_unlock(&sbi->inode_lock[ATOMIC_FILE]);
 
        if (inode) {
-               drop_inmem_pages(inode);
+               if (gc_failure) {
+                       if (fi->i_gc_failures[GC_FAILURE_ATOMIC])
+                               goto drop;
+                       goto skip;
+               }
+drop:
+               set_inode_flag(inode, FI_ATOMIC_REVOKE_REQUEST);
+               f2fs_drop_inmem_pages(inode);
                iput(inode);
        }
+skip:
        congestion_wait(BLK_RW_ASYNC, HZ/50);
        cond_resched();
        goto next;
 }
 
-void drop_inmem_pages(struct inode *inode)
+void f2fs_drop_inmem_pages(struct inode *inode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        struct f2fs_inode_info *fi = F2FS_I(inode);
@@ -309,11 +320,11 @@ void drop_inmem_pages(struct inode *inode)
        mutex_unlock(&fi->inmem_lock);
 
        clear_inode_flag(inode, FI_ATOMIC_FILE);
-       clear_inode_flag(inode, FI_HOT_DATA);
+       fi->i_gc_failures[GC_FAILURE_ATOMIC] = 0;
        stat_dec_atomic_write(inode);
 }
 
-void drop_inmem_page(struct inode *inode, struct page *page)
+void f2fs_drop_inmem_page(struct inode *inode, struct page *page)
 {
        struct f2fs_inode_info *fi = F2FS_I(inode);
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
@@ -328,7 +339,7 @@ void drop_inmem_page(struct inode *inode, struct page *page)
                        break;
        }
 
-       f2fs_bug_on(sbi, !cur || cur->page != page);
+       f2fs_bug_on(sbi, list_empty(head) || cur->page != page);
        list_del(&cur->list);
        mutex_unlock(&fi->inmem_lock);
 
@@ -343,8 +354,7 @@ void drop_inmem_page(struct inode *inode, struct page *page)
        trace_f2fs_commit_inmem_page(page, INMEM_INVALIDATE);
 }
 
-static int __commit_inmem_pages(struct inode *inode,
-                                       struct list_head *revoke_list)
+static int __f2fs_commit_inmem_pages(struct inode *inode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        struct f2fs_inode_info *fi = F2FS_I(inode);
@@ -357,9 +367,12 @@ static int __commit_inmem_pages(struct inode *inode,
                .op_flags = REQ_SYNC | REQ_PRIO,
                .io_type = FS_DATA_IO,
        };
+       struct list_head revoke_list;
        pgoff_t last_idx = ULONG_MAX;
        int err = 0;
 
+       INIT_LIST_HEAD(&revoke_list);
+
        list_for_each_entry_safe(cur, tmp, &fi->inmem_pages, list) {
                struct page *page = cur->page;
 
@@ -371,14 +384,14 @@ static int __commit_inmem_pages(struct inode *inode,
                        f2fs_wait_on_page_writeback(page, DATA, true);
                        if (clear_page_dirty_for_io(page)) {
                                inode_dec_dirty_pages(inode);
-                               remove_dirty_inode(inode);
+                               f2fs_remove_dirty_inode(inode);
                        }
 retry:
                        fio.page = page;
                        fio.old_blkaddr = NULL_ADDR;
                        fio.encrypted_page = NULL;
                        fio.need_lock = LOCK_DONE;
-                       err = do_write_data_page(&fio);
+                       err = f2fs_do_write_data_page(&fio);
                        if (err) {
                                if (err == -ENOMEM) {
                                        congestion_wait(BLK_RW_ASYNC, HZ/50);
@@ -393,50 +406,46 @@ static int __commit_inmem_pages(struct inode *inode,
                        last_idx = page->index;
                }
                unlock_page(page);
-               list_move_tail(&cur->list, revoke_list);
+               list_move_tail(&cur->list, &revoke_list);
        }
 
        if (last_idx != ULONG_MAX)
                f2fs_submit_merged_write_cond(sbi, inode, 0, last_idx, DATA);
 
-       if (!err)
-               __revoke_inmem_pages(inode, revoke_list, false, false);
+       if (err) {
+               /*
+                * try to revoke all committed pages, but still we could fail
+                * due to no memory or other reason, if that happened, EAGAIN
+                * will be returned, which means in such case, transaction is
+                * already not integrity, caller should use journal to do the
+                * recovery or rewrite & commit last transaction. For other
+                * error number, revoking was done by filesystem itself.
+                */
+               err = __revoke_inmem_pages(inode, &revoke_list, false, true);
+
+               /* drop all uncommitted pages */
+               __revoke_inmem_pages(inode, &fi->inmem_pages, true, false);
+       } else {
+               __revoke_inmem_pages(inode, &revoke_list, false, false);
+       }
 
        return err;
 }
 
-int commit_inmem_pages(struct inode *inode)
+int f2fs_commit_inmem_pages(struct inode *inode)
 {
        struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
        struct f2fs_inode_info *fi = F2FS_I(inode);
-       struct list_head revoke_list;
        int err;
 
-       INIT_LIST_HEAD(&revoke_list);
        f2fs_balance_fs(sbi, true);
        f2fs_lock_op(sbi);
 
        set_inode_flag(inode, FI_ATOMIC_COMMIT);
 
        mutex_lock(&fi->inmem_lock);
-       err = __commit_inmem_pages(inode, &revoke_list);
-       if (err) {
-               int ret;
-               /*
-                * try to revoke all committed pages, but still we could fail
-                * due to no memory or other reason, if that happened, EAGAIN
-                * will be returned, which means in such case, transaction is
-                * already not integrity, caller should use journal to do the
-                * recovery or rewrite & commit last transaction. For other
-                * error number, revoking was done by filesystem itself.
-                */
-               ret = __revoke_inmem_pages(inode, &revoke_list, false, true);
-               if (ret)
-                       err = ret;
+       err = __f2fs_commit_inmem_pages(inode);
 
-               /* drop all uncommitted pages */
-               __revoke_inmem_pages(inode, &fi->inmem_pages, true, false);
-       }
        spin_lock(&sbi->inode_lock[ATOMIC_FILE]);
        if (!list_empty(&fi->inmem_ilist))
                list_del_init(&fi->inmem_ilist);
@@ -478,25 +487,28 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need)
 
 void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
 {
+       if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
+               return;
+
        /* try to shrink extent cache when there is no enough memory */
-       if (!available_free_memory(sbi, EXTENT_CACHE))
+       if (!f2fs_available_free_memory(sbi, EXTENT_CACHE))
                f2fs_shrink_extent_tree(sbi, EXTENT_CACHE_SHRINK_NUMBER);
 
        /* check the # of cached NAT entries */
-       if (!available_free_memory(sbi, NAT_ENTRIES))
-               try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK);
+       if (!f2fs_available_free_memory(sbi, NAT_ENTRIES))
+               f2fs_try_to_free_nats(sbi, NAT_ENTRY_PER_BLOCK);
 
-       if (!available_free_memory(sbi, FREE_NIDS))
-               try_to_free_nids(sbi, MAX_FREE_NIDS);
+       if (!f2fs_available_free_memory(sbi, FREE_NIDS))
+               f2fs_try_to_free_nids(sbi, MAX_FREE_NIDS);
        else
-               build_free_nids(sbi, false, false);
+               f2fs_build_free_nids(sbi, false, false);
 
        if (!is_idle(sbi) && !excess_dirty_nats(sbi))
                return;
 
        /* checkpoint is the only way to shrink partial cached entries */
-       if (!available_free_memory(sbi, NAT_ENTRIES) ||
-                       !available_free_memory(sbi, INO_ENTRIES) ||
+       if (!f2fs_available_free_memory(sbi, NAT_ENTRIES) ||
+                       !f2fs_available_free_memory(sbi, INO_ENTRIES) ||
                        excess_prefree_segs(sbi) ||
                        excess_dirty_nats(sbi) ||
                        f2fs_time_over(sbi, CP_TIME)) {
@@ -504,7 +516,7 @@ void f2fs_balance_fs_bg(struct f2fs_sb_info *sbi)
                        struct blk_plug plug;
 
                        blk_start_plug(&plug);
-                       sync_dirty_inodes(sbi, FILE_INODE);
+                       f2fs_sync_dirty_inodes(sbi, FILE_INODE);
                        blk_finish_plug(&plug);
                }
                f2fs_sync_fs(sbi->sb, true);
@@ -537,7 +549,7 @@ static int submit_flush_wait(struct f2fs_sb_info *sbi, nid_t ino)
                return __submit_flush_wait(sbi, sbi->sb->s_bdev);
 
        for (i = 0; i < sbi->s_ndevs; i++) {
-               if (!is_dirty_device(sbi, ino, i, FLUSH_INO))
+               if (!f2fs_is_dirty_device(sbi, ino, i, FLUSH_INO))
                        continue;
                ret = __submit_flush_wait(sbi, FDEV(i).bdev);
                if (ret)
@@ -648,7 +660,7 @@ int f2fs_issue_flush(struct f2fs_sb_info *sbi, nid_t ino)
        return cmd.ret;
 }
 
-int create_flush_cmd_control(struct f2fs_sb_info *sbi)
+int f2fs_create_flush_cmd_control(struct f2fs_sb_info *sbi)
 {
        dev_t dev = sbi->sb->s_bdev->bd_dev;
        struct flush_cmd_control *fcc;
@@ -685,7 +697,7 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi)
        return err;
 }
 
-void destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free)
+void f2fs_destroy_flush_cmd_control(struct f2fs_sb_info *sbi, bool free)
 {
        struct flush_cmd_control *fcc = SM_I(sbi)->fcc_info;
 
@@ -915,6 +927,42 @@ static void __check_sit_bitmap(struct f2fs_sb_info *sbi,
 #endif
 }
 
+static void __init_discard_policy(struct f2fs_sb_info *sbi,
+                               struct discard_policy *dpolicy,
+                               int discard_type, unsigned int granularity)
+{
+       /* common policy */
+       dpolicy->type = discard_type;
+       dpolicy->sync = true;
+       dpolicy->granularity = granularity;
+
+       dpolicy->max_requests = DEF_MAX_DISCARD_REQUEST;
+       dpolicy->io_aware_gran = MAX_PLIST_NUM;
+
+       if (discard_type == DPOLICY_BG) {
+               dpolicy->min_interval = DEF_MIN_DISCARD_ISSUE_TIME;
+               dpolicy->mid_interval = DEF_MID_DISCARD_ISSUE_TIME;
+               dpolicy->max_interval = DEF_MAX_DISCARD_ISSUE_TIME;
+               dpolicy->io_aware = true;
+               dpolicy->sync = false;
+               if (utilization(sbi) > DEF_DISCARD_URGENT_UTIL) {
+                       dpolicy->granularity = 1;
+                       dpolicy->max_interval = DEF_MIN_DISCARD_ISSUE_TIME;
+               }
+       } else if (discard_type == DPOLICY_FORCE) {
+               dpolicy->min_interval = DEF_MIN_DISCARD_ISSUE_TIME;
+               dpolicy->mid_interval = DEF_MID_DISCARD_ISSUE_TIME;
+               dpolicy->max_interval = DEF_MAX_DISCARD_ISSUE_TIME;
+               dpolicy->io_aware = false;
+       } else if (discard_type == DPOLICY_FSTRIM) {
+               dpolicy->io_aware = false;
+       } else if (discard_type == DPOLICY_UMOUNT) {
+               dpolicy->max_requests = UINT_MAX;
+               dpolicy->io_aware = false;
+       }
+}
+
+
 /* this function is copied from blkdev_issue_discard from block/blk-lib.c */
 static void __submit_discard_cmd(struct f2fs_sb_info *sbi,
                                                struct discard_policy *dpolicy,
@@ -929,6 +977,9 @@ static void __submit_discard_cmd(struct f2fs_sb_info *sbi,
        if (dc->state != D_PREP)
                return;
 
+       if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
+               return;
+
        trace_f2fs_issue_discard(dc->bdev, dc->start, dc->len);
 
        dc->error = __blkdev_issue_discard(dc->bdev,
@@ -972,7 +1023,7 @@ static struct discard_cmd *__insert_discard_tree(struct f2fs_sb_info *sbi,
                goto do_insert;
        }
 
-       p = __lookup_rb_tree_for_insert(sbi, &dcc->root, &parent, lstart);
+       p = f2fs_lookup_rb_tree_for_insert(sbi, &dcc->root, &parent, lstart);
 do_insert:
        dc = __attach_discard_cmd(sbi, bdev, lstart, start, len, parent, p);
        if (!dc)
@@ -1037,7 +1088,7 @@ static void __update_discard_tree_range(struct f2fs_sb_info *sbi,
 
        mutex_lock(&dcc->cmd_lock);
 
-       dc = (struct discard_cmd *)__lookup_rb_tree_ret(&dcc->root,
+       dc = (struct discard_cmd *)f2fs_lookup_rb_tree_ret(&dcc->root,
                                        NULL, lstart,
                                        (struct rb_entry **)&prev_dc,
                                        (struct rb_entry **)&next_dc,
@@ -1130,68 +1181,6 @@ static int __queue_discard_cmd(struct f2fs_sb_info *sbi,
        return 0;
 }
 
-static void __issue_discard_cmd_range(struct f2fs_sb_info *sbi,
-                                       struct discard_policy *dpolicy,
-                                       unsigned int start, unsigned int end)
-{
-       struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
-       struct discard_cmd *prev_dc = NULL, *next_dc = NULL;
-       struct rb_node **insert_p = NULL, *insert_parent = NULL;
-       struct discard_cmd *dc;
-       struct blk_plug plug;
-       int issued;
-
-next:
-       issued = 0;
-
-       mutex_lock(&dcc->cmd_lock);
-       f2fs_bug_on(sbi, !__check_rb_tree_consistence(sbi, &dcc->root));
-
-       dc = (struct discard_cmd *)__lookup_rb_tree_ret(&dcc->root,
-                                       NULL, start,
-                                       (struct rb_entry **)&prev_dc,
-                                       (struct rb_entry **)&next_dc,
-                                       &insert_p, &insert_parent, true);
-       if (!dc)
-               dc = next_dc;
-
-       blk_start_plug(&plug);
-
-       while (dc && dc->lstart <= end) {
-               struct rb_node *node;
-
-               if (dc->len < dpolicy->granularity)
-                       goto skip;
-
-               if (dc->state != D_PREP) {
-                       list_move_tail(&dc->list, &dcc->fstrim_list);
-                       goto skip;
-               }
-
-               __submit_discard_cmd(sbi, dpolicy, dc);
-
-               if (++issued >= dpolicy->max_requests) {
-                       start = dc->lstart + dc->len;
-
-                       blk_finish_plug(&plug);
-                       mutex_unlock(&dcc->cmd_lock);
-
-                       schedule();
-
-                       goto next;
-               }
-skip:
-               node = rb_next(&dc->rb_node);
-               dc = rb_entry_safe(node, struct discard_cmd, rb_node);
-
-               if (fatal_signal_pending(current))
-                       break;
-       }
-
-       blk_finish_plug(&plug);
-       mutex_unlock(&dcc->cmd_lock);
-}
-
 static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
                                        struct discard_policy *dpolicy)
 {
@@ -1210,7 +1199,8 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
                mutex_lock(&dcc->cmd_lock);
                if (list_empty(pend_list))
                        goto next;
-               f2fs_bug_on(sbi, !__check_rb_tree_consistence(sbi, &dcc->root));
+               f2fs_bug_on(sbi,
+                       !f2fs_check_rb_tree_consistence(sbi, &dcc->root));
                blk_start_plug(&plug);
                list_for_each_entry_safe(dc, tmp, pend_list, list) {
                        f2fs_bug_on(sbi, dc->state != D_PREP);
@@ -1263,7 +1253,7 @@ static bool __drop_discard_cmd(struct f2fs_sb_info *sbi)
        return dropped;
 }
 
-void drop_discard_cmd(struct f2fs_sb_info *sbi)
+void f2fs_drop_discard_cmd(struct f2fs_sb_info *sbi)
 {
        __drop_discard_cmd(sbi);
 }
@@ -1332,7 +1322,18 @@ static unsigned int __wait_discard_cmd_range(struct f2fs_sb_info *sbi,
 static void __wait_all_discard_cmd(struct f2fs_sb_info *sbi,
                                                struct discard_policy *dpolicy)
 {
-       __wait_discard_cmd_range(sbi, dpolicy, 0, UINT_MAX);
+       struct discard_policy dp;
+
+       if (dpolicy) {
+               __wait_discard_cmd_range(sbi, dpolicy, 0, UINT_MAX);
+               return;
+       }
+
+       /* wait all */
+       __init_discard_policy(sbi, &dp, DPOLICY_FSTRIM, 1);
+       __wait_discard_cmd_range(sbi, &dp, 0, UINT_MAX);
+       __init_discard_policy(sbi, &dp, DPOLICY_UMOUNT, 1);
+       __wait_discard_cmd_range(sbi, &dp, 0, UINT_MAX);
 }
 
 /* This should be covered by global mutex, &sit_i->sentry_lock */
@@ -1343,7 +1344,8 @@ static void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
        bool need_wait = false;
 
        mutex_lock(&dcc->cmd_lock);
-       dc = (struct discard_cmd *)__lookup_rb_tree(&dcc->root, NULL, blkaddr);
+       dc = (struct discard_cmd *)f2fs_lookup_rb_tree(&dcc->root,
+                                                       NULL, blkaddr);
        if (dc) {
                if (dc->state == D_PREP) {
                        __punch_discard_cmd(sbi, dc, blkaddr);
@@ -1358,7 +1360,7 @@ static void f2fs_wait_discard_bio(struct f2fs_sb_info *sbi, block_t blkaddr)
                __wait_one_discard_bio(sbi, dc);
 }
 
-void stop_discard_thread(struct f2fs_sb_info *sbi)
+void f2fs_stop_discard_thread(struct f2fs_sb_info *sbi)
 {
        struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
 
@@ -1377,11 +1379,13 @@ bool f2fs_wait_discard_bios(struct f2fs_sb_info *sbi)
        struct discard_policy dpolicy;
        bool dropped;
 
-       init_discard_policy(&dpolicy, DPOLICY_UMOUNT, dcc->discard_granularity);
+       __init_discard_policy(sbi, &dpolicy, DPOLICY_UMOUNT,
+                                       dcc->discard_granularity);
        __issue_discard_cmd(sbi, &dpolicy);
        dropped = __drop_discard_cmd(sbi);
-       __wait_all_discard_cmd(sbi, &dpolicy);
 
+       /* just to make sure there is no pending discard commands */
+       __wait_all_discard_cmd(sbi, NULL);
        return dropped;
 }
 
@@ -1397,32 +1401,39 @@ static int issue_discard_thread(void *data)
        set_freezable();
 
        do {
-               init_discard_policy(&dpolicy, DPOLICY_BG,
+               __init_discard_policy(sbi, &dpolicy, DPOLICY_BG,
                                        dcc->discard_granularity);
 
                wait_event_interruptible_timeout(*q,
                                kthread_should_stop() || freezing(current) ||
                                dcc->discard_wake,
                                msecs_to_jiffies(wait_ms));
+
+               if (dcc->discard_wake)
+                       dcc->discard_wake = 0;
+
                if (try_to_freeze())
                        continue;
                if (f2fs_readonly(sbi->sb))
                        continue;
                if (kthread_should_stop())
                        return 0;
+               if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) {
+                       wait_ms = dpolicy.max_interval;
+                       continue;
+               }
 
-               if (dcc->discard_wake)
-                       dcc->discard_wake = 0;
-
-               if (sbi->gc_thread && sbi->gc_thread->gc_urgent)
-                       init_discard_policy(&dpolicy, DPOLICY_FORCE, 1);
+               if (sbi->gc_mode == GC_URGENT)
+                       __init_discard_policy(sbi, &dpolicy, DPOLICY_FORCE, 1);
 
                sb_start_intwrite(sbi->sb);
 
                issued = __issue_discard_cmd(sbi, &dpolicy);
-               if (issued) {
+               if (issued > 0) {
                        __wait_all_discard_cmd(sbi, &dpolicy);
                        wait_ms = dpolicy.min_interval;
+               } else if (issued == -1){
+                       wait_ms = dpolicy.mid_interval;
                } else {
                        wait_ms = dpolicy.max_interval;
                }
@@ -1591,20 +1602,24 @@ static bool add_discard_addrs(struct f2fs_sb_info *sbi, struct cp_control *cpc,
        return false;
 }
 
-void release_discard_addrs(struct f2fs_sb_info *sbi)
+static void release_discard_addr(struct discard_entry *entry)
+{
+       list_del(&entry->list);
+       kmem_cache_free(discard_entry_slab, entry);
+}
+
+void f2fs_release_discard_addrs(struct f2fs_sb_info *sbi)
 {
        struct list_head *head = &(SM_I(sbi)->dcc_info->entry_list);
        struct discard_entry *entry, *this;
 
        /* drop caches */
-       list_for_each_entry_safe(entry, this, head, list) {
-               list_del(&entry->list);
-               kmem_cache_free(discard_entry_slab, entry);
-       }
+       list_for_each_entry_safe(entry, this, head, list)
+               release_discard_addr(entry);
 }
 
 /*
- * Should call clear_prefree_segments after checkpoint is done.
+ * Should call f2fs_clear_prefree_segments after checkpoint is done.
  */
 static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)
 {
@@ -1617,7 +1632,8 @@ static void set_prefree_as_free_segments(struct f2fs_sb_info *sbi)
        mutex_unlock(&dirty_i->seglist_lock);
 }
 
-void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
+void f2fs_clear_prefree_segments(struct f2fs_sb_info *sbi,
+                                               struct cp_control *cpc)
 {
        struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
        struct list_head *head = &dcc->entry_list;
@@ -1700,40 +1716,13 @@ void clear_prefree_segments(struct f2fs_sb_info *sbi, struct cp_control *cpc)
                if (cur_pos < sbi->blocks_per_seg)
                        goto find_next;
 
-               list_del(&entry->list);
+               release_discard_addr(entry);
                dcc->nr_discards -= total_len;
-               kmem_cache_free(discard_entry_slab, entry);
        }
 
        wake_up_discard_thread(sbi, false);
 }
 
-void init_discard_policy(struct discard_policy *dpolicy,
-                               int discard_type, unsigned int granularity)
-{
-       /* common policy */
-       dpolicy->type = discard_type;
-       dpolicy->sync = true;
-       dpolicy->granularity = granularity;
-
-       dpolicy->max_requests = DEF_MAX_DISCARD_REQUEST;
-       dpolicy->io_aware_gran = MAX_PLIST_NUM;
-
-       if (discard_type == DPOLICY_BG) {
-               dpolicy->min_interval = DEF_MIN_DISCARD_ISSUE_TIME;
-               dpolicy->max_interval = DEF_MAX_DISCARD_ISSUE_TIME;
-               dpolicy->io_aware = true;
-       } else if (discard_type == DPOLICY_FORCE) {
-               dpolicy->min_interval = DEF_MIN_DISCARD_ISSUE_TIME;
-               dpolicy->max_interval = DEF_MAX_DISCARD_ISSUE_TIME;
-               dpolicy->io_aware = false;
-       } else if (discard_type == DPOLICY_FSTRIM) {
-               dpolicy->io_aware = false;
-       } else if (discard_type == DPOLICY_UMOUNT) {
-               dpolicy->io_aware = false;
-       }
-}
-
 static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
 {
        dev_t dev = sbi->sb->s_bdev->bd_dev;
@@ -1786,7 +1775,7 @@ static void destroy_discard_cmd_control(struct f2fs_sb_info *sbi)
        if (!dcc)
                return;
 
-       stop_discard_thread(sbi);
+       f2fs_stop_discard_thread(sbi);
 
        kfree(dcc);
        SM_I(sbi)->dcc_info = NULL;
@@ -1833,8 +1822,9 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
                                (new_vblocks > sbi->blocks_per_seg)));
 
        se->valid_blocks = new_vblocks;
-       se->mtime = get_mtime(sbi);
-       SIT_I(sbi)->max_mtime = se->mtime;
+       se->mtime = get_mtime(sbi, false);
+       if (se->mtime > SIT_I(sbi)->max_mtime)
+               SIT_I(sbi)->max_mtime = se->mtime;
 
        /* Update valid block bitmap */
        if (del > 0) {
@@ -1902,7 +1892,7 @@ static void update_sit_entry(struct f2fs_sb_info *sbi, block_t blkaddr, int del)
                get_sec_entry(sbi, segno)->valid_blocks += del;
 }
 
-void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr)
+void f2fs_invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr)
 {
        unsigned int segno = GET_SEGNO(sbi, addr);
        struct sit_info *sit_i = SIT_I(sbi);
@@ -1922,14 +1912,14 @@ void invalidate_blocks(struct f2fs_sb_info *sbi, block_t addr)
        up_write(&sit_i->sentry_lock);
 }
 
-bool is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr)
+bool f2fs_is_checkpointed_data(struct f2fs_sb_info *sbi, block_t blkaddr)
 {
        struct sit_info *sit_i = SIT_I(sbi);
        unsigned int segno, offset;
        struct seg_entry *se;
        bool is_cp = false;
 
-       if (blkaddr == NEW_ADDR || blkaddr == NULL_ADDR)
+       if (!is_valid_blkaddr(blkaddr))
                return true;
 
        down_read(&sit_i->sentry_lock);
@@ -1961,7 +1951,7 @@ static void __add_sum_entry(struct f2fs_sb_info *sbi, int type,
 /*
  * Calculate the number of current summary pages for writing
  */
-int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra)
+int f2fs_npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra)
 {
        int valid_sum_count = 0;
        int i, sum_in_page;
@@ -1991,14 +1981,15 @@ int npages_for_summary_flush(struct f2fs_sb_info *sbi, bool for_ra)
 /*
  * Caller should put this summary page
  */
-struct page *get_sum_page(struct f2fs_sb_info *sbi, unsigned int segno)
+struct page *f2fs_get_sum_page(struct f2fs_sb_info *sbi, unsigned int segno)
 {
-       return get_meta_page(sbi, GET_SUM_BLOCK(sbi, segno));
+       return f2fs_get_meta_page(sbi, GET_SUM_BLOCK(sbi, segno));
 }
 
-void update_meta_page(struct f2fs_sb_info *sbi, void *src, block_t blk_addr)
+void f2fs_update_meta_page(struct f2fs_sb_info *sbi,
+                                       void *src, block_t blk_addr)
 {
-       struct page *page = grab_meta_page(sbi, blk_addr);
+       struct page *page = f2fs_grab_meta_page(sbi, blk_addr);
 
        memcpy(page_address(page), src, PAGE_SIZE);
        set_page_dirty(page);
@@ -2008,18 +1999,19 @@ void update_meta_page(struct f2fs_sb_info *sbi, void *src, block_t blk_addr)
 static void write_sum_page(struct f2fs_sb_info *sbi,
                        struct f2fs_summary_block *sum_blk, block_t blk_addr)
 {
-       update_meta_page(sbi, (void *)sum_blk, blk_addr);
+       f2fs_update_meta_page(sbi, (void *)sum_blk, blk_addr);
 }
 
 static void write_current_sum_page(struct f2fs_sb_info *sbi,
                                                int type, block_t blk_addr)
 {
        struct curseg_info *curseg = CURSEG_I(sbi, type);
-       struct page *page = grab_meta_page(sbi, blk_addr);
+       struct page *page = f2fs_grab_meta_page(sbi, blk_addr);
        struct f2fs_summary_block *src = curseg->sum_blk;
        struct f2fs_summary_block *dst;
 
        dst = (struct f2fs_summary_block *)page_address(page);
+       memset(dst, 0, PAGE_SIZE);
 
        mutex_lock(&curseg->curseg_mutex);
 
@@ -2259,7 +2251,7 @@ static void change_curseg(struct f2fs_sb_info *sbi, int type)
        curseg->alloc_type = SSR;
        __next_free_blkoff(sbi, curseg, 0);
 
-       sum_page = get_sum_page(sbi, new_segno);
+       sum_page = f2fs_get_sum_page(sbi, new_segno);
        sum_node = (struct f2fs_summary_block *)page_address(sum_page);
        memcpy(curseg->sum_blk, sum_node, SUM_ENTRY_SIZE);
        f2fs_put_page(sum_page, 1);
@@ -2273,7 +2265,7 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type)
        int i, cnt;
        bool reversed = false;
 
-       /* need_SSR() already forces to do this */
+       /* f2fs_need_SSR() already forces to do this */
        if (v_ops->get_victim(sbi, &segno, BG_GC, type, SSR)) {
                curseg->next_segno = segno;
                return 1;
@@ -2325,7 +2317,7 @@ static void allocate_segment_by_default(struct f2fs_sb_info *sbi,
                new_curseg(sbi, type, false);
        else if (curseg->alloc_type == LFS && is_next_segment_free(sbi, type))
                new_curseg(sbi, type, false);
-       else if (need_SSR(sbi) && get_ssr_segment(sbi, type))
+       else if (f2fs_need_SSR(sbi) && get_ssr_segment(sbi, type))
                change_curseg(sbi, type);
        else
                new_curseg(sbi, type, false);
@@ -2333,7 +2325,7 @@ static void allocate_segment_by_default(struct f2fs_sb_info *sbi,
        stat_inc_seg_type(sbi, curseg);
 }
 
-void allocate_new_segments(struct f2fs_sb_info *sbi)
+void f2fs_allocate_new_segments(struct f2fs_sb_info *sbi)
 {
        struct curseg_info *curseg;
        unsigned int old_segno;
@@ -2355,7 +2347,8 @@ static const struct segment_allocation default_salloc_ops = {
        .allocate_segment = allocate_segment_by_default,
 };
 
-bool exist_trim_candidates(struct f2fs_sb_info *sbi, struct cp_control *cpc)
+bool f2fs_exist_trim_candidates(struct f2fs_sb_info *sbi,
+                                               struct cp_control *cpc)
 {
        __u64 trim_start = cpc->trim_start;
        bool has_candidate = false;
@@ -2373,11 +2366,72 @@ bool exist_trim_candidates(struct f2fs_sb_info *sbi, struct cp_control *cpc)
        return has_candidate;
 }
 
+static void __issue_discard_cmd_range(struct f2fs_sb_info *sbi,
+                                       struct discard_policy *dpolicy,
+                                       unsigned int start, unsigned int end)
+{
+       struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
+       struct discard_cmd *prev_dc = NULL, *next_dc = NULL;
+       struct rb_node **insert_p = NULL, *insert_parent = NULL;
+       struct discard_cmd *dc;
+       struct blk_plug plug;
+       int issued;
+
+next:
+       issued = 0;
+
+       mutex_lock(&dcc->cmd_lock);
+       f2fs_bug_on(sbi, !f2fs_check_rb_tree_consistence(sbi, &dcc->root));
+
+       dc = (struct discard_cmd *)f2fs_lookup_rb_tree_ret(&dcc->root,
+                                       NULL, start,
+                                       (struct rb_entry **)&prev_dc,
+                                       (struct rb_entry **)&next_dc,
+                                       &insert_p, &insert_parent, true);
+       if (!dc)
+               dc = next_dc;
+
+       blk_start_plug(&plug);
+
+       while (dc && dc->lstart <= end) {
+               struct rb_node *node;
+
+               if (dc->len < dpolicy->granularity)
+                       goto skip;
+
+               if (dc->state != D_PREP) {
+                       list_move_tail(&dc->list, &dcc->fstrim_list);
+                       goto skip;
+               }
+
+               __submit_discard_cmd(sbi, dpolicy, dc);
+
+               if (++issued >= dpolicy->max_requests) {
+                       start = dc->lstart + dc->len;
+
+                       blk_finish_plug(&plug);
+                       mutex_unlock(&dcc->cmd_lock);
+                       __wait_all_discard_cmd(sbi, NULL);
+                       congestion_wait(BLK_RW_ASYNC, HZ/50);
+                       goto next;
+               }
+skip:
+               node = rb_next(&dc->rb_node);
+               dc = rb_entry_safe(node, struct discard_cmd, rb_node);
+
+               if (fatal_signal_pending(current))
+                       break;
+       }
+
+       blk_finish_plug(&plug);
+       mutex_unlock(&dcc->cmd_lock);
+}
+
 int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
 {
        __u64 start = F2FS_BYTES_TO_BLK(range->start);
        __u64 end = start + F2FS_BYTES_TO_BLK(range->len) - 1;
-       unsigned int start_segno, end_segno, cur_segno;
+       unsigned int start_segno, end_segno;
        block_t start_block, end_block;
        struct cp_control cpc;
        struct discard_policy dpolicy;
@@ -2388,12 +2442,12 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
                return -EINVAL;
 
        if (end <= MAIN_BLKADDR(sbi))
-               goto out;
+               return -EINVAL;
 
        if (is_sbi_flag_set(sbi, SBI_NEED_FSCK)) {
                f2fs_msg(sbi->sb, KERN_WARNING,
                        "Found FS corruption, run fsck to fix.");
-               goto out;
+               return -EIO;
        }
 
        /* start/end segment number in main_area */
@@ -2403,40 +2457,36 @@ int f2fs_trim_fs(struct f2fs_sb_info *sbi, struct fstrim_range *range)
 
        cpc.reason = CP_DISCARD;
        cpc.trim_minlen = max_t(__u64, 1, F2FS_BYTES_TO_BLK(range->minlen));
+       cpc.trim_start = start_segno;
+       cpc.trim_end = end_segno;
 
-       /* do checkpoint to issue discard commands safely */
-       for (cur_segno = start_segno; cur_segno <= end_segno;
-                                       cur_segno = cpc.trim_end + 1) {
-               cpc.trim_start = cur_segno;
-
-               if (sbi->discard_blks == 0)
-                       break;
-               else if (sbi->discard_blks < BATCHED_TRIM_BLOCKS(sbi))
-                       cpc.trim_end = end_segno;
-               else
-                       cpc.trim_end = min_t(unsigned int,
-                               rounddown(cur_segno +
-                               BATCHED_TRIM_SEGMENTS(sbi),
-                               sbi->segs_per_sec) - 1, end_segno);
-
-               mutex_lock(&sbi->gc_mutex);
-               err = write_checkpoint(sbi, &cpc);
-               mutex_unlock(&sbi->gc_mutex);
-               if (err)
-                       break;
+       if (sbi->discard_blks == 0)
+               goto out;
 
-               schedule();
-       }
+       mutex_lock(&sbi->gc_mutex);
+       err = f2fs_write_checkpoint(sbi, &cpc);
+       mutex_unlock(&sbi->gc_mutex);
+       if (err)
+               goto out;
 
        start_block = START_BLOCK(sbi, start_segno);
-       end_block = START_BLOCK(sbi, min(cur_segno, end_segno) + 1);
+       end_block = START_BLOCK(sbi, end_segno + 1);
 
-       init_discard_policy(&dpolicy, DPOLICY_FSTRIM, cpc.trim_minlen);
+       __init_discard_policy(sbi, &dpolicy, DPOLICY_FSTRIM, cpc.trim_minlen);
        __issue_discard_cmd_range(sbi, &dpolicy, start_block, end_block);
-       trimmed = __wait_discard_cmd_range(sbi, &dpolicy,
+
+       /*
+        * We filed discard candidates, but actually we don't need to wait for
+        * all of them, since they'll be issued in idle time along with runtime
+        * discard option. User configuration looks like using runtime discard
+        * or periodic fstrim instead of it.
+        */
+       if (!test_opt(sbi, DISCARD)) {
+               trimmed = __wait_discard_cmd_range(sbi, &dpolicy,
                                        start_block, end_block);
+               range->len = F2FS_BLK_TO_BYTES(trimmed);
+       }
 out:
-       range->len = F2FS_BLK_TO_BYTES(trimmed);
        return err;
 }
 
@@ -2448,7 +2498,7 @@ static bool __has_curseg_space(struct f2fs_sb_info *sbi, int type)
        return false;
 }
 
-int rw_hint_to_seg_type(enum rw_hint hint)
+int f2fs_rw_hint_to_seg_type(enum rw_hint hint)
 {
        switch (hint) {
        case WRITE_LIFE_SHORT:
@@ -2521,7 +2571,7 @@ int rw_hint_to_seg_type(enum rw_hint hint)
  * WRITE_LIFE_LONG       "                        WRITE_LIFE_LONG
  */
 
-enum rw_hint io_type_to_rw_hint(struct f2fs_sb_info *sbi,
+enum rw_hint f2fs_io_type_to_rw_hint(struct f2fs_sb_info *sbi,
                                enum page_type type, enum temp_type temp)
 {
        if (F2FS_OPTION(sbi).whint_mode == WHINT_MODE_USER) {
@@ -2588,9 +2638,11 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)
                if (is_cold_data(fio->page) || file_is_cold(inode))
                        return CURSEG_COLD_DATA;
                if (file_is_hot(inode) ||
-                               is_inode_flag_set(inode, FI_HOT_DATA))
+                               is_inode_flag_set(inode, FI_HOT_DATA) ||
+                               is_inode_flag_set(inode, FI_ATOMIC_FILE) ||
+                               is_inode_flag_set(inode, FI_VOLATILE_FILE))
                        return CURSEG_HOT_DATA;
-               return rw_hint_to_seg_type(inode->i_write_hint);
+               return f2fs_rw_hint_to_seg_type(inode->i_write_hint);
        } else {
                if (IS_DNODE(fio->page))
                        return is_cold_node(fio->page) ? CURSEG_WARM_NODE :
@@ -2626,7 +2678,7 @@ static int __get_segment_type(struct f2fs_io_info *fio)
        return type;
 }
 
-void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
+void f2fs_allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
                block_t old_blkaddr, block_t *new_blkaddr,
                struct f2fs_summary *sum, int type,
                struct f2fs_io_info *fio, bool add_list)
@@ -2686,6 +2738,7 @@ void allocate_data_block(struct f2fs_sb_info *sbi, struct page *page,
 
                INIT_LIST_HEAD(&fio->list);
                fio->in_list = true;
+               fio->retry = false;
                io = sbi->write_io[fio->type] + fio->temp;
                spin_lock(&io->io_lock);
                list_add_tail(&fio->list, &io->io_list);
@@ -2708,7 +2761,7 @@ static void update_device_state(struct f2fs_io_info *fio)
        devidx = f2fs_target_device_index(sbi, fio->new_blkaddr);
 
        /* update device state for fsync */
-       set_dirty_device(sbi, fio->ino, devidx, FLUSH_INO);
+       f2fs_set_dirty_device(sbi, fio->ino, devidx, FLUSH_INO);
 
        /* update device state for checkpoint */
        if (!f2fs_test_bit(devidx, (char *)&sbi->dirty_device)) {
@@ -2721,23 +2774,28 @@ static void update_device_state(struct f2fs_io_info *fio)
 static void do_write_page(struct f2fs_summary *sum, struct f2fs_io_info *fio)
 {
        int type = __get_segment_type(fio);
-       int err;
+       bool keep_order = (test_opt(fio->sbi, LFS) && type == CURSEG_COLD_DATA);
 
+       if (keep_order)
+               down_read(&fio->sbi->io_order_lock);
 reallocate:
-       allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr,
+       f2fs_allocate_data_block(fio->sbi, fio->page, fio->old_blkaddr,
                        &fio->new_blkaddr, sum, type, fio, true);
 
        /* writeout dirty page into bdev */
-       err = f2fs_submit_page_write(fio);
-       if (err == -EAGAIN) {
+       f2fs_submit_page_write(fio);
+       if (fio->retry) {
                fio->old_blkaddr = fio->new_blkaddr;
                goto reallocate;
-       } else if (!err) {
-               update_device_state(fio);
        }
+
+       update_device_state(fio);
+
+       if (keep_order)
+               up_read(&fio->sbi->io_order_lock);
 }
 
-void write_meta_page(struct f2fs_sb_info *sbi, struct page *page,
+void f2fs_do_write_meta_page(struct f2fs_sb_info *sbi, struct page *page,
                                        enum iostat_type io_type)
 {
        struct f2fs_io_info fio = {
@@ -2757,12 +2815,13 @@ void write_meta_page(struct f2fs_sb_info *sbi, struct page *page,
                fio.op_flags &= ~REQ_META;
 
        set_page_writeback(page);
+       ClearPageError(page);
        f2fs_submit_page_write(&fio);
 
        f2fs_update_iostat(sbi, io_type, F2FS_BLKSIZE);
 }
 
-void write_node_page(unsigned int nid, struct f2fs_io_info *fio)
+void f2fs_do_write_node_page(unsigned int nid, struct f2fs_io_info *fio)
 {
        struct f2fs_summary sum;
 
@@ -2772,14 +2831,15 @@ void write_node_page(unsigned int nid, struct f2fs_io_info *fio)
        f2fs_update_iostat(fio->sbi, fio->io_type, F2FS_BLKSIZE);
 }
 
-void write_data_page(struct dnode_of_data *dn, struct f2fs_io_info *fio)
+void f2fs_outplace_write_data(struct dnode_of_data *dn,
+                                       struct f2fs_io_info *fio)
 {
        struct f2fs_sb_info *sbi = fio->sbi;
        struct f2fs_summary sum;
        struct node_info ni;
 
        f2fs_bug_on(sbi, dn->data_blkaddr == NULL_ADDR);
-       get_node_info(sbi, dn->nid, &ni);
+       f2fs_get_node_info(sbi, dn->nid, &ni);
        set_summary(&sum, dn->nid, dn->ofs_in_node, ni.version);
        do_write_page(&sum, fio);
        f2fs_update_data_blkaddr(dn, fio->new_blkaddr);
@@ -2787,7 +2847,7 @@ void write_data_page(struct dnode_of_data *dn, struct f2fs_io_info *fio)
        f2fs_update_iostat(sbi, fio->io_type, F2FS_BLKSIZE);
 }
 
-int rewrite_data_page(struct f2fs_io_info *fio)
+int f2fs_inplace_write_data(struct f2fs_io_info *fio)
 {
        int err;
        struct f2fs_sb_info *sbi = fio->sbi;
@@ -2822,7 +2882,7 @@ static inline int __f2fs_get_curseg(struct f2fs_sb_info *sbi,
        return i;
 }
 
-void __f2fs_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
+void f2fs_do_replace_block(struct f2fs_sb_info *sbi, struct f2fs_summary *sum,
                                block_t old_blkaddr, block_t new_blkaddr,
                                bool recover_curseg, bool recover_newaddr)
 {
@@ -2907,7 +2967,7 @@ void f2fs_replace_block(struct f2fs_sb_info *sbi, struct dnode_of_data *dn,
 
        set_summary(&sum, dn->nid, dn->ofs_in_node, version);
 
-       __f2fs_replace_block(sbi, &sum, old_addr, new_addr,
+       f2fs_do_replace_block(sbi, &sum, old_addr, new_addr,
                                        recover_curseg, recover_newaddr);
 
        f2fs_update_data_blkaddr(dn, new_addr);
@@ -2932,7 +2992,7 @@ void f2fs_wait_on_block_writeback(struct f2fs_sb_info *sbi, block_t blkaddr)
 {
        struct page *cpage;
 
-       if (blkaddr == NEW_ADDR || blkaddr == NULL_ADDR)
+       if (!is_valid_blkaddr(blkaddr))
                return;
 
        cpage = find_lock_page(META_MAPPING(sbi), blkaddr);
@@ -2953,7 +3013,7 @@ static void read_compacted_summaries(struct f2fs_sb_info *sbi)
 
        start = start_sum_block(sbi);
 
-       page = get_meta_page(sbi, start++);
+       page = f2fs_get_meta_page(sbi, start++);
        kaddr = (unsigned char *)page_address(page);
 
        /* Step 1: restore nat cache */
@@ -2993,7 +3053,7 @@ static void read_compacted_summaries(struct f2fs_sb_info *sbi)
                        f2fs_put_page(page, 1);
                        page = NULL;
 
-                       page = get_meta_page(sbi, start++);
+                       page = f2fs_get_meta_page(sbi, start++);
                        kaddr = (unsigned char *)page_address(page);
                        offset = 0;
                }
@@ -3032,7 +3092,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type)
                        blk_addr = GET_SUM_BLOCK(sbi, segno);
        }
 
-       new = get_meta_page(sbi, blk_addr);
+       new = f2fs_get_meta_page(sbi, blk_addr);
        sum = (struct f2fs_summary_block *)page_address(new);
 
        if (IS_NODESEG(type)) {
@@ -3044,7 +3104,7 @@ static int read_normal_summaries(struct f2fs_sb_info *sbi, int type)
                                ns->ofs_in_node = 0;
                        }
                } else {
-                       restore_node_summary(sbi, segno, sum);
+                       f2fs_restore_node_summary(sbi, segno, sum);
                }
        }
 
@@ -3076,10 +3136,10 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi)
        int err;
 
        if (is_set_ckpt_flags(sbi, CP_COMPACT_SUM_FLAG)) {
-               int npages = npages_for_summary_flush(sbi, true);
+               int npages = f2fs_npages_for_summary_flush(sbi, true);
 
                if (npages >= 2)
-                       ra_meta_pages(sbi, start_sum_block(sbi), npages,
+                       f2fs_ra_meta_pages(sbi, start_sum_block(sbi), npages,
                                                        META_CP, true);
 
                /* restore for compacted data summary */
@@ -3088,7 +3148,7 @@ static int restore_curseg_summaries(struct f2fs_sb_info *sbi)
        }
 
        if (__exist_node_summaries(sbi))
-               ra_meta_pages(sbi, sum_blk_addr(sbi, NR_CURSEG_TYPE, type),
+               f2fs_ra_meta_pages(sbi, sum_blk_addr(sbi, NR_CURSEG_TYPE, type),
                                        NR_CURSEG_TYPE - type, META_CP, true);
 
        for (; type <= CURSEG_COLD_NODE; type++) {
@@ -3114,8 +3174,9 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
        int written_size = 0;
        int i, j;
 
-       page = grab_meta_page(sbi, blkaddr++);
+       page = f2fs_grab_meta_page(sbi, blkaddr++);
        kaddr = (unsigned char *)page_address(page);
+       memset(kaddr, 0, PAGE_SIZE);
 
        /* Step 1: write nat cache */
        seg_i = CURSEG_I(sbi, CURSEG_HOT_DATA);
@@ -3138,8 +3199,9 @@ static void write_compacted_summaries(struct f2fs_sb_info *sbi, block_t blkaddr)
 
                for (j = 0; j < blkoff; j++) {
                        if (!page) {
-                               page = grab_meta_page(sbi, blkaddr++);
+                               page = f2fs_grab_meta_page(sbi, blkaddr++);
                                kaddr = (unsigned char *)page_address(page);
+                               memset(kaddr, 0, PAGE_SIZE);
                                written_size = 0;
                        }
                        summary = (struct f2fs_summary *)(kaddr + written_size);
@@ -3174,7 +3236,7 @@ static void write_normal_summaries(struct f2fs_sb_info *sbi,
                write_current_sum_page(sbi, i, blkaddr + (i - type));
 }
 
-void write_data_summaries(struct f2fs_sb_info *sbi, block_t start_blk)
+void f2fs_write_data_summaries(struct f2fs_sb_info *sbi, block_t start_blk)
 {
        if (is_set_ckpt_flags(sbi, CP_COMPACT_SUM_FLAG))
                write_compacted_summaries(sbi, start_blk);
@@ -3182,12 +3244,12 @@ void write_data_summaries(struct f2fs_sb_info *sbi, block_t start_blk)
                write_normal_summaries(sbi, start_blk, CURSEG_HOT_DATA);
 }
 
-void write_node_summaries(struct f2fs_sb_info *sbi, block_t start_blk)
+void f2fs_write_node_summaries(struct f2fs_sb_info *sbi, block_t start_blk)
 {
        write_normal_summaries(sbi, start_blk, CURSEG_HOT_NODE);
 }
 
-int lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
+int f2fs_lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
                                        unsigned int val, int alloc)
 {
        int i;
@@ -3212,7 +3274,7 @@ int lookup_journal_in_cursum(struct f2fs_journal *journal, int type,
 static struct page *get_current_sit_page(struct f2fs_sb_info *sbi,
                                        unsigned int segno)
 {
-       return get_meta_page(sbi, current_sit_addr(sbi, segno));
+       return f2fs_get_meta_page(sbi, current_sit_addr(sbi, segno));
 }
 
 static struct page *get_next_sit_page(struct f2fs_sb_info *sbi,
@@ -3225,7 +3287,7 @@ static struct page *get_next_sit_page(struct f2fs_sb_info *sbi,
        src_off = current_sit_addr(sbi, start);
        dst_off = next_sit_addr(sbi, src_off);
 
-       page = grab_meta_page(sbi, dst_off);
+       page = f2fs_grab_meta_page(sbi, dst_off);
        seg_info_to_sit_page(sbi, page, start);
 
        set_page_dirty(page);
@@ -3321,7 +3383,7 @@ static void remove_sits_in_journal(struct f2fs_sb_info *sbi)
  * CP calls this function, which flushes SIT entries including sit_journal,
  * and moves prefree segs to free segs.
  */
-void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
+void f2fs_flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 {
        struct sit_info *sit_i = SIT_I(sbi);
        unsigned long *bitmap = sit_i->dirty_sentries_bitmap;
@@ -3380,6 +3442,11 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
                        int offset, sit_offset;
 
                        se = get_seg_entry(sbi, segno);
+#ifdef CONFIG_F2FS_CHECK_FS
+                       if (memcmp(se->cur_valid_map, se->cur_valid_map_mir,
+                                               SIT_VBLOCK_MAP_SIZE))
+                               f2fs_bug_on(sbi, 1);
+#endif
 
                        /* add discard candidates */
                        if (!(cpc->reason & CP_DISCARD)) {
@@ -3388,17 +3455,21 @@ void flush_sit_entries(struct f2fs_sb_info *sbi, struct cp_control *cpc)
                        }
 
                        if (to_journal) {
-                               offset = lookup_journal_in_cursum(journal,
+                               offset = f2fs_lookup_journal_in_cursum(journal,
                                                        SIT_JOURNAL, segno, 1);
                                f2fs_bug_on(sbi, offset < 0);
                                segno_in_journal(journal, offset) =
                                                        cpu_to_le32(segno);
                                seg_info_to_raw_sit(se,
                                        &sit_in_journal(journal, offset));
+                               check_block_count(sbi, segno,
+                                       &sit_in_journal(journal, offset));
                        } else {
                                sit_offset = SIT_ENTRY_OFFSET(sit_i, segno);
                                seg_info_to_raw_sit(se,
                                                &raw_sit->entries[sit_offset]);
+                               check_block_count(sbi, segno,
+                                               &raw_sit->entries[sit_offset]);
                        }
 
                        __clear_bit(segno, bitmap);
@@ -3446,8 +3517,10 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
 
        SM_I(sbi)->sit_info = sit_i;
 
-       sit_i->sentries = f2fs_kvzalloc(sbi, MAIN_SEGS(sbi) *
-                                       sizeof(struct seg_entry), GFP_KERNEL);
+       sit_i->sentries =
+               f2fs_kvzalloc(sbi, array_size(sizeof(struct seg_entry),
+                                             MAIN_SEGS(sbi)),
+                             GFP_KERNEL);
        if (!sit_i->sentries)
                return -ENOMEM;
 
@@ -3487,8 +3560,10 @@ static int build_sit_info(struct f2fs_sb_info *sbi)
                return -ENOMEM;
 
        if (sbi->segs_per_sec > 1) {
-               sit_i->sec_entries = f2fs_kvzalloc(sbi, MAIN_SECS(sbi) *
-                                       sizeof(struct sec_entry), GFP_KERNEL);
+               sit_i->sec_entries =
+                       f2fs_kvzalloc(sbi, array_size(sizeof(struct sec_entry),
+                                                     MAIN_SECS(sbi)),
+                                     GFP_KERNEL);
                if (!sit_i->sec_entries)
                        return -ENOMEM;
        }
@@ -3564,7 +3639,8 @@ static int build_curseg(struct f2fs_sb_info *sbi)
        struct curseg_info *array;
        int i;
 
-       array = f2fs_kzalloc(sbi, sizeof(*array) * NR_CURSEG_TYPE, GFP_KERNEL);
+       array = f2fs_kzalloc(sbi, array_size(NR_CURSEG_TYPE, sizeof(*array)),
+                            GFP_KERNEL);
        if (!array)
                return -ENOMEM;
 
@@ -3597,9 +3673,10 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
        unsigned int i, start, end;
        unsigned int readed, start_blk = 0;
        int err = 0;
+       block_t total_node_blocks = 0;
 
        do {
-               readed = ra_meta_pages(sbi, start_blk, BIO_MAX_PAGES,
+               readed = f2fs_ra_meta_pages(sbi, start_blk, BIO_MAX_PAGES,
                                                        META_SIT, true);
 
                start = start_blk * sit_i->sents_per_block;
@@ -3619,6 +3696,8 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
                        if (err)
                                return err;
                        seg_info_from_raw_sit(se, &sit);
+                       if (IS_NODESEG(se->type))
+                               total_node_blocks += se->valid_blocks;
 
                        /* build discard map only one time */
                        if (f2fs_discard_en(sbi)) {
@@ -3647,15 +3726,28 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
                unsigned int old_valid_blocks;
 
                start = le32_to_cpu(segno_in_journal(journal, i));
+               if (start >= MAIN_SEGS(sbi)) {
+                       f2fs_msg(sbi->sb, KERN_ERR,
+                                       "Wrong journal entry on segno %u",
+                                       start);
+                       set_sbi_flag(sbi, SBI_NEED_FSCK);
+                       err = -EINVAL;
+                       break;
+               }
+
                se = &sit_i->sentries[start];
                sit = sit_in_journal(journal, i);
 
                old_valid_blocks = se->valid_blocks;
+               if (IS_NODESEG(se->type))
+                       total_node_blocks -= old_valid_blocks;
 
                err = check_block_count(sbi, start, &sit);
                if (err)
                        break;
                seg_info_from_raw_sit(se, &sit);
+               if (IS_NODESEG(se->type))
+                       total_node_blocks += se->valid_blocks;
 
                if (f2fs_discard_en(sbi)) {
                        if (is_set_ckpt_flags(sbi, CP_TRIMMED_FLAG)) {
@@ -3664,16 +3756,28 @@ static int build_sit_entries(struct f2fs_sb_info *sbi)
                        } else {
                                memcpy(se->discard_map, se->cur_valid_map,
                                                        SIT_VBLOCK_MAP_SIZE);
-                               sbi->discard_blks += old_valid_blocks -
-                                                       se->valid_blocks;
+                               sbi->discard_blks += old_valid_blocks;
+                               sbi->discard_blks -= se->valid_blocks;
                        }
                }
 
-               if (sbi->segs_per_sec > 1)
+               if (sbi->segs_per_sec > 1) {
                        get_sec_entry(sbi, start)->valid_blocks +=
-                               se->valid_blocks - old_valid_blocks;
+                                                       se->valid_blocks;
+                       get_sec_entry(sbi, start)->valid_blocks -=
+                                                       old_valid_blocks;
+               }
        }
        up_read(&curseg->journal_rwsem);
+
+       if (!err && total_node_blocks != valid_node_count(sbi)) {
+               f2fs_msg(sbi->sb, KERN_ERR,
+                       "SIT is corrupted node# %u vs %u",
+                       total_node_blocks, valid_node_count(sbi));
+               set_sbi_flag(sbi, SBI_NEED_FSCK);
+               err = -EINVAL;
+       }
+
        return err;
 }
 
@@ -3772,7 +3876,7 @@ static void init_min_max_mtime(struct f2fs_sb_info *sbi)
 
        down_write(&sit_i->sentry_lock);
 
-       sit_i->min_mtime = LLONG_MAX;
+       sit_i->min_mtime = ULLONG_MAX;
 
        for (segno = 0; segno < MAIN_SEGS(sbi); segno += sbi->segs_per_sec) {
                unsigned int i;
@@ -3786,11 +3890,11 @@ static void init_min_max_mtime(struct f2fs_sb_info *sbi)
                if (sit_i->min_mtime > mtime)
                        sit_i->min_mtime = mtime;
        }
-       sit_i->max_mtime = get_mtime(sbi);
+       sit_i->max_mtime = get_mtime(sbi, false);
        up_write(&sit_i->sentry_lock);
 }
 
-int build_segment_manager(struct f2fs_sb_info *sbi)
+int f2fs_build_segment_manager(struct f2fs_sb_info *sbi)
 {
        struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
        struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
@@ -3822,14 +3926,12 @@ int build_segment_manager(struct f2fs_sb_info *sbi)
        sm_info->min_hot_blocks = DEF_MIN_HOT_BLOCKS;
        sm_info->min_ssr_sections = reserved_sections(sbi);
 
-       sm_info->trim_sections = DEF_BATCHED_TRIM_SECTIONS;
-
        INIT_LIST_HEAD(&sm_info->sit_entry_set);
 
        init_rwsem(&sm_info->curseg_lock);
 
        if (!f2fs_readonly(sbi->sb)) {
-               err = create_flush_cmd_control(sbi);
+               err = f2fs_create_flush_cmd_control(sbi);
                if (err)
                        return err;
        }
@@ -3954,13 +4056,13 @@ static void destroy_sit_info(struct f2fs_sb_info *sbi)
        kfree(sit_i);
 }
 
-void destroy_segment_manager(struct f2fs_sb_info *sbi)
+void f2fs_destroy_segment_manager(struct f2fs_sb_info *sbi)
 {
        struct f2fs_sm_info *sm_info = SM_I(sbi);
 
        if (!sm_info)
                return;
-       destroy_flush_cmd_control(sbi, true);
+       f2fs_destroy_flush_cmd_control(sbi, true);
        destroy_discard_cmd_control(sbi);
        destroy_dirty_segmap(sbi);
        destroy_curseg(sbi);
@@ -3970,7 +4072,7 @@ void destroy_segment_manager(struct f2fs_sb_info *sbi)
        kfree(sm_info);
 }
 
-int __init create_segment_manager_caches(void)
+int __init f2fs_create_segment_manager_caches(void)
 {
        discard_entry_slab = f2fs_kmem_cache_create("discard_entry",
                        sizeof(struct discard_entry));
@@ -4003,7 +4105,7 @@ int __init create_segment_manager_caches(void)
        return -ENOMEM;
 }
 
-void destroy_segment_manager_caches(void)
+void f2fs_destroy_segment_manager_caches(void)
 {
        kmem_cache_destroy(sit_entry_set_slab);
        kmem_cache_destroy(discard_cmd_slab);
index 3325d076972326d5f11cd7776fceb07a3fec5a14..f18fc82fbe998c26784d2c60a735e3aec1bdde67 100644 (file)
@@ -85,7 +85,7 @@
        (GET_SEGOFF_FROM_SEG0(sbi, blk_addr) & ((sbi)->blocks_per_seg - 1))
 
 #define GET_SEGNO(sbi, blk_addr)                                       \
-       ((((blk_addr) == NULL_ADDR) || ((blk_addr) == NEW_ADDR)) ?      \
+       ((!is_valid_blkaddr(blk_addr)) ?                        \
        NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi),                 \
                GET_SEGNO_FROM_SEG0(sbi, blk_addr)))
 #define BLKS_PER_SEC(sbi)                                      \
@@ -215,6 +215,8 @@ struct segment_allocation {
 #define IS_DUMMY_WRITTEN_PAGE(page)                    \
                (page_private(page) == (unsigned long)DUMMY_WRITTEN_PAGE)
 
+#define MAX_SKIP_ATOMIC_COUNT                  16
+
 struct inmem_pages {
        struct list_head list;
        struct page *page;
@@ -375,6 +377,7 @@ static inline void seg_info_to_sit_page(struct f2fs_sb_info *sbi,
        int i;
 
        raw_sit = (struct f2fs_sit_block *)page_address(page);
+       memset(raw_sit, 0, PAGE_SIZE);
        for (i = 0; i < end - start; i++) {
                rs = &raw_sit->entries[i];
                se = get_seg_entry(sbi, start + i);
@@ -742,12 +745,23 @@ static inline void set_to_next_sit(struct sit_info *sit_i, unsigned int start)
 #endif
 }
 
-static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi)
+static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi,
+                                               bool base_time)
 {
        struct sit_info *sit_i = SIT_I(sbi);
-       time64_t now = ktime_get_real_seconds();
+       time64_t diff, now = ktime_get_real_seconds();
+
+       if (now >= sit_i->mounted_time)
+               return sit_i->elapsed_time + now - sit_i->mounted_time;
 
-       return sit_i->elapsed_time + now - sit_i->mounted_time;
+       /* system time is set to the past */
+       if (!base_time) {
+               diff = sit_i->mounted_time - now;
+               if (sit_i->elapsed_time >= diff)
+                       return sit_i->elapsed_time - diff;
+               return 0;
+       }
+       return sit_i->elapsed_time;
 }
 
 static inline void set_summary(struct f2fs_summary *sum, nid_t nid,
@@ -771,15 +785,6 @@ static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type)
                                - (base + 1) + type;
 }
 
-static inline bool no_fggc_candidate(struct f2fs_sb_info *sbi,
-                                               unsigned int secno)
-{
-       if (get_valid_blocks(sbi, GET_SEG_FROM_SEC(sbi, secno), true) >
-                                               sbi->fggc_threshold)
-               return true;
-       return false;
-}
-
 static inline bool sec_usage_check(struct f2fs_sb_info *sbi, unsigned int secno)
 {
        if (IS_CURSEC(sbi, secno) || (sbi->cur_victim_sec == secno))
index 0b5664a1a6cc85c2420142359364e3c32b0e782e..36cfd816c160827f6f65c358e1465d016eee1dca 100644 (file)
@@ -109,11 +109,11 @@ unsigned long f2fs_shrink_scan(struct shrinker *shrink,
 
                /* shrink clean nat cache entries */
                if (freed < nr)
-                       freed += try_to_free_nats(sbi, nr - freed);
+                       freed += f2fs_try_to_free_nats(sbi, nr - freed);
 
                /* shrink free nids cache entries */
                if (freed < nr)
-                       freed += try_to_free_nids(sbi, nr - freed);
+                       freed += f2fs_try_to_free_nids(sbi, nr - freed);
 
                spin_lock(&f2fs_list_lock);
                p = p->next;
index 970ae27f401c8f611f834dfb42c016db143288ef..3995e926ba3a366218d4ddc4ec2bcaccb0e855ab 100644 (file)
@@ -740,6 +740,10 @@ static int parse_options(struct super_block *sb, char *options)
                        } else if (strlen(name) == 6 &&
                                        !strncmp(name, "strict", 6)) {
                                F2FS_OPTION(sbi).fsync_mode = FSYNC_MODE_STRICT;
+                       } else if (strlen(name) == 9 &&
+                                       !strncmp(name, "nobarrier", 9)) {
+                               F2FS_OPTION(sbi).fsync_mode =
+                                                       FSYNC_MODE_NOBARRIER;
                        } else {
                                kfree(name);
                                return -EINVAL;
@@ -826,15 +830,14 @@ static struct inode *f2fs_alloc_inode(struct super_block *sb)
 
        /* Initialize f2fs-specific inode info */
        atomic_set(&fi->dirty_pages, 0);
-       fi->i_current_depth = 1;
        init_rwsem(&fi->i_sem);
        INIT_LIST_HEAD(&fi->dirty_list);
        INIT_LIST_HEAD(&fi->gdirty_list);
        INIT_LIST_HEAD(&fi->inmem_ilist);
        INIT_LIST_HEAD(&fi->inmem_pages);
        mutex_init(&fi->inmem_lock);
-       init_rwsem(&fi->dio_rwsem[READ]);
-       init_rwsem(&fi->dio_rwsem[WRITE]);
+       init_rwsem(&fi->i_gc_rwsem[READ]);
+       init_rwsem(&fi->i_gc_rwsem[WRITE]);
        init_rwsem(&fi->i_mmap_sem);
        init_rwsem(&fi->i_xattr_sem);
 
@@ -862,7 +865,7 @@ static int f2fs_drop_inode(struct inode *inode)
 
                        /* some remained atomic pages should discarded */
                        if (f2fs_is_atomic_file(inode))
-                               drop_inmem_pages(inode);
+                               f2fs_drop_inmem_pages(inode);
 
                        /* should remain fi->extent_tree for writepage */
                        f2fs_destroy_extent_node(inode);
@@ -999,7 +1002,7 @@ static void f2fs_put_super(struct super_block *sb)
                struct cp_control cpc = {
                        .reason = CP_UMOUNT,
                };
-               write_checkpoint(sbi, &cpc);
+               f2fs_write_checkpoint(sbi, &cpc);
        }
 
        /* be sure to wait for any on-going discard commands */
@@ -1009,17 +1012,17 @@ static void f2fs_put_super(struct super_block *sb)
                struct cp_control cpc = {
                        .reason = CP_UMOUNT | CP_TRIMMED,
                };
-               write_checkpoint(sbi, &cpc);
+               f2fs_write_checkpoint(sbi, &cpc);
        }
 
-       /* write_checkpoint can update stat informaion */
+       /* f2fs_write_checkpoint can update stat informaion */
        f2fs_destroy_stats(sbi);
 
        /*
         * normally superblock is clean, so we need to release this.
         * In addition, EIO will skip do checkpoint, we need this as well.
         */
-       release_ino_entry(sbi, true);
+       f2fs_release_ino_entry(sbi, true);
 
        f2fs_leave_shrinker(sbi);
        mutex_unlock(&sbi->umount_mutex);
@@ -1031,8 +1034,8 @@ static void f2fs_put_super(struct super_block *sb)
        iput(sbi->meta_inode);
 
        /* destroy f2fs internal modules */
-       destroy_node_manager(sbi);
-       destroy_segment_manager(sbi);
+       f2fs_destroy_node_manager(sbi);
+       f2fs_destroy_segment_manager(sbi);
 
        kfree(sbi->ckpt);
 
@@ -1074,7 +1077,7 @@ int f2fs_sync_fs(struct super_block *sb, int sync)
                cpc.reason = __get_cp_reason(sbi);
 
                mutex_lock(&sbi->gc_mutex);
-               err = write_checkpoint(sbi, &cpc);
+               err = f2fs_write_checkpoint(sbi, &cpc);
                mutex_unlock(&sbi->gc_mutex);
        }
        f2fs_trace_ios(NULL, 1);
@@ -1477,11 +1480,11 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
         */
        if ((*flags & SB_RDONLY) || !test_opt(sbi, BG_GC)) {
                if (sbi->gc_thread) {
-                       stop_gc_thread(sbi);
+                       f2fs_stop_gc_thread(sbi);
                        need_restart_gc = true;
                }
        } else if (!sbi->gc_thread) {
-               err = start_gc_thread(sbi);
+               err = f2fs_start_gc_thread(sbi);
                if (err)
                        goto restore_opts;
                need_stop_gc = true;
@@ -1504,9 +1507,9 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
         */
        if ((*flags & SB_RDONLY) || !test_opt(sbi, FLUSH_MERGE)) {
                clear_opt(sbi, FLUSH_MERGE);
-               destroy_flush_cmd_control(sbi, false);
+               f2fs_destroy_flush_cmd_control(sbi, false);
        } else {
-               err = create_flush_cmd_control(sbi);
+               err = f2fs_create_flush_cmd_control(sbi);
                if (err)
                        goto restore_gc;
        }
@@ -1524,11 +1527,11 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
        return 0;
 restore_gc:
        if (need_restart_gc) {
-               if (start_gc_thread(sbi))
+               if (f2fs_start_gc_thread(sbi))
                        f2fs_msg(sbi->sb, KERN_WARNING,
                                "background gc thread has stopped");
        } else if (need_stop_gc) {
-               stop_gc_thread(sbi);
+               f2fs_stop_gc_thread(sbi);
        }
 restore_opts:
 #ifdef CONFIG_QUOTA
@@ -1800,7 +1803,7 @@ static int f2fs_quota_on(struct super_block *sb, int type, int format_id,
        inode = d_inode(path->dentry);
 
        inode_lock(inode);
-       F2FS_I(inode)->i_flags |= FS_NOATIME_FL | FS_IMMUTABLE_FL;
+       F2FS_I(inode)->i_flags |= F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL;
        inode_set_flags(inode, S_NOATIME | S_IMMUTABLE,
                                        S_NOATIME | S_IMMUTABLE);
        inode_unlock(inode);
@@ -1824,7 +1827,7 @@ static int f2fs_quota_off(struct super_block *sb, int type)
                goto out_put;
 
        inode_lock(inode);
-       F2FS_I(inode)->i_flags &= ~(FS_NOATIME_FL | FS_IMMUTABLE_FL);
+       F2FS_I(inode)->i_flags &= ~(F2FS_NOATIME_FL | F2FS_IMMUTABLE_FL);
        inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
        inode_unlock(inode);
        f2fs_mark_inode_dirty_sync(inode, false);
@@ -1946,7 +1949,7 @@ static struct inode *f2fs_nfs_get_inode(struct super_block *sb,
        struct f2fs_sb_info *sbi = F2FS_SB(sb);
        struct inode *inode;
 
-       if (check_nid_range(sbi, ino))
+       if (f2fs_check_nid_range(sbi, ino))
                return ERR_PTR(-ESTALE);
 
        /*
@@ -2129,6 +2132,8 @@ static inline bool sanity_check_area_boundary(struct f2fs_sb_info *sbi,
 static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
                                struct buffer_head *bh)
 {
+       block_t segment_count, segs_per_sec, secs_per_zone;
+       block_t total_sections, blocks_per_seg;
        struct f2fs_super_block *raw_super = (struct f2fs_super_block *)
                                        (bh->b_data + F2FS_SUPER_OFFSET);
        struct super_block *sb = sbi->sb;
@@ -2185,6 +2190,72 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
                return 1;
        }
 
+       segment_count = le32_to_cpu(raw_super->segment_count);
+       segs_per_sec = le32_to_cpu(raw_super->segs_per_sec);
+       secs_per_zone = le32_to_cpu(raw_super->secs_per_zone);
+       total_sections = le32_to_cpu(raw_super->section_count);
+
+       /* blocks_per_seg should be 512, given the above check */
+       blocks_per_seg = 1 << le32_to_cpu(raw_super->log_blocks_per_seg);
+
+       if (segment_count > F2FS_MAX_SEGMENT ||
+                               segment_count < F2FS_MIN_SEGMENTS) {
+               f2fs_msg(sb, KERN_INFO,
+                       "Invalid segment count (%u)",
+                       segment_count);
+               return 1;
+       }
+
+       if (total_sections > segment_count ||
+                       total_sections < F2FS_MIN_SEGMENTS ||
+                       segs_per_sec > segment_count || !segs_per_sec) {
+               f2fs_msg(sb, KERN_INFO,
+                       "Invalid segment/section count (%u, %u x %u)",
+                       segment_count, total_sections, segs_per_sec);
+               return 1;
+       }
+
+       if ((segment_count / segs_per_sec) < total_sections) {
+               f2fs_msg(sb, KERN_INFO,
+                       "Small segment_count (%u < %u * %u)",
+                       segment_count, segs_per_sec, total_sections);
+               return 1;
+       }
+
+       if (segment_count > (le32_to_cpu(raw_super->block_count) >> 9)) {
+               f2fs_msg(sb, KERN_INFO,
+                       "Wrong segment_count / block_count (%u > %u)",
+                       segment_count, le32_to_cpu(raw_super->block_count));
+               return 1;
+       }
+
+       if (secs_per_zone > total_sections) {
+               f2fs_msg(sb, KERN_INFO,
+                       "Wrong secs_per_zone (%u > %u)",
+                       secs_per_zone, total_sections);
+               return 1;
+       }
+       if (le32_to_cpu(raw_super->extension_count) > F2FS_MAX_EXTENSION ||
+                       raw_super->hot_ext_count > F2FS_MAX_EXTENSION ||
+                       (le32_to_cpu(raw_super->extension_count) +
+                       raw_super->hot_ext_count) > F2FS_MAX_EXTENSION) {
+               f2fs_msg(sb, KERN_INFO,
+                       "Corrupted extension count (%u + %u > %u)",
+                       le32_to_cpu(raw_super->extension_count),
+                       raw_super->hot_ext_count,
+                       F2FS_MAX_EXTENSION);
+               return 1;
+       }
+
+       if (le32_to_cpu(raw_super->cp_payload) >
+                               (blocks_per_seg - F2FS_CP_PACKS)) {
+               f2fs_msg(sb, KERN_INFO,
+                       "Insane cp_payload (%u > %u)",
+                       le32_to_cpu(raw_super->cp_payload),
+                       blocks_per_seg - F2FS_CP_PACKS);
+               return 1;
+       }
+
        /* check reserved ino info */
        if (le32_to_cpu(raw_super->node_ino) != 1 ||
                le32_to_cpu(raw_super->meta_ino) != 2 ||
@@ -2197,13 +2268,6 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
                return 1;
        }
 
-       if (le32_to_cpu(raw_super->segment_count) > F2FS_MAX_SEGMENT) {
-               f2fs_msg(sb, KERN_INFO,
-                       "Invalid segment count (%u)",
-                       le32_to_cpu(raw_super->segment_count));
-               return 1;
-       }
-
        /* check CP/SIT/NAT/SSA/MAIN_AREA area boundary */
        if (sanity_check_area_boundary(sbi, bh))
                return 1;
@@ -2211,7 +2275,7 @@ static int sanity_check_raw_super(struct f2fs_sb_info *sbi,
        return 0;
 }
 
-int sanity_check_ckpt(struct f2fs_sb_info *sbi)
+int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi)
 {
        unsigned int total, fsmeta;
        struct f2fs_super_block *raw_super = F2FS_RAW_SUPER(sbi);
@@ -2292,13 +2356,15 @@ static void init_sb_info(struct f2fs_sb_info *sbi)
        for (i = 0; i < NR_COUNT_TYPE; i++)
                atomic_set(&sbi->nr_pages[i], 0);
 
-       atomic_set(&sbi->wb_sync_req, 0);
+       for (i = 0; i < META; i++)
+               atomic_set(&sbi->wb_sync_req[i], 0);
 
        INIT_LIST_HEAD(&sbi->s_list);
        mutex_init(&sbi->umount_mutex);
        for (i = 0; i < NR_PAGE_TYPE - 1; i++)
                for (j = HOT; j < NR_TEMP_TYPE; j++)
                        mutex_init(&sbi->wio_mutex[i][j]);
+       init_rwsem(&sbi->io_order_lock);
        spin_lock_init(&sbi->cp_lock);
 
        sbi->dirty_device = 0;
@@ -2353,8 +2419,10 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi)
 
 #define F2FS_REPORT_NR_ZONES   4096
 
-       zones = f2fs_kzalloc(sbi, sizeof(struct blk_zone) *
-                               F2FS_REPORT_NR_ZONES, GFP_KERNEL);
+       zones = f2fs_kzalloc(sbi,
+                            array_size(F2FS_REPORT_NR_ZONES,
+                                       sizeof(struct blk_zone)),
+                            GFP_KERNEL);
        if (!zones)
                return -ENOMEM;
 
@@ -2494,8 +2562,10 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi)
         * Initialize multiple devices information, or single
         * zoned block device information.
         */
-       sbi->devs = f2fs_kzalloc(sbi, sizeof(struct f2fs_dev_info) *
-                                               max_devices, GFP_KERNEL);
+       sbi->devs = f2fs_kzalloc(sbi,
+                                array_size(max_devices,
+                                           sizeof(struct f2fs_dev_info)),
+                                GFP_KERNEL);
        if (!sbi->devs)
                return -ENOMEM;
 
@@ -2717,9 +2787,11 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
                int n = (i == META) ? 1: NR_TEMP_TYPE;
                int j;
 
-               sbi->write_io[i] = f2fs_kmalloc(sbi,
-                                       n * sizeof(struct f2fs_bio_info),
-                                       GFP_KERNEL);
+               sbi->write_io[i] =
+                       f2fs_kmalloc(sbi,
+                                    array_size(n,
+                                               sizeof(struct f2fs_bio_info)),
+                                    GFP_KERNEL);
                if (!sbi->write_io[i]) {
                        err = -ENOMEM;
                        goto free_options;
@@ -2759,7 +2831,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
                goto free_io_dummy;
        }
 
-       err = get_valid_checkpoint(sbi);
+       err = f2fs_get_valid_checkpoint(sbi);
        if (err) {
                f2fs_msg(sb, KERN_ERR, "Failed to get valid F2FS checkpoint");
                goto free_meta_inode;
@@ -2789,18 +2861,18 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
                spin_lock_init(&sbi->inode_lock[i]);
        }
 
-       init_extent_cache_info(sbi);
+       f2fs_init_extent_cache_info(sbi);
 
-       init_ino_entry_info(sbi);
+       f2fs_init_ino_entry_info(sbi);
 
        /* setup f2fs internal modules */
-       err = build_segment_manager(sbi);
+       err = f2fs_build_segment_manager(sbi);
        if (err) {
                f2fs_msg(sb, KERN_ERR,
                        "Failed to initialize F2FS segment manager");
                goto free_sm;
        }
-       err = build_node_manager(sbi);
+       err = f2fs_build_node_manager(sbi);
        if (err) {
                f2fs_msg(sb, KERN_ERR,
                        "Failed to initialize F2FS node manager");
@@ -2818,7 +2890,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
                sbi->kbytes_written =
                        le64_to_cpu(seg_i->journal->info.kbytes_written);
 
-       build_gc_manager(sbi);
+       f2fs_build_gc_manager(sbi);
 
        /* get an inode for node space */
        sbi->node_inode = f2fs_iget(sb, F2FS_NODE_INO(sbi));
@@ -2870,7 +2942,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
        }
 #endif
        /* if there are nt orphan nodes free them */
-       err = recover_orphan_inodes(sbi);
+       err = f2fs_recover_orphan_inodes(sbi);
        if (err)
                goto free_meta;
 
@@ -2892,7 +2964,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
                if (!retry)
                        goto skip_recovery;
 
-               err = recover_fsync_data(sbi, false);
+               err = f2fs_recover_fsync_data(sbi, false);
                if (err < 0) {
                        need_fsck = true;
                        f2fs_msg(sb, KERN_ERR,
@@ -2900,7 +2972,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
                        goto free_meta;
                }
        } else {
-               err = recover_fsync_data(sbi, true);
+               err = f2fs_recover_fsync_data(sbi, true);
 
                if (!f2fs_readonly(sb) && err > 0) {
                        err = -EINVAL;
@@ -2910,7 +2982,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
                }
        }
 skip_recovery:
-       /* recover_fsync_data() cleared this already */
+       /* f2fs_recover_fsync_data() cleared this already */
        clear_sbi_flag(sbi, SBI_POR_DOING);
 
        /*
@@ -2919,7 +2991,7 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
         */
        if (test_opt(sbi, BG_GC) && !f2fs_readonly(sb)) {
                /* After POR, we can run background GC thread.*/
-               err = start_gc_thread(sbi);
+               err = f2fs_start_gc_thread(sbi);
                if (err)
                        goto free_meta;
        }
@@ -2950,10 +3022,10 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 #endif
        f2fs_sync_inode_meta(sbi);
        /*
-        * Some dirty meta pages can be produced by recover_orphan_inodes()
+        * Some dirty meta pages can be produced by f2fs_recover_orphan_inodes()
         * failed by EIO. Then, iput(node_inode) can trigger balance_fs_bg()
-        * followed by write_checkpoint() through f2fs_write_node_pages(), which
-        * falls into an infinite loop in sync_meta_pages().
+        * followed by f2fs_write_checkpoint() through f2fs_write_node_pages(), which
+        * falls into an infinite loop in f2fs_sync_meta_pages().
         */
        truncate_inode_pages_final(META_MAPPING(sbi));
 #ifdef CONFIG_QUOTA
@@ -2966,13 +3038,13 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
 free_stats:
        f2fs_destroy_stats(sbi);
 free_node_inode:
-       release_ino_entry(sbi, true);
+       f2fs_release_ino_entry(sbi, true);
        truncate_inode_pages_final(NODE_MAPPING(sbi));
        iput(sbi->node_inode);
 free_nm:
-       destroy_node_manager(sbi);
+       f2fs_destroy_node_manager(sbi);
 free_sm:
-       destroy_segment_manager(sbi);
+       f2fs_destroy_segment_manager(sbi);
 free_devices:
        destroy_device_list(sbi);
        kfree(sbi->ckpt);
@@ -3018,8 +3090,8 @@ static void kill_f2fs_super(struct super_block *sb)
 {
        if (sb->s_root) {
                set_sbi_flag(F2FS_SB(sb), SBI_IS_CLOSE);
-               stop_gc_thread(F2FS_SB(sb));
-               stop_discard_thread(F2FS_SB(sb));
+               f2fs_stop_gc_thread(F2FS_SB(sb));
+               f2fs_stop_discard_thread(F2FS_SB(sb));
        }
        kill_block_super(sb);
 }
@@ -3057,21 +3129,27 @@ static int __init init_f2fs_fs(void)
 {
        int err;
 
+       if (PAGE_SIZE != F2FS_BLKSIZE) {
+               printk("F2FS not supported on PAGE_SIZE(%lu) != %d\n",
+                               PAGE_SIZE, F2FS_BLKSIZE);
+               return -EINVAL;
+       }
+
        f2fs_build_trace_ios();
 
        err = init_inodecache();
        if (err)
                goto fail;
-       err = create_node_manager_caches();
+       err = f2fs_create_node_manager_caches();
        if (err)
                goto free_inodecache;
-       err = create_segment_manager_caches();
+       err = f2fs_create_segment_manager_caches();
        if (err)
                goto free_node_manager_caches;
-       err = create_checkpoint_caches();
+       err = f2fs_create_checkpoint_caches();
        if (err)
                goto free_segment_manager_caches;
-       err = create_extent_cache();
+       err = f2fs_create_extent_cache();
        if (err)
                goto free_checkpoint_caches;
        err = f2fs_init_sysfs();
@@ -3086,8 +3164,13 @@ static int __init init_f2fs_fs(void)
        err = f2fs_create_root_stats();
        if (err)
                goto free_filesystem;
+       err = f2fs_init_post_read_processing();
+       if (err)
+               goto free_root_stats;
        return 0;
 
+free_root_stats:
+       f2fs_destroy_root_stats();
 free_filesystem:
        unregister_filesystem(&f2fs_fs_type);
 free_shrinker:
@@ -3095,13 +3178,13 @@ static int __init init_f2fs_fs(void)
 free_sysfs:
        f2fs_exit_sysfs();
 free_extent_cache:
-       destroy_extent_cache();
+       f2fs_destroy_extent_cache();
 free_checkpoint_caches:
-       destroy_checkpoint_caches();
+       f2fs_destroy_checkpoint_caches();
 free_segment_manager_caches:
-       destroy_segment_manager_caches();
+       f2fs_destroy_segment_manager_caches();
 free_node_manager_caches:
-       destroy_node_manager_caches();
+       f2fs_destroy_node_manager_caches();
 free_inodecache:
        destroy_inodecache();
 fail:
@@ -3110,14 +3193,15 @@ static int __init init_f2fs_fs(void)
 
 static void __exit exit_f2fs_fs(void)
 {
+       f2fs_destroy_post_read_processing();
        f2fs_destroy_root_stats();
        unregister_filesystem(&f2fs_fs_type);
        unregister_shrinker(&f2fs_shrinker_info);
        f2fs_exit_sysfs();
-       destroy_extent_cache();
-       destroy_checkpoint_caches();
-       destroy_segment_manager_caches();
-       destroy_node_manager_caches();
+       f2fs_destroy_extent_cache();
+       f2fs_destroy_checkpoint_caches();
+       f2fs_destroy_segment_manager_caches();
+       f2fs_destroy_node_manager_caches();
        destroy_inodecache();
        f2fs_destroy_trace_ios();
 }
index 4b47ca6296a75093ed48d023e80d6ee6001731bb..2e7e611deaef2df1f61cc7145138db9c7a08dba5 100644 (file)
@@ -147,13 +147,13 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
                int len = 0, i;
 
                len += snprintf(buf + len, PAGE_SIZE - len,
-                                               "cold file extenstion:\n");
+                                               "cold file extension:\n");
                for (i = 0; i < cold_count; i++)
                        len += snprintf(buf + len, PAGE_SIZE - len, "%s\n",
                                                                extlist[i]);
 
                len += snprintf(buf + len, PAGE_SIZE - len,
-                                               "hot file extenstion:\n");
+                                               "hot file extension:\n");
                for (i = cold_count; i < cold_count + hot_count; i++)
                        len += snprintf(buf + len, PAGE_SIZE - len, "%s\n",
                                                                extlist[i]);
@@ -165,7 +165,7 @@ static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
        return snprintf(buf, PAGE_SIZE, "%u\n", *ui);
 }
 
-static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
+static ssize_t __sbi_store(struct f2fs_attr *a,
                        struct f2fs_sb_info *sbi,
                        const char *buf, size_t count)
 {
@@ -201,13 +201,13 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
 
                down_write(&sbi->sb_lock);
 
-               ret = update_extension_list(sbi, name, hot, set);
+               ret = f2fs_update_extension_list(sbi, name, hot, set);
                if (ret)
                        goto out;
 
                ret = f2fs_commit_super(sbi, false);
                if (ret)
-                       update_extension_list(sbi, name, hot, !set);
+                       f2fs_update_extension_list(sbi, name, hot, !set);
 out:
                up_write(&sbi->sb_lock);
                return ret ? ret : count;
@@ -245,19 +245,56 @@ static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
                return count;
        }
 
+       if (!strcmp(a->attr.name, "trim_sections"))
+               return -EINVAL;
+
+       if (!strcmp(a->attr.name, "gc_urgent")) {
+               if (t >= 1) {
+                       sbi->gc_mode = GC_URGENT;
+                       if (sbi->gc_thread) {
+                               wake_up_interruptible_all(
+                                       &sbi->gc_thread->gc_wait_queue_head);
+                               wake_up_discard_thread(sbi, true);
+                       }
+               } else {
+                       sbi->gc_mode = GC_NORMAL;
+               }
+               return count;
+       }
+       if (!strcmp(a->attr.name, "gc_idle")) {
+               if (t == GC_IDLE_CB)
+                       sbi->gc_mode = GC_IDLE_CB;
+               else if (t == GC_IDLE_GREEDY)
+                       sbi->gc_mode = GC_IDLE_GREEDY;
+               else
+                       sbi->gc_mode = GC_NORMAL;
+               return count;
+       }
+
        *ui = t;
 
        if (!strcmp(a->attr.name, "iostat_enable") && *ui == 0)
                f2fs_reset_iostat(sbi);
-       if (!strcmp(a->attr.name, "gc_urgent") && t == 1 && sbi->gc_thread) {
-               sbi->gc_thread->gc_wake = 1;
-               wake_up_interruptible_all(&sbi->gc_thread->gc_wait_queue_head);
-               wake_up_discard_thread(sbi, true);
-       }
-
        return count;
 }
 
+static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
+                       struct f2fs_sb_info *sbi,
+                       const char *buf, size_t count)
+{
+       ssize_t ret;
+       bool gc_entry = (!strcmp(a->attr.name, "gc_urgent") ||
+                                       a->struct_type == GC_THREAD);
+
+       if (gc_entry)
+               down_read(&sbi->sb->s_umount);
+       ret = __sbi_store(a, sbi, buf, count);
+       if (gc_entry)
+               up_read(&sbi->sb->s_umount);
+
+       return ret;
+}
+
 static ssize_t f2fs_attr_show(struct kobject *kobj,
                                struct attribute *attr, char *buf)
 {
@@ -346,8 +383,8 @@ F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_urgent_sleep_time,
 F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_min_sleep_time, min_sleep_time);
 F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_max_sleep_time, max_sleep_time);
 F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time);
-F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_idle, gc_idle);
-F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_urgent, gc_urgent);
+F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle, gc_mode);
+F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent, gc_mode);
 F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments);
 F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards);
 F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_granularity, discard_granularity);
index ae2dfa709f5dcf2f8e5b1084f5bce89377942ccc..708271871f945c63a4b11885ef2e8e3453b6bc8f 100644 (file)
@@ -252,7 +252,7 @@ static int read_inline_xattr(struct inode *inode, struct page *ipage,
        if (ipage) {
                inline_addr = inline_xattr_addr(inode, ipage);
        } else {
-               page = get_node_page(sbi, inode->i_ino);
+               page = f2fs_get_node_page(sbi, inode->i_ino);
                if (IS_ERR(page))
                        return PTR_ERR(page);
 
@@ -273,7 +273,7 @@ static int read_xattr_block(struct inode *inode, void *txattr_addr)
        void *xattr_addr;
 
        /* The inode already has an extended attribute block. */
-       xpage = get_node_page(sbi, xnid);
+       xpage = f2fs_get_node_page(sbi, xnid);
        if (IS_ERR(xpage))
                return PTR_ERR(xpage);
 
@@ -397,7 +397,7 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
        int err = 0;
 
        if (hsize > inline_size && !F2FS_I(inode)->i_xattr_nid)
-               if (!alloc_nid(sbi, &new_nid))
+               if (!f2fs_alloc_nid(sbi, &new_nid))
                        return -ENOSPC;
 
        /* write to inline xattr */
@@ -405,9 +405,9 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
                if (ipage) {
                        inline_addr = inline_xattr_addr(inode, ipage);
                } else {
-                       in_page = get_node_page(sbi, inode->i_ino);
+                       in_page = f2fs_get_node_page(sbi, inode->i_ino);
                        if (IS_ERR(in_page)) {
-                               alloc_nid_failed(sbi, new_nid);
+                               f2fs_alloc_nid_failed(sbi, new_nid);
                                return PTR_ERR(in_page);
                        }
                        inline_addr = inline_xattr_addr(inode, in_page);
@@ -417,8 +417,8 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
                                                        NODE, true);
                /* no need to use xattr node block */
                if (hsize <= inline_size) {
-                       err = truncate_xattr_node(inode);
-                       alloc_nid_failed(sbi, new_nid);
+                       err = f2fs_truncate_xattr_node(inode);
+                       f2fs_alloc_nid_failed(sbi, new_nid);
                        if (err) {
                                f2fs_put_page(in_page, 1);
                                return err;
@@ -431,10 +431,10 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
 
        /* write to xattr node block */
        if (F2FS_I(inode)->i_xattr_nid) {
-               xpage = get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
+               xpage = f2fs_get_node_page(sbi, F2FS_I(inode)->i_xattr_nid);
                if (IS_ERR(xpage)) {
                        err = PTR_ERR(xpage);
-                       alloc_nid_failed(sbi, new_nid);
+                       f2fs_alloc_nid_failed(sbi, new_nid);
                        goto in_page_out;
                }
                f2fs_bug_on(sbi, new_nid);
@@ -442,13 +442,13 @@ static inline int write_all_xattrs(struct inode *inode, __u32 hsize,
        } else {
                struct dnode_of_data dn;
                set_new_dnode(&dn, inode, NULL, NULL, new_nid);
-               xpage = new_node_page(&dn, XATTR_NODE_OFFSET);
+               xpage = f2fs_new_node_page(&dn, XATTR_NODE_OFFSET);
                if (IS_ERR(xpage)) {
                        err = PTR_ERR(xpage);
-                       alloc_nid_failed(sbi, new_nid);
+                       f2fs_alloc_nid_failed(sbi, new_nid);
                        goto in_page_out;
                }
-               alloc_nid_done(sbi, new_nid);
+               f2fs_alloc_nid_done(sbi, new_nid);
        }
        xattr_addr = page_address(xpage);
 
@@ -693,7 +693,7 @@ int f2fs_setxattr(struct inode *inode, int index, const char *name,
        if (err)
                return err;
 
-       /* this case is only from init_inode_metadata */
+       /* this case is only from f2fs_init_inode_metadata */
        if (ipage)
                return __f2fs_setxattr(inode, index, name, value,
                                                size, ipage, flags);
index ffbbf0520d9e8f8f566cb790642fd78647767410..065dc919a0ce15963b21265f4872b007bcfc3310 100644 (file)
@@ -158,8 +158,14 @@ static inline int __fat_get_block(struct inode *inode, sector_t iblock,
        err = fat_bmap(inode, iblock, &phys, &mapped_blocks, create, false);
        if (err)
                return err;
+       if (!phys) {
+               fat_fs_error(sb,
+                            "invalid FAT chain (i_pos %lld, last_block %llu)",
+                            MSDOS_I(inode)->i_pos,
+                            (unsigned long long)last_block);
+               return -EIO;
+       }
 
-       BUG_ON(!phys);
        BUG_ON(*max_blocks != mapped_blocks);
        set_buffer_new(bh_result);
        map_bh(bh_result, sb, phys);
@@ -502,6 +508,7 @@ static int fat_validate_dir(struct inode *dir)
 /* doesn't deal with root inode */
 int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
 {
+       struct timespec ts;
        struct msdos_sb_info *sbi = MSDOS_SB(inode->i_sb);
        int error;
 
@@ -552,11 +559,14 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
        inode->i_blocks = ((inode->i_size + (sbi->cluster_size - 1))
                           & ~((loff_t)sbi->cluster_size - 1)) >> 9;
 
-       fat_time_fat2unix(sbi, &inode->i_mtime, de->time, de->date, 0);
+       fat_time_fat2unix(sbi, &ts, de->time, de->date, 0);
+       inode->i_mtime = timespec_to_timespec64(ts);
        if (sbi->options.isvfat) {
-               fat_time_fat2unix(sbi, &inode->i_ctime, de->ctime,
+               fat_time_fat2unix(sbi, &ts, de->ctime,
                                  de->cdate, de->ctime_cs);
-               fat_time_fat2unix(sbi, &inode->i_atime, 0, de->adate, 0);
+               inode->i_ctime = timespec_to_timespec64(ts);
+               fat_time_fat2unix(sbi, &ts, 0, de->adate, 0);
+               inode->i_atime = timespec_to_timespec64(ts);
        } else
                inode->i_ctime = inode->i_atime = inode->i_mtime;
 
@@ -825,6 +835,7 @@ static int fat_statfs(struct dentry *dentry, struct kstatfs *buf)
 
 static int __fat_write_inode(struct inode *inode, int wait)
 {
+       struct timespec ts;
        struct super_block *sb = inode->i_sb;
        struct msdos_sb_info *sbi = MSDOS_SB(sb);
        struct buffer_head *bh;
@@ -862,13 +873,16 @@ static int __fat_write_inode(struct inode *inode, int wait)
                raw_entry->size = cpu_to_le32(inode->i_size);
        raw_entry->attr = fat_make_attrs(inode);
        fat_set_start(raw_entry, MSDOS_I(inode)->i_logstart);
-       fat_time_unix2fat(sbi, &inode->i_mtime, &raw_entry->time,
+       ts = timespec64_to_timespec(inode->i_mtime);
+       fat_time_unix2fat(sbi, &ts, &raw_entry->time,
                          &raw_entry->date, NULL);
        if (sbi->options.isvfat) {
                __le16 atime;
-               fat_time_unix2fat(sbi, &inode->i_ctime, &raw_entry->ctime,
+               ts = timespec64_to_timespec(inode->i_ctime);
+               fat_time_unix2fat(sbi, &ts, &raw_entry->ctime,
                                  &raw_entry->cdate, &raw_entry->ctime_cs);
-               fat_time_unix2fat(sbi, &inode->i_atime, &atime,
+               ts = timespec64_to_timespec(inode->i_atime);
+               fat_time_unix2fat(sbi, &ts, &atime,
                                  &raw_entry->adate, NULL);
        }
        spin_unlock(&sbi->inode_hash_lock);
index 484ce674e0cdd18b0f501391f21551684643d9f0..16a832c37d663b518432387e5826c1b957fee3d9 100644 (file)
@@ -250,7 +250,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
        if (err)
                return err;
 
-       dir->i_ctime = dir->i_mtime = *ts;
+       dir->i_ctime = dir->i_mtime = timespec_to_timespec64(*ts);
        if (IS_DIRSYNC(dir))
                (void)fat_sync_inode(dir);
        else
@@ -266,7 +266,8 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
        struct super_block *sb = dir->i_sb;
        struct inode *inode = NULL;
        struct fat_slot_info sinfo;
-       struct timespec ts;
+       struct timespec64 ts;
+       struct timespec t;
        unsigned char msdos_name[MSDOS_NAME];
        int err, is_hid;
 
@@ -285,7 +286,8 @@ static int msdos_create(struct inode *dir, struct dentry *dentry, umode_t mode,
        }
 
        ts = current_time(dir);
-       err = msdos_add_entry(dir, msdos_name, 0, is_hid, 0, &ts, &sinfo);
+       t = timespec64_to_timespec(ts);
+       err = msdos_add_entry(dir, msdos_name, 0, is_hid, 0, &t, &sinfo);
        if (err)
                goto out;
        inode = fat_build_inode(sb, sinfo.de, sinfo.i_pos);
@@ -344,7 +346,8 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
        struct fat_slot_info sinfo;
        struct inode *inode;
        unsigned char msdos_name[MSDOS_NAME];
-       struct timespec ts;
+       struct timespec64 ts;
+       struct timespec t;
        int err, is_hid, cluster;
 
        mutex_lock(&MSDOS_SB(sb)->s_lock);
@@ -362,12 +365,13 @@ static int msdos_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
        }
 
        ts = current_time(dir);
-       cluster = fat_alloc_new_dir(dir, &ts);
+       t = timespec64_to_timespec(ts);
+       cluster = fat_alloc_new_dir(dir, &t);
        if (cluster < 0) {
                err = cluster;
                goto out;
        }
-       err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &ts, &sinfo);
+       err = msdos_add_entry(dir, msdos_name, 1, is_hid, cluster, &t, &sinfo);
        if (err)
                goto out_free;
        inc_nlink(dir);
@@ -432,7 +436,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
        struct msdos_dir_entry *dotdot_de;
        struct inode *old_inode, *new_inode;
        struct fat_slot_info old_sinfo, sinfo;
-       struct timespec ts;
+       struct timespec64 ts;
        loff_t new_i_pos;
        int err, old_attrs, is_dir, update_dotdot, corrupt = 0;
 
@@ -499,8 +503,9 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
                new_i_pos = MSDOS_I(new_inode)->i_pos;
                fat_detach(new_inode);
        } else {
+               struct timespec t = timespec64_to_timespec(ts);
                err = msdos_add_entry(new_dir, new_name, is_dir, is_hid, 0,
-                                     &ts, &sinfo);
+                                     &t, &sinfo);
                if (err)
                        goto out;
                new_i_pos = sinfo.i_pos;
index 4f4362d5a04c4c5283fec23fa703440e12da8d49..9a5469120caaf4dc6adafc7560da2fb13ffd009b 100644 (file)
@@ -664,7 +664,7 @@ static int vfat_add_entry(struct inode *dir, const struct qstr *qname,
        if (len == 0)
                return -ENOENT;
 
-       slots = kmalloc(sizeof(*slots) * MSDOS_SLOTS, GFP_NOFS);
+       slots = kmalloc_array(MSDOS_SLOTS, sizeof(*slots), GFP_NOFS);
        if (slots == NULL)
                return -ENOMEM;
 
@@ -678,7 +678,7 @@ static int vfat_add_entry(struct inode *dir, const struct qstr *qname,
                goto cleanup;
 
        /* update timestamp */
-       dir->i_ctime = dir->i_mtime = dir->i_atime = *ts;
+       dir->i_ctime = dir->i_mtime = dir->i_atime = timespec_to_timespec64(*ts);
        if (IS_DIRSYNC(dir))
                (void)fat_sync_inode(dir);
        else
@@ -761,13 +761,15 @@ static int vfat_create(struct inode *dir, struct dentry *dentry, umode_t mode,
        struct super_block *sb = dir->i_sb;
        struct inode *inode;
        struct fat_slot_info sinfo;
-       struct timespec ts;
+       struct timespec64 ts;
+       struct timespec t;
        int err;
 
        mutex_lock(&MSDOS_SB(sb)->s_lock);
 
        ts = current_time(dir);
-       err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &ts, &sinfo);
+       t = timespec64_to_timespec(ts);
+       err = vfat_add_entry(dir, &dentry->d_name, 0, 0, &t, &sinfo);
        if (err)
                goto out;
        inode_inc_iversion(dir);
@@ -850,18 +852,20 @@ static int vfat_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
        struct super_block *sb = dir->i_sb;
        struct inode *inode;
        struct fat_slot_info sinfo;
-       struct timespec ts;
+       struct timespec64 ts;
+       struct timespec t;
        int err, cluster;
 
        mutex_lock(&MSDOS_SB(sb)->s_lock);
 
        ts = current_time(dir);
-       cluster = fat_alloc_new_dir(dir, &ts);
+       t = timespec64_to_timespec(ts);
+       cluster = fat_alloc_new_dir(dir, &t);
        if (cluster < 0) {
                err = cluster;
                goto out;
        }
-       err = vfat_add_entry(dir, &dentry->d_name, 1, cluster, &ts, &sinfo);
+       err = vfat_add_entry(dir, &dentry->d_name, 1, cluster, &t, &sinfo);
        if (err)
                goto out_free;
        inode_inc_iversion(dir);
@@ -899,7 +903,8 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
        struct msdos_dir_entry *dotdot_de;
        struct inode *old_inode, *new_inode;
        struct fat_slot_info old_sinfo, sinfo;
-       struct timespec ts;
+       struct timespec64 ts;
+       struct timespec t;
        loff_t new_i_pos;
        int err, is_dir, update_dotdot, corrupt = 0;
        struct super_block *sb = old_dir->i_sb;
@@ -934,8 +939,9 @@ static int vfat_rename(struct inode *old_dir, struct dentry *old_dentry,
                new_i_pos = MSDOS_I(new_inode)->i_pos;
                fat_detach(new_inode);
        } else {
+               t = timespec64_to_timespec(ts);
                err = vfat_add_entry(new_dir, &new_dentry->d_name, is_dir, 0,
-                                    &ts, &sinfo);
+                                    &t, &sinfo);
                if (err)
                        goto out;
                new_i_pos = sinfo.i_pos;
index e03ca14f40e957703ad901e83c2f6ec90f46fc56..c6b88fa85e2e5d048ea49b268c402843d53c2c0e 100644 (file)
@@ -64,9 +64,12 @@ static struct fuse_req *__fuse_request_alloc(unsigned npages, gfp_t flags)
                        pages = req->inline_pages;
                        page_descs = req->inline_page_descs;
                } else {
-                       pages = kmalloc(sizeof(struct page *) * npages, flags);
-                       page_descs = kmalloc(sizeof(struct fuse_page_desc) *
-                                            npages, flags);
+                       pages = kmalloc_array(npages, sizeof(struct page *),
+                                             flags);
+                       page_descs =
+                               kmalloc_array(npages,
+                                             sizeof(struct fuse_page_desc),
+                                             flags);
                }
 
                if (!pages || !page_descs) {
@@ -1359,7 +1362,8 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
        if (!fud)
                return -EPERM;
 
-       bufs = kmalloc(pipe->buffers * sizeof(struct pipe_buffer), GFP_KERNEL);
+       bufs = kmalloc_array(pipe->buffers, sizeof(struct pipe_buffer),
+                            GFP_KERNEL);
        if (!bufs)
                return -ENOMEM;
 
@@ -1940,7 +1944,8 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe,
        if (!fud)
                return -EPERM;
 
-       bufs = kmalloc(pipe->buffers * sizeof(struct pipe_buffer), GFP_KERNEL);
+       bufs = kmalloc_array(pipe->buffers, sizeof(struct pipe_buffer),
+                            GFP_KERNEL);
        if (!bufs)
                return -ENOMEM;
 
index ffcaf98044b9aeb81292532a838133c518ca6d73..a24df8861b40d2148e51b98f2503c5c846f9d7ea 100644 (file)
@@ -217,7 +217,7 @@ void fuse_change_attributes(struct inode *inode, struct fuse_attr *attr,
                return;
        }
 
-       old_mtime = inode->i_mtime;
+       old_mtime = timespec64_to_timespec(inode->i_mtime);
        fuse_change_attributes_common(inode, attr, attr_valid);
 
        oldsize = inode->i_size;
index d9fb0ad6cc30cc92c32e22b1c86ea056cad732b7..d97ad89955d1419f4bb88eb5c86c4e6daecb284c 100644 (file)
@@ -871,7 +871,7 @@ static struct gfs2_leaf *new_leaf(struct inode *inode, struct buffer_head **pbh,
        struct buffer_head *bh;
        struct gfs2_leaf *leaf;
        struct gfs2_dirent *dent;
-       struct timespec tv = current_time(inode);
+       struct timespec64 tv = current_time(inode);
 
        error = gfs2_alloc_blocks(ip, &bn, &n, 0, NULL);
        if (error)
@@ -1055,7 +1055,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name)
        /* Change the pointers.
           Don't bother distinguishing stuffed from non-stuffed.
           This code is complicated enough already. */
-       lp = kmalloc(half_len * sizeof(__be64), GFP_NOFS);
+       lp = kmalloc_array(half_len, sizeof(__be64), GFP_NOFS);
        if (!lp) {
                error = -ENOMEM;
                goto fail_brelse;
@@ -1169,7 +1169,7 @@ static int dir_double_exhash(struct gfs2_inode *dip)
        if (IS_ERR(hc))
                return PTR_ERR(hc);
 
-       hc2 = kmalloc(hsize_bytes * 2, GFP_NOFS | __GFP_NOWARN);
+       hc2 = kmalloc_array(hsize_bytes, 2, GFP_NOFS | __GFP_NOWARN);
        if (hc2 == NULL)
                hc2 = __vmalloc(hsize_bytes * 2, GFP_NOFS, PAGE_KERNEL);
 
@@ -1596,7 +1596,7 @@ int gfs2_dir_read(struct inode *inode, struct dir_context *ctx,
 
        error = -ENOMEM;
        /* 96 is max number of dirents which can be stuffed into an inode */
-       darr = kmalloc(96 * sizeof(struct gfs2_dirent *), GFP_NOFS);
+       darr = kmalloc_array(96, sizeof(struct gfs2_dirent *), GFP_NOFS);
        if (darr) {
                g.pdent = (const struct gfs2_dirent **)darr;
                g.offset = 0;
@@ -1802,7 +1802,7 @@ int gfs2_dir_add(struct inode *inode, const struct qstr *name,
        struct gfs2_inode *ip = GFS2_I(inode);
        struct buffer_head *bh = da->bh;
        struct gfs2_dirent *dent = da->dent;
-       struct timespec tv;
+       struct timespec64 tv;
        struct gfs2_leaf *leaf;
        int error;
 
@@ -1880,7 +1880,7 @@ int gfs2_dir_del(struct gfs2_inode *dip, const struct dentry *dentry)
        const struct qstr *name = &dentry->d_name;
        struct gfs2_dirent *dent, *prev = NULL;
        struct buffer_head *bh;
-       struct timespec tv = current_time(&dip->i_inode);
+       struct timespec64 tv = current_time(&dip->i_inode);
 
        /* Returns _either_ the entry (if its first in block) or the
           previous entry otherwise */
index 097bd3c0f270b690d9e74c9c053698568a03fef9..4614ee25f6211efe24550edfdd68021ceaa20bf7 100644 (file)
@@ -1303,7 +1303,8 @@ int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs)
        default:
                if (num_gh <= 4)
                        break;
-               pph = kmalloc(num_gh * sizeof(struct gfs2_holder *), GFP_NOFS);
+               pph = kmalloc_array(num_gh, sizeof(struct gfs2_holder *),
+                                   GFP_NOFS);
                if (!pph)
                        return -ENOMEM;
        }
index d8782a7a1e7dd250aa332c21c8d9b479fa11b317..c63bee9adb6a8e175d8e2cfc78abe197264acf5e 100644 (file)
@@ -338,7 +338,7 @@ static int inode_go_demote_ok(const struct gfs2_glock *gl)
 static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
 {
        const struct gfs2_dinode *str = buf;
-       struct timespec atime;
+       struct timespec64 atime;
        u16 height, depth;
 
        if (unlikely(ip->i_no_addr != be64_to_cpu(str->di_num.no_addr)))
@@ -361,7 +361,7 @@ static int gfs2_dinode_in(struct gfs2_inode *ip, const void *buf)
        gfs2_set_inode_blocks(&ip->i_inode, be64_to_cpu(str->di_blocks));
        atime.tv_sec = be64_to_cpu(str->di_atime);
        atime.tv_nsec = be32_to_cpu(str->di_atime_nsec);
-       if (timespec_compare(&ip->i_inode.i_atime, &atime) < 0)
+       if (timespec64_compare(&ip->i_inode.i_atime, &atime) < 0)
                ip->i_inode.i_atime = atime;
        ip->i_inode.i_mtime.tv_sec = be64_to_cpu(str->di_mtime);
        ip->i_inode.i_mtime.tv_nsec = be32_to_cpu(str->di_mtime_nsec);
index e8585dfd209f5b8174b6fb8d892de7b4e28270fe..0efae7a0ee8017a41754e9bf51f013e1e20971ef 100644 (file)
@@ -886,7 +886,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda)
        gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota),
                              &data_blocks, &ind_blocks);
 
-       ghs = kmalloc(num_qd * sizeof(struct gfs2_holder), GFP_NOFS);
+       ghs = kmalloc_array(num_qd, sizeof(struct gfs2_holder), GFP_NOFS);
        if (!ghs)
                return -ENOMEM;
 
index 6bc5cfe710d18fc1e7bf6a0550a1a032593e0ccb..33abcf29bc05c4c80114203a05958240c085198b 100644 (file)
@@ -2605,8 +2605,9 @@ void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state)
 {
        unsigned int x;
 
-       rlist->rl_ghs = kmalloc(rlist->rl_rgrps * sizeof(struct gfs2_holder),
-                               GFP_NOFS | __GFP_NOFAIL);
+       rlist->rl_ghs = kmalloc_array(rlist->rl_rgrps,
+                                     sizeof(struct gfs2_holder),
+                                     GFP_NOFS | __GFP_NOFAIL);
        for (x = 0; x < rlist->rl_rgrps; x++)
                gfs2_holder_init(rlist->rl_rgd[x]->rd_gl,
                                state, 0,
index cf5c7f3080d24502218a4a3dadd776c61de7d1cd..af0d5b01cf0bfcc1963e4f671d080102d65edfe2 100644 (file)
@@ -1097,7 +1097,7 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host
        int error = 0, err;
 
        memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
-       gha = kmalloc(slots * sizeof(struct gfs2_holder), GFP_KERNEL);
+       gha = kmalloc_array(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
        if (!gha)
                return -ENOMEM;
        for (x = 0; x < slots; x++)
index b3309b83371a24232459a518d90b2537f7a3b06b..2a16111d312fcaded7e265d294031035b63a9a3a 100644 (file)
@@ -351,7 +351,7 @@ static int hfs_read_inode(struct inode *inode, void *data)
                inode->i_mode &= ~hsb->s_file_umask;
                inode->i_mode |= S_IFREG;
                inode->i_ctime = inode->i_atime = inode->i_mtime =
-                               hfs_m_to_utime(rec->file.MdDat);
+                               timespec_to_timespec64(hfs_m_to_utime(rec->file.MdDat));
                inode->i_op = &hfs_file_inode_operations;
                inode->i_fop = &hfs_file_operations;
                inode->i_mapping->a_ops = &hfs_aops;
@@ -362,7 +362,7 @@ static int hfs_read_inode(struct inode *inode, void *data)
                HFS_I(inode)->fs_blocks = 0;
                inode->i_mode = S_IFDIR | (S_IRWXUGO & ~hsb->s_dir_umask);
                inode->i_ctime = inode->i_atime = inode->i_mtime =
-                               hfs_m_to_utime(rec->dir.MdDat);
+                               timespec_to_timespec64(hfs_m_to_utime(rec->dir.MdDat));
                inode->i_op = &hfs_dir_inode_operations;
                inode->i_fop = &hfs_dir_operations;
                break;
index c0c8d433864f15cc97ee9aead06298dab27443b5..c824f702feec438eb1cbd59aa721ba19ea280a25 100644 (file)
@@ -493,9 +493,9 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
                hfsplus_get_perms(inode, &folder->permissions, 1);
                set_nlink(inode, 1);
                inode->i_size = 2 + be32_to_cpu(folder->valence);
-               inode->i_atime = hfsp_mt2ut(folder->access_date);
-               inode->i_mtime = hfsp_mt2ut(folder->content_mod_date);
-               inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date);
+               inode->i_atime = timespec_to_timespec64(hfsp_mt2ut(folder->access_date));
+               inode->i_mtime = timespec_to_timespec64(hfsp_mt2ut(folder->content_mod_date));
+               inode->i_ctime = timespec_to_timespec64(hfsp_mt2ut(folder->attribute_mod_date));
                HFSPLUS_I(inode)->create_date = folder->create_date;
                HFSPLUS_I(inode)->fs_blocks = 0;
                if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) {
@@ -531,9 +531,9 @@ int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
                        init_special_inode(inode, inode->i_mode,
                                           be32_to_cpu(file->permissions.dev));
                }
-               inode->i_atime = hfsp_mt2ut(file->access_date);
-               inode->i_mtime = hfsp_mt2ut(file->content_mod_date);
-               inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date);
+               inode->i_atime = timespec_to_timespec64(hfsp_mt2ut(file->access_date));
+               inode->i_mtime = timespec_to_timespec64(hfsp_mt2ut(file->content_mod_date));
+               inode->i_ctime = timespec_to_timespec64(hfsp_mt2ut(file->attribute_mod_date));
                HFSPLUS_I(inode)->create_date = file->create_date;
        } else {
                pr_err("bad catalog entry used to create inode\n");
index 3cd85eb5bbb124b77dfbbd105abce405d7b66f80..2597b290c2a596c0853761a1f7f776f38ddfbfa0 100644 (file)
@@ -555,9 +555,9 @@ static int read_name(struct inode *ino, char *name)
        set_nlink(ino, st.nlink);
        i_uid_write(ino, st.uid);
        i_gid_write(ino, st.gid);
-       ino->i_atime = st.atime;
-       ino->i_mtime = st.mtime;
-       ino->i_ctime = st.ctime;
+       ino->i_atime = timespec_to_timespec64(st.atime);
+       ino->i_mtime = timespec_to_timespec64(st.mtime);
+       ino->i_ctime = timespec_to_timespec64(st.ctime);
        ino->i_size = st.size;
        ino->i_blocks = st.blocks;
        return 0;
@@ -838,15 +838,15 @@ static int hostfs_setattr(struct dentry *dentry, struct iattr *attr)
        }
        if (attr->ia_valid & ATTR_ATIME) {
                attrs.ia_valid |= HOSTFS_ATTR_ATIME;
-               attrs.ia_atime = attr->ia_atime;
+               attrs.ia_atime = timespec64_to_timespec(attr->ia_atime);
        }
        if (attr->ia_valid & ATTR_MTIME) {
                attrs.ia_valid |= HOSTFS_ATTR_MTIME;
-               attrs.ia_mtime = attr->ia_mtime;
+               attrs.ia_mtime = timespec64_to_timespec(attr->ia_mtime);
        }
        if (attr->ia_valid & ATTR_CTIME) {
                attrs.ia_valid |= HOSTFS_ATTR_CTIME;
-               attrs.ia_ctime = attr->ia_ctime;
+               attrs.ia_ctime = timespec64_to_timespec(attr->ia_ctime);
        }
        if (attr->ia_valid & ATTR_ATIME_SET) {
                attrs.ia_valid |= HOSTFS_ATTR_ATIME_SET;
index a4ad18afbdec7ffba2eb5cd46c59879433ba6da9..4ada525c5c43781aeb5060455c01d5c2511fd368 100644 (file)
@@ -33,7 +33,8 @@ int hpfs_add_pos(struct inode *inode, loff_t *pos)
                        if (hpfs_inode->i_rddir_off[i] == pos)
                                return 0;
        if (!(i&0x0f)) {
-               if (!(ppos = kmalloc((i+0x11) * sizeof(loff_t*), GFP_NOFS))) {
+               ppos = kmalloc_array(i + 0x11, sizeof(loff_t *), GFP_NOFS);
+               if (!ppos) {
                        pr_err("out of memory for position list\n");
                        return -ENOMEM;
                }
index 7c49f1ef0c850320b351397e0c1f2d93f267131a..ecd9fccd166316b10f54f2919cee01762b0cfbfd 100644 (file)
@@ -115,7 +115,7 @@ __le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp)
        int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21;
        int i;
        __le32 *b;
-       if (!(b = kmalloc(n * 512, GFP_KERNEL))) {
+       if (!(b = kmalloc_array(n, 512, GFP_KERNEL))) {
                pr_err("can't allocate memory for bitmap directory\n");
                return NULL;
        }       
index 0df41bb77e0f426bde8901b3124071bf89701da0..2c300e98179607ea0062a2c1dbcee17e9bc926c4 100644 (file)
@@ -1577,8 +1577,8 @@ static void update_ovl_inode_times(struct dentry *dentry, struct inode *inode,
        if (upperdentry) {
                struct inode *realinode = d_inode(upperdentry);
 
-               if ((!timespec_equal(&inode->i_mtime, &realinode->i_mtime) ||
-                    !timespec_equal(&inode->i_ctime, &realinode->i_ctime))) {
+               if ((!timespec64_equal(&inode->i_mtime, &realinode->i_mtime) ||
+                    !timespec64_equal(&inode->i_ctime, &realinode->i_ctime))) {
                        inode->i_mtime = realinode->i_mtime;
                        inode->i_ctime = realinode->i_ctime;
                }
@@ -1601,12 +1601,12 @@ static int relatime_need_update(const struct path *path, struct inode *inode,
        /*
         * Is mtime younger than atime? If yes, update atime:
         */
-       if (timespec_compare(&inode->i_mtime, &inode->i_atime) >= 0)
+       if (timespec64_compare(&inode->i_mtime, &inode->i_atime) >= 0)
                return 1;
        /*
         * Is ctime younger than atime? If yes, update atime:
         */
-       if (timespec_compare(&inode->i_ctime, &inode->i_atime) >= 0)
+       if (timespec64_compare(&inode->i_ctime, &inode->i_atime) >= 0)
                return 1;
 
        /*
@@ -1621,7 +1621,7 @@ static int relatime_need_update(const struct path *path, struct inode *inode,
        return 0;
 }
 
-int generic_update_time(struct inode *inode, struct timespec *time, int flags)
+int generic_update_time(struct inode *inode, struct timespec64 *time, int flags)
 {
        int iflags = I_DIRTY_TIME;
        bool dirty = false;
@@ -1649,9 +1649,9 @@ EXPORT_SYMBOL(generic_update_time);
  * This does the actual work of updating an inodes time or version.  Must have
  * had called mnt_want_write() before calling this.
  */
-static int update_time(struct inode *inode, struct timespec *time, int flags)
+static int update_time(struct inode *inode, struct timespec64 *time, int flags)
 {
-       int (*update_time)(struct inode *, struct timespec *, int);
+       int (*update_time)(struct inode *, struct timespec64 *, int);
 
        update_time = inode->i_op->update_time ? inode->i_op->update_time :
                generic_update_time;
@@ -1672,7 +1672,7 @@ bool __atime_needs_update(const struct path *path, struct inode *inode,
                          bool rcu)
 {
        struct vfsmount *mnt = path->mnt;
-       struct timespec now;
+       struct timespec64 now;
 
        if (inode->i_flags & S_NOATIME)
                return false;
@@ -1695,10 +1695,10 @@ bool __atime_needs_update(const struct path *path, struct inode *inode,
 
        now = current_time(inode);
 
-       if (!relatime_need_update(path, inode, now, rcu))
+       if (!relatime_need_update(path, inode, timespec64_to_timespec(now), rcu))
                return false;
 
-       if (timespec_equal(&inode->i_atime, &now))
+       if (timespec64_equal(&inode->i_atime, &now))
                return false;
 
        return true;
@@ -1708,7 +1708,7 @@ void touch_atime(const struct path *path)
 {
        struct vfsmount *mnt = path->mnt;
        struct inode *inode = d_inode(path->dentry);
-       struct timespec now;
+       struct timespec64 now;
 
        if (!__atime_needs_update(path, inode, false))
                return;
@@ -1842,7 +1842,7 @@ EXPORT_SYMBOL(file_remove_privs);
 int file_update_time(struct file *file)
 {
        struct inode *inode = file_inode(file);
-       struct timespec now;
+       struct timespec64 now;
        int sync_it = 0;
        int ret;
 
@@ -1851,10 +1851,10 @@ int file_update_time(struct file *file)
                return 0;
 
        now = current_time(inode);
-       if (!timespec_equal(&inode->i_mtime, &now))
+       if (!timespec64_equal(&inode->i_mtime, &now))
                sync_it = S_MTIME;
 
-       if (!timespec_equal(&inode->i_ctime, &now))
+       if (!timespec64_equal(&inode->i_ctime, &now))
                sync_it |= S_CTIME;
 
        if (IS_I_VERSION(inode) && inode_iversion_need_inc(inode))
@@ -2097,6 +2097,30 @@ void inode_nohighmem(struct inode *inode)
 }
 EXPORT_SYMBOL(inode_nohighmem);
 
+/**
+ * timespec64_trunc - Truncate timespec64 to a granularity
+ * @t: Timespec64
+ * @gran: Granularity in ns.
+ *
+ * Truncate a timespec64 to a granularity. Always rounds down. gran must
+ * not be 0 nor greater than a second (NSEC_PER_SEC, or 10^9 ns).
+ */
+struct timespec64 timespec64_trunc(struct timespec64 t, unsigned gran)
+{
+       /* Avoid division in the common cases 1 ns and 1 s. */
+       if (gran == 1) {
+               /* nothing */
+       } else if (gran == NSEC_PER_SEC) {
+               t.tv_nsec = 0;
+       } else if (gran > 1 && gran < NSEC_PER_SEC) {
+               t.tv_nsec -= t.tv_nsec % gran;
+       } else {
+               WARN(1, "illegal file time granularity: %u", gran);
+       }
+       return t;
+}
+EXPORT_SYMBOL(timespec64_trunc);
+
 /**
  * current_time - Return FS time
  * @inode: inode.
@@ -2107,15 +2131,15 @@ EXPORT_SYMBOL(inode_nohighmem);
  * Note that inode and inode->sb cannot be NULL.
  * Otherwise, the function warns and returns time without truncation.
  */
-struct timespec current_time(struct inode *inode)
+struct timespec64 current_time(struct inode *inode)
 {
-       struct timespec now = current_kernel_time();
+       struct timespec64 now = current_kernel_time64();
 
        if (unlikely(!inode->i_sb)) {
                WARN(1, "current_time() called with uninitialized super_block in the inode");
                return now;
        }
 
-       return timespec_trunc(now, inode->i_sb->s_time_gran);
+       return timespec64_trunc(now, inode->i_sb->s_time_gran);
 }
 EXPORT_SYMBOL(current_time);
index 7d1e9f45f098c76647914d6bc4a9033e653ae20f..77397b5a96ef9c8f90a8e2b9c7afb50afdbae025 100644 (file)
@@ -1388,7 +1388,11 @@ int iomap_swapfile_activate(struct swap_info_struct *sis,
        loff_t len = ALIGN_DOWN(i_size_read(inode), PAGE_SIZE);
        loff_t ret;
 
-       ret = filemap_write_and_wait(inode->i_mapping);
+       /*
+        * Persist all file mapping metadata so that we won't have any
+        * IOMAP_F_DIRTY iomaps.
+        */
+       ret = vfs_fsync(swap_file, 1);
        if (ret)
                return ret;
 
index 240779e4689c53f0705615ee4d39d2096f9854b0..a1143e57a718ee20c83b0c813fb13425beff2d16 100644 (file)
@@ -223,7 +223,7 @@ static struct jbd2_revoke_table_s *jbd2_journal_init_revoke_table(int hash_size)
        table->hash_size = hash_size;
        table->hash_shift = shift;
        table->hash_table =
-               kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
+               kmalloc_array(hash_size, sizeof(struct list_head), GFP_KERNEL);
        if (!table->hash_table) {
                kmem_cache_free(jbd2_revoke_table_cache, table);
                table = NULL;
index 7ebacf14837fd8ed1d47d1eec3f753e546de22bc..093ffbd823958e900fbebfafe53cba2de13c7fa0 100644 (file)
@@ -133,7 +133,8 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size)
        size_t i;
 
        *size = jffs2_acl_size(acl->a_count);
-       header = kmalloc(sizeof(*header) + acl->a_count * sizeof(*entry), GFP_KERNEL);
+       header = kmalloc(struct_size(header, a_entries, acl->a_count),
+                       GFP_KERNEL);
        if (!header)
                return ERR_PTR(-ENOMEM);
        header->a_version = cpu_to_je32(JFFS2_ACL_VERSION);
index 2e2b5745c3b75d42caea23256ccc4bfc6dacb039..12d0271bdde387cf07e7a6a3853b4a7c9d3861f1 100644 (file)
@@ -22,6 +22,7 @@ struct jffs2_acl_entry_short {
 
 struct jffs2_acl_header {
        jint32_t        a_version;
+       struct jffs2_acl_entry  a_entries[];
 };
 
 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
index e5a6deb38e1e1be47803250b3de5d115ce5c7e88..b2944f9218f79df0e1b43b3342cf17657784c4d5 100644 (file)
@@ -201,7 +201,7 @@ static int jffs2_create(struct inode *dir_i, struct dentry *dentry,
        if (ret)
                goto fail;
 
-       dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(ri->ctime));
+       dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->ctime)));
 
        jffs2_free_raw_inode(ri);
 
@@ -234,7 +234,7 @@ static int jffs2_unlink(struct inode *dir_i, struct dentry *dentry)
        if (dead_f->inocache)
                set_nlink(d_inode(dentry), dead_f->inocache->pino_nlink);
        if (!ret)
-               dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
+               dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(now));
        return ret;
 }
 /***********************************************************************/
@@ -268,7 +268,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
                set_nlink(d_inode(old_dentry), ++f->inocache->pino_nlink);
                mutex_unlock(&f->sem);
                d_instantiate(dentry, d_inode(old_dentry));
-               dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
+               dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(now));
                ihold(d_inode(old_dentry));
        }
        return ret;
@@ -418,7 +418,7 @@ static int jffs2_symlink (struct inode *dir_i, struct dentry *dentry, const char
                goto fail;
        }
 
-       dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
+       dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(rd->mctime)));
 
        jffs2_free_raw_dirent(rd);
 
@@ -561,7 +561,7 @@ static int jffs2_mkdir (struct inode *dir_i, struct dentry *dentry, umode_t mode
                goto fail;
        }
 
-       dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
+       dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(rd->mctime)));
        inc_nlink(dir_i);
 
        jffs2_free_raw_dirent(rd);
@@ -598,7 +598,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
        ret = jffs2_do_unlink(c, dir_f, dentry->d_name.name,
                              dentry->d_name.len, f, now);
        if (!ret) {
-               dir_i->i_mtime = dir_i->i_ctime = ITIME(now);
+               dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(now));
                clear_nlink(d_inode(dentry));
                drop_nlink(dir_i);
        }
@@ -733,7 +733,7 @@ static int jffs2_mknod (struct inode *dir_i, struct dentry *dentry, umode_t mode
                goto fail;
        }
 
-       dir_i->i_mtime = dir_i->i_ctime = ITIME(je32_to_cpu(rd->mctime));
+       dir_i->i_mtime = dir_i->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(rd->mctime)));
 
        jffs2_free_raw_dirent(rd);
 
@@ -853,14 +853,14 @@ static int jffs2_rename (struct inode *old_dir_i, struct dentry *old_dentry,
                 * 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);
+               new_dir_i->i_mtime = new_dir_i->i_ctime = timespec_to_timespec64(ITIME(now));
                return ret;
        }
 
        if (d_is_dir(old_dentry))
                drop_nlink(old_dir_i);
 
-       new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = ITIME(now);
+       new_dir_i->i_mtime = new_dir_i->i_ctime = old_dir_i->i_mtime = old_dir_i->i_ctime = timespec_to_timespec64(ITIME(now));
 
        return 0;
 }
index bd0428bebe9b7787089135ddc4094800f86882a0..481afd4c2e1a4efef715b1bcd46f8e3962bb9aac 100644 (file)
@@ -308,7 +308,7 @@ static int jffs2_write_end(struct file *filp, struct address_space *mapping,
                        inode->i_size = pos + writtenlen;
                        inode->i_blocks = (inode->i_size + 511) >> 9;
 
-                       inode->i_ctime = inode->i_mtime = ITIME(je32_to_cpu(ri->ctime));
+                       inode->i_ctime = inode->i_mtime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->ctime)));
                }
        }
 
index eab04eca95a3f6accd533be6b0c36fe7a92c75f1..0ecfb8ea38cd2ee7328252010a48af4db4fd194c 100644 (file)
@@ -146,9 +146,9 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
                return PTR_ERR(new_metadata);
        }
        /* It worked. Update the inode */
-       inode->i_atime = ITIME(je32_to_cpu(ri->atime));
-       inode->i_ctime = ITIME(je32_to_cpu(ri->ctime));
-       inode->i_mtime = ITIME(je32_to_cpu(ri->mtime));
+       inode->i_atime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->atime)));
+       inode->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->ctime)));
+       inode->i_mtime = timespec_to_timespec64(ITIME(je32_to_cpu(ri->mtime)));
        inode->i_mode = jemode_to_cpu(ri->mode);
        i_uid_write(inode, je16_to_cpu(ri->uid));
        i_gid_write(inode, je16_to_cpu(ri->gid));
@@ -280,9 +280,9 @@ struct inode *jffs2_iget(struct super_block *sb, unsigned long ino)
        i_uid_write(inode, je16_to_cpu(latest_node.uid));
        i_gid_write(inode, je16_to_cpu(latest_node.gid));
        inode->i_size = je32_to_cpu(latest_node.isize);
-       inode->i_atime = ITIME(je32_to_cpu(latest_node.atime));
-       inode->i_mtime = ITIME(je32_to_cpu(latest_node.mtime));
-       inode->i_ctime = ITIME(je32_to_cpu(latest_node.ctime));
+       inode->i_atime = timespec_to_timespec64(ITIME(je32_to_cpu(latest_node.atime)));
+       inode->i_mtime = timespec_to_timespec64(ITIME(je32_to_cpu(latest_node.mtime)));
+       inode->i_ctime = timespec_to_timespec64(ITIME(je32_to_cpu(latest_node.ctime)));
 
        set_nlink(inode, f->inocache->pino_nlink);
 
index 2cfe487708e08f268c166053927eafec9c68eac6..c6821a5094818a48030697b95178241304905d28 100644 (file)
@@ -1208,7 +1208,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c)
        if (!c->wbuf)
                return -ENOMEM;
 
-       c->oobbuf = kmalloc(NR_OOB_SCAN_PAGES * c->oobavail, GFP_KERNEL);
+       c->oobbuf = kmalloc_array(NR_OOB_SCAN_PAGES, c->oobavail, GFP_KERNEL);
        if (!c->oobbuf) {
                kfree(c->wbuf);
                return -ENOMEM;
index 2d514c7affc2ab9382fa812bc173874f3b58b8e9..49263e220dbcf3add3b1cd624a1b8709af955c8e 100644 (file)
@@ -1641,7 +1641,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen)
        max_ranges = nblocks;
        do_div(max_ranges, minlen);
        range_cnt = min_t(u64, max_ranges + 1, 32 * 1024);
-       totrim = kmalloc(sizeof(struct range2trim) * range_cnt, GFP_NOFS);
+       totrim = kmalloc_array(range_cnt, sizeof(struct range2trim), GFP_NOFS);
        if (totrim == NULL) {
                jfs_error(bmp->db_ipbmap->i_sb, "no memory for trim array\n");
                IWRITE_UNLOCK(ipbmap);
index de2bcb36e0793915e28bd65e1c7e6f6b02514402..52bae3f5c9145df968a3803ee2f7cad0b5fe4bf7 100644 (file)
@@ -594,7 +594,8 @@ int dtSearch(struct inode *ip, struct component_name * key, ino_t * data,
        struct component_name ciKey;
        struct super_block *sb = ip->i_sb;
 
-       ciKey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), GFP_NOFS);
+       ciKey.name = kmalloc_array(JFS_NAME_MAX + 1, sizeof(wchar_t),
+                                  GFP_NOFS);
        if (!ciKey.name) {
                rc = -ENOMEM;
                goto dtSearch_Exit2;
@@ -957,7 +958,7 @@ static int dtSplitUp(tid_t tid,
        smp = split->mp;
        sp = DT_PAGE(ip, smp);
 
-       key.name = kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t), GFP_NOFS);
+       key.name = kmalloc_array(JFS_NAME_MAX + 2, sizeof(wchar_t), GFP_NOFS);
        if (!key.name) {
                DT_PUTPAGE(smp);
                rc = -ENOMEM;
@@ -3779,12 +3780,12 @@ static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp,
        struct component_name lkey;
        struct component_name rkey;
 
-       lkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
+       lkey.name = kmalloc_array(JFS_NAME_MAX + 1, sizeof(wchar_t),
                                        GFP_KERNEL);
        if (lkey.name == NULL)
                return -ENOMEM;
 
-       rkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
+       rkey.name = kmalloc_array(JFS_NAME_MAX + 1, sizeof(wchar_t),
                                        GFP_KERNEL);
        if (rkey.name == NULL) {
                kfree(lkey.name);
index c7de6f5bbefc1da43b269ffe54ddec707ba7b0a1..0148e2e4d97ac66e826ad5ddfb5cf32b20258468 100644 (file)
@@ -121,7 +121,7 @@ int get_UCSname(struct component_name * uniName, struct dentry *dentry)
                return -ENAMETOOLONG;
 
        uniName->name =
-           kmalloc((length + 1) * sizeof(wchar_t), GFP_NOFS);
+           kmalloc_array(length + 1, sizeof(wchar_t), GFP_NOFS);
 
        if (uniName->name == NULL)
                return -ENOMEM;
index 89d1dc19340b09d4d9cd9db44ae3dfc9413bea98..d66cc077730386e811679abcecbf7efebcdf11b4 100644 (file)
@@ -779,7 +779,7 @@ int kernfs_add_one(struct kernfs_node *kn)
        ps_iattr = parent->iattr;
        if (ps_iattr) {
                struct iattr *ps_iattrs = &ps_iattr->ia_iattr;
-               ktime_get_real_ts(&ps_iattrs->ia_ctime);
+               ktime_get_real_ts64(&ps_iattrs->ia_ctime);
                ps_iattrs->ia_mtime = ps_iattrs->ia_ctime;
        }
 
@@ -1306,7 +1306,7 @@ static void __kernfs_remove(struct kernfs_node *kn)
 
                        /* update timestamps on the parent */
                        if (ps_iattr) {
-                               ktime_get_real_ts(&ps_iattr->ia_iattr.ia_ctime);
+                               ktime_get_real_ts64(&ps_iattr->ia_iattr.ia_ctime);
                                ps_iattr->ia_iattr.ia_mtime =
                                        ps_iattr->ia_iattr.ia_ctime;
                        }
index a34303981deb2cac6d39996e767b9e738d3c81df..3d73fe9d56e235f51907eac11510aabae9fc3344 100644 (file)
@@ -52,7 +52,7 @@ static struct kernfs_iattrs *kernfs_iattrs(struct kernfs_node *kn)
        iattrs->ia_uid = GLOBAL_ROOT_UID;
        iattrs->ia_gid = GLOBAL_ROOT_GID;
 
-       ktime_get_real_ts(&iattrs->ia_atime);
+       ktime_get_real_ts64(&iattrs->ia_atime);
        iattrs->ia_mtime = iattrs->ia_atime;
        iattrs->ia_ctime = iattrs->ia_atime;
 
@@ -176,9 +176,9 @@ static inline void set_inode_attr(struct inode *inode, struct iattr *iattr)
        struct super_block *sb = inode->i_sb;
        inode->i_uid = iattr->ia_uid;
        inode->i_gid = iattr->ia_gid;
-       inode->i_atime = timespec_trunc(iattr->ia_atime, sb->s_time_gran);
-       inode->i_mtime = timespec_trunc(iattr->ia_mtime, sb->s_time_gran);
-       inode->i_ctime = timespec_trunc(iattr->ia_ctime, sb->s_time_gran);
+       inode->i_atime = timespec64_trunc(iattr->ia_atime, sb->s_time_gran);
+       inode->i_mtime = timespec64_trunc(iattr->ia_mtime, sb->s_time_gran);
+       inode->i_ctime = timespec64_trunc(iattr->ia_ctime, sb->s_time_gran);
 }
 
 static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
index 05e211be86840f065c604a75cf9a914d55726a38..db7b6917d9c52d52d981efca3eb36f17149a0712 100644 (file)
@@ -1562,7 +1562,7 @@ EXPORT_SYMBOL(__break_lease);
  * exclusive leases.  The justification is that if someone has an
  * exclusive lease, then they could be modifying it.
  */
-void lease_get_mtime(struct inode *inode, struct timespec *time)
+void lease_get_mtime(struct inode *inode, struct timespec64 *time)
 {
        bool has_lease = false;
        struct file_lock_context *ctx;
index bf41e2e72c1883b7fba884a8f7006ecc50bcf768..081ccf0caee35966477d8a2b801c19051fd2faf9 100644 (file)
@@ -353,8 +353,9 @@ struct mb_cache *mb_cache_create(int bucket_bits)
        cache->c_max_entries = bucket_count << 4;
        INIT_LIST_HEAD(&cache->c_list);
        spin_lock_init(&cache->c_list_lock);
-       cache->c_hash = kmalloc(bucket_count * sizeof(struct hlist_bl_head),
-                               GFP_KERNEL);
+       cache->c_hash = kmalloc_array(bucket_count,
+                                     sizeof(struct hlist_bl_head),
+                                     GFP_KERNEL);
        if (!cache->c_hash) {
                kfree(cache);
                goto err_out;
index 6df1f61855d600a7072b2b770e993118cc5ac036..734cef54fdf8b0cc3c4136dc3b11f6e07c5952e2 100644 (file)
@@ -537,12 +537,12 @@ static int __nd_alloc_stack(struct nameidata *nd)
        struct saved *p;
 
        if (nd->flags & LOOKUP_RCU) {
-               p= kmalloc(MAXSYMLINKS * sizeof(struct saved),
+               p= kmalloc_array(MAXSYMLINKS, sizeof(struct saved),
                                  GFP_ATOMIC);
                if (unlikely(!p))
                        return -ECHILD;
        } else {
-               p= kmalloc(MAXSYMLINKS * sizeof(struct saved),
+               p= kmalloc_array(MAXSYMLINKS, sizeof(struct saved),
                                  GFP_KERNEL);
                if (unlikely(!p))
                        return -ENOMEM;
@@ -2463,6 +2463,35 @@ static int lookup_one_len_common(const char *name, struct dentry *base,
        return inode_permission(base->d_inode, MAY_EXEC);
 }
 
+/**
+ * try_lookup_one_len - filesystem helper to lookup single pathname component
+ * @name:      pathname component to lookup
+ * @base:      base directory to lookup from
+ * @len:       maximum length @len should be interpreted to
+ *
+ * Look up a dentry by name in the dcache, returning NULL if it does not
+ * currently exist.  The function does not try to create a dentry.
+ *
+ * Note that this routine is purely a helper for filesystem usage and should
+ * not be called by generic code.
+ *
+ * The caller must hold base->i_mutex.
+ */
+struct dentry *try_lookup_one_len(const char *name, struct dentry *base, int len)
+{
+       struct qstr this;
+       int err;
+
+       WARN_ON_ONCE(!inode_is_locked(base->d_inode));
+
+       err = lookup_one_len_common(name, base, len, &this);
+       if (err)
+               return ERR_PTR(err);
+
+       return lookup_dcache(&this, base, 0);
+}
+EXPORT_SYMBOL(try_lookup_one_len);
+
 /**
  * lookup_one_len - filesystem helper to lookup single pathname component
  * @name:      pathname component to lookup
index a50d7813e3ea8dd03dd7c5e02b36574be815ad8b..64c214fb9da67d5ba0ce6fb732a6c3df963823cf 100644 (file)
@@ -40,7 +40,9 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
                rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
 
        inode = nfs_delegation_find_inode(cps->clp, &args->fh);
-       if (inode == NULL) {
+       if (IS_ERR(inode)) {
+               if (inode == ERR_PTR(-EAGAIN))
+                       res->status = htonl(NFS4ERR_DELAY);
                trace_nfs4_cb_getattr(cps->clp, &args->fh, NULL,
                                -ntohl(res->status));
                goto out;
@@ -54,8 +56,8 @@ __be32 nfs4_callback_getattr(void *argp, void *resp,
        res->change_attr = delegation->change_attr;
        if (nfs_have_writebacks(inode))
                res->change_attr++;
-       res->ctime = inode->i_ctime;
-       res->mtime = inode->i_mtime;
+       res->ctime = timespec64_to_timespec(inode->i_ctime);
+       res->mtime = timespec64_to_timespec(inode->i_mtime);
        res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) &
                args->bitmap[0];
        res->bitmap[1] = (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) &
@@ -86,7 +88,9 @@ __be32 nfs4_callback_recall(void *argp, void *resp,
 
        res = htonl(NFS4ERR_BADHANDLE);
        inode = nfs_delegation_find_inode(cps->clp, &args->fh);
-       if (inode == NULL) {
+       if (IS_ERR(inode)) {
+               if (inode == ERR_PTR(-EAGAIN))
+                       res = htonl(NFS4ERR_DELAY);
                trace_nfs4_cb_recall(cps->clp, &args->fh, NULL,
                                &args->stateid, -ntohl(res));
                goto out;
@@ -124,7 +128,6 @@ static struct inode *nfs_layout_find_inode_by_stateid(struct nfs_client *clp,
        struct inode *inode;
        struct pnfs_layout_hdr *lo;
 
-restart:
        list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
                list_for_each_entry(lo, &server->layouts, plh_layouts) {
                        if (stateid != NULL &&
@@ -132,20 +135,20 @@ static struct inode *nfs_layout_find_inode_by_stateid(struct nfs_client *clp,
                                continue;
                        inode = igrab(lo->plh_inode);
                        if (!inode)
-                               continue;
+                               return ERR_PTR(-EAGAIN);
                        if (!nfs_sb_active(inode->i_sb)) {
                                rcu_read_unlock();
                                spin_unlock(&clp->cl_lock);
                                iput(inode);
                                spin_lock(&clp->cl_lock);
                                rcu_read_lock();
-                               goto restart;
+                               return ERR_PTR(-EAGAIN);
                        }
                        return inode;
                }
        }
 
-       return NULL;
+       return ERR_PTR(-ENOENT);
 }
 
 /*
@@ -162,7 +165,6 @@ static struct inode *nfs_layout_find_inode_by_fh(struct nfs_client *clp,
        struct inode *inode;
        struct pnfs_layout_hdr *lo;
 
-restart:
        list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
                list_for_each_entry(lo, &server->layouts, plh_layouts) {
                        nfsi = NFS_I(lo->plh_inode);
@@ -172,20 +174,20 @@ static struct inode *nfs_layout_find_inode_by_fh(struct nfs_client *clp,
                                continue;
                        inode = igrab(lo->plh_inode);
                        if (!inode)
-                               continue;
+                               return ERR_PTR(-EAGAIN);
                        if (!nfs_sb_active(inode->i_sb)) {
                                rcu_read_unlock();
                                spin_unlock(&clp->cl_lock);
                                iput(inode);
                                spin_lock(&clp->cl_lock);
                                rcu_read_lock();
-                               goto restart;
+                               return ERR_PTR(-EAGAIN);
                        }
                        return inode;
                }
        }
 
-       return NULL;
+       return ERR_PTR(-ENOENT);
 }
 
 static struct inode *nfs_layout_find_inode(struct nfs_client *clp,
@@ -197,7 +199,7 @@ static struct inode *nfs_layout_find_inode(struct nfs_client *clp,
        spin_lock(&clp->cl_lock);
        rcu_read_lock();
        inode = nfs_layout_find_inode_by_stateid(clp, stateid);
-       if (!inode)
+       if (inode == ERR_PTR(-ENOENT))
                inode = nfs_layout_find_inode_by_fh(clp, fh);
        rcu_read_unlock();
        spin_unlock(&clp->cl_lock);
@@ -252,8 +254,11 @@ static u32 initiate_file_draining(struct nfs_client *clp,
        LIST_HEAD(free_me_list);
 
        ino = nfs_layout_find_inode(clp, &args->cbl_fh, &args->cbl_stateid);
-       if (!ino)
-               goto out;
+       if (IS_ERR(ino)) {
+               if (ino == ERR_PTR(-EAGAIN))
+                       rv = NFS4ERR_DELAY;
+               goto out_noput;
+       }
 
        pnfs_layoutcommit_inode(ino, false);
 
@@ -299,9 +304,10 @@ static u32 initiate_file_draining(struct nfs_client *clp,
        nfs_commit_inode(ino, 0);
        pnfs_put_layout_hdr(lo);
 out:
+       nfs_iput_and_deactive(ino);
+out_noput:
        trace_nfs4_cb_layoutrecall_file(clp, &args->cbl_fh, ino,
                        &args->cbl_stateid, -rv);
-       nfs_iput_and_deactive(ino);
        return rv;
 }
 
@@ -322,6 +328,8 @@ static u32 initiate_bulk_draining(struct nfs_client *clp,
 static u32 do_callback_layoutrecall(struct nfs_client *clp,
                                    struct cb_layoutrecallargs *args)
 {
+       write_seqcount_begin(&clp->cl_callback_count);
+       write_seqcount_end(&clp->cl_callback_count);
        if (args->cbl_recall_type == RETURN_FILE)
                return initiate_file_draining(clp, args);
        return initiate_bulk_draining(clp, args);
@@ -420,11 +428,8 @@ validate_seqid(const struct nfs4_slot_table *tbl, const struct nfs4_slot *slot,
                return htonl(NFS4ERR_SEQ_FALSE_RETRY);
        }
 
-       /* Wraparound */
-       if (unlikely(slot->seq_nr == 0xFFFFFFFFU)) {
-               if (args->csa_sequenceid == 1)
-                       return htonl(NFS4_OK);
-       } else if (likely(args->csa_sequenceid == slot->seq_nr + 1))
+       /* Note: wraparound relies on seq_nr being of type u32 */
+       if (likely(args->csa_sequenceid == slot->seq_nr + 1))
                return htonl(NFS4_OK);
 
        /* Misordered request */
index bbc91d7ca1bd43db7335f1dd8afe4182dd319ecf..377a61654a887401da3a97b942599eb494dbf3d6 100644 (file)
@@ -969,7 +969,8 @@ struct nfs_server *nfs_create_server(struct nfs_mount_info *mount_info,
        }
 
        if (!(fattr->valid & NFS_ATTR_FATTR)) {
-               error = nfs_mod->rpc_ops->getattr(server, mount_info->mntfh, fattr, NULL);
+               error = nfs_mod->rpc_ops->getattr(server, mount_info->mntfh,
+                               fattr, NULL, NULL);
                if (error < 0) {
                        dprintk("nfs_create_server: getattr error = %d\n", -error);
                        goto error;
index 1819d0d0ba4b14b92ad311ae2cf588f7f1ecb6a2..bbd0465535ebd9e433a812d60ab345161ef736b3 100644 (file)
@@ -404,6 +404,10 @@ int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred,
 
        trace_nfs4_set_delegation(inode, type);
 
+       spin_lock(&inode->i_lock);
+       if (NFS_I(inode)->cache_validity & (NFS_INO_INVALID_ATTR|NFS_INO_INVALID_ATIME))
+               NFS_I(inode)->cache_validity |= NFS_INO_REVAL_FORCED;
+       spin_unlock(&inode->i_lock);
 out:
        spin_unlock(&clp->cl_lock);
        if (delegation != NULL)
@@ -483,38 +487,88 @@ static bool nfs_delegation_need_return(struct nfs_delegation *delegation)
 int nfs_client_return_marked_delegations(struct nfs_client *clp)
 {
        struct nfs_delegation *delegation;
+       struct nfs_delegation *prev;
        struct nfs_server *server;
        struct inode *inode;
+       struct inode *place_holder = NULL;
+       struct nfs_delegation *place_holder_deleg = NULL;
        int err = 0;
 
 restart:
+       /*
+        * To avoid quadratic looping we hold a reference
+        * to an inode place_holder.  Each time we restart, we
+        * list nfs_servers from the server of that inode, and
+        * delegation in the server from the delegations of that
+        * inode.
+        * prev is an RCU-protected pointer to a delegation which
+        * wasn't marked for return and might be a good choice for
+        * the next place_holder.
+        */
        rcu_read_lock();
-       list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
-               list_for_each_entry_rcu(delegation, &server->delegations,
-                                                               super_list) {
-                       if (!nfs_delegation_need_return(delegation))
+       prev = NULL;
+       if (place_holder)
+               server = NFS_SERVER(place_holder);
+       else
+               server = list_entry_rcu(clp->cl_superblocks.next,
+                                       struct nfs_server, client_link);
+       list_for_each_entry_from_rcu(server, &clp->cl_superblocks, client_link) {
+               delegation = NULL;
+               if (place_holder && server == NFS_SERVER(place_holder))
+                       delegation = rcu_dereference(NFS_I(place_holder)->delegation);
+               if (!delegation || delegation != place_holder_deleg)
+                       delegation = list_entry_rcu(server->delegations.next,
+                                                   struct nfs_delegation, super_list);
+               list_for_each_entry_from_rcu(delegation, &server->delegations, super_list) {
+                       struct inode *to_put = NULL;
+
+                       if (!nfs_delegation_need_return(delegation)) {
+                               prev = delegation;
                                continue;
+                       }
                        if (!nfs_sb_active(server->super))
-                               continue;
+                               break; /* continue in outer loop */
+
+                       if (prev) {
+                               struct inode *tmp;
+
+                               tmp = nfs_delegation_grab_inode(prev);
+                               if (tmp) {
+                                       to_put = place_holder;
+                                       place_holder = tmp;
+                                       place_holder_deleg = prev;
+                               }
+                       }
+
                        inode = nfs_delegation_grab_inode(delegation);
                        if (inode == NULL) {
                                rcu_read_unlock();
+                               if (to_put)
+                                       iput(to_put);
                                nfs_sb_deactive(server->super);
                                goto restart;
                        }
                        delegation = nfs_start_delegation_return_locked(NFS_I(inode));
                        rcu_read_unlock();
 
+                       if (to_put)
+                               iput(to_put);
+
                        err = nfs_end_delegation_return(inode, delegation, 0);
                        iput(inode);
                        nfs_sb_deactive(server->super);
+                       cond_resched();
                        if (!err)
                                goto restart;
                        set_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state);
+                       if (place_holder)
+                               iput(place_holder);
                        return err;
                }
        }
        rcu_read_unlock();
+       if (place_holder)
+               iput(place_holder);
        return 0;
 }
 
@@ -802,12 +856,14 @@ nfs_delegation_find_inode_server(struct nfs_server *server,
                if (delegation->inode != NULL &&
                    nfs_compare_fh(fhandle, &NFS_I(delegation->inode)->fh) == 0) {
                        res = igrab(delegation->inode);
+                       spin_unlock(&delegation->lock);
+                       if (res != NULL)
+                               return res;
+                       return ERR_PTR(-EAGAIN);
                }
                spin_unlock(&delegation->lock);
-               if (res != NULL)
-                       break;
        }
-       return res;
+       return ERR_PTR(-ENOENT);
 }
 
 /**
@@ -822,16 +878,16 @@ struct inode *nfs_delegation_find_inode(struct nfs_client *clp,
                                        const struct nfs_fh *fhandle)
 {
        struct nfs_server *server;
-       struct inode *res = NULL;
+       struct inode *res;
 
        rcu_read_lock();
        list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) {
                res = nfs_delegation_find_inode_server(server, fhandle);
-               if (res != NULL)
-                       break;
+               if (res != ERR_PTR(-ENOENT))
+                       return res;
        }
        rcu_read_unlock();
-       return res;
+       return ERR_PTR(-ENOENT);
 }
 
 static void nfs_delegation_mark_reclaim_server(struct nfs_server *server)
@@ -887,7 +943,7 @@ void nfs_delegation_reap_unclaimed(struct nfs_client *clp)
                                                &delegation->flags) == 0)
                                continue;
                        if (!nfs_sb_active(server->super))
-                               continue;
+                               break; /* continue in outer loop */
                        inode = nfs_delegation_grab_inode(delegation);
                        if (inode == NULL) {
                                rcu_read_unlock();
@@ -904,6 +960,7 @@ void nfs_delegation_reap_unclaimed(struct nfs_client *clp)
                        }
                        iput(inode);
                        nfs_sb_deactive(server->super);
+                       cond_resched();
                        goto restart;
                }
        }
@@ -995,7 +1052,7 @@ void nfs_reap_expired_delegations(struct nfs_client *clp)
                                                &delegation->flags) == 0)
                                continue;
                        if (!nfs_sb_active(server->super))
-                               continue;
+                               break; /* continue in outer loop */
                        inode = nfs_delegation_grab_inode(delegation);
                        if (inode == NULL) {
                                rcu_read_unlock();
@@ -1020,6 +1077,7 @@ void nfs_reap_expired_delegations(struct nfs_client *clp)
                        }
                        iput(inode);
                        nfs_sb_deactive(server->super);
+                       cond_resched();
                        goto restart;
                }
        }
index 73f8b43d988cfa2f7b3366b1147dc296b55802ef..7a9c14426855309d2bb68e681b2db32321648d0c 100644 (file)
@@ -1012,13 +1012,25 @@ int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags)
 
        if (IS_AUTOMOUNT(inode))
                return 0;
+
+       if (flags & LOOKUP_OPEN) {
+               switch (inode->i_mode & S_IFMT) {
+               case S_IFREG:
+                       /* A NFSv4 OPEN will revalidate later */
+                       if (server->caps & NFS_CAP_ATOMIC_OPEN)
+                               goto out;
+                       /* Fallthrough */
+               case S_IFDIR:
+                       if (server->flags & NFS_MOUNT_NOCTO)
+                               break;
+                       /* NFS close-to-open cache consistency validation */
+                       goto out_force;
+               }
+       }
+
        /* VFS wants an on-the-wire revalidation */
        if (flags & LOOKUP_REVAL)
                goto out_force;
-       /* This is an open(2) */
-       if ((flags & LOOKUP_OPEN) && !(server->flags & NFS_MOUNT_NOCTO) &&
-           (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
-               goto out_force;
 out:
        return (inode->i_nlink == 0) ? -ENOENT : 0;
 out_force:
@@ -1039,13 +1051,15 @@ int nfs_lookup_verify_inode(struct inode *inode, unsigned int flags)
  *
  * If LOOKUP_RCU prevents us from performing a full check, return 1
  * suggesting a reval is needed.
+ *
+ * Note that when creating a new file, or looking up a rename target,
+ * then it shouldn't be necessary to revalidate a negative dentry.
  */
 static inline
 int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry,
                       unsigned int flags)
 {
-       /* Don't revalidate a negative dentry if we're creating a new file */
-       if (flags & LOOKUP_CREATE)
+       if (flags & (LOOKUP_CREATE | LOOKUP_RENAME_TARGET))
                return 0;
        if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG)
                return 1;
@@ -1106,7 +1120,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
                goto out_set_verifier;
 
        /* Force a full look up iff the parent directory has changed */
-       if (!nfs_is_exclusive_create(dir, flags) &&
+       if (!(flags & (LOOKUP_EXCL | LOOKUP_REVAL)) &&
            nfs_check_verifier(dir, dentry, flags & LOOKUP_RCU)) {
                error = nfs_lookup_verify_inode(inode, flags);
                if (error) {
@@ -1270,11 +1284,13 @@ static void nfs_drop_nlink(struct inode *inode)
 {
        spin_lock(&inode->i_lock);
        /* drop the inode if we're reasonably sure this is the last link */
-       if (inode->i_nlink == 1)
-               clear_nlink(inode);
+       if (inode->i_nlink > 0)
+               drop_nlink(inode);
+       NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
        NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
                | NFS_INO_INVALID_CTIME
-               | NFS_INO_INVALID_OTHER;
+               | NFS_INO_INVALID_OTHER
+               | NFS_INO_REVAL_FORCED;
        spin_unlock(&inode->i_lock);
 }
 
@@ -1335,7 +1351,7 @@ struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned in
         * If we're doing an exclusive create, optimize away the lookup
         * but don't hash the dentry.
         */
-       if (nfs_is_exclusive_create(dir, flags))
+       if (nfs_is_exclusive_create(dir, flags) || flags & LOOKUP_RENAME_TARGET)
                return NULL;
 
        res = ERR_PTR(-ENOMEM);
@@ -1640,7 +1656,8 @@ int nfs_instantiate(struct dentry *dentry, struct nfs_fh *fhandle,
        nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
        if (!(fattr->valid & NFS_ATTR_FATTR)) {
                struct nfs_server *server = NFS_SB(dentry->d_sb);
-               error = server->nfs_client->rpc_ops->getattr(server, fhandle, fattr, NULL);
+               error = server->nfs_client->rpc_ops->getattr(server, fhandle,
+                               fattr, NULL, NULL);
                if (error < 0)
                        goto out_error;
        }
@@ -2036,7 +2053,15 @@ int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        } else
                error = task->tk_status;
        rpc_put_task(task);
-       nfs_mark_for_revalidate(old_inode);
+       /* Ensure the inode attributes are revalidated */
+       if (error == 0) {
+               spin_lock(&old_inode->i_lock);
+               NFS_I(old_inode)->attr_gencount = nfs_inc_attr_generation_counter();
+               NFS_I(old_inode)->cache_validity |= NFS_INO_INVALID_CHANGE
+                       | NFS_INO_INVALID_CTIME
+                       | NFS_INO_REVAL_FORCED;
+               spin_unlock(&old_inode->i_lock);
+       }
 out:
        if (rehash)
                d_rehash(rehash);
index ab5de3246c5c34c3640a9464da8a6a87ece68d8e..deecb67638aa94d55a171529053dc7096a6a014c 100644 (file)
@@ -102,7 +102,7 @@ nfs_fh_to_dentry(struct super_block *sb, struct fid *fid,
        }
 
        rpc_ops = NFS_SB(sb)->nfs_client->rpc_ops;
-       ret = rpc_ops->getattr(NFS_SB(sb), server_fh, fattr, label);
+       ret = rpc_ops->getattr(NFS_SB(sb), server_fh, fattr, label, NULL);
        if (ret) {
                dprintk("%s: getattr failed %d\n", __func__, ret);
                dentry = ERR_PTR(ret);
index c75ad982bcfcc5989a7a3c6afda037599eb5952c..d4a07acad5989e1374f879f2cc46c284f9aa8c4f 100644 (file)
@@ -461,7 +461,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh,
                fh_count = be32_to_cpup(p);
 
                fls->mirror_array[i]->fh_versions =
-                       kzalloc(fh_count * sizeof(struct nfs_fh),
+                       kcalloc(fh_count, sizeof(struct nfs_fh),
                                gfp_flags);
                if (fls->mirror_array[i]->fh_versions == NULL) {
                        rc = -ENOMEM;
@@ -2347,6 +2347,7 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = {
        .id                     = LAYOUT_FLEX_FILES,
        .name                   = "LAYOUT_FLEX_FILES",
        .owner                  = THIS_MODULE,
+       .flags                  = PNFS_LAYOUTGET_ON_OPEN,
        .set_layoutdriver       = ff_layout_set_layoutdriver,
        .alloc_layout_hdr       = ff_layout_alloc_layout_hdr,
        .free_layout_hdr        = ff_layout_free_layout_hdr,
index d62279d3fc5d311f5eacc6eb7618beac70159bf5..59aa04976331be3c7459785cae239fcd22bfd2b7 100644 (file)
@@ -99,7 +99,8 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
        version_count = be32_to_cpup(p);
        dprintk("%s: version count %d\n", __func__, version_count);
 
-       ds_versions = kzalloc(version_count * sizeof(struct nfs4_ff_ds_version),
+       ds_versions = kcalloc(version_count,
+                             sizeof(struct nfs4_ff_ds_version),
                              gfp_flags);
        if (!ds_versions)
                goto out_scratch;
index 1c5d8d31fc0a9d823fa351b371713206d41dd63a..666415d13d5215c731bb1b2ab3e67e879b37c4ee 100644 (file)
@@ -88,8 +88,8 @@ enum fscache_checkaux nfs_fscache_inode_check_aux(void *cookie_netfs_data,
                return FSCACHE_CHECKAUX_OBSOLETE;
 
        memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime = nfsi->vfs_inode.i_mtime;
-       auxdata.ctime = nfsi->vfs_inode.i_ctime;
+       auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
+       auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
 
        if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
                auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
index b55fc7920c3b6a692affefebf75b6f43cedd9b01..4dc887813c71d312fe09df36ddbbd78a0b27024a 100644 (file)
@@ -237,8 +237,8 @@ void nfs_fscache_init_inode(struct inode *inode)
                return;
 
        memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime = nfsi->vfs_inode.i_mtime;
-       auxdata.ctime = nfsi->vfs_inode.i_ctime;
+       auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
+       auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
 
        if (NFS_SERVER(&nfsi->vfs_inode)->nfs_client->rpc_ops->version == 4)
                auxdata.change_attr = inode_peek_iversion_raw(&nfsi->vfs_inode);
@@ -262,8 +262,8 @@ void nfs_fscache_clear_inode(struct inode *inode)
        dfprintk(FSCACHE, "NFS: clear cookie (0x%p/0x%p)\n", nfsi, cookie);
 
        memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime = nfsi->vfs_inode.i_mtime;
-       auxdata.ctime = nfsi->vfs_inode.i_ctime;
+       auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
+       auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
        fscache_relinquish_cookie(cookie, &auxdata, false);
        nfsi->fscache = NULL;
 }
@@ -304,8 +304,8 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)
                return;
 
        memset(&auxdata, 0, sizeof(auxdata));
-       auxdata.mtime = nfsi->vfs_inode.i_mtime;
-       auxdata.ctime = nfsi->vfs_inode.i_ctime;
+       auxdata.mtime = timespec64_to_timespec(nfsi->vfs_inode.i_mtime);
+       auxdata.ctime = timespec64_to_timespec(nfsi->vfs_inode.i_ctime);
 
        if (inode_is_open_for_write(inode)) {
                dfprintk(FSCACHE, "NFS: nfsi 0x%p disabling cache\n", nfsi);
index bd15d0b5762665b4f50be2c7a07c513b6891c635..b65aee481d131d00734c057cd16f4532f2898211 100644 (file)
@@ -195,10 +195,16 @@ bool nfs_check_cache_invalid(struct inode *inode, unsigned long flags)
 static void nfs_set_cache_invalid(struct inode *inode, unsigned long flags)
 {
        struct nfs_inode *nfsi = NFS_I(inode);
-       bool have_delegation = nfs_have_delegated_attributes(inode);
+       bool have_delegation = NFS_PROTO(inode)->have_delegation(inode, FMODE_READ);
+
+       if (have_delegation) {
+               if (!(flags & NFS_INO_REVAL_FORCED))
+                       flags &= ~NFS_INO_INVALID_OTHER;
+               flags &= ~(NFS_INO_INVALID_CHANGE
+                               | NFS_INO_INVALID_SIZE
+                               | NFS_INO_REVAL_PAGECACHE);
+       }
 
-       if (have_delegation)
-               flags &= ~(NFS_INO_INVALID_CHANGE|NFS_INO_REVAL_PAGECACHE);
        if (inode->i_mapping->nrpages == 0)
                flags &= ~NFS_INO_INVALID_DATA;
        nfsi->cache_validity |= flags;
@@ -448,6 +454,7 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
                /* We can't support update_atime(), since the server will reset it */
                inode->i_flags |= S_NOATIME|S_NOCMTIME;
                inode->i_mode = fattr->mode;
+               nfsi->cache_validity = 0;
                if ((fattr->valid & NFS_ATTR_FATTR_MODE) == 0
                                && nfs_server_capable(inode, NFS_CAP_MODE))
                        nfs_set_cache_invalid(inode, NFS_INO_INVALID_OTHER);
@@ -494,15 +501,15 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
                nfsi->read_cache_jiffies = fattr->time_start;
                nfsi->attr_gencount = fattr->gencount;
                if (fattr->valid & NFS_ATTR_FATTR_ATIME)
-                       inode->i_atime = fattr->atime;
+                       inode->i_atime = timespec_to_timespec64(fattr->atime);
                else if (nfs_server_capable(inode, NFS_CAP_ATIME))
                        nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATIME);
                if (fattr->valid & NFS_ATTR_FATTR_MTIME)
-                       inode->i_mtime = fattr->mtime;
+                       inode->i_mtime = timespec_to_timespec64(fattr->mtime);
                else if (nfs_server_capable(inode, NFS_CAP_MTIME))
                        nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME);
                if (fattr->valid & NFS_ATTR_FATTR_CTIME)
-                       inode->i_ctime = fattr->ctime;
+                       inode->i_ctime = timespec_to_timespec64(fattr->ctime);
                else if (nfs_server_capable(inode, NFS_CAP_CTIME))
                        nfs_set_cache_invalid(inode, NFS_INO_INVALID_CTIME);
                if (fattr->valid & NFS_ATTR_FATTR_CHANGE)
@@ -534,6 +541,9 @@ nfs_fhget(struct super_block *sb, struct nfs_fh *fh, struct nfs_fattr *fattr, st
                        inode->i_blocks = nfs_calc_block_size(fattr->du.nfs3.used);
                }
 
+               if (nfsi->cache_validity != 0)
+                       nfsi->cache_validity |= NFS_INO_REVAL_FORCED;
+
                nfs_setsecurity(inode, fattr, label);
 
                nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
@@ -667,9 +677,13 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr,
 
        spin_lock(&inode->i_lock);
        NFS_I(inode)->attr_gencount = fattr->gencount;
-       nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
-                       | NFS_INO_INVALID_CTIME);
+       if ((attr->ia_valid & ATTR_SIZE) != 0) {
+               nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME);
+               nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC);
+               nfs_vmtruncate(inode, attr->ia_size);
+       }
        if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0) {
+               NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_CTIME;
                if ((attr->ia_valid & ATTR_MODE) != 0) {
                        int mode = attr->ia_mode & S_IALLUGO;
                        mode |= inode->i_mode & ~S_IALLUGO;
@@ -679,13 +693,45 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr,
                        inode->i_uid = attr->ia_uid;
                if ((attr->ia_valid & ATTR_GID) != 0)
                        inode->i_gid = attr->ia_gid;
+               if (fattr->valid & NFS_ATTR_FATTR_CTIME)
+                       inode->i_ctime = timespec_to_timespec64(fattr->ctime);
+               else
+                       nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
+                                       | NFS_INO_INVALID_CTIME);
                nfs_set_cache_invalid(inode, NFS_INO_INVALID_ACCESS
                                | NFS_INO_INVALID_ACL);
        }
-       if ((attr->ia_valid & ATTR_SIZE) != 0) {
-               nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME);
-               nfs_inc_stats(inode, NFSIOS_SETATTRTRUNC);
-               nfs_vmtruncate(inode, attr->ia_size);
+       if (attr->ia_valid & (ATTR_ATIME_SET|ATTR_ATIME)) {
+               NFS_I(inode)->cache_validity &= ~(NFS_INO_INVALID_ATIME
+                               | NFS_INO_INVALID_CTIME);
+               if (fattr->valid & NFS_ATTR_FATTR_ATIME)
+                       inode->i_atime = timespec_to_timespec64(fattr->atime);
+               else if (attr->ia_valid & ATTR_ATIME_SET)
+                       inode->i_atime = attr->ia_atime;
+               else
+                       nfs_set_cache_invalid(inode, NFS_INO_INVALID_ATIME);
+
+               if (fattr->valid & NFS_ATTR_FATTR_CTIME)
+                       inode->i_ctime = timespec_to_timespec64(fattr->ctime);
+               else
+                       nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
+                                       | NFS_INO_INVALID_CTIME);
+       }
+       if (attr->ia_valid & (ATTR_MTIME_SET|ATTR_MTIME)) {
+               NFS_I(inode)->cache_validity &= ~(NFS_INO_INVALID_MTIME
+                               | NFS_INO_INVALID_CTIME);
+               if (fattr->valid & NFS_ATTR_FATTR_MTIME)
+                       inode->i_mtime = timespec_to_timespec64(fattr->mtime);
+               else if (attr->ia_valid & ATTR_MTIME_SET)
+                       inode->i_mtime = attr->ia_mtime;
+               else
+                       nfs_set_cache_invalid(inode, NFS_INO_INVALID_MTIME);
+
+               if (fattr->valid & NFS_ATTR_FATTR_CTIME)
+                       inode->i_ctime = timespec_to_timespec64(fattr->ctime);
+               else
+                       nfs_set_cache_invalid(inode, NFS_INO_INVALID_CHANGE
+                                       | NFS_INO_INVALID_CTIME);
        }
        if (fattr->valid)
                nfs_update_inode(inode, fattr);
@@ -1097,7 +1143,8 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
                goto out;
        }
 
-       status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), fattr, label);
+       status = NFS_PROTO(inode)->getattr(server, NFS_FH(inode), fattr,
+                       label, inode);
        if (status != 0) {
                dfprintk(PAGECACHE, "nfs_revalidate_inode: (%s/%Lu) getattr failed, error=%d\n",
                         inode->i_sb->s_id,
@@ -1304,6 +1351,8 @@ static bool nfs_file_has_buffered_writers(struct nfs_inode *nfsi)
 
 static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 {
+       struct timespec ts;
+
        if ((fattr->valid & NFS_ATTR_FATTR_PRECHANGE)
                        && (fattr->valid & NFS_ATTR_FATTR_CHANGE)
                        && inode_eq_iversion_raw(inode, fattr->pre_change_attr)) {
@@ -1312,16 +1361,18 @@ static void nfs_wcc_update_inode(struct inode *inode, struct nfs_fattr *fattr)
                        nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA);
        }
        /* If we have atomic WCC data, we may update some attributes */
+       ts = timespec64_to_timespec(inode->i_ctime);
        if ((fattr->valid & NFS_ATTR_FATTR_PRECTIME)
                        && (fattr->valid & NFS_ATTR_FATTR_CTIME)
-                       && timespec_equal(&inode->i_ctime, &fattr->pre_ctime)) {
-               memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
+                       && timespec_equal(&ts, &fattr->pre_ctime)) {
+               inode->i_ctime = timespec_to_timespec64(fattr->ctime);
        }
 
+       ts = timespec64_to_timespec(inode->i_mtime);
        if ((fattr->valid & NFS_ATTR_FATTR_PREMTIME)
                        && (fattr->valid & NFS_ATTR_FATTR_MTIME)
-                       && timespec_equal(&inode->i_mtime, &fattr->pre_mtime)) {
-               memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime));
+                       && timespec_equal(&ts, &fattr->pre_mtime)) {
+               inode->i_mtime = timespec_to_timespec64(fattr->mtime);
                if (S_ISDIR(inode->i_mode))
                        nfs_set_cache_invalid(inode, NFS_INO_INVALID_DATA);
        }
@@ -1347,10 +1398,11 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
        struct nfs_inode *nfsi = NFS_I(inode);
        loff_t cur_size, new_isize;
        unsigned long invalid = 0;
+       struct timespec ts;
 
-
-       if (nfs_have_delegated_attributes(inode))
+       if (NFS_PROTO(inode)->have_delegation(inode, FMODE_READ))
                return 0;
+
        /* Has the inode gone and changed behind our back? */
        if ((fattr->valid & NFS_ATTR_FATTR_FILEID) && nfsi->fileid != fattr->fileid)
                return -ESTALE;
@@ -1363,10 +1415,12 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
                        invalid |= NFS_INO_INVALID_CHANGE
                                | NFS_INO_REVAL_PAGECACHE;
 
-               if ((fattr->valid & NFS_ATTR_FATTR_MTIME) && !timespec_equal(&inode->i_mtime, &fattr->mtime))
+               ts = timespec64_to_timespec(inode->i_mtime);
+               if ((fattr->valid & NFS_ATTR_FATTR_MTIME) && !timespec_equal(&ts, &fattr->mtime))
                        invalid |= NFS_INO_INVALID_MTIME;
 
-               if ((fattr->valid & NFS_ATTR_FATTR_CTIME) && !timespec_equal(&inode->i_ctime, &fattr->ctime))
+               ts = timespec64_to_timespec(inode->i_ctime);
+               if ((fattr->valid & NFS_ATTR_FATTR_CTIME) && !timespec_equal(&ts, &fattr->ctime))
                        invalid |= NFS_INO_INVALID_CTIME;
 
                if (fattr->valid & NFS_ATTR_FATTR_SIZE) {
@@ -1396,11 +1450,12 @@ static int nfs_check_inode_attributes(struct inode *inode, struct nfs_fattr *fat
        if ((fattr->valid & NFS_ATTR_FATTR_NLINK) && inode->i_nlink != fattr->nlink)
                invalid |= NFS_INO_INVALID_OTHER;
 
-       if ((fattr->valid & NFS_ATTR_FATTR_ATIME) && !timespec_equal(&inode->i_atime, &fattr->atime))
+       ts = timespec64_to_timespec(inode->i_atime);
+       if ((fattr->valid & NFS_ATTR_FATTR_ATIME) && !timespec_equal(&ts, &fattr->atime))
                invalid |= NFS_INO_INVALID_ATIME;
 
        if (invalid != 0)
-               nfs_set_cache_invalid(inode, invalid | NFS_INO_REVAL_FORCED);
+               nfs_set_cache_invalid(inode, invalid);
 
        nfsi->read_cache_jiffies = fattr->time_start;
        return 0;
@@ -1629,7 +1684,8 @@ int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        nfs_fattr_set_barrier(fattr);
        status = nfs_post_op_update_inode_locked(inode, fattr,
                        NFS_INO_INVALID_CHANGE
-                       | NFS_INO_INVALID_CTIME);
+                       | NFS_INO_INVALID_CTIME
+                       | NFS_INO_REVAL_FORCED);
        spin_unlock(&inode->i_lock);
 
        return status;
@@ -1667,12 +1723,12 @@ int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fa
        }
        if ((fattr->valid & NFS_ATTR_FATTR_CTIME) != 0 &&
                        (fattr->valid & NFS_ATTR_FATTR_PRECTIME) == 0) {
-               memcpy(&fattr->pre_ctime, &inode->i_ctime, sizeof(fattr->pre_ctime));
+               fattr->pre_ctime = timespec64_to_timespec(inode->i_ctime);
                fattr->valid |= NFS_ATTR_FATTR_PRECTIME;
        }
        if ((fattr->valid & NFS_ATTR_FATTR_MTIME) != 0 &&
                        (fattr->valid & NFS_ATTR_FATTR_PREMTIME) == 0) {
-               memcpy(&fattr->pre_mtime, &inode->i_mtime, sizeof(fattr->pre_mtime));
+               fattr->pre_mtime = timespec64_to_timespec(inode->i_mtime);
                fattr->valid |= NFS_ATTR_FATTR_PREMTIME;
        }
        if ((fattr->valid & NFS_ATTR_FATTR_SIZE) != 0 &&
@@ -1746,6 +1802,8 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        unsigned long save_cache_validity;
        bool have_writers = nfs_file_has_buffered_writers(nfsi);
        bool cache_revalidated = true;
+       bool attr_changed = false;
+       bool have_delegation;
 
        dfprintk(VFS, "NFS: %s(%s/%lu fh_crc=0x%08x ct=%d info=0x%x)\n",
                        __func__, inode->i_sb->s_id, inode->i_ino,
@@ -1780,6 +1838,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
                        !IS_AUTOMOUNT(inode))
                server->fsid = fattr->fsid;
 
+       /* Save the delegation state before clearing cache_validity */
+       have_delegation = nfs_have_delegated_attributes(inode);
+
        /*
         * Update the read time so we don't revalidate too often.
         */
@@ -1802,12 +1863,9 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        /* More cache consistency checks */
        if (fattr->valid & NFS_ATTR_FATTR_CHANGE) {
                if (!inode_eq_iversion_raw(inode, fattr->change_attr)) {
-                       dprintk("NFS: change_attr change on server for file %s/%ld\n",
-                                       inode->i_sb->s_id, inode->i_ino);
                        /* Could it be a race with writeback? */
-                       if (!have_writers) {
-                               invalid |= NFS_INO_INVALID_CHANGE
-                                       | NFS_INO_INVALID_DATA
+                       if (!(have_writers || have_delegation)) {
+                               invalid |= NFS_INO_INVALID_DATA
                                        | NFS_INO_INVALID_ACCESS
                                        | NFS_INO_INVALID_ACL;
                                /* Force revalidate of all attributes */
@@ -1817,8 +1875,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
                                        | NFS_INO_INVALID_OTHER;
                                if (S_ISDIR(inode->i_mode))
                                        nfs_force_lookup_revalidate(inode);
+                               dprintk("NFS: change_attr change on server for file %s/%ld\n",
+                                               inode->i_sb->s_id,
+                                               inode->i_ino);
                        }
                        inode_set_iversion_raw(inode, fattr->change_attr);
+                       attr_changed = true;
                }
        } else {
                nfsi->cache_validity |= save_cache_validity &
@@ -1829,7 +1891,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        }
 
        if (fattr->valid & NFS_ATTR_FATTR_MTIME) {
-               memcpy(&inode->i_mtime, &fattr->mtime, sizeof(inode->i_mtime));
+               inode->i_mtime = timespec_to_timespec64(fattr->mtime);
        } else if (server->caps & NFS_CAP_MTIME) {
                nfsi->cache_validity |= save_cache_validity &
                                (NFS_INO_INVALID_MTIME
@@ -1838,7 +1900,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        }
 
        if (fattr->valid & NFS_ATTR_FATTR_CTIME) {
-               memcpy(&inode->i_ctime, &fattr->ctime, sizeof(inode->i_ctime));
+               inode->i_ctime = timespec_to_timespec64(fattr->ctime);
        } else if (server->caps & NFS_CAP_CTIME) {
                nfsi->cache_validity |= save_cache_validity &
                                (NFS_INO_INVALID_CTIME
@@ -1850,13 +1912,14 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        if (fattr->valid & NFS_ATTR_FATTR_SIZE) {
                new_isize = nfs_size_to_loff_t(fattr->size);
                cur_isize = i_size_read(inode);
-               if (new_isize != cur_isize) {
+               if (new_isize != cur_isize && !have_delegation) {
                        /* Do we perhaps have any outstanding writes, or has
                         * the file grown beyond our last write? */
                        if (!nfs_have_writebacks(inode) || new_isize > cur_isize) {
                                i_size_write(inode, new_isize);
                                if (!have_writers)
                                        invalid |= NFS_INO_INVALID_DATA;
+                               attr_changed = true;
                        }
                        dprintk("NFS: isize change on server for file %s/%ld "
                                        "(%Ld to %Ld)\n",
@@ -1875,7 +1938,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 
 
        if (fattr->valid & NFS_ATTR_FATTR_ATIME)
-               memcpy(&inode->i_atime, &fattr->atime, sizeof(inode->i_atime));
+               inode->i_atime = timespec_to_timespec64(fattr->atime);
        else if (server->caps & NFS_CAP_ATIME) {
                nfsi->cache_validity |= save_cache_validity &
                                (NFS_INO_INVALID_ATIME
@@ -1889,14 +1952,12 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
                        newmode |= fattr->mode & S_IALLUGO;
                        inode->i_mode = newmode;
                        invalid |= NFS_INO_INVALID_ACCESS
-                               | NFS_INO_INVALID_ACL
-                               | NFS_INO_INVALID_OTHER;
+                               | NFS_INO_INVALID_ACL;
+                       attr_changed = true;
                }
        } else if (server->caps & NFS_CAP_MODE) {
                nfsi->cache_validity |= save_cache_validity &
-                               (NFS_INO_INVALID_ACCESS
-                               | NFS_INO_INVALID_ACL
-                               | NFS_INO_INVALID_OTHER
+                               (NFS_INO_INVALID_OTHER
                                | NFS_INO_REVAL_FORCED);
                cache_revalidated = false;
        }
@@ -1904,15 +1965,13 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        if (fattr->valid & NFS_ATTR_FATTR_OWNER) {
                if (!uid_eq(inode->i_uid, fattr->uid)) {
                        invalid |= NFS_INO_INVALID_ACCESS
-                               | NFS_INO_INVALID_ACL
-                               | NFS_INO_INVALID_OTHER;
+                               | NFS_INO_INVALID_ACL;
                        inode->i_uid = fattr->uid;
+                       attr_changed = true;
                }
        } else if (server->caps & NFS_CAP_OWNER) {
                nfsi->cache_validity |= save_cache_validity &
-                               (NFS_INO_INVALID_ACCESS
-                               | NFS_INO_INVALID_ACL
-                               | NFS_INO_INVALID_OTHER
+                               (NFS_INO_INVALID_OTHER
                                | NFS_INO_REVAL_FORCED);
                cache_revalidated = false;
        }
@@ -1920,25 +1979,23 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        if (fattr->valid & NFS_ATTR_FATTR_GROUP) {
                if (!gid_eq(inode->i_gid, fattr->gid)) {
                        invalid |= NFS_INO_INVALID_ACCESS
-                               | NFS_INO_INVALID_ACL
-                               | NFS_INO_INVALID_OTHER;
+                               | NFS_INO_INVALID_ACL;
                        inode->i_gid = fattr->gid;
+                       attr_changed = true;
                }
        } else if (server->caps & NFS_CAP_OWNER_GROUP) {
                nfsi->cache_validity |= save_cache_validity &
-                               (NFS_INO_INVALID_ACCESS
-                               | NFS_INO_INVALID_ACL
-                               | NFS_INO_INVALID_OTHER
+                               (NFS_INO_INVALID_OTHER
                                | NFS_INO_REVAL_FORCED);
                cache_revalidated = false;
        }
 
        if (fattr->valid & NFS_ATTR_FATTR_NLINK) {
                if (inode->i_nlink != fattr->nlink) {
-                       invalid |= NFS_INO_INVALID_OTHER;
                        if (S_ISDIR(inode->i_mode))
                                invalid |= NFS_INO_INVALID_DATA;
                        set_nlink(inode, fattr->nlink);
+                       attr_changed = true;
                }
        } else if (server->caps & NFS_CAP_NLINK) {
                nfsi->cache_validity |= save_cache_validity &
@@ -1958,7 +2015,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
                cache_revalidated = false;
 
        /* Update attrtimeo value if we're out of the unstable period */
-       if (invalid & NFS_INO_INVALID_ATTR) {
+       if (attr_changed) {
                invalid &= ~NFS_INO_INVALID_ATTR;
                nfs_inc_stats(inode, NFSIOS_ATTRINVALIDATE);
                nfsi->attrtimeo = NFS_MINATTRTIMEO(inode);
@@ -1984,9 +2041,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)
                                || S_ISLNK(inode->i_mode)))
                invalid &= ~NFS_INO_INVALID_DATA;
-       if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ) ||
-                       (save_cache_validity & NFS_INO_REVAL_FORCED))
-               nfs_set_cache_invalid(inode, invalid);
+       nfs_set_cache_invalid(inode, invalid);
 
        return 0;
  out_err:
index 85e4b4a233f9d9b3f0bcab413c92458844c558e3..350675e3ed479e11af839fcbbc9b99e1d972b068 100644 (file)
@@ -354,6 +354,7 @@ static __be32 *xdr_time_not_set(__be32 *p)
 
 static void encode_sattr(struct xdr_stream *xdr, const struct iattr *attr)
 {
+       struct timespec ts;
        __be32 *p;
 
        p = xdr_reserve_space(xdr, NFS_sattr_sz << 2);
@@ -375,17 +376,21 @@ static void encode_sattr(struct xdr_stream *xdr, const struct iattr *attr)
        else
                *p++ = cpu_to_be32(NFS2_SATTR_NOT_SET);
 
-       if (attr->ia_valid & ATTR_ATIME_SET)
-               p = xdr_encode_time(p, &attr->ia_atime);
-       else if (attr->ia_valid & ATTR_ATIME)
-               p = xdr_encode_current_server_time(p, &attr->ia_atime);
-       else
+       if (attr->ia_valid & ATTR_ATIME_SET) {
+               ts = timespec64_to_timespec(attr->ia_atime);
+               p = xdr_encode_time(p, &ts);
+       } else if (attr->ia_valid & ATTR_ATIME) {
+               ts = timespec64_to_timespec(attr->ia_atime);
+               p = xdr_encode_current_server_time(p, &ts);
+       } else
                p = xdr_time_not_set(p);
-       if (attr->ia_valid & ATTR_MTIME_SET)
-               xdr_encode_time(p, &attr->ia_mtime);
-       else if (attr->ia_valid & ATTR_MTIME)
-               xdr_encode_current_server_time(p, &attr->ia_mtime);
-       else
+       if (attr->ia_valid & ATTR_MTIME_SET) {
+               ts = timespec64_to_timespec(attr->ia_atime);
+               xdr_encode_time(p, &ts);
+       } else if (attr->ia_valid & ATTR_MTIME) {
+               ts = timespec64_to_timespec(attr->ia_mtime);
+               xdr_encode_current_server_time(p, &ts);
+       } else
                xdr_time_not_set(p);
 }
 
index eadf1ab31d1666c7ce462b56d8f00ae80de7650a..ec8a9efa268fec13f78daaf347b37a6b707d6f1e 100644 (file)
@@ -101,7 +101,8 @@ nfs3_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
  */
 static int
 nfs3_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
-               struct nfs_fattr *fattr, struct nfs4_label *label)
+               struct nfs_fattr *fattr, struct nfs4_label *label,
+               struct inode *inode)
 {
        struct rpc_message msg = {
                .rpc_proc       = &nfs3_procedures[NFS3PROC_GETATTR],
@@ -414,7 +415,9 @@ nfs3_proc_remove(struct inode *dir, struct dentry *dentry)
 }
 
 static void
-nfs3_proc_unlink_setup(struct rpc_message *msg, struct dentry *dentry)
+nfs3_proc_unlink_setup(struct rpc_message *msg,
+               struct dentry *dentry,
+               struct inode *inode)
 {
        msg->rpc_proc = &nfs3_procedures[NFS3PROC_REMOVE];
 }
@@ -823,7 +826,8 @@ static int nfs3_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
 }
 
 static void nfs3_proc_write_setup(struct nfs_pgio_header *hdr,
-                                 struct rpc_message *msg)
+                                 struct rpc_message *msg,
+                                 struct rpc_clnt **clnt)
 {
        msg->rpc_proc = &nfs3_procedures[NFS3PROC_WRITE];
 }
@@ -844,7 +848,8 @@ static int nfs3_commit_done(struct rpc_task *task, struct nfs_commit_data *data)
        return 0;
 }
 
-static void nfs3_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg)
+static void nfs3_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg,
+                                  struct rpc_clnt **clnt)
 {
        msg->rpc_proc = &nfs3_procedures[NFS3PROC_COMMIT];
 }
index 09ee36dd84262971296138b9945dc843b5926645..64e4fa33d89f0e347155db74507862ec6f09fcc8 100644 (file)
@@ -561,6 +561,7 @@ static __be32 *xdr_decode_nfstime3(__be32 *p, struct timespec *timep)
  */
 static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
 {
+       struct timespec ts;
        u32 nbytes;
        __be32 *p;
 
@@ -610,8 +611,10 @@ static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
                *p++ = xdr_zero;
 
        if (attr->ia_valid & ATTR_ATIME_SET) {
+               struct timespec ts;
                *p++ = xdr_two;
-               p = xdr_encode_nfstime3(p, &attr->ia_atime);
+               ts = timespec64_to_timespec(attr->ia_atime);
+               p = xdr_encode_nfstime3(p, &ts);
        } else if (attr->ia_valid & ATTR_ATIME) {
                *p++ = xdr_one;
        } else
@@ -619,7 +622,8 @@ static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr)
 
        if (attr->ia_valid & ATTR_MTIME_SET) {
                *p++ = xdr_two;
-               xdr_encode_nfstime3(p, &attr->ia_mtime);
+               ts = timespec64_to_timespec(attr->ia_mtime);
+               xdr_encode_nfstime3(p, &ts);
        } else if (attr->ia_valid & ATTR_MTIME) {
                *p = xdr_one;
        } else
index 9c374441f660a85bc3e3b2ee1f65f97c9f8dc316..5f59b6f65a421911fb35d196636dd7d0a7488053 100644 (file)
@@ -370,6 +370,10 @@ nfs42_layoutstat_done(struct rpc_task *task, void *calldata)
        switch (task->tk_status) {
        case 0:
                break;
+       case -NFS4ERR_BADHANDLE:
+       case -ESTALE:
+               pnfs_destroy_layout(NFS_I(inode));
+               break;
        case -NFS4ERR_EXPIRED:
        case -NFS4ERR_ADMIN_REVOKED:
        case -NFS4ERR_DELEG_REVOKED:
@@ -462,7 +466,7 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *server,
                nfs42_layoutstat_release(data);
                return -EAGAIN;
        }
-       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0);
+       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0);
        task = rpc_run_task(&task_setup);
        if (IS_ERR(task))
                return PTR_ERR(task);
index b374f680830ca34e5cdd7a4f3fb35d69ae7a2c06..137e18abb7e792660be11acf7b114213f71cd9a1 100644 (file)
@@ -212,6 +212,31 @@ struct nfs4_state_recovery_ops {
                struct rpc_cred *);
 };
 
+struct nfs4_opendata {
+       struct kref kref;
+       struct nfs_openargs o_arg;
+       struct nfs_openres o_res;
+       struct nfs_open_confirmargs c_arg;
+       struct nfs_open_confirmres c_res;
+       struct nfs4_string owner_name;
+       struct nfs4_string group_name;
+       struct nfs4_label *a_label;
+       struct nfs_fattr f_attr;
+       struct nfs4_label *f_label;
+       struct dentry *dir;
+       struct dentry *dentry;
+       struct nfs4_state_owner *owner;
+       struct nfs4_state *state;
+       struct iattr attrs;
+       struct nfs4_layoutget *lgp;
+       unsigned long timestamp;
+       bool rpc_done;
+       bool file_created;
+       bool is_recover;
+       bool cancelled;
+       int rpc_status;
+};
+
 struct nfs4_add_xprt_data {
        struct nfs_client       *clp;
        struct rpc_cred         *cred;
@@ -251,7 +276,7 @@ extern int nfs4_handle_exception(struct nfs_server *, int, struct nfs4_exception
 extern int nfs4_call_sync(struct rpc_clnt *, struct nfs_server *,
                          struct rpc_message *, struct nfs4_sequence_args *,
                          struct nfs4_sequence_res *, int);
-extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int);
+extern void nfs4_init_sequence(struct nfs4_sequence_args *, struct nfs4_sequence_res *, int, int);
 extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
 extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
 extern int nfs4_proc_get_rootfh(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *, bool);
index 22dc30a679a03615e480b993b76482f8536bcf19..b6f9d84ba19b1a1002cbc22760ab4d84bd396006 100644 (file)
@@ -343,7 +343,7 @@ static ssize_t nfs_idmap_lookup_name(__u32 id, const char *type, char *buf,
        int id_len;
        ssize_t ret;
 
-       id_len = snprintf(id_str, sizeof(id_str), "%u", id);
+       id_len = nfs_map_numeric_to_string(id, id_str, sizeof(id_str));
        ret = nfs_idmap_get_key(id_str, id_len, type, buf, buflen, idmap);
        if (ret < 0)
                return -EINVAL;
@@ -627,7 +627,8 @@ static int nfs_idmap_read_and_verify_message(struct idmap_msg *im,
                if (strcmp(upcall->im_name, im->im_name) != 0)
                        break;
                /* Note: here we store the NUL terminator too */
-               len = sprintf(id_str, "%d", im->im_id) + 1;
+               len = 1 + nfs_map_numeric_to_string(im->im_id, id_str,
+                                                   sizeof(id_str));
                ret = nfs_idmap_instantiate(key, authkey, id_str, len);
                break;
        case IDMAP_CONV_IDTONAME:
index b71757e85066995786df12ebe2e10b5bb19c6ef9..ed45090e4df6471902f5968b908429fe28976280 100644 (file)
@@ -71,6 +71,8 @@
 
 #define NFSDBG_FACILITY                NFSDBG_PROC
 
+#define NFS4_BITMASK_SZ                3
+
 #define NFS4_POLL_RETRY_MIN    (HZ/10)
 #define NFS4_POLL_RETRY_MAX    (15*HZ)
 
        | ATTR_MTIME_SET)
 
 struct nfs4_opendata;
-static int _nfs4_proc_open(struct nfs4_opendata *data);
 static int _nfs4_recover_proc_open(struct nfs4_opendata *data);
 static int nfs4_do_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fsinfo *);
 static void nfs_fixup_referral_attributes(struct nfs_fattr *fattr);
-static int nfs4_proc_getattr(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *label);
-static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label);
+static int nfs4_proc_getattr(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *, struct nfs4_label *label, struct inode *inode);
+static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle, struct nfs_fattr *fattr, struct nfs4_label *label, struct inode *inode);
 static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
                            struct nfs_fattr *fattr, struct iattr *sattr,
                            struct nfs_open_context *ctx, struct nfs4_label *ilabel,
@@ -274,6 +275,33 @@ const u32 nfs4_fs_locations_bitmap[3] = {
        | FATTR4_WORD1_MOUNTED_ON_FILEID,
 };
 
+static void nfs4_bitmap_copy_adjust(__u32 *dst, const __u32 *src,
+               struct inode *inode)
+{
+       unsigned long cache_validity;
+
+       memcpy(dst, src, NFS4_BITMASK_SZ*sizeof(*dst));
+       if (!inode || !nfs4_have_delegation(inode, FMODE_READ))
+               return;
+
+       cache_validity = READ_ONCE(NFS_I(inode)->cache_validity);
+       if (!(cache_validity & NFS_INO_REVAL_FORCED))
+               cache_validity &= ~(NFS_INO_INVALID_CHANGE
+                               | NFS_INO_INVALID_SIZE);
+
+       if (!(cache_validity & NFS_INO_INVALID_SIZE))
+               dst[0] &= ~FATTR4_WORD0_SIZE;
+
+       if (!(cache_validity & NFS_INO_INVALID_CHANGE))
+               dst[0] &= ~FATTR4_WORD0_CHANGE;
+}
+
+static void nfs4_bitmap_copy_adjust_setattr(__u32 *dst,
+               const __u32 *src, struct inode *inode)
+{
+       nfs4_bitmap_copy_adjust(dst, src, inode);
+}
+
 static void nfs4_setup_readdir(u64 cookie, __be32 *verifier, struct dentry *dentry,
                struct nfs4_readdir_arg *readdir)
 {
@@ -407,6 +435,11 @@ static int nfs4_do_handle_exception(struct nfs_server *server,
        switch(errorcode) {
                case 0:
                        return 0;
+               case -NFS4ERR_BADHANDLE:
+               case -ESTALE:
+                       if (inode != NULL && S_ISREG(inode->i_mode))
+                               pnfs_destroy_layout(NFS_I(inode));
+                       break;
                case -NFS4ERR_DELEG_REVOKED:
                case -NFS4ERR_ADMIN_REVOKED:
                case -NFS4ERR_EXPIRED:
@@ -608,20 +641,16 @@ struct nfs4_call_sync_data {
 };
 
 void nfs4_init_sequence(struct nfs4_sequence_args *args,
-                       struct nfs4_sequence_res *res, int cache_reply)
+                       struct nfs4_sequence_res *res, int cache_reply,
+                       int privileged)
 {
        args->sa_slot = NULL;
        args->sa_cache_this = cache_reply;
-       args->sa_privileged = 0;
+       args->sa_privileged = privileged;
 
        res->sr_slot = NULL;
 }
 
-static void nfs4_set_sequence_privileged(struct nfs4_sequence_args *args)
-{
-       args->sa_privileged = 1;
-}
-
 static void nfs40_sequence_free_slot(struct nfs4_sequence_res *res)
 {
        struct nfs4_slot *slot = res->sr_slot;
@@ -746,12 +775,19 @@ static int nfs41_sequence_process(struct rpc_task *task,
                        slot->slot_nr,
                        slot->seq_nr);
                goto out_retry;
+       case -NFS4ERR_RETRY_UNCACHED_REP:
+       case -NFS4ERR_SEQ_FALSE_RETRY:
+               /*
+                * The server thinks we tried to replay a request.
+                * Retry the call after bumping the sequence ID.
+                */
+               goto retry_new_seq;
        case -NFS4ERR_BADSLOT:
                /*
                 * The slot id we used was probably retired. Try again
                 * using a different slot id.
                 */
-               if (slot->seq_nr < slot->table->target_highest_slotid)
+               if (slot->slot_nr < slot->table->target_highest_slotid)
                        goto session_recover;
                goto retry_nowait;
        case -NFS4ERR_SEQ_MISORDERED:
@@ -770,10 +806,6 @@ static int nfs41_sequence_process(struct rpc_task *task,
                        goto retry_nowait;
                }
                goto session_recover;
-       case -NFS4ERR_SEQ_FALSE_RETRY:
-               if (interrupted)
-                       goto retry_new_seq;
-               goto session_recover;
        default:
                /* Just update the slot sequence no. */
                slot->seq_done = 1;
@@ -1035,7 +1067,7 @@ int nfs4_call_sync(struct rpc_clnt *clnt,
                   struct nfs4_sequence_res *res,
                   int cache_reply)
 {
-       nfs4_init_sequence(args, res, cache_reply);
+       nfs4_init_sequence(args, res, cache_reply, 0);
        return nfs4_call_sync_sequence(clnt, server, msg, args, res);
 }
 
@@ -1064,30 +1096,6 @@ static void update_changeattr(struct inode *dir, struct nfs4_change_info *cinfo,
        spin_unlock(&dir->i_lock);
 }
 
-struct nfs4_opendata {
-       struct kref kref;
-       struct nfs_openargs o_arg;
-       struct nfs_openres o_res;
-       struct nfs_open_confirmargs c_arg;
-       struct nfs_open_confirmres c_res;
-       struct nfs4_string owner_name;
-       struct nfs4_string group_name;
-       struct nfs4_label *a_label;
-       struct nfs_fattr f_attr;
-       struct nfs4_label *f_label;
-       struct dentry *dir;
-       struct dentry *dentry;
-       struct nfs4_state_owner *owner;
-       struct nfs4_state *state;
-       struct iattr attrs;
-       unsigned long timestamp;
-       bool rpc_done;
-       bool file_created;
-       bool is_recover;
-       bool cancelled;
-       int rpc_status;
-};
-
 struct nfs4_open_createattrs {
        struct nfs4_label *label;
        struct iattr *sattr;
@@ -1268,6 +1276,7 @@ static void nfs4_opendata_free(struct kref *kref)
                        struct nfs4_opendata, kref);
        struct super_block *sb = p->dentry->d_sb;
 
+       nfs4_lgopen_release(p->lgp);
        nfs_free_seqid(p->o_arg.seqid);
        nfs4_sequence_free_slot(&p->o_res.seq_res);
        if (p->state != NULL)
@@ -2187,13 +2196,12 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
        };
        int status;
 
-       nfs4_init_sequence(&data->c_arg.seq_args, &data->c_res.seq_res, 1);
+       nfs4_init_sequence(&data->c_arg.seq_args, &data->c_res.seq_res, 1,
+                               data->is_recover);
        kref_get(&data->kref);
        data->rpc_done = false;
        data->rpc_status = 0;
        data->timestamp = jiffies;
-       if (data->is_recover)
-               nfs4_set_sequence_privileged(&data->c_arg.seq_args);
        task = rpc_run_task(&task_setup_data);
        if (IS_ERR(task))
                return PTR_ERR(task);
@@ -2327,7 +2335,8 @@ static const struct rpc_call_ops nfs4_open_ops = {
        .rpc_release = nfs4_open_release,
 };
 
-static int nfs4_run_open_task(struct nfs4_opendata *data, int isrecover)
+static int nfs4_run_open_task(struct nfs4_opendata *data,
+                             struct nfs_open_context *ctx)
 {
        struct inode *dir = d_inode(data->dir);
        struct nfs_server *server = NFS_SERVER(dir);
@@ -2350,15 +2359,17 @@ static int nfs4_run_open_task(struct nfs4_opendata *data, int isrecover)
        };
        int status;
 
-       nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1);
        kref_get(&data->kref);
        data->rpc_done = false;
        data->rpc_status = 0;
        data->cancelled = false;
        data->is_recover = false;
-       if (isrecover) {
-               nfs4_set_sequence_privileged(&o_arg->seq_args);
+       if (!ctx) {
+               nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1, 1);
                data->is_recover = true;
+       } else {
+               nfs4_init_sequence(&o_arg->seq_args, &o_res->seq_res, 1, 0);
+               pnfs_lgopen_prepare(data, ctx);
        }
        task = rpc_run_task(&task_setup_data);
        if (IS_ERR(task))
@@ -2380,7 +2391,7 @@ static int _nfs4_recover_proc_open(struct nfs4_opendata *data)
        struct nfs_openres *o_res = &data->o_res;
        int status;
 
-       status = nfs4_run_open_task(data, 1);
+       status = nfs4_run_open_task(data, NULL);
        if (status != 0 || !data->rpc_done)
                return status;
 
@@ -2441,7 +2452,8 @@ static int nfs4_opendata_access(struct rpc_cred *cred,
 /*
  * Note: On error, nfs4_proc_open will free the struct nfs4_opendata
  */
-static int _nfs4_proc_open(struct nfs4_opendata *data)
+static int _nfs4_proc_open(struct nfs4_opendata *data,
+                          struct nfs_open_context *ctx)
 {
        struct inode *dir = d_inode(data->dir);
        struct nfs_server *server = NFS_SERVER(dir);
@@ -2449,7 +2461,7 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
        struct nfs_openres *o_res = &data->o_res;
        int status;
 
-       status = nfs4_run_open_task(data, 0);
+       status = nfs4_run_open_task(data, ctx);
        if (!data->rpc_done)
                return status;
        if (status != 0) {
@@ -2480,7 +2492,8 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
        }
        if (!(o_res->f_attr->valid & NFS_ATTR_FATTR)) {
                nfs4_sequence_free_slot(&o_res->seq_res);
-               nfs4_proc_getattr(server, &o_res->fh, o_res->f_attr, o_res->f_label);
+               nfs4_proc_getattr(server, &o_res->fh, o_res->f_attr,
+                               o_res->f_label, NULL);
        }
        return 0;
 }
@@ -2800,11 +2813,11 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
 
        seq = raw_seqcount_begin(&sp->so_reclaim_seqcount);
 
-       ret = _nfs4_proc_open(opendata);
+       ret = _nfs4_proc_open(opendata, ctx);
        if (ret != 0)
                goto out;
 
-       state = nfs4_opendata_to_nfs4_state(opendata);
+       state = _nfs4_opendata_to_nfs4_state(opendata);
        ret = PTR_ERR(state);
        if (IS_ERR(state))
                goto out;
@@ -2838,8 +2851,12 @@ static int _nfs4_open_and_get_state(struct nfs4_opendata *opendata,
                nfs_inode_attach_open_context(ctx);
                if (read_seqcount_retry(&sp->so_reclaim_seqcount, seq))
                        nfs4_schedule_stateid_recovery(server, state);
+               else
+                       pnfs_parse_lgopen(state->inode, opendata->lgp, ctx);
        }
+
 out:
+       nfs4_sequence_free_slot(&opendata->o_res.seq_res);
        return ret;
 }
 
@@ -3039,7 +3056,6 @@ static int _nfs4_do_setattr(struct inode *inode,
        };
        struct rpc_cred *delegation_cred = NULL;
        unsigned long timestamp = jiffies;
-       fmode_t fmode;
        bool truncate;
        int status;
 
@@ -3047,11 +3063,12 @@ static int _nfs4_do_setattr(struct inode *inode,
 
        /* Servers should only apply open mode checks for file size changes */
        truncate = (arg->iap->ia_valid & ATTR_SIZE) ? true : false;
-       fmode = truncate ? FMODE_WRITE : FMODE_READ;
+       if (!truncate)
+               goto zero_stateid;
 
-       if (nfs4_copy_delegation_stateid(inode, fmode, &arg->stateid, &delegation_cred)) {
+       if (nfs4_copy_delegation_stateid(inode, FMODE_WRITE, &arg->stateid, &delegation_cred)) {
                /* Use that stateid */
-       } else if (truncate && ctx != NULL) {
+       } else if (ctx != NULL) {
                struct nfs_lock_context *l_ctx;
                if (!nfs4_valid_open_stateid(ctx->state))
                        return -EBADF;
@@ -3063,8 +3080,10 @@ static int _nfs4_do_setattr(struct inode *inode,
                nfs_put_lock_context(l_ctx);
                if (status == -EIO)
                        return -EBADF;
-       } else
+       } else {
+zero_stateid:
                nfs4_stateid_copy(&arg->stateid, &zero_stateid);
+       }
        if (delegation_cred)
                msg.rpc_cred = delegation_cred;
 
@@ -3083,12 +3102,13 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
                           struct nfs4_label *olabel)
 {
        struct nfs_server *server = NFS_SERVER(inode);
+       __u32 bitmask[NFS4_BITMASK_SZ];
        struct nfs4_state *state = ctx ? ctx->state : NULL;
        struct nfs_setattrargs  arg = {
                .fh             = NFS_FH(inode),
                .iap            = sattr,
                .server         = server,
-               .bitmask = server->attr_bitmask,
+               .bitmask = bitmask,
                .label          = ilabel,
        };
        struct nfs_setattrres  res = {
@@ -3103,11 +3123,11 @@ static int nfs4_do_setattr(struct inode *inode, struct rpc_cred *cred,
        };
        int err;
 
-       arg.bitmask = nfs4_bitmask(server, ilabel);
-       if (ilabel)
-               arg.bitmask = nfs4_bitmask(server, olabel);
-
        do {
+               nfs4_bitmap_copy_adjust_setattr(bitmask,
+                               nfs4_bitmask(server, olabel),
+                               inode);
+
                err = _nfs4_do_setattr(inode, &arg, &res, cred, ctx);
                switch (err) {
                case -NFS4ERR_OPENMODE:
@@ -3393,7 +3413,7 @@ int nfs4_do_close(struct nfs4_state *state, gfp_t gfp_mask, int wait)
        calldata = kzalloc(sizeof(*calldata), gfp_mask);
        if (calldata == NULL)
                goto out;
-       nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 1);
+       nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 1, 0);
        calldata->inode = state->inode;
        calldata->state = state;
        calldata->arg.fh = NFS_FH(state->inode);
@@ -3742,7 +3762,7 @@ static int nfs4_proc_get_root(struct nfs_server *server, struct nfs_fh *mntfh,
        if (IS_ERR(label))
                return PTR_ERR(label);
 
-       error = nfs4_proc_getattr(server, mntfh, fattr, label);
+       error = nfs4_proc_getattr(server, mntfh, fattr, label, NULL);
        if (error < 0) {
                dprintk("nfs4_get_root: getattr error = %d\n", -error);
                goto err_free_label;
@@ -3807,11 +3827,13 @@ static int nfs4_get_referral(struct rpc_clnt *client, struct inode *dir,
 }
 
 static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
-                               struct nfs_fattr *fattr, struct nfs4_label *label)
+                               struct nfs_fattr *fattr, struct nfs4_label *label,
+                               struct inode *inode)
 {
+       __u32 bitmask[NFS4_BITMASK_SZ];
        struct nfs4_getattr_arg args = {
                .fh = fhandle,
-               .bitmask = server->attr_bitmask,
+               .bitmask = bitmask,
        };
        struct nfs4_getattr_res res = {
                .fattr = fattr,
@@ -3824,19 +3846,20 @@ static int _nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
                .rpc_resp = &res,
        };
 
-       args.bitmask = nfs4_bitmask(server, label);
+       nfs4_bitmap_copy_adjust(bitmask, nfs4_bitmask(server, label), inode);
 
        nfs_fattr_init(fattr);
        return nfs4_call_sync(server->client, server, &msg, &args.seq_args, &res.seq_res, 0);
 }
 
 static int nfs4_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
-                               struct nfs_fattr *fattr, struct nfs4_label *label)
+                               struct nfs_fattr *fattr, struct nfs4_label *label,
+                               struct inode *inode)
 {
        struct nfs4_exception exception = { };
        int err;
        do {
-               err = _nfs4_proc_getattr(server, fhandle, fattr, label);
+               err = _nfs4_proc_getattr(server, fhandle, fattr, label, inode);
                trace_nfs4_getattr(server, fhandle, fattr, err);
                err = nfs4_handle_exception(server, err,
                                &exception);
@@ -4089,7 +4112,7 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry
        };
        int status = 0;
 
-       if (!nfs_have_delegated_attributes(inode)) {
+       if (!nfs4_have_delegation(inode, FMODE_READ)) {
                res.fattr = nfs_alloc_fattr();
                if (res.fattr == NULL)
                        return -ENOMEM;
@@ -4265,15 +4288,16 @@ static int nfs4_proc_rmdir(struct inode *dir, const struct qstr *name)
        return err;
 }
 
-static void nfs4_proc_unlink_setup(struct rpc_message *msg, struct dentry *dentry)
+static void nfs4_proc_unlink_setup(struct rpc_message *msg,
+               struct dentry *dentry,
+               struct inode *inode)
 {
        struct nfs_removeargs *args = msg->rpc_argp;
        struct nfs_removeres *res = msg->rpc_resp;
-       struct inode *inode = d_inode(dentry);
 
        res->server = NFS_SB(dentry->d_sb);
        msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_REMOVE];
-       nfs4_init_sequence(&args->seq_args, &res->seq_res, 1);
+       nfs4_init_sequence(&args->seq_args, &res->seq_res, 1, 0);
 
        nfs_fattr_init(res->dir_attr);
 
@@ -4319,7 +4343,7 @@ static void nfs4_proc_rename_setup(struct rpc_message *msg,
                nfs4_inode_return_delegation(new_inode);
        msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_RENAME];
        res->server = NFS_SB(old_dentry->d_sb);
-       nfs4_init_sequence(&arg->seq_args, &res->seq_res, 1);
+       nfs4_init_sequence(&arg->seq_args, &res->seq_res, 1, 0);
 }
 
 static void nfs4_proc_rename_rpc_prepare(struct rpc_task *task, struct nfs_renamedata *data)
@@ -4352,11 +4376,12 @@ static int nfs4_proc_rename_done(struct rpc_task *task, struct inode *old_dir,
 static int _nfs4_proc_link(struct inode *inode, struct inode *dir, const struct qstr *name)
 {
        struct nfs_server *server = NFS_SERVER(inode);
+       __u32 bitmask[NFS4_BITMASK_SZ];
        struct nfs4_link_arg arg = {
                .fh     = NFS_FH(inode),
                .dir_fh = NFS_FH(dir),
                .name   = name,
-               .bitmask = server->attr_bitmask,
+               .bitmask = bitmask,
        };
        struct nfs4_link_res res = {
                .server = server,
@@ -4378,9 +4403,9 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, const struct
                status = PTR_ERR(res.label);
                goto out;
        }
-       arg.bitmask = nfs4_bitmask(server, res.label);
 
        nfs4_inode_make_writeable(inode);
+       nfs4_bitmap_copy_adjust_setattr(bitmask, nfs4_bitmask(server, res.label), inode);
 
        status = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
        if (!status) {
@@ -4895,7 +4920,7 @@ static void nfs4_proc_read_setup(struct nfs_pgio_header *hdr,
        if (!hdr->pgio_done_cb)
                hdr->pgio_done_cb = nfs4_read_done_cb;
        msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_READ];
-       nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0);
+       nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 0, 0);
 }
 
 static int nfs4_proc_pgio_rpc_prepare(struct rpc_task *task,
@@ -4979,7 +5004,8 @@ bool nfs4_write_need_cache_consistency_data(struct nfs_pgio_header *hdr)
 }
 
 static void nfs4_proc_write_setup(struct nfs_pgio_header *hdr,
-                                 struct rpc_message *msg)
+                                 struct rpc_message *msg,
+                                 struct rpc_clnt **clnt)
 {
        struct nfs_server *server = NFS_SERVER(hdr->inode);
 
@@ -4995,7 +5021,8 @@ static void nfs4_proc_write_setup(struct nfs_pgio_header *hdr,
        hdr->timestamp   = jiffies;
 
        msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_WRITE];
-       nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 1);
+       nfs4_init_sequence(&hdr->args.seq_args, &hdr->res.seq_res, 1, 0);
+       nfs4_state_protect_write(server->nfs_client, clnt, msg, hdr);
 }
 
 static void nfs4_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit_data *data)
@@ -5026,7 +5053,8 @@ static int nfs4_commit_done(struct rpc_task *task, struct nfs_commit_data *data)
        return data->commit_done_cb(task, data);
 }
 
-static void nfs4_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg)
+static void nfs4_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg,
+                                  struct rpc_clnt **clnt)
 {
        struct nfs_server *server = NFS_SERVER(data->inode);
 
@@ -5034,7 +5062,8 @@ static void nfs4_proc_commit_setup(struct nfs_commit_data *data, struct rpc_mess
                data->commit_done_cb = nfs4_commit_done_cb;
        data->res.server = server;
        msg->rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_COMMIT];
-       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1);
+       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0);
+       nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_COMMIT, clnt, msg);
 }
 
 struct nfs4_renewdata {
@@ -5391,7 +5420,8 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl
         */
        spin_lock(&inode->i_lock);
        NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
-               | NFS_INO_INVALID_CTIME;
+               | NFS_INO_INVALID_CTIME
+               | NFS_INO_REVAL_FORCED;
        spin_unlock(&inode->i_lock);
        nfs_access_zap_cache(inode);
        nfs_zap_acl_cache(inode);
@@ -5591,13 +5621,14 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
                return 0;
 
        rcu_read_lock();
-       len = 14 + strlen(clp->cl_ipaddr) + 1 +
-               strlen(rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)) +
+       len = 14 +
+               strlen(clp->cl_rpcclient->cl_nodename) +
                1 +
-               strlen(rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_PROTO)) +
+               strlen(rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR)) +
                1;
        rcu_read_unlock();
-
+       if (nfs4_client_id_uniquifier[0] != '\0')
+               len += strlen(nfs4_client_id_uniquifier) + 1;
        if (len > NFS4_OPAQUE_LIMIT + 1)
                return -EINVAL;
 
@@ -5611,10 +5642,17 @@ nfs4_init_nonuniform_client_string(struct nfs_client *clp)
                return -ENOMEM;
 
        rcu_read_lock();
-       scnprintf(str, len, "Linux NFSv4.0 %s/%s %s",
-                       clp->cl_ipaddr,
-                       rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR),
-                       rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_PROTO));
+       if (nfs4_client_id_uniquifier[0] != '\0')
+               scnprintf(str, len, "Linux NFSv4.0 %s/%s/%s",
+                         clp->cl_rpcclient->cl_nodename,
+                         nfs4_client_id_uniquifier,
+                         rpc_peeraddr2str(clp->cl_rpcclient,
+                                          RPC_DISPLAY_ADDR));
+       else
+               scnprintf(str, len, "Linux NFSv4.0 %s/%s",
+                         clp->cl_rpcclient->cl_nodename,
+                         rpc_peeraddr2str(clp->cl_rpcclient,
+                                          RPC_DISPLAY_ADDR));
        rcu_read_unlock();
 
        clp->cl_owner_id = str;
@@ -5972,7 +6010,7 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
        data = kzalloc(sizeof(*data), GFP_NOFS);
        if (data == NULL)
                return -ENOMEM;
-       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1);
+       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0);
 
        nfs4_state_protect(server->nfs_client,
                        NFS_SP4_MACH_CRED_CLEANUP,
@@ -6247,7 +6285,7 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
                return ERR_PTR(-ENOMEM);
        }
 
-       nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1);
+       nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1, 0);
        msg.rpc_argp = &data->arg;
        msg.rpc_resp = &data->res;
        task_setup_data.callback_data = data;
@@ -6411,32 +6449,36 @@ static void nfs4_lock_done(struct rpc_task *task, void *calldata)
        case 0:
                renew_lease(NFS_SERVER(d_inode(data->ctx->dentry)),
                                data->timestamp);
-               if (data->arg.new_lock) {
+               if (data->arg.new_lock && !data->cancelled) {
                        data->fl.fl_flags &= ~(FL_SLEEP | FL_ACCESS);
-                       if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0) {
-                               rpc_restart_call_prepare(task);
+                       if (locks_lock_inode_wait(lsp->ls_state->inode, &data->fl) < 0)
                                break;
-                       }
                }
+
                if (data->arg.new_lock_owner != 0) {
                        nfs_confirm_seqid(&lsp->ls_seqid, 0);
                        nfs4_stateid_copy(&lsp->ls_stateid, &data->res.stateid);
                        set_bit(NFS_LOCK_INITIALIZED, &lsp->ls_flags);
-               } else if (!nfs4_update_lock_stateid(lsp, &data->res.stateid))
-                       rpc_restart_call_prepare(task);
+                       goto out_done;
+               } else if (nfs4_update_lock_stateid(lsp, &data->res.stateid))
+                       goto out_done;
+
                break;
        case -NFS4ERR_BAD_STATEID:
        case -NFS4ERR_OLD_STATEID:
        case -NFS4ERR_STALE_STATEID:
        case -NFS4ERR_EXPIRED:
                if (data->arg.new_lock_owner != 0) {
-                       if (!nfs4_stateid_match(&data->arg.open_stateid,
+                       if (nfs4_stateid_match(&data->arg.open_stateid,
                                                &lsp->ls_state->open_stateid))
-                               rpc_restart_call_prepare(task);
-               } else if (!nfs4_stateid_match(&data->arg.lock_stateid,
+                               goto out_done;
+               } else if (nfs4_stateid_match(&data->arg.lock_stateid,
                                                &lsp->ls_stateid))
-                               rpc_restart_call_prepare(task);
+                               goto out_done;
        }
+       if (!data->cancelled)
+               rpc_restart_call_prepare(task);
+out_done:
        dprintk("%s: done, ret = %d!\n", __func__, data->rpc_status);
 }
 
@@ -6509,14 +6551,14 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
                return -ENOMEM;
        if (IS_SETLKW(cmd))
                data->arg.block = 1;
-       nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1);
+       nfs4_init_sequence(&data->arg.seq_args, &data->res.seq_res, 1,
+                               recovery_type > NFS_LOCK_NEW);
        msg.rpc_argp = &data->arg;
        msg.rpc_resp = &data->res;
        task_setup_data.callback_data = data;
        if (recovery_type > NFS_LOCK_NEW) {
                if (recovery_type == NFS_LOCK_RECLAIM)
                        data->arg.reclaim = NFS_LOCK_RECLAIM;
-               nfs4_set_sequence_privileged(&data->arg.seq_args);
        } else
                data->arg.new_lock = 1;
        task = rpc_run_task(&task_setup_data);
@@ -6911,7 +6953,7 @@ nfs4_release_lockowner(struct nfs_server *server, struct nfs4_lock_state *lsp)
 
        msg.rpc_argp = &data->args;
        msg.rpc_resp = &data->res;
-       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0);
+       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0, 0);
        rpc_call_async(server->client, &msg, 0, &nfs4_release_lockowner_ops, data);
 }
 
@@ -7107,8 +7149,7 @@ static int _nfs40_proc_get_locations(struct inode *inode,
        locations->server = server;
        locations->nlocations = 0;
 
-       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0);
-       nfs4_set_sequence_privileged(&args.seq_args);
+       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
        status = nfs4_call_sync_sequence(clnt, server, &msg,
                                        &args.seq_args, &res.seq_res);
        if (status)
@@ -7161,8 +7202,7 @@ static int _nfs41_proc_get_locations(struct inode *inode,
        locations->server = server;
        locations->nlocations = 0;
 
-       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0);
-       nfs4_set_sequence_privileged(&args.seq_args);
+       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
        status = nfs4_call_sync_sequence(clnt, server, &msg,
                                        &args.seq_args, &res.seq_res);
        if (status == NFS4_OK &&
@@ -7249,8 +7289,7 @@ static int _nfs40_proc_fsid_present(struct inode *inode, struct rpc_cred *cred)
        if (res.fh == NULL)
                return -ENOMEM;
 
-       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0);
-       nfs4_set_sequence_privileged(&args.seq_args);
+       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
        status = nfs4_call_sync_sequence(clnt, server, &msg,
                                                &args.seq_args, &res.seq_res);
        nfs_free_fhandle(res.fh);
@@ -7291,8 +7330,7 @@ static int _nfs41_proc_fsid_present(struct inode *inode, struct rpc_cred *cred)
        if (res.fh == NULL)
                return -ENOMEM;
 
-       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0);
-       nfs4_set_sequence_privileged(&args.seq_args);
+       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
        status = nfs4_call_sync_sequence(clnt, server, &msg,
                                                &args.seq_args, &res.seq_res);
        nfs_free_fhandle(res.fh);
@@ -8070,8 +8108,7 @@ int nfs4_proc_get_lease_time(struct nfs_client *clp, struct nfs_fsinfo *fsinfo)
        };
        int status;
 
-       nfs4_init_sequence(&args.la_seq_args, &res.lr_seq_res, 0);
-       nfs4_set_sequence_privileged(&args.la_seq_args);
+       nfs4_init_sequence(&args.la_seq_args, &res.lr_seq_res, 0, 1);
        task = rpc_run_task(&task_setup);
 
        if (IS_ERR(task))
@@ -8408,10 +8445,8 @@ static struct rpc_task *_nfs41_proc_sequence(struct nfs_client *clp,
        calldata = kzalloc(sizeof(*calldata), GFP_NOFS);
        if (calldata == NULL)
                goto out_put_clp;
-       nfs4_init_sequence(&calldata->args, &calldata->res, 0);
+       nfs4_init_sequence(&calldata->args, &calldata->res, 0, is_privileged);
        nfs4_sequence_attach_slot(&calldata->args, &calldata->res, slot);
-       if (is_privileged)
-               nfs4_set_sequence_privileged(&calldata->args);
        msg.rpc_argp = &calldata->args;
        msg.rpc_resp = &calldata->res;
        calldata->clp = clp;
@@ -8563,8 +8598,7 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp,
        calldata->clp = clp;
        calldata->arg.one_fs = 0;
 
-       nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 0);
-       nfs4_set_sequence_privileged(&calldata->arg.seq_args);
+       nfs4_init_sequence(&calldata->arg.seq_args, &calldata->res.seq_res, 0, 1);
        msg.rpc_argp = &calldata->arg;
        msg.rpc_resp = &calldata->res;
        task_setup_data.callback_data = calldata;
@@ -8693,63 +8727,19 @@ nfs4_layoutget_handle_exception(struct rpc_task *task,
        return status;
 }
 
-static size_t max_response_pages(struct nfs_server *server)
+size_t max_response_pages(struct nfs_server *server)
 {
        u32 max_resp_sz = server->nfs_client->cl_session->fc_attrs.max_resp_sz;
        return nfs_page_array_len(0, max_resp_sz);
 }
 
-static void nfs4_free_pages(struct page **pages, size_t size)
-{
-       int i;
-
-       if (!pages)
-               return;
-
-       for (i = 0; i < size; i++) {
-               if (!pages[i])
-                       break;
-               __free_page(pages[i]);
-       }
-       kfree(pages);
-}
-
-static struct page **nfs4_alloc_pages(size_t size, gfp_t gfp_flags)
-{
-       struct page **pages;
-       int i;
-
-       pages = kcalloc(size, sizeof(struct page *), gfp_flags);
-       if (!pages) {
-               dprintk("%s: can't alloc array of %zu pages\n", __func__, size);
-               return NULL;
-       }
-
-       for (i = 0; i < size; i++) {
-               pages[i] = alloc_page(gfp_flags);
-               if (!pages[i]) {
-                       dprintk("%s: failed to allocate page\n", __func__);
-                       nfs4_free_pages(pages, size);
-                       return NULL;
-               }
-       }
-
-       return pages;
-}
-
 static void nfs4_layoutget_release(void *calldata)
 {
        struct nfs4_layoutget *lgp = calldata;
-       struct inode *inode = lgp->args.inode;
-       struct nfs_server *server = NFS_SERVER(inode);
-       size_t max_pages = max_response_pages(server);
 
        dprintk("--> %s\n", __func__);
        nfs4_sequence_free_slot(&lgp->res.seq_res);
-       nfs4_free_pages(lgp->args.layout.pages, max_pages);
-       pnfs_put_layout_hdr(NFS_I(inode)->layout);
-       put_nfs_open_context(lgp->args.ctx);
-       kfree(calldata);
+       pnfs_layoutget_free(lgp);
        dprintk("<-- %s\n", __func__);
 }
 
@@ -8760,11 +8750,10 @@ static const struct rpc_call_ops nfs4_layoutget_call_ops = {
 };
 
 struct pnfs_layout_segment *
-nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags)
+nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout)
 {
        struct inode *inode = lgp->args.inode;
        struct nfs_server *server = NFS_SERVER(inode);
-       size_t max_pages = max_response_pages(server);
        struct rpc_task *task;
        struct rpc_message msg = {
                .rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_LAYOUTGET],
@@ -8791,16 +8780,7 @@ nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags)
        /* nfs4_layoutget_release calls pnfs_put_layout_hdr */
        pnfs_get_layout_hdr(NFS_I(inode)->layout);
 
-       lgp->args.layout.pages = nfs4_alloc_pages(max_pages, gfp_flags);
-       if (!lgp->args.layout.pages) {
-               nfs4_layoutget_release(lgp);
-               return ERR_PTR(-ENOMEM);
-       }
-       lgp->args.layout.pglen = max_pages * PAGE_SIZE;
-
-       lgp->res.layoutp = &lgp->args.layout;
-       lgp->res.seq_res.sr_slot = NULL;
-       nfs4_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0);
+       nfs4_init_sequence(&lgp->args.seq_args, &lgp->res.seq_res, 0, 0);
 
        task = rpc_run_task(&task_setup_data);
        if (IS_ERR(task))
@@ -8927,7 +8907,7 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync)
                }
                task_setup_data.flags |= RPC_TASK_ASYNC;
        }
-       nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1);
+       nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, 0);
        task = rpc_run_task(&task_setup_data);
        if (IS_ERR(task))
                return PTR_ERR(task);
@@ -9074,7 +9054,7 @@ nfs4_proc_layoutcommit(struct nfs4_layoutcommit_data *data, bool sync)
                }
                task_setup_data.flags = RPC_TASK_ASYNC;
        }
-       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1);
+       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0);
        task = rpc_run_task(&task_setup_data);
        if (IS_ERR(task))
                return PTR_ERR(task);
@@ -9254,8 +9234,7 @@ static int _nfs41_test_stateid(struct nfs_server *server,
                &rpc_client, &msg);
 
        dprintk("NFS call  test_stateid %p\n", stateid);
-       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0);
-       nfs4_set_sequence_privileged(&args.seq_args);
+       nfs4_init_sequence(&args.seq_args, &res.seq_res, 0, 1);
        status = nfs4_call_sync_sequence(rpc_client, server, &msg,
                        &args.seq_args, &res.seq_res);
        if (status != NFS_OK) {
@@ -9347,7 +9326,17 @@ static const struct rpc_call_ops nfs41_free_stateid_ops = {
        .rpc_release = nfs41_free_stateid_release,
 };
 
-static struct rpc_task *_nfs41_free_stateid(struct nfs_server *server,
+/**
+ * nfs41_free_stateid - perform a FREE_STATEID operation
+ *
+ * @server: server / transport on which to perform the operation
+ * @stateid: state ID to release
+ * @cred: credential
+ * @is_recovery: set to true if this call needs to be privileged
+ *
+ * Note: this function is always asynchronous.
+ */
+static int nfs41_free_stateid(struct nfs_server *server,
                const nfs4_stateid *stateid,
                struct rpc_cred *cred,
                bool privileged)
@@ -9363,6 +9352,7 @@ static struct rpc_task *_nfs41_free_stateid(struct nfs_server *server,
                .flags = RPC_TASK_ASYNC,
        };
        struct nfs_free_stateid_data *data;
+       struct rpc_task *task;
 
        nfs4_state_protect(server->nfs_client, NFS_SP4_MACH_CRED_STATEID,
                &task_setup.rpc_client, &msg);
@@ -9370,7 +9360,7 @@ static struct rpc_task *_nfs41_free_stateid(struct nfs_server *server,
        dprintk("NFS call  free_stateid %p\n", stateid);
        data = kmalloc(sizeof(*data), GFP_NOFS);
        if (!data)
-               return ERR_PTR(-ENOMEM);
+               return -ENOMEM;
        data->server = server;
        nfs4_stateid_copy(&data->args.stateid, stateid);
 
@@ -9378,31 +9368,8 @@ static struct rpc_task *_nfs41_free_stateid(struct nfs_server *server,
 
        msg.rpc_argp = &data->args;
        msg.rpc_resp = &data->res;
-       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1);
-       if (privileged)
-               nfs4_set_sequence_privileged(&data->args.seq_args);
-
-       return rpc_run_task(&task_setup);
-}
-
-/**
- * nfs41_free_stateid - perform a FREE_STATEID operation
- *
- * @server: server / transport on which to perform the operation
- * @stateid: state ID to release
- * @cred: credential
- * @is_recovery: set to true if this call needs to be privileged
- *
- * Note: this function is always asynchronous.
- */
-static int nfs41_free_stateid(struct nfs_server *server,
-               const nfs4_stateid *stateid,
-               struct rpc_cred *cred,
-               bool is_recovery)
-{
-       struct rpc_task *task;
-
-       task = _nfs41_free_stateid(server, stateid, cred, is_recovery);
+       nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, privileged);
+       task = rpc_run_task(&task_setup);
        if (IS_ERR(task))
                return PTR_ERR(task);
        rpc_put_task(task);
@@ -9539,7 +9506,8 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
                | NFS_CAP_ATOMIC_OPEN
                | NFS_CAP_POSIX_LOCK
                | NFS_CAP_STATEID_NFSV41
-               | NFS_CAP_ATOMIC_OPEN_V1,
+               | NFS_CAP_ATOMIC_OPEN_V1
+               | NFS_CAP_LGOPEN,
        .init_client = nfs41_init_client,
        .shutdown_client = nfs41_shutdown_client,
        .match_stateid = nfs41_match_stateid,
@@ -9564,6 +9532,7 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
                | NFS_CAP_POSIX_LOCK
                | NFS_CAP_STATEID_NFSV41
                | NFS_CAP_ATOMIC_OPEN_V1
+               | NFS_CAP_LGOPEN
                | NFS_CAP_ALLOCATE
                | NFS_CAP_COPY
                | NFS_CAP_DEALLOCATE
index c10a422efe6f4422ab22750c22cce18b37ef36f9..2bf2eaa08ca7de5397e0099786b672a757543242 100644 (file)
@@ -77,6 +77,14 @@ const nfs4_stateid invalid_stateid = {
        .type = NFS4_INVALID_STATEID_TYPE,
 };
 
+const nfs4_stateid current_stateid = {
+       {
+               /* Funky initialiser keeps older gcc versions happy */
+               .data = { 0x0, 0x0, 0x0, 0x1, 0 },
+       },
+       .type = NFS4_SPECIAL_STATEID_TYPE,
+};
+
 static DEFINE_MUTEX(nfs_clid_init_mutex);
 
 int nfs4_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
index 9b73920323211351f14752f3d6c92e627c6fa9ed..cd41d2577a049b489496b24a05ec2e28b959ee9d 100644 (file)
 /* Mapping from NFS error code to "errno" error code. */
 #define errno_NFSERR_IO                EIO
 
+struct compound_hdr;
 static int nfs4_stat_to_errno(int);
+static void encode_layoutget(struct xdr_stream *xdr,
+                            const struct nfs4_layoutget_args *args,
+                            struct compound_hdr *hdr);
+static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
+                            struct nfs4_layoutget_res *res);
 
 /* NFSv4 COMPOUND tags are only wanted for debugging purposes */
 #ifdef DEBUG
@@ -424,6 +430,8 @@ static int nfs4_stat_to_errno(int);
 #define decode_sequence_maxsz  0
 #define encode_layoutreturn_maxsz 0
 #define decode_layoutreturn_maxsz 0
+#define encode_layoutget_maxsz 0
+#define decode_layoutget_maxsz 0
 #endif /* CONFIG_NFS_V4_1 */
 
 #define NFS4_enc_compound_sz   (1024)  /* XXX: large enough? */
@@ -476,14 +484,16 @@ static int nfs4_stat_to_errno(int);
                                encode_open_maxsz + \
                                encode_access_maxsz + \
                                encode_getfh_maxsz + \
-                               encode_getattr_maxsz)
+                               encode_getattr_maxsz + \
+                               encode_layoutget_maxsz)
 #define NFS4_dec_open_sz        (compound_decode_hdr_maxsz + \
                                decode_sequence_maxsz + \
                                decode_putfh_maxsz + \
                                decode_open_maxsz + \
                                decode_access_maxsz + \
                                decode_getfh_maxsz + \
-                               decode_getattr_maxsz)
+                               decode_getattr_maxsz + \
+                               decode_layoutget_maxsz)
 #define NFS4_enc_open_confirm_sz \
                                (compound_encode_hdr_maxsz + \
                                 encode_putfh_maxsz + \
@@ -497,13 +507,15 @@ static int nfs4_stat_to_errno(int);
                                        encode_putfh_maxsz + \
                                        encode_open_maxsz + \
                                        encode_access_maxsz + \
-                                       encode_getattr_maxsz)
+                                       encode_getattr_maxsz + \
+                                       encode_layoutget_maxsz)
 #define NFS4_dec_open_noattr_sz        (compound_decode_hdr_maxsz + \
                                        decode_sequence_maxsz + \
                                        decode_putfh_maxsz + \
                                        decode_open_maxsz + \
                                        decode_access_maxsz + \
-                                       decode_getattr_maxsz)
+                                       decode_getattr_maxsz + \
+                                       decode_layoutget_maxsz)
 #define NFS4_enc_open_downgrade_sz \
                                (compound_encode_hdr_maxsz + \
                                 encode_sequence_maxsz + \
@@ -1057,6 +1069,7 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
                                const struct nfs_server *server,
                                const uint32_t attrmask[])
 {
+       struct timespec ts;
        char owner_name[IDMAP_NAMESZ];
        char owner_group[IDMAP_NAMESZ];
        int owner_namelen = 0;
@@ -1145,14 +1158,16 @@ static void encode_attrs(struct xdr_stream *xdr, const struct iattr *iap,
        if (bmval[1] & FATTR4_WORD1_TIME_ACCESS_SET) {
                if (iap->ia_valid & ATTR_ATIME_SET) {
                        *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
-                       p = xdr_encode_nfstime4(p, &iap->ia_atime);
+                       ts = timespec64_to_timespec(iap->ia_atime);
+                       p = xdr_encode_nfstime4(p, &ts);
                } else
                        *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
        }
        if (bmval[1] & FATTR4_WORD1_TIME_MODIFY_SET) {
                if (iap->ia_valid & ATTR_MTIME_SET) {
                        *p++ = cpu_to_be32(NFS4_SET_TO_CLIENT_TIME);
-                       p = xdr_encode_nfstime4(p, &iap->ia_mtime);
+                       ts = timespec64_to_timespec(iap->ia_mtime);
+                       p = xdr_encode_nfstime4(p, &ts);
                } else
                        *p++ = cpu_to_be32(NFS4_SET_TO_SERVER_TIME);
        }
@@ -2070,6 +2085,13 @@ encode_layoutreturn(struct xdr_stream *xdr,
                    struct compound_hdr *hdr)
 {
 }
+
+static void
+encode_layoutget(struct xdr_stream *xdr,
+                     const struct nfs4_layoutget_args *args,
+                     struct compound_hdr *hdr)
+{
+}
 #endif /* CONFIG_NFS_V4_1 */
 
 /*
@@ -2316,6 +2338,12 @@ static void nfs4_xdr_enc_open(struct rpc_rqst *req, struct xdr_stream *xdr,
        if (args->access)
                encode_access(xdr, args->access, &hdr);
        encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
+       if (args->lg_args) {
+               encode_layoutget(xdr, args->lg_args, &hdr);
+               xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
+                                args->lg_args->layout.pages,
+                                0, args->lg_args->layout.pglen);
+       }
        encode_nops(&hdr);
 }
 
@@ -2356,6 +2384,12 @@ static void nfs4_xdr_enc_open_noattr(struct rpc_rqst *req,
        if (args->access)
                encode_access(xdr, args->access, &hdr);
        encode_getfattr_open(xdr, args->bitmask, args->open_bitmap, &hdr);
+       if (args->lg_args) {
+               encode_layoutget(xdr, args->lg_args, &hdr);
+               xdr_inline_pages(&req->rq_rcv_buf, hdr.replen << 2,
+                                args->lg_args->layout.pages,
+                                0, args->lg_args->layout.pglen);
+       }
        encode_nops(&hdr);
 }
 
@@ -6024,7 +6058,7 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
 
        status = decode_op_hdr(xdr, OP_LAYOUTGET);
        if (status)
-               return status;
+               goto out;
        p = xdr_inline_decode(xdr, 4);
        if (unlikely(!p))
                goto out_overflow;
@@ -6037,7 +6071,8 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
        if (!layout_count) {
                dprintk("%s: server responded with empty layout array\n",
                        __func__);
-               return -EINVAL;
+               status = -EINVAL;
+               goto out;
        }
 
        p = xdr_inline_decode(xdr, 28);
@@ -6062,7 +6097,8 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
                dprintk("NFS: server cheating in layoutget reply: "
                                "layout len %u > recvd %u\n",
                                res->layoutp->len, recvd);
-               return -EINVAL;
+               status = -EINVAL;
+               goto out;
        }
 
        if (layout_count > 1) {
@@ -6075,10 +6111,13 @@ static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
                        __func__, layout_count);
        }
 
-       return 0;
+out:
+       res->status = status;
+       return status;
 out_overflow:
        print_overflow_msg(__func__, xdr);
-       return -EIO;
+       status = -EIO;
+       goto out;
 }
 
 static int decode_layoutreturn(struct xdr_stream *xdr,
@@ -6177,6 +6216,13 @@ int decode_layoutreturn(struct xdr_stream *xdr,
 {
        return 0;
 }
+
+static int decode_layoutget(struct xdr_stream *xdr, struct rpc_rqst *req,
+                           struct nfs4_layoutget_res *res)
+{
+       return 0;
+}
+
 #endif /* CONFIG_NFS_V4_1 */
 
 /*
@@ -6623,6 +6669,8 @@ static int nfs4_xdr_dec_open(struct rpc_rqst *rqstp, struct xdr_stream *xdr,
        if (res->access_request)
                decode_access(xdr, &res->access_supported, &res->access_result);
        decode_getfattr_label(xdr, res->f_attr, res->f_label, res->server);
+       if (res->lg_res)
+               decode_layoutget(xdr, rqstp, res->lg_res);
 out:
        return status;
 }
@@ -6675,6 +6723,8 @@ static int nfs4_xdr_dec_open_noattr(struct rpc_rqst *rqstp,
        if (res->access_request)
                decode_access(xdr, &res->access_supported, &res->access_result);
        decode_getfattr(xdr, res->f_attr, res->server);
+       if (res->lg_res)
+               decode_layoutget(xdr, rqstp, res->lg_res);
 out:
        return status;
 }
index ee723aa153a3300633bc434f52156f3cf443f3dd..bcc3addec3c5376436f55f4d7cabad564bc41ea7 100644 (file)
@@ -37,6 +37,7 @@
 #include "nfs4trace.h"
 #include "delegation.h"
 #include "nfs42.h"
+#include "nfs4_fs.h"
 
 #define NFSDBG_FACILITY                NFSDBG_PNFS
 #define PNFS_LAYOUTGET_RETRY_TIMEOUT (120*HZ)
@@ -915,45 +916,99 @@ pnfs_layoutgets_blocked(const struct pnfs_layout_hdr *lo)
                test_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags);
 }
 
-/*
- * Get layout from server.
- *    for now, assume that whole file layouts are requested.
- *    arg->offset: 0
- *    arg->length: all ones
- */
-static struct pnfs_layout_segment *
-send_layoutget(struct pnfs_layout_hdr *lo,
+static struct nfs_server *
+pnfs_find_server(struct inode *inode, struct nfs_open_context *ctx)
+{
+       struct nfs_server *server;
+
+       if (inode) {
+               server = NFS_SERVER(inode);
+       } else {
+               struct dentry *parent_dir = dget_parent(ctx->dentry);
+               server = NFS_SERVER(parent_dir->d_inode);
+               dput(parent_dir);
+       }
+       return server;
+}
+
+static void nfs4_free_pages(struct page **pages, size_t size)
+{
+       int i;
+
+       if (!pages)
+               return;
+
+       for (i = 0; i < size; i++) {
+               if (!pages[i])
+                       break;
+               __free_page(pages[i]);
+       }
+       kfree(pages);
+}
+
+static struct page **nfs4_alloc_pages(size_t size, gfp_t gfp_flags)
+{
+       struct page **pages;
+       int i;
+
+       pages = kcalloc(size, sizeof(struct page *), gfp_flags);
+       if (!pages) {
+               dprintk("%s: can't alloc array of %zu pages\n", __func__, size);
+               return NULL;
+       }
+
+       for (i = 0; i < size; i++) {
+               pages[i] = alloc_page(gfp_flags);
+               if (!pages[i]) {
+                       dprintk("%s: failed to allocate page\n", __func__);
+                       nfs4_free_pages(pages, size);
+                       return NULL;
+               }
+       }
+
+       return pages;
+}
+
+static struct nfs4_layoutget *
+pnfs_alloc_init_layoutget_args(struct inode *ino,
           struct nfs_open_context *ctx,
-          nfs4_stateid *stateid,
+          const nfs4_stateid *stateid,
           const struct pnfs_layout_range *range,
-          long *timeout, gfp_t gfp_flags)
+          gfp_t gfp_flags)
 {
-       struct inode *ino = lo->plh_inode;
-       struct nfs_server *server = NFS_SERVER(ino);
+       struct nfs_server *server = pnfs_find_server(ino, ctx);
+       size_t max_pages = max_response_pages(server);
        struct nfs4_layoutget *lgp;
-       loff_t i_size;
 
        dprintk("--> %s\n", __func__);
 
-       /*
-        * Synchronously retrieve layout information from server and
-        * store in lseg. If we race with a concurrent seqid morphing
-        * op, then re-send the LAYOUTGET.
-        */
        lgp = kzalloc(sizeof(*lgp), gfp_flags);
        if (lgp == NULL)
-               return ERR_PTR(-ENOMEM);
+               return NULL;
+
+       lgp->args.layout.pages = nfs4_alloc_pages(max_pages, gfp_flags);
+       if (!lgp->args.layout.pages) {
+               kfree(lgp);
+               return NULL;
+       }
+       lgp->args.layout.pglen = max_pages * PAGE_SIZE;
+       lgp->res.layoutp = &lgp->args.layout;
 
-       i_size = i_size_read(ino);
+       /* Don't confuse uninitialised result and success */
+       lgp->res.status = -NFS4ERR_DELAY;
 
        lgp->args.minlength = PAGE_SIZE;
        if (lgp->args.minlength > range->length)
                lgp->args.minlength = range->length;
-       if (range->iomode == IOMODE_READ) {
-               if (range->offset >= i_size)
-                       lgp->args.minlength = 0;
-               else if (i_size - range->offset < lgp->args.minlength)
-                       lgp->args.minlength = i_size - range->offset;
+       if (ino) {
+               loff_t i_size = i_size_read(ino);
+
+               if (range->iomode == IOMODE_READ) {
+                       if (range->offset >= i_size)
+                               lgp->args.minlength = 0;
+                       else if (i_size - range->offset < lgp->args.minlength)
+                               lgp->args.minlength = i_size - range->offset;
+               }
        }
        lgp->args.maxcount = PNFS_LAYOUT_MAXSIZE;
        pnfs_copy_range(&lgp->args.range, range);
@@ -962,9 +1017,21 @@ send_layoutget(struct pnfs_layout_hdr *lo,
        lgp->args.ctx = get_nfs_open_context(ctx);
        nfs4_stateid_copy(&lgp->args.stateid, stateid);
        lgp->gfp_flags = gfp_flags;
-       lgp->cred = lo->plh_lc_cred;
+       lgp->cred = get_rpccred(ctx->cred);
+       lgp->callback_count = raw_seqcount_begin(&server->nfs_client->cl_callback_count);
+       return lgp;
+}
 
-       return nfs4_proc_layoutget(lgp, timeout, gfp_flags);
+void pnfs_layoutget_free(struct nfs4_layoutget *lgp)
+{
+       size_t max_pages = lgp->args.layout.pglen / PAGE_SIZE;
+
+       nfs4_free_pages(lgp->args.layout.pages, max_pages);
+       if (lgp->args.inode)
+               pnfs_put_layout_hdr(NFS_I(lgp->args.inode)->layout);
+       put_rpccred(lgp->cred);
+       put_nfs_open_context(lgp->args.ctx);
+       kfree(lgp);
 }
 
 static void pnfs_clear_layoutcommit(struct inode *inode,
@@ -1144,7 +1211,7 @@ _pnfs_return_layout(struct inode *ino)
        LIST_HEAD(tmp_list);
        nfs4_stateid stateid;
        int status = 0;
-       bool send;
+       bool send, valid_layout;
 
        dprintk("NFS: %s for inode %lu\n", __func__, ino->i_ino);
 
@@ -1165,6 +1232,7 @@ _pnfs_return_layout(struct inode *ino)
                        goto out_put_layout_hdr;
                spin_lock(&ino->i_lock);
        }
+       valid_layout = pnfs_layout_is_valid(lo);
        pnfs_clear_layoutcommit(ino, &tmp_list);
        pnfs_mark_matching_lsegs_invalid(lo, &tmp_list, NULL, 0);
 
@@ -1178,7 +1246,8 @@ _pnfs_return_layout(struct inode *ino)
        }
 
        /* Don't send a LAYOUTRETURN if list was initially empty */
-       if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) {
+       if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags) ||
+                       !valid_layout) {
                spin_unlock(&ino->i_lock);
                dprintk("NFS: %s no layout segments to return\n", __func__);
                goto out_put_layout_hdr;
@@ -1671,6 +1740,22 @@ static void pnfs_clear_first_layoutget(struct pnfs_layout_hdr *lo)
        wake_up_bit(bitlock, NFS_LAYOUT_FIRST_LAYOUTGET);
 }
 
+static void _add_to_server_list(struct pnfs_layout_hdr *lo,
+                               struct nfs_server *server)
+{
+       if (list_empty(&lo->plh_layouts)) {
+               struct nfs_client *clp = server->nfs_client;
+
+               /* The lo must be on the clp list if there is any
+                * chance of a CB_LAYOUTRECALL(FILE) coming in.
+                */
+               spin_lock(&clp->cl_lock);
+               if (list_empty(&lo->plh_layouts))
+                       list_add_tail(&lo->plh_layouts, &server->layouts);
+               spin_unlock(&clp->cl_lock);
+       }
+}
+
 /*
  * Layout segment is retreived from the server if not cached.
  * The appropriate layout segment is referenced and returned to the caller.
@@ -1694,6 +1779,7 @@ pnfs_update_layout(struct inode *ino,
        struct nfs_client *clp = server->nfs_client;
        struct pnfs_layout_hdr *lo = NULL;
        struct pnfs_layout_segment *lseg = NULL;
+       struct nfs4_layoutget *lgp;
        nfs4_stateid stateid;
        long timeout = 0;
        unsigned long giveup = jiffies + (clp->cl_lease_time << 1);
@@ -1820,15 +1906,7 @@ pnfs_update_layout(struct inode *ino,
        atomic_inc(&lo->plh_outstanding);
        spin_unlock(&ino->i_lock);
 
-       if (list_empty(&lo->plh_layouts)) {
-               /* The lo must be on the clp list if there is any
-                * chance of a CB_LAYOUTRECALL(FILE) coming in.
-                */
-               spin_lock(&clp->cl_lock);
-               if (list_empty(&lo->plh_layouts))
-                       list_add_tail(&lo->plh_layouts, &server->layouts);
-               spin_unlock(&clp->cl_lock);
-       }
+       _add_to_server_list(lo, server);
 
        pg_offset = arg.offset & ~PAGE_MASK;
        if (pg_offset) {
@@ -1838,7 +1916,15 @@ pnfs_update_layout(struct inode *ino,
        if (arg.length != NFS4_MAX_UINT64)
                arg.length = PAGE_ALIGN(arg.length);
 
-       lseg = send_layoutget(lo, ctx, &stateid, &arg, &timeout, gfp_flags);
+       lgp = pnfs_alloc_init_layoutget_args(ino, ctx, &stateid, &arg, gfp_flags);
+       if (!lgp) {
+               trace_pnfs_update_layout(ino, pos, count, iomode, lo, NULL,
+                                        PNFS_UPDATE_LAYOUT_NOMEM);
+               atomic_dec(&lo->plh_outstanding);
+               goto out_put_layout_hdr;
+       }
+
+       lseg = nfs4_proc_layoutget(lgp, &timeout);
        trace_pnfs_update_layout(ino, pos, count, iomode, lo, lseg,
                                 PNFS_UPDATE_LAYOUT_SEND_LAYOUTGET);
        atomic_dec(&lo->plh_outstanding);
@@ -1919,6 +2005,171 @@ pnfs_sanity_check_layout_range(struct pnfs_layout_range *range)
        return true;
 }
 
+static struct pnfs_layout_hdr *
+_pnfs_grab_empty_layout(struct inode *ino, struct nfs_open_context *ctx)
+{
+       struct pnfs_layout_hdr *lo;
+
+       spin_lock(&ino->i_lock);
+       lo = pnfs_find_alloc_layout(ino, ctx, GFP_KERNEL);
+       if (!lo)
+               goto out_unlock;
+       if (!test_bit(NFS_LAYOUT_INVALID_STID, &lo->plh_flags))
+               goto out_unlock;
+       if (test_bit(NFS_LAYOUT_RETURN, &lo->plh_flags))
+               goto out_unlock;
+       if (pnfs_layoutgets_blocked(lo))
+               goto out_unlock;
+       if (test_and_set_bit(NFS_LAYOUT_FIRST_LAYOUTGET, &lo->plh_flags))
+               goto out_unlock;
+       atomic_inc(&lo->plh_outstanding);
+       spin_unlock(&ino->i_lock);
+       _add_to_server_list(lo, NFS_SERVER(ino));
+       return lo;
+
+out_unlock:
+       spin_unlock(&ino->i_lock);
+       pnfs_put_layout_hdr(lo);
+       return NULL;
+}
+
+extern const nfs4_stateid current_stateid;
+
+static void _lgopen_prepare_attached(struct nfs4_opendata *data,
+                                    struct nfs_open_context *ctx)
+{
+       struct inode *ino = data->dentry->d_inode;
+       struct pnfs_layout_range rng = {
+               .iomode = (data->o_arg.fmode & FMODE_WRITE) ?
+                         IOMODE_RW: IOMODE_READ,
+               .offset = 0,
+               .length = NFS4_MAX_UINT64,
+       };
+       struct nfs4_layoutget *lgp;
+       struct pnfs_layout_hdr *lo;
+
+       /* Heuristic: don't send layoutget if we have cached data */
+       if (rng.iomode == IOMODE_READ &&
+          (i_size_read(ino) == 0 || ino->i_mapping->nrpages != 0))
+               return;
+
+       lo = _pnfs_grab_empty_layout(ino, ctx);
+       if (!lo)
+               return;
+       lgp = pnfs_alloc_init_layoutget_args(ino, ctx, &current_stateid,
+                                            &rng, GFP_KERNEL);
+       if (!lgp) {
+               pnfs_clear_first_layoutget(lo);
+               pnfs_put_layout_hdr(lo);
+               return;
+       }
+       data->lgp = lgp;
+       data->o_arg.lg_args = &lgp->args;
+       data->o_res.lg_res = &lgp->res;
+}
+
+static void _lgopen_prepare_floating(struct nfs4_opendata *data,
+                                    struct nfs_open_context *ctx)
+{
+       struct pnfs_layout_range rng = {
+               .iomode = (data->o_arg.fmode & FMODE_WRITE) ?
+                         IOMODE_RW: IOMODE_READ,
+               .offset = 0,
+               .length = NFS4_MAX_UINT64,
+       };
+       struct nfs4_layoutget *lgp;
+
+       lgp = pnfs_alloc_init_layoutget_args(NULL, ctx, &current_stateid,
+                                            &rng, GFP_KERNEL);
+       if (!lgp)
+               return;
+       data->lgp = lgp;
+       data->o_arg.lg_args = &lgp->args;
+       data->o_res.lg_res = &lgp->res;
+}
+
+void pnfs_lgopen_prepare(struct nfs4_opendata *data,
+                        struct nfs_open_context *ctx)
+{
+       struct nfs_server *server = NFS_SERVER(data->dir->d_inode);
+
+       if (!(pnfs_enabled_sb(server) &&
+             server->pnfs_curr_ld->flags & PNFS_LAYOUTGET_ON_OPEN))
+               return;
+       /* Could check on max_ops, but currently hardcoded high enough */
+       if (!nfs_server_capable(data->dir->d_inode, NFS_CAP_LGOPEN))
+               return;
+       if (data->state)
+               _lgopen_prepare_attached(data, ctx);
+       else
+               _lgopen_prepare_floating(data, ctx);
+}
+
+void pnfs_parse_lgopen(struct inode *ino, struct nfs4_layoutget *lgp,
+                      struct nfs_open_context *ctx)
+{
+       struct pnfs_layout_hdr *lo;
+       struct pnfs_layout_segment *lseg;
+       struct nfs_server *srv = NFS_SERVER(ino);
+       u32 iomode;
+
+       if (!lgp)
+               return;
+       dprintk("%s: entered with status %i\n", __func__, lgp->res.status);
+       if (lgp->res.status) {
+               switch (lgp->res.status) {
+               default:
+                       break;
+               /*
+                * Halt lgopen attempts if the server doesn't recognise
+                * the "current stateid" value, the layout type, or the
+                * layoutget operation as being valid.
+                * Also if it complains about too many ops in the compound
+                * or of the request/reply being too big.
+                */
+               case -NFS4ERR_BAD_STATEID:
+               case -NFS4ERR_NOTSUPP:
+               case -NFS4ERR_REP_TOO_BIG:
+               case -NFS4ERR_REP_TOO_BIG_TO_CACHE:
+               case -NFS4ERR_REQ_TOO_BIG:
+               case -NFS4ERR_TOO_MANY_OPS:
+               case -NFS4ERR_UNKNOWN_LAYOUTTYPE:
+                       srv->caps &= ~NFS_CAP_LGOPEN;
+               }
+               return;
+       }
+       if (!lgp->args.inode) {
+               lo = _pnfs_grab_empty_layout(ino, ctx);
+               if (!lo)
+                       return;
+               lgp->args.inode = ino;
+       } else
+               lo = NFS_I(lgp->args.inode)->layout;
+
+       if (read_seqcount_retry(&srv->nfs_client->cl_callback_count,
+                               lgp->callback_count))
+               return;
+       lseg = pnfs_layout_process(lgp);
+       if (!IS_ERR(lseg)) {
+               iomode = lgp->args.range.iomode;
+               pnfs_layout_clear_fail_bit(lo, pnfs_iomode_to_fail_bit(iomode));
+               pnfs_put_lseg(lseg);
+       }
+}
+
+void nfs4_lgopen_release(struct nfs4_layoutget *lgp)
+{
+       if (lgp != NULL) {
+               struct inode *inode = lgp->args.inode;
+               if (inode) {
+                       struct pnfs_layout_hdr *lo = NFS_I(inode)->layout;
+                       atomic_dec(&lo->plh_outstanding);
+                       pnfs_clear_first_layoutget(lo);
+               }
+               pnfs_layoutget_free(lgp);
+       }
+}
+
 struct pnfs_layout_segment *
 pnfs_layout_process(struct nfs4_layoutget *lgp)
 {
@@ -1984,8 +2235,6 @@ pnfs_layout_process(struct nfs4_layoutget *lgp)
        spin_unlock(&ino->i_lock);
        lseg->pls_layout = lo;
        NFS_SERVER(ino)->pnfs_curr_ld->free_lseg(lseg);
-       if (!pnfs_layout_is_valid(lo))
-               nfs_commit_inode(ino, 0);
        return ERR_PTR(-EAGAIN);
 }
 
index daf6cbf5c15f549c1ec5c16e5b7b958d243bad45..a8f5e6b167491e3746a921f1f611fbb06b7d5f45 100644 (file)
@@ -35,6 +35,8 @@
 #include <linux/nfs_page.h>
 #include <linux/workqueue.h>
 
+struct nfs4_opendata;
+
 enum {
        NFS_LSEG_VALID = 0,     /* cleared when lseg is recalled/returned */
        NFS_LSEG_ROC,           /* roc bit received from server */
@@ -110,6 +112,7 @@ enum layoutdriver_policy_flags {
        PNFS_LAYOUTRET_ON_SETATTR       = 1 << 0,
        PNFS_LAYOUTRET_ON_ERROR         = 1 << 1,
        PNFS_READ_WHOLE_PAGE            = 1 << 2,
+       PNFS_LAYOUTGET_ON_OPEN          = 1 << 3,
 };
 
 struct nfs4_deviceid_node;
@@ -223,10 +226,11 @@ extern int pnfs_register_layoutdriver(struct pnfs_layoutdriver_type *);
 extern void pnfs_unregister_layoutdriver(struct pnfs_layoutdriver_type *);
 
 /* nfs4proc.c */
+extern size_t max_response_pages(struct nfs_server *server);
 extern int nfs4_proc_getdeviceinfo(struct nfs_server *server,
                                   struct pnfs_device *dev,
                                   struct rpc_cred *cred);
-extern struct pnfs_layout_segment* nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout, gfp_t gfp_flags);
+extern struct pnfs_layout_segment* nfs4_proc_layoutget(struct nfs4_layoutget *lgp, long *timeout);
 extern int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync);
 
 /* pnfs.c */
@@ -246,6 +250,7 @@ size_t pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio,
                            struct nfs_page *prev, struct nfs_page *req);
 void pnfs_set_lo_fail(struct pnfs_layout_segment *lseg);
 struct pnfs_layout_segment *pnfs_layout_process(struct nfs4_layoutget *lgp);
+void pnfs_layoutget_free(struct nfs4_layoutget *lgp);
 void pnfs_free_lseg_list(struct list_head *tmp_list);
 void pnfs_destroy_layout(struct nfs_inode *);
 void pnfs_destroy_all_layouts(struct nfs_client *);
@@ -375,6 +380,11 @@ void pnfs_layout_mark_request_commit(struct nfs_page *req,
                                     struct pnfs_layout_segment *lseg,
                                     struct nfs_commit_info *cinfo,
                                     u32 ds_commit_idx);
+void pnfs_lgopen_prepare(struct nfs4_opendata *data,
+                        struct nfs_open_context *ctx);
+void pnfs_parse_lgopen(struct inode *ino, struct nfs4_layoutget *lgp,
+                      struct nfs_open_context *ctx);
+void nfs4_lgopen_release(struct nfs4_layoutget *lgp);
 
 static inline bool nfs_have_layout(struct inode *inode)
 {
@@ -775,6 +785,22 @@ static inline bool nfs4_refresh_layout_stateid(nfs4_stateid *dst,
 {
        return false;
 }
+
+static inline void pnfs_lgopen_prepare(struct nfs4_opendata *data,
+               struct nfs_open_context *ctx)
+{
+}
+
+static inline void pnfs_parse_lgopen(struct inode *ino,
+               struct nfs4_layoutget *lgp,
+               struct nfs_open_context *ctx)
+{
+}
+
+static inline void nfs4_lgopen_release(struct nfs4_layoutget *lgp)
+{
+}
+
 #endif /* CONFIG_NFS_V4_1 */
 
 #if IS_ENABLED(CONFIG_NFS_V4_2)
index 4e93d63087338be524918512085c2e2f5a071cdb..e0c257bd62b938372f957b58177458fe37c9f0da 100644 (file)
@@ -99,7 +99,8 @@ nfs_proc_get_root(struct nfs_server *server, struct nfs_fh *fhandle,
  */
 static int
 nfs_proc_getattr(struct nfs_server *server, struct nfs_fh *fhandle,
-               struct nfs_fattr *fattr, struct nfs4_label *label)
+               struct nfs_fattr *fattr, struct nfs4_label *label,
+               struct inode *inode)
 {
        struct rpc_message msg = {
                .rpc_proc       = &nfs_procedures[NFSPROC_GETATTR],
@@ -321,7 +322,9 @@ nfs_proc_remove(struct inode *dir, struct dentry *dentry)
 }
 
 static void
-nfs_proc_unlink_setup(struct rpc_message *msg, struct dentry *dentry)
+nfs_proc_unlink_setup(struct rpc_message *msg,
+               struct dentry *dentry,
+               struct inode *inode)
 {
        msg->rpc_proc = &nfs_procedures[NFSPROC_REMOVE];
 }
@@ -618,7 +621,8 @@ static int nfs_write_done(struct rpc_task *task, struct nfs_pgio_header *hdr)
 }
 
 static void nfs_proc_write_setup(struct nfs_pgio_header *hdr,
-                                struct rpc_message *msg)
+                                struct rpc_message *msg,
+                                struct rpc_clnt **clnt)
 {
        /* Note: NFSv2 ignores @stable and always uses NFS_FILE_SYNC */
        hdr->args.stable = NFS_FILE_SYNC;
@@ -631,7 +635,8 @@ static void nfs_proc_commit_rpc_prepare(struct rpc_task *task, struct nfs_commit
 }
 
 static void
-nfs_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg)
+nfs_proc_commit_setup(struct nfs_commit_data *data, struct rpc_message *msg,
+                       struct rpc_clnt **clnt)
 {
        BUG();
 }
index bf54fc9ae135fa3098bbfb4e713835cabde77c20..fd61bf0fce63acf21c3219196a463735f3032f83 100644 (file)
@@ -85,7 +85,7 @@ static const struct rpc_call_ops nfs_unlink_ops = {
        .rpc_call_prepare = nfs_unlink_prepare,
 };
 
-static void nfs_do_call_unlink(struct nfs_unlinkdata *data)
+static void nfs_do_call_unlink(struct inode *inode, struct nfs_unlinkdata *data)
 {
        struct rpc_message msg = {
                .rpc_argp = &data->args,
@@ -105,7 +105,7 @@ static void nfs_do_call_unlink(struct nfs_unlinkdata *data)
        data->args.fh = NFS_FH(dir);
        nfs_fattr_init(data->res.dir_attr);
 
-       NFS_PROTO(dir)->unlink_setup(&msg, data->dentry);
+       NFS_PROTO(dir)->unlink_setup(&msg, data->dentry, inode);
 
        task_setup_data.rpc_client = NFS_CLIENT(dir);
        task = rpc_run_task(&task_setup_data);
@@ -113,7 +113,7 @@ static void nfs_do_call_unlink(struct nfs_unlinkdata *data)
                rpc_put_task_async(task);
 }
 
-static int nfs_call_unlink(struct dentry *dentry, struct nfs_unlinkdata *data)
+static int nfs_call_unlink(struct dentry *dentry, struct inode *inode, struct nfs_unlinkdata *data)
 {
        struct inode *dir = d_inode(dentry->d_parent);
        struct dentry *alias;
@@ -153,7 +153,7 @@ static int nfs_call_unlink(struct dentry *dentry, struct nfs_unlinkdata *data)
                return ret;
        }
        data->dentry = alias;
-       nfs_do_call_unlink(data);
+       nfs_do_call_unlink(inode, data);
        return 1;
 }
 
@@ -231,7 +231,7 @@ nfs_complete_unlink(struct dentry *dentry, struct inode *inode)
        dentry->d_fsdata = NULL;
        spin_unlock(&dentry->d_lock);
 
-       if (NFS_STALE(inode) || !nfs_call_unlink(dentry, data))
+       if (NFS_STALE(inode) || !nfs_call_unlink(dentry, inode, data))
                nfs_free_unlinkdata(data);
 }
 
@@ -448,6 +448,7 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
        unsigned char silly[SILLYNAME_LEN + 1];
        unsigned long long fileid;
        struct dentry *sdentry;
+       struct inode *inode = d_inode(dentry);
        struct rpc_task *task;
        int            error = -EBUSY;
 
@@ -485,6 +486,8 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
                        goto out;
        } while (d_inode(sdentry) != NULL); /* need negative lookup */
 
+       ihold(inode);
+
        /* queue unlink first. Can't do this from rpc_release as it
         * has to allocate memory
         */
@@ -509,6 +512,12 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
        case 0:
                /* The rename succeeded */
                nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
+               spin_lock(&inode->i_lock);
+               NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
+               NFS_I(inode)->cache_validity |= NFS_INO_INVALID_CHANGE
+                       | NFS_INO_INVALID_CTIME
+                       | NFS_INO_REVAL_FORCED;
+               spin_unlock(&inode->i_lock);
                d_move(dentry, sdentry);
                break;
        case -ERESTARTSYS:
@@ -519,6 +528,7 @@ nfs_sillyrename(struct inode *dir, struct dentry *dentry)
        }
        rpc_put_task(task);
 out_dput:
+       iput(inode);
        dput(sdentry);
 out:
        return error;
index 0193053bc139d3228602d589dbb643206e970dba..a057b4f45a468dd695202f5462787cfd8d2dc0fa 100644 (file)
@@ -1375,12 +1375,9 @@ static void nfs_initiate_write(struct nfs_pgio_header *hdr,
        int priority = flush_task_priority(how);
 
        task_setup_data->priority = priority;
-       rpc_ops->write_setup(hdr, msg);
+       rpc_ops->write_setup(hdr, msg, &task_setup_data->rpc_client);
        trace_nfs_initiate_write(hdr->inode, hdr->io_start, hdr->good_bytes,
                                 hdr->args.stable);
-
-       nfs4_state_protect_write(NFS_SERVER(hdr->inode)->nfs_client,
-                                &task_setup_data->rpc_client, msg, hdr);
 }
 
 /* If a nfs_flush_* function fails, it should remove reqs from @head and
@@ -1669,14 +1666,11 @@ int nfs_initiate_commit(struct rpc_clnt *clnt, struct nfs_commit_data *data,
                .priority = priority,
        };
        /* Set up the initial task struct.  */
-       nfs_ops->commit_setup(data, &msg);
+       nfs_ops->commit_setup(data, &msg, &task_setup_data.rpc_client);
        trace_nfs_initiate_commit(data);
 
        dprintk("NFS: initiated commit call\n");
 
-       nfs4_state_protect(NFS_SERVER(data->inode)->nfs_client,
-               NFS_SP4_MACH_CRED_COMMIT, &task_setup_data.rpc_client, &msg);
-
        task = rpc_run_task(&task_setup_data);
        if (IS_ERR(task))
                return PTR_ERR(task);
index a43dfedd69ec0ee91822e2513663719c31796724..4fb1f72a25fb3de83d2d3c5c8e38dff4ec4eac20 100644 (file)
@@ -121,13 +121,15 @@ nfsd4_block_commit_blocks(struct inode *inode, struct nfsd4_layoutcommit *lcp,
 {
        loff_t new_size = lcp->lc_last_wr + 1;
        struct iattr iattr = { .ia_valid = 0 };
+       struct timespec ts;
        int error;
 
+       ts = timespec64_to_timespec(inode->i_mtime);
        if (lcp->lc_mtime.tv_nsec == UTIME_NOW ||
-           timespec_compare(&lcp->lc_mtime, &inode->i_mtime) < 0)
-               lcp->lc_mtime = current_time(inode);
+           timespec_compare(&lcp->lc_mtime, &ts) < 0)
+               lcp->lc_mtime = timespec64_to_timespec(current_time(inode));
        iattr.ia_valid |= ATTR_ATIME | ATTR_CTIME | ATTR_MTIME;
-       iattr.ia_atime = iattr.ia_ctime = iattr.ia_mtime = lcp->lc_mtime;
+       iattr.ia_atime = iattr.ia_ctime = iattr.ia_mtime = timespec_to_timespec64(lcp->lc_mtime);
 
        if (new_size > i_size_read(inode)) {
                iattr.ia_valid |= ATTR_SIZE;
@@ -216,13 +218,21 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,
        struct request_queue *q = bdev->bd_disk->queue;
        struct request *rq;
        struct scsi_request *req;
-       size_t bufflen = 252, len, id_len;
+       /*
+        * The allocation length (passed in bytes 3 and 4 of the INQUIRY
+        * command descriptor block) specifies the number of bytes that have
+        * been allocated for the data-in buffer.
+        * 252 is the highest one-byte value that is a multiple of 4.
+        * 65532 is the highest two-byte value that is a multiple of 4.
+        */
+       size_t bufflen = 252, maxlen = 65532, len, id_len;
        u8 *buf, *d, type, assoc;
-       int error;
+       int retries = 1, error;
 
        if (WARN_ON_ONCE(!blk_queue_scsi_passthrough(q)))
                return -EINVAL;
 
+again:
        buf = kzalloc(bufflen, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
@@ -255,6 +265,12 @@ static int nfsd4_scsi_identify_device(struct block_device *bdev,
 
        len = (buf[2] << 8) + buf[3] + 4;
        if (len > bufflen) {
+               if (len <= maxlen && retries--) {
+                       blk_put_request(rq);
+                       kfree(buf);
+                       bufflen = len;
+                       goto again;
+               }
                pr_err("pNFS: INQUIRY 0x83 response invalid (len = %zd)\n",
                        len);
                goto out_put_request;
index 046b3f04875745019abc3247b2e7e479d96d9dd8..b7559c6f2b9767609f0832f0fb5e0fb80d51fce0 100644 (file)
@@ -67,11 +67,6 @@ enum {
        RC_REPLBUFF,
 };
 
-/*
- * If requests are retransmitted within this interval, they're dropped.
- */
-#define RC_DELAY               (HZ/5)
-
 /* Cache entries expire after this time period */
 #define RC_EXPIRE              (120 * HZ)
 
index 8ceb25a10ea0df002cae637d137d0f0e0d55a93b..a1143f7c220153c0809cb8dd43da895a685fe98b 100644 (file)
@@ -404,8 +404,9 @@ fsloc_parse(char **mesg, char *buf, struct nfsd4_fs_locations *fsloc)
        if (fsloc->locations_count == 0)
                return 0;
 
-       fsloc->locations = kzalloc(fsloc->locations_count
-                       * sizeof(struct nfsd4_fs_location), GFP_KERNEL);
+       fsloc->locations = kcalloc(fsloc->locations_count,
+                                  sizeof(struct nfsd4_fs_location),
+                                  GFP_KERNEL);
        if (!fsloc->locations)
                return -ENOMEM;
        for (i=0; i < fsloc->locations_count; i++) {
index 3192b544a441506567423dc3b92c0200a76b80cf..9b973f4f7d01c5f67d7042c72a1663780f8f7b42 100644 (file)
@@ -165,6 +165,7 @@ static __be32 *
 encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
              struct kstat *stat)
 {
+       struct timespec ts;
        *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
        *p++ = htonl((u32) (stat->mode & S_IALLUGO));
        *p++ = htonl((u32) stat->nlink);
@@ -180,9 +181,12 @@ encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
        *p++ = htonl((u32) MINOR(stat->rdev));
        p = encode_fsid(p, fhp);
        p = xdr_encode_hyper(p, stat->ino);
-       p = encode_time3(p, &stat->atime);
-       p = encode_time3(p, &stat->mtime);
-       p = encode_time3(p, &stat->ctime);
+       ts = timespec64_to_timespec(stat->atime);
+       p = encode_time3(p, &ts);
+       ts = timespec64_to_timespec(stat->mtime);
+       p = encode_time3(p, &ts);
+       ts = timespec64_to_timespec(stat->ctime);
+       p = encode_time3(p, &ts);
 
        return p;
 }
@@ -271,8 +275,8 @@ void fill_pre_wcc(struct svc_fh *fhp)
                stat.size  = inode->i_size;
        }
 
-       fhp->fh_pre_mtime = stat.mtime;
-       fhp->fh_pre_ctime = stat.ctime;
+       fhp->fh_pre_mtime = timespec64_to_timespec(stat.mtime);
+       fhp->fh_pre_ctime = timespec64_to_timespec(stat.ctime);
        fhp->fh_pre_size  = stat.size;
        fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode);
        fhp->fh_pre_saved = true;
index 66eaeb1e8c2ce75559d4b03c36ab7a16bda56af5..9c247fa1e95940564857fd585a7a539f64a3a977 100644 (file)
@@ -510,8 +510,9 @@ nfs4_legacy_state_init(struct net *net)
        struct nfsd_net *nn = net_generic(net, nfsd_net_id);
        int i;
 
-       nn->reclaim_str_hashtbl = kmalloc(sizeof(struct list_head) *
-                                         CLIENT_HASH_SIZE, GFP_KERNEL);
+       nn->reclaim_str_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
+                                               sizeof(struct list_head),
+                                               GFP_KERNEL);
        if (!nn->reclaim_str_hashtbl)
                return -ENOMEM;
 
index fc74d6f46bd5d17a2adf89a4d2ddc80f9e5c44cd..857141446d6b378cbdfcb09c8ec5b2df5c319d6d 100644 (file)
@@ -1807,8 +1807,9 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name)
        clp->cl_name.data = kmemdup(name.data, name.len, GFP_KERNEL);
        if (clp->cl_name.data == NULL)
                goto err_no_name;
-       clp->cl_ownerstr_hashtbl = kmalloc(sizeof(struct list_head) *
-                       OWNER_HASH_SIZE, GFP_KERNEL);
+       clp->cl_ownerstr_hashtbl = kmalloc_array(OWNER_HASH_SIZE,
+                                                sizeof(struct list_head),
+                                                GFP_KERNEL);
        if (!clp->cl_ownerstr_hashtbl)
                goto err_no_hashtbl;
        for (i = 0; i < OWNER_HASH_SIZE; i++)
@@ -4378,8 +4379,11 @@ nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh,
        spin_unlock(&state_lock);
 
        if (status)
-               destroy_unhashed_deleg(dp);
+               goto out_unlock;
+
        return dp;
+out_unlock:
+       vfs_setlease(fp->fi_deleg_file, F_UNLCK, NULL, (void **)&dp);
 out_clnt_odstate:
        put_clnt_odstate(dp->dl_clnt_odstate);
 out_stid:
@@ -7093,16 +7097,19 @@ static int nfs4_state_create_net(struct net *net)
        struct nfsd_net *nn = net_generic(net, nfsd_net_id);
        int i;
 
-       nn->conf_id_hashtbl = kmalloc(sizeof(struct list_head) *
-                       CLIENT_HASH_SIZE, GFP_KERNEL);
+       nn->conf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
+                                           sizeof(struct list_head),
+                                           GFP_KERNEL);
        if (!nn->conf_id_hashtbl)
                goto err;
-       nn->unconf_id_hashtbl = kmalloc(sizeof(struct list_head) *
-                       CLIENT_HASH_SIZE, GFP_KERNEL);
+       nn->unconf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
+                                             sizeof(struct list_head),
+                                             GFP_KERNEL);
        if (!nn->unconf_id_hashtbl)
                goto err_unconf_id;
-       nn->sessionid_hashtbl = kmalloc(sizeof(struct list_head) *
-                       SESSION_HASH_SIZE, GFP_KERNEL);
+       nn->sessionid_hashtbl = kmalloc_array(SESSION_HASH_SIZE,
+                                             sizeof(struct list_head),
+                                             GFP_KERNEL);
        if (!nn->sessionid_hashtbl)
                goto err_sessionid;
 
index 1d048dd95464683477401cb8db88771b0dc8fb71..a96843c59fc146f1abb8c3a623984f29a083fefb 100644 (file)
@@ -320,6 +320,7 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
                   struct iattr *iattr, struct nfs4_acl **acl,
                   struct xdr_netobj *label, int *umask)
 {
+       struct timespec ts;
        int expected_len, len = 0;
        u32 dummy32;
        char *buf;
@@ -421,7 +422,8 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
                switch (dummy32) {
                case NFS4_SET_TO_CLIENT_TIME:
                        len += 12;
-                       status = nfsd4_decode_time(argp, &iattr->ia_atime);
+                       status = nfsd4_decode_time(argp, &ts);
+                       iattr->ia_atime = timespec_to_timespec64(ts);
                        if (status)
                                return status;
                        iattr->ia_valid |= (ATTR_ATIME | ATTR_ATIME_SET);
@@ -440,7 +442,8 @@ nfsd4_decode_fattr(struct nfsd4_compoundargs *argp, u32 *bmval,
                switch (dummy32) {
                case NFS4_SET_TO_CLIENT_TIME:
                        len += 12;
-                       status = nfsd4_decode_time(argp, &iattr->ia_mtime);
+                       status = nfsd4_decode_time(argp, &ts);
+                       iattr->ia_mtime = timespec_to_timespec64(ts);
                        if (status)
                                return status;
                        iattr->ia_valid |= (ATTR_MTIME | ATTR_MTIME_SET);
@@ -1585,6 +1588,8 @@ nfsd4_decode_getdeviceinfo(struct nfsd4_compoundargs *argp,
        gdev->gd_maxcount = be32_to_cpup(p++);
        num = be32_to_cpup(p++);
        if (num) {
+               if (num > 1000)
+                       goto xdr_error;
                READ_BUF(4 * num);
                gdev->gd_notify_types = be32_to_cpup(p++);
                for (i = 1; i < num; i++) {
@@ -3651,7 +3656,8 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
                nfserr = nfserr_resource;
                goto err_no_verf;
        }
-       maxcount = min_t(u32, readdir->rd_maxcount, INT_MAX);
+       maxcount = svc_max_payload(resp->rqstp);
+       maxcount = min_t(u32, readdir->rd_maxcount, maxcount);
        /*
         * Note the rfc defines rd_maxcount as the size of the
         * READDIR4resok structure, which includes the verifier above
@@ -3665,7 +3671,7 @@ nfsd4_encode_readdir(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4
 
        /* RFC 3530 14.2.24 allows us to ignore dircount when it's 0: */
        if (!readdir->rd_dircount)
-               readdir->rd_dircount = INT_MAX;
+               readdir->rd_dircount = svc_max_payload(resp->rqstp);
 
        readdir->xdr = xdr;
        readdir->rd_maxcount = maxcount;
index 334f2ad6070491d2302e93fd7fc87b6603c325f7..dbdeb9d6af0392e3017b1ed73feebc993397c269 100644 (file)
@@ -177,7 +177,8 @@ int nfsd_reply_cache_init(void)
 
        drc_hashtbl = kcalloc(hashsize, sizeof(*drc_hashtbl), GFP_KERNEL);
        if (!drc_hashtbl) {
-               drc_hashtbl = vzalloc(hashsize * sizeof(*drc_hashtbl));
+               drc_hashtbl = vzalloc(array_size(hashsize,
+                                                sizeof(*drc_hashtbl)));
                if (!drc_hashtbl)
                        goto out_nomem;
        }
@@ -394,7 +395,6 @@ nfsd_cache_lookup(struct svc_rqst *rqstp)
        __wsum                  csum;
        u32 hash = nfsd_cache_hash(xid);
        struct nfsd_drc_bucket *b = &drc_hashtbl[hash];
-       unsigned long           age;
        int type = rqstp->rq_cachetype;
        int rtn = RC_DOIT;
 
@@ -461,12 +461,11 @@ nfsd_cache_lookup(struct svc_rqst *rqstp)
 found_entry:
        nfsdstats.rchits++;
        /* We found a matching entry which is either in progress or done. */
-       age = jiffies - rp->c_timestamp;
        lru_put_end(b, rp);
 
        rtn = RC_DROPIT;
-       /* Request being processed or excessive rexmits */
-       if (rp->c_state == RC_INPROG || age < RC_DELAY)
+       /* Request being processed */
+       if (rp->c_state == RC_INPROG)
                goto out;
 
        /* From the hall of fame of impractical attacks:
index a43e8260520af9980e8c3374781c937c9d8df3b0..6b2e8b73d36e3a4459e6b76bf057543884673a86 100644 (file)
@@ -131,7 +131,7 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
 {
        struct dentry   *dentry = fhp->fh_dentry;
        int type;
-       struct timespec time;
+       struct timespec64 time;
        u32 f;
 
        type = (stat->mode & S_IFMT);
index 63a1ca4b9deee22a786822229b8421bcdcf74e31..e2bea2ac5dfb2809ae9460edce3a58916456c9ef 100644 (file)
@@ -79,12 +79,11 @@ static void dnotify_recalc_inode_mask(struct fsnotify_mark *fsn_mark)
  */
 static int dnotify_handle_event(struct fsnotify_group *group,
                                struct inode *inode,
-                               struct fsnotify_mark *inode_mark,
-                               struct fsnotify_mark *vfsmount_mark,
                                u32 mask, const void *data, int data_type,
                                const unsigned char *file_name, u32 cookie,
                                struct fsnotify_iter_info *iter_info)
 {
+       struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);
        struct dnotify_mark *dn_mark;
        struct dnotify_struct *dn;
        struct dnotify_struct **prev;
@@ -95,7 +94,8 @@ static int dnotify_handle_event(struct fsnotify_group *group,
        if (!S_ISDIR(inode->i_mode))
                return 0;
 
-       BUG_ON(vfsmount_mark);
+       if (WARN_ON(fsnotify_iter_vfsmount_mark(iter_info)))
+               return 0;
 
        dn_mark = container_of(inode_mark, struct dnotify_mark, fsn_mark);
 
@@ -319,7 +319,7 @@ int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)
                dn_mark = container_of(fsn_mark, struct dnotify_mark, fsn_mark);
                spin_lock(&fsn_mark->lock);
        } else {
-               error = fsnotify_add_mark_locked(new_fsn_mark, inode, NULL, 0);
+               error = fsnotify_add_inode_mark_locked(new_fsn_mark, inode, 0);
                if (error) {
                        mutex_unlock(&dnotify_group->mark_mutex);
                        goto out_err;
index d94e8031fe5fb8e95a168a475ad0069df3016465..f90842efea13c95390e85cb22897cadbaa376700 100644 (file)
@@ -87,17 +87,17 @@ static int fanotify_get_response(struct fsnotify_group *group,
        return ret;
 }
 
-static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark,
-                                      struct fsnotify_mark *vfsmnt_mark,
-                                      u32 event_mask,
-                                      const void *data, int data_type)
+static bool fanotify_should_send_event(struct fsnotify_iter_info *iter_info,
+                                      u32 event_mask, const void *data,
+                                      int data_type)
 {
        __u32 marks_mask = 0, marks_ignored_mask = 0;
        const struct path *path = data;
+       struct fsnotify_mark *mark;
+       int type;
 
-       pr_debug("%s: inode_mark=%p vfsmnt_mark=%p mask=%x data=%p"
-                " data_type=%d\n", __func__, inode_mark, vfsmnt_mark,
-                event_mask, data, data_type);
+       pr_debug("%s: report_mask=%x mask=%x data=%p data_type=%d\n",
+                __func__, iter_info->report_mask, event_mask, data, data_type);
 
        /* if we don't have enough info to send an event to userspace say no */
        if (data_type != FSNOTIFY_EVENT_PATH)
@@ -108,20 +108,21 @@ static bool fanotify_should_send_event(struct fsnotify_mark *inode_mark,
            !d_can_lookup(path->dentry))
                return false;
 
-       /*
-        * if the event is for a child and this inode doesn't care about
-        * events on the child, don't send it!
-        */
-       if (inode_mark &&
-           (!(event_mask & FS_EVENT_ON_CHILD) ||
-            (inode_mark->mask & FS_EVENT_ON_CHILD))) {
-               marks_mask |= inode_mark->mask;
-               marks_ignored_mask |= inode_mark->ignored_mask;
-       }
+       fsnotify_foreach_obj_type(type) {
+               if (!fsnotify_iter_should_report_type(iter_info, type))
+                       continue;
+               mark = iter_info->marks[type];
+               /*
+                * if the event is for a child and this inode doesn't care about
+                * events on the child, don't send it!
+                */
+               if (type == FSNOTIFY_OBJ_TYPE_INODE &&
+                   (event_mask & FS_EVENT_ON_CHILD) &&
+                   !(mark->mask & FS_EVENT_ON_CHILD))
+                       continue;
 
-       if (vfsmnt_mark) {
-               marks_mask |= vfsmnt_mark->mask;
-               marks_ignored_mask |= vfsmnt_mark->ignored_mask;
+               marks_mask |= mark->mask;
+               marks_ignored_mask |= mark->ignored_mask;
        }
 
        if (d_is_dir(path->dentry) &&
@@ -178,8 +179,6 @@ init: __maybe_unused
 
 static int fanotify_handle_event(struct fsnotify_group *group,
                                 struct inode *inode,
-                                struct fsnotify_mark *inode_mark,
-                                struct fsnotify_mark *fanotify_mark,
                                 u32 mask, const void *data, int data_type,
                                 const unsigned char *file_name, u32 cookie,
                                 struct fsnotify_iter_info *iter_info)
@@ -199,8 +198,7 @@ static int fanotify_handle_event(struct fsnotify_group *group,
        BUILD_BUG_ON(FAN_ACCESS_PERM != FS_ACCESS_PERM);
        BUILD_BUG_ON(FAN_ONDIR != FS_ISDIR);
 
-       if (!fanotify_should_send_event(inode_mark, fanotify_mark, mask, data,
-                                       data_type))
+       if (!fanotify_should_send_event(iter_info, mask, data, data_type))
                return 0;
 
        pr_debug("%s: group=%p inode=%p mask=%x\n", __func__, group, inode,
index d478629c728beabe160468903fe59ca7500c2f77..10aac1942c9f32e537c9b102429c10340daaa323 100644 (file)
@@ -77,7 +77,7 @@ static void inotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
        struct inotify_inode_mark *inode_mark;
        struct inode *inode;
 
-       if (!(mark->connector->flags & FSNOTIFY_OBJ_TYPE_INODE))
+       if (mark->connector->type != FSNOTIFY_OBJ_TYPE_INODE)
                return;
 
        inode_mark = container_of(mark, struct inotify_inode_mark, fsn_mark);
@@ -116,7 +116,7 @@ static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
        if (mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY)
                mflags |= FAN_MARK_IGNORED_SURV_MODIFY;
 
-       if (mark->connector->flags & FSNOTIFY_OBJ_TYPE_INODE) {
+       if (mark->connector->type == FSNOTIFY_OBJ_TYPE_INODE) {
                inode = igrab(mark->connector->inode);
                if (!inode)
                        return;
@@ -126,7 +126,7 @@ static void fanotify_fdinfo(struct seq_file *m, struct fsnotify_mark *mark)
                show_mark_fhandle(m, inode);
                seq_putc(m, '\n');
                iput(inode);
-       } else if (mark->connector->flags & FSNOTIFY_OBJ_TYPE_VFSMOUNT) {
+       } else if (mark->connector->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT) {
                struct mount *mnt = real_mount(mark->connector->mnt);
 
                seq_printf(m, "fanotify mnt_id:%x mflags:%x mask:%x ignored_mask:%x\n",
index 613ec7e5a46582e4e2e03b1d623e9822017ddc5a..f174397b63a046f32ca24a7be30080c4ff5fe009 100644 (file)
@@ -184,8 +184,6 @@ int __fsnotify_parent(const struct path *path, struct dentry *dentry, __u32 mask
 EXPORT_SYMBOL_GPL(__fsnotify_parent);
 
 static int send_to_group(struct inode *to_tell,
-                        struct fsnotify_mark *inode_mark,
-                        struct fsnotify_mark *vfsmount_mark,
                         __u32 mask, const void *data,
                         int data_is, u32 cookie,
                         const unsigned char *file_name,
@@ -195,48 +193,45 @@ static int send_to_group(struct inode *to_tell,
        __u32 test_mask = (mask & ~FS_EVENT_ON_CHILD);
        __u32 marks_mask = 0;
        __u32 marks_ignored_mask = 0;
+       struct fsnotify_mark *mark;
+       int type;
 
-       if (unlikely(!inode_mark && !vfsmount_mark)) {
-               BUG();
+       if (WARN_ON(!iter_info->report_mask))
                return 0;
-       }
 
        /* clear ignored on inode modification */
        if (mask & FS_MODIFY) {
-               if (inode_mark &&
-                   !(inode_mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY))
-                       inode_mark->ignored_mask = 0;
-               if (vfsmount_mark &&
-                   !(vfsmount_mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY))
-                       vfsmount_mark->ignored_mask = 0;
-       }
-
-       /* does the inode mark tell us to do something? */
-       if (inode_mark) {
-               group = inode_mark->group;
-               marks_mask |= inode_mark->mask;
-               marks_ignored_mask |= inode_mark->ignored_mask;
+               fsnotify_foreach_obj_type(type) {
+                       if (!fsnotify_iter_should_report_type(iter_info, type))
+                               continue;
+                       mark = iter_info->marks[type];
+                       if (mark &&
+                           !(mark->flags & FSNOTIFY_MARK_FLAG_IGNORED_SURV_MODIFY))
+                               mark->ignored_mask = 0;
+               }
        }
 
-       /* does the vfsmount_mark tell us to do something? */
-       if (vfsmount_mark) {
-               group = vfsmount_mark->group;
-               marks_mask |= vfsmount_mark->mask;
-               marks_ignored_mask |= vfsmount_mark->ignored_mask;
+       fsnotify_foreach_obj_type(type) {
+               if (!fsnotify_iter_should_report_type(iter_info, type))
+                       continue;
+               mark = iter_info->marks[type];
+               /* does the object mark tell us to do something? */
+               if (mark) {
+                       group = mark->group;
+                       marks_mask |= mark->mask;
+                       marks_ignored_mask |= mark->ignored_mask;
+               }
        }
 
-       pr_debug("%s: group=%p to_tell=%p mask=%x inode_mark=%p"
-                " vfsmount_mark=%p marks_mask=%x marks_ignored_mask=%x"
+       pr_debug("%s: group=%p to_tell=%p mask=%x marks_mask=%x marks_ignored_mask=%x"
                 " data=%p data_is=%d cookie=%d\n",
-                __func__, group, to_tell, mask, inode_mark, vfsmount_mark,
-                marks_mask, marks_ignored_mask, data,
-                data_is, cookie);
+                __func__, group, to_tell, mask, marks_mask, marks_ignored_mask,
+                data, data_is, cookie);
 
        if (!(test_mask & marks_mask & ~marks_ignored_mask))
                return 0;
 
-       return group->ops->handle_event(group, to_tell, inode_mark,
-                                       vfsmount_mark, mask, data, data_is,
+       return group->ops->handle_event(group, to_tell, mask, data, data_is,
                                        file_name, cookie, iter_info);
 }
 
@@ -263,6 +258,57 @@ static struct fsnotify_mark *fsnotify_next_mark(struct fsnotify_mark *mark)
        return hlist_entry_safe(node, struct fsnotify_mark, obj_list);
 }
 
+/*
+ * iter_info is a multi head priority queue of marks.
+ * Pick a subset of marks from queue heads, all with the
+ * same group and set the report_mask for selected subset.
+ * Returns the report_mask of the selected subset.
+ */
+static unsigned int fsnotify_iter_select_report_types(
+               struct fsnotify_iter_info *iter_info)
+{
+       struct fsnotify_group *max_prio_group = NULL;
+       struct fsnotify_mark *mark;
+       int type;
+
+       /* Choose max prio group among groups of all queue heads */
+       fsnotify_foreach_obj_type(type) {
+               mark = iter_info->marks[type];
+               if (mark &&
+                   fsnotify_compare_groups(max_prio_group, mark->group) > 0)
+                       max_prio_group = mark->group;
+       }
+
+       if (!max_prio_group)
+               return 0;
+
+       /* Set the report mask for marks from same group as max prio group */
+       iter_info->report_mask = 0;
+       fsnotify_foreach_obj_type(type) {
+               mark = iter_info->marks[type];
+               if (mark &&
+                   fsnotify_compare_groups(max_prio_group, mark->group) == 0)
+                       fsnotify_iter_set_report_type(iter_info, type);
+       }
+
+       return iter_info->report_mask;
+}
+
+/*
+ * Pop from iter_info multi head queue, the marks that were iterated in the
+ * current iteration step.
+ */
+static void fsnotify_iter_next(struct fsnotify_iter_info *iter_info)
+{
+       int type;
+
+       fsnotify_foreach_obj_type(type) {
+               if (fsnotify_iter_should_report_type(iter_info, type))
+                       iter_info->marks[type] =
+                               fsnotify_next_mark(iter_info->marks[type]);
+       }
+}
+
 /*
  * This is the main call to fsnotify.  The VFS calls into hook specific functions
  * in linux/fsnotify.h.  Those functions then in turn call here.  Here will call
@@ -307,15 +353,15 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
 
        if ((mask & FS_MODIFY) ||
            (test_mask & to_tell->i_fsnotify_mask)) {
-               iter_info.inode_mark =
+               iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] =
                        fsnotify_first_mark(&to_tell->i_fsnotify_marks);
        }
 
        if (mnt && ((mask & FS_MODIFY) ||
                    (test_mask & mnt->mnt_fsnotify_mask))) {
-               iter_info.inode_mark =
+               iter_info.marks[FSNOTIFY_OBJ_TYPE_INODE] =
                        fsnotify_first_mark(&to_tell->i_fsnotify_marks);
-               iter_info.vfsmount_mark =
+               iter_info.marks[FSNOTIFY_OBJ_TYPE_VFSMOUNT] =
                        fsnotify_first_mark(&mnt->mnt_fsnotify_marks);
        }
 
@@ -324,32 +370,14 @@ int fsnotify(struct inode *to_tell, __u32 mask, const void *data, int data_is,
         * ignore masks are properly reflected for mount mark notifications.
         * That's why this traversal is so complicated...
         */
-       while (iter_info.inode_mark || iter_info.vfsmount_mark) {
-               struct fsnotify_mark *inode_mark = iter_info.inode_mark;
-               struct fsnotify_mark *vfsmount_mark = iter_info.vfsmount_mark;
-
-               if (inode_mark && vfsmount_mark) {
-                       int cmp = fsnotify_compare_groups(inode_mark->group,
-                                                         vfsmount_mark->group);
-                       if (cmp > 0)
-                               inode_mark = NULL;
-                       else if (cmp < 0)
-                               vfsmount_mark = NULL;
-               }
-
-               ret = send_to_group(to_tell, inode_mark, vfsmount_mark, mask,
-                                   data, data_is, cookie, file_name,
-                                   &iter_info);
+       while (fsnotify_iter_select_report_types(&iter_info)) {
+               ret = send_to_group(to_tell, mask, data, data_is, cookie,
+                                   file_name, &iter_info);
 
                if (ret && (mask & ALL_FSNOTIFY_PERM_EVENTS))
                        goto out;
 
-               if (inode_mark)
-                       iter_info.inode_mark =
-                               fsnotify_next_mark(iter_info.inode_mark);
-               if (vfsmount_mark)
-                       iter_info.vfsmount_mark =
-                               fsnotify_next_mark(iter_info.vfsmount_mark);
+               fsnotify_iter_next(&iter_info);
        }
        ret = 0;
 out:
index 60f365dc1408bb535a41b08a84cc059349a408e2..34515d2c4ba3902e4a8910ff5cb11fa08f6c754d 100644 (file)
@@ -9,12 +9,6 @@
 
 #include "../mount.h"
 
-struct fsnotify_iter_info {
-       struct fsnotify_mark *inode_mark;
-       struct fsnotify_mark *vfsmount_mark;
-       int srcu_idx;
-};
-
 /* destroy all events sitting in this groups notification queue */
 extern void fsnotify_flush_notify(struct fsnotify_group *group);
 
index b7a4b6a69efa97f5c698ee1c93cb0b3992d80e49..aa5468f23e45ceea0b524019d2c0968b72c02eea 100644 (file)
@@ -67,7 +67,7 @@ void fsnotify_destroy_group(struct fsnotify_group *group)
        fsnotify_group_stop_queueing(group);
 
        /* Clear all marks for this group and queue them for destruction */
-       fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_ALL_TYPES);
+       fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_ALL_TYPES_MASK);
 
        /*
         * Some marks can still be pinned when waiting for response from
index c00d2caca8948662a06bfd715187d8640c774b3b..7e4578d35b613ce97b87a53e50b2b34df0561e37 100644 (file)
@@ -25,8 +25,6 @@ extern void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
                                           struct fsnotify_group *group);
 extern int inotify_handle_event(struct fsnotify_group *group,
                                struct inode *inode,
-                               struct fsnotify_mark *inode_mark,
-                               struct fsnotify_mark *vfsmount_mark,
                                u32 mask, const void *data, int data_type,
                                const unsigned char *file_name, u32 cookie,
                                struct fsnotify_iter_info *iter_info);
index 40dedb37a1f3093f97ebca766c78284b4ba6385a..9ab6dde38a14c346b000716786f1552f87f85698 100644 (file)
@@ -65,12 +65,11 @@ static int inotify_merge(struct list_head *list,
 
 int inotify_handle_event(struct fsnotify_group *group,
                         struct inode *inode,
-                        struct fsnotify_mark *inode_mark,
-                        struct fsnotify_mark *vfsmount_mark,
                         u32 mask, const void *data, int data_type,
                         const unsigned char *file_name, u32 cookie,
                         struct fsnotify_iter_info *iter_info)
 {
+       struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);
        struct inotify_inode_mark *i_mark;
        struct inotify_event_info *event;
        struct fsnotify_event *fsn_event;
@@ -78,7 +77,8 @@ int inotify_handle_event(struct fsnotify_group *group,
        int len = 0;
        int alloc_len = sizeof(struct inotify_event_info);
 
-       BUG_ON(vfsmount_mark);
+       if (WARN_ON(fsnotify_iter_vfsmount_mark(iter_info)))
+               return 0;
 
        if ((inode_mark->mask & FS_EXCL_UNLINK) &&
            (data_type == FSNOTIFY_EVENT_PATH)) {
index ef32f36579589090535cd046ae3a193b77bb830d..1cf5b779d862dc81f9b00454d06babd8fc3acb1f 100644 (file)
@@ -485,10 +485,14 @@ void inotify_ignored_and_remove_idr(struct fsnotify_mark *fsn_mark,
                                    struct fsnotify_group *group)
 {
        struct inotify_inode_mark *i_mark;
+       struct fsnotify_iter_info iter_info = { };
+
+       fsnotify_iter_set_report_type_mark(&iter_info, FSNOTIFY_OBJ_TYPE_INODE,
+                                          fsn_mark);
 
        /* Queue ignore event for the watch */
-       inotify_handle_event(group, NULL, fsn_mark, NULL, FS_IN_IGNORED,
-                            NULL, FSNOTIFY_EVENT_NONE, NULL, 0, NULL);
+       inotify_handle_event(group, NULL, FS_IN_IGNORED, NULL,
+                            FSNOTIFY_EVENT_NONE, NULL, 0, &iter_info);
 
        i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
        /* remove this mark from the idr */
@@ -578,7 +582,7 @@ static int inotify_new_watch(struct fsnotify_group *group,
        }
 
        /* we are on the idr, now get on the inode */
-       ret = fsnotify_add_mark_locked(&tmp_i_mark->fsn_mark, inode, NULL, 0);
+       ret = fsnotify_add_inode_mark_locked(&tmp_i_mark->fsn_mark, inode, 0);
        if (ret) {
                /* we failed to get on the inode, get off the idr */
                inotify_remove_from_idr(group, tmp_i_mark);
index e9191b416434e68d7794bb5dcf8784c1a402f144..61f4c5fa34c7c8129f1e76963b96422de72f4141 100644 (file)
@@ -119,9 +119,9 @@ static void __fsnotify_recalc_mask(struct fsnotify_mark_connector *conn)
                if (mark->flags & FSNOTIFY_MARK_FLAG_ATTACHED)
                        new_mask |= mark->mask;
        }
-       if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE)
+       if (conn->type == FSNOTIFY_OBJ_TYPE_INODE)
                conn->inode->i_fsnotify_mask = new_mask;
-       else if (conn->flags & FSNOTIFY_OBJ_TYPE_VFSMOUNT)
+       else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT)
                real_mount(conn->mnt)->mnt_fsnotify_mask = new_mask;
 }
 
@@ -139,7 +139,7 @@ void fsnotify_recalc_mask(struct fsnotify_mark_connector *conn)
        spin_lock(&conn->lock);
        __fsnotify_recalc_mask(conn);
        spin_unlock(&conn->lock);
-       if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE)
+       if (conn->type == FSNOTIFY_OBJ_TYPE_INODE)
                __fsnotify_update_child_dentry_flags(conn->inode);
 }
 
@@ -166,18 +166,18 @@ static struct inode *fsnotify_detach_connector_from_object(
 {
        struct inode *inode = NULL;
 
-       if (conn->flags & FSNOTIFY_OBJ_TYPE_INODE) {
+       if (conn->type == FSNOTIFY_OBJ_TYPE_INODE) {
                inode = conn->inode;
                rcu_assign_pointer(inode->i_fsnotify_marks, NULL);
                inode->i_fsnotify_mask = 0;
                conn->inode = NULL;
-               conn->flags &= ~FSNOTIFY_OBJ_TYPE_INODE;
-       } else if (conn->flags & FSNOTIFY_OBJ_TYPE_VFSMOUNT) {
+               conn->type = FSNOTIFY_OBJ_TYPE_DETACHED;
+       } else if (conn->type == FSNOTIFY_OBJ_TYPE_VFSMOUNT) {
                rcu_assign_pointer(real_mount(conn->mnt)->mnt_fsnotify_marks,
                                   NULL);
                real_mount(conn->mnt)->mnt_fsnotify_mask = 0;
                conn->mnt = NULL;
-               conn->flags &= ~FSNOTIFY_OBJ_TYPE_VFSMOUNT;
+               conn->type = FSNOTIFY_OBJ_TYPE_DETACHED;
        }
 
        return inode;
@@ -294,12 +294,12 @@ static void fsnotify_put_mark_wake(struct fsnotify_mark *mark)
 
 bool fsnotify_prepare_user_wait(struct fsnotify_iter_info *iter_info)
 {
-       /* This can fail if mark is being removed */
-       if (!fsnotify_get_mark_safe(iter_info->inode_mark))
-               return false;
-       if (!fsnotify_get_mark_safe(iter_info->vfsmount_mark)) {
-               fsnotify_put_mark_wake(iter_info->inode_mark);
-               return false;
+       int type;
+
+       fsnotify_foreach_obj_type(type) {
+               /* This can fail if mark is being removed */
+               if (!fsnotify_get_mark_safe(iter_info->marks[type]))
+                       goto fail;
        }
 
        /*
@@ -310,13 +310,20 @@ bool fsnotify_prepare_user_wait(struct fsnotify_iter_info *iter_info)
        srcu_read_unlock(&fsnotify_mark_srcu, iter_info->srcu_idx);
 
        return true;
+
+fail:
+       for (type--; type >= 0; type--)
+               fsnotify_put_mark_wake(iter_info->marks[type]);
+       return false;
 }
 
 void fsnotify_finish_user_wait(struct fsnotify_iter_info *iter_info)
 {
+       int type;
+
        iter_info->srcu_idx = srcu_read_lock(&fsnotify_mark_srcu);
-       fsnotify_put_mark_wake(iter_info->inode_mark);
-       fsnotify_put_mark_wake(iter_info->vfsmount_mark);
+       fsnotify_foreach_obj_type(type)
+               fsnotify_put_mark_wake(iter_info->marks[type]);
 }
 
 /*
@@ -442,10 +449,10 @@ static int fsnotify_attach_connector_to_object(
        spin_lock_init(&conn->lock);
        INIT_HLIST_HEAD(&conn->list);
        if (inode) {
-               conn->flags = FSNOTIFY_OBJ_TYPE_INODE;
+               conn->type = FSNOTIFY_OBJ_TYPE_INODE;
                conn->inode = igrab(inode);
        } else {
-               conn->flags = FSNOTIFY_OBJ_TYPE_VFSMOUNT;
+               conn->type = FSNOTIFY_OBJ_TYPE_VFSMOUNT;
                conn->mnt = mnt;
        }
        /*
@@ -479,8 +486,7 @@ static struct fsnotify_mark_connector *fsnotify_grab_connector(
        if (!conn)
                goto out;
        spin_lock(&conn->lock);
-       if (!(conn->flags & (FSNOTIFY_OBJ_TYPE_INODE |
-                            FSNOTIFY_OBJ_TYPE_VFSMOUNT))) {
+       if (conn->type == FSNOTIFY_OBJ_TYPE_DETACHED) {
                spin_unlock(&conn->lock);
                srcu_read_unlock(&fsnotify_mark_srcu, idx);
                return NULL;
@@ -646,16 +652,16 @@ struct fsnotify_mark *fsnotify_find_mark(
        return NULL;
 }
 
-/* Clear any marks in a group with given type */
+/* Clear any marks in a group with given type mask */
 void fsnotify_clear_marks_by_group(struct fsnotify_group *group,
-                                  unsigned int type)
+                                  unsigned int type_mask)
 {
        struct fsnotify_mark *lmark, *mark;
        LIST_HEAD(to_free);
        struct list_head *head = &to_free;
 
        /* Skip selection step if we want to clear all marks. */
-       if (type == FSNOTIFY_OBJ_ALL_TYPES) {
+       if (type_mask == FSNOTIFY_OBJ_ALL_TYPES_MASK) {
                head = &group->marks_list;
                goto clear;
        }
@@ -670,7 +676,7 @@ void fsnotify_clear_marks_by_group(struct fsnotify_group *group,
         */
        mutex_lock_nested(&group->mark_mutex, SINGLE_DEPTH_NESTING);
        list_for_each_entry_safe(mark, lmark, &group->marks_list, g_list) {
-               if (mark->connector->flags & type)
+               if ((1U << mark->connector->type) & type_mask)
                        list_move(&mark->g_list, &to_free);
        }
        mutex_unlock(&group->mark_mutex);
index f8eb04387ca4372ee8acce8d28b29c89618477ae..fbd0090d7d0c4f3723f73fec9ed49f220337c635 100644 (file)
@@ -527,7 +527,7 @@ int ntfs_read_compressed_block(struct page *page)
        BUG_ON(ni->type != AT_DATA);
        BUG_ON(ni->name_len);
 
-       pages = kmalloc(nr_pages * sizeof(struct page *), GFP_NOFS);
+       pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_NOFS);
 
        /* Allocate memory to store the buffer heads we need. */
        bhs_size = cb_size / block_size * sizeof(struct buffer_head *);
index 1c1ee489284b7028d2e373fb93aa25328bc7db64..decaf75d1cd583102aeb1ee298599888df5a2b71 100644 (file)
@@ -667,18 +667,18 @@ static int ntfs_read_locked_inode(struct inode *vi)
         * mtime is the last change of the data within the file. Not changed
         * when only metadata is changed, e.g. a rename doesn't affect mtime.
         */
-       vi->i_mtime = ntfs2utc(si->last_data_change_time);
+       vi->i_mtime = timespec_to_timespec64(ntfs2utc(si->last_data_change_time));
        /*
         * ctime is the last change of the metadata of the file. This obviously
         * always changes, when mtime is changed. ctime can be changed on its
         * own, mtime is then not changed, e.g. when a file is renamed.
         */
-       vi->i_ctime = ntfs2utc(si->last_mft_change_time);
+       vi->i_ctime = timespec_to_timespec64(ntfs2utc(si->last_mft_change_time));
        /*
         * Last access to the data within the file. Not changed during a rename
         * for example but changed whenever the file is written to.
         */
-       vi->i_atime = ntfs2utc(si->last_access_time);
+       vi->i_atime = timespec_to_timespec64(ntfs2utc(si->last_access_time));
 
        /* Find the attribute list attribute if present. */
        ntfs_attr_reinit_search_ctx(ctx);
@@ -2804,11 +2804,11 @@ int ntfs_truncate(struct inode *vi)
         * for real.
         */
        if (!IS_NOCMTIME(VFS_I(base_ni)) && !IS_RDONLY(VFS_I(base_ni))) {
-               struct timespec now = current_time(VFS_I(base_ni));
+               struct timespec64 now = current_time(VFS_I(base_ni));
                int sync_it = 0;
 
-               if (!timespec_equal(&VFS_I(base_ni)->i_mtime, &now) ||
-                   !timespec_equal(&VFS_I(base_ni)->i_ctime, &now))
+               if (!timespec64_equal(&VFS_I(base_ni)->i_mtime, &now) ||
+                   !timespec64_equal(&VFS_I(base_ni)->i_ctime, &now))
                        sync_it = 1;
                VFS_I(base_ni)->i_mtime = now;
                VFS_I(base_ni)->i_ctime = now;
@@ -2923,14 +2923,14 @@ int ntfs_setattr(struct dentry *dentry, struct iattr *attr)
                }
        }
        if (ia_valid & ATTR_ATIME)
-               vi->i_atime = timespec_trunc(attr->ia_atime,
-                               vi->i_sb->s_time_gran);
+               vi->i_atime = timespec64_trunc(attr->ia_atime,
+                                              vi->i_sb->s_time_gran);
        if (ia_valid & ATTR_MTIME)
-               vi->i_mtime = timespec_trunc(attr->ia_mtime,
-                               vi->i_sb->s_time_gran);
+               vi->i_mtime = timespec64_trunc(attr->ia_mtime,
+                                              vi->i_sb->s_time_gran);
        if (ia_valid & ATTR_CTIME)
-               vi->i_ctime = timespec_trunc(attr->ia_ctime,
-                               vi->i_sb->s_time_gran);
+               vi->i_ctime = timespec64_trunc(attr->ia_ctime,
+                                              vi->i_sb->s_time_gran);
        mark_inode_dirty(vi);
 out:
        return err;
@@ -2997,7 +2997,7 @@ int __ntfs_write_inode(struct inode *vi, int sync)
        si = (STANDARD_INFORMATION*)((u8*)ctx->attr +
                        le16_to_cpu(ctx->attr->data.resident.value_offset));
        /* Update the access times if they have changed. */
-       nt = utc2ntfs(vi->i_mtime);
+       nt = utc2ntfs(timespec64_to_timespec(vi->i_mtime));
        if (si->last_data_change_time != nt) {
                ntfs_debug("Updating mtime for inode 0x%lx: old = 0x%llx, "
                                "new = 0x%llx", vi->i_ino, (long long)
@@ -3006,7 +3006,7 @@ int __ntfs_write_inode(struct inode *vi, int sync)
                si->last_data_change_time = nt;
                modified = true;
        }
-       nt = utc2ntfs(vi->i_ctime);
+       nt = utc2ntfs(timespec64_to_timespec(vi->i_ctime));
        if (si->last_mft_change_time != nt) {
                ntfs_debug("Updating ctime for inode 0x%lx: old = 0x%llx, "
                                "new = 0x%llx", vi->i_ino, (long long)
@@ -3015,7 +3015,7 @@ int __ntfs_write_inode(struct inode *vi, int sync)
                si->last_mft_change_time = nt;
                modified = true;
        }
-       nt = utc2ntfs(vi->i_atime);
+       nt = utc2ntfs(timespec64_to_timespec(vi->i_atime));
        if (si->last_access_time != nt) {
                ntfs_debug("Updating atime for inode 0x%lx: old = 0x%llx, "
                                "new = 0x%llx", vi->i_ino,
index e5076185cc1ecf560193958a2bab37d106e340d7..1296f78ae9667ccdefe06fd7358502a0d9dda126 100644 (file)
@@ -1078,7 +1078,7 @@ int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec,
        o2net_set_nst_sock_container(&nst, sc);
 
        veclen = caller_veclen + 1;
-       vec = kmalloc(sizeof(struct kvec) * veclen, GFP_ATOMIC);
+       vec = kmalloc_array(veclen, sizeof(struct kvec), GFP_ATOMIC);
        if (vec == NULL) {
                mlog(0, "failed to %zu element kvec!\n", veclen);
                ret = -ENOMEM;
index 425081be61610263962bcef9de4b9141252e5a57..2acd58ba9b7b27dbaf2a2834c8ee0aea7c609f94 100644 (file)
@@ -86,7 +86,7 @@ static void dlm_free_pagevec(void **vec, int pages)
 
 static void **dlm_alloc_pagevec(int pages)
 {
-       void **vec = kmalloc(pages * sizeof(void *), GFP_KERNEL);
+       void **vec = kmalloc_array(pages, sizeof(void *), GFP_KERNEL);
        int i;
 
        if (!vec)
index 68728de1286460b0ead492d5b2f773258cccc46d..0ff424c6d17c806841e9cd5f48323a7d92536407 100644 (file)
@@ -2140,6 +2140,7 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
        struct ocfs2_inode_info *oi = OCFS2_I(inode);
        struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
        struct ocfs2_meta_lvb *lvb;
+       struct timespec ts;
 
        lvb = ocfs2_dlm_lvb(&lockres->l_lksb);
 
@@ -2160,12 +2161,15 @@ static void __ocfs2_stuff_meta_lvb(struct inode *inode)
        lvb->lvb_igid      = cpu_to_be32(i_gid_read(inode));
        lvb->lvb_imode     = cpu_to_be16(inode->i_mode);
        lvb->lvb_inlink    = cpu_to_be16(inode->i_nlink);
+       ts = timespec64_to_timespec(inode->i_atime);
        lvb->lvb_iatime_packed  =
-               cpu_to_be64(ocfs2_pack_timespec(&inode->i_atime));
+               cpu_to_be64(ocfs2_pack_timespec(&ts));
+       ts = timespec64_to_timespec(inode->i_ctime);
        lvb->lvb_ictime_packed =
-               cpu_to_be64(ocfs2_pack_timespec(&inode->i_ctime));
+               cpu_to_be64(ocfs2_pack_timespec(&ts));
+       ts = timespec64_to_timespec(inode->i_mtime);
        lvb->lvb_imtime_packed =
-               cpu_to_be64(ocfs2_pack_timespec(&inode->i_mtime));
+               cpu_to_be64(ocfs2_pack_timespec(&ts));
        lvb->lvb_iattr    = cpu_to_be32(oi->ip_attr);
        lvb->lvb_idynfeatures = cpu_to_be16(oi->ip_dyn_features);
        lvb->lvb_igeneration = cpu_to_be32(inode->i_generation);
@@ -2183,6 +2187,7 @@ static void ocfs2_unpack_timespec(struct timespec *spec,
 
 static void ocfs2_refresh_inode_from_lvb(struct inode *inode)
 {
+       struct timespec ts;
        struct ocfs2_inode_info *oi = OCFS2_I(inode);
        struct ocfs2_lock_res *lockres = &oi->ip_inode_lockres;
        struct ocfs2_meta_lvb *lvb;
@@ -2210,12 +2215,15 @@ static void ocfs2_refresh_inode_from_lvb(struct inode *inode)
        i_gid_write(inode, be32_to_cpu(lvb->lvb_igid));
        inode->i_mode    = be16_to_cpu(lvb->lvb_imode);
        set_nlink(inode, be16_to_cpu(lvb->lvb_inlink));
-       ocfs2_unpack_timespec(&inode->i_atime,
+       ocfs2_unpack_timespec(&ts,
                              be64_to_cpu(lvb->lvb_iatime_packed));
-       ocfs2_unpack_timespec(&inode->i_mtime,
+       inode->i_atime = timespec_to_timespec64(ts);
+       ocfs2_unpack_timespec(&ts,
                              be64_to_cpu(lvb->lvb_imtime_packed));
-       ocfs2_unpack_timespec(&inode->i_ctime,
+       inode->i_mtime = timespec_to_timespec64(ts);
+       ocfs2_unpack_timespec(&ts,
                              be64_to_cpu(lvb->lvb_ictime_packed));
+       inode->i_ctime = timespec_to_timespec64(ts);
        spin_unlock(&oi->ip_lock);
 }
 
index a2a8603d27e0c1fc8cb1f4261ebe0a3ee6c36908..255f758af03a0998dd2e233397dde23fc6740760 100644 (file)
@@ -222,7 +222,7 @@ static int ocfs2_sync_file(struct file *file, loff_t start, loff_t end,
 int ocfs2_should_update_atime(struct inode *inode,
                              struct vfsmount *vfsmnt)
 {
-       struct timespec now;
+       struct timespec64 now;
        struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
 
        if (ocfs2_is_hard_readonly(osb) || ocfs2_is_soft_readonly(osb))
@@ -248,8 +248,8 @@ int ocfs2_should_update_atime(struct inode *inode,
                return 0;
 
        if (vfsmnt->mnt_flags & MNT_RELATIME) {
-               if ((timespec_compare(&inode->i_atime, &inode->i_mtime) <= 0) ||
-                   (timespec_compare(&inode->i_atime, &inode->i_ctime) <= 0))
+               if ((timespec64_compare(&inode->i_atime, &inode->i_mtime) <= 0) ||
+                   (timespec64_compare(&inode->i_atime, &inode->i_ctime) <= 0))
                        return 1;
 
                return 0;
index e5dcea6cee5ff678b33e78083c7240ddc56e3500..bd3475694e83a06501a055e73fd1403f81123eef 100644 (file)
@@ -1383,7 +1383,7 @@ static int __ocfs2_recovery_thread(void *arg)
                goto bail;
        }
 
-       rm_quota = kzalloc(osb->max_slots * sizeof(int), GFP_NOFS);
+       rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS);
        if (!rm_quota) {
                status = -ENOMEM;
                goto bail;
index af155c1831234f7cfef3d4a5d4e0d7b6359f79ed..5965f3878d49be01a92b6276ce88c25be4df21cb 100644 (file)
@@ -69,10 +69,11 @@ static struct inode **get_local_system_inode(struct ocfs2_super *osb,
        spin_unlock(&osb->osb_lock);
 
        if (unlikely(!local_system_inodes)) {
-               local_system_inodes = kzalloc(sizeof(struct inode *) *
-                                             NUM_LOCAL_SYSTEM_INODES *
-                                             osb->max_slots,
-                                             GFP_NOFS);
+               local_system_inodes =
+                       kzalloc(array3_size(sizeof(struct inode *),
+                                           NUM_LOCAL_SYSTEM_INODES,
+                                           osb->max_slots),
+                               GFP_NOFS);
                if (!local_system_inodes) {
                        mlog_errno(-ENOMEM);
                        /*
index 74b37cbbd5d4a1c750a6adc1d75906a776963f9a..33ee8cb32f8314a8e3a90710a3f4bcebfa3fdb8e 100644 (file)
@@ -719,37 +719,6 @@ struct ORANGEFS_dev_map_desc32 {
        __s32 count;
 };
 
-static unsigned long translate_dev_map26(unsigned long args, long *error)
-{
-       struct ORANGEFS_dev_map_desc32 __user *p32 = (void __user *)args;
-       /*
-        * Depending on the architecture, allocate some space on the
-        * user-call-stack based on our expected layout.
-        */
-       struct ORANGEFS_dev_map_desc __user *p =
-           compat_alloc_user_space(sizeof(*p));
-       compat_uptr_t addr;
-
-       *error = 0;
-       /* get the ptr from the 32 bit user-space */
-       if (get_user(addr, &p32->ptr))
-               goto err;
-       /* try to put that into a 64-bit layout */
-       if (put_user(compat_ptr(addr), &p->ptr))
-               goto err;
-       /* copy the remaining fields */
-       if (copy_in_user(&p->total_size, &p32->total_size, sizeof(__s32)))
-               goto err;
-       if (copy_in_user(&p->size, &p32->size, sizeof(__s32)))
-               goto err;
-       if (copy_in_user(&p->count, &p32->count, sizeof(__s32)))
-               goto err;
-       return (unsigned long)p;
-err:
-       *error = -EFAULT;
-       return 0;
-}
-
 /*
  * 32 bit user-space apps' ioctl handlers when kernel modules
  * is compiled as a 64 bit one
@@ -758,25 +727,26 @@ static long orangefs_devreq_compat_ioctl(struct file *filp, unsigned int cmd,
                                      unsigned long args)
 {
        long ret;
-       unsigned long arg = args;
 
        /* Check for properly constructed commands */
        ret = check_ioctl_command(cmd);
        if (ret < 0)
                return ret;
        if (cmd == ORANGEFS_DEV_MAP) {
-               /*
-                * convert the arguments to what we expect internally
-                * in kernel space
-                */
-               arg = translate_dev_map26(args, &ret);
-               if (ret < 0) {
-                       gossip_err("Could not translate dev map\n");
-                       return ret;
-               }
+               struct ORANGEFS_dev_map_desc desc;
+               struct ORANGEFS_dev_map_desc32 d32;
+
+               if (copy_from_user(&d32, (void __user *)args, sizeof(d32)))
+                       return -EFAULT;
+
+               desc.ptr = compat_ptr(d32.ptr);
+               desc.total_size = d32.total_size;
+               desc.size = d32.size;
+               desc.count = d32.count;
+               return orangefs_bufmap_initialize(&desc);
        }
        /* no other ioctl requires translation */
-       return dispatch_ioctl_command(cmd, arg);
+       return dispatch_ioctl_command(cmd, args);
 }
 
 #endif /* CONFIG_COMPAT is in .config */
index d6db252e62003fbd7be2a50e42e85a2ee8bcdf60..6e4d2af8f5bcffee89b75d9e9672bb0ca86eb6e6 100644 (file)
@@ -297,7 +297,7 @@ int orangefs_permission(struct inode *inode, int mask)
        return generic_permission(inode, mask);
 }
 
-int orangefs_update_time(struct inode *inode, struct timespec *time, int flags)
+int orangefs_update_time(struct inode *inode, struct timespec64 *time, int flags)
 {
        struct iattr iattr;
        gossip_debug(GOSSIP_INODE_DEBUG, "orangefs_update_time: %pU\n",
index 004511617b6d76e577ae7b84620fcc0d66f63f1e..17b24ad6b264b1733e2ee081a1bb44ab85253e46 100644 (file)
@@ -342,7 +342,7 @@ int orangefs_getattr(const struct path *path, struct kstat *stat,
 
 int orangefs_permission(struct inode *inode, int mask);
 
-int orangefs_update_time(struct inode *, struct timespec *, int);
+int orangefs_update_time(struct inode *, struct timespec64 *, int);
 
 /*
  * defined in xattr.c
index 079a465796f3ef95e318b3929b83fab005f42df7..dd28079f518c0c3d09865969e854fa07952286fe 100644 (file)
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Documentation/ABI/stable/orangefs-sysfs:
+ * Documentation/ABI/stable/sysfs-fs-orangefs:
  *
  * What:               /sys/fs/orangefs/perf_counter_reset
  * Date:               June 2015
index 1db5b3b458a19c2a45bebf0d571e4091574c2393..ed16a898caeb8d59ef3daad075c96774a7648db7 100644 (file)
@@ -416,7 +416,7 @@ int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags)
        return err;
 }
 
-int ovl_update_time(struct inode *inode, struct timespec *ts, int flags)
+int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags)
 {
        if (flags & S_ATIME) {
                struct ovl_fs *ofs = inode->i_sb->s_fs_info;
index 08801b45df00dcb346be697f8a6a407f5afabde0..c993dd8db739df44572fb4c0dcf7882b20ea2eab 100644 (file)
@@ -612,7 +612,7 @@ static int ovl_get_index_name_fh(struct ovl_fh *fh, struct qstr *name)
 {
        char *n, *s;
 
-       n = kzalloc(fh->len * 2, GFP_KERNEL);
+       n = kcalloc(fh->len, 2, GFP_KERNEL);
        if (!n)
                return -ENOMEM;
 
index 3c5e9f18b0d9f368025a299124def2e47f9bc4c4..7538b9b56237b46f6cb3f8ed00dc36cecd4b5c94 100644 (file)
@@ -325,7 +325,7 @@ int ovl_xattr_get(struct dentry *dentry, struct inode *inode, const char *name,
 ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
 struct posix_acl *ovl_get_acl(struct inode *inode, int type);
 int ovl_open_maybe_copy_up(struct dentry *dentry, unsigned int file_flags);
-int ovl_update_time(struct inode *inode, struct timespec *ts, int flags);
+int ovl_update_time(struct inode *inode, struct timespec64 *ts, int flags);
 bool ovl_is_private_xattr(const char *name);
 
 struct ovl_inode_params {
index 4aa9ce5df02ffc9b6daf9d1d47157f5aee660799..b6572944efc340d89f136c5a9c17ac409c8bef00 100644 (file)
@@ -389,7 +389,8 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns,
        unsigned long *entries;
        int err;
 
-       entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries), GFP_KERNEL);
+       entries = kmalloc_array(MAX_STACK_TRACE_DEPTH, sizeof(*entries),
+                               GFP_KERNEL);
        if (!entries)
                return -ENOMEM;
 
@@ -2438,14 +2439,11 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
        for (p = ents; p < last; p++) {
                if (p->len != dentry->d_name.len)
                        continue;
-               if (!memcmp(dentry->d_name.name, p->name, p->len))
+               if (!memcmp(dentry->d_name.name, p->name, p->len)) {
+                       res = proc_pident_instantiate(dentry, task, p);
                        break;
+               }
        }
-       if (p >= last)
-               goto out;
-
-       res = proc_pident_instantiate(dentry, task, p);
-out:
        put_task_struct(task);
 out_no_task:
        return res;
index 7b4d9714f2485a5c53397bf9dc198419b8b30464..6ac1c92997ea2a20c3af8959c6920218f16a846d 100644 (file)
@@ -409,7 +409,7 @@ static struct proc_dir_entry *__proc_create(struct proc_dir_entry **parent,
        if (!ent)
                goto out;
 
-       if (qstr.len + 1 <= sizeof(ent->inline_name)) {
+       if (qstr.len + 1 <= SIZEOF_PDE_INLINE_NAME) {
                ent->name = ent->inline_name;
        } else {
                ent->name = kmalloc(qstr.len + 1, GFP_KERNEL);
@@ -740,3 +740,27 @@ void *PDE_DATA(const struct inode *inode)
        return __PDE_DATA(inode);
 }
 EXPORT_SYMBOL(PDE_DATA);
+
+/*
+ * Pull a user buffer into memory and pass it to the file's write handler if
+ * one is supplied.  The ->write() method is permitted to modify the
+ * kernel-side buffer.
+ */
+ssize_t proc_simple_write(struct file *f, const char __user *ubuf, size_t size,
+                         loff_t *_pos)
+{
+       struct proc_dir_entry *pde = PDE(file_inode(f));
+       char *buf;
+       int ret;
+
+       if (!pde->write)
+               return -EACCES;
+       if (size == 0 || size > PAGE_SIZE - 1)
+               return -EINVAL;
+       buf = memdup_user_nul(ubuf, size);
+       if (IS_ERR(buf))
+               return PTR_ERR(buf);
+       ret = pde->write(f, buf, size);
+       kfree(buf);
+       return ret == 0 ? size : ret;
+}
index 2cf3b74391ca5774a04cabe2b70e1e84ec7b3002..85ffbd27f2883a8e6fb3dfe8275c2e1a36ac3ffe 100644 (file)
@@ -105,9 +105,8 @@ void __init proc_init_kmemcache(void)
                kmem_cache_create("pde_opener", sizeof(struct pde_opener), 0,
                                  SLAB_ACCOUNT|SLAB_PANIC, NULL);
        proc_dir_entry_cache = kmem_cache_create_usercopy(
-               "proc_dir_entry", sizeof(struct proc_dir_entry), 0, SLAB_PANIC,
-               offsetof(struct proc_dir_entry, inline_name),
-               sizeof_field(struct proc_dir_entry, inline_name), NULL);
+               "proc_dir_entry", SIZEOF_PDE_SLOT, 0, SLAB_PANIC,
+               OFFSETOF_PDE_NAME, SIZEOF_PDE_INLINE_NAME, NULL);
 }
 
 static int proc_show_options(struct seq_file *seq, struct dentry *root)
index 50cb22a08c2f91224e635f8ae34b27e85761aeff..da3dbfa09e79c2f82a4f601f2eb103c00f716a23 100644 (file)
@@ -48,6 +48,7 @@ struct proc_dir_entry {
                const struct seq_operations *seq_ops;
                int (*single_show)(struct seq_file *, void *);
        };
+       proc_write_t write;
        void *data;
        unsigned int state_size;
        unsigned int low_ino;
@@ -61,14 +62,20 @@ struct proc_dir_entry {
        char *name;
        umode_t mode;
        u8 namelen;
-#ifdef CONFIG_64BIT
-#define SIZEOF_PDE_INLINE_NAME (192-155)
-#else
-#define SIZEOF_PDE_INLINE_NAME (128-95)
-#endif
-       char inline_name[SIZEOF_PDE_INLINE_NAME];
+       char inline_name[];
 } __randomize_layout;
 
+#define OFFSETOF_PDE_NAME offsetof(struct proc_dir_entry, inline_name)
+#define SIZEOF_PDE_SLOT                                        \
+       (OFFSETOF_PDE_NAME + 34 <= 64 ? 64 :            \
+        OFFSETOF_PDE_NAME + 34 <= 128 ? 128 :          \
+        OFFSETOF_PDE_NAME + 34 <= 192 ? 192 :          \
+        OFFSETOF_PDE_NAME + 34 <= 256 ? 256 :          \
+        OFFSETOF_PDE_NAME + 34 <= 512 ? 512 :          \
+        0)
+
+#define SIZEOF_PDE_INLINE_NAME (SIZEOF_PDE_SLOT - OFFSETOF_PDE_NAME)
+
 extern struct kmem_cache *proc_dir_entry_cache;
 void pde_free(struct proc_dir_entry *pde);
 
@@ -189,6 +196,7 @@ static inline bool is_empty_pde(const struct proc_dir_entry *pde)
 {
        return S_ISDIR(pde->mode) && !pde->proc_iops;
 }
+extern ssize_t proc_simple_write(struct file *, const char __user *, size_t, loff_t *);
 
 /*
  * inode.c
index 7d94fa005b0d9a85c198887ebfa8227e4c7f1262..d5e0fcb3439e91b8c722b7193c0d8a59e2ecbe98 100644 (file)
@@ -46,6 +46,9 @@ static int seq_open_net(struct inode *inode, struct file *file)
 
        WARN_ON_ONCE(state_size < sizeof(*p));
 
+       if (file->f_mode & FMODE_WRITE && !PDE(inode)->write)
+               return -EACCES;
+
        net = get_proc_net(inode);
        if (!net)
                return -ENXIO;
@@ -73,6 +76,7 @@ static int seq_release_net(struct inode *ino, struct file *f)
 static const struct file_operations proc_net_seq_fops = {
        .open           = seq_open_net,
        .read           = seq_read,
+       .write          = proc_simple_write,
        .llseek         = seq_lseek,
        .release        = seq_release_net,
 };
@@ -93,6 +97,50 @@ struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode,
 }
 EXPORT_SYMBOL_GPL(proc_create_net_data);
 
+/**
+ * proc_create_net_data_write - Create a writable net_ns-specific proc file
+ * @name: The name of the file.
+ * @mode: The file's access mode.
+ * @parent: The parent directory in which to create.
+ * @ops: The seq_file ops with which to read the file.
+ * @write: The write method which which to 'modify' the file.
+ * @data: Data for retrieval by PDE_DATA().
+ *
+ * Create a network namespaced proc file in the @parent directory with the
+ * specified @name and @mode that allows reading of a file that displays a
+ * series of elements and also provides for the file accepting writes that have
+ * some arbitrary effect.
+ *
+ * The functions in the @ops table are used to iterate over items to be
+ * presented and extract the readable content using the seq_file interface.
+ *
+ * The @write function is called with the data copied into a kernel space
+ * scratch buffer and has a NUL appended for convenience.  The buffer may be
+ * modified by the @write function.  @write should return 0 on success.
+ *
+ * The @data value is accessible from the @show and @write functions by calling
+ * PDE_DATA() on the file inode.  The network namespace must be accessed by
+ * calling seq_file_net() on the seq_file struct.
+ */
+struct proc_dir_entry *proc_create_net_data_write(const char *name, umode_t mode,
+                                                 struct proc_dir_entry *parent,
+                                                 const struct seq_operations *ops,
+                                                 proc_write_t write,
+                                                 unsigned int state_size, void *data)
+{
+       struct proc_dir_entry *p;
+
+       p = proc_create_reg(name, mode, &parent, data);
+       if (!p)
+               return NULL;
+       p->proc_fops = &proc_net_seq_fops;
+       p->seq_ops = ops;
+       p->state_size = state_size;
+       p->write = write;
+       return proc_register(parent, p);
+}
+EXPORT_SYMBOL_GPL(proc_create_net_data_write);
+
 static int single_open_net(struct inode *inode, struct file *file)
 {
        struct proc_dir_entry *de = PDE(inode);
@@ -119,6 +167,7 @@ static int single_release_net(struct inode *ino, struct file *f)
 static const struct file_operations proc_net_single_fops = {
        .open           = single_open_net,
        .read           = seq_read,
+       .write          = proc_simple_write,
        .llseek         = seq_lseek,
        .release        = single_release_net,
 };
@@ -138,6 +187,49 @@ struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
 }
 EXPORT_SYMBOL_GPL(proc_create_net_single);
 
+/**
+ * proc_create_net_single_write - Create a writable net_ns-specific proc file
+ * @name: The name of the file.
+ * @mode: The file's access mode.
+ * @parent: The parent directory in which to create.
+ * @show: The seqfile show method with which to read the file.
+ * @write: The write method which which to 'modify' the file.
+ * @data: Data for retrieval by PDE_DATA().
+ *
+ * Create a network-namespaced proc file in the @parent directory with the
+ * specified @name and @mode that allows reading of a file that displays a
+ * single element rather than a series and also provides for the file accepting
+ * writes that have some arbitrary effect.
+ *
+ * The @show function is called to extract the readable content via the
+ * seq_file interface.
+ *
+ * The @write function is called with the data copied into a kernel space
+ * scratch buffer and has a NUL appended for convenience.  The buffer may be
+ * modified by the @write function.  @write should return 0 on success.
+ *
+ * The @data value is accessible from the @show and @write functions by calling
+ * PDE_DATA() on the file inode.  The network namespace must be accessed by
+ * calling seq_file_single_net() on the seq_file struct.
+ */
+struct proc_dir_entry *proc_create_net_single_write(const char *name, umode_t mode,
+                                                   struct proc_dir_entry *parent,
+                                                   int (*show)(struct seq_file *, void *),
+                                                   proc_write_t write,
+                                                   void *data)
+{
+       struct proc_dir_entry *p;
+
+       p = proc_create_reg(name, mode, &parent, data);
+       if (!p)
+               return NULL;
+       p->proc_fops = &proc_net_single_fops;
+       p->single_show = show;
+       p->write = write;
+       return proc_register(parent, p);
+}
+EXPORT_SYMBOL_GPL(proc_create_net_single_write);
+
 static struct net *get_proc_task_net(struct inode *dir)
 {
        struct task_struct *task;
index 4d765e5e91eda8961d3a49fab214dd8736c1e699..89921a0d2ebbcb9b31c361a7b5972480771cf5ad 100644 (file)
@@ -1426,7 +1426,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
        /* If there are mixed files and directories we need a new table */
        if (nr_dirs && nr_files) {
                struct ctl_table *new;
-               files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
+               files = kcalloc(nr_files + 1, sizeof(struct ctl_table),
                                GFP_KERNEL);
                if (!files)
                        goto out;
index 61b7340b357a2aad54e6c9b5eca97b8c9bd7a425..f4b1a9d2eca6010be2838197dc9741ec67a3857e 100644 (file)
@@ -204,8 +204,7 @@ struct proc_dir_entry proc_root = {
        .proc_fops      = &proc_root_operations,
        .parent         = &proc_root,
        .subdir         = RB_ROOT,
-       .name           = proc_root.inline_name,
-       .inline_name    = "/proc",
+       .name           = "/proc",
 };
 
 int pid_ns_prepare_proc(struct pid_namespace *ns)
index 597969db9e903ef301a51d4db13d7372e12c7e14..e9679016271fba923290c24e13f5368f5f0e0199 100644 (file)
@@ -1473,7 +1473,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
        pm.show_pfn = file_ns_capable(file, &init_user_ns, CAP_SYS_ADMIN);
 
        pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
-       pm.buffer = kmalloc(pm.len * PM_ENTRY_BYTES, GFP_KERNEL);
+       pm.buffer = kmalloc_array(pm.len, PM_ENTRY_BYTES, GFP_KERNEL);
        ret = -ENOMEM;
        if (!pm.buffer)
                goto out_mm;
index 3bd12f955867e5faf865b32f1197054d6a99dde9..3f723cb478af31c721ec263b4db9fb3e9ac17054 100644 (file)
@@ -10,7 +10,7 @@
 static int uptime_proc_show(struct seq_file *m, void *v)
 {
        struct timespec uptime;
-       struct timespec idle;
+       struct timespec64 idle;
        u64 nsec;
        u32 rem;
        int i;
index dc720573fd5308802eacd0ba181b93f96799e95e..c238ab8ba31d6139a9b19c087e6041d3e1b8dffc 100644 (file)
@@ -328,7 +328,7 @@ void pstore_record_init(struct pstore_record *record,
        record->psi = psinfo;
 
        /* Report zeroed timestamp if called before timekeeping has resumed. */
-       record->time = ns_to_timespec(ktime_get_real_fast_ns());
+       record->time = ns_to_timespec64(ktime_get_real_fast_ns());
 }
 
 /*
index 49b2bc1148683bd0a986e74e17bfb101fbd59b33..bbd1e357c23df64b385f4baf119e649342c9c50e 100644 (file)
@@ -153,21 +153,23 @@ ramoops_get_next_prz(struct persistent_ram_zone *przs[], uint *c, uint max,
        return prz;
 }
 
-static int ramoops_read_kmsg_hdr(char *buffer, struct timespec *time,
+static int ramoops_read_kmsg_hdr(char *buffer, struct timespec64 *time,
                                  bool *compressed)
 {
        char data_type;
        int header_length = 0;
 
-       if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lu.%lu-%c\n%n", &time->tv_sec,
-                       &time->tv_nsec, &data_type, &header_length) == 3) {
+       if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lld.%lu-%c\n%n",
+                  (time64_t *)&time->tv_sec, &time->tv_nsec, &data_type,
+                  &header_length) == 3) {
                if (data_type == 'C')
                        *compressed = true;
                else
                        *compressed = false;
-       } else if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lu.%lu\n%n",
-                       &time->tv_sec, &time->tv_nsec, &header_length) == 2) {
-                       *compressed = false;
+       } else if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lld.%lu\n%n",
+                         (time64_t *)&time->tv_sec, &time->tv_nsec,
+                         &header_length) == 2) {
+               *compressed = false;
        } else {
                time->tv_sec = 0;
                time->tv_nsec = 0;
@@ -360,8 +362,8 @@ static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz,
        char *hdr;
        size_t len;
 
-       hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lu.%lu-%c\n",
-               record->time.tv_sec,
+       hdr = kasprintf(GFP_ATOMIC, RAMOOPS_KERNMSG_HDR "%lld.%06lu-%c\n",
+               (time64_t)record->time.tv_sec,
                record->time.tv_nsec / 1000,
                record->compressed ? 'C' : 'D');
        WARN_ON_ONCE(!hdr);
index e83bd9744b5d3b9d81b0a95898a91ed0ec9ebce7..153f8f690490771208dbff66f458caaa9ec57d22 100644 (file)
@@ -778,7 +778,7 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,
                goto out;
        }
        if (nr_segs > fast_segs) {
-               iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL);
+               iov = kmalloc_array(nr_segs, sizeof(struct iovec), GFP_KERNEL);
                if (iov == NULL) {
                        ret = -ENOMEM;
                        goto out;
@@ -849,7 +849,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
                goto out;
        if (nr_segs > fast_segs) {
                ret = -ENOMEM;
-               iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL);
+               iov = kmalloc_array(nr_segs, sizeof(struct iovec), GFP_KERNEL);
                if (iov == NULL)
                        goto out;
        }
index edc8ef78b63fc204275725bf9c9d6b9a5b788a81..bf708ac287b42b38196801514cf5ec1b9e82437b 100644 (file)
@@ -1456,7 +1456,7 @@ int reiserfs_init_bitmap_cache(struct super_block *sb)
        struct reiserfs_bitmap_info *bitmap;
        unsigned int bmap_nr = reiserfs_bmap_count(sb);
 
-       bitmap = vmalloc(sizeof(*bitmap) * bmap_nr);
+       bitmap = vmalloc(array_size(bmap_nr, sizeof(*bitmap)));
        if (bitmap == NULL)
                return -ENOMEM;
 
index b13fc024d2eed8b3201ae1c6dda226a0031d1e8d..132ec4406ed00733947e9ba8c2fc770de08ec749 100644 (file)
@@ -1044,7 +1044,8 @@ int reiserfs_get_block(struct inode *inode, sector_t block,
                        if (blocks_needed == 1) {
                                un = &unf_single;
                        } else {
-                               un = kzalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_NOFS);
+                               un = kcalloc(min(blocks_needed, max_to_insert),
+                                            UNFM_P_SIZE, GFP_NOFS);
                                if (!un) {
                                        un = &unf_single;
                                        blocks_needed = 1;
index 23148c3ed67560fa97a10e5ef36e1024ad95aee7..52eb5d293a343dc26a544c7f5d7b3fbec1de4b04 100644 (file)
@@ -350,7 +350,8 @@ static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes)
        if (num_cnodes <= 0) {
                return NULL;
        }
-       head = vzalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
+       head = vzalloc(array_size(num_cnodes,
+                                 sizeof(struct reiserfs_journal_cnode)));
        if (!head) {
                return NULL;
        }
@@ -2192,10 +2193,12 @@ static int journal_read_transaction(struct super_block *sb,
         * now we know we've got a good transaction, and it was
         * inside the valid time ranges
         */
-       log_blocks = kmalloc(get_desc_trans_len(desc) *
-                            sizeof(struct buffer_head *), GFP_NOFS);
-       real_blocks = kmalloc(get_desc_trans_len(desc) *
-                             sizeof(struct buffer_head *), GFP_NOFS);
+       log_blocks = kmalloc_array(get_desc_trans_len(desc),
+                                  sizeof(struct buffer_head *),
+                                  GFP_NOFS);
+       real_blocks = kmalloc_array(get_desc_trans_len(desc),
+                                   sizeof(struct buffer_head *),
+                                   GFP_NOFS);
        if (!log_blocks || !real_blocks) {
                brelse(c_bh);
                brelse(d_bh);
index 5089dac0266020d705e54dcb8f06ca1a998ccec2..97f3fc4fdd79e8b1b1fa2ad3be41a394742780ee 100644 (file)
@@ -1316,7 +1316,7 @@ static int reiserfs_rename(struct inode *old_dir, struct dentry *old_dentry,
        int jbegin_count;
        umode_t old_inode_mode;
        unsigned long savelink = 1;
-       struct timespec ctime;
+       struct timespec64 ctime;
 
        if (flags & ~RENAME_NOREPLACE)
                return -EINVAL;
index 6052d323bc9a75effe265bfaa392e9357b97a839..8096c74c38ac1d68d08b94e659d1fb10511163c0 100644 (file)
@@ -120,7 +120,8 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new)
                 * array of bitmap block pointers
                 */
                bitmap =
-                   vzalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
+                   vzalloc(array_size(bmap_nr_new,
+                                      sizeof(struct reiserfs_bitmap_info)));
                if (!bitmap) {
                        /*
                         * Journal bitmaps are still supersized, but the
index 5dbf5324bdda53377e57d38661ec3a835256c85f..ff94fad477e461435e335030dd7baf99c0783636 100644 (file)
@@ -451,10 +451,10 @@ int reiserfs_commit_write(struct file *f, struct page *page,
 
 static void update_ctime(struct inode *inode)
 {
-       struct timespec now = current_time(inode);
+       struct timespec64 now = current_time(inode);
 
        if (inode_unhashed(inode) || !inode->i_nlink ||
-           timespec_equal(&inode->i_ctime, &now))
+           timespec64_equal(&inode->i_ctime, &now))
                return;
 
        inode->i_ctime = current_time(inode);
index bc3cc0f9889611446ef94cda24ec5e20892c435f..317891ff8165ba19b775fcfaa8f6deccb58ba18f 100644 (file)
@@ -1236,7 +1236,7 @@ static int compat_core_sys_select(int n, compat_ulong_t __user *inp,
        size = FDS_BYTES(n);
        bits = stack_fds;
        if (size > sizeof(stack_fds) / 6) {
-               bits = kmalloc(6 * size, GFP_KERNEL);
+               bits = kmalloc_array(6, size, GFP_KERNEL);
                ret = -ENOMEM;
                if (!bits)
                        goto out_nofds;
index cbb42f77a2bd221d8ab7c9cb2b6dc0e047b321e2..4fcd1498acf522d75cced6ea13d22b9d78c9b43b 100644 (file)
@@ -259,10 +259,8 @@ static const struct file_operations signalfd_fops = {
        .llseek         = noop_llseek,
 };
 
-static int do_signalfd4(int ufd, sigset_t __user *user_mask, size_t sizemask,
-                       int flags)
+static int do_signalfd4(int ufd, sigset_t *mask, int flags)
 {
-       sigset_t sigmask;
        struct signalfd_ctx *ctx;
 
        /* Check the SFD_* constants for consistency.  */
@@ -272,18 +270,15 @@ static int do_signalfd4(int ufd, sigset_t __user *user_mask, size_t sizemask,
        if (flags & ~(SFD_CLOEXEC | SFD_NONBLOCK))
                return -EINVAL;
 
-       if (sizemask != sizeof(sigset_t) ||
-           copy_from_user(&sigmask, user_mask, sizeof(sigmask)))
-               return -EINVAL;
-       sigdelsetmask(&sigmask, sigmask(SIGKILL) | sigmask(SIGSTOP));
-       signotset(&sigmask);
+       sigdelsetmask(mask, sigmask(SIGKILL) | sigmask(SIGSTOP));
+       signotset(mask);
 
        if (ufd == -1) {
                ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
                if (!ctx)
                        return -ENOMEM;
 
-               ctx->sigmask = sigmask;
+               ctx->sigmask = *mask;
 
                /*
                 * When we call this, the initialization must be complete, since
@@ -303,7 +298,7 @@ static int do_signalfd4(int ufd, sigset_t __user *user_mask, size_t sizemask,
                        return -EINVAL;
                }
                spin_lock_irq(&current->sighand->siglock);
-               ctx->sigmask = sigmask;
+               ctx->sigmask = *mask;
                spin_unlock_irq(&current->sighand->siglock);
 
                wake_up(&current->sighand->signalfd_wqh);
@@ -316,46 +311,51 @@ static int do_signalfd4(int ufd, sigset_t __user *user_mask, size_t sizemask,
 SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask,
                size_t, sizemask, int, flags)
 {
-       return do_signalfd4(ufd, user_mask, sizemask, flags);
+       sigset_t mask;
+
+       if (sizemask != sizeof(sigset_t) ||
+           copy_from_user(&mask, user_mask, sizeof(mask)))
+               return -EINVAL;
+       return do_signalfd4(ufd, &mask, flags);
 }
 
 SYSCALL_DEFINE3(signalfd, int, ufd, sigset_t __user *, user_mask,
                size_t, sizemask)
 {
-       return do_signalfd4(ufd, user_mask, sizemask, 0);
+       sigset_t mask;
+
+       if (sizemask != sizeof(sigset_t) ||
+           copy_from_user(&mask, user_mask, sizeof(mask)))
+               return -EINVAL;
+       return do_signalfd4(ufd, &mask, 0);
 }
 
 #ifdef CONFIG_COMPAT
 static long do_compat_signalfd4(int ufd,
-                       const compat_sigset_t __user *sigmask,
+                       const compat_sigset_t __user *user_mask,
                        compat_size_t sigsetsize, int flags)
 {
-       sigset_t tmp;
-       sigset_t __user *ksigmask;
+       sigset_t mask;
 
        if (sigsetsize != sizeof(compat_sigset_t))
                return -EINVAL;
-       if (get_compat_sigset(&tmp, sigmask))
-               return -EFAULT;
-       ksigmask = compat_alloc_user_space(sizeof(sigset_t));
-       if (copy_to_user(ksigmask, &tmp, sizeof(sigset_t)))
+       if (get_compat_sigset(&mask, user_mask))
                return -EFAULT;
-
-       return do_signalfd4(ufd, ksigmask, sizeof(sigset_t), flags);
+       return do_signalfd4(ufd, &mask, flags);
 }
 
 COMPAT_SYSCALL_DEFINE4(signalfd4, int, ufd,
-                    const compat_sigset_t __user *, sigmask,
+                    const compat_sigset_t __user *, user_mask,
                     compat_size_t, sigsetsize,
                     int, flags)
 {
-       return do_compat_signalfd4(ufd, sigmask, sigsetsize, flags);
+       return do_compat_signalfd4(ufd, user_mask, sigsetsize, flags);
 }
 
 COMPAT_SYSCALL_DEFINE3(signalfd, int, ufd,
-                    const compat_sigset_t __user *,sigmask,
+                    const compat_sigset_t __user *, user_mask,
                     compat_size_t, sigsetsize)
 {
-       return do_compat_signalfd4(ufd, sigmask, sigsetsize, 0);
+       return do_compat_signalfd4(ufd, user_mask, sigsetsize, 0);
 }
 #endif
index 005d09cf3fa879fd2fab8fd6a95433fefa7abc4d..b3daa971f59771d6adf248a192db7d6e3121b015 100644 (file)
@@ -259,8 +259,9 @@ int splice_grow_spd(const struct pipe_inode_info *pipe, struct splice_pipe_desc
        if (buffers <= PIPE_DEF_BUFFERS)
                return 0;
 
-       spd->pages = kmalloc(buffers * sizeof(struct page *), GFP_KERNEL);
-       spd->partial = kmalloc(buffers * sizeof(struct partial_page), GFP_KERNEL);
+       spd->pages = kmalloc_array(buffers, sizeof(struct page *), GFP_KERNEL);
+       spd->partial = kmalloc_array(buffers, sizeof(struct partial_page),
+                                    GFP_KERNEL);
 
        if (spd->pages && spd->partial)
                return 0;
@@ -395,7 +396,7 @@ static ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
 
        vec = __vec;
        if (nr_pages > PIPE_DEF_BUFFERS) {
-               vec = kmalloc(nr_pages * sizeof(struct kvec), GFP_KERNEL);
+               vec = kmalloc_array(nr_pages, sizeof(struct kvec), GFP_KERNEL);
                if (unlikely(!vec)) {
                        res = -ENOMEM;
                        goto out;
@@ -1242,38 +1243,26 @@ static int pipe_to_user(struct pipe_inode_info *pipe, struct pipe_buffer *buf,
  * For lack of a better implementation, implement vmsplice() to userspace
  * as a simple copy of the pipes pages to the user iov.
  */
-static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov,
-                            unsigned long nr_segs, unsigned int flags)
+static long vmsplice_to_user(struct file *file, struct iov_iter *iter,
+                            unsigned int flags)
 {
-       struct pipe_inode_info *pipe;
-       struct splice_desc sd;
-       long ret;
-       struct iovec iovstack[UIO_FASTIOV];
-       struct iovec *iov = iovstack;
-       struct iov_iter iter;
+       struct pipe_inode_info *pipe = get_pipe_info(file);
+       struct splice_desc sd = {
+               .total_len = iov_iter_count(iter),
+               .flags = flags,
+               .u.data = iter
+       };
+       long ret = 0;
 
-       pipe = get_pipe_info(file);
        if (!pipe)
                return -EBADF;
 
-       ret = import_iovec(READ, uiov, nr_segs,
-                          ARRAY_SIZE(iovstack), &iov, &iter);
-       if (ret < 0)
-               return ret;
-
-       sd.total_len = iov_iter_count(&iter);
-       sd.len = 0;
-       sd.flags = flags;
-       sd.u.data = &iter;
-       sd.pos = 0;
-
        if (sd.total_len) {
                pipe_lock(pipe);
                ret = __splice_from_pipe(pipe, &sd, pipe_to_user);
                pipe_unlock(pipe);
        }
 
-       kfree(iov);
        return ret;
 }
 
@@ -1282,14 +1271,11 @@ static long vmsplice_to_user(struct file *file, const struct iovec __user *uiov,
  * as splice-from-memory, where the regular splice is splice-from-file (or
  * to file). In both cases the output is a pipe, naturally.
  */
-static long vmsplice_to_pipe(struct file *file, const struct iovec __user *uiov,
-                            unsigned long nr_segs, unsigned int flags)
+static long vmsplice_to_pipe(struct file *file, struct iov_iter *iter,
+                            unsigned int flags)
 {
        struct pipe_inode_info *pipe;
-       struct iovec iovstack[UIO_FASTIOV];
-       struct iovec *iov = iovstack;
-       struct iov_iter from;
-       long ret;
+       long ret = 0;
        unsigned buf_flag = 0;
 
        if (flags & SPLICE_F_GIFT)
@@ -1299,22 +1285,31 @@ static long vmsplice_to_pipe(struct file *file, const struct iovec __user *uiov,
        if (!pipe)
                return -EBADF;
 
-       ret = import_iovec(WRITE, uiov, nr_segs,
-                          ARRAY_SIZE(iovstack), &iov, &from);
-       if (ret < 0)
-               return ret;
-
        pipe_lock(pipe);
        ret = wait_for_space(pipe, flags);
        if (!ret)
-               ret = iter_to_pipe(&from, pipe, buf_flag);
+               ret = iter_to_pipe(iter, pipe, buf_flag);
        pipe_unlock(pipe);
        if (ret > 0)
                wakeup_pipe_readers(pipe);
-       kfree(iov);
        return ret;
 }
 
+static int vmsplice_type(struct fd f, int *type)
+{
+       if (!f.file)
+               return -EBADF;
+       if (f.file->f_mode & FMODE_WRITE) {
+               *type = WRITE;
+       } else if (f.file->f_mode & FMODE_READ) {
+               *type = READ;
+       } else {
+               fdput(f);
+               return -EBADF;
+       }
+       return 0;
+}
+
 /*
  * Note that vmsplice only really supports true splicing _from_ user memory
  * to a pipe, not the other way around. Splicing from user memory is a simple
@@ -1331,57 +1326,69 @@ static long vmsplice_to_pipe(struct file *file, const struct iovec __user *uiov,
  * Currently we punt and implement it as a normal copy, see pipe_to_user().
  *
  */
-static long do_vmsplice(int fd, const struct iovec __user *iov,
-                       unsigned long nr_segs, unsigned int flags)
+static long do_vmsplice(struct file *f, struct iov_iter *iter, unsigned int flags)
 {
-       struct fd f;
-       long error;
-
        if (unlikely(flags & ~SPLICE_F_ALL))
                return -EINVAL;
-       if (unlikely(nr_segs > UIO_MAXIOV))
-               return -EINVAL;
-       else if (unlikely(!nr_segs))
-               return 0;
 
-       error = -EBADF;
-       f = fdget(fd);
-       if (f.file) {
-               if (f.file->f_mode & FMODE_WRITE)
-                       error = vmsplice_to_pipe(f.file, iov, nr_segs, flags);
-               else if (f.file->f_mode & FMODE_READ)
-                       error = vmsplice_to_user(f.file, iov, nr_segs, flags);
-
-               fdput(f);
-       }
+       if (!iov_iter_count(iter))
+               return 0;
 
-       return error;
+       if (iov_iter_rw(iter) == WRITE)
+               return vmsplice_to_pipe(f, iter, flags);
+       else
+               return vmsplice_to_user(f, iter, flags);
 }
 
-SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, iov,
+SYSCALL_DEFINE4(vmsplice, int, fd, const struct iovec __user *, uiov,
                unsigned long, nr_segs, unsigned int, flags)
 {
-       return do_vmsplice(fd, iov, nr_segs, flags);
+       struct iovec iovstack[UIO_FASTIOV];
+       struct iovec *iov = iovstack;
+       struct iov_iter iter;
+       long error;
+       struct fd f;
+       int type;
+
+       f = fdget(fd);
+       error = vmsplice_type(f, &type);
+       if (error)
+               return error;
+
+       error = import_iovec(type, uiov, nr_segs,
+                            ARRAY_SIZE(iovstack), &iov, &iter);
+       if (!error) {
+               error = do_vmsplice(f.file, &iter, flags);
+               kfree(iov);
+       }
+       fdput(f);
+       return error;
 }
 
 #ifdef CONFIG_COMPAT
 COMPAT_SYSCALL_DEFINE4(vmsplice, int, fd, const struct compat_iovec __user *, iov32,
                    unsigned int, nr_segs, unsigned int, flags)
 {
-       unsigned i;
-       struct iovec __user *iov;
-       if (nr_segs > UIO_MAXIOV)
-               return -EINVAL;
-       iov = compat_alloc_user_space(nr_segs * sizeof(struct iovec));
-       for (i = 0; i < nr_segs; i++) {
-               struct compat_iovec v;
-               if (get_user(v.iov_base, &iov32[i].iov_base) ||
-                   get_user(v.iov_len, &iov32[i].iov_len) ||
-                   put_user(compat_ptr(v.iov_base), &iov[i].iov_base) ||
-                   put_user(v.iov_len, &iov[i].iov_len))
-                       return -EFAULT;
+       struct iovec iovstack[UIO_FASTIOV];
+       struct iovec *iov = iovstack;
+       struct iov_iter iter;
+       long error;
+       struct fd f;
+       int type;
+
+       f = fdget(fd);
+       error = vmsplice_type(f, &type);
+       if (error)
+               return error;
+
+       error = compat_import_iovec(type, iov32, nr_segs,
+                            ARRAY_SIZE(iovstack), &iov, &iter);
+       if (!error) {
+               error = do_vmsplice(f.file, &iter, flags);
+               kfree(iov);
        }
-       return do_vmsplice(fd, iov, nr_segs, flags);
+       fdput(f);
+       return error;
 }
 #endif
 
index 4e267cc21c77c652b155636ca5967820a96dba1e..9da224d4f2da1d7de9f2bf292e7afa504a9668f3 100644 (file)
@@ -1276,7 +1276,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry,
                                        .dirtied_ino = 3 };
        struct ubifs_budget_req ino_req = { .dirtied_ino = 1,
                        .dirtied_ino_d = ALIGN(old_inode_ui->data_len, 8) };
-       struct timespec time;
+       struct timespec64 time;
        unsigned int uninitialized_var(saved_nlink);
        struct fscrypt_name old_nm, new_nm;
 
@@ -1504,7 +1504,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
        int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir);
        struct inode *fst_inode = d_inode(old_dentry);
        struct inode *snd_inode = d_inode(new_dentry);
-       struct timespec time;
+       struct timespec64 time;
        int err;
        struct fscrypt_name fst_nm, snd_nm;
 
index 28b80713a163e3e59355559e1be4ea7a8228990b..fd7eb6fe90904fa9a57bd46711124f54af475849 100644 (file)
@@ -1089,14 +1089,14 @@ static void do_attr_changes(struct inode *inode, const struct iattr *attr)
        if (attr->ia_valid & ATTR_GID)
                inode->i_gid = attr->ia_gid;
        if (attr->ia_valid & ATTR_ATIME)
-               inode->i_atime = timespec_trunc(attr->ia_atime,
-                                               inode->i_sb->s_time_gran);
+               inode->i_atime = timespec64_trunc(attr->ia_atime,
+                                                 inode->i_sb->s_time_gran);
        if (attr->ia_valid & ATTR_MTIME)
-               inode->i_mtime = timespec_trunc(attr->ia_mtime,
-                                               inode->i_sb->s_time_gran);
+               inode->i_mtime = timespec64_trunc(attr->ia_mtime,
+                                                 inode->i_sb->s_time_gran);
        if (attr->ia_valid & ATTR_CTIME)
-               inode->i_ctime = timespec_trunc(attr->ia_ctime,
-                                               inode->i_sb->s_time_gran);
+               inode->i_ctime = timespec64_trunc(attr->ia_ctime,
+                                                 inode->i_sb->s_time_gran);
        if (attr->ia_valid & ATTR_MODE) {
                umode_t mode = attr->ia_mode;
 
@@ -1367,8 +1367,9 @@ int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 static inline int mctime_update_needed(const struct inode *inode,
                                       const struct timespec *now)
 {
-       if (!timespec_equal(&inode->i_mtime, now) ||
-           !timespec_equal(&inode->i_ctime, now))
+       struct timespec64 now64 = timespec_to_timespec64(*now);
+       if (!timespec64_equal(&inode->i_mtime, &now64) ||
+           !timespec64_equal(&inode->i_ctime, &now64))
                return 1;
        return 0;
 }
@@ -1380,7 +1381,7 @@ static inline int mctime_update_needed(const struct inode *inode,
  *
  * This function updates time of the inode.
  */
-int ubifs_update_time(struct inode *inode, struct timespec *time,
+int ubifs_update_time(struct inode *inode, struct timespec64 *time,
                             int flags)
 {
        struct ubifs_inode *ui = ubifs_inode(inode);
@@ -1424,7 +1425,7 @@ int ubifs_update_time(struct inode *inode, struct timespec *time,
  */
 static int update_mctime(struct inode *inode)
 {
-       struct timespec now = current_time(inode);
+       struct timespec now = timespec64_to_timespec(current_time(inode));
        struct ubifs_inode *ui = ubifs_inode(inode);
        struct ubifs_info *c = inode->i_sb->s_fs_info;
 
@@ -1518,7 +1519,7 @@ static vm_fault_t ubifs_vm_page_mkwrite(struct vm_fault *vmf)
        struct page *page = vmf->page;
        struct inode *inode = file_inode(vmf->vma->vm_file);
        struct ubifs_info *c = inode->i_sb->s_fs_info;
-       struct timespec now = current_time(inode);
+       struct timespec now = timespec64_to_timespec(current_time(inode));
        struct ubifs_budget_req req = { .new_page = 1 };
        int err, update_time;
 
index da8afdfccaa64daa357dfc969c50d341783efab5..07b4956e042522e684e3dec9b36909fd46c83f83 100644 (file)
@@ -1282,10 +1282,11 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in
                              int *new_len)
 {
        void *buf;
-       int err, dlen, compr_type, out_len, old_dlen;
+       int err, compr_type;
+       u32 dlen, out_len, old_dlen;
 
        out_len = le32_to_cpu(dn->size);
-       buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
+       buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
        if (!buf)
                return -ENOMEM;
 
index 9a517109da0feda2ac19ba4781072ab4ab4aad31..8e99dad1888009f764d49ffc359be3a3b23578a3 100644 (file)
@@ -628,11 +628,12 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
        /* Needed by 'ubifs_pack_lsave()' */
        c->main_first = c->leb_cnt - *main_lebs;
 
-       lsave = kmalloc(sizeof(int) * c->lsave_cnt, GFP_KERNEL);
+       lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_KERNEL);
        pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL);
        nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL);
        buf = vmalloc(c->leb_size);
-       ltab = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs);
+       ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
+                                 c->lpt_lebs));
        if (!pnode || !nnode || !buf || !ltab || !lsave) {
                err = -ENOMEM;
                goto out;
@@ -1626,7 +1627,8 @@ static int lpt_init_rd(struct ubifs_info *c)
 {
        int err, i;
 
-       c->ltab = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs);
+       c->ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
+                                    c->lpt_lebs));
        if (!c->ltab)
                return -ENOMEM;
 
@@ -1636,15 +1638,17 @@ static int lpt_init_rd(struct ubifs_info *c)
                return -ENOMEM;
 
        for (i = 0; i < LPROPS_HEAP_CNT; i++) {
-               c->lpt_heap[i].arr = kmalloc(sizeof(void *) * LPT_HEAP_SZ,
-                                            GFP_KERNEL);
+               c->lpt_heap[i].arr = kmalloc_array(LPT_HEAP_SZ,
+                                                  sizeof(void *),
+                                                  GFP_KERNEL);
                if (!c->lpt_heap[i].arr)
                        return -ENOMEM;
                c->lpt_heap[i].cnt = 0;
                c->lpt_heap[i].max_cnt = LPT_HEAP_SZ;
        }
 
-       c->dirty_idx.arr = kmalloc(sizeof(void *) * LPT_HEAP_SZ, GFP_KERNEL);
+       c->dirty_idx.arr = kmalloc_array(LPT_HEAP_SZ, sizeof(void *),
+                                        GFP_KERNEL);
        if (!c->dirty_idx.arr)
                return -ENOMEM;
        c->dirty_idx.cnt = 0;
@@ -1688,7 +1692,8 @@ static int lpt_init_wr(struct ubifs_info *c)
 {
        int err, i;
 
-       c->ltab_cmt = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs);
+       c->ltab_cmt = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
+                                        c->lpt_lebs));
        if (!c->ltab_cmt)
                return -ENOMEM;
 
@@ -1697,7 +1702,7 @@ static int lpt_init_wr(struct ubifs_info *c)
                return -ENOMEM;
 
        if (c->big_lpt) {
-               c->lsave = kmalloc(sizeof(int) * c->lsave_cnt, GFP_NOFS);
+               c->lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_NOFS);
                if (!c->lsave)
                        return -ENOMEM;
                err = read_lsave(c);
@@ -1939,8 +1944,8 @@ int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum,
                        return err;
        }
 
-       path = kmalloc(sizeof(struct lpt_scan_node) * (c->lpt_hght + 1),
-                      GFP_NOFS);
+       path = kmalloc_array(c->lpt_hght + 1, sizeof(struct lpt_scan_node),
+                            GFP_NOFS);
        if (!path)
                return -ENOMEM;
 
index 6c397a389105a68f75b6c3dbaba9d7bf3e01c5af..c5466c70d620015aaa16ede0790aefb3c6efbc14 100644 (file)
@@ -1196,7 +1196,8 @@ static int mount_ubifs(struct ubifs_info *c)
         * never exceed 64.
         */
        err = -ENOMEM;
-       c->bottom_up_buf = kmalloc(BOTTOM_UP_HEIGHT * sizeof(int), GFP_KERNEL);
+       c->bottom_up_buf = kmalloc_array(BOTTOM_UP_HEIGHT, sizeof(int),
+                                        GFP_KERNEL);
        if (!c->bottom_up_buf)
                goto out_free;
 
index ba3d0e0f86151e533d98fb656910665a0da61e3c..4a21e7f75e7a16537353c90bf850e52709252a34 100644 (file)
@@ -1104,8 +1104,9 @@ static struct ubifs_znode *dirty_cow_bottom_up(struct ubifs_info *c,
        ubifs_assert(znode);
        if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) {
                kfree(c->bottom_up_buf);
-               c->bottom_up_buf = kmalloc(c->zroot.znode->level * sizeof(int),
-                                          GFP_NOFS);
+               c->bottom_up_buf = kmalloc_array(c->zroot.znode->level,
+                                                sizeof(int),
+                                                GFP_NOFS);
                if (!c->bottom_up_buf)
                        return ERR_PTR(-ENOMEM);
                path = c->bottom_up_buf;
index aa31f60220ef4b8a52fa41d9261e1dffcb1dbc5e..a9df94ad46a34a91f95f4d25562760031937bb0a 100644 (file)
@@ -366,7 +366,8 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt)
 
        dbg_gc("%d znodes to write", cnt);
 
-       c->gap_lebs = kmalloc(sizeof(int) * (c->lst.idx_lebs + 1), GFP_NOFS);
+       c->gap_lebs = kmalloc_array(c->lst.idx_lebs + 1, sizeof(int),
+                                   GFP_NOFS);
        if (!c->gap_lebs)
                return -ENOMEM;
 
@@ -674,7 +675,7 @@ static int alloc_idx_lebs(struct ubifs_info *c, int cnt)
        dbg_cmt("need about %d empty LEBS for TNC commit", leb_cnt);
        if (!leb_cnt)
                return 0;
-       c->ilebs = kmalloc(leb_cnt * sizeof(int), GFP_NOFS);
+       c->ilebs = kmalloc_array(leb_cnt, sizeof(int), GFP_NOFS);
        if (!c->ilebs)
                return -ENOMEM;
        for (i = 0; i < leb_cnt; i++) {
index 209d6369ae71cdd7c6686a419e18f0eae5544211..04bf84d71e7bbae5339d4f7ceea70406be7d1cc8 100644 (file)
@@ -1738,7 +1738,7 @@ int ubifs_calc_dark(const struct ubifs_info *c, int spc);
 int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync);
 int ubifs_setattr(struct dentry *dentry, struct iattr *attr);
 #ifdef CONFIG_UBIFS_ATIME_SUPPORT
-int ubifs_update_time(struct inode *inode, struct timespec *time, int flags);
+int ubifs_update_time(struct inode *inode, struct timespec64 *time, int flags);
 #endif
 
 /* dir.c */
index b7a0d4b4bda144015c5f59ce42108b1d2660c07f..56569023783b3503fe37b414287eadcbd4efa176 100644 (file)
@@ -124,8 +124,8 @@ struct inode *udf_new_inode(struct inode *dir, umode_t mode)
                iinfo->i_alloc_type = ICBTAG_FLAG_AD_SHORT;
        else
                iinfo->i_alloc_type = ICBTAG_FLAG_AD_LONG;
-       inode->i_mtime = inode->i_atime = inode->i_ctime =
-               iinfo->i_crtime = current_time(inode);
+       inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
+       iinfo->i_crtime = timespec64_to_timespec(inode->i_mtime);
        if (unlikely(insert_inode_locked(inode) < 0)) {
                make_bad_inode(inode);
                iput(inode);
index c80765d62f7e9028a3ba2ac282ba2d8c615acbaa..7f39d17352c9697863f02140f7cf7ec1120a2215 100644 (file)
@@ -1271,6 +1271,7 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
        struct udf_inode_info *iinfo = UDF_I(inode);
        struct udf_sb_info *sbi = UDF_SB(inode->i_sb);
        struct kernel_lb_addr *iloc = &iinfo->i_location;
+       struct timespec ts;
        unsigned int link_count;
        unsigned int indirections = 0;
        int bs = inode->i_sb->s_blocksize;
@@ -1443,15 +1444,12 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
                inode->i_blocks = le64_to_cpu(fe->logicalBlocksRecorded) <<
                        (inode->i_sb->s_blocksize_bits - 9);
 
-               if (!udf_disk_stamp_to_time(&inode->i_atime, fe->accessTime))
-                       inode->i_atime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&inode->i_mtime,
-                                           fe->modificationTime))
-                       inode->i_mtime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&inode->i_ctime, fe->attrTime))
-                       inode->i_ctime = sbi->s_record_time;
+               udf_disk_stamp_to_time(&ts, fe->accessTime);
+               inode->i_atime = timespec_to_timespec64(ts);
+               udf_disk_stamp_to_time(&ts, fe->modificationTime);
+               inode->i_mtime = timespec_to_timespec64(ts);
+               udf_disk_stamp_to_time(&ts, fe->attrTime);
+               inode->i_ctime = timespec_to_timespec64(ts);
 
                iinfo->i_unique = le64_to_cpu(fe->uniqueID);
                iinfo->i_lenEAttr = le32_to_cpu(fe->lengthExtendedAttr);
@@ -1461,18 +1459,13 @@ static int udf_read_inode(struct inode *inode, bool hidden_inode)
                inode->i_blocks = le64_to_cpu(efe->logicalBlocksRecorded) <<
                    (inode->i_sb->s_blocksize_bits - 9);
 
-               if (!udf_disk_stamp_to_time(&inode->i_atime, efe->accessTime))
-                       inode->i_atime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&inode->i_mtime,
-                                           efe->modificationTime))
-                       inode->i_mtime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime))
-                       iinfo->i_crtime = sbi->s_record_time;
-
-               if (!udf_disk_stamp_to_time(&inode->i_ctime, efe->attrTime))
-                       inode->i_ctime = sbi->s_record_time;
+               udf_disk_stamp_to_time(&ts, efe->accessTime);
+               inode->i_atime = timespec_to_timespec64(ts);
+               udf_disk_stamp_to_time(&ts, efe->modificationTime);
+               inode->i_mtime = timespec_to_timespec64(ts);
+               udf_disk_stamp_to_time(&iinfo->i_crtime, efe->createTime);
+               udf_disk_stamp_to_time(&ts, efe->attrTime);
+               inode->i_ctime = timespec_to_timespec64(ts);
 
                iinfo->i_unique = le64_to_cpu(efe->uniqueID);
                iinfo->i_lenEAttr = le32_to_cpu(efe->lengthExtendedAttr);
@@ -1722,9 +1715,12 @@ static int udf_update_inode(struct inode *inode, int do_sync)
                       inode->i_sb->s_blocksize - sizeof(struct fileEntry));
                fe->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
 
-               udf_time_to_disk_stamp(&fe->accessTime, inode->i_atime);
-               udf_time_to_disk_stamp(&fe->modificationTime, inode->i_mtime);
-               udf_time_to_disk_stamp(&fe->attrTime, inode->i_ctime);
+               udf_time_to_disk_stamp(&fe->accessTime,
+                                      timespec64_to_timespec(inode->i_atime));
+               udf_time_to_disk_stamp(&fe->modificationTime,
+                                      timespec64_to_timespec(inode->i_mtime));
+               udf_time_to_disk_stamp(&fe->attrTime,
+                                      timespec64_to_timespec(inode->i_ctime));
                memset(&(fe->impIdent), 0, sizeof(struct regid));
                strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER);
                fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX;
@@ -1743,14 +1739,17 @@ static int udf_update_inode(struct inode *inode, int do_sync)
                efe->objectSize = cpu_to_le64(inode->i_size);
                efe->logicalBlocksRecorded = cpu_to_le64(lb_recorded);
 
-               udf_adjust_time(iinfo, inode->i_atime);
-               udf_adjust_time(iinfo, inode->i_mtime);
-               udf_adjust_time(iinfo, inode->i_ctime);
+               udf_adjust_time(iinfo, timespec64_to_timespec(inode->i_atime));
+               udf_adjust_time(iinfo, timespec64_to_timespec(inode->i_mtime));
+               udf_adjust_time(iinfo, timespec64_to_timespec(inode->i_ctime));
 
-               udf_time_to_disk_stamp(&efe->accessTime, inode->i_atime);
-               udf_time_to_disk_stamp(&efe->modificationTime, inode->i_mtime);
+               udf_time_to_disk_stamp(&efe->accessTime,
+                                      timespec64_to_timespec(inode->i_atime));
+               udf_time_to_disk_stamp(&efe->modificationTime,
+                                      timespec64_to_timespec(inode->i_mtime));
                udf_time_to_disk_stamp(&efe->createTime, iinfo->i_crtime);
-               udf_time_to_disk_stamp(&efe->attrTime, inode->i_ctime);
+               udf_time_to_disk_stamp(&efe->attrTime,
+                                      timespec64_to_timespec(inode->i_ctime));
 
                memset(&(efe->impIdent), 0, sizeof(efe->impIdent));
                strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER);
index 0d27d41f5c6e70e51c12d9d702b8ec32e239bfff..0c504c8031d36a0de5a3add21cb294722b621a60 100644 (file)
@@ -862,6 +862,9 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
        struct buffer_head *bh;
        uint16_t ident;
        int ret = -ENOMEM;
+#ifdef UDFFS_DEBUG
+       struct timestamp *ts;
+#endif
 
        outstr = kmalloc(128, GFP_NOFS);
        if (!outstr)
@@ -880,15 +883,15 @@ static int udf_load_pvoldesc(struct super_block *sb, sector_t block)
 
        pvoldesc = (struct primaryVolDesc *)bh->b_data;
 
-       if (udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
-                             pvoldesc->recordingDateAndTime)) {
+       udf_disk_stamp_to_time(&UDF_SB(sb)->s_record_time,
+                             pvoldesc->recordingDateAndTime);
 #ifdef UDFFS_DEBUG
-               struct timestamp *ts = &pvoldesc->recordingDateAndTime;
-               udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
-                         le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
-                         ts->minute, le16_to_cpu(ts->typeAndTimezone));
+       ts = &pvoldesc->recordingDateAndTime;
+       udf_debug("recording time %04u/%02u/%02u %02u:%02u (%x)\n",
+                 le16_to_cpu(ts->year), ts->month, ts->day, ts->hour,
+                 ts->minute, le16_to_cpu(ts->typeAndTimezone));
 #endif
-       }
+
 
        ret = udf_dstrCS0toChar(sb, outstr, 31, pvoldesc->volIdent, 32);
        if (ret < 0)
@@ -1585,7 +1588,7 @@ static struct udf_vds_record *handle_partition_descriptor(
                struct udf_vds_record *new_loc;
                unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP);
 
-               new_loc = kzalloc(sizeof(*new_loc) * new_size, GFP_KERNEL);
+               new_loc = kcalloc(new_size, sizeof(*new_loc), GFP_KERNEL);
                if (!new_loc)
                        return ERR_PTR(-ENOMEM);
                memcpy(new_loc, data->part_descs_loc,
@@ -1644,8 +1647,9 @@ static noinline int udf_process_sequence(
 
        memset(data.vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH);
        data.size_part_descs = PART_DESC_ALLOC_STEP;
-       data.part_descs_loc = kzalloc(sizeof(*data.part_descs_loc) *
-                                       data.size_part_descs, GFP_KERNEL);
+       data.part_descs_loc = kcalloc(data.size_part_descs,
+                                     sizeof(*data.part_descs_loc),
+                                     GFP_KERNEL);
        if (!data.part_descs_loc)
                return -ENOMEM;
 
index fc8d1b3384d25767df9d083ab1088a3dbbc52d5c..bae311b59400459338d2c60f9e962429066e1483 100644 (file)
@@ -253,8 +253,8 @@ extern struct long_ad *udf_get_filelongad(uint8_t *, int, uint32_t *, int);
 extern struct short_ad *udf_get_fileshortad(uint8_t *, int, uint32_t *, int);
 
 /* udftime.c */
-extern struct timespec *udf_disk_stamp_to_time(struct timespec *dest,
+extern void udf_disk_stamp_to_time(struct timespec *dest,
                                                struct timestamp src);
-extern struct timestamp *udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
+extern void udf_time_to_disk_stamp(struct timestamp *dest, struct timespec src);
 
 #endif                         /* __UDF_DECL_H */
index 0927a4b2ecafba09171d62adf90edd13b791b668..67b33ac5d41bdd5d4078dcdb7f1e3ab5ec2f16c1 100644 (file)
@@ -40,7 +40,7 @@
 #include <linux/kernel.h>
 #include <linux/time.h>
 
-struct timespec *
+void
 udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
 {
        u16 typeAndTimezone = le16_to_cpu(src.typeAndTimezone);
@@ -67,10 +67,9 @@ udf_disk_stamp_to_time(struct timespec *dest, struct timestamp src)
         * recorded with bogus sub-second values.
         */
        dest->tv_nsec %= NSEC_PER_SEC;
-       return dest;
 }
 
-struct timestamp *
+void
 udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
 {
        long seconds;
@@ -79,9 +78,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
 
        offset = -sys_tz.tz_minuteswest;
 
-       if (!dest)
-               return NULL;
-
        dest->typeAndTimezone = cpu_to_le16(0x1000 | (offset & 0x0FFF));
 
        seconds = ts.tv_sec + offset * 60;
@@ -97,7 +93,6 @@ udf_time_to_disk_stamp(struct timestamp *dest, struct timespec ts)
                                        dest->centiseconds * 10000) / 100;
        dest->microseconds = (ts.tv_nsec / 1000 - dest->centiseconds * 10000 -
                              dest->hundredsOfMicroseconds * 100);
-       return dest;
 }
 
 /* EOF */
index 8254b8b3690fa7d553c4ec6187a99f9c420f023f..488088141451ba6c9dab80dd0c96a1502100b3f7 100644 (file)
@@ -541,7 +541,9 @@ static int ufs_read_cylinder_structures(struct super_block *sb)
         * Read cylinder group (we read only first fragment from block
         * at this time) and prepare internal data structures for cg caching.
         */
-       if (!(sbi->s_ucg = kmalloc (sizeof(struct buffer_head *) * uspi->s_ncg, GFP_NOFS)))
+       sbi->s_ucg = kmalloc_array(uspi->s_ncg, sizeof(struct buffer_head *),
+                                  GFP_NOFS);
+       if (!sbi->s_ucg)
                goto failed;
        for (i = 0; i < uspi->s_ncg; i++) 
                sbi->s_ucg[i] = NULL;
index e8d67a443bd7c54663fcf447d6cc025df644cf1e..2f3f75a7f180fff432d29d5b64167ed9c1014865 100644 (file)
@@ -1,20 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
 #
 # Copyright (c) 2000-2005 Silicon Graphics, Inc.
 # All Rights Reserved.
 #
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it would be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write the Free Software Foundation,
-# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-#
 
 ccflags-y += -I$(src)                  # needed for trace events
 ccflags-y += -I$(src)/libxfs
@@ -62,6 +50,7 @@ xfs-y                         += $(addprefix libxfs/, \
                                   xfs_sb.o \
                                   xfs_symlink_remote.o \
                                   xfs_trans_resv.o \
+                                  xfs_types.o \
                                   )
 # xfs_rtbitmap is shared with libxfs
 xfs-$(CONFIG_XFS_RT)           += $(addprefix libxfs/, \
index 7bace03dc9dcfdb816347127066288aeda286470..fdd9d6ede25ca74065c2b092c742031068270aae 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include <linux/mm.h>
 #include <linux/sched/mm.h>
index 6023b594ead71a42fdfc2d81c44e79bb914083ba..8e6b3ba81c03e398d2b91c76c456760c2a97ae82 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_SUPPORT_KMEM_H__
 #define __XFS_SUPPORT_KMEM_H__
index 03885a968de877ac73038d942fd687e51a1afe3d..84db76e0e3e3c58ae7d25b38a46a1ce2b4d5cae4 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 938f2f96c5e8c00140bcf606fac82ef1ecca5d8e..4619b554ee90381406363a1f4a7ca3924c7df748 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_AG_RESV_H__
 #define        __XFS_AG_RESV_H__
index dc9dd3805d97b309442b9fce04186a51cd5e3dcc..eef466260d43adb3cc9ef6ae3dcea36f82cd90a4 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -227,15 +215,37 @@ xfs_alloc_get_rec(
        xfs_extlen_t            *len,   /* output: length of extent */
        int                     *stat)  /* output: success/failure */
 {
+       struct xfs_mount        *mp = cur->bc_mp;
+       xfs_agnumber_t          agno = cur->bc_private.a.agno;
        union xfs_btree_rec     *rec;
        int                     error;
 
        error = xfs_btree_get_rec(cur, &rec, stat);
-       if (!error && *stat == 1) {
-               *bno = be32_to_cpu(rec->alloc.ar_startblock);
-               *len = be32_to_cpu(rec->alloc.ar_blockcount);
-       }
-       return error;
+       if (error || !(*stat))
+               return error;
+       if (rec->alloc.ar_blockcount == 0)
+               goto out_bad_rec;
+
+       *bno = be32_to_cpu(rec->alloc.ar_startblock);
+       *len = be32_to_cpu(rec->alloc.ar_blockcount);
+
+       /* check for valid extent range, including overflow */
+       if (!xfs_verify_agbno(mp, agno, *bno))
+               goto out_bad_rec;
+       if (*bno > *bno + *len)
+               goto out_bad_rec;
+       if (!xfs_verify_agbno(mp, agno, *bno + *len - 1))
+               goto out_bad_rec;
+
+       return 0;
+
+out_bad_rec:
+       xfs_warn(mp,
+               "%s Freespace BTree record corruption in AG %d detected!",
+               cur->bc_btnum == XFS_BTNUM_BNO ? "Block" : "Size", agno);
+       xfs_warn(mp,
+               "start block 0x%x block count 0x%x", *bno, *len);
+       return -EFSCORRUPTED;
 }
 
 /*
@@ -3113,55 +3123,6 @@ xfs_alloc_query_all(
        return xfs_btree_query_all(cur, xfs_alloc_query_range_helper, &query);
 }
 
-/* Find the size of the AG, in blocks. */
-xfs_agblock_t
-xfs_ag_block_count(
-       struct xfs_mount        *mp,
-       xfs_agnumber_t          agno)
-{
-       ASSERT(agno < mp->m_sb.sb_agcount);
-
-       if (agno < mp->m_sb.sb_agcount - 1)
-               return mp->m_sb.sb_agblocks;
-       return mp->m_sb.sb_dblocks - (agno * mp->m_sb.sb_agblocks);
-}
-
-/*
- * Verify that an AG block number pointer neither points outside the AG
- * nor points at static metadata.
- */
-bool
-xfs_verify_agbno(
-       struct xfs_mount        *mp,
-       xfs_agnumber_t          agno,
-       xfs_agblock_t           agbno)
-{
-       xfs_agblock_t           eoag;
-
-       eoag = xfs_ag_block_count(mp, agno);
-       if (agbno >= eoag)
-               return false;
-       if (agbno <= XFS_AGFL_BLOCK(mp))
-               return false;
-       return true;
-}
-
-/*
- * Verify that an FS block number pointer neither points outside the
- * filesystem nor points at static AG metadata.
- */
-bool
-xfs_verify_fsbno(
-       struct xfs_mount        *mp,
-       xfs_fsblock_t           fsbno)
-{
-       xfs_agnumber_t          agno = XFS_FSB_TO_AGNO(mp, fsbno);
-
-       if (agno >= mp->m_sb.sb_agcount)
-               return false;
-       return xfs_verify_agbno(mp, agno, XFS_FSB_TO_AGBNO(mp, fsbno));
-}
-
 /* Is there a record covering a given extent? */
 int
 xfs_alloc_has_record(
index 0747adcd57d63acc66c441e10a028710dab21ef4..e716c993ac4c5b6a52d9f42ea6fa5459bd796a20 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_ALLOC_H__
 #define        __XFS_ALLOC_H__
@@ -254,10 +242,6 @@ int xfs_alloc_query_range(struct xfs_btree_cur *cur,
                xfs_alloc_query_range_fn fn, void *priv);
 int xfs_alloc_query_all(struct xfs_btree_cur *cur, xfs_alloc_query_range_fn fn,
                void *priv);
-xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno);
-bool xfs_verify_agbno(struct xfs_mount *mp, xfs_agnumber_t agno,
-               xfs_agblock_t agbno);
-bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
 
 int xfs_alloc_has_record(struct xfs_btree_cur *cur, xfs_agblock_t bno,
                xfs_extlen_t len, bool *exist);
index 18aec7a0e5998f64d5d7c9f90f263c919d31f217..4e59cc8a280221973279f262e2ee613ba61a5b3d 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -242,7 +230,6 @@ xfs_allocbt_init_ptr_from_cur(
        struct xfs_agf          *agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
 
        ASSERT(cur->bc_private.a.agno == be32_to_cpu(agf->agf_seqno));
-       ASSERT(agf->agf_roots[cur->bc_btnum] != 0);
 
        ptr->s = agf->agf_roots[cur->bc_btnum];
 }
index 2fd54728871ccdf85614bfa7091c2f2cec37b39e..c9305ebb69f634bd3c6ccffc9dd133a35bca19f6 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_ALLOC_BTREE_H__
 #define        __XFS_ALLOC_BTREE_H__
index c3d02a66d39dcb92eda2607803041ec65088a584..99590f61d624be66bef0248c93ba1e8a806b4215 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 2135b8e67dcc15fdb969939c5fd6b18d09d0fdda..76e90046731cad79b4127396d78a26050a9e4a8a 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -477,7 +465,7 @@ xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes)
         * A data fork btree root must have space for at least
         * MINDBTPTRS key/ptr pairs if the data fork is small or empty.
         */
-       minforkoff = MAX(dsize, XFS_BMDR_SPACE_CALC(MINDBTPTRS));
+       minforkoff = max(dsize, XFS_BMDR_SPACE_CALC(MINDBTPTRS));
        minforkoff = roundup(minforkoff, 8) >> 3;
 
        /* attr fork btree root can have at least this many key/ptr pairs */
@@ -803,9 +791,8 @@ xfs_attr_shortform_to_leaf(
        ASSERT(blkno == 0);
        error = xfs_attr3_leaf_create(args, blkno, &bp);
        if (error) {
-               error = xfs_da_shrink_inode(args, 0, bp);
-               bp = NULL;
-               if (error)
+               /* xfs_attr3_leaf_create may not have instantiated a block */
+               if (bp && (xfs_da_shrink_inode(args, 0, bp) != 0))
                        goto out;
                xfs_idata_realloc(dp, size, XFS_ATTR_FORK);     /* try to put */
                memcpy(ifp->if_u1.if_data, tmpbuffer, size);    /* it back */
index 4da08af5b13401a08e454f60620f4e1cde44c7a5..7b74e18becff79950778a62faf0a9a31b2becdc6 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_ATTR_LEAF_H__
 #define        __XFS_ATTR_LEAF_H__
index 83a6d3c7f872db5e7cc18472937629d37a655927..bf2e0371149bf5fc5259bc0eb9a66b91870e7b45 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 5a9acfa156d7af59855fde90fb5e6d8721ea289b..9d20b66ad379e776e70fd420f88af77d0b69d435 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_ATTR_REMOTE_H__
 #define        __XFS_ATTR_REMOTE_H__
index afd684ae31365f061c1f4a6ba9b729293bf478ca..aafa4fe706240e3575448253b6d085be3711c504 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_ATTR_SF_H__
 #define        __XFS_ATTR_SF_H__
index 0a94cce5ea356bd5a22be0ea6003434998510bf2..40ce5f3094d19d399bca5758b428177dcadd7824 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_log_format.h"
index 61c6b2025d0c83cbee67c8d4b156023e15ac0a2a..99017b8df292586d7e6fbe045e1abab2862e93a4 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_BIT_H__
 #define        __XFS_BIT_H__
index 7b0e2b551e23b84642b4399a77c322d935e25556..01628f0c9a0c227543087c70bd7391ad3f0eee2c 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -1248,7 +1236,6 @@ xfs_iread_extents(
 
                num_recs = xfs_btree_get_numrecs(block);
                if (unlikely(i + num_recs > nextents)) {
-                       ASSERT(i + num_recs <= nextents);
                        xfs_warn(ip->i_mount,
                                "corrupt dinode %Lu, (btree extents).",
                                (unsigned long long) ip->i_ino);
@@ -2936,7 +2923,7 @@ xfs_bmap_extsize_align(
         * perform this alignment, or if a truncate shot us in the
         * foot.
         */
-       temp = do_mod(orig_off, extsz);
+       div_u64_rem(orig_off, extsz, &temp);
        if (temp) {
                align_alen += temp;
                align_off -= temp;
@@ -3480,7 +3467,7 @@ xfs_bmap_btalloc(
        xfs_rmap_skip_owner_update(&args.oinfo);
 
        /* Trim the allocation back to the maximum an AG can fit. */
-       args.maxlen = MIN(ap->length, mp->m_ag_max_usable);
+       args.maxlen = min(ap->length, mp->m_ag_max_usable);
        args.firstblock = *ap->firstblock;
        blen = 0;
        if (nullfb) {
@@ -3510,15 +3497,17 @@ xfs_bmap_btalloc(
        /* apply extent size hints if obtained earlier */
        if (align) {
                args.prod = align;
-               if ((args.mod = (xfs_extlen_t)do_mod(ap->offset, args.prod)))
-                       args.mod = (xfs_extlen_t)(args.prod - args.mod);
+               div_u64_rem(ap->offset, args.prod, &args.mod);
+               if (args.mod)
+                       args.mod = args.prod - args.mod;
        } else if (mp->m_sb.sb_blocksize >= PAGE_SIZE) {
                args.prod = 1;
                args.mod = 0;
        } else {
                args.prod = PAGE_SIZE >> mp->m_sb.sb_blocklog;
-               if ((args.mod = (xfs_extlen_t)(do_mod(ap->offset, args.prod))))
-                       args.mod = (xfs_extlen_t)(args.prod - args.mod);
+               div_u64_rem(ap->offset, args.prod, &args.mod);
+               if (args.mod)
+                       args.mod = args.prod - args.mod;
        }
        /*
         * If we are not low on available data blocks, and the
@@ -4966,13 +4955,15 @@ xfs_bmap_del_extent_real(
        if (whichfork == XFS_DATA_FORK && XFS_IS_REALTIME_INODE(ip)) {
                xfs_fsblock_t   bno;
                xfs_filblks_t   len;
+               xfs_extlen_t    mod;
+
+               bno = div_u64_rem(del->br_startblock, mp->m_sb.sb_rextsize,
+                                 &mod);
+               ASSERT(mod == 0);
+               len = div_u64_rem(del->br_blockcount, mp->m_sb.sb_rextsize,
+                                 &mod);
+               ASSERT(mod == 0);
 
-               ASSERT(do_mod(del->br_blockcount, mp->m_sb.sb_rextsize) == 0);
-               ASSERT(do_mod(del->br_startblock, mp->m_sb.sb_rextsize) == 0);
-               bno = del->br_startblock;
-               len = del->br_blockcount;
-               do_div(bno, mp->m_sb.sb_rextsize);
-               do_div(len, mp->m_sb.sb_rextsize);
                error = xfs_rtfree_extent(tp, bno, (xfs_extlen_t)len);
                if (error)
                        goto done;
@@ -5309,9 +5300,12 @@ __xfs_bunmapi(
                        del.br_blockcount = max_len;
                }
 
+               if (!isrt)
+                       goto delete;
+
                sum = del.br_startblock + del.br_blockcount;
-               if (isrt &&
-                   (mod = do_mod(sum, mp->m_sb.sb_rextsize))) {
+               div_u64_rem(sum, mp->m_sb.sb_rextsize, &mod);
+               if (mod) {
                        /*
                         * Realtime extent not lined up at the end.
                         * The extent could have been split into written
@@ -5358,7 +5352,8 @@ __xfs_bunmapi(
                                goto error0;
                        goto nodelete;
                }
-               if (isrt && (mod = do_mod(del.br_startblock, mp->m_sb.sb_rextsize))) {
+               div_u64_rem(del.br_startblock, mp->m_sb.sb_rextsize, &mod);
+               if (mod) {
                        /*
                         * Realtime extent is lined up at the end but not
                         * at the front.  We'll get rid of full extents if
@@ -5427,6 +5422,7 @@ __xfs_bunmapi(
                        }
                }
 
+delete:
                if (wasdel) {
                        error = xfs_bmap_del_extent_delay(ip, whichfork, &icur,
                                        &got, &del);
index 2c233f9f1a2605c18bba863fbf62b0131f6b69a9..99dddbd0fcc6c606e59544d69a0435b0cc205c5f 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_BMAP_H__
 #define        __XFS_BMAP_H__
index ac9d4aeedb093fc80fb28badf461b68d47914765..e1a2d9ceb61528c53953840f00836b851bd1142a 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index fb3cd2d9e0f83af29a8078dd04a32a916743ad6c..29b407d053b4e9fd948b92415a9e2c94d8022c83 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2002-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_BMAP_BTREE_H__
 #define __XFS_BMAP_BTREE_H__
index c825c8182b301194cb0cdf952a1591540e95f307..34c6d7bd4d180c736d8da7e6c33a413ee177ac5f 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -234,7 +222,6 @@ xfs_btree_check_sptr(
        return xfs_verify_agbno(cur->bc_mp, cur->bc_private.a.agno, agbno);
 }
 
-#ifdef DEBUG
 /*
  * Check that a given (indexed) btree pointer at a certain level of a
  * btree is valid and doesn't point past where it should.
@@ -247,17 +234,31 @@ xfs_btree_check_ptr(
        int                     level)
 {
        if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
-               XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
-                               xfs_btree_check_lptr(cur,
-                                       be64_to_cpu((&ptr->l)[index]), level));
+               if (xfs_btree_check_lptr(cur, be64_to_cpu((&ptr->l)[index]),
+                               level))
+                       return 0;
+               xfs_err(cur->bc_mp,
+"Inode %llu fork %d: Corrupt btree %d pointer at level %d index %d.",
+                               cur->bc_private.b.ip->i_ino,
+                               cur->bc_private.b.whichfork, cur->bc_btnum,
+                               level, index);
        } else {
-               XFS_WANT_CORRUPTED_RETURN(cur->bc_mp,
-                               xfs_btree_check_sptr(cur,
-                                       be32_to_cpu((&ptr->s)[index]), level));
+               if (xfs_btree_check_sptr(cur, be32_to_cpu((&ptr->s)[index]),
+                               level))
+                       return 0;
+               xfs_err(cur->bc_mp,
+"AG %u: Corrupt btree %d pointer at level %d index %d.",
+                               cur->bc_private.a.agno, cur->bc_btnum,
+                               level, index);
        }
 
-       return 0;
+       return -EFSCORRUPTED;
 }
+
+#ifdef DEBUG
+# define xfs_btree_debug_check_ptr     xfs_btree_check_ptr
+#else
+# define xfs_btree_debug_check_ptr(...)        (0)
 #endif
 
 /*
@@ -988,22 +989,30 @@ xfs_btree_readahead(
        return xfs_btree_readahead_sblock(cur, lr, block);
 }
 
-STATIC xfs_daddr_t
+STATIC int
 xfs_btree_ptr_to_daddr(
        struct xfs_btree_cur    *cur,
-       union xfs_btree_ptr     *ptr)
+       union xfs_btree_ptr     *ptr,
+       xfs_daddr_t             *daddr)
 {
-       if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
-               ASSERT(ptr->l != cpu_to_be64(NULLFSBLOCK));
+       xfs_fsblock_t           fsbno;
+       xfs_agblock_t           agbno;
+       int                     error;
 
-               return XFS_FSB_TO_DADDR(cur->bc_mp, be64_to_cpu(ptr->l));
-       } else {
-               ASSERT(cur->bc_private.a.agno != NULLAGNUMBER);
-               ASSERT(ptr->s != cpu_to_be32(NULLAGBLOCK));
+       error = xfs_btree_check_ptr(cur, ptr, 0, 1);
+       if (error)
+               return error;
 
-               return XFS_AGB_TO_DADDR(cur->bc_mp, cur->bc_private.a.agno,
-                                       be32_to_cpu(ptr->s));
+       if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
+               fsbno = be64_to_cpu(ptr->l);
+               *daddr = XFS_FSB_TO_DADDR(cur->bc_mp, fsbno);
+       } else {
+               agbno = be32_to_cpu(ptr->s);
+               *daddr = XFS_AGB_TO_DADDR(cur->bc_mp, cur->bc_private.a.agno,
+                               agbno);
        }
+
+       return 0;
 }
 
 /*
@@ -1018,8 +1027,11 @@ xfs_btree_readahead_ptr(
        union xfs_btree_ptr     *ptr,
        xfs_extlen_t            count)
 {
-       xfs_buf_readahead(cur->bc_mp->m_ddev_targp,
-                         xfs_btree_ptr_to_daddr(cur, ptr),
+       xfs_daddr_t             daddr;
+
+       if (xfs_btree_ptr_to_daddr(cur, ptr, &daddr))
+               return;
+       xfs_buf_readahead(cur->bc_mp->m_ddev_targp, daddr,
                          cur->bc_mp->m_bsize * count, cur->bc_ops->buf_ops);
 }
 
@@ -1282,11 +1294,14 @@ xfs_btree_get_buf_block(
 {
        struct xfs_mount        *mp = cur->bc_mp;
        xfs_daddr_t             d;
+       int                     error;
 
        /* need to sort out how callers deal with failures first */
        ASSERT(!(flags & XBF_TRYLOCK));
 
-       d = xfs_btree_ptr_to_daddr(cur, ptr);
+       error = xfs_btree_ptr_to_daddr(cur, ptr, &d);
+       if (error)
+               return error;
        *bpp = xfs_trans_get_buf(cur->bc_tp, mp->m_ddev_targp, d,
                                 mp->m_bsize, flags);
 
@@ -1317,7 +1332,9 @@ xfs_btree_read_buf_block(
        /* need to sort out how callers deal with failures first */
        ASSERT(!(flags & XBF_TRYLOCK));
 
-       d = xfs_btree_ptr_to_daddr(cur, ptr);
+       error = xfs_btree_ptr_to_daddr(cur, ptr, &d);
+       if (error)
+               return error;
        error = xfs_trans_read_buf(mp, cur->bc_tp, mp->m_ddev_targp, d,
                                   mp->m_bsize, flags, bpp,
                                   cur->bc_ops->buf_ops);
@@ -1764,6 +1781,7 @@ xfs_btree_lookup_get_block(
        struct xfs_btree_block  **blkp) /* return btree block */
 {
        struct xfs_buf          *bp;    /* buffer pointer for btree block */
+       xfs_daddr_t             daddr;
        int                     error = 0;
 
        /* special case the root block if in an inode */
@@ -1780,7 +1798,10 @@ xfs_btree_lookup_get_block(
         * Otherwise throw it away and get a new one.
         */
        bp = cur->bc_bufs[level];
-       if (bp && XFS_BUF_ADDR(bp) == xfs_btree_ptr_to_daddr(cur, pp)) {
+       error = xfs_btree_ptr_to_daddr(cur, pp, &daddr);
+       if (error)
+               return error;
+       if (bp && XFS_BUF_ADDR(bp) == daddr) {
                *blkp = XFS_BUF_TO_BLOCK(bp);
                return 0;
        }
@@ -1896,7 +1917,13 @@ xfs_btree_lookup(
                        high = xfs_btree_get_numrecs(block);
                        if (!high) {
                                /* Block is empty, must be an empty leaf. */
-                               ASSERT(level == 0 && cur->bc_nlevels == 1);
+                               if (level != 0 || cur->bc_nlevels != 1) {
+                                       XFS_CORRUPTION_ERROR(__func__,
+                                                       XFS_ERRLEVEL_LOW,
+                                                       cur->bc_mp, block,
+                                                       sizeof(*block));
+                                       return -EFSCORRUPTED;
+                               }
 
                                cur->bc_ptrs[0] = dir != XFS_LOOKUP_LE;
                                *stat = 0;
@@ -1946,11 +1973,10 @@ xfs_btree_lookup(
                                keyno = 1;
                        pp = xfs_btree_ptr_addr(cur, keyno, block);
 
-#ifdef DEBUG
-                       error = xfs_btree_check_ptr(cur, pp, 0, level);
+                       error = xfs_btree_debug_check_ptr(cur, pp, 0, level);
                        if (error)
                                goto error0;
-#endif
+
                        cur->bc_ptrs[level] = keyno;
                }
        }
@@ -2354,11 +2380,11 @@ xfs_btree_lshift(
 
                lpp = xfs_btree_ptr_addr(cur, lrecs, left);
                rpp = xfs_btree_ptr_addr(cur, 1, right);
-#ifdef DEBUG
-               error = xfs_btree_check_ptr(cur, rpp, 0, level);
+
+               error = xfs_btree_debug_check_ptr(cur, rpp, 0, level);
                if (error)
                        goto error0;
-#endif
+
                xfs_btree_copy_keys(cur, lkp, rkp, 1);
                xfs_btree_copy_ptrs(cur, lpp, rpp, 1);
 
@@ -2393,15 +2419,14 @@ xfs_btree_lshift(
        XFS_BTREE_STATS_ADD(cur, moves, rrecs - 1);
        if (level > 0) {
                /* It's a nonleaf. operate on keys and ptrs */
-#ifdef DEBUG
                int                     i;              /* loop index */
 
                for (i = 0; i < rrecs; i++) {
-                       error = xfs_btree_check_ptr(cur, rpp, i + 1, level);
+                       error = xfs_btree_debug_check_ptr(cur, rpp, i + 1, level);
                        if (error)
                                goto error0;
                }
-#endif
+
                xfs_btree_shift_keys(cur,
                                xfs_btree_key_addr(cur, 2, right),
                                -1, rrecs);
@@ -2541,22 +2566,18 @@ xfs_btree_rshift(
                rkp = xfs_btree_key_addr(cur, 1, right);
                rpp = xfs_btree_ptr_addr(cur, 1, right);
 
-#ifdef DEBUG
                for (i = rrecs - 1; i >= 0; i--) {
-                       error = xfs_btree_check_ptr(cur, rpp, i, level);
+                       error = xfs_btree_debug_check_ptr(cur, rpp, i, level);
                        if (error)
                                goto error0;
                }
-#endif
 
                xfs_btree_shift_keys(cur, rkp, 1, rrecs);
                xfs_btree_shift_ptrs(cur, rpp, 1, rrecs);
 
-#ifdef DEBUG
-               error = xfs_btree_check_ptr(cur, lpp, 0, level);
+               error = xfs_btree_debug_check_ptr(cur, lpp, 0, level);
                if (error)
                        goto error0;
-#endif
 
                /* Now put the new data in, and log it. */
                xfs_btree_copy_keys(cur, rkp, lkp, 1);
@@ -2661,9 +2682,7 @@ __xfs_btree_split(
        int                     rrecs;
        int                     src_index;
        int                     error;          /* error return value */
-#ifdef DEBUG
        int                     i;
-#endif
 
        XFS_BTREE_STATS_INC(cur, split);
 
@@ -2729,13 +2748,11 @@ __xfs_btree_split(
                rkp = xfs_btree_key_addr(cur, 1, right);
                rpp = xfs_btree_ptr_addr(cur, 1, right);
 
-#ifdef DEBUG
                for (i = src_index; i < rrecs; i++) {
-                       error = xfs_btree_check_ptr(cur, lpp, i, level);
+                       error = xfs_btree_debug_check_ptr(cur, lpp, i, level);
                        if (error)
                                goto error0;
                }
-#endif
 
                /* Copy the keys & pointers to the new block. */
                xfs_btree_copy_keys(cur, rkp, lkp, rrecs);
@@ -2923,9 +2940,7 @@ xfs_btree_new_iroot(
        union xfs_btree_ptr     nptr;           /* new block addr */
        int                     level;          /* btree level */
        int                     error;          /* error return code */
-#ifdef DEBUG
        int                     i;              /* loop counter */
-#endif
 
        XFS_BTREE_STATS_INC(cur, newroot);
 
@@ -2972,20 +2987,18 @@ xfs_btree_new_iroot(
        xfs_btree_copy_keys(cur, ckp, kp, xfs_btree_get_numrecs(cblock));
 
        cpp = xfs_btree_ptr_addr(cur, 1, cblock);
-#ifdef DEBUG
        for (i = 0; i < be16_to_cpu(cblock->bb_numrecs); i++) {
-               error = xfs_btree_check_ptr(cur, pp, i, level);
+               error = xfs_btree_debug_check_ptr(cur, pp, i, level);
                if (error)
                        goto error0;
        }
-#endif
+
        xfs_btree_copy_ptrs(cur, cpp, pp, xfs_btree_get_numrecs(cblock));
 
-#ifdef DEBUG
-       error = xfs_btree_check_ptr(cur, &nptr, 0, level);
+       error = xfs_btree_debug_check_ptr(cur, &nptr, 0, level);
        if (error)
                goto error0;
-#endif
+
        xfs_btree_copy_ptrs(cur, pp, &nptr, 1);
 
        xfs_iroot_realloc(cur->bc_private.b.ip,
@@ -3229,9 +3242,7 @@ xfs_btree_insrec(
        int                     ptr;    /* key/record index */
        int                     numrecs;/* number of records */
        int                     error;  /* error return value */
-#ifdef DEBUG
        int                     i;
-#endif
        xfs_daddr_t             old_bn;
 
        ncur = NULL;
@@ -3321,22 +3332,18 @@ xfs_btree_insrec(
                kp = xfs_btree_key_addr(cur, ptr, block);
                pp = xfs_btree_ptr_addr(cur, ptr, block);
 
-#ifdef DEBUG
                for (i = numrecs - ptr; i >= 0; i--) {
-                       error = xfs_btree_check_ptr(cur, pp, i, level);
+                       error = xfs_btree_debug_check_ptr(cur, pp, i, level);
                        if (error)
                                return error;
                }
-#endif
 
                xfs_btree_shift_keys(cur, kp, 1, numrecs - ptr + 1);
                xfs_btree_shift_ptrs(cur, pp, 1, numrecs - ptr + 1);
 
-#ifdef DEBUG
-               error = xfs_btree_check_ptr(cur, ptrp, 0, level);
+               error = xfs_btree_debug_check_ptr(cur, ptrp, 0, level);
                if (error)
                        goto error0;
-#endif
 
                /* Now put the new data in, bump numrecs and log it. */
                xfs_btree_copy_keys(cur, kp, key, 1);
@@ -3524,8 +3531,8 @@ xfs_btree_kill_iroot(
        int                     error;
 #ifdef DEBUG
        union xfs_btree_ptr     ptr;
-       int                     i;
 #endif
+       int                     i;
 
        ASSERT(cur->bc_flags & XFS_BTREE_ROOT_IN_INODE);
        ASSERT(cur->bc_nlevels > 1);
@@ -3581,13 +3588,13 @@ xfs_btree_kill_iroot(
 
        pp = xfs_btree_ptr_addr(cur, 1, block);
        cpp = xfs_btree_ptr_addr(cur, 1, cblock);
-#ifdef DEBUG
+
        for (i = 0; i < numrecs; i++) {
-               error = xfs_btree_check_ptr(cur, cpp, i, level - 1);
+               error = xfs_btree_debug_check_ptr(cur, cpp, i, level - 1);
                if (error)
                        return error;
        }
-#endif
+
        xfs_btree_copy_ptrs(cur, pp, cpp, numrecs);
 
        error = xfs_btree_free_block(cur, cbp);
@@ -3721,13 +3728,11 @@ xfs_btree_delrec(
                lkp = xfs_btree_key_addr(cur, ptr + 1, block);
                lpp = xfs_btree_ptr_addr(cur, ptr + 1, block);
 
-#ifdef DEBUG
                for (i = 0; i < numrecs - ptr; i++) {
-                       error = xfs_btree_check_ptr(cur, lpp, i, level);
+                       error = xfs_btree_debug_check_ptr(cur, lpp, i, level);
                        if (error)
                                goto error0;
                }
-#endif
 
                if (ptr < numrecs) {
                        xfs_btree_shift_keys(cur, lkp, -1, numrecs - ptr);
@@ -4060,13 +4065,13 @@ xfs_btree_delrec(
                lpp = xfs_btree_ptr_addr(cur, lrecs + 1, left);
                rkp = xfs_btree_key_addr(cur, 1, right);
                rpp = xfs_btree_ptr_addr(cur, 1, right);
-#ifdef DEBUG
+
                for (i = 1; i < rrecs; i++) {
-                       error = xfs_btree_check_ptr(cur, rpp, i, level);
+                       error = xfs_btree_debug_check_ptr(cur, rpp, i, level);
                        if (error)
                                goto error0;
                }
-#endif
+
                xfs_btree_copy_keys(cur, lkp, rkp, rrecs);
                xfs_btree_copy_ptrs(cur, lpp, rpp, rrecs);
 
index d7911efee6dcb474748b064eb4f6383746911e7d..0a4fdf7f11a73cae877f4ab22dd0aeabfee932d0 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_BTREE_H__
 #define        __XFS_BTREE_H__
index ea187b4a7991c15343d1405af8720e20b2166abc..8a301402bbc4e3bb6f54abfa0320a33cba1eddaa 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -305,9 +293,11 @@ xfs_da3_node_read(
                        type = XFS_BLFT_DIR_LEAFN_BUF;
                        break;
                default:
-                       type = 0;
-                       ASSERT(0);
-                       break;
+                       XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW,
+                                       tp->t_mountp, info, sizeof(*info));
+                       xfs_trans_brelse(tp, *bpp);
+                       *bpp = NULL;
+                       return -EFSCORRUPTED;
                }
                xfs_trans_buf_set_type(tp, *bpp, type);
        }
@@ -2091,7 +2081,7 @@ xfs_da_grow_inode_int(
                 */
                mapp = kmem_alloc(sizeof(*mapp) * count, KM_SLEEP);
                for (b = *bno, mapi = 0; b < *bno + count; ) {
-                       nmap = MIN(XFS_BMAP_MAX_NMAP, count);
+                       nmap = min(XFS_BMAP_MAX_NMAP, count);
                        c = (int)(*bno + count - b);
                        error = xfs_bmapi_write(tp, dp, b, c,
                                        xfs_bmapi_aflag(w)|XFS_BMAPI_METADATA,
index ae6de17467f265b0d416b7e49d575aa0002552b2..28260073ae71af3d1f7bbbb277fe2d9677843067 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_DA_BTREE_H__
 #define        __XFS_DA_BTREE_H__
index 6d77d1a8498ad62c6d3775f39ed9f4b8e5a5afd6..b39053dcb643976fe571a13db58202c0dcdb251f 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 7e77299b778950127cbbcbe9b1dea5feb2ca6e10..5d5bf3bffc783a1f3711cdf9edca5c2e4ccc2e4b 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_DA_FORMAT_H__
 #define __XFS_DA_FORMAT_H__
index 3daf175e25359d4f3bde26b9fb3903c41489bf4a..c3e5bffda4f5e5b3e36c67638e58eff957c964fe 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index e70725ba1f5f794d2b262084e44ac3f80680c7b5..a02b2b748b6d062bc233f488b89d43ea70464b48 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_DEFER_H__
 #define        __XFS_DEFER_H__
index 92f94e190f04474953105c049b62a8367fbc7d1e..59169aff30fef499014e79c5e437137410e1ee32 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 989e95a53db2fef07fac1a0103888513b4b518c9..ed385316c7dccc6d08bde28fbb5f65b2ed7abba8 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_DIR2_H__
 #define __XFS_DIR2_H__
index 875893ded514329a49c92eaacb1ec9995abe9f88..30ed5919da7235e8885afbe15adacffad9949a79 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -514,8 +502,8 @@ xfs_dir2_block_addname(
                        if (mid - lowstale)
                                memmove(&blp[lowstale], &blp[lowstale + 1],
                                        (mid - lowstale) * sizeof(*blp));
-                       lfloglow = MIN(lowstale, lfloglow);
-                       lfloghigh = MAX(mid, lfloghigh);
+                       lfloglow = min(lowstale, lfloglow);
+                       lfloghigh = max(mid, lfloghigh);
                }
                /*
                 * Move entries toward the high-numbered stale entry.
@@ -526,8 +514,8 @@ xfs_dir2_block_addname(
                        if (highstale - mid)
                                memmove(&blp[mid + 1], &blp[mid],
                                        (highstale - mid) * sizeof(*blp));
-                       lfloglow = MIN(mid, lfloglow);
-                       lfloghigh = MAX(highstale, lfloghigh);
+                       lfloglow = min(mid, lfloglow);
+                       lfloghigh = max(highstale, lfloghigh);
                }
                be32_add_cpu(&btp->stale, -1);
        }
index cb67ec730b9bd50caf46e6dcd35e1e76aef46203..01162c62ec8f8fe49ac05c68a9b8925b2b693946 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
 #include "xfs_cksum.h"
 #include "xfs_log.h"
 
+static xfs_failaddr_t xfs_dir2_data_freefind_verify(
+               struct xfs_dir2_data_hdr *hdr, struct xfs_dir2_data_free *bf,
+               struct xfs_dir2_data_unused *dup,
+               struct xfs_dir2_data_free **bf_ent);
+
 /*
  * Check the consistency of the data block.
  * The input can also be a block-format directory.
@@ -147,6 +140,8 @@ __xfs_dir3_data_check(
                 * doesn't need to be there.
                 */
                if (be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG) {
+                       xfs_failaddr_t  fa;
+
                        if (lastfree != 0)
                                return __this_address;
                        if (endp < p + be16_to_cpu(dup->length))
@@ -154,7 +149,9 @@ __xfs_dir3_data_check(
                        if (be16_to_cpu(*xfs_dir2_data_unused_tag_p(dup)) !=
                            (char *)dup - (char *)hdr)
                                return __this_address;
-                       dfp = xfs_dir2_data_freefind(hdr, bf, dup);
+                       fa = xfs_dir2_data_freefind_verify(hdr, bf, dup, &dfp);
+                       if (fa)
+                               return fa;
                        if (dfp) {
                                i = (int)(dfp - bf);
                                if ((freeseen & (1 << i)) != 0)
@@ -242,7 +239,8 @@ xfs_dir3_data_check(
        if (!fa)
                return;
        xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
-                       bp->b_addr, __FILE__, __LINE__, fa);
+                       bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__,
+                       fa);
        ASSERT(0);
 }
 #endif
@@ -381,55 +379,79 @@ xfs_dir3_data_readahead(
 }
 
 /*
- * Given a data block and an unused entry from that block,
- * return the bestfree entry if any that corresponds to it.
+ * Find the bestfree entry that exactly coincides with unused directory space
+ * or a verifier error because the bestfree data are bad.
  */
-xfs_dir2_data_free_t *
-xfs_dir2_data_freefind(
-       struct xfs_dir2_data_hdr *hdr,          /* data block header */
-       struct xfs_dir2_data_free *bf,          /* bestfree table pointer */
-       struct xfs_dir2_data_unused *dup)       /* unused space */
+static xfs_failaddr_t
+xfs_dir2_data_freefind_verify(
+       struct xfs_dir2_data_hdr        *hdr,
+       struct xfs_dir2_data_free       *bf,
+       struct xfs_dir2_data_unused     *dup,
+       struct xfs_dir2_data_free       **bf_ent)
 {
-       xfs_dir2_data_free_t    *dfp;           /* bestfree entry */
-       xfs_dir2_data_aoff_t    off;            /* offset value needed */
-#ifdef DEBUG
-       int                     matched;        /* matched the value */
-       int                     seenzero;       /* saw a 0 bestfree entry */
-#endif
+       struct xfs_dir2_data_free       *dfp;
+       xfs_dir2_data_aoff_t            off;
+       bool                            matched = false;
+       bool                            seenzero = false;
 
+       *bf_ent = NULL;
        off = (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr);
 
-#ifdef DEBUG
        /*
         * Validate some consistency in the bestfree table.
         * Check order, non-overlapping entries, and if we find the
         * one we're looking for it has to be exact.
         */
-       ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
-              hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
-              hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
-              hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
-       for (dfp = &bf[0], seenzero = matched = 0;
-            dfp < &bf[XFS_DIR2_DATA_FD_COUNT];
-            dfp++) {
+       for (dfp = &bf[0]; dfp < &bf[XFS_DIR2_DATA_FD_COUNT]; dfp++) {
                if (!dfp->offset) {
-                       ASSERT(!dfp->length);
-                       seenzero = 1;
+                       if (dfp->length)
+                               return __this_address;
+                       seenzero = true;
                        continue;
                }
-               ASSERT(seenzero == 0);
+               if (seenzero)
+                       return __this_address;
                if (be16_to_cpu(dfp->offset) == off) {
-                       matched = 1;
-                       ASSERT(dfp->length == dup->length);
-               } else if (off < be16_to_cpu(dfp->offset))
-                       ASSERT(off + be16_to_cpu(dup->length) <= be16_to_cpu(dfp->offset));
-               else
-                       ASSERT(be16_to_cpu(dfp->offset) + be16_to_cpu(dfp->length) <= off);
-               ASSERT(matched || be16_to_cpu(dfp->length) >= be16_to_cpu(dup->length));
-               if (dfp > &bf[0])
-                       ASSERT(be16_to_cpu(dfp[-1].length) >= be16_to_cpu(dfp[0].length));
+                       matched = true;
+                       if (dfp->length != dup->length)
+                               return __this_address;
+               } else if (be16_to_cpu(dfp->offset) > off) {
+                       if (off + be16_to_cpu(dup->length) >
+                                       be16_to_cpu(dfp->offset))
+                               return __this_address;
+               } else {
+                       if (be16_to_cpu(dfp->offset) +
+                                       be16_to_cpu(dfp->length) > off)
+                               return __this_address;
+               }
+               if (!matched &&
+                   be16_to_cpu(dfp->length) < be16_to_cpu(dup->length))
+                       return __this_address;
+               if (dfp > &bf[0] &&
+                   be16_to_cpu(dfp[-1].length) < be16_to_cpu(dfp[0].length))
+                       return __this_address;
        }
-#endif
+
+       /* Looks ok so far; now try to match up with a bestfree entry. */
+       *bf_ent = xfs_dir2_data_freefind(hdr, bf, dup);
+       return NULL;
+}
+
+/*
+ * Given a data block and an unused entry from that block,
+ * return the bestfree entry if any that corresponds to it.
+ */
+xfs_dir2_data_free_t *
+xfs_dir2_data_freefind(
+       struct xfs_dir2_data_hdr *hdr,          /* data block header */
+       struct xfs_dir2_data_free *bf,          /* bestfree table pointer */
+       struct xfs_dir2_data_unused *dup)       /* unused space */
+{
+       xfs_dir2_data_free_t    *dfp;           /* bestfree entry */
+       xfs_dir2_data_aoff_t    off;            /* offset value needed */
+
+       off = (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr);
+
        /*
         * If this is smaller than the smallest bestfree entry,
         * it can't be there since they're sorted.
@@ -1124,7 +1146,7 @@ xfs_dir2_data_use_free(
        return 0;
 corrupt:
        xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, args->dp->i_mount,
-                       hdr, __FILE__, __LINE__, fa);
+                       hdr, sizeof(*hdr), __FILE__, __LINE__, fa);
        return -EFSCORRUPTED;
 }
 
index 50fc9c0c5e2bf9314948dedb218ac898cf0f581f..1728a3e6f5cf7381460ffce134f166661e164dc3 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -81,7 +69,8 @@ xfs_dir3_leaf_check(
        if (!fa)
                return;
        xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
-                       bp->b_addr, __FILE__, __LINE__, fa);
+                       bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__,
+                       fa);
        ASSERT(0);
 }
 #else
@@ -601,8 +590,8 @@ xfs_dir3_leaf_find_entry(
                                (index - lowstale - 1) *
                                        sizeof(xfs_dir2_leaf_entry_t));
                }
-               *lfloglow = MIN(lowstale, *lfloglow);
-               *lfloghigh = MAX(index - 1, *lfloghigh);
+               *lfloglow = min(lowstale, *lfloglow);
+               *lfloghigh = max(index - 1, *lfloghigh);
                leafhdr->stale--;
                return &ents[index - 1];
        }
@@ -621,8 +610,8 @@ xfs_dir3_leaf_find_entry(
                memmove(&ents[index + 1], &ents[index],
                        (highstale - index) * sizeof(xfs_dir2_leaf_entry_t));
        }
-       *lfloglow = MIN(index, *lfloglow);
-       *lfloghigh = MAX(highstale, *lfloghigh);
+       *lfloglow = min(index, *lfloglow);
+       *lfloghigh = max(highstale, *lfloghigh);
        leafhdr->stale--;
        return &ents[index];
 }
@@ -872,7 +861,6 @@ xfs_dir2_leaf_addname(
         */
        dup = (xfs_dir2_data_unused_t *)
              ((char *)hdr + be16_to_cpu(bf[0].offset));
-       ASSERT(be16_to_cpu(dup->length) >= length);
        needscan = needlog = 0;
        /*
         * Mark the initial part of our freespace in use for the new entry.
index 9df096cc3c37176aa89b4e7145fcd433368ed3ac..2daf874969abd11e09bfe5912c6cfe60ac3101ef 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -84,7 +72,8 @@ xfs_dir3_leaf_check(
        if (!fa)
                return;
        xfs_corruption_error(__func__, XFS_ERRLEVEL_LOW, dp->i_mount,
-                       bp->b_addr, __FILE__, __LINE__, fa);
+                       bp->b_addr, BBTOB(bp->b_length), __FILE__, __LINE__,
+                       fa);
        ASSERT(0);
 }
 #else
index 753aeeeffc1833a72c2a12277157324342b4652d..59f9fb2241a5f0db3e05f339139ecb10d508e577 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_DIR2_PRIV_H__
 #define __XFS_DIR2_PRIV_H__
index 0c75a7f00883ff4b9bb2808c8d7c9229b4616088..585dfdb7b6b688f13d43fed7dd5878afedfbc8a9 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index cce520becee4358f90a60c2ccdd2f417d0db495d..d293f371dd54bc70583407a3d7638c64efbe586c 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index d47b9162594508922aa88dc73abe4020ef2b400f..b9974e7a8e6eaa76b8e01063ca49db5eafa01814 100644 (file)
@@ -1,21 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * Copyright (C) 2017 Oracle.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_ERRORTAG_H_
 #define __XFS_ERRORTAG_H_
index c1cb29a5f4f61c371a4b08cc3a6f54b1da108025..1c5a8aaf2bfcea6b51b76e7aa7dff4b55b4e4145 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_FORMAT_H__
 #define __XFS_FORMAT_H__
index dddc75e4f1f68c60a1e2cc0eadf8f8991ac83635..f3aa59302feffac144a42e1dab18e5dfe5cfb2ab 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: LGPL-2.1
 /*
  * Copyright (c) 1995-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_FS_H__
 #define __XFS_FS_H__
index 4ca4ff7a757d643e45a006400096a5b0c4ee6ce6..0d968e8143aaa50c4e86bf5d3abfa18e6a5eeb35 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -133,16 +121,45 @@ xfs_inobt_get_rec(
        struct xfs_inobt_rec_incore     *irec,
        int                             *stat)
 {
+       struct xfs_mount                *mp = cur->bc_mp;
+       xfs_agnumber_t                  agno = cur->bc_private.a.agno;
        union xfs_btree_rec             *rec;
        int                             error;
+       uint64_t                        realfree;
 
        error = xfs_btree_get_rec(cur, &rec, stat);
        if (error || *stat == 0)
                return error;
 
-       xfs_inobt_btrec_to_irec(cur->bc_mp, rec, irec);
+       xfs_inobt_btrec_to_irec(mp, rec, irec);
+
+       if (!xfs_verify_agino(mp, agno, irec->ir_startino))
+               goto out_bad_rec;
+       if (irec->ir_count < XFS_INODES_PER_HOLEMASK_BIT ||
+           irec->ir_count > XFS_INODES_PER_CHUNK)
+               goto out_bad_rec;
+       if (irec->ir_freecount > XFS_INODES_PER_CHUNK)
+               goto out_bad_rec;
+
+       /* if there are no holes, return the first available offset */
+       if (!xfs_inobt_issparse(irec->ir_holemask))
+               realfree = irec->ir_free;
+       else
+               realfree = irec->ir_free & xfs_inobt_irec_to_allocmask(irec);
+       if (hweight64(realfree) != irec->ir_freecount)
+               goto out_bad_rec;
 
        return 0;
+
+out_bad_rec:
+       xfs_warn(mp,
+               "%s Inode BTree record corruption in AG %d detected!",
+               cur->bc_btnum == XFS_BTNUM_INO ? "Used" : "Free", agno);
+       xfs_warn(mp,
+"start inode 0x%x, count 0x%x, free 0x%x freemask 0x%llx, holemask 0x%x",
+               irec->ir_startino, irec->ir_count, irec->ir_freecount,
+               irec->ir_free, irec->ir_holemask);
+       return -EFSCORRUPTED;
 }
 
 /*
@@ -880,6 +897,7 @@ xfs_ialloc_ag_alloc(
        be32_add_cpu(&agi->agi_freecount, newlen);
        pag = xfs_perag_get(args.mp, agno);
        pag->pagi_freecount += newlen;
+       pag->pagi_count += newlen;
        xfs_perag_put(pag);
        agi->agi_newino = cpu_to_be32(newino);
 
@@ -1974,6 +1992,7 @@ xfs_difree_inobt(
                xfs_ialloc_log_agi(tp, agbp, XFS_AGI_COUNT | XFS_AGI_FREECOUNT);
                pag = xfs_perag_get(mp, agno);
                pag->pagi_freecount -= ilen - 1;
+               pag->pagi_count -= ilen;
                xfs_perag_put(pag);
                xfs_trans_mod_sb(tp, XFS_TRANS_SB_ICOUNT, -ilen);
                xfs_trans_mod_sb(tp, XFS_TRANS_SB_IFREE, -(ilen - 1));
@@ -2477,26 +2496,13 @@ xfs_ialloc_log_agi(
        }
 }
 
-#ifdef DEBUG
-STATIC void
-xfs_check_agi_unlinked(
-       struct xfs_agi          *agi)
-{
-       int                     i;
-
-       for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++)
-               ASSERT(agi->agi_unlinked[i]);
-}
-#else
-#define xfs_check_agi_unlinked(agi)
-#endif
-
 static xfs_failaddr_t
 xfs_agi_verify(
        struct xfs_buf  *bp)
 {
        struct xfs_mount *mp = bp->b_target->bt_mount;
        struct xfs_agi  *agi = XFS_BUF_TO_AGI(bp);
+       int             i;
 
        if (xfs_sb_version_hascrc(&mp->m_sb)) {
                if (!uuid_equal(&agi->agi_uuid, &mp->m_sb.sb_meta_uuid))
@@ -2532,7 +2538,13 @@ xfs_agi_verify(
        if (bp->b_pag && be32_to_cpu(agi->agi_seqno) != bp->b_pag->pag_agno)
                return __this_address;
 
-       xfs_check_agi_unlinked(agi);
+       for (i = 0; i < XFS_AGI_UNLINKED_BUCKETS; i++) {
+               if (agi->agi_unlinked[i] == NULLAGINO)
+                       continue;
+               if (!xfs_verify_ino(mp, be32_to_cpu(agi->agi_unlinked[i])))
+                       return __this_address;
+       }
+
        return NULL;
 }
 
@@ -2664,96 +2676,6 @@ xfs_ialloc_pagi_init(
        return 0;
 }
 
-/* Calculate the first and last possible inode number in an AG. */
-void
-xfs_ialloc_agino_range(
-       struct xfs_mount        *mp,
-       xfs_agnumber_t          agno,
-       xfs_agino_t             *first,
-       xfs_agino_t             *last)
-{
-       xfs_agblock_t           bno;
-       xfs_agblock_t           eoag;
-
-       eoag = xfs_ag_block_count(mp, agno);
-
-       /*
-        * Calculate the first inode, which will be in the first
-        * cluster-aligned block after the AGFL.
-        */
-       bno = round_up(XFS_AGFL_BLOCK(mp) + 1,
-                       xfs_ialloc_cluster_alignment(mp));
-       *first = XFS_OFFBNO_TO_AGINO(mp, bno, 0);
-
-       /*
-        * Calculate the last inode, which will be at the end of the
-        * last (aligned) cluster that can be allocated in the AG.
-        */
-       bno = round_down(eoag, xfs_ialloc_cluster_alignment(mp));
-       *last = XFS_OFFBNO_TO_AGINO(mp, bno, 0) - 1;
-}
-
-/*
- * Verify that an AG inode number pointer neither points outside the AG
- * nor points at static metadata.
- */
-bool
-xfs_verify_agino(
-       struct xfs_mount        *mp,
-       xfs_agnumber_t          agno,
-       xfs_agino_t             agino)
-{
-       xfs_agino_t             first;
-       xfs_agino_t             last;
-
-       xfs_ialloc_agino_range(mp, agno, &first, &last);
-       return agino >= first && agino <= last;
-}
-
-/*
- * Verify that an FS inode number pointer neither points outside the
- * filesystem nor points at static AG metadata.
- */
-bool
-xfs_verify_ino(
-       struct xfs_mount        *mp,
-       xfs_ino_t               ino)
-{
-       xfs_agnumber_t          agno = XFS_INO_TO_AGNO(mp, ino);
-       xfs_agino_t             agino = XFS_INO_TO_AGINO(mp, ino);
-
-       if (agno >= mp->m_sb.sb_agcount)
-               return false;
-       if (XFS_AGINO_TO_INO(mp, agno, agino) != ino)
-               return false;
-       return xfs_verify_agino(mp, agno, agino);
-}
-
-/* Is this an internal inode number? */
-bool
-xfs_internal_inum(
-       struct xfs_mount        *mp,
-       xfs_ino_t               ino)
-{
-       return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino ||
-               (xfs_sb_version_hasquota(&mp->m_sb) &&
-                xfs_is_quota_inode(&mp->m_sb, ino));
-}
-
-/*
- * Verify that a directory entry's inode number doesn't point at an internal
- * inode, empty space, or static AG metadata.
- */
-bool
-xfs_verify_dir_ino(
-       struct xfs_mount        *mp,
-       xfs_ino_t               ino)
-{
-       if (xfs_internal_inum(mp, ino))
-               return false;
-       return xfs_verify_ino(mp, ino);
-}
-
 /* Is there an inode record covering a given range of inode numbers? */
 int
 xfs_ialloc_has_inode_record(
index 77fffced8bac42418b269f359138f8a0ebf9dc2f..90b09c5f163bdf323314ec4a02b5993611f6af1f 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_IALLOC_H__
 #define        __XFS_IALLOC_H__
@@ -181,12 +169,5 @@ int xfs_inobt_insert_rec(struct xfs_btree_cur *cur, uint16_t holemask,
                int *stat);
 
 int xfs_ialloc_cluster_alignment(struct xfs_mount *mp);
-void xfs_ialloc_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno,
-               xfs_agino_t *first, xfs_agino_t *last);
-bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno,
-               xfs_agino_t agino);
-bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino);
-bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino);
-bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino);
 
 #endif /* __XFS_IALLOC_H__ */
index b04c555121599132bb849a3b20c1f9d5be25d37b..a5237afec5abc850df3b7afed976a32bf698815f 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 4acdd5458d59f17fe7086ecb3058fbc716d91a11..bf8f0c405e7d2cd8e037618a47abfcab64a728a2 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_IALLOC_BTREE_H__
 #define        __XFS_IALLOC_BTREE_H__
index b0f31791c7e6137c0b7e46c35000e3c76e145ba1..b80c63faace29b3355ae78d903c8e6e25a790ee5 100644 (file)
@@ -1,14 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2017 Christoph Hellwig.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
  */
 
 #include <linux/cache.h>
index 1201107eabc632c91894f52590609045a104eabf..d38d724534c48e2a4644be06acbf6d64da9a65b2 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -201,11 +189,6 @@ xfs_imap_to_bp(
                        ASSERT(buf_flags & XBF_TRYLOCK);
                        return error;
                }
-
-               if (error == -EFSCORRUPTED &&
-                   (iget_flags & XFS_IGET_UNTRUSTED))
-                       return -EINVAL;
-
                xfs_warn(mp, "%s: xfs_trans_read_buf() returned error %d.",
                        __func__, error);
                return error;
@@ -397,6 +380,7 @@ xfs_dinode_verify(
        xfs_ino_t               ino,
        struct xfs_dinode       *dip)
 {
+       xfs_failaddr_t          fa;
        uint16_t                mode;
        uint16_t                flags;
        uint64_t                flags2;
@@ -513,6 +497,12 @@ xfs_dinode_verify(
                        return __this_address;
        }
 
+       /* extent size hint validation */
+       fa = xfs_inode_validate_extsize(mp, be32_to_cpu(dip->di_extsize),
+                       mode, flags);
+       if (fa)
+               return fa;
+
        /* only version 3 or greater inodes are extensively verified here */
        if (dip->di_version < 3)
                return NULL;
@@ -521,7 +511,7 @@ xfs_dinode_verify(
 
        /* don't allow reflink/cowextsize if we don't have reflink */
        if ((flags2 & (XFS_DIFLAG2_REFLINK | XFS_DIFLAG2_COWEXTSIZE)) &&
-            !xfs_sb_version_hasreflink(&mp->m_sb))
+            !xfs_sb_version_hasreflink(&mp->m_sb))
                return __this_address;
 
        /* only regular files get reflink */
@@ -536,6 +526,12 @@ xfs_dinode_verify(
        if ((flags2 & XFS_DIFLAG2_REFLINK) && (flags2 & XFS_DIFLAG2_DAX))
                return __this_address;
 
+       /* COW extent size hint validation */
+       fa = xfs_inode_validate_cowextsize(mp, be32_to_cpu(dip->di_cowextsize),
+                       mode, flags, flags2);
+       if (fa)
+               return fa;
+
        return NULL;
 }
 
index d9a376a78ee2fe9fde8ce58536c5754048b89353..ab0f841653174e8d142a771c7bbca683a38e5737 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_INODE_BUF_H__
 #define        __XFS_INODE_BUF_H__
index 701c42a28d05299c4284075759e10dca9b615b58..183ec0cb8921c3a2e2d638055e5d1744699c9896 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include <linux/log2.h>
 
index dd8aba0dd119cf5fa29f206734f89164150e94c7..781b1603df5e277687a06097111fb4cb2f99a25a 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_INODE_FORK_H__
 #define        __XFS_INODE_FORK_H__
index 349d9f8edb89b4dd040cdf741c5ca2ba3207c329..79bb79853c9f1d4616547c05c3a1be83e639aa10 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_LOG_FORMAT_H__
 #define __XFS_LOG_FORMAT_H__
index 66948a9fd4861653058df5738ffa057355d58697..f3d18eaecebb0ccc833b2663bd3a09662789e637 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_LOG_RECOVER_H__
 #define __XFS_LOG_RECOVER_H__
index cc4cbe290939255c2279052ae773bea227f42d70..1b542ec11d5d450bb9e43afab396882853bfc78f 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2013 Jie Liu.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index d4af2804b1781bc3256a225e8f3b3dd37124a423..4bfdd5f4c6afaca665ed8f35b41551a8b45a0ad2 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_QUOTA_DEFS_H__
 #define __XFS_QUOTA_DEFS_H__
index 418d53295893792f68212756236612c351772696..9dda6fd0bb13837d051f2de5c04cc1802d210a9d 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -125,16 +111,53 @@ xfs_refcount_get_rec(
        struct xfs_refcount_irec        *irec,
        int                             *stat)
 {
+       struct xfs_mount                *mp = cur->bc_mp;
+       xfs_agnumber_t                  agno = cur->bc_private.a.agno;
        union xfs_btree_rec             *rec;
        int                             error;
+       xfs_agblock_t                   realstart;
 
        error = xfs_btree_get_rec(cur, &rec, stat);
-       if (!error && *stat == 1) {
-               xfs_refcount_btrec_to_irec(rec, irec);
-               trace_xfs_refcount_get(cur->bc_mp, cur->bc_private.a.agno,
-                               irec);
+       if (error || !*stat)
+               return error;
+
+       xfs_refcount_btrec_to_irec(rec, irec);
+
+       agno = cur->bc_private.a.agno;
+       if (irec->rc_blockcount == 0 || irec->rc_blockcount > MAXREFCEXTLEN)
+               goto out_bad_rec;
+
+       /* handle special COW-staging state */
+       realstart = irec->rc_startblock;
+       if (realstart & XFS_REFC_COW_START) {
+               if (irec->rc_refcount != 1)
+                       goto out_bad_rec;
+               realstart &= ~XFS_REFC_COW_START;
+       } else if (irec->rc_refcount < 2) {
+               goto out_bad_rec;
        }
-       return error;
+
+       /* check for valid extent range, including overflow */
+       if (!xfs_verify_agbno(mp, agno, realstart))
+               goto out_bad_rec;
+       if (realstart > realstart + irec->rc_blockcount)
+               goto out_bad_rec;
+       if (!xfs_verify_agbno(mp, agno, realstart + irec->rc_blockcount - 1))
+               goto out_bad_rec;
+
+       if (irec->rc_refcount == 0 || irec->rc_refcount > MAXREFCOUNT)
+               goto out_bad_rec;
+
+       trace_xfs_refcount_get(cur->bc_mp, cur->bc_private.a.agno, irec);
+       return 0;
+
+out_bad_rec:
+       xfs_warn(mp,
+               "Refcount BTree record corruption in AG %d detected!", agno);
+       xfs_warn(mp,
+               "Start block 0x%x, block count 0x%x, references 0x%x",
+               irec->rc_startblock, irec->rc_blockcount, irec->rc_refcount);
+       return -EFSCORRUPTED;
 }
 
 /*
index a92ad9078bc16ca20768c865bdd7e797e2519920..5fef74412727abef7c9337ddf2c3fa3fc9cfe1d4 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_REFCOUNT_H__
 #define __XFS_REFCOUNT_H__
index 375abfeb62675e118b2a47bc994a8920db4c10b2..b71937982c5b2cca40ee89b89babe60bea97603d 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -192,7 +178,6 @@ xfs_refcountbt_init_ptr_from_cur(
        struct xfs_agf          *agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
 
        ASSERT(cur->bc_private.a.agno == be32_to_cpu(agf->agf_seqno));
-       ASSERT(agf->agf_refcount_root != 0);
 
        ptr->s = agf->agf_refcount_root;
 }
index 2bc4694ef146ec7c141c1a07ffe20c1e85538a71..d2852b6e1fa8a888eef79934de814b40e5a2ea4c 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_REFCOUNT_BTREE_H__
 #define        __XFS_REFCOUNT_BTREE_H__
index c0644f1be8a80ed7f42c85abcf6e511b3be36c41..d4460b0d2d81583fe52960df611a903a8def1800 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -39,6 +27,7 @@
 #include "xfs_extent_busy.h"
 #include "xfs_bmap.h"
 #include "xfs_inode.h"
+#include "xfs_ialloc.h"
 
 /*
  * Lookup the first record less than or equal to [bno, len, owner, offset]
@@ -203,6 +192,8 @@ xfs_rmap_get_rec(
        struct xfs_rmap_irec    *irec,
        int                     *stat)
 {
+       struct xfs_mount        *mp = cur->bc_mp;
+       xfs_agnumber_t          agno = cur->bc_private.a.agno;
        union xfs_btree_rec     *rec;
        int                     error;
 
@@ -210,7 +201,43 @@ xfs_rmap_get_rec(
        if (error || !*stat)
                return error;
 
-       return xfs_rmap_btrec_to_irec(rec, irec);
+       if (xfs_rmap_btrec_to_irec(rec, irec))
+               goto out_bad_rec;
+
+       if (irec->rm_blockcount == 0)
+               goto out_bad_rec;
+       if (irec->rm_startblock <= XFS_AGFL_BLOCK(mp)) {
+               if (irec->rm_owner != XFS_RMAP_OWN_FS)
+                       goto out_bad_rec;
+               if (irec->rm_blockcount != XFS_AGFL_BLOCK(mp) + 1)
+                       goto out_bad_rec;
+       } else {
+               /* check for valid extent range, including overflow */
+               if (!xfs_verify_agbno(mp, agno, irec->rm_startblock))
+                       goto out_bad_rec;
+               if (irec->rm_startblock >
+                               irec->rm_startblock + irec->rm_blockcount)
+                       goto out_bad_rec;
+               if (!xfs_verify_agbno(mp, agno,
+                               irec->rm_startblock + irec->rm_blockcount - 1))
+                       goto out_bad_rec;
+       }
+
+       if (!(xfs_verify_ino(mp, irec->rm_owner) ||
+             (irec->rm_owner <= XFS_RMAP_OWN_FS &&
+              irec->rm_owner >= XFS_RMAP_OWN_MIN)))
+               goto out_bad_rec;
+
+       return 0;
+out_bad_rec:
+       xfs_warn(mp,
+               "Reverse Mapping BTree record corruption in AG %d detected!",
+               agno);
+       xfs_warn(mp,
+               "Owner 0x%llx, flags 0x%x, start block 0x%x block count 0x%x",
+               irec->rm_owner, irec->rm_flags, irec->rm_startblock,
+               irec->rm_blockcount);
+       return -EFSCORRUPTED;
 }
 
 struct xfs_find_left_neighbor_info {
index 43e506f67680396ea4814ac7e482cd70c1675c4f..9f19454768b2370a169912ce191de67b7859c5d4 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_RMAP_H__
 #define __XFS_RMAP_H__
index d756e0b84abf2f2c2a0867dbe4748aeefd1ac274..221a88ea60bb47afcf32005b9902168208d5047b 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -234,7 +222,6 @@ xfs_rmapbt_init_ptr_from_cur(
        struct xfs_agf          *agf = XFS_BUF_TO_AGF(cur->bc_private.a.agbp);
 
        ASSERT(cur->bc_private.a.agno == be32_to_cpu(agf->agf_seqno));
-       ASSERT(agf->agf_roots[cur->bc_btnum] != 0);
 
        ptr->s = agf->agf_roots[cur->bc_btnum];
 }
index d68d96eed7ea8c3cc3a605503a087d4b76830890..50198b6c3bb20c3376e5acf83b96b7a23bbe171c 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_RMAP_BTREE_H__
 #define __XFS_RMAP_BTREE_H__
index 369eeb7a52ec1778b788bda7f15691d9cdb7140c..65fc4ed2e9a1050b76b1cd85d874294e52a8afd9 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -1092,18 +1080,6 @@ xfs_rtalloc_query_all(
        return xfs_rtalloc_query_range(tp, &keys[0], &keys[1], fn, priv);
 }
 
-/*
- * Verify that an realtime block number pointer doesn't point off the
- * end of the realtime device.
- */
-bool
-xfs_verify_rtbno(
-       struct xfs_mount        *mp,
-       xfs_rtblock_t           rtbno)
-{
-       return rtbno < mp->m_sb.sb_rblocks;
-}
-
 /* Is the given extent all free? */
 int
 xfs_rtalloc_extent_is_free(
index d485e14313c66eae27ed4244e8cce82564bbcae8..350119eeaecb29b23b6fde020ee75c2542777013 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -278,6 +266,22 @@ xfs_mount_validate_sb(
                return -EFSCORRUPTED;
        }
 
+       if (sbp->sb_unit) {
+               if (!xfs_sb_version_hasdalign(sbp) ||
+                   sbp->sb_unit > sbp->sb_width ||
+                   (sbp->sb_width % sbp->sb_unit) != 0) {
+                       xfs_notice(mp, "SB stripe unit sanity check failed");
+                       return -EFSCORRUPTED;
+               }
+       } else if (xfs_sb_version_hasdalign(sbp)) {
+               xfs_notice(mp, "SB stripe alignment sanity check failed");
+               return -EFSCORRUPTED;
+       } else if (sbp->sb_width) {
+               xfs_notice(mp, "SB stripe width sanity check failed");
+               return -EFSCORRUPTED;
+       }
+
+
        if (xfs_sb_version_hascrc(&mp->m_sb) &&
            sbp->sb_blocksize < XFS_MIN_CRC_BLOCKSIZE) {
                xfs_notice(mp, "v5 SB sanity check failed");
@@ -767,7 +771,7 @@ xfs_sb_mount_common(
        mp->m_refc_mnr[1] = mp->m_refc_mxr[1] / 2;
 
        mp->m_bsize = XFS_FSB_TO_BB(mp, 1);
-       mp->m_ialloc_inos = (int)MAX((uint16_t)XFS_INODES_PER_CHUNK,
+       mp->m_ialloc_inos = max_t(uint16_t, XFS_INODES_PER_CHUNK,
                                        sbp->sb_inopblock);
        mp->m_ialloc_blks = mp->m_ialloc_inos >> sbp->sb_inopblog;
 
@@ -970,14 +974,16 @@ xfs_sync_sb_buf(
        struct xfs_mount        *mp)
 {
        struct xfs_trans        *tp;
+       struct xfs_buf          *bp;
        int                     error;
 
        error = xfs_trans_alloc(mp, &M_RES(mp)->tr_sb, 0, 0, 0, &tp);
        if (error)
                return error;
 
+       bp = xfs_trans_getsb(tp, mp, 0);
        xfs_log_sb(tp);
-       xfs_trans_bhold(tp, mp->m_sb_bp);
+       xfs_trans_bhold(tp, bp);
        xfs_trans_set_sync(tp);
        error = xfs_trans_commit(tp);
        if (error)
@@ -985,9 +991,9 @@ xfs_sync_sb_buf(
        /*
         * write out the sb buffer to get the changes to disk
         */
-       error = xfs_bwrite(mp->m_sb_bp);
+       error = xfs_bwrite(bp);
 out:
-       xfs_buf_relse(mp->m_sb_bp);
+       xfs_buf_relse(bp);
        return error;
 }
 
index 244e0162c49e7702c7a94a0961a9bc2d5a8f47fc..13564d69800af4973ea79ef10dfd141b88034815 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_SB_H__
 #define        __XFS_SB_H__
index ae99c260adb1b86279054b387a92857caa48a995..22089f1c880a3d89b10f04b7acdb019995a3b686 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_SHARED_H__
 #define __XFS_SHARED_H__
index 5ef5f354587e9c0dc8b5e5042e11e7f6a873b56d..95374ab2dee7313fbe3ea027db5e2a75b3037496 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * Copyright (c) 2012-2013 Red Hat, Inc.
  * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 3bccdf73e1410e821d84521897cf41a72258e5ce..f99a7aefe4184dc86aa9bb8ee7e631526b57d711 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * Copyright (C) 2010 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -248,7 +236,7 @@ xfs_calc_write_reservation(
        struct xfs_mount        *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX((xfs_calc_inode_res(mp, 1) +
+               max((xfs_calc_inode_res(mp, 1) +
                     xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK),
                                      XFS_FSB_TO_B(mp, 1)) +
                     xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
@@ -275,7 +263,7 @@ xfs_calc_itruncate_reservation(
        struct xfs_mount        *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX((xfs_calc_inode_res(mp, 1) +
+               max((xfs_calc_inode_res(mp, 1) +
                     xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + 1,
                                      XFS_FSB_TO_B(mp, 1))),
                    (xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
@@ -300,7 +288,7 @@ xfs_calc_rename_reservation(
        struct xfs_mount        *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX((xfs_calc_inode_res(mp, 4) +
+               max((xfs_calc_inode_res(mp, 4) +
                     xfs_calc_buf_res(2 * XFS_DIROP_LOG_COUNT(mp),
                                      XFS_FSB_TO_B(mp, 1))),
                    (xfs_calc_buf_res(7, mp->m_sb.sb_sectsize) +
@@ -340,7 +328,7 @@ xfs_calc_link_reservation(
 {
        return XFS_DQUOT_LOGRES(mp) +
                xfs_calc_iunlink_remove_reservation(mp) +
-               MAX((xfs_calc_inode_res(mp, 2) +
+               max((xfs_calc_inode_res(mp, 2) +
                     xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
                                      XFS_FSB_TO_B(mp, 1))),
                    (xfs_calc_buf_res(3, mp->m_sb.sb_sectsize) +
@@ -378,7 +366,7 @@ xfs_calc_remove_reservation(
 {
        return XFS_DQUOT_LOGRES(mp) +
                xfs_calc_iunlink_add_reservation(mp) +
-               MAX((xfs_calc_inode_res(mp, 1) +
+               max((xfs_calc_inode_res(mp, 1) +
                     xfs_calc_buf_res(XFS_DIROP_LOG_COUNT(mp),
                                      XFS_FSB_TO_B(mp, 1))),
                    (xfs_calc_buf_res(4, mp->m_sb.sb_sectsize) +
@@ -436,7 +424,7 @@ STATIC uint
 xfs_calc_icreate_reservation(xfs_mount_t *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX(xfs_calc_icreate_resv_alloc(mp),
+               max(xfs_calc_icreate_resv_alloc(mp),
                    xfs_calc_create_resv_modify(mp));
 }
 
@@ -644,7 +632,7 @@ STATIC uint
 xfs_calc_attrinval_reservation(
        struct xfs_mount        *mp)
 {
-       return MAX((xfs_calc_inode_res(mp, 1) +
+       return max((xfs_calc_inode_res(mp, 1) +
                    xfs_calc_buf_res(XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK),
                                     XFS_FSB_TO_B(mp, 1))),
                   (xfs_calc_buf_res(9, mp->m_sb.sb_sectsize) +
@@ -708,7 +696,7 @@ xfs_calc_attrrm_reservation(
        struct xfs_mount        *mp)
 {
        return XFS_DQUOT_LOGRES(mp) +
-               MAX((xfs_calc_inode_res(mp, 1) +
+               max((xfs_calc_inode_res(mp, 1) +
                     xfs_calc_buf_res(XFS_DA_NODE_MAXDEPTH,
                                      XFS_FSB_TO_B(mp, 1)) +
                     (uint)XFS_FSB_TO_B(mp,
index b7e5357d060a4295e7452b2a5f045e3d853bfc9d..7241ab28cf84fe32ee7f854264f472f03591a5eb 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_TRANS_RESV_H__
 #define        __XFS_TRANS_RESV_H__
index d787c677d2a3201cc62d042fbee55415923934f6..a62fb950bef18acfe820098082a19172feeadef5 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_TRANS_SPACE_H__
 #define __XFS_TRANS_SPACE_H__
diff --git a/fs/xfs/libxfs/xfs_types.c b/fs/xfs/libxfs/xfs_types.c
new file mode 100644 (file)
index 0000000..2e2a243
--- /dev/null
@@ -0,0 +1,173 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
+ * Copyright (C) 2017 Oracle.
+ * All Rights Reserved.
+ */
+#include "xfs.h"
+#include "xfs_fs.h"
+#include "xfs_format.h"
+#include "xfs_log_format.h"
+#include "xfs_shared.h"
+#include "xfs_trans_resv.h"
+#include "xfs_bit.h"
+#include "xfs_sb.h"
+#include "xfs_mount.h"
+#include "xfs_defer.h"
+#include "xfs_inode.h"
+#include "xfs_btree.h"
+#include "xfs_rmap.h"
+#include "xfs_alloc_btree.h"
+#include "xfs_alloc.h"
+#include "xfs_ialloc.h"
+
+/* Find the size of the AG, in blocks. */
+xfs_agblock_t
+xfs_ag_block_count(
+       struct xfs_mount        *mp,
+       xfs_agnumber_t          agno)
+{
+       ASSERT(agno < mp->m_sb.sb_agcount);
+
+       if (agno < mp->m_sb.sb_agcount - 1)
+               return mp->m_sb.sb_agblocks;
+       return mp->m_sb.sb_dblocks - (agno * mp->m_sb.sb_agblocks);
+}
+
+/*
+ * Verify that an AG block number pointer neither points outside the AG
+ * nor points at static metadata.
+ */
+bool
+xfs_verify_agbno(
+       struct xfs_mount        *mp,
+       xfs_agnumber_t          agno,
+       xfs_agblock_t           agbno)
+{
+       xfs_agblock_t           eoag;
+
+       eoag = xfs_ag_block_count(mp, agno);
+       if (agbno >= eoag)
+               return false;
+       if (agbno <= XFS_AGFL_BLOCK(mp))
+               return false;
+       return true;
+}
+
+/*
+ * Verify that an FS block number pointer neither points outside the
+ * filesystem nor points at static AG metadata.
+ */
+bool
+xfs_verify_fsbno(
+       struct xfs_mount        *mp,
+       xfs_fsblock_t           fsbno)
+{
+       xfs_agnumber_t          agno = XFS_FSB_TO_AGNO(mp, fsbno);
+
+       if (agno >= mp->m_sb.sb_agcount)
+               return false;
+       return xfs_verify_agbno(mp, agno, XFS_FSB_TO_AGBNO(mp, fsbno));
+}
+
+/* Calculate the first and last possible inode number in an AG. */
+void
+xfs_agino_range(
+       struct xfs_mount        *mp,
+       xfs_agnumber_t          agno,
+       xfs_agino_t             *first,
+       xfs_agino_t             *last)
+{
+       xfs_agblock_t           bno;
+       xfs_agblock_t           eoag;
+
+       eoag = xfs_ag_block_count(mp, agno);
+
+       /*
+        * Calculate the first inode, which will be in the first
+        * cluster-aligned block after the AGFL.
+        */
+       bno = round_up(XFS_AGFL_BLOCK(mp) + 1,
+                       xfs_ialloc_cluster_alignment(mp));
+       *first = XFS_OFFBNO_TO_AGINO(mp, bno, 0);
+
+       /*
+        * Calculate the last inode, which will be at the end of the
+        * last (aligned) cluster that can be allocated in the AG.
+        */
+       bno = round_down(eoag, xfs_ialloc_cluster_alignment(mp));
+       *last = XFS_OFFBNO_TO_AGINO(mp, bno, 0) - 1;
+}
+
+/*
+ * Verify that an AG inode number pointer neither points outside the AG
+ * nor points at static metadata.
+ */
+bool
+xfs_verify_agino(
+       struct xfs_mount        *mp,
+       xfs_agnumber_t          agno,
+       xfs_agino_t             agino)
+{
+       xfs_agino_t             first;
+       xfs_agino_t             last;
+
+       xfs_agino_range(mp, agno, &first, &last);
+       return agino >= first && agino <= last;
+}
+
+/*
+ * Verify that an FS inode number pointer neither points outside the
+ * filesystem nor points at static AG metadata.
+ */
+bool
+xfs_verify_ino(
+       struct xfs_mount        *mp,
+       xfs_ino_t               ino)
+{
+       xfs_agnumber_t          agno = XFS_INO_TO_AGNO(mp, ino);
+       xfs_agino_t             agino = XFS_INO_TO_AGINO(mp, ino);
+
+       if (agno >= mp->m_sb.sb_agcount)
+               return false;
+       if (XFS_AGINO_TO_INO(mp, agno, agino) != ino)
+               return false;
+       return xfs_verify_agino(mp, agno, agino);
+}
+
+/* Is this an internal inode number? */
+bool
+xfs_internal_inum(
+       struct xfs_mount        *mp,
+       xfs_ino_t               ino)
+{
+       return ino == mp->m_sb.sb_rbmino || ino == mp->m_sb.sb_rsumino ||
+               (xfs_sb_version_hasquota(&mp->m_sb) &&
+                xfs_is_quota_inode(&mp->m_sb, ino));
+}
+
+/*
+ * Verify that a directory entry's inode number doesn't point at an internal
+ * inode, empty space, or static AG metadata.
+ */
+bool
+xfs_verify_dir_ino(
+       struct xfs_mount        *mp,
+       xfs_ino_t               ino)
+{
+       if (xfs_internal_inum(mp, ino))
+               return false;
+       return xfs_verify_ino(mp, ino);
+}
+
+/*
+ * Verify that an realtime block number pointer doesn't point off the
+ * end of the realtime device.
+ */
+bool
+xfs_verify_rtbno(
+       struct xfs_mount        *mp,
+       xfs_rtblock_t           rtbno)
+{
+       return rtbno < mp->m_sb.sb_rblocks;
+}
index ea18449bd7326181e717525799051da8265d309a..4055d62f690c380235169732c66de76842578fc0 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_TYPES_H__
 #define        __XFS_TYPES_H__
@@ -159,4 +147,23 @@ typedef struct xfs_bmbt_irec
        xfs_exntst_t    br_state;       /* extent state */
 } xfs_bmbt_irec_t;
 
+/*
+ * Type verifier functions
+ */
+struct xfs_mount;
+
+xfs_agblock_t xfs_ag_block_count(struct xfs_mount *mp, xfs_agnumber_t agno);
+bool xfs_verify_agbno(struct xfs_mount *mp, xfs_agnumber_t agno,
+               xfs_agblock_t agbno);
+bool xfs_verify_fsbno(struct xfs_mount *mp, xfs_fsblock_t fsbno);
+
+void xfs_agino_range(struct xfs_mount *mp, xfs_agnumber_t agno,
+               xfs_agino_t *first, xfs_agino_t *last);
+bool xfs_verify_agino(struct xfs_mount *mp, xfs_agnumber_t agno,
+               xfs_agino_t agino);
+bool xfs_verify_ino(struct xfs_mount *mp, xfs_ino_t ino);
+bool xfs_internal_inum(struct xfs_mount *mp, xfs_ino_t ino);
+bool xfs_verify_dir_ino(struct xfs_mount *mp, xfs_ino_t ino);
+bool xfs_verify_rtbno(struct xfs_mount *mp, xfs_rtblock_t rtbno);
+
 #endif /* __XFS_TYPES_H__ */
index e3c92d19e54079e5ffc950adf8974c35eee0703e..79155eec341bff4b6718a0b50d6ec60475c329f9 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_SUPPORT_MRLOCK_H__
 #define __XFS_SUPPORT_MRLOCK_H__
index 1f71793f7db454dde089eef71babf08edac1088f..9bb0745f1ad2845c8476f7edaf314a1c4e3591f2 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -881,7 +867,7 @@ xfs_scrub_agi(
        }
 
        /* Check inode counters */
-       xfs_ialloc_agino_range(mp, agno, &first_agino, &last_agino);
+       xfs_agino_range(mp, agno, &first_agino, &last_agino);
        icount = be32_to_cpu(agi->agi_count);
        if (icount > last_agino - first_agino + 1 ||
            icount < be32_to_cpu(agi->agi_freecount))
index 8b91e9ebe1e73ed69b67aa652aff1e5cc920175e..117eedac53dffbe573d9fcd10b02523e373d71e7 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2018 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 941a0a55224e84bedd893e5e67f1d89b0cf6236d..50e4f7fa06f0dda683ad218f5039683f3c4010cc 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 84b6d6b66578b2ee78bb0601adca44329f2ad4b1..de51cf8a8516e4c05a26a16fd2fc53f66f1bd77a 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index eeadb33a701c2313e4961598b4eff73a8052cd2c..3d08589f5c60ecde42a3d1e74eea2ff83940cc7a 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 2d29dceaa00e7f2b594be87a53261cb7ada0143a..5b472045f036e9c17d8114c27c7afcd0f7c17f8d 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index e2b868ede70beb9174bafe9d2d6bf4874d47c5f3..956627500f2c9d5047e238430ea524942d1754a3 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_SCRUB_BTREE_H__
 #define __XFS_SCRUB_BTREE_H__
index 41198a5f872c1adb491bdd7401a0bfb63fbd85bb..70e70c69f83fa8de24fbafce2cb9f0d5e1f04a48 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 76bb2d1d808c884a47668abdc0961b182a75a0f0..2172bd5361e27ffa3e46a94297167a8e3007d8c0 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_SCRUB_COMMON_H__
 #define __XFS_SCRUB_COMMON_H__
index bffdb7dc09bf8db89b9702013bfbdbe614b6cf8b..d700c4d4d4ef4e4d4d4d637e0e68638a37ed91f1 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index d31468d68cefb37e7acb122635de4f3b1a9d7dad..365f9f0019e6d770d10a6709a781669dc5207547 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_SCRUB_DABTREE_H__
 #define __XFS_SCRUB_DABTREE_H__
index 1a4309b3e786bf6fd91812c70958d8c30a763610..86324775fc9b42c57d0e202427b3e7cf3b15ce04 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 00a834d3b56d60da02f219e61838230e652127cc..13d43d108574e3715acbd40ab49b31e06178a93a 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 0c696f7018de2a04230e389cca4542c49de72cc9..7a6208505980e88ad61520e7ab4f26527e8d73c3 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 77c6b22c6bfdfe28d6d238ae6e9d1d73e70aacb5..e2bda58c32f0bce2dd98d02a8cccce6bd04906d7 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 15ae4d23d6acaebbd1ea4a2fff03aecd6595710e..6ff906aa0a3b76cae5a052657b156449ac4b6d4c 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 324a5f159145ce4c8c3e659bac1076125f0af21a..607a9faa8eccca1dc57e850b305212cd6a722752 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index e3e8fba1c99cc41d64a95122aa04b847360ae71e..326be4e8b71e0b368a41ac4c01150ff259348271 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2018 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index f2b0895294db3a5e204ba53b8a619a46b60a6550..ef47826b672535c51beda51f4326636c54fe161b 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2018 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_SCRUB_REPAIR_H__
 #define __XFS_SCRUB_REPAIR_H__
index b376a9a77c0471a0d06eeda872e1ea1d3d06f8c6..c6d763236ba79cab131c1c9186d54279c60fab84 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 40f462a11ea54bd2d70e3535484dcce4dc8d4257..1f86e02a07cabae5f21ac4d44f117c5a32748ac0 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 36db098ba58338849a4f14f69775929bb7242376..58ae76b3a421fc6e7f69632a6e2dac1579186dc3 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 636424d5e2ee743a695bbd5cd25c8764c339d0a9..b295edd5fc0e1ccd448ade23fc32199944be1baf 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_SCRUB_SCRUB_H__
 #define __XFS_SCRUB_SCRUB_H__
index 3aa3d60f7c16d8d4f6f9e83ae91d1851bb4bf0ea..570a8981211621c5fd5c4aa0567c1e59ac51eea9 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 86daed0e3a458dd16ab76251b2772400be1e9409..7c76d8b5cb0535def3946b630c9b393a84ee8bbb 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 794d56bb1af856d560def2a245c1686d9e365257..cec3e5ece5a169c611d44ff3a79912bf4f0abf4f 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM xfs_scrub
index e00e0eadac6a2355a4530075d22a4b2af3abf7a5..2897ba3a17e62b6fc33962cc06aca71fb80c85be 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_SCRUB_H__
 #define __XFS_SCRUB_H__
index 5ff7f228d61622e01b3aef4728e86072411e1f8c..583a9f539bf1726894f6692c3510fd4b3a7af38d 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_H__
 #define __XFS_H__
index 3354140de07eb8aa2566c6c9254ad85e24a2a4bf..8039e35147ddd015d228dd40a818253cb12b4da4 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2008, Christoph Hellwig
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_format.h"
index 04327318ef676c2cff237ee9334a8e562654a826..94615e34bc868ca4f263abc99443831b4a2e4d83 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2001-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_ACL_H__
 #define __XFS_ACL_H__
index ca690372668960a3f15fe0b8b7e092c9dc3f8f6e..8eb3ba3d4d0026f8cba2ce7b5ba9dbca4d3d889e 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_shared.h"
@@ -543,8 +531,19 @@ xfs_submit_ioend(
 {
        /* Convert CoW extents to regular */
        if (!status && ioend->io_type == XFS_IO_COW) {
+               /*
+                * Yuk. This can do memory allocation, but is not a
+                * transactional operation so everything is done in GFP_KERNEL
+                * context. That can deadlock, because we hold pages in
+                * writeback state and GFP_KERNEL allocations can block on them.
+                * Hence we must operate in nofs conditions here.
+                */
+               unsigned nofs_flag;
+
+               nofs_flag = memalloc_nofs_save();
                status = xfs_reflink_convert_cow(XFS_I(ioend->io_inode),
                                ioend->io_offset, ioend->io_size);
+               memalloc_nofs_restore(nofs_flag);
        }
 
        /* Reserve log space if we might write beyond the on-disk inode size. */
index 694c85b03813ea811a781f6fb6700e7c161d73ae..25bc6d4a12313e7b056867e894eac8df063079de 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2005-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_AOPS_H__
 #define __XFS_AOPS_H__
index d07bf27451c9b2e03a034581e418d8aeeab7304b..033ff8c478e2e5d1af9b4656422f02bb278c6dcc 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_ATTR_H__
 #define        __XFS_ATTR_H__
index 52818ea2eb5062426ce911c35edd5eaf9db731da..7ce10055f275654ed62ce886435bc3ff4e2f9268 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 3e59a348ea71258e7421790803426177c56b3383..f9ca80154c9c4fcd7deef98314ec6450664c0d66 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -139,7 +127,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
                    ((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) {
                        XFS_CORRUPTION_ERROR("xfs_attr_shortform_list",
                                             XFS_ERRLEVEL_LOW,
-                                            context->dp->i_mount, sfe);
+                                            context->dp->i_mount, sfe,
+                                            sizeof(*sfe));
                        kmem_free(sbuf);
                        return -EFSCORRUPTED;
                }
@@ -241,7 +230,7 @@ xfs_attr_node_list_lookup(
                if (magic != XFS_DA_NODE_MAGIC &&
                    magic != XFS_DA3_NODE_MAGIC) {
                        XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
-                                       node);
+                                       node, sizeof(*node));
                        goto out_corruptbuf;
                }
 
index 618bb71535c862a1289a64511a1b83e8e9ed541e..956ebd583e27d8911ba979896cf92a401bb64162 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 24b354a2c83641487acfeb76a336a6476b9b98b3..fd1a1b13df51fac8e14cdc4417704ac38c226ac0 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef        __XFS_BMAP_ITEM_H__
 #define        __XFS_BMAP_ITEM_H__
index 06badcbadeb44ef5de30710d22428ccd08933b6b..c35009a8669953dfee4013615ca62b47237b4d77 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * Copyright (c) 2012 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -92,6 +80,7 @@ xfs_bmap_rtalloc(
        int             error;          /* error return value */
        xfs_mount_t     *mp;            /* mount point structure */
        xfs_extlen_t    prod = 0;       /* product factor for allocators */
+       xfs_extlen_t    mod = 0;        /* product factor for allocators */
        xfs_extlen_t    ralen = 0;      /* realtime allocation length */
        xfs_extlen_t    align;          /* minimum allocation alignment */
        xfs_rtblock_t   rtb;
@@ -111,7 +100,8 @@ xfs_bmap_rtalloc(
         * If the offset & length are not perfectly aligned
         * then kill prod, it will just get us in trouble.
         */
-       if (do_mod(ap->offset, align) || ap->length % align)
+       div_u64_rem(ap->offset, align, &mod);
+       if (mod || ap->length % align)
                prod = 1;
        /*
         * Set ralen to be the actual requested length in rtextents.
@@ -948,9 +938,11 @@ xfs_alloc_file_space(
                        do_div(s, extsz);
                        s *= extsz;
                        e = startoffset_fsb + allocatesize_fsb;
-                       if ((temp = do_mod(startoffset_fsb, extsz)))
+                       div_u64_rem(startoffset_fsb, extsz, &temp);
+                       if (temp)
                                e += temp;
-                       if ((temp = do_mod(e, extsz)))
+                       div_u64_rem(e, extsz, &temp);
+                       if (temp)
                                e += extsz - temp;
                } else {
                        s = 0;
@@ -1111,7 +1103,7 @@ xfs_adjust_extent_unmap_boundaries(
 
        if (nimap && imap.br_startblock != HOLESTARTBLOCK) {
                ASSERT(imap.br_startblock != DELAYSTARTBLOCK);
-               mod = do_mod(imap.br_startblock, mp->m_sb.sb_rextsize);
+               div_u64_rem(imap.br_startblock, mp->m_sb.sb_rextsize, &mod);
                if (mod)
                        *startoffset_fsb += mp->m_sb.sb_rextsize - mod;
        }
index 4d4ae48bd4f61e593a83caddeb0be56b83f4e3d0..87363d136bb618145c396223da5b4755bdd572c8 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_BMAP_UTIL_H__
 #define        __XFS_BMAP_UTIL_H__
index 5179ab9e3d6a3c615301b4145ba188baa26ae5c3..e9c058e3761ca032fbaa10e5952e4d867a00b2b2 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include <linux/stddef.h>
@@ -33,7 +21,6 @@
 #include <linux/migrate.h>
 #include <linux/backing-dev.h>
 #include <linux/freezer.h>
-#include <linux/sched/mm.h>
 
 #include "xfs_format.h"
 #include "xfs_log_format.h"
index f5f2b71c2fde9bb022940934aab6d6df7ec64c2e..d24dbd4dac39d5d89c75abb0705cfea8012faf25 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_BUF_H__
 #define __XFS_BUF_H__
index c2311379d1c31894a9830303f32eb7927150756c..1c9d1398980b6562969ab03a38e5158aeafc6c07 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -842,7 +830,7 @@ xfs_buf_item_log_segment(
         * of the last bit to be set in this word plus one.
         */
        if (bit) {
-               end_bit = MIN(bit + bits_to_set, (uint)NBWORD);
+               end_bit = min(bit + bits_to_set, (uint)NBWORD);
                mask = ((1U << (end_bit - bit)) - 1) << bit;
                *wordp |= mask;
                wordp++;
index 643f53dcfe516dff1348387685106d6d72fb76e2..3f7d7b72e7e610aa9d7b5f717858895ccd48ea3d 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_BUF_ITEM_H__
 #define        __XFS_BUF_ITEM_H__
index b6ae3597bfb0b408041b13c785ec8492cd53198e..5142e64e2345897b8a770f024dc594a10c009446 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * Copyright (c) 2013 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 7b68e6c9a474ba367cbebe3ebe550f8e3c22450b..678a5fcd7576f6caa56655f988472eb3c2f406b7 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2010 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_format.h"
index 2567391489bd6c1c08a25eb317b78317581c2380..0973a0423bed926fef0662aa65d835e4b76578bd 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index bdd6bd921528dd64611d96987242354aa353176d..64bd8640f6e81dc6adba863883fb745554db73af 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_DQUOT_H__
 #define __XFS_DQUOT_H__
index 8eb7415474d63cd40e7bc6af46f4b0289fbf08bf..7dedd17c4813172239c2cef774b6c4ab3c068dd2 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 502e9464634a3eaef114bc53a9cd6ed9d4122355..db9df710a3080c43a964c04d3869a1a208209916 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_DQUOT_ITEM_H__
 #define __XFS_DQUOT_ITEM_H__
index 7975634cb8fe5dd3c515ad4e211815c6d9a2c9ba..0470114a8d80c1cf4e1382cdda423a439d4566c0 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_format.h"
@@ -334,13 +322,14 @@ xfs_corruption_error(
        const char              *tag,
        int                     level,
        struct xfs_mount        *mp,
-       void                    *p,
+       void                    *buf,
+       size_t                  bufsize,
        const char              *filename,
        int                     linenum,
        xfs_failaddr_t          failaddr)
 {
        if (level <= xfs_error_level)
-               xfs_hex_dump(p, XFS_CORRUPTION_DUMP_LEN);
+               xfs_hex_dump(buf, bufsize);
        xfs_error_report(tag, level, mp, filename, linenum, failaddr);
        xfs_alert(mp, "Corruption detected. Unmount and run xfs_repair");
 }
index ce391349e78be37366baa4a801ca3f191023e32e..246d3e989c6c92770ac0dff3af1bcb5dbdcb23c0 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_ERROR_H__
 #define        __XFS_ERROR_H__
@@ -24,8 +12,9 @@ extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
                        const char *filename, int linenum,
                        xfs_failaddr_t failaddr);
 extern void xfs_corruption_error(const char *tag, int level,
-                       struct xfs_mount *mp, void *p, const char *filename,
-                       int linenum, xfs_failaddr_t failaddr);
+                       struct xfs_mount *mp, void *buf, size_t bufsize,
+                       const char *filename, int linenum,
+                       xfs_failaddr_t failaddr);
 extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error,
                        const char *name, void *buf, size_t bufsz,
                        xfs_failaddr_t failaddr);
@@ -37,8 +26,8 @@ extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
 
 #define        XFS_ERROR_REPORT(e, lvl, mp)    \
        xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
-#define        XFS_CORRUPTION_ERROR(e, lvl, mp, mem)   \
-       xfs_corruption_error(e, lvl, mp, mem, \
+#define        XFS_CORRUPTION_ERROR(e, lvl, mp, buf, bufsize)  \
+       xfs_corruption_error(e, lvl, mp, buf, bufsize, \
                             __FILE__, __LINE__, __return_address)
 
 #define XFS_ERRLEVEL_OFF       0
index eed698aa9f165e5ffa4b4b01edf025ea12b4189e..3cf4682e2510db5eb3614d15a47e4992365dc673 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2004-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_format.h"
@@ -140,15 +128,24 @@ xfs_nfs_get_inode(
         */
        error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED, 0, &ip);
        if (error) {
+
                /*
                 * EINVAL means the inode cluster doesn't exist anymore.
-                * This implies the filehandle is stale, so we should
-                * translate it here.
+                * EFSCORRUPTED means the metadata pointing to the inode cluster
+                * or the inode cluster itself is corrupt.  This implies the
+                * filehandle is stale, so we should translate it here.
                 * We don't use ESTALE directly down the chain to not
                 * confuse applications using bulkstat that expect EINVAL.
                 */
-               if (error == -EINVAL || error == -ENOENT)
+               switch (error) {
+               case -EINVAL:
+               case -ENOENT:
+               case -EFSCORRUPTED:
                        error = -ESTALE;
+                       break;
+               default:
+                       break;
+               }
                return ERR_PTR(error);
        }
 
index 3272b6ae7a356d229b99611aabb5ea3976279fb2..64471a3ddb04d3d2dfea92c007799bcc92be101d 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_EXPORT_H__
 #define __XFS_EXPORT_H__
index 13e3d1a69e761ed3f19f0258201d677f888d9bb9..0ed68379e5512d6347399b2ec0c7e970e2eacd86 100644 (file)
@@ -1,21 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * Copyright (c) 2010 David Chinner.
  * Copyright (c) 2011 Christoph Hellwig.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 60195ea1b84ab0f99cfda8158bdac399a3ac5201..990ab3891971730d3bfe2e060191d4e14ecaa9f0 100644 (file)
@@ -1,21 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * Copyright (c) 2010 David Chinner.
  * Copyright (c) 2011 Christoph Hellwig.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_EXTENT_BUSY_H__
 #define        __XFS_EXTENT_BUSY_H__
index a889b550979a2beb6a37e599761cd8a394243672..d9da66c718bb652d87ba41baf37bd1554908a685 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index a32c794a86b7b48761aac60fe598a6f8876d63f1..2a6a895ca73e542c571cb47d3ac7b86ccfe7511d 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_EXTFREE_ITEM_H__
 #define        __XFS_EXTFREE_ITEM_H__
index bed07dfbb85e946f14c5c7c189c73b255d785a33..a3e7767a571580d949fd5d73aae1695b69f22226 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 3f8722e51dbebefc80af4b47bb9adf178c6f3a4e..2d2c5ab9143c2aae73ae37d72f4eb7959ce39cef 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2006-2007 Silicon Graphics, Inc.
  * Copyright (c) 2014 Christoph Hellwig.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_format.h"
index 2ef43406e53bd91cba503fb73527d2604136386a..5cc7665e93c92be0dcc6eeb6b25c7261dfcfc942 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2006-2007 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_FILESTREAM_H__
 #define __XFS_FILESTREAM_H__
index 0299febece9c440d30d3ceccb2c27445aa55787c..c34fa9c342f25fdbee7e39fead0078e30859bba3 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 0b9bf822595c0e7d43c6f43ae9104c8fcdaa995c..c6c57739b8626a3ed0ad4c8a5075703307003460 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2017 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_FSMAP_H__
 #define __XFS_FSMAP_H__
index bc7ef18da243e9a76c1976900979eef4b7c09534..a7afcad6b71140aed25f02979946cb9795afa644 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 20484ed5e919af18144faf9b4e639a21b50ef6f2..d023db0862c24ce512865c25581d8adb373604ee 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_FSOPS_H__
 #define        __XFS_FSOPS_H__
index fdde17a2333c793bba6fbae9fe5fd3a1cfa4a5dc..5169e84ae38255a9438d2f7425c534b4954b9c9f 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_sysctl.h"
index 164350d91efcf6923501647ee46553f2fad12d19..47f417d20a30c5c8b885946c09ed013e8af16523 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index d69a0f5a6a73f266600456f62e1afe4a9666ac71..26c0626f1f75b6a5ef0cbe152c4836f2341c9dda 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef XFS_SYNC_H
 #define XFS_SYNC_H 1
index 5da9599156ed38c1ef508aeaed2496ee5fe1b5f7..8381d34cb102f8c6f7541d80173c98d456b7e622 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2008-2010, 2013 Dave Chinner
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 59e89f87c09b3fb8483326a30a9fcb879a4c4665..a50d0b01e15a37ccf25032465125c789706597b1 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2008-2010, Dave Chinner
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef XFS_ICREATE_ITEM_H
 #define XFS_ICREATE_ITEM_H     1
index 05207a64dd53cd25a3012b93e257c4af273eba38..7a96c4e0ab5c621f38d9e034622d26ebd8d95437 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include <linux/log2.h>
 #include <linux/iversion.h>
@@ -773,7 +761,7 @@ xfs_ialloc(
        xfs_inode_t     *ip;
        uint            flags;
        int             error;
-       struct timespec tv;
+       struct timespec64 tv;
        struct inode    *inode;
 
        /*
@@ -2090,10 +2078,15 @@ xfs_iunlink_remove(
         * list this inode will go on.
         */
        agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
-       ASSERT(agino != 0);
+       if (!xfs_verify_agino(mp, agno, agino))
+               return -EFSCORRUPTED;
        bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS;
-       ASSERT(agi->agi_unlinked[bucket_index] != cpu_to_be32(NULLAGINO));
-       ASSERT(agi->agi_unlinked[bucket_index]);
+       if (!xfs_verify_agino(mp, agno,
+                       be32_to_cpu(agi->agi_unlinked[bucket_index]))) {
+               XFS_CORRUPTION_ERROR(__func__, XFS_ERRLEVEL_LOW, mp,
+                               agi, sizeof(*agi));
+               return -EFSCORRUPTED;
+       }
 
        if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) {
                /*
@@ -2171,8 +2164,12 @@ xfs_iunlink_remove(
 
                        last_offset = imap.im_boffset;
                        next_agino = be32_to_cpu(last_dip->di_next_unlinked);
-                       ASSERT(next_agino != NULLAGINO);
-                       ASSERT(next_agino != 0);
+                       if (!xfs_verify_agino(mp, agno, next_agino)) {
+                               XFS_CORRUPTION_ERROR(__func__,
+                                               XFS_ERRLEVEL_LOW, mp,
+                                               last_dip, sizeof(*last_dip));
+                               return -EFSCORRUPTED;
+                       }
                }
 
                /*
@@ -2261,7 +2258,7 @@ xfs_ifree_cluster(
                 */
                ioffset = inum - xic->first_ino;
                if ((xic->alloc & XFS_INOBT_MASK(ioffset)) == 0) {
-                       ASSERT(do_mod(ioffset, inodes_per_cluster) == 0);
+                       ASSERT(ioffset % inodes_per_cluster == 0);
                        continue;
                }
 
index a91d9fb1effcbe53267d816461b26a03eae65f8a..2ed63a49e89087d2bac533715a1c215687cf877e 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_INODE_H__
 #define        __XFS_INODE_H__
index 3e5b8574818e0af60231b1aca9f140f53d405eac..2389c34c172dda0ab4333e0461d3727296509a1e 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index b72373a33cd9d765d3bf4ad7c4f5e4012c0d056a..27081eba220c95247a24a417e00ace8d574e3d44 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_INODE_ITEM_H__
 #define        __XFS_INODE_ITEM_H__
index 32b680522abd808acff0dacf1199b16cfaba1edc..0ef5ece5634c11099d04112359daadb4fdbcab03 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -1094,12 +1082,14 @@ xfs_ioctl_setattr_dax_invalidate(
        /*
         * It is only valid to set the DAX flag on regular files and
         * directories on filesystems where the block size is equal to the page
-        * size. On directories it serves as an inherit hint.
+        * size. On directories it serves as an inherited hint so we don't
+        * have to check the device for dax support or flush pagecache.
         */
        if (fa->fsx_xflags & FS_XFLAG_DAX) {
                if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)))
                        return -EINVAL;
-               if (!bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)),
+               if (S_ISREG(inode->i_mode) &&
+                   !bdev_dax_supported(xfs_find_bdev_for_inode(VFS_I(ip)),
                                sb->s_blocksize))
                        return -EINVAL;
        }
@@ -1110,6 +1100,9 @@ xfs_ioctl_setattr_dax_invalidate(
        if (!(fa->fsx_xflags & FS_XFLAG_DAX) && !IS_DAX(inode))
                return 0;
 
+       if (S_ISDIR(inode->i_mode))
+               return 0;
+
        /* lock, flush and invalidate mapping in preparation for flag change */
        xfs_ilock(ip, XFS_MMAPLOCK_EXCL | XFS_IOLOCK_EXCL);
        error = filemap_write_and_wait(inode->i_mapping);
@@ -1819,13 +1812,13 @@ xfs_ioc_getlabel(
        /* Paranoia */
        BUILD_BUG_ON(sizeof(sbp->sb_fname) > FSLABEL_MAX);
 
+       /* 1 larger than sb_fname, so this ensures a trailing NUL char */
+       memset(label, 0, sizeof(label));
        spin_lock(&mp->m_sb_lock);
-       strncpy(label, sbp->sb_fname, sizeof(sbp->sb_fname));
+       strncpy(label, sbp->sb_fname, XFSLABEL_MAX);
        spin_unlock(&mp->m_sb_lock);
 
-       /* xfs on-disk label is 12 chars, be sure we send a null to user */
-       label[XFSLABEL_MAX] = '\0';
-       if (copy_to_user(user_label, label, sizeof(sbp->sb_fname)))
+       if (copy_to_user(user_label, label, sizeof(label)))
                return -EFAULT;
        return 0;
 }
@@ -1861,7 +1854,7 @@ xfs_ioc_setlabel(
 
        spin_lock(&mp->m_sb_lock);
        memset(sbp->sb_fname, 0, sizeof(sbp->sb_fname));
-       strncpy(sbp->sb_fname, label, sizeof(sbp->sb_fname));
+       memcpy(sbp->sb_fname, label, len);
        spin_unlock(&mp->m_sb_lock);
 
        /*
index 8de879f0c7d5e8a63ced7b6d64fdf2fa5834754b..4b17f67c888a057feabfba771e058e51fe791be3 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2008 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_IOCTL_H__
 #define __XFS_IOCTL_H__
index 10fbde359649dc6a52a8afdb9b26353b4152bbc5..fba115f4103acb7e56107111b34037011804463b 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2004-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include <linux/compat.h>
 #include <linux/ioctl.h>
index 5492bcf6f442bc2e12977bf0ca5b7b9268d25a10..d28fa824284aaf8198ad50404e86f4793bb70892 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2004-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_IOCTL32_H__
 #define __XFS_IOCTL32_H__
index c6ce6f9335b65e66caf1ee303390253d36a5a8f1..49f5492eed3bdb9d85c53843df03546c83f2c799 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * Copyright (c) 2016 Christoph Hellwig.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include <linux/iomap.h>
 #include "xfs.h"
@@ -200,7 +188,7 @@ xfs_iomap_write_direct(
                        goto out_unlock;
        } else {
                if (nmaps && (imap->br_startblock == HOLESTARTBLOCK))
-                       last_fsb = MIN(last_fsb, (xfs_fileoff_t)
+                       last_fsb = min(last_fsb, (xfs_fileoff_t)
                                        imap->br_blockcount +
                                        imap->br_startoff);
        }
@@ -488,8 +476,8 @@ xfs_iomap_prealloc_size(
         * The shift throttle value is set to the maximum value as determined by
         * the global low free space values and per-quota low free space values.
         */
-       alloc_blocks = MIN(alloc_blocks, qblocks);
-       shift = MAX(shift, qshift);
+       alloc_blocks = min(alloc_blocks, qblocks);
+       shift = max(shift, qshift);
 
        if (shift)
                alloc_blocks >>= shift;
index ee535065c5d0e3795158e9cf1ce7dafad5f3a729..83474c9cede92d584e9f0b18906f9ff69af24375 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2003-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_IOMAP_H__
 #define __XFS_IOMAP_H__
@@ -42,10 +30,10 @@ xfs_aligned_fsb_count(
        if (extsz) {
                xfs_extlen_t    align;
 
-               align = do_mod(offset_fsb, extsz);
+               div_u64_rem(offset_fsb, extsz, &align);
                if (align)
                        count_fsb += align;
-               align = do_mod(count_fsb, extsz);
+               div_u64_rem(count_fsb, extsz, &align);
                if (align)
                        count_fsb += extsz - align;
        }
index 3b4be06fdaa57112150770c84d62f048261a00c8..0fa29f39d658a7fcd8a8886689ab8e1b67a5db7e 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -1054,7 +1042,7 @@ xfs_vn_setattr(
 STATIC int
 xfs_vn_update_time(
        struct inode            *inode,
-       struct timespec         *now,
+       struct timespec64       *now,
        int                     flags)
 {
        struct xfs_inode        *ip = XFS_I(inode);
@@ -1274,6 +1262,14 @@ xfs_setup_inode(
        xfs_diflags_to_iflags(inode, ip);
 
        if (S_ISDIR(inode->i_mode)) {
+               /*
+                * We set the i_rwsem class here to avoid potential races with
+                * lockdep_annotate_inode_mutex_key() reinitialising the lock
+                * after a filehandle lookup has already found the inode in
+                * cache before it has been unlocked via unlock_new_inode().
+                */
+               lockdep_set_class(&inode->i_rwsem,
+                                 &inode->i_sb->s_type->i_mutex_dir_key);
                lockdep_set_class(&ip->i_lock.mr_lock, &xfs_dir_ilock_class);
                ip->d_ops = ip->i_mount->m_dir_inode_ops;
        } else {
index 0259a383721a5eadf6aea62c36780b2c7a107ee4..4d24ff309f593f803b9cba0b96f487e353ebcb81 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_IOPS_H__
 #define __XFS_IOPS_H__
index d583105144233182291f4b30039e45b7024d8196..24f4f1c555b5b979ba1e5a640f6a666ce34a12d5 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -571,7 +559,7 @@ xfs_inumbers(
            *lastino != XFS_AGINO_TO_INO(mp, agno, agino))
                return error;
 
-       bcount = MIN(left, (int)(PAGE_SIZE / sizeof(*buffer)));
+       bcount = min(left, (int)(PAGE_SIZE / sizeof(*buffer)));
        buffer = kmem_zalloc(bcount * sizeof(*buffer), KM_SLEEP);
        do {
                struct xfs_inobt_rec_incore     r;
index 6ea8b3912fa4fcb5b67ac9fd0d9c24164c12f6c1..8a822285b6718f417d4ab3c04a0566d1dac3566a 100644 (file)
@@ -1,18 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2001 Silicon Graphics, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_ITABLE_H__
 #define        __XFS_ITABLE_H__
index bee51a14a906ea71661e06b5d82fd46dd219c536..edbd5a210df22144ab810a67d88dac5f479b39f7 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_LINUX__
 #define __XFS_LINUX__
@@ -38,6 +26,7 @@ typedef __u32                 xfs_nlink_t;
 
 #include <linux/semaphore.h>
 #include <linux/mm.h>
+#include <linux/sched/mm.h>
 #include <linux/kernel.h>
 #include <linux/blkdev.h>
 #include <linux/slab.h>
@@ -151,8 +140,6 @@ typedef __u32                       xfs_nlink_t;
 
 #define XFS_PROJID_DEFAULT     0
 
-#define MIN(a,b)       (min(a,b))
-#define MAX(a,b)       (max(a,b))
 #define howmany(x, y)  (((x)+((y)-1))/(y))
 
 static inline void delay(long ticks)
@@ -220,25 +207,6 @@ static inline xfs_dev_t linux_to_xfs_dev_t(dev_t dev)
 #define xfs_sort(a,n,s,fn)     sort(a,n,s,fn,NULL)
 #define xfs_stack_trace()      dump_stack()
 
-/* Side effect free 64 bit mod operation */
-static inline __u32 xfs_do_mod(void *a, __u32 b, int n)
-{
-       switch (n) {
-               case 4:
-                       return *(__u32 *)a % b;
-               case 8:
-                       {
-                       __u64   c = *(__u64 *)a;
-                       return do_div(c, b);
-                       }
-       }
-
-       /* NOTREACHED */
-       return 0;
-}
-
-#define do_mod(a, b)   xfs_do_mod(&(a), (b), sizeof(a))
-
 static inline uint64_t roundup_64(uint64_t x, uint32_t y)
 {
        x += y - 1;
index c21039f27e39d7becf044241af1ce2633aa66a00..5e56f3b93d4b7757865b1e31c402c156c28580df 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -1641,8 +1629,8 @@ xlog_grant_push_ail(
         * log, and 256 blocks.
         */
        free_threshold = BTOBB(need_bytes);
-       free_threshold = MAX(free_threshold, (log->l_logBBsize >> 2));
-       free_threshold = MAX(free_threshold, 256);
+       free_threshold = max(free_threshold, (log->l_logBBsize >> 2));
+       free_threshold = max(free_threshold, 256);
        if (free_blocks >= free_threshold)
                return;
 
index fa8ad31d587f23072fcc761e59a70d81a1afb136..3c1f6a8b4b701839e33522bfd0dbec4e9fb10fab 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_LOG_H__
 #define __XFS_LOG_H__
index c15687724728b278646d7975529b0383872edc41..d3884e08b43cbcdf414432d6c829a8ea7c69ed78 100644 (file)
@@ -1,18 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2010 Red Hat, Inc. All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "xfs.h"
index 129975970d993dd81e28abf049eb05e4b1cc6649..b5f82cb362020c7451b823c2ff7d1e23840e12fd 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_LOG_PRIV_H__
 #define __XFS_LOG_PRIV_H__
index 06a09cb948b529bbf8506186bafbe23ccdcc775e..b181b5f57a19edc2c0cfdfec9ce68a517d6008c9 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -1247,6 +1235,25 @@ xlog_verify_head(
                                be32_to_cpu((*rhead)->h_size));
 }
 
+/*
+ * We need to make sure we handle log wrapping properly, so we can't use the
+ * calculated logbno directly. Make sure it wraps to the correct bno inside the
+ * log.
+ *
+ * The log is limited to 32 bit sizes, so we use the appropriate modulus
+ * operation here and cast it back to a 64 bit daddr on return.
+ */
+static inline xfs_daddr_t
+xlog_wrap_logbno(
+       struct xlog             *log,
+       xfs_daddr_t             bno)
+{
+       int                     mod;
+
+       div_s64_rem(bno, log->l_logBBsize, &mod);
+       return mod;
+}
+
 /*
  * 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
@@ -1295,12 +1302,13 @@ xlog_check_unmount_rec(
        } 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);
+
+       after_umount_blk = xlog_wrap_logbno(log,
+                       rhead_blk + hblks + BTOBB(be32_to_cpu(rhead->h_len)));
+
        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);
+               umount_data_blk = xlog_wrap_logbno(log, rhead_blk + hblks);
                error = xlog_bread(log, umount_data_blk, 1, bp, &offset);
                if (error)
                        return error;
@@ -1816,7 +1824,7 @@ xlog_clear_stale_blocks(
         * we don't waste all day writing from the head to the tail
         * for no reason.
         */
-       max_distance = MIN(max_distance, tail_distance);
+       max_distance = min(max_distance, tail_distance);
 
        if ((head_block + max_distance) <= log->l_logBBsize) {
                /*
@@ -2884,14 +2892,14 @@ xlog_recover_buffer_pass2(
         * buffers in the log can be a different size if the log was generated
         * by an older kernel using unclustered inode buffers or a newer kernel
         * running with a different inode cluster size.  Regardless, if the
-        * the inode buffer size isn't MAX(blocksize, mp->m_inode_cluster_size)
+        * the inode buffer size isn't max(blocksize, mp->m_inode_cluster_size)
         * for *our* value of mp->m_inode_cluster_size, then we need to keep
         * the buffer out of the buffer cache so that the buffer won't
         * overlap with future reads of those inodes.
         */
        if (XFS_DINODE_MAGIC ==
            be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) &&
-           (BBTOB(bp->b_io_length) != MAX(log->l_mp->m_sb.sb_blocksize,
+           (BBTOB(bp->b_io_length) != max(log->l_mp->m_sb.sb_blocksize,
                        (uint32_t)log->l_mp->m_inode_cluster_size))) {
                xfs_buf_stale(bp);
                error = xfs_bwrite(bp);
@@ -3115,7 +3123,8 @@ xlog_recover_inode_pass2(
                if ((ldip->di_format != XFS_DINODE_FMT_EXTENTS) &&
                    (ldip->di_format != XFS_DINODE_FMT_BTREE)) {
                        XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(3)",
-                                        XFS_ERRLEVEL_LOW, mp, ldip);
+                                        XFS_ERRLEVEL_LOW, mp, ldip,
+                                        sizeof(*ldip));
                        xfs_alert(mp,
                "%s: Bad regular inode log record, rec ptr "PTR_FMT", "
                "ino ptr = "PTR_FMT", ino bp = "PTR_FMT", ino %Ld",
@@ -3128,7 +3137,8 @@ xlog_recover_inode_pass2(
                    (ldip->di_format != XFS_DINODE_FMT_BTREE) &&
                    (ldip->di_format != XFS_DINODE_FMT_LOCAL)) {
                        XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(4)",
-                                            XFS_ERRLEVEL_LOW, mp, ldip);
+                                            XFS_ERRLEVEL_LOW, mp, ldip,
+                                            sizeof(*ldip));
                        xfs_alert(mp,
                "%s: Bad dir inode log record, rec ptr "PTR_FMT", "
                "ino ptr = "PTR_FMT", ino bp = "PTR_FMT", ino %Ld",
@@ -3139,7 +3149,8 @@ xlog_recover_inode_pass2(
        }
        if (unlikely(ldip->di_nextents + ldip->di_anextents > ldip->di_nblocks)){
                XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(5)",
-                                    XFS_ERRLEVEL_LOW, mp, ldip);
+                                    XFS_ERRLEVEL_LOW, mp, ldip,
+                                    sizeof(*ldip));
                xfs_alert(mp,
        "%s: Bad inode log record, rec ptr "PTR_FMT", dino ptr "PTR_FMT", "
        "dino bp "PTR_FMT", ino %Ld, total extents = %d, nblocks = %Ld",
@@ -3151,7 +3162,8 @@ xlog_recover_inode_pass2(
        }
        if (unlikely(ldip->di_forkoff > mp->m_sb.sb_inodesize)) {
                XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(6)",
-                                    XFS_ERRLEVEL_LOW, mp, ldip);
+                                    XFS_ERRLEVEL_LOW, mp, ldip,
+                                    sizeof(*ldip));
                xfs_alert(mp,
        "%s: Bad inode log record, rec ptr "PTR_FMT", dino ptr "PTR_FMT", "
        "dino bp "PTR_FMT", ino %Ld, forkoff 0x%x", __func__,
@@ -3162,7 +3174,8 @@ xlog_recover_inode_pass2(
        isize = xfs_log_dinode_size(ldip->di_version);
        if (unlikely(item->ri_buf[1].i_len > isize)) {
                XFS_CORRUPTION_ERROR("xlog_recover_inode_pass2(7)",
-                                    XFS_ERRLEVEL_LOW, mp, ldip);
+                                    XFS_ERRLEVEL_LOW, mp, ldip,
+                                    sizeof(*ldip));
                xfs_alert(mp,
                        "%s: Bad inode log record length %d, rec ptr "PTR_FMT,
                        __func__, item->ri_buf[1].i_len, item);
@@ -5466,9 +5479,7 @@ xlog_do_recovery_pass(
                         */
                        if (blk_no + bblks <= log->l_logBBsize ||
                            blk_no >= log->l_logBBsize) {
-                               /* mod blk_no in case the header wrapped and
-                                * pushed it beyond the end of the log */
-                               rblk_no = do_mod(blk_no, log->l_logBBsize);
+                               rblk_no = xlog_wrap_logbno(log, blk_no);
                                error = xlog_bread(log, rblk_no, bblks, dbp,
                                                   &offset);
                                if (error)
index e68bd1050eab53fca672d8afd5444d7b62cfcfbf..576c375ce12a8f411a49f75cf6bd72f69c96279c 100644 (file)
@@ -1,18 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2011 Red Hat, Inc.  All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "xfs.h"
index 73ed8fec0328c42d79b82466660cb126c4d1dc87..a3378252baa10dad6899e5044ee774a50d9c980e 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -874,9 +862,12 @@ xfs_mountfs(
         * Get and sanity-check the root inode.
         * Save the pointer to it in the mount structure.
         */
-       error = xfs_iget(mp, NULL, sbp->sb_rootino, 0, XFS_ILOCK_EXCL, &rip);
+       error = xfs_iget(mp, NULL, sbp->sb_rootino, XFS_IGET_UNTRUSTED,
+                        XFS_ILOCK_EXCL, &rip);
        if (error) {
-               xfs_warn(mp, "failed to read root inode");
+               xfs_warn(mp,
+                       "Failed to read root inode 0x%llx, error %d",
+                       sbp->sb_rootino, -error);
                goto out_log_dealloc;
        }
 
index 10b90bbc51629fd536fc4447dd5cbc600b522259..245349d1e23f351d66d08fe137fe77904d8f046d 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_MOUNT_H__
 #define        __XFS_MOUNT_H__
@@ -283,7 +271,7 @@ xfs_preferred_iosize(xfs_mount_t *mp)
        return (mp->m_swidth ?
                (mp->m_swidth << mp->m_sb.sb_blocklog) :
                ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ?
-                       (1 << (int)MAX(mp->m_readio_log, mp->m_writeio_log)) :
+                       (1 << (int)max(mp->m_readio_log, mp->m_writeio_log)) :
                        PAGE_SIZE));
 }
 
index 70eea7ae2876b19594728c50a3f4a97fc87bbac2..74738813f60d8bb6561c3ef9b3cf7ad4923276d5 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2006-2007 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_mru_cache.h"
index b3f3fbdfcc47c0ecbb6b01407346e71693393d04..f1fde1ecf730f7fdb7c010cc4102bb98ba0a023d 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2006-2007 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_MRU_CACHE_H__
 #define __XFS_MRU_CACHE_H__
index 0492436a053fcf0875764b341cbb150a2dde3baa..d3e04d20d8d45007279ee85ab5b04833d3f9355a 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2016 Oracle.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_ONDISK_H
 #define __XFS_ONDISK_H
index c3e014bfc848539ebcc4deb14c1ec1d8afbbd67b..9ceb85cce33a54cc02fd1b09efd074c2af8206c0 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index e3129b280423224a1479bb880fd7746bc5a50963..3ccf0fbc9071a69b527f27a43090d1c58490d5d1 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_QM_H__
 #define __XFS_QM_H__
index 36b89e2c5eb904d3cd6495bdc9cc7ade016ce1c7..73a1d77ec187c8958d09cc6fb13f4af3e0e61605 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 3e05d300b14ebc1b21ff5095cd1e375d0b44a42d..abc8a21e3a822955406a65aaaf6a27b3b9424849 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include <linux/capability.h>
index 3edf52b149199332f67183817de01c8828a502a1..55b798265ef7375f69562ed6d81aee46701cd4ee 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_QUOTA_H__
 #define __XFS_QUOTA_H__
index c93fc913dffbcc629d5bba5ad6e1cf3e7a035f35..205fbb2a77e4d97ebf148e7c9fbea5ea79787c2a 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2008, Christoph Hellwig
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_format.h"
index e5866b714d5f3803587dbf0aab317b2804b7257b..472a73e9d331b0e044179b98e92c0c226139777c 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 0e5327349a13ee5921808ed866ac02acc038d0df..dd830b69cd1e508189cd9a69969ce29695d7a7c0 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef        __XFS_REFCOUNT_ITEM_H__
 #define        __XFS_REFCOUNT_ITEM_H__
index 713e857d9ffa4eac6c6a649164b4c7e307928c1e..592fb2071a037629b879dfda731a498da2b2b718 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 701487bab468c83526d3bf9169e625de338ce904..1532827ba911849d193a647115b2376d50f9cf47 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef __XFS_REFLINK_H
 #define __XFS_REFLINK_H 1
index e5b5b3e7ef82a9c4c8cf900bc219fd2b80e5e08e..127dc9c32a54247be2b24ec56de1f2d91e82a6c4 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 340c968e1f9c047f5c12eacafc215e55cc5129ad..7e482baa27f5b5e3a2bf5e89b80933f04dac3b74 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #ifndef        __XFS_RMAP_ITEM_H__
 #define        __XFS_RMAP_ITEM_H__
index 488719d43ca82a434e2ee8afdd94b2ec9cfcddad..329d4d26c13e5b206b0c337013f66b97cc3041a3 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -313,8 +301,12 @@ xfs_rtallocate_extent_block(
                /*
                 * If size should be a multiple of prod, make that so.
                 */
-               if (prod > 1 && (p = do_mod(bestlen, prod)))
-                       bestlen -= p;
+               if (prod > 1) {
+                       div_u64_rem(bestlen, prod, &p);
+                       if (p)
+                               bestlen -= p;
+               }
+
                /*
                 * Allocate besti for bestlen & return that.
                 */
@@ -1275,7 +1267,7 @@ xfs_rtpick_extent(
                b = (mp->m_sb.sb_rextents * ((resid << 1) + 1ULL)) >>
                    (log2 + 1);
                if (b >= mp->m_sb.sb_rextents)
-                       b = do_mod(b, mp->m_sb.sb_rextents);
+                       div64_u64_rem(b, mp->m_sb.sb_rextents, &b);
                if (b + len > mp->m_sb.sb_rextents)
                        b = mp->m_sb.sb_rextents - len;
        }
index 52632ab727f7fbf874cd201a9e1b89d7d1bbad1e..93e77b2213559d8ad932d47a18afa1522e7d97ba 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_RTALLOC_H__
 #define        __XFS_RTALLOC_H__
index 1cc79907b377329cce913c6c59823d9d05e1e029..4e4423153071c788bb278d3856e3ff346cb915f8 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include <linux/proc_fs.h>
index f64d0ae345c4d7b5dd3759fc2340572373a71743..130db070e4d8a9ae0ad22b89d85cdd3eb3255f7e 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_STATS_H__
 #define __XFS_STATS_H__
index ed67389f494895f284b04f9f5b1cd75446f9e051..9d791f158dfe68f5d65f8fda193cdd5496322cc1 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "xfs.h"
@@ -1148,7 +1136,7 @@ xfs_fs_statfs(
        statp->f_bavail = statp->f_bfree;
 
        fakeinos = statp->f_bfree << sbp->sb_inopblog;
-       statp->f_files = MIN(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
+       statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
        if (mp->m_maxicount)
                statp->f_files = min_t(typeof(statp->f_files),
                                        statp->f_files,
index 8cee8e8050e3e9fa5ebba5f4009e064c27dc7688..21cb49a43d7cb0c8c9945fc35cd71dc0e3fceb6d 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_SUPER_H__
 #define __XFS_SUPER_H__
index aed03da637d43e754fe6b19a93ad42cc843a3022..3783afcb68d24a2ece0279a8ee11e0bd6dec5404 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * Copyright (c) 2012-2013 Red Hat, Inc.
  * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_shared.h"
index aeaee89236171e7c421276205f3fd2771b7faa82..9743d8c9394ba8a618a9e73cec48d1d8133e3bb1 100644 (file)
@@ -1,18 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2012 Red Hat, Inc. All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_SYMLINK_H
 #define __XFS_SYMLINK_H 1
index afe1f66aaa6980a682ae6a736351115a5ae87ac1..0cc034dfb78608e23b5a6fea5f41b076c8743b12 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2001-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include <linux/sysctl.h>
index b53a33e69932df6ada6a124ede8d738b91eddf3b..168488130a1906e34e1181da624891e20b73436a 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2001-2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_SYSCTL_H__
 #define __XFS_SYSCTL_H__
index 2d5cd2529f8e1d1b6461ccd738fbd04a8c7e8b77..cd6a994a72500ac48755549db33d5510e3c36fdc 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "xfs.h"
index d04637181ef21709715d6320bf0569e3d715740a..e9f810fc6731746ea0aa1eebf328f352688479dc 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2014 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #ifndef __XFS_SYSFS_H__
index 35f3546b6af5237a78a9fe1bd3aa07cbb8503349..cb6489c22cad2015126b6e7b1977c1507b017ad5 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2009, Christoph Hellwig
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 9d4c4ca24fe69e5649b3ed6a343ab27da433a871..972d45d28097fc6f8612bf59179679e95663e6b5 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2009, Christoph Hellwig
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM xfs
index fc7ba75b8b69d4e8d686f80cebd357b0dc7f61f2..e040af120b69b3a69b38517cde3092773b391260 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
  * Copyright (C) 2010 Red Hat, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 29706b8b3bd41e4475750be52b909b6f6f57c2c4..6526314f0b8f6e9cae00f527de5a2661903cee31 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef        __XFS_TRANS_H__
 #define        __XFS_TRANS_H__
index 41e280ef148381741157fc63459198cf06cdcbaf..55326f971cb36bb87e35552f461a81a1c206ef3f 100644 (file)
@@ -1,20 +1,8 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * Copyright (c) 2008 Dave Chinner
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 230a21df4b12131ace50c15fd7afe51b0a17fcd9..a15a5cd867f9b943ead844efb8da4095e6527f51 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index a8ddb4eed2798c7a1209fca65d82d13001777669..15919f67a88f57aeab504f471c9088d066d08493 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index c381c02cca45c85c726b99b41d9484ed9fc35e08..c23257a26c2b81883e7012ff0b526927ec1f77f6 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000-2002 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 2f44a08bdf65dd3914061a2af301dce283b96655..bd66c76f55e6dc0f453471d591f0b26a94d0e6c5 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index f7bd7960a90f5671eee2c6e5a110761679319dc4..542927321a61b5e2ff52b30faca74dac268c1722 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #include "xfs.h"
 #include "xfs_fs.h"
@@ -70,7 +58,7 @@ xfs_trans_ichgtime(
        int                     flags)
 {
        struct inode            *inode = VFS_I(ip);
-       struct timespec         tv;
+       struct timespec64 tv;
 
        ASSERT(tp);
        ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
index 9717ae74b36dab2528ee11af715e5de767f042fd..091eae9f4e7434e7d40364567dc98e84aa177060 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2000,2002,2005 Silicon Graphics, Inc.
  * All Rights Reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 #ifndef __XFS_TRANS_PRIV_H__
 #define        __XFS_TRANS_PRIV_H__
index c7f8e82f5bdad50da45d7b31c8ee4b97d7b9de25..46dd4fca8aa772e97cd75f21a6fb2a9932308958 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 5831ca0c270b39cc74daec8363d8726bf5339f19..726d8e2c0558a560165ede020f81539549652aa9 100644 (file)
@@ -1,21 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * Copyright (C) 2016 Oracle.  All Rights Reserved.
- *
  * Author: Darrick J. Wong <darrick.wong@oracle.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 would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 #include "xfs.h"
 #include "xfs_fs.h"
index 0594db435972500de9c8901ff5baeda14832bc83..63ee1d5bf1d77a33d7f760f0f10d722266488cb1 100644 (file)
@@ -1,19 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (C) 2008 Christoph Hellwig.
  * Portions Copyright (C) 2000-2008 Silicon Graphics, Inc.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write the Free Software Foundation,
- * Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  */
 
 #include "xfs.h"
index 0a6c5bd92256651ffb0a97bb0df64952fc2e6ffb..3a26aa7ead23c998dd335d60c5c171bc70defd1d 100644 (file)
@@ -80,7 +80,8 @@
 #define ACPI_LV_ALLOCATIONS         0x00100000
 #define ACPI_LV_FUNCTIONS           0x00200000
 #define ACPI_LV_OPTIMIZATIONS       0x00400000
-#define ACPI_LV_VERBOSITY2          0x00700000 | ACPI_LV_VERBOSITY1
+#define ACPI_LV_PARSE_TREES         0x00800000
+#define ACPI_LV_VERBOSITY2          0x00F00000 | ACPI_LV_VERBOSITY1
 #define ACPI_LV_ALL                 ACPI_LV_VERBOSITY2
 
 /* Trace verbosity level 3 [Threading, I/O, and Interrupts] */
 #define ACPI_DB_TABLES              ACPI_DEBUG_LEVEL (ACPI_LV_TABLES)
 #define ACPI_DB_FUNCTIONS           ACPI_DEBUG_LEVEL (ACPI_LV_FUNCTIONS)
 #define ACPI_DB_OPTIMIZATIONS       ACPI_DEBUG_LEVEL (ACPI_LV_OPTIMIZATIONS)
+#define ACPI_DB_PARSE_TREES         ACPI_DEBUG_LEVEL (ACPI_LV_PARSE_TREES)
 #define ACPI_DB_VALUES              ACPI_DEBUG_LEVEL (ACPI_LV_VALUES)
 #define ACPI_DB_OBJECTS             ACPI_DEBUG_LEVEL (ACPI_LV_OBJECTS)
 #define ACPI_DB_ALLOCATIONS         ACPI_DEBUG_LEVEL (ACPI_LV_ALLOCATIONS)
index 77d71bd1be39abcc4e1d4528f26158b130fd1615..48d84f0d9547ad8d2c24057a9e780e74dec8045c 100644 (file)
@@ -12,7 +12,7 @@
 
 /* Current ACPICA subsystem version in YYYYMMDD format */
 
-#define ACPI_CA_VERSION                 0x20180508
+#define ACPI_CA_VERSION                 0x20180531
 
 #include <acpi/acconfig.h>
 #include <acpi/actypes.h>
index 876012da8e6e63a8756916e44f6936b04a8c8532..c50ef7e6b94252bab51e09a5db207f15df6b8157 100644 (file)
@@ -67,7 +67,7 @@
  * IORT - IO Remapping Table
  *
  * Conforms to "IO Remapping Table System Software on ARM Platforms",
- * Document number: ARM DEN 0049C, May 2017
+ * Document number: ARM DEN 0049D, March 2018
  *
  ******************************************************************************/
 
@@ -98,7 +98,8 @@ enum acpi_iort_node_type {
        ACPI_IORT_NODE_NAMED_COMPONENT = 0x01,
        ACPI_IORT_NODE_PCI_ROOT_COMPLEX = 0x02,
        ACPI_IORT_NODE_SMMU = 0x03,
-       ACPI_IORT_NODE_SMMU_V3 = 0x04
+       ACPI_IORT_NODE_SMMU_V3 = 0x04,
+       ACPI_IORT_NODE_PMCG = 0x05
 };
 
 struct acpi_iort_id_mapping {
@@ -152,10 +153,17 @@ struct acpi_iort_named_component {
        char device_name[1];    /* Path of namespace object */
 };
 
+/* Masks for Flags field above */
+
+#define ACPI_IORT_NC_STALL_SUPPORTED    (1)
+#define ACPI_IORT_NC_PASID_BITS         (31<<1)
+
 struct acpi_iort_root_complex {
        u64 memory_properties;  /* Memory access properties */
        u32 ats_attribute;
        u32 pci_segment_number;
+       u8 memory_address_limit;        /* Memory address size limit */
+       u8 reserved[3];         /* Reserved, must be zero */
 };
 
 /* Values for ats_attribute field above */
@@ -209,9 +217,7 @@ struct acpi_iort_smmu_v3 {
        u32 pri_gsiv;
        u32 gerr_gsiv;
        u32 sync_gsiv;
-       u8 pxm;
-       u8 reserved1;
-       u16 reserved2;
+       u32 pxm;
        u32 id_mapping_index;
 };
 
@@ -224,9 +230,16 @@ struct acpi_iort_smmu_v3 {
 /* Masks for Flags field above */
 
 #define ACPI_IORT_SMMU_V3_COHACC_OVERRIDE   (1)
-#define ACPI_IORT_SMMU_V3_HTTU_OVERRIDE     (1<<1)
+#define ACPI_IORT_SMMU_V3_HTTU_OVERRIDE     (3<<1)
 #define ACPI_IORT_SMMU_V3_PXM_VALID         (1<<3)
 
+struct acpi_iort_pmcg {
+       u64 page0_base_address;
+       u32 overflow_gsiv;
+       u32 node_reference;
+       u64 page1_base_address;
+};
+
 /*******************************************************************************
  *
  * IVRS - I/O Virtualization Reporting Structure
index 2b1bafa197c0d68bc094949818695c2b29ae6c64..66ceb12ebc63032a9f4af8a9da7db9ac04c83178 100644 (file)
@@ -1272,6 +1272,7 @@ typedef enum {
 #define ACPI_OSI_WIN_10                 0x0D
 #define ACPI_OSI_WIN_10_RS1             0x0E
 #define ACPI_OSI_WIN_10_RS2             0x0F
+#define ACPI_OSI_WIN_10_RS3             0x10
 
 /* Definitions of getopt */
 
index 27c8386987ffa43db5aee53c655b9913e96ce8e1..dfe99c8a5ba5731ad5dbe7f825c5596f9fbff48d 100644 (file)
 #define TEGRA_SWGROUP_EMUCIF   18
 #define TEGRA_SWGROUP_TSEC     19
 
+#define TEGRA114_MC_RESET_AVPC         0
+#define TEGRA114_MC_RESET_DC           1
+#define TEGRA114_MC_RESET_DCB          2
+#define TEGRA114_MC_RESET_EPP          3
+#define TEGRA114_MC_RESET_2D           4
+#define TEGRA114_MC_RESET_HC           5
+#define TEGRA114_MC_RESET_HDA          6
+#define TEGRA114_MC_RESET_ISP          7
+#define TEGRA114_MC_RESET_MPCORE       8
+#define TEGRA114_MC_RESET_MPCORELP     9
+#define TEGRA114_MC_RESET_MPE          10
+#define TEGRA114_MC_RESET_3D           11
+#define TEGRA114_MC_RESET_3D2          12
+#define TEGRA114_MC_RESET_PPCS         13
+#define TEGRA114_MC_RESET_VDE          14
+#define TEGRA114_MC_RESET_VI           15
+
 #endif
index f534d7c06019415d541df1b45db4a5def3591c69..186e6b7e9b35c4079ea5e2152a84ebb08c9fa917 100644 (file)
 #define TEGRA_SWGROUP_VIC      24
 #define TEGRA_SWGROUP_VI       25
 
+#define TEGRA124_MC_RESET_AFI          0
+#define TEGRA124_MC_RESET_AVPC         1
+#define TEGRA124_MC_RESET_DC           2
+#define TEGRA124_MC_RESET_DCB          3
+#define TEGRA124_MC_RESET_HC           4
+#define TEGRA124_MC_RESET_HDA          5
+#define TEGRA124_MC_RESET_ISP2         6
+#define TEGRA124_MC_RESET_MPCORE       7
+#define TEGRA124_MC_RESET_MPCORELP     8
+#define TEGRA124_MC_RESET_MSENC                9
+#define TEGRA124_MC_RESET_PPCS         10
+#define TEGRA124_MC_RESET_SATA         11
+#define TEGRA124_MC_RESET_VDE          12
+#define TEGRA124_MC_RESET_VI           13
+#define TEGRA124_MC_RESET_VIC          14
+#define TEGRA124_MC_RESET_XUSB_HOST    15
+#define TEGRA124_MC_RESET_XUSB_DEV     16
+#define TEGRA124_MC_RESET_TSEC         17
+#define TEGRA124_MC_RESET_SDMMC1       18
+#define TEGRA124_MC_RESET_SDMMC2       19
+#define TEGRA124_MC_RESET_SDMMC3       20
+#define TEGRA124_MC_RESET_SDMMC4       21
+#define TEGRA124_MC_RESET_ISP2B                22
+#define TEGRA124_MC_RESET_GPU          23
+
 #endif
diff --git a/include/dt-bindings/memory/tegra20-mc.h b/include/dt-bindings/memory/tegra20-mc.h
new file mode 100644 (file)
index 0000000..35e131e
--- /dev/null
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef DT_BINDINGS_MEMORY_TEGRA20_MC_H
+#define DT_BINDINGS_MEMORY_TEGRA20_MC_H
+
+#define TEGRA20_MC_RESET_AVPC          0
+#define TEGRA20_MC_RESET_DC            1
+#define TEGRA20_MC_RESET_DCB           2
+#define TEGRA20_MC_RESET_EPP           3
+#define TEGRA20_MC_RESET_2D            4
+#define TEGRA20_MC_RESET_HC            5
+#define TEGRA20_MC_RESET_ISP           6
+#define TEGRA20_MC_RESET_MPCORE                7
+#define TEGRA20_MC_RESET_MPEA          8
+#define TEGRA20_MC_RESET_MPEB          9
+#define TEGRA20_MC_RESET_MPEC          10
+#define TEGRA20_MC_RESET_3D            11
+#define TEGRA20_MC_RESET_PPCS          12
+#define TEGRA20_MC_RESET_VDE           13
+#define TEGRA20_MC_RESET_VI            14
+
+#endif
index 4490f7cf47726f64859333f72eca18b435276aea..cacf05617e03e6a1565fe5db7ef770c1e3a46dcb 100644 (file)
 #define TEGRA_SWGROUP_ETR      29
 #define TEGRA_SWGROUP_TSECB    30
 
+#define TEGRA210_MC_RESET_AFI          0
+#define TEGRA210_MC_RESET_AVPC         1
+#define TEGRA210_MC_RESET_DC           2
+#define TEGRA210_MC_RESET_DCB          3
+#define TEGRA210_MC_RESET_HC           4
+#define TEGRA210_MC_RESET_HDA          5
+#define TEGRA210_MC_RESET_ISP2         6
+#define TEGRA210_MC_RESET_MPCORE       7
+#define TEGRA210_MC_RESET_NVENC                8
+#define TEGRA210_MC_RESET_PPCS         9
+#define TEGRA210_MC_RESET_SATA         10
+#define TEGRA210_MC_RESET_VI           11
+#define TEGRA210_MC_RESET_VIC          12
+#define TEGRA210_MC_RESET_XUSB_HOST    13
+#define TEGRA210_MC_RESET_XUSB_DEV     14
+#define TEGRA210_MC_RESET_A9AVP                15
+#define TEGRA210_MC_RESET_TSEC         16
+#define TEGRA210_MC_RESET_SDMMC1       17
+#define TEGRA210_MC_RESET_SDMMC2       18
+#define TEGRA210_MC_RESET_SDMMC3       19
+#define TEGRA210_MC_RESET_SDMMC4       20
+#define TEGRA210_MC_RESET_ISP2B                21
+#define TEGRA210_MC_RESET_GPU          22
+#define TEGRA210_MC_RESET_NVDEC                23
+#define TEGRA210_MC_RESET_APE          24
+#define TEGRA210_MC_RESET_SE           25
+#define TEGRA210_MC_RESET_NVJPG                26
+#define TEGRA210_MC_RESET_AXIAP                27
+#define TEGRA210_MC_RESET_ETR          28
+#define TEGRA210_MC_RESET_TSECB                29
+
 #endif
index 3cac81919023d48de1c10f3753c02d24178c6a92..169f005fbc788fc94aed2f1754e6294db717f7f1 100644 (file)
 #define TEGRA_SWGROUP_MPCORE   17
 #define TEGRA_SWGROUP_ISP      18
 
+#define TEGRA30_MC_RESET_AFI           0
+#define TEGRA30_MC_RESET_AVPC          1
+#define TEGRA30_MC_RESET_DC            2
+#define TEGRA30_MC_RESET_DCB           3
+#define TEGRA30_MC_RESET_EPP           4
+#define TEGRA30_MC_RESET_2D            5
+#define TEGRA30_MC_RESET_HC            6
+#define TEGRA30_MC_RESET_HDA           7
+#define TEGRA30_MC_RESET_ISP           8
+#define TEGRA30_MC_RESET_MPCORE                9
+#define TEGRA30_MC_RESET_MPCORELP      10
+#define TEGRA30_MC_RESET_MPE           11
+#define TEGRA30_MC_RESET_3D            12
+#define TEGRA30_MC_RESET_3D2           13
+#define TEGRA30_MC_RESET_PPCS          14
+#define TEGRA30_MC_RESET_SATA          15
+#define TEGRA30_MC_RESET_VDE           16
+#define TEGRA30_MC_RESET_VI            17
+
 #endif
diff --git a/include/dt-bindings/power/px30-power.h b/include/dt-bindings/power/px30-power.h
new file mode 100644 (file)
index 0000000..30917a9
--- /dev/null
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __DT_BINDINGS_POWER_PX30_POWER_H__
+#define __DT_BINDINGS_POWER_PX30_POWER_H__
+
+/* VD_CORE */
+#define PX30_PD_A35_0          0
+#define PX30_PD_A35_1          1
+#define PX30_PD_A35_2          2
+#define PX30_PD_A35_3          3
+#define PX30_PD_SCU            4
+
+/* VD_LOGIC */
+#define PX30_PD_USB            5
+#define PX30_PD_DDR            6
+#define PX30_PD_SDCARD         7
+#define PX30_PD_CRYPTO         8
+#define PX30_PD_GMAC           9
+#define PX30_PD_MMC_NAND       10
+#define PX30_PD_VPU            11
+#define PX30_PD_VO             12
+#define PX30_PD_VI             13
+#define PX30_PD_GPU            14
+
+/* VD_PMU */
+#define PX30_PD_PMU            15
+
+#endif
diff --git a/include/dt-bindings/power/r8a77470-sysc.h b/include/dt-bindings/power/r8a77470-sysc.h
new file mode 100644 (file)
index 0000000..8bf4db1
--- /dev/null
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2018 Renesas Electronics Corp.
+ */
+#ifndef __DT_BINDINGS_POWER_R8A77470_SYSC_H__
+#define __DT_BINDINGS_POWER_R8A77470_SYSC_H__
+
+/*
+ * These power domain indices match the numbers of the interrupt bits
+ * representing the power areas in the various Interrupt Registers
+ * (e.g. SYSCISR, Interrupt Status Register)
+ */
+
+#define R8A77470_PD_CA7_CPU0            5
+#define R8A77470_PD_CA7_CPU1            6
+#define R8A77470_PD_SGX                        20
+#define R8A77470_PD_CA7_SCU            21
+
+/* Always-on power area */
+#define R8A77470_PD_ALWAYS_ON          32
+
+#endif /* __DT_BINDINGS_POWER_R8A77470_SYSC_H__ */
diff --git a/include/dt-bindings/power/r8a77990-sysc.h b/include/dt-bindings/power/r8a77990-sysc.h
new file mode 100644 (file)
index 0000000..944d85b
--- /dev/null
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (C) 2018 Renesas Electronics Corp.
+ */
+#ifndef __DT_BINDINGS_POWER_R8A77990_SYSC_H__
+#define __DT_BINDINGS_POWER_R8A77990_SYSC_H__
+
+/*
+ * These power domain indices match the numbers of the interrupt bits
+ * representing the power areas in the various Interrupt Registers
+ * (e.g. SYSCISR, Interrupt Status Register)
+ */
+
+#define R8A77990_PD_CA53_CPU0          5
+#define R8A77990_PD_CA53_CPU1          6
+#define R8A77990_PD_CR7                        13
+#define R8A77990_PD_A3VC               14
+#define R8A77990_PD_3DG_A              17
+#define R8A77990_PD_3DG_B              18
+#define R8A77990_PD_CA53_SCU           21
+#define R8A77990_PD_A2VC1              26
+
+/* Always-on power area */
+#define R8A77990_PD_ALWAYS_ON          32
+
+#endif /* __DT_BINDINGS_POWER_R8A77990_SYSC_H__ */
diff --git a/include/dt-bindings/power/rk3036-power.h b/include/dt-bindings/power/rk3036-power.h
new file mode 100644 (file)
index 0000000..0bc6b5d
--- /dev/null
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __DT_BINDINGS_POWER_RK3036_POWER_H__
+#define __DT_BINDINGS_POWER_RK3036_POWER_H__
+
+#define RK3036_PD_MSCH         0
+#define RK3036_PD_CORE         1
+#define RK3036_PD_PERI         2
+#define RK3036_PD_VIO          3
+#define RK3036_PD_VPU          4
+#define RK3036_PD_GPU          5
+#define RK3036_PD_SYS          6
+
+#endif
diff --git a/include/dt-bindings/power/rk3128-power.h b/include/dt-bindings/power/rk3128-power.h
new file mode 100644 (file)
index 0000000..c051dc3
--- /dev/null
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __DT_BINDINGS_POWER_RK3128_POWER_H__
+#define __DT_BINDINGS_POWER_RK3128_POWER_H__
+
+/* VD_CORE */
+#define RK3128_PD_CORE         0
+
+/* VD_LOGIC */
+#define RK3128_PD_VIO          1
+#define RK3128_PD_VIDEO                2
+#define RK3128_PD_GPU          3
+#define RK3128_PD_MSCH         4
+
+#endif
diff --git a/include/dt-bindings/power/rk3228-power.h b/include/dt-bindings/power/rk3228-power.h
new file mode 100644 (file)
index 0000000..6a8dc1b
--- /dev/null
@@ -0,0 +1,21 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __DT_BINDINGS_POWER_RK3228_POWER_H__
+#define __DT_BINDINGS_POWER_RK3228_POWER_H__
+
+/**
+ * RK3228 idle id Summary.
+ */
+
+#define RK3228_PD_CORE         0
+#define RK3228_PD_MSCH         1
+#define RK3228_PD_BUS          2
+#define RK3228_PD_SYS          3
+#define RK3228_PD_VIO          4
+#define RK3228_PD_VOP          5
+#define RK3228_PD_VPU          6
+#define RK3228_PD_RKVDEC       7
+#define RK3228_PD_GPU          8
+#define RK3228_PD_PERI         9
+#define RK3228_PD_GMAC         10
+
+#endif
index 2480469ce8fb34a15e724cbd78f9b29fc8defb37..e0a9c236887281d793acff2ea457d2290c56cb4e 100644 (file)
@@ -1,6 +1,6 @@
 /* Asymmetric public-key cryptography key subtype
  *
- * See Documentation/security/asymmetric-keys.txt
+ * See Documentation/crypto/asymmetric-keys.txt
  *
  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
index b38240716d411745b9e11e2d68030b1ae4a948fb..1cb77cd5135e3272b141eedabcd52dafc97a180e 100644 (file)
@@ -1,6 +1,6 @@
 /* Asymmetric Public-key cryptography key type interface
  *
- * See Documentation/security/asymmetric-keys.txt
+ * See Documentation/crypto/asymmetric-keys.txt
  *
  * Copyright (C) 2012 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
index e7efe12a81bdfae67d4f5709e34b14831bd594ac..cfdd2484cc4263375fbb3ba527a75db2789bbb36 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <linux/irqchip/arm-gic-v4.h>
 
-#define VGIC_V3_MAX_CPUS       255
+#define VGIC_V3_MAX_CPUS       512
 #define VGIC_V2_MAX_CPUS       8
 #define VGIC_NR_IRQS_LEGACY     256
 #define VGIC_NR_SGIS           16
@@ -201,6 +201,14 @@ struct vgic_its {
 
 struct vgic_state_iter;
 
+struct vgic_redist_region {
+       u32 index;
+       gpa_t base;
+       u32 count; /* number of redistributors or 0 if single region */
+       u32 free_index; /* index of the next free redistributor */
+       struct list_head list;
+};
+
 struct vgic_dist {
        bool                    in_kernel;
        bool                    ready;
@@ -220,10 +228,7 @@ struct vgic_dist {
                /* either a GICv2 CPU interface */
                gpa_t                   vgic_cpu_base;
                /* or a number of GICv3 redistributor regions */
-               struct {
-                       gpa_t           vgic_redist_base;
-                       gpa_t           vgic_redist_free_offset;
-               };
+               struct list_head rd_regions;
        };
 
        /* distributor enabled */
@@ -311,6 +316,7 @@ struct vgic_cpu {
         */
        struct vgic_io_device   rd_iodev;
        struct vgic_io_device   sgi_iodev;
+       struct vgic_redist_region *rdreg;
 
        /* Contains the attributes and gpa of the LPI pending tables. */
        u64 pendbaser;
@@ -332,7 +338,6 @@ void kvm_vgic_early_init(struct kvm *kvm);
 int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu);
 int kvm_vgic_create(struct kvm *kvm, u32 type);
 void kvm_vgic_destroy(struct kvm *kvm);
-void kvm_vgic_vcpu_early_init(struct kvm_vcpu *vcpu);
 void kvm_vgic_vcpu_destroy(struct kvm_vcpu *vcpu);
 int kvm_vgic_map_resources(struct kvm *kvm);
 int kvm_vgic_hyp_init(void);
index a89df3be16863302dcedde84da6f0dbc278fde8c..65e3832f96b2529784599a66e7c87273211d6e0e 100644 (file)
@@ -1,6 +1,6 @@
 /* Generic associative array implementation.
  *
- * See Documentation/assoc_array.txt for information.
+ * See Documentation/core-api/assoc_array.rst for information.
  *
  * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
index 711275e6681c7829aba18c5e1c07f05d3bc36996..a00a06550c10ccbc6229be83779d231acb4487f0 100644 (file)
@@ -1,6 +1,6 @@
 /* Private definitions for the generic associative array implementation.
  *
- * See Documentation/assoc_array.txt for information.
+ * See Documentation/core-api/assoc_array.rst for information.
  *
  * Copyright (C) 2013 Red Hat, Inc. All Rights Reserved.
  * Written by David Howells (dhowells@redhat.com)
index 2baab6f3861d20ec998266dd0d36e30b3f446262..7fbf0539e14a06d240ef14fa6c1f42098a11f5f2 100644 (file)
@@ -84,10 +84,6 @@ struct backlight_properties {
 
 #define BL_CORE_SUSPENDED      (1 << 0)        /* backlight is suspended */
 #define BL_CORE_FBBLANK                (1 << 1)        /* backlight is under an fb blank event */
-#define BL_CORE_DRIVER4                (1 << 28)       /* reserved for driver specific use */
-#define BL_CORE_DRIVER3                (1 << 29)       /* reserved for driver specific use */
-#define BL_CORE_DRIVER2                (1 << 30)       /* reserved for driver specific use */
-#define BL_CORE_DRIVER1                (1 << 31)       /* reserved for driver specific use */
 
 };
 
index 7ecfc88314d835605d72189e7458f362bb6a1632..4903deb0777a746068ecd7f5cc5a472276885cfe 100644 (file)
@@ -628,6 +628,7 @@ int ceph_flags_to_mode(int flags);
                                 CEPH_CAP_XATTR_SHARED)
 #define CEPH_STAT_CAP_INLINE_DATA (CEPH_CAP_FILE_SHARED | \
                                   CEPH_CAP_FILE_RD)
+#define CEPH_STAT_RSTAT CEPH_CAP_FILE_WREXTEND
 
 #define CEPH_CAP_ANY_SHARED (CEPH_CAP_AUTH_SHARED |                    \
                              CEPH_CAP_LINK_SHARED |                    \
index 96bb3228598927c0cb089b5f4fa88da445cd1b26..0d6ee04b4c417c3fcd82c320ce3c7f2a75254d13 100644 (file)
@@ -170,6 +170,7 @@ struct ceph_osd_request {
        u64             r_tid;              /* unique for this client */
        struct rb_node  r_node;
        struct rb_node  r_mc_node;          /* map check */
+       struct work_struct r_complete_work;
        struct ceph_osd *r_osd;
 
        struct ceph_osd_request_target r_t;
@@ -201,7 +202,6 @@ struct ceph_osd_request {
        struct timespec r_mtime;              /* ditto */
        u64 r_data_offset;                    /* ditto */
        bool r_linger;                        /* don't resend on failure */
-       bool r_abort_on_full;                 /* return ENOSPC when full */
 
        /* internal */
        unsigned long r_stamp;                /* jiffies, send or check time */
@@ -347,6 +347,8 @@ struct ceph_osd_client {
        struct rb_root         linger_map_checks;
        atomic_t               num_requests;
        atomic_t               num_homeless;
+       bool                   abort_on_full; /* abort w/ ENOSPC when full */
+       int                    abort_err;
        struct delayed_work    timeout_work;
        struct delayed_work    osds_timeout_work;
 #ifdef CONFIG_DEBUG_FS
@@ -359,6 +361,7 @@ struct ceph_osd_client {
        struct ceph_msgpool     msgpool_op_reply;
 
        struct workqueue_struct *notify_wq;
+       struct workqueue_struct *completion_wq;
 };
 
 static inline bool ceph_osdmap_flag(struct ceph_osd_client *osdc, int flag)
@@ -378,6 +381,7 @@ extern void ceph_osdc_handle_reply(struct ceph_osd_client *osdc,
 extern void ceph_osdc_handle_map(struct ceph_osd_client *osdc,
                                 struct ceph_msg *msg);
 void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb);
+void ceph_osdc_abort_requests(struct ceph_osd_client *osdc, int err);
 
 extern void osd_req_op_init(struct ceph_osd_request *osd_req,
                            unsigned int which, u16 opcode, u32 flags);
@@ -440,7 +444,7 @@ extern void osd_req_op_cls_response_data_pages(struct ceph_osd_request *,
                                        struct page **pages, u64 length,
                                        u32 alignment, bool pages_from_pool,
                                        bool own_pages);
-extern void osd_req_op_cls_init(struct ceph_osd_request *osd_req,
+extern int osd_req_op_cls_init(struct ceph_osd_request *osd_req,
                                        unsigned int which, u16 opcode,
                                        const char *class, const char *method);
 extern int osd_req_op_xattr_init(struct ceph_osd_request *osd_req, unsigned int which,
index e71fb222c7c3640e46426dc5a0de96d6814d96df..5675b1f09bc5c2fa813f4e8e714a791f2666ab1c 100644 (file)
@@ -279,10 +279,10 @@ bool ceph_osds_changed(const struct ceph_osds *old_acting,
                       const struct ceph_osds *new_acting,
                       bool any_change);
 
-int __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
-                               const struct ceph_object_id *oid,
-                               const struct ceph_object_locator *oloc,
-                               struct ceph_pg *raw_pgid);
+void __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
+                                const struct ceph_object_id *oid,
+                                const struct ceph_object_locator *oloc,
+                                struct ceph_pg *raw_pgid);
 int ceph_object_locator_to_pg(struct ceph_osdmap *osdmap,
                              const struct ceph_object_id *oid,
                              const struct ceph_object_locator *oloc,
index 7cf262a421c3f4105424b4d7a12116108b6b9251..b3233e8202f9c2cec17556e71213eb1bc025ca23 100644 (file)
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * See Documentation/circular-buffers.txt for more information.
+ * See Documentation/core-api/circular-buffers.rst for more information.
  */
 
 #ifndef _LINUX_CIRC_BUF_H
index 7207de8c4e9aea1e653f804e29cbe6ed7f989aca..5c91108846db20894ab70dafe43b7922fe08fb1f 100644 (file)
@@ -207,9 +207,9 @@ struct iattr {
        kuid_t          ia_uid;
        kgid_t          ia_gid;
        loff_t          ia_size;
-       struct timespec ia_atime;
-       struct timespec ia_mtime;
-       struct timespec ia_ctime;
+       struct timespec64 ia_atime;
+       struct timespec64 ia_mtime;
+       struct timespec64 ia_ctime;
 
        /*
         * Not an attribute, but an auxiliary info for filesystems wanting to
@@ -604,9 +604,9 @@ struct inode {
        };
        dev_t                   i_rdev;
        loff_t                  i_size;
-       struct timespec         i_atime;
-       struct timespec         i_mtime;
-       struct timespec         i_ctime;
+       struct timespec64       i_atime;
+       struct timespec64       i_mtime;
+       struct timespec64       i_ctime;
        spinlock_t              i_lock; /* i_blocks, i_bytes, maybe i_size */
        unsigned short          i_bytes;
        unsigned int            i_blkbits;
@@ -1093,7 +1093,7 @@ extern int vfs_lock_file(struct file *, unsigned int, struct file_lock *, struct
 extern int vfs_cancel_lock(struct file *filp, struct file_lock *fl);
 extern int locks_lock_inode_wait(struct inode *inode, struct file_lock *fl);
 extern int __break_lease(struct inode *inode, unsigned int flags, unsigned int type);
-extern void lease_get_mtime(struct inode *, struct timespec *time);
+extern void lease_get_mtime(struct inode *, struct timespec64 *time);
 extern int generic_setlease(struct file *, long, struct file_lock **, void **priv);
 extern int vfs_setlease(struct file *, long, struct file_lock **, void **);
 extern int lease_modify(struct file_lock *, int, struct list_head *);
@@ -1208,7 +1208,8 @@ static inline int __break_lease(struct inode *inode, unsigned int mode, unsigned
        return 0;
 }
 
-static inline void lease_get_mtime(struct inode *inode, struct timespec *time)
+static inline void lease_get_mtime(struct inode *inode,
+                                  struct timespec64 *time)
 {
        return;
 }
@@ -1478,7 +1479,8 @@ static inline void i_gid_write(struct inode *inode, gid_t gid)
        inode->i_gid = make_kgid(inode->i_sb->s_user_ns, gid);
 }
 
-extern struct timespec current_time(struct inode *inode);
+extern struct timespec64 timespec64_trunc(struct timespec64 t, unsigned gran);
+extern struct timespec64 current_time(struct inode *inode);
 
 /*
  * Snapshotting support.
@@ -1773,7 +1775,7 @@ struct inode_operations {
        ssize_t (*listxattr) (struct dentry *, char *, size_t);
        int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
                      u64 len);
-       int (*update_time)(struct inode *, struct timespec *, int);
+       int (*update_time)(struct inode *, struct timespec64 *, int);
        int (*atomic_open)(struct inode *, struct dentry *,
                           struct file *, unsigned open_flag,
                           umode_t create_mode, int *opened);
@@ -2217,7 +2219,7 @@ extern int current_umask(void);
 
 extern void ihold(struct inode * inode);
 extern void iput(struct inode *);
-extern int generic_update_time(struct inode *, struct timespec *, int);
+extern int generic_update_time(struct inode *, struct timespec64 *, int);
 
 /* /sys/fs */
 extern struct kobject *fs_kobj;
index 25b6492de6e532652e47a397c44909fc6f23cff4..ee8b43e4c15a615bbddc93e8869668eba100f1b9 100644 (file)
@@ -25,6 +25,10 @@ static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
 }
 
 /* crypto.c */
+static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work)
+{
+}
+
 static inline struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *inode,
                                                  gfp_t gfp_flags)
 {
@@ -150,10 +154,13 @@ static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
 }
 
 /* bio.c */
-static inline void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *ctx,
-                                            struct bio *bio)
+static inline void fscrypt_decrypt_bio(struct bio *bio)
+{
+}
+
+static inline void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,
+                                              struct bio *bio)
 {
-       return;
 }
 
 static inline void fscrypt_pullback_bio_page(struct page **page, bool restore)
index 5080cb1bec4c73172ba9f801a1aa5887e09ea9d2..6456c6b2005f498a56c2b60cd510e15a823ddb6c 100644 (file)
@@ -59,6 +59,7 @@ static inline bool fscrypt_dummy_context_enabled(struct inode *inode)
 }
 
 /* crypto.c */
+extern void fscrypt_enqueue_decrypt_work(struct work_struct *);
 extern struct fscrypt_ctx *fscrypt_get_ctx(const struct inode *, gfp_t);
 extern void fscrypt_release_ctx(struct fscrypt_ctx *);
 extern struct page *fscrypt_encrypt_page(const struct inode *, struct page *,
@@ -174,7 +175,9 @@ static inline bool fscrypt_match_name(const struct fscrypt_name *fname,
 }
 
 /* bio.c */
-extern void fscrypt_decrypt_bio_pages(struct fscrypt_ctx *, struct bio *);
+extern void fscrypt_decrypt_bio(struct bio *);
+extern void fscrypt_enqueue_decrypt_bio(struct fscrypt_ctx *ctx,
+                                       struct bio *bio);
 extern void fscrypt_pullback_bio_page(struct page **, bool);
 extern int fscrypt_zeroout_range(const struct inode *, pgoff_t, sector_t,
                                 unsigned int);
index e64c0294f50bf82dd50d447e37a5c77f86eabc26..b38964a7a521e5d204db057a4cd3ac09ac97f3e5 100644 (file)
@@ -98,8 +98,6 @@ struct fsnotify_iter_info;
 struct fsnotify_ops {
        int (*handle_event)(struct fsnotify_group *group,
                            struct inode *inode,
-                           struct fsnotify_mark *inode_mark,
-                           struct fsnotify_mark *vfsmount_mark,
                            u32 mask, const void *data, int data_type,
                            const unsigned char *file_name, u32 cookie,
                            struct fsnotify_iter_info *iter_info);
@@ -201,6 +199,57 @@ struct fsnotify_group {
 #define FSNOTIFY_EVENT_PATH    1
 #define FSNOTIFY_EVENT_INODE   2
 
+enum fsnotify_obj_type {
+       FSNOTIFY_OBJ_TYPE_INODE,
+       FSNOTIFY_OBJ_TYPE_VFSMOUNT,
+       FSNOTIFY_OBJ_TYPE_COUNT,
+       FSNOTIFY_OBJ_TYPE_DETACHED = FSNOTIFY_OBJ_TYPE_COUNT
+};
+
+#define FSNOTIFY_OBJ_TYPE_INODE_FL     (1U << FSNOTIFY_OBJ_TYPE_INODE)
+#define FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL  (1U << FSNOTIFY_OBJ_TYPE_VFSMOUNT)
+#define FSNOTIFY_OBJ_ALL_TYPES_MASK    ((1U << FSNOTIFY_OBJ_TYPE_COUNT) - 1)
+
+struct fsnotify_iter_info {
+       struct fsnotify_mark *marks[FSNOTIFY_OBJ_TYPE_COUNT];
+       unsigned int report_mask;
+       int srcu_idx;
+};
+
+static inline bool fsnotify_iter_should_report_type(
+               struct fsnotify_iter_info *iter_info, int type)
+{
+       return (iter_info->report_mask & (1U << type));
+}
+
+static inline void fsnotify_iter_set_report_type(
+               struct fsnotify_iter_info *iter_info, int type)
+{
+       iter_info->report_mask |= (1U << type);
+}
+
+static inline void fsnotify_iter_set_report_type_mark(
+               struct fsnotify_iter_info *iter_info, int type,
+               struct fsnotify_mark *mark)
+{
+       iter_info->marks[type] = mark;
+       iter_info->report_mask |= (1U << type);
+}
+
+#define FSNOTIFY_ITER_FUNCS(name, NAME) \
+static inline struct fsnotify_mark *fsnotify_iter_##name##_mark( \
+               struct fsnotify_iter_info *iter_info) \
+{ \
+       return (iter_info->report_mask & FSNOTIFY_OBJ_TYPE_##NAME##_FL) ? \
+               iter_info->marks[FSNOTIFY_OBJ_TYPE_##NAME] : NULL; \
+}
+
+FSNOTIFY_ITER_FUNCS(inode, INODE)
+FSNOTIFY_ITER_FUNCS(vfsmount, VFSMOUNT)
+
+#define fsnotify_foreach_obj_type(type) \
+       for (type = 0; type < FSNOTIFY_OBJ_TYPE_COUNT; type++)
+
 /*
  * Inode / vfsmount point to this structure which tracks all marks attached to
  * the inode / vfsmount. The reference to inode / vfsmount is held by this
@@ -209,11 +258,7 @@ struct fsnotify_group {
  */
 struct fsnotify_mark_connector {
        spinlock_t lock;
-#define FSNOTIFY_OBJ_TYPE_INODE                0x01
-#define FSNOTIFY_OBJ_TYPE_VFSMOUNT     0x02
-#define FSNOTIFY_OBJ_ALL_TYPES         (FSNOTIFY_OBJ_TYPE_INODE | \
-                                        FSNOTIFY_OBJ_TYPE_VFSMOUNT)
-       unsigned int flags;     /* Type of object [lock] */
+       unsigned int type;      /* Type of object [lock] */
        union { /* Object pointer [lock] */
                struct inode *inode;
                struct vfsmount *mnt;
@@ -356,7 +401,21 @@ extern struct fsnotify_mark *fsnotify_find_mark(
 extern int fsnotify_add_mark(struct fsnotify_mark *mark, struct inode *inode,
                             struct vfsmount *mnt, int allow_dups);
 extern int fsnotify_add_mark_locked(struct fsnotify_mark *mark,
-                                   struct inode *inode, struct vfsmount *mnt, int allow_dups);
+                                   struct inode *inode, struct vfsmount *mnt,
+                                   int allow_dups);
+/* attach the mark to the inode */
+static inline int fsnotify_add_inode_mark(struct fsnotify_mark *mark,
+                                         struct inode *inode,
+                                         int allow_dups)
+{
+       return fsnotify_add_mark(mark, inode, NULL, allow_dups);
+}
+static inline int fsnotify_add_inode_mark_locked(struct fsnotify_mark *mark,
+                                                struct inode *inode,
+                                                int allow_dups)
+{
+       return fsnotify_add_mark_locked(mark, inode, NULL, allow_dups);
+}
 /* given a group and a mark, flag mark to be freed when all references are dropped */
 extern void fsnotify_destroy_mark(struct fsnotify_mark *mark,
                                  struct fsnotify_group *group);
@@ -369,12 +428,12 @@ extern void fsnotify_clear_marks_by_group(struct fsnotify_group *group, unsigned
 /* run all the marks in a group, and clear all of the vfsmount marks */
 static inline void fsnotify_clear_vfsmount_marks_by_group(struct fsnotify_group *group)
 {
-       fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_VFSMOUNT);
+       fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_VFSMOUNT_FL);
 }
 /* run all the marks in a group, and clear all of the inode marks */
 static inline void fsnotify_clear_inode_marks_by_group(struct fsnotify_group *group)
 {
-       fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_INODE);
+       fsnotify_clear_marks_by_group(group, FSNOTIFY_OBJ_TYPE_INODE_FL);
 }
 extern void fsnotify_get_mark(struct fsnotify_mark *mark);
 extern void fsnotify_put_mark(struct fsnotify_mark *mark);
index 9c3c9a319e48b439f6d7013bb444ee20aeece52a..8154f4920fcb9de96a24ec7b85d9b92f56968122 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Ftrace header.  For implementation details beyond the random comments
- * scattered below, see: Documentation/trace/ftrace-design.txt
+ * scattered below, see: Documentation/trace/ftrace-design.rst
  */
 
 #ifndef _LINUX_FTRACE_H
index 859d673d98c80239715df9ef56c32672647e47a1..57537e67b468c82d1c20a5150c0cf1e1f64f52ca 100644 (file)
@@ -1,18 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  * Hardware spinlock public header
  *
  * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com
  *
  * Contact: Ohad Ben-Cohen <ohad@wizery.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.
  */
 
 #ifndef __LINUX_HWSPINLOCK_H
@@ -24,6 +16,7 @@
 /* hwspinlock mode argument */
 #define HWLOCK_IRQSTATE        0x01    /* Disable interrupts, save state */
 #define HWLOCK_IRQ     0x02    /* Disable interrupts, don't save state */
+#define HWLOCK_RAW     0x03
 
 struct device;
 struct device_node;
@@ -175,6 +168,25 @@ static inline int hwspin_trylock_irq(struct hwspinlock *hwlock)
        return __hwspin_trylock(hwlock, HWLOCK_IRQ, NULL);
 }
 
+/**
+ * hwspin_trylock_raw() - attempt to lock a specific hwspinlock
+ * @hwlock: an hwspinlock which we want to trylock
+ *
+ * This function attempts to lock an hwspinlock, and will immediately fail
+ * if the hwspinlock is already taken.
+ *
+ * Caution: User must protect the routine of getting hardware lock with mutex
+ * or spinlock to avoid dead-lock, that will let user can do some time-consuming
+ * or sleepable operations under the hardware lock.
+ *
+ * Returns 0 if we successfully locked the hwspinlock, -EBUSY if
+ * the hwspinlock was already taken, and -EINVAL if @hwlock is invalid.
+ */
+static inline int hwspin_trylock_raw(struct hwspinlock *hwlock)
+{
+       return __hwspin_trylock(hwlock, HWLOCK_RAW, NULL);
+}
+
 /**
  * hwspin_trylock() - attempt to lock a specific hwspinlock
  * @hwlock: an hwspinlock which we want to trylock
@@ -242,6 +254,29 @@ int hwspin_lock_timeout_irq(struct hwspinlock *hwlock, unsigned int to)
        return __hwspin_lock_timeout(hwlock, to, HWLOCK_IRQ, NULL);
 }
 
+/**
+ * hwspin_lock_timeout_raw() - lock an hwspinlock with timeout limit
+ * @hwlock: the hwspinlock to be locked
+ * @to: timeout value in msecs
+ *
+ * This function locks the underlying @hwlock. If the @hwlock
+ * is already taken, the function will busy loop waiting for it to
+ * be released, but give up when @timeout msecs have elapsed.
+ *
+ * Caution: User must protect the routine of getting hardware lock with mutex
+ * or spinlock to avoid dead-lock, that will let user can do some time-consuming
+ * or sleepable operations under the hardware lock.
+ *
+ * Returns 0 when the @hwlock was successfully taken, and an appropriate
+ * error code otherwise (most notably an -ETIMEDOUT if the @hwlock is still
+ * busy after @timeout msecs). The function will never sleep.
+ */
+static inline
+int hwspin_lock_timeout_raw(struct hwspinlock *hwlock, unsigned int to)
+{
+       return __hwspin_lock_timeout(hwlock, to, HWLOCK_RAW, NULL);
+}
+
 /**
  * hwspin_lock_timeout() - lock an hwspinlock with timeout limit
  * @hwlock: the hwspinlock to be locked
@@ -301,6 +336,21 @@ static inline void hwspin_unlock_irq(struct hwspinlock *hwlock)
        __hwspin_unlock(hwlock, HWLOCK_IRQ, NULL);
 }
 
+/**
+ * hwspin_unlock_raw() - unlock hwspinlock
+ * @hwlock: a previously-acquired hwspinlock which we want to unlock
+ *
+ * This function will unlock a specific hwspinlock.
+ *
+ * @hwlock must be already locked (e.g. by hwspin_trylock()) before calling
+ * this function: it is a bug to call unlock on a @hwlock that is already
+ * unlocked.
+ */
+static inline void hwspin_unlock_raw(struct hwspinlock *hwlock)
+{
+       __hwspin_unlock(hwlock, HWLOCK_RAW, NULL);
+}
+
 /**
  * hwspin_unlock() - unlock hwspinlock
  * @hwlock: a previously-acquired hwspinlock which we want to unlock
diff --git a/include/linux/i2c-pnx.h b/include/linux/i2c-pnx.h
deleted file mode 100644 (file)
index 5388326..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Header file for I2C support on PNX010x/4008.
- *
- * Author: Dennis Kovalev <dkovalev@ru.mvista.com>
- *
- * 2004-2006 (c) MontaVista Software, Inc. This file is licensed under
- * the terms of the GNU General Public License version 2. This program
- * is licensed "as is" without any warranty of any kind, whether express
- * or implied.
- */
-
-#ifndef __I2C_PNX_H__
-#define __I2C_PNX_H__
-
-struct platform_device;
-struct clk;
-
-struct i2c_pnx_mif {
-       int                     ret;            /* Return value */
-       int                     mode;           /* Interface mode */
-       struct completion       complete;       /* I/O completion */
-       struct timer_list       timer;          /* Timeout */
-       u8 *                    buf;            /* Data buffer */
-       int                     len;            /* Length of data buffer */
-       int                     order;          /* RX Bytes to order via TX */
-};
-
-struct i2c_pnx_algo_data {
-       void __iomem            *ioaddr;
-       struct i2c_pnx_mif      mif;
-       int                     last;
-       struct clk              *clk;
-       struct i2c_adapter      adapter;
-       int                     irq;
-       u32                     timeout;
-};
-
-#endif /* __I2C_PNX_H__ */
index 44ad14e016b556f66e4c92adddecd45199794519..254cd34eeae22a0b4a961a376b39bc74031aebb1 100644 (file)
@@ -394,7 +394,6 @@ static inline bool i2c_detect_slave_mode(struct device *dev) { return false; }
  * @addr: stored in i2c_client.addr
  * @dev_name: Overrides the default <busnr>-<addr> dev_name if set
  * @platform_data: stored in i2c_client.dev.platform_data
- * @archdata: copied into i2c_client.dev.archdata
  * @of_node: pointer to OpenFirmware device node
  * @fwnode: device node supplied by the platform firmware
  * @properties: additional device properties for the device
@@ -419,7 +418,6 @@ struct i2c_board_info {
        unsigned short  addr;
        const char      *dev_name;
        void            *platform_data;
-       struct dev_archdata     *archdata;
        struct device_node *of_node;
        struct fwnode_handle *fwnode;
        const struct property_entry *properties;
@@ -903,6 +901,9 @@ extern const struct of_device_id
 *i2c_of_match_device(const struct of_device_id *matches,
                     struct i2c_client *client);
 
+int of_i2c_get_board_info(struct device *dev, struct device_node *node,
+                         struct i2c_board_info *info);
+
 #else
 
 static inline struct i2c_client *of_find_i2c_device_by_node(struct device_node *node)
@@ -927,6 +928,13 @@ static inline const struct of_device_id
        return NULL;
 }
 
+static inline int of_i2c_get_board_info(struct device *dev,
+                                       struct device_node *node,
+                                       struct i2c_board_info *info)
+{
+       return -ENOTSUPP;
+}
+
 #endif /* CONFIG_OF */
 
 #if IS_ENABLED(CONFIG_ACPI)
index 3ecf6f5e3a5f01eb81a67d7456868d43e1fd64ce..b76a1807028ddcdd41df38064a174d36d8748646 100644 (file)
@@ -22,13 +22,27 @@ enum kcov_mode {
        KCOV_MODE_TRACE_CMP = 3,
 };
 
+#define KCOV_IN_CTXSW  (1 << 30)
+
 void kcov_task_init(struct task_struct *t);
 void kcov_task_exit(struct task_struct *t);
 
+#define kcov_prepare_switch(t)                 \
+do {                                           \
+       (t)->kcov_mode |= KCOV_IN_CTXSW;        \
+} while (0)
+
+#define kcov_finish_switch(t)                  \
+do {                                           \
+       (t)->kcov_mode &= ~KCOV_IN_CTXSW;       \
+} while (0)
+
 #else
 
 static inline void kcov_task_init(struct task_struct *t) {}
 static inline void kcov_task_exit(struct task_struct *t) {}
+static inline void kcov_prepare_switch(struct task_struct *t) {}
+static inline void kcov_finish_switch(struct task_struct *t) {}
 
 #endif /* CONFIG_KCOV */
 #endif /* _LINUX_KCOV_H */
index 6d6e79c59e68fa7fd5387f48814341082d6b8526..4ee7bc548a833c1f5fa16186205dfdbe0557f795 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/preempt.h>
 #include <linux/msi.h>
 #include <linux/slab.h>
+#include <linux/vmalloc.h>
 #include <linux/rcupdate.h>
 #include <linux/ratelimit.h>
 #include <linux/err.h>
@@ -730,13 +731,16 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu);
 
 void kvm_flush_remote_tlbs(struct kvm *kvm);
 void kvm_reload_remote_mmus(struct kvm *kvm);
+
+bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
+                                unsigned long *vcpu_bitmap, cpumask_var_t tmp);
 bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req);
 
 long kvm_arch_dev_ioctl(struct file *filp,
                        unsigned int ioctl, unsigned long arg);
 long kvm_arch_vcpu_ioctl(struct file *filp,
                         unsigned int ioctl, unsigned long arg);
-int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf);
+vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf);
 
 int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext);
 
@@ -808,6 +812,10 @@ bool kvm_arch_vcpu_in_kernel(struct kvm_vcpu *vcpu);
 int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu);
 
 #ifndef __KVM_HAVE_ARCH_VM_ALLOC
+/*
+ * All architectures that want to use vzalloc currently also
+ * need their own kvm_arch_alloc_vm implementation.
+ */
 static inline struct kvm *kvm_arch_alloc_vm(void)
 {
        return kzalloc(sizeof(struct kvm), GFP_KERNEL);
@@ -1270,4 +1278,13 @@ static inline long kvm_arch_vcpu_async_ioctl(struct file *filp,
 void kvm_arch_mmu_notifier_invalidate_range(struct kvm *kvm,
                unsigned long start, unsigned long end);
 
+#ifdef CONFIG_HAVE_KVM_VCPU_RUN_PID_CHANGE
+int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu);
+#else
+static inline int kvm_arch_vcpu_run_pid_change(struct kvm_vcpu *vcpu)
+{
+       return 0;
+}
+#endif /* CONFIG_HAVE_KVM_VCPU_RUN_PID_CHANGE */
+
 #endif
index f68db9e450eb3f7ed00e30855a3b183c42d41b7f..d7618c41f74c7e5eb5cb707a5ec2b9da81ad451b 100644 (file)
 
 #ifndef cond_syscall
 #define cond_syscall(x)        asm(                            \
-       ".weak " VMLINUX_SYMBOL_STR(x) "\n\t"           \
-       ".set  " VMLINUX_SYMBOL_STR(x) ","              \
-                VMLINUX_SYMBOL_STR(sys_ni_syscall))
+       ".weak " __stringify(x) "\n\t"                  \
+       ".set  " __stringify(x) ","                     \
+                __stringify(sys_ni_syscall))
 #endif
 
 #ifndef SYSCALL_ALIAS
 #define SYSCALL_ALIAS(alias, name) asm(                        \
-       ".globl " VMLINUX_SYMBOL_STR(alias) "\n\t"      \
-       ".set   " VMLINUX_SYMBOL_STR(alias) ","         \
-                 VMLINUX_SYMBOL_STR(name))
+       ".globl " __stringify(alias) "\n\t"             \
+       ".set   " __stringify(alias) ","                \
+                 __stringify(name))
 #endif
 
 #define __page_aligned_data    __section(.data..page_aligned) __aligned(PAGE_SIZE)
index 4f52ec7557254e7a1f2c90dfe4edd63efa6bf8f6..6c6fb116e9258859951b5e96ee6d3da33a274cc4 100644 (file)
@@ -53,6 +53,7 @@ enum memcg_memory_event {
        MEMCG_HIGH,
        MEMCG_MAX,
        MEMCG_OOM,
+       MEMCG_OOM_KILL,
        MEMCG_SWAP_MAX,
        MEMCG_SWAP_FAIL,
        MEMCG_NR_MEMORY_EVENTS,
@@ -720,11 +721,8 @@ static inline void count_memcg_event_mm(struct mm_struct *mm,
 
        rcu_read_lock();
        memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
-       if (likely(memcg)) {
+       if (likely(memcg))
                count_memcg_events(memcg, idx, 1);
-               if (idx == OOM_KILL)
-                       cgroup_file_notify(&memcg->events_file);
-       }
        rcu_read_unlock();
 }
 
@@ -735,6 +733,21 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg,
        cgroup_file_notify(&memcg->events_file);
 }
 
+static inline void memcg_memory_event_mm(struct mm_struct *mm,
+                                        enum memcg_memory_event event)
+{
+       struct mem_cgroup *memcg;
+
+       if (mem_cgroup_disabled())
+               return;
+
+       rcu_read_lock();
+       memcg = mem_cgroup_from_task(rcu_dereference(mm->owner));
+       if (likely(memcg))
+               memcg_memory_event(memcg, event);
+       rcu_read_unlock();
+}
+
 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 void mem_cgroup_split_huge_fixup(struct page *head);
 #endif
@@ -756,6 +769,11 @@ static inline void memcg_memory_event(struct mem_cgroup *memcg,
 {
 }
 
+static inline void memcg_memory_event_mm(struct mm_struct *mm,
+                                        enum memcg_memory_event event)
+{
+}
+
 static inline enum mem_cgroup_protection mem_cgroup_protected(
        struct mem_cgroup *root, struct mem_cgroup *memcg)
 {
index f72dc53848d705b3d09d57d9df466fb796e51669..0013075d4cda0615c9f0a254c786d35ebb0eec79 100644 (file)
@@ -56,6 +56,7 @@
 #define ARIZONA_MAX_PDM_SPK 2
 
 struct regulator_init_data;
+struct gpio_desc;
 
 struct arizona_micbias {
        int mV;                    /** Regulated voltage */
@@ -77,7 +78,7 @@ struct arizona_micd_range {
 };
 
 struct arizona_pdata {
-       int reset;      /** GPIO controlling /RESET, if any */
+       struct gpio_desc *reset;      /** GPIO controlling /RESET, if any */
 
        /** Regulator configuration for MICVDD */
        struct arizona_micsupp_pdata micvdd;
index 34cc85864be5e95f4e9442ed48f45a35fb142b3f..ddd0b953323b1051f79635dfa32b7adc210f72fb 100644 (file)
@@ -108,9 +108,9 @@ struct as3711_regulator_pdata {
 };
 
 struct as3711_bl_pdata {
-       const char *su1_fb;
+       bool su1_fb;
        int su1_max_uA;
-       const char *su2_fb;
+       bool su2_fb;
        int su2_max_uA;
        enum as3711_su2_feedback su2_feedback;
        enum as3711_su2_fbprot su2_fbprot;
index 82bf7747b312be46f834125d52cdd5fd0109ca84..517e60eecbcbea92e6f81c9fb7615b2a9a387fcb 100644 (file)
@@ -592,11 +592,11 @@ enum axp806_irqs {
        AXP806_IRQ_DCDCC_V_LOW,
        AXP806_IRQ_DCDCD_V_LOW,
        AXP806_IRQ_DCDCE_V_LOW,
-       AXP806_IRQ_PWROK_LONG,
-       AXP806_IRQ_PWROK_SHORT,
+       AXP806_IRQ_POK_LONG,
+       AXP806_IRQ_POK_SHORT,
        AXP806_IRQ_WAKEUP,
-       AXP806_IRQ_PWROK_FALL,
-       AXP806_IRQ_PWROK_RISE,
+       AXP806_IRQ_POK_FALL,
+       AXP806_IRQ_POK_RISE,
 };
 
 enum axp809_irqs {
@@ -642,7 +642,7 @@ struct axp20x_dev {
        struct regmap_irq_chip_data     *regmap_irqc;
        long                            variant;
        int                             nr_cells;
-       struct mfd_cell                 *cells;
+       const struct mfd_cell           *cells;
        const struct regmap_config      *regmap_cfg;
        const struct regmap_irq_chip    *regmap_irq_chip;
 };
index f09e9cf2e4ab9a85a378c67202e5f4df8e008969..32421dfeb996cb2e8a36fa210bfae968db6bc849 100644 (file)
@@ -329,23 +329,7 @@ extern struct attribute_group cros_ec_vbc_attr_group;
 /* debugfs stuff */
 int cros_ec_debugfs_init(struct cros_ec_dev *ec);
 void cros_ec_debugfs_remove(struct cros_ec_dev *ec);
-
-/* ACPI GPE handler */
-#ifdef CONFIG_ACPI
-
-int cros_ec_acpi_install_gpe_handler(struct device *dev);
-void cros_ec_acpi_remove_gpe_handler(void);
-void cros_ec_acpi_clear_gpe(void);
-
-#else /* CONFIG_ACPI */
-
-static inline int cros_ec_acpi_install_gpe_handler(struct device *dev)
-{
-       return -ENODEV;
-}
-static inline void cros_ec_acpi_remove_gpe_handler(void) {}
-static inline void cros_ec_acpi_clear_gpe(void) {}
-
-#endif /* CONFIG_ACPI */
+void cros_ec_debugfs_suspend(struct cros_ec_dev *ec);
+void cros_ec_debugfs_resume(struct cros_ec_dev *ec);
 
 #endif /* __LINUX_MFD_CROS_EC_H */
index 796fb9794c9eb67cb55902697ae3d3b12621e59a..fe0ce7bc59cfa2948ed9ad15d0f7700af8f93d3a 100644 (file)
@@ -21,6 +21,7 @@ enum rave_sp_command {
        RAVE_SP_CMD_STATUS                      = 0xA0,
        RAVE_SP_CMD_SW_WDT                      = 0xA1,
        RAVE_SP_CMD_PET_WDT                     = 0xA2,
+       RAVE_SP_CMD_SET_BACKLIGHT               = 0xA6,
        RAVE_SP_CMD_RESET                       = 0xA7,
        RAVE_SP_CMD_RESET_REASON                = 0xA8,
 
index 2aadab6f34a12fddbd5b10e77361bbe287f18ed0..067d14655c28b9fb3a88eec21d9282afc38bd244 100644 (file)
@@ -8,6 +8,8 @@
 #define _LINUX_STM32_GPTIMER_H_
 
 #include <linux/clk.h>
+#include <linux/dmaengine.h>
+#include <linux/dma-mapping.h>
 #include <linux/regmap.h>
 
 #define TIM_CR1                0x00    /* Control Register 1      */
@@ -27,6 +29,8 @@
 #define TIM_CCR3       0x3C    /* Capt/Comp Register 3    */
 #define TIM_CCR4       0x40    /* Capt/Comp Register 4    */
 #define TIM_BDTR       0x44    /* Break and Dead-Time Reg */
+#define TIM_DCR                0x48    /* DMA control register    */
+#define TIM_DMAR       0x4C    /* DMA register for transfer */
 
 #define TIM_CR1_CEN    BIT(0)  /* Counter Enable          */
 #define TIM_CR1_DIR    BIT(4)  /* Counter Direction       */
 #define TIM_SMCR_SMS   (BIT(0) | BIT(1) | BIT(2)) /* Slave mode selection */
 #define TIM_SMCR_TS    (BIT(4) | BIT(5) | BIT(6)) /* Trigger selection */
 #define TIM_DIER_UIE   BIT(0)  /* Update interrupt        */
+#define TIM_DIER_UDE   BIT(8)  /* Update DMA request Enable */
+#define TIM_DIER_CC1DE BIT(9)  /* CC1 DMA request Enable  */
+#define TIM_DIER_CC2DE BIT(10) /* CC2 DMA request Enable  */
+#define TIM_DIER_CC3DE BIT(11) /* CC3 DMA request Enable  */
+#define TIM_DIER_CC4DE BIT(12) /* CC4 DMA request Enable  */
+#define TIM_DIER_COMDE BIT(13) /* COM DMA request Enable  */
+#define TIM_DIER_TDE   BIT(14) /* Trigger DMA request Enable */
 #define TIM_SR_UIF     BIT(0)  /* Update interrupt flag   */
 #define TIM_EGR_UG     BIT(0)  /* Update Generation       */
 #define TIM_CCMR_PE    BIT(3)  /* Channel Preload Enable  */
 #define TIM_CCMR_M1    (BIT(6) | BIT(5))  /* Channel PWM Mode 1 */
+#define TIM_CCMR_CC1S          (BIT(0) | BIT(1)) /* Capture/compare 1 sel */
+#define TIM_CCMR_IC1PSC                GENMASK(3, 2)   /* Input capture 1 prescaler */
+#define TIM_CCMR_CC2S          (BIT(8) | BIT(9)) /* Capture/compare 2 sel */
+#define TIM_CCMR_IC2PSC                GENMASK(11, 10) /* Input capture 2 prescaler */
+#define TIM_CCMR_CC1S_TI1      BIT(0)  /* IC1/IC3 selects TI1/TI3 */
+#define TIM_CCMR_CC1S_TI2      BIT(1)  /* IC1/IC3 selects TI2/TI4 */
+#define TIM_CCMR_CC2S_TI2      BIT(8)  /* IC2/IC4 selects TI2/TI4 */
+#define TIM_CCMR_CC2S_TI1      BIT(9)  /* IC2/IC4 selects TI1/TI3 */
 #define TIM_CCER_CC1E  BIT(0)  /* Capt/Comp 1  out Ena    */
 #define TIM_CCER_CC1P  BIT(1)  /* Capt/Comp 1  Polarity   */
 #define TIM_CCER_CC1NE BIT(2)  /* Capt/Comp 1N out Ena    */
 #define TIM_CCER_CC1NP BIT(3)  /* Capt/Comp 1N Polarity   */
 #define TIM_CCER_CC2E  BIT(4)  /* Capt/Comp 2  out Ena    */
+#define TIM_CCER_CC2P  BIT(5)  /* Capt/Comp 2  Polarity   */
 #define TIM_CCER_CC3E  BIT(8)  /* Capt/Comp 3  out Ena    */
+#define TIM_CCER_CC3P  BIT(9)  /* Capt/Comp 3  Polarity   */
 #define TIM_CCER_CC4E  BIT(12) /* Capt/Comp 4  out Ena    */
+#define TIM_CCER_CC4P  BIT(13) /* Capt/Comp 4  Polarity   */
 #define TIM_CCER_CCXE  (BIT(0) | BIT(4) | BIT(8) | BIT(12))
 #define TIM_BDTR_BKE   BIT(12) /* Break input enable      */
 #define TIM_BDTR_BKP   BIT(13) /* Break input polarity    */
 #define TIM_BDTR_BK2F  (BIT(20) | BIT(21) | BIT(22) | BIT(23))
 #define TIM_BDTR_BK2E  BIT(24) /* Break 2 input enable    */
 #define TIM_BDTR_BK2P  BIT(25) /* Break 2 input polarity  */
+#define TIM_DCR_DBA    GENMASK(4, 0)   /* DMA base addr */
+#define TIM_DCR_DBL    GENMASK(12, 8)  /* DMA burst len */
 
 #define MAX_TIM_PSC            0xFFFF
+#define MAX_TIM_ICPSC          0x3
 #define TIM_CR2_MMS_SHIFT      4
 #define TIM_CR2_MMS2_SHIFT     20
 #define TIM_SMCR_TS_SHIFT      4
 #define TIM_BDTR_BKF_SHIFT     16
 #define TIM_BDTR_BK2F_SHIFT    20
 
+enum stm32_timers_dmas {
+       STM32_TIMERS_DMA_CH1,
+       STM32_TIMERS_DMA_CH2,
+       STM32_TIMERS_DMA_CH3,
+       STM32_TIMERS_DMA_CH4,
+       STM32_TIMERS_DMA_UP,
+       STM32_TIMERS_DMA_TRIG,
+       STM32_TIMERS_DMA_COM,
+       STM32_TIMERS_MAX_DMAS,
+};
+
+/**
+ * struct stm32_timers_dma - STM32 timer DMA handling.
+ * @completion:                end of DMA transfer completion
+ * @phys_base:         control registers physical base address
+ * @lock:              protect DMA access
+ * @chan:              DMA channel in use
+ * @chans:             DMA channels available for this timer instance
+ */
+struct stm32_timers_dma {
+       struct completion completion;
+       phys_addr_t phys_base;
+       struct mutex lock;
+       struct dma_chan *chan;
+       struct dma_chan *chans[STM32_TIMERS_MAX_DMAS];
+};
+
 struct stm32_timers {
        struct clk *clk;
        struct regmap *regmap;
        u32 max_arr;
+       struct stm32_timers_dma dma; /* Only to be used by the parent */
 };
+
+#if IS_REACHABLE(CONFIG_MFD_STM32_TIMERS)
+int stm32_timers_dma_burst_read(struct device *dev, u32 *buf,
+                               enum stm32_timers_dmas id, u32 reg,
+                               unsigned int num_reg, unsigned int bursts,
+                               unsigned long tmo_ms);
+#else
+static inline int stm32_timers_dma_burst_read(struct device *dev, u32 *buf,
+                                             enum stm32_timers_dmas id,
+                                             u32 reg,
+                                             unsigned int num_reg,
+                                             unsigned int bursts,
+                                             unsigned long tmo_ms)
+{
+       return -ENODEV;
+}
+#endif
 #endif
diff --git a/include/linux/mfd/syscon/exynos4-pmu.h b/include/linux/mfd/syscon/exynos4-pmu.h
deleted file mode 100644 (file)
index 278b1b1..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2015 Samsung Electronics Co., Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _LINUX_MFD_SYSCON_PMU_EXYNOS4_H_
-#define _LINUX_MFD_SYSCON_PMU_EXYNOS4_H_
-
-/* Exynos4 PMU register definitions */
-
-/* MIPI_PHYn_CONTROL register offset: n = 0..1 */
-#define EXYNOS4_MIPI_PHY_CONTROL(n)    (0x710 + (n) * 4)
-#define EXYNOS4_MIPI_PHY_ENABLE                (1 << 0)
-#define EXYNOS4_MIPI_PHY_SRESETN       (1 << 1)
-#define EXYNOS4_MIPI_PHY_MRESETN       (1 << 2)
-#define EXYNOS4_MIPI_PHY_RESET_MASK    (3 << 1)
-
-#endif /* _LINUX_MFD_SYSCON_PMU_EXYNOS4_H_ */
diff --git a/include/linux/mfd/syscon/exynos5-pmu.h b/include/linux/mfd/syscon/exynos5-pmu.h
deleted file mode 100644 (file)
index b4942a3..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Exynos5 SoC series Power Management Unit (PMU) register offsets
- * and bit definitions.
- *
- * Copyright (C) 2014 Samsung Electronics Co., Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _LINUX_MFD_SYSCON_PMU_EXYNOS5_H_
-#define _LINUX_MFD_SYSCON_PMU_EXYNOS5_H_
-
-#define EXYNOS5_PHY_ENABLE                     BIT(0)
-#define EXYNOS5_MIPI_PHY_S_RESETN              BIT(1)
-#define EXYNOS5_MIPI_PHY_M_RESETN              BIT(2)
-
-#endif /* _LINUX_MFD_SYSCON_PMU_EXYNOS5_H_ */
index f069c518c0ed64346c7abf2f8bc534ce5acba60e..c204d9a79436f324523f8b3d21c65fce37bc359b 100644 (file)
@@ -205,10 +205,10 @@ enum tps65218_regulator_id {
        TPS65218_DCDC_4,
        TPS65218_DCDC_5,
        TPS65218_DCDC_6,
-       /* LS's */
-       TPS65218_LS_3,
        /* LDOs */
        TPS65218_LDO_1,
+       /* LS's */
+       TPS65218_LS_3,
 };
 
 #define TPS65218_MAX_REG_ID            TPS65218_LDO_1
index 44f9d9f647ed1b1c15a1d4b3226ed841be37d1c3..ffe81127d91cbc797884d26b168aecd007b83423 100644 (file)
@@ -1,17 +1,6 @@
-/*
- * Copyright (c) 2017 Intel Corporation
- *
- * Functions to access TPS68470 power management chip.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation version 2.
- *
- * This program is distributed "as is" WITHOUT ANY WARRANTY of any
- * kind, whether express or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (C) 2017 Intel Corporation */
+/* Functions to access TPS68470 power management chip. */
 
 #ifndef __LINUX_MFD_TPS68470_H
 #define __LINUX_MFD_TPS68470_H
index 0e493884e6e1bb36a0af2f95015da6605fc85621..a0fbb9ffe3805276a16c485564de77047898a18e 100644 (file)
@@ -575,6 +575,11 @@ static inline void *kvmalloc_array(size_t n, size_t size, gfp_t flags)
        return kvmalloc(bytes, flags);
 }
 
+static inline void *kvcalloc(size_t n, size_t size, gfp_t flags)
+{
+       return kvmalloc_array(n, size, flags | __GFP_ZERO);
+}
+
 extern void kvfree(const void *addr);
 
 static inline atomic_t *compound_mapcount_ptr(struct page *page)
index a982bb7cd4806f887811b4928e1154f654cd0474..a78606e8e3df7c155410da7a366490354fb9dcb6 100644 (file)
@@ -81,6 +81,7 @@ extern void done_path_create(struct path *, struct dentry *);
 extern struct dentry *kern_path_locked(const char *, struct path *);
 extern int kern_path_mountpoint(int, const char *, struct path *, unsigned int);
 
+extern struct dentry *try_lookup_one_len(const char *, struct dentry *, int);
 extern struct dentry *lookup_one_len(const char *, struct dentry *, int);
 extern struct dentry *lookup_one_len_unlocked(const char *, struct dentry *, int);
 
index 04551af2ff2309345cfae37a718cdfe4d25e1c8e..dd2052f0efb7742f881cdcf334edc570c7d4d790 100644 (file)
@@ -345,7 +345,7 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)
 
        rcu_read_lock();
        nat_hook = rcu_dereference(nf_nat_hook);
-       if (nat_hook->decode_session)
+       if (nat_hook && nat_hook->decode_session)
                nat_hook->decode_session(skb, fl);
        rcu_read_unlock();
 #endif
index bfb3531fd88a4f7811e6ef9fffbaff672dfa6c53..8ce271e187b62f034e6b49140f81e5a8b0d90119 100644 (file)
@@ -23,6 +23,9 @@
 /* Set is defined with timeout support: timeout value may be 0 */
 #define IPSET_NO_TIMEOUT       UINT_MAX
 
+/* Max timeout value, see msecs_to_jiffies() in jiffies.h */
+#define IPSET_MAX_TIMEOUT      (UINT_MAX >> 1)/MSEC_PER_SEC
+
 #define ip_set_adt_opt_timeout(opt, set)       \
 ((opt)->ext.timeout != IPSET_NO_TIMEOUT ? (opt)->ext.timeout : (set)->timeout)
 
@@ -32,11 +35,10 @@ ip_set_timeout_uget(struct nlattr *tb)
        unsigned int timeout = ip_set_get_h32(tb);
 
        /* Normalize to fit into jiffies */
-       if (timeout > UINT_MAX/MSEC_PER_SEC)
-               timeout = UINT_MAX/MSEC_PER_SEC;
+       if (timeout > IPSET_MAX_TIMEOUT)
+               timeout = IPSET_MAX_TIMEOUT;
 
-       /* Userspace supplied TIMEOUT parameter: adjust crazy size */
-       return timeout == IPSET_NO_TIMEOUT ? IPSET_NO_TIMEOUT - 1 : timeout;
+       return timeout;
 }
 
 static inline bool
@@ -65,8 +67,14 @@ ip_set_timeout_set(unsigned long *timeout, u32 value)
 static inline u32
 ip_set_timeout_get(const unsigned long *timeout)
 {
-       return *timeout == IPSET_ELEM_PERMANENT ? 0 :
-               jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
+       u32 t;
+
+       if (*timeout == IPSET_ELEM_PERMANENT)
+               return 0;
+
+       t = jiffies_to_msecs(*timeout - jiffies)/MSEC_PER_SEC;
+       /* Zero value in userspace means no timeout */
+       return t == 0 ? 1 : t;
 }
 
 #endif /* __KERNEL__ */
index 4e735be53e704a56a33f8576b75023dafd60f158..74ae3e1d19a04a8e3e1fbaa24dc64aa152c75f2d 100644 (file)
@@ -28,6 +28,7 @@ struct nfs41_impl_id;
 struct nfs_client {
        refcount_t              cl_count;
        atomic_t                cl_mds_count;
+       seqcount_t              cl_callback_count;
        int                     cl_cons_state;  /* current construction state (-ve: init error) */
 #define NFS_CS_READY           0               /* ready to be used */
 #define NFS_CS_INITING         1               /* busy initialising */
@@ -235,6 +236,7 @@ struct nfs_server {
 #define NFS_CAP_ACLS           (1U << 3)
 #define NFS_CAP_ATOMIC_OPEN    (1U << 4)
 /* #define NFS_CAP_CHANGE_ATTR (1U << 5) */
+#define NFS_CAP_LGOPEN         (1U << 5)
 #define NFS_CAP_FILEID         (1U << 6)
 #define NFS_CAP_MODE           (1U << 7)
 #define NFS_CAP_NLINK          (1U << 8)
index 34d28564ecf37e59f1b3d6a8a370ee8257c3e0a2..9dee3c23895d82fae05025961fe83d15b23d45b7 100644 (file)
@@ -259,6 +259,7 @@ struct nfs4_layoutget_args {
 
 struct nfs4_layoutget_res {
        struct nfs4_sequence_res seq_res;
+       int status;
        __u32 return_on_close;
        struct pnfs_layout_range range;
        __u32 type;
@@ -270,6 +271,7 @@ struct nfs4_layoutget {
        struct nfs4_layoutget_args args;
        struct nfs4_layoutget_res res;
        struct rpc_cred *cred;
+       unsigned callback_count;
        gfp_t gfp_flags;
 };
 
@@ -435,6 +437,7 @@ struct nfs_openargs {
        enum createmode4        createmode;
        const struct nfs4_label *label;
        umode_t                 umask;
+       struct nfs4_layoutget_args *lg_args;
 };
 
 struct nfs_openres {
@@ -457,6 +460,7 @@ struct nfs_openres {
        __u32                   access_request;
        __u32                   access_supported;
        __u32                   access_result;
+       struct nfs4_layoutget_res *lg_res;
 };
 
 /*
@@ -1577,7 +1581,8 @@ struct nfs_rpc_ops {
        struct dentry *(*try_mount) (int, const char *, struct nfs_mount_info *,
                                     struct nfs_subversion *);
        int     (*getattr) (struct nfs_server *, struct nfs_fh *,
-                           struct nfs_fattr *, struct nfs4_label *);
+                           struct nfs_fattr *, struct nfs4_label *,
+                           struct inode *);
        int     (*setattr) (struct dentry *, struct nfs_fattr *,
                            struct iattr *);
        int     (*lookup)  (struct inode *, const struct qstr *,
@@ -1591,7 +1596,7 @@ struct nfs_rpc_ops {
        int     (*create)  (struct inode *, struct dentry *,
                            struct iattr *, int);
        int     (*remove)  (struct inode *, struct dentry *);
-       void    (*unlink_setup)  (struct rpc_message *, struct dentry *);
+       void    (*unlink_setup)  (struct rpc_message *, struct dentry *, struct inode *);
        void    (*unlink_rpc_prepare) (struct rpc_task *, struct nfs_unlinkdata *);
        int     (*unlink_done) (struct rpc_task *, struct inode *);
        void    (*rename_setup)  (struct rpc_message *msg,
@@ -1620,9 +1625,11 @@ struct nfs_rpc_ops {
                                    struct nfs_pgio_header *);
        void    (*read_setup)(struct nfs_pgio_header *, struct rpc_message *);
        int     (*read_done)(struct rpc_task *, struct nfs_pgio_header *);
-       void    (*write_setup)(struct nfs_pgio_header *, struct rpc_message *);
+       void    (*write_setup)(struct nfs_pgio_header *, struct rpc_message *,
+                               struct rpc_clnt **);
        int     (*write_done)(struct rpc_task *, struct nfs_pgio_header *);
-       void    (*commit_setup) (struct nfs_commit_data *, struct rpc_message *);
+       void    (*commit_setup) (struct nfs_commit_data *, struct rpc_message *,
+                               struct rpc_clnt **);
        void    (*commit_rpc_prepare)(struct rpc_task *, struct nfs_commit_data *);
        int     (*commit_done) (struct rpc_task *, struct nfs_commit_data *);
        int     (*lock)(struct file *, int, struct file_lock *);
diff --git a/include/linux/platform_data/media/ir-rx51.h b/include/linux/platform_data/media/ir-rx51.h
deleted file mode 100644 (file)
index 9d127aa..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _IR_RX51_H
-#define _IR_RX51_H
-
-struct ir_rx51_platform_data {
-       int(*set_max_mpu_wakeup_lat)(struct device *dev, long t);
-};
-
-#endif
index 2744cff1b297e198041e6982700d2dc9fb9d8c58..19f5cb618c55dbf7bd54f9b6785f2892aecbc28a 100644 (file)
@@ -58,11 +58,10 @@ struct mlxreg_hotplug_device {
  * struct mlxreg_core_data - attributes control data:
  *
  * @label: attribute label;
- * @label: attribute register offset;
  * @reg: attribute register;
  * @mask: attribute access mask;
- * @mode: access mode;
  * @bit: attribute effective bit;
+ * @mode: access mode;
  * @np - pointer to node platform associated with attribute;
  * @hpdev - hotplug device data;
  * @health_cntr: dynamic device health indication counter;
index f1a2cf655bdb5895c5b8ea1a66efbe5724b76629..1bbfa27cccb41449d9811ae345e27d329959dc0d 100644 (file)
@@ -56,6 +56,16 @@ struct davinci_nand_pdata {          /* platform_data */
        uint32_t                mask_ale;
        uint32_t                mask_cle;
 
+       /*
+        * 0-indexed chip-select number of the asynchronous
+        * interface to which the NAND device has been connected.
+        *
+        * So, if you have NAND connected to CS3 of DA850, you
+        * will pass '1' here. Since the asynchronous interface
+        * on DA850 starts from CS2.
+        */
+       uint32_t                core_chipsel;
+
        /* for packages using two chipselects */
        uint32_t                mask_chipsel;
 
index 997b06634152611155c5e2b6bf093a24373f9e2e..18602cab77991326e2c6128e6a38b73c1bf97b8c 100644 (file)
@@ -7,7 +7,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * For further information, see the Documentation/spi/sc18is602 file.
+ * For further information, see the Documentation/spi/spi-sc18is602 file.
  */
 
 /**
index 7c686d335c12ec12c3bc31699db001f72eddfcf1..ee495d707f178fb3e403d37e30e47e9ab66ca350 100644 (file)
@@ -18,9 +18,6 @@
 
 #include <drm/drm_mode.h>
 
-struct sh_mobile_meram_cfg;
-struct sh_mobile_meram_info;
-
 enum shmob_drm_clk_source {
        SHMOB_DRM_CLK_BUS,
        SHMOB_DRM_CLK_PERIPHERAL,
@@ -93,7 +90,6 @@ struct shmob_drm_platform_data {
        struct shmob_drm_interface_data iface;
        struct shmob_drm_panel_data panel;
        struct shmob_drm_backlight_data backlight;
-       const struct sh_mobile_meram_cfg *meram;
 };
 
 #endif /* __SHMOB_DRM_H__ */
index 6f012fefa1a231b5517981353ea2b892fd668863..328f670d10bd731b81e0a2bf3edecc819cfb3d26 100644 (file)
@@ -5,24 +5,29 @@
 
 /*
  * struct spi_imx_master - device.platform_data for SPI controller devices.
- * @chipselect: Array of chipselects for this master. Numbers >= 0 mean gpio
- *              pins, numbers < 0 mean internal CSPI chipselects according
- *              to MXC_SPI_CS(). Normally you want to use gpio based chip
- *              selects as the CSPI module tries to be intelligent about
- *              when to assert the chipselect: The CSPI module deasserts the
- *              chipselect once it runs out of input data. The other problem
- *              is that it is not possible to mix between high active and low
- *              active chipselects on one single bus using the internal
- *              chipselects. Unfortunately Freescale decided to put some
+ * @chipselect: Array of chipselects for this master or NULL.  Numbers >= 0
+ *              mean GPIO pins, -ENOENT means internal CSPI chipselect
+ *              matching the position in the array.  E.g., if chipselect[1] =
+ *              -ENOENT then a SPI slave using chip select 1 will use the
+ *              native SS1 line of the CSPI.  Omitting the array will use
+ *              all native chip selects.
+
+ *              Normally you want to use gpio based chip selects as the CSPI
+ *              module tries to be intelligent about when to assert the
+ *              chipselect:  The CSPI module deasserts the chipselect once it
+ *              runs out of input data.  The other problem is that it is not
+ *              possible to mix between high active and low active chipselects
+ *              on one single bus using the internal chipselects.
+ *              Unfortunately, on some SoCs, Freescale decided to put some
  *              chipselects on dedicated pins which are not usable as gpios,
  *              so we have to support the internal chipselects.
- * @num_chipselect: ARRAY_SIZE(chipselect)
+ *
+ * @num_chipselect: If @chipselect is specified, ARRAY_SIZE(chipselect),
+ *                  otherwise the number of native chip selects.
  */
 struct spi_imx_master {
        int     *chipselect;
        int     num_chipselect;
 };
 
-#define MXC_SPI_CS(no) ((no) - 32)
-
 #endif /* __MACH_SPI_H_*/
index ac72e115093c8618ebd43086dcb07e961df9cdb3..e6407bafcbf8662a800ff9eaf901adf3df20cf77 100644 (file)
 
 #include <linux/of_platform.h>
 
+/**
+ * struct aemif_abus_data - Async bus configuration parameters.
+ *
+ * @cs - Chip-select number.
+ */
+struct aemif_abus_data {
+       u32 cs;
+};
+
+/**
+ * struct aemif_platform_data - Data to set up the TI aemif driver.
+ *
+ * @dev_lookup: of_dev_auxdata passed to of_platform_populate() for aemif
+ *              subdevices.
+ * @cs_offset: Lowest allowed chip-select number.
+ * @abus_data: Array of async bus configuration entries.
+ * @num_abus_data: Number of abus entries.
+ * @sub_devices: Array of platform subdevices.
+ * @num_sub_devices: Number of subdevices.
+ */
 struct aemif_platform_data {
        struct of_dev_auxdata *dev_lookup;
+       u32 cs_offset;
+       struct aemif_abus_data *abus_data;
+       size_t num_abus_data;
+       struct platform_device *sub_devices;
+       size_t num_sub_devices;
 };
 
 #endif /* __TI_DAVINCI_AEMIF_DATA_H__ */
index 80ce28d4083247f145b63c940da5927ced1a5ae3..990aad477458113abf887af2f12e68bf56eec66d 100644 (file)
@@ -45,6 +45,7 @@ struct sysc_regbits {
        s8 emufree_shift;
 };
 
+#define SYSC_QUIRK_RESOURCE_PROVIDER   BIT(9)
 #define SYSC_QUIRK_LEGACY_IDLE         BIT(8)
 #define SYSC_QUIRK_RESET_STATUS                BIT(7)
 #define SYSC_QUIRK_NO_IDLE_ON_INIT     BIT(6)
index 42e0d649e6531577a841cbb7d4b16842a6f413e4..9206a4fef9ac151905a825700c6ae7477d7cbd88 100644 (file)
@@ -237,6 +237,8 @@ unsigned int of_genpd_opp_to_performance_state(struct device *dev,
                                struct device_node *opp_node);
 
 int genpd_dev_pm_attach(struct device *dev);
+struct device *genpd_dev_pm_attach_by_id(struct device *dev,
+                                        unsigned int index);
 #else /* !CONFIG_PM_GENERIC_DOMAINS_OF */
 static inline int of_genpd_add_provider_simple(struct device_node *np,
                                        struct generic_pm_domain *genpd)
@@ -282,6 +284,12 @@ static inline int genpd_dev_pm_attach(struct device *dev)
        return 0;
 }
 
+static inline struct device *genpd_dev_pm_attach_by_id(struct device *dev,
+                                                      unsigned int index)
+{
+       return NULL;
+}
+
 static inline
 struct generic_pm_domain *of_genpd_remove_last(struct device_node *np)
 {
@@ -291,6 +299,8 @@ struct generic_pm_domain *of_genpd_remove_last(struct device_node *np)
 
 #ifdef CONFIG_PM
 int dev_pm_domain_attach(struct device *dev, bool power_on);
+struct device *dev_pm_domain_attach_by_id(struct device *dev,
+                                         unsigned int index);
 void dev_pm_domain_detach(struct device *dev, bool power_off);
 void dev_pm_domain_set(struct device *dev, struct dev_pm_domain *pd);
 #else
@@ -298,6 +308,11 @@ static inline int dev_pm_domain_attach(struct device *dev, bool power_on)
 {
        return 0;
 }
+static inline struct device *dev_pm_domain_attach_by_id(struct device *dev,
+                                                       unsigned int index)
+{
+       return NULL;
+}
 static inline void dev_pm_domain_detach(struct device *dev, bool power_off) {}
 static inline void dev_pm_domain_set(struct device *dev,
                                     struct dev_pm_domain *pd) {}
index db5dbbf7a48d4581da71e14fac6728eee72ba67d..f0fc4700b6ff53adfb8584162ae0bb3c522237a2 100644 (file)
@@ -56,7 +56,8 @@ extern void pm_runtime_update_max_time_suspended(struct device *dev,
                                                 s64 delta_ns);
 extern void pm_runtime_set_memalloc_noio(struct device *dev, bool enable);
 extern void pm_runtime_clean_up_links(struct device *dev);
-extern void pm_runtime_resume_suppliers(struct device *dev);
+extern void pm_runtime_get_suppliers(struct device *dev);
+extern void pm_runtime_put_suppliers(struct device *dev);
 extern void pm_runtime_new_link(struct device *dev);
 extern void pm_runtime_drop_link(struct device *dev);
 
@@ -172,7 +173,8 @@ static inline unsigned long pm_runtime_autosuspend_expiration(
 static inline void pm_runtime_set_memalloc_noio(struct device *dev,
                                                bool enable){}
 static inline void pm_runtime_clean_up_links(struct device *dev) {}
-static inline void pm_runtime_resume_suppliers(struct device *dev) {}
+static inline void pm_runtime_get_suppliers(struct device *dev) {}
+static inline void pm_runtime_put_suppliers(struct device *dev) {}
 static inline void pm_runtime_new_link(struct device *dev) {}
 static inline void pm_runtime_drop_link(struct device *dev) {}
 
index e518352137e796127b4fa5eb7898fe67225e9d13..626fc65c433640c5d6c6302949c9a3028c84a6de 100644 (file)
@@ -14,6 +14,8 @@ struct seq_operations;
 
 #ifdef CONFIG_PROC_FS
 
+typedef int (*proc_write_t)(struct file *, char *, size_t);
+
 extern void proc_root_init(void);
 extern void proc_flush_task(struct task_struct *);
 
@@ -61,6 +63,16 @@ struct proc_dir_entry *proc_create_net_data(const char *name, umode_t mode,
 struct proc_dir_entry *proc_create_net_single(const char *name, umode_t mode,
                struct proc_dir_entry *parent,
                int (*show)(struct seq_file *, void *), void *data);
+struct proc_dir_entry *proc_create_net_data_write(const char *name, umode_t mode,
+                                                 struct proc_dir_entry *parent,
+                                                 const struct seq_operations *ops,
+                                                 proc_write_t write,
+                                                 unsigned int state_size, void *data);
+struct proc_dir_entry *proc_create_net_single_write(const char *name, umode_t mode,
+                                                   struct proc_dir_entry *parent,
+                                                   int (*show)(struct seq_file *, void *),
+                                                   proc_write_t write,
+                                                   void *data);
 
 #else /* CONFIG_PROC_FS */
 
index 61f806a7fe29ec570a1c8f066767ef31c67b3042..a15bc4d487528f4f4301fdb9f30d465799637652 100644 (file)
@@ -71,7 +71,7 @@ struct pstore_record {
        struct pstore_info      *psi;
        enum pstore_type_id     type;
        u64                     id;
-       struct timespec         time;
+       struct timespec64       time;
        char                    *buf;
        ssize_t                 size;
        ssize_t                 ecc_notice_size;
index e8afbd71a140696cd5b6affe1a7fbada5ccc5148..8ea265a022fdb3752476ea1e1e2ef8def054b041 100644 (file)
@@ -14,6 +14,8 @@ struct platform_pwm_backlight_data {
        unsigned int lth_brightness;
        unsigned int pwm_period_ns;
        unsigned int *levels;
+       unsigned int post_pwm_on_delay;
+       unsigned int pwm_off_delay;
        /* TODO remove once all users are switched to gpiod_* API */
        int enable_gpio;
        int (*init)(struct device *dev);
diff --git a/include/linux/qcom-geni-se.h b/include/linux/qcom-geni-se.h
new file mode 100644 (file)
index 0000000..5d61449
--- /dev/null
@@ -0,0 +1,425 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
+ */
+
+#ifndef _LINUX_QCOM_GENI_SE
+#define _LINUX_QCOM_GENI_SE
+
+/* Transfer mode supported by GENI Serial Engines */
+enum geni_se_xfer_mode {
+       GENI_SE_INVALID,
+       GENI_SE_FIFO,
+       GENI_SE_DMA,
+};
+
+/* Protocols supported by GENI Serial Engines */
+enum geni_se_protocol_type {
+       GENI_SE_NONE,
+       GENI_SE_SPI,
+       GENI_SE_UART,
+       GENI_SE_I2C,
+       GENI_SE_I3C,
+};
+
+struct geni_wrapper;
+struct clk;
+
+/**
+ * struct geni_se - GENI Serial Engine
+ * @base:              Base Address of the Serial Engine's register block
+ * @dev:               Pointer to the Serial Engine device
+ * @wrapper:           Pointer to the parent QUP Wrapper core
+ * @clk:               Handle to the core serial engine clock
+ * @num_clk_levels:    Number of valid clock levels in clk_perf_tbl
+ * @clk_perf_tbl:      Table of clock frequency input to serial engine clock
+ */
+struct geni_se {
+       void __iomem *base;
+       struct device *dev;
+       struct geni_wrapper *wrapper;
+       struct clk *clk;
+       unsigned int num_clk_levels;
+       unsigned long *clk_perf_tbl;
+};
+
+/* Common SE registers */
+#define GENI_FORCE_DEFAULT_REG         0x20
+#define SE_GENI_STATUS                 0x40
+#define GENI_SER_M_CLK_CFG             0x48
+#define GENI_SER_S_CLK_CFG             0x4c
+#define GENI_FW_REVISION_RO            0x68
+#define SE_GENI_CLK_SEL                        0x7c
+#define SE_GENI_DMA_MODE_EN            0x258
+#define SE_GENI_M_CMD0                 0x600
+#define SE_GENI_M_CMD_CTRL_REG         0x604
+#define SE_GENI_M_IRQ_STATUS           0x610
+#define SE_GENI_M_IRQ_EN               0x614
+#define SE_GENI_M_IRQ_CLEAR            0x618
+#define SE_GENI_S_CMD0                 0x630
+#define SE_GENI_S_CMD_CTRL_REG         0x634
+#define SE_GENI_S_IRQ_STATUS           0x640
+#define SE_GENI_S_IRQ_EN               0x644
+#define SE_GENI_S_IRQ_CLEAR            0x648
+#define SE_GENI_TX_FIFOn               0x700
+#define SE_GENI_RX_FIFOn               0x780
+#define SE_GENI_TX_FIFO_STATUS         0x800
+#define SE_GENI_RX_FIFO_STATUS         0x804
+#define SE_GENI_TX_WATERMARK_REG       0x80c
+#define SE_GENI_RX_WATERMARK_REG       0x810
+#define SE_GENI_RX_RFR_WATERMARK_REG   0x814
+#define SE_GENI_IOS                    0x908
+#define SE_DMA_TX_IRQ_STAT             0xc40
+#define SE_DMA_TX_IRQ_CLR              0xc44
+#define SE_DMA_TX_FSM_RST              0xc58
+#define SE_DMA_RX_IRQ_STAT             0xd40
+#define SE_DMA_RX_IRQ_CLR              0xd44
+#define SE_DMA_RX_FSM_RST              0xd58
+#define SE_HW_PARAM_0                  0xe24
+#define SE_HW_PARAM_1                  0xe28
+
+/* GENI_FORCE_DEFAULT_REG fields */
+#define FORCE_DEFAULT  BIT(0)
+
+/* GENI_STATUS fields */
+#define M_GENI_CMD_ACTIVE              BIT(0)
+#define S_GENI_CMD_ACTIVE              BIT(12)
+
+/* GENI_SER_M_CLK_CFG/GENI_SER_S_CLK_CFG */
+#define SER_CLK_EN                     BIT(0)
+#define CLK_DIV_MSK                    GENMASK(15, 4)
+#define CLK_DIV_SHFT                   4
+
+/* GENI_FW_REVISION_RO fields */
+#define FW_REV_PROTOCOL_MSK            GENMASK(15, 8)
+#define FW_REV_PROTOCOL_SHFT           8
+
+/* GENI_CLK_SEL fields */
+#define CLK_SEL_MSK                    GENMASK(2, 0)
+
+/* SE_GENI_DMA_MODE_EN */
+#define GENI_DMA_MODE_EN               BIT(0)
+
+/* GENI_M_CMD0 fields */
+#define M_OPCODE_MSK                   GENMASK(31, 27)
+#define M_OPCODE_SHFT                  27
+#define M_PARAMS_MSK                   GENMASK(26, 0)
+
+/* GENI_M_CMD_CTRL_REG */
+#define M_GENI_CMD_CANCEL              BIT(2)
+#define M_GENI_CMD_ABORT               BIT(1)
+#define M_GENI_DISABLE                 BIT(0)
+
+/* GENI_S_CMD0 fields */
+#define S_OPCODE_MSK                   GENMASK(31, 27)
+#define S_OPCODE_SHFT                  27
+#define S_PARAMS_MSK                   GENMASK(26, 0)
+
+/* GENI_S_CMD_CTRL_REG */
+#define S_GENI_CMD_CANCEL              BIT(2)
+#define S_GENI_CMD_ABORT               BIT(1)
+#define S_GENI_DISABLE                 BIT(0)
+
+/* GENI_M_IRQ_EN fields */
+#define M_CMD_DONE_EN                  BIT(0)
+#define M_CMD_OVERRUN_EN               BIT(1)
+#define M_ILLEGAL_CMD_EN               BIT(2)
+#define M_CMD_FAILURE_EN               BIT(3)
+#define M_CMD_CANCEL_EN                        BIT(4)
+#define M_CMD_ABORT_EN                 BIT(5)
+#define M_TIMESTAMP_EN                 BIT(6)
+#define M_RX_IRQ_EN                    BIT(7)
+#define M_GP_SYNC_IRQ_0_EN             BIT(8)
+#define M_GP_IRQ_0_EN                  BIT(9)
+#define M_GP_IRQ_1_EN                  BIT(10)
+#define M_GP_IRQ_2_EN                  BIT(11)
+#define M_GP_IRQ_3_EN                  BIT(12)
+#define M_GP_IRQ_4_EN                  BIT(13)
+#define M_GP_IRQ_5_EN                  BIT(14)
+#define M_IO_DATA_DEASSERT_EN          BIT(22)
+#define M_IO_DATA_ASSERT_EN            BIT(23)
+#define M_RX_FIFO_RD_ERR_EN            BIT(24)
+#define M_RX_FIFO_WR_ERR_EN            BIT(25)
+#define M_RX_FIFO_WATERMARK_EN         BIT(26)
+#define M_RX_FIFO_LAST_EN              BIT(27)
+#define M_TX_FIFO_RD_ERR_EN            BIT(28)
+#define M_TX_FIFO_WR_ERR_EN            BIT(29)
+#define M_TX_FIFO_WATERMARK_EN         BIT(30)
+#define M_SEC_IRQ_EN                   BIT(31)
+#define M_COMMON_GENI_M_IRQ_EN (GENMASK(6, 1) | \
+                               M_IO_DATA_DEASSERT_EN | \
+                               M_IO_DATA_ASSERT_EN | M_RX_FIFO_RD_ERR_EN | \
+                               M_RX_FIFO_WR_ERR_EN | M_TX_FIFO_RD_ERR_EN | \
+                               M_TX_FIFO_WR_ERR_EN)
+
+/* GENI_S_IRQ_EN fields */
+#define S_CMD_DONE_EN                  BIT(0)
+#define S_CMD_OVERRUN_EN               BIT(1)
+#define S_ILLEGAL_CMD_EN               BIT(2)
+#define S_CMD_FAILURE_EN               BIT(3)
+#define S_CMD_CANCEL_EN                        BIT(4)
+#define S_CMD_ABORT_EN                 BIT(5)
+#define S_GP_SYNC_IRQ_0_EN             BIT(8)
+#define S_GP_IRQ_0_EN                  BIT(9)
+#define S_GP_IRQ_1_EN                  BIT(10)
+#define S_GP_IRQ_2_EN                  BIT(11)
+#define S_GP_IRQ_3_EN                  BIT(12)
+#define S_GP_IRQ_4_EN                  BIT(13)
+#define S_GP_IRQ_5_EN                  BIT(14)
+#define S_IO_DATA_DEASSERT_EN          BIT(22)
+#define S_IO_DATA_ASSERT_EN            BIT(23)
+#define S_RX_FIFO_RD_ERR_EN            BIT(24)
+#define S_RX_FIFO_WR_ERR_EN            BIT(25)
+#define S_RX_FIFO_WATERMARK_EN         BIT(26)
+#define S_RX_FIFO_LAST_EN              BIT(27)
+#define S_COMMON_GENI_S_IRQ_EN (GENMASK(5, 1) | GENMASK(13, 9) | \
+                                S_RX_FIFO_RD_ERR_EN | S_RX_FIFO_WR_ERR_EN)
+
+/*  GENI_/TX/RX/RX_RFR/_WATERMARK_REG fields */
+#define WATERMARK_MSK                  GENMASK(5, 0)
+
+/* GENI_TX_FIFO_STATUS fields */
+#define TX_FIFO_WC                     GENMASK(27, 0)
+
+/*  GENI_RX_FIFO_STATUS fields */
+#define RX_LAST                                BIT(31)
+#define RX_LAST_BYTE_VALID_MSK         GENMASK(30, 28)
+#define RX_LAST_BYTE_VALID_SHFT                28
+#define RX_FIFO_WC_MSK                 GENMASK(24, 0)
+
+/* SE_GENI_IOS fields */
+#define IO2_DATA_IN                    BIT(1)
+#define RX_DATA_IN                     BIT(0)
+
+/* SE_DMA_TX_IRQ_STAT Register fields */
+#define TX_DMA_DONE                    BIT(0)
+#define TX_EOT                         BIT(1)
+#define TX_SBE                         BIT(2)
+#define TX_RESET_DONE                  BIT(3)
+
+/* SE_DMA_RX_IRQ_STAT Register fields */
+#define RX_DMA_DONE                    BIT(0)
+#define RX_EOT                         BIT(1)
+#define RX_SBE                         BIT(2)
+#define RX_RESET_DONE                  BIT(3)
+#define RX_FLUSH_DONE                  BIT(4)
+#define RX_GENI_GP_IRQ                 GENMASK(10, 5)
+#define RX_GENI_CANCEL_IRQ             BIT(11)
+#define RX_GENI_GP_IRQ_EXT             GENMASK(13, 12)
+
+/* SE_HW_PARAM_0 fields */
+#define TX_FIFO_WIDTH_MSK              GENMASK(29, 24)
+#define TX_FIFO_WIDTH_SHFT             24
+#define TX_FIFO_DEPTH_MSK              GENMASK(21, 16)
+#define TX_FIFO_DEPTH_SHFT             16
+
+/* SE_HW_PARAM_1 fields */
+#define RX_FIFO_WIDTH_MSK              GENMASK(29, 24)
+#define RX_FIFO_WIDTH_SHFT             24
+#define RX_FIFO_DEPTH_MSK              GENMASK(21, 16)
+#define RX_FIFO_DEPTH_SHFT             16
+
+#define HW_VER_MAJOR_MASK              GENMASK(31, 28)
+#define HW_VER_MAJOR_SHFT              28
+#define HW_VER_MINOR_MASK              GENMASK(27, 16)
+#define HW_VER_MINOR_SHFT              16
+#define HW_VER_STEP_MASK               GENMASK(15, 0)
+
+#if IS_ENABLED(CONFIG_QCOM_GENI_SE)
+
+u32 geni_se_get_qup_hw_version(struct geni_se *se);
+
+#define geni_se_get_wrapper_version(se, major, minor, step) do { \
+       u32 ver; \
+\
+       ver = geni_se_get_qup_hw_version(se); \
+       major = (ver & HW_VER_MAJOR_MASK) >> HW_VER_MAJOR_SHFT; \
+       minor = (ver & HW_VER_MINOR_MASK) >> HW_VER_MINOR_SHFT; \
+       step = version & HW_VER_STEP_MASK; \
+} while (0)
+
+/**
+ * geni_se_read_proto() - Read the protocol configured for a serial engine
+ * @se:                Pointer to the concerned serial engine.
+ *
+ * Return: Protocol value as configured in the serial engine.
+ */
+static inline u32 geni_se_read_proto(struct geni_se *se)
+{
+       u32 val;
+
+       val = readl_relaxed(se->base + GENI_FW_REVISION_RO);
+
+       return (val & FW_REV_PROTOCOL_MSK) >> FW_REV_PROTOCOL_SHFT;
+}
+
+/**
+ * geni_se_setup_m_cmd() - Setup the primary sequencer
+ * @se:                Pointer to the concerned serial engine.
+ * @cmd:       Command/Operation to setup in the primary sequencer.
+ * @params:    Parameter for the sequencer command.
+ *
+ * This function is used to configure the primary sequencer with the
+ * command and its associated parameters.
+ */
+static inline void geni_se_setup_m_cmd(struct geni_se *se, u32 cmd, u32 params)
+{
+       u32 m_cmd;
+
+       m_cmd = (cmd << M_OPCODE_SHFT) | (params & M_PARAMS_MSK);
+       writel_relaxed(m_cmd, se->base + SE_GENI_M_CMD0);
+}
+
+/**
+ * geni_se_setup_s_cmd() - Setup the secondary sequencer
+ * @se:                Pointer to the concerned serial engine.
+ * @cmd:       Command/Operation to setup in the secondary sequencer.
+ * @params:    Parameter for the sequencer command.
+ *
+ * This function is used to configure the secondary sequencer with the
+ * command and its associated parameters.
+ */
+static inline void geni_se_setup_s_cmd(struct geni_se *se, u32 cmd, u32 params)
+{
+       u32 s_cmd;
+
+       s_cmd = readl_relaxed(se->base + SE_GENI_S_CMD0);
+       s_cmd &= ~(S_OPCODE_MSK | S_PARAMS_MSK);
+       s_cmd |= (cmd << S_OPCODE_SHFT);
+       s_cmd |= (params & S_PARAMS_MSK);
+       writel_relaxed(s_cmd, se->base + SE_GENI_S_CMD0);
+}
+
+/**
+ * geni_se_cancel_m_cmd() - Cancel the command configured in the primary
+ *                          sequencer
+ * @se:        Pointer to the concerned serial engine.
+ *
+ * This function is used to cancel the currently configured command in the
+ * primary sequencer.
+ */
+static inline void geni_se_cancel_m_cmd(struct geni_se *se)
+{
+       writel_relaxed(M_GENI_CMD_CANCEL, se->base + SE_GENI_M_CMD_CTRL_REG);
+}
+
+/**
+ * geni_se_cancel_s_cmd() - Cancel the command configured in the secondary
+ *                          sequencer
+ * @se:        Pointer to the concerned serial engine.
+ *
+ * This function is used to cancel the currently configured command in the
+ * secondary sequencer.
+ */
+static inline void geni_se_cancel_s_cmd(struct geni_se *se)
+{
+       writel_relaxed(S_GENI_CMD_CANCEL, se->base + SE_GENI_S_CMD_CTRL_REG);
+}
+
+/**
+ * geni_se_abort_m_cmd() - Abort the command configured in the primary sequencer
+ * @se:        Pointer to the concerned serial engine.
+ *
+ * This function is used to force abort the currently configured command in the
+ * primary sequencer.
+ */
+static inline void geni_se_abort_m_cmd(struct geni_se *se)
+{
+       writel_relaxed(M_GENI_CMD_ABORT, se->base + SE_GENI_M_CMD_CTRL_REG);
+}
+
+/**
+ * geni_se_abort_s_cmd() - Abort the command configured in the secondary
+ *                         sequencer
+ * @se:        Pointer to the concerned serial engine.
+ *
+ * This function is used to force abort the currently configured command in the
+ * secondary sequencer.
+ */
+static inline void geni_se_abort_s_cmd(struct geni_se *se)
+{
+       writel_relaxed(S_GENI_CMD_ABORT, se->base + SE_GENI_S_CMD_CTRL_REG);
+}
+
+/**
+ * geni_se_get_tx_fifo_depth() - Get the TX fifo depth of the serial engine
+ * @se:        Pointer to the concerned serial engine.
+ *
+ * This function is used to get the depth i.e. number of elements in the
+ * TX fifo of the serial engine.
+ *
+ * Return: TX fifo depth in units of FIFO words.
+ */
+static inline u32 geni_se_get_tx_fifo_depth(struct geni_se *se)
+{
+       u32 val;
+
+       val = readl_relaxed(se->base + SE_HW_PARAM_0);
+
+       return (val & TX_FIFO_DEPTH_MSK) >> TX_FIFO_DEPTH_SHFT;
+}
+
+/**
+ * geni_se_get_tx_fifo_width() - Get the TX fifo width of the serial engine
+ * @se:        Pointer to the concerned serial engine.
+ *
+ * This function is used to get the width i.e. word size per element in the
+ * TX fifo of the serial engine.
+ *
+ * Return: TX fifo width in bits
+ */
+static inline u32 geni_se_get_tx_fifo_width(struct geni_se *se)
+{
+       u32 val;
+
+       val = readl_relaxed(se->base + SE_HW_PARAM_0);
+
+       return (val & TX_FIFO_WIDTH_MSK) >> TX_FIFO_WIDTH_SHFT;
+}
+
+/**
+ * geni_se_get_rx_fifo_depth() - Get the RX fifo depth of the serial engine
+ * @se:        Pointer to the concerned serial engine.
+ *
+ * This function is used to get the depth i.e. number of elements in the
+ * RX fifo of the serial engine.
+ *
+ * Return: RX fifo depth in units of FIFO words
+ */
+static inline u32 geni_se_get_rx_fifo_depth(struct geni_se *se)
+{
+       u32 val;
+
+       val = readl_relaxed(se->base + SE_HW_PARAM_1);
+
+       return (val & RX_FIFO_DEPTH_MSK) >> RX_FIFO_DEPTH_SHFT;
+}
+
+void geni_se_init(struct geni_se *se, u32 rx_wm, u32 rx_rfr);
+
+void geni_se_select_mode(struct geni_se *se, enum geni_se_xfer_mode mode);
+
+void geni_se_config_packing(struct geni_se *se, int bpw, int pack_words,
+                           bool msb_to_lsb, bool tx_cfg, bool rx_cfg);
+
+int geni_se_resources_off(struct geni_se *se);
+
+int geni_se_resources_on(struct geni_se *se);
+
+int geni_se_clk_tbl_get(struct geni_se *se, unsigned long **tbl);
+
+int geni_se_clk_freq_match(struct geni_se *se, unsigned long req_freq,
+                          unsigned int *index, unsigned long *res_freq,
+                          bool exact);
+
+int geni_se_tx_dma_prep(struct geni_se *se, void *buf, size_t len,
+                       dma_addr_t *iova);
+
+int geni_se_rx_dma_prep(struct geni_se *se, void *buf, size_t len,
+                       dma_addr_t *iova);
+
+void geni_se_tx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len);
+
+void geni_se_rx_dma_unprep(struct geni_se *se, dma_addr_t iova, size_t len);
+#endif
+#endif
index 127f534fec94aadfdc322a562b03f0860d3ccfa3..36df6ccbc874b6655fa1ac64ebdcaff150d26215 100644 (file)
@@ -403,6 +403,19 @@ static inline void list_splice_tail_init_rcu(struct list_head *list,
             &pos->member != (head);    \
             pos = list_entry_rcu(pos->member.next, typeof(*pos), member))
 
+/**
+ * list_for_each_entry_from_rcu - iterate over a list from current point
+ * @pos:       the type * to use as a loop cursor.
+ * @head:      the head for your list.
+ * @member:    the name of the list_node within the struct.
+ *
+ * Iterate over the tail of a list starting from a given position,
+ * which must have been in the list when the RCU read lock was taken.
+ */
+#define list_for_each_entry_from_rcu(pos, head, member)                        \
+       for (; &(pos)->member != (head);                                        \
+               pos = list_entry_rcu(pos->member.next, typeof(*(pos)), member))
+
 /**
  * hlist_del_rcu - deletes entry from hash list without re-initialization
  * @n: the element to delete from the hash list.
index e4b257ff881bfe439a945d7487f5700f17a26740..bc8206a8f30e6b0c2172e3bc3da3a85cab536cdd 100644 (file)
@@ -109,7 +109,7 @@ static inline void hlist_nulls_add_head_rcu(struct hlist_nulls_node *n,
  *
  * The barrier() is needed to make sure compiler doesn't cache first element [1],
  * as this loop can be restarted [2]
- * [1] Documentation/atomic_ops.txt around line 114
+ * [1] Documentation/core-api/atomic_ops.rst around line 114
  * [2] Documentation/RCU/rculist_nulls.txt around line 146
  */
 #define hlist_nulls_for_each_entry_rcu(tpos, pos, head, member)                        \
index ca07366c4c333512e297bf4b4b50be6475857fac..9fe156d1c018e3d4dd5f5717a81fd9fde6212d96 100644 (file)
@@ -1,35 +1,10 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
 /*
  * Remote processor messaging
  *
  * Copyright (C) 2011 Texas Instruments, Inc.
  * Copyright (C) 2011 Google, Inc.
  * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in
- *   the documentation and/or other materials provided with the
- *   distribution.
- * * Neither the name Texas Instruments nor the names of its
- *   contributors may 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.
  */
 
 #ifndef _LINUX_RPMSG_H
index a622f029836ea0d1a9ed6fc3982df95324af8986..96e26d94719f3b818b8fb3de09dbac2f47da6a44 100644 (file)
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
 #ifndef _LINUX_RPMSG_QCOM_GLINK_H
 #define _LINUX_RPMSG_QCOM_GLINK_H
 
index 3aa4fcb74e761dfda361f17d09593ecd9c361646..87bf02d93a279a9b98df452c7ad78a0b54adc1db 100644 (file)
@@ -742,7 +742,7 @@ struct task_struct {
        pid_t                           pid;
        pid_t                           tgid;
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
        /* Canary value for the -fstack-protector GCC feature: */
        unsigned long                   stack_canary;
 #endif
@@ -1130,7 +1130,7 @@ struct task_struct {
 
 #ifdef CONFIG_KCOV
        /* Coverage collection mode enabled for this task (0 if disabled): */
-       enum kcov_mode                  kcov_mode;
+       unsigned int                    kcov_mode;
 
        /* Size of the kcov_area: */
        unsigned int                    kcov_size;
@@ -1639,6 +1639,12 @@ static inline void clear_tsk_thread_flag(struct task_struct *tsk, int flag)
        clear_ti_thread_flag(task_thread_info(tsk), flag);
 }
 
+static inline void update_tsk_thread_flag(struct task_struct *tsk, int flag,
+                                         bool value)
+{
+       update_ti_thread_flag(task_thread_info(tsk), flag, value);
+}
+
 static inline int test_and_set_tsk_thread_flag(struct task_struct *tsk, int flag)
 {
        return test_and_set_ti_thread_flag(task_thread_info(tsk), flag);
index b458c87b866cb14d3489f63c0f95e2ec161d7259..f4c9fc0fc7555a226a7607758b816b1c9486d5f6 100644 (file)
@@ -85,8 +85,8 @@ struct scmi_clk_ops {
  * @level_set: sets the performance level of a domain
  * @level_get: gets the performance level of a domain
  * @device_domain_id: gets the scmi domain id for a given device
- * @get_transition_latency: gets the DVFS transition latency for a given device
- * @add_opps_to_device: adds all the OPPs for a given device
+ * @transition_latency_get: gets the DVFS transition latency for a given device
+ * @device_opps_add: adds all the OPPs for a given device
  * @freq_set: sets the frequency for a given device using sustained frequency
  *     to sustained performance level mapping
  * @freq_get: gets the frequency for a given device using sustained frequency
@@ -102,10 +102,10 @@ struct scmi_perf_ops {
        int (*level_get)(const struct scmi_handle *handle, u32 domain,
                         u32 *level, bool poll);
        int (*device_domain_id)(struct device *dev);
-       int (*get_transition_latency)(const struct scmi_handle *handle,
+       int (*transition_latency_get)(const struct scmi_handle *handle,
                                      struct device *dev);
-       int (*add_opps_to_device)(const struct scmi_handle *handle,
-                                 struct device *dev);
+       int (*device_opps_add)(const struct scmi_handle *handle,
+                              struct device *dev);
        int (*freq_set)(const struct scmi_handle *handle, u32 domain,
                        unsigned long rate, bool poll);
        int (*freq_get)(const struct scmi_handle *handle, u32 domain,
@@ -189,6 +189,14 @@ struct scmi_sensor_ops {
  * @perf_ops: pointer to set of performance protocol operations
  * @clk_ops: pointer to set of clock protocol operations
  * @sensor_ops: pointer to set of sensor protocol operations
+ * @perf_priv: pointer to private data structure specific to performance
+ *     protocol(for internal use only)
+ * @clk_priv: pointer to private data structure specific to clock
+ *     protocol(for internal use only)
+ * @power_priv: pointer to private data structure specific to power
+ *     protocol(for internal use only)
+ * @sensor_priv: pointer to private data structure specific to sensors
+ *     protocol(for internal use only)
  */
 struct scmi_handle {
        struct device *dev;
index 4d759e1ddc335de2cc24d9ba5b55639b66cae39a..14e3fe4bd6a15a4b02f1a0c01268c70ca730ee0c 100644 (file)
@@ -600,6 +600,7 @@ struct memcg_cache_params {
                        struct memcg_cache_array __rcu *memcg_caches;
                        struct list_head __root_caches_node;
                        struct list_head children;
+                       bool dying;
                };
                struct {
                        struct mem_cgroup *memcg;
index c1657ed27b303acd96a5cda27f8f4895a3524ec6..86e1b358688aa45c121c4972d78aa8e0804010e3 100644 (file)
@@ -9,4 +9,6 @@ void *qcom_smem_get(unsigned host, unsigned item, size_t *size);
 
 int qcom_smem_get_free_space(unsigned host);
 
+phys_addr_t qcom_smem_virt_to_phys(void *p);
+
 #endif
index 0ccbc138c26adb3268365e184fd69a239959f0f4..18435e5c6364bb55ee0e427751bd6ee37e478c73 100644 (file)
@@ -1,17 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Texas Instruments System Control Interface Protocol
  *
  * Copyright (C) 2015-2016 Texas Instruments Incorporated - http://www.ti.com/
  *     Nishanth Menon
- *
- * 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 "as is" WITHOUT ANY WARRANTY of any
- * kind, whether express or implied; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
  */
 
 #ifndef __TISCI_PROTOCOL_H
index 03696c729fb4feeff3fc597f0dfc55304d8a8692..6b792d080eee8f70ce27b5e7c726a98516560090 100644 (file)
@@ -6,7 +6,7 @@
 #include <linux/sched.h>
 #include <linux/random.h>
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 # include <asm/stackprotector.h>
 #else
 static inline void boot_init_stack_canary(void)
index 22484e44544d56c8e069b90861f4ce7699c4db66..765573dc17d659d36bf8418d1ba19e66c0c843a4 100644 (file)
@@ -41,10 +41,10 @@ struct kstat {
        kuid_t          uid;
        kgid_t          gid;
        loff_t          size;
-       struct timespec atime;
-       struct timespec mtime;
-       struct timespec ctime;
-       struct timespec btime;                  /* File creation time */
+       struct timespec64 atime;
+       struct timespec64 mtime;
+       struct timespec64 ctime;
+       struct timespec64 btime;                        /* File creation time */
        u64             blocks;
 };
 
diff --git a/include/linux/ste_modem_shm.h b/include/linux/ste_modem_shm.h
deleted file mode 100644 (file)
index 8444a4e..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) ST-Ericsson AB 2012
- * Author: Sjur Brendeland / sjur.brandeland@stericsson.com
- *
- * License terms: GNU General Public License (GPL) version 2
- */
-
-#ifndef __INC_MODEM_DEV_H
-#define __INC_MODEM_DEV_H
-#include <linux/types.h>
-#include <linux/platform_device.h>
-
-struct ste_modem_device;
-
-/**
- * struct ste_modem_dev_cb - Callbacks for modem initiated events.
- * @kick: Called when the modem kicks the host.
- *
- * This structure contains callbacks for actions triggered by the modem.
- */
-struct ste_modem_dev_cb {
-       void (*kick)(struct ste_modem_device *mdev, int notify_id);
-};
-
-/**
- * struct ste_modem_dev_ops - Functions to control modem and modem interface.
- *
- * @power:     Main power switch, used for cold-start or complete power off.
- * @kick:      Kick the modem.
- * @kick_subscribe: Subscribe for notifications from the modem.
- * @setup:     Provide callback functions to modem device.
- *
- * This structure contains functions used by the ste remoteproc driver
- * to manage the modem.
- */
-struct ste_modem_dev_ops {
-       int (*power)(struct ste_modem_device *mdev, bool on);
-       int (*kick)(struct ste_modem_device *mdev, int notify_id);
-       int (*kick_subscribe)(struct ste_modem_device *mdev, int notify_id);
-       int (*setup)(struct ste_modem_device *mdev,
-                    struct ste_modem_dev_cb *cfg);
-};
-
-/**
- * struct ste_modem_device - represent the STE modem device
- * @pdev: Reference to platform device
- * @ops: Operations used to manage the modem.
- * @drv_data: Driver private data.
- */
-struct ste_modem_device {
-       struct platform_device pdev;
-       struct ste_modem_dev_ops ops;
-       void *drv_data;
-};
-
-#endif /*INC_MODEM_DEV_H*/
index 4397c52ec4a496f61f7c26599a515276c0acc3ee..d23c5030901a2fe91a436a1e449273a543e015ca 100644 (file)
@@ -5,6 +5,7 @@
 #include <linux/types.h>
 
 struct file;
+struct task_struct;
 
 /* Descriptions of the types of units to
  * print in */
index 8f144db73e380a0b042a5e70a98f4cb8bcac0c37..92d182fd8e3b0d9b655313132f8befaffb32eb78 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
  * Copyright (c) 2015-2017 Oracle. All rights reserved.
  * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
index 7337e1221590c235cc9a4b8bbdbc9fb0e1299c5d..fd78f78df5c662b61430b93858bb5295fec45480 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
  * Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
  *
@@ -70,37 +71,16 @@ extern atomic_t rdma_stat_rq_prod;
 extern atomic_t rdma_stat_sq_poll;
 extern atomic_t rdma_stat_sq_prod;
 
-/*
- * Contexts are built when an RDMA request is created and are a
- * record of the resources that can be recovered when the request
- * completes.
- */
-struct svc_rdma_op_ctxt {
-       struct list_head list;
-       struct xdr_buf arg;
-       struct ib_cqe cqe;
-       u32 byte_len;
-       struct svcxprt_rdma *xprt;
-       enum dma_data_direction direction;
-       int count;
-       unsigned int mapped_sges;
-       int hdr_count;
-       struct ib_send_wr send_wr;
-       struct ib_sge sge[1 + RPCRDMA_MAX_INLINE_THRESH / PAGE_SIZE];
-       struct page *pages[RPCSVC_MAXPAGES];
-};
-
 struct svcxprt_rdma {
        struct svc_xprt      sc_xprt;           /* SVC transport structure */
        struct rdma_cm_id    *sc_cm_id;         /* RDMA connection id */
        struct list_head     sc_accept_q;       /* Conn. waiting accept */
        int                  sc_ord;            /* RDMA read limit */
-       int                  sc_max_sge;
+       int                  sc_max_send_sges;
        bool                 sc_snd_w_inv;      /* OK to use Send With Invalidate */
 
        atomic_t             sc_sq_avail;       /* SQEs ready to be consumed */
        unsigned int         sc_sq_depth;       /* Depth of SQ */
-       unsigned int         sc_rq_depth;       /* Depth of RQ */
        __be32               sc_fc_credits;     /* Forward credits */
        u32                  sc_max_requests;   /* Max requests */
        u32                  sc_max_bc_requests;/* Backward credits */
@@ -109,9 +89,8 @@ struct svcxprt_rdma {
 
        struct ib_pd         *sc_pd;
 
-       spinlock_t           sc_ctxt_lock;
-       struct list_head     sc_ctxts;
-       int                  sc_ctxt_used;
+       spinlock_t           sc_send_lock;
+       struct list_head     sc_send_ctxts;
        spinlock_t           sc_rw_ctxt_lock;
        struct list_head     sc_rw_ctxts;
 
@@ -127,6 +106,9 @@ struct svcxprt_rdma {
        unsigned long        sc_flags;
        struct list_head     sc_read_complete_q;
        struct work_struct   sc_work;
+
+       spinlock_t           sc_recv_lock;
+       struct list_head     sc_recv_ctxts;
 };
 /* sc_flags */
 #define RDMAXPRT_CONN_PENDING  3
@@ -141,12 +123,30 @@ struct svcxprt_rdma {
 
 #define RPCSVC_MAXPAYLOAD_RDMA RPCSVC_MAXPAYLOAD
 
-/* Track DMA maps for this transport and context */
-static inline void svc_rdma_count_mappings(struct svcxprt_rdma *rdma,
-                                          struct svc_rdma_op_ctxt *ctxt)
-{
-       ctxt->mapped_sges++;
-}
+struct svc_rdma_recv_ctxt {
+       struct list_head        rc_list;
+       struct ib_recv_wr       rc_recv_wr;
+       struct ib_cqe           rc_cqe;
+       struct ib_sge           rc_recv_sge;
+       void                    *rc_recv_buf;
+       struct xdr_buf          rc_arg;
+       bool                    rc_temp;
+       u32                     rc_byte_len;
+       unsigned int            rc_page_count;
+       unsigned int            rc_hdr_count;
+       struct page             *rc_pages[RPCSVC_MAXPAGES];
+};
+
+struct svc_rdma_send_ctxt {
+       struct list_head        sc_list;
+       struct ib_send_wr       sc_send_wr;
+       struct ib_cqe           sc_cqe;
+       void                    *sc_xprt_buf;
+       int                     sc_page_count;
+       int                     sc_cur_sge_no;
+       struct page             *sc_pages[RPCSVC_MAXPAGES];
+       struct ib_sge           sc_sges[];
+};
 
 /* svc_rdma_backchannel.c */
 extern int svc_rdma_handle_bc_reply(struct rpc_xprt *xprt,
@@ -154,13 +154,18 @@ extern int svc_rdma_handle_bc_reply(struct rpc_xprt *xprt,
                                    struct xdr_buf *rcvbuf);
 
 /* svc_rdma_recvfrom.c */
+extern void svc_rdma_recv_ctxts_destroy(struct svcxprt_rdma *rdma);
+extern bool svc_rdma_post_recvs(struct svcxprt_rdma *rdma);
+extern void svc_rdma_recv_ctxt_put(struct svcxprt_rdma *rdma,
+                                  struct svc_rdma_recv_ctxt *ctxt);
+extern void svc_rdma_flush_recv_queues(struct svcxprt_rdma *rdma);
 extern int svc_rdma_recvfrom(struct svc_rqst *);
 
 /* svc_rdma_rw.c */
 extern void svc_rdma_destroy_rw_ctxts(struct svcxprt_rdma *rdma);
 extern int svc_rdma_recv_read_chunk(struct svcxprt_rdma *rdma,
                                    struct svc_rqst *rqstp,
-                                   struct svc_rdma_op_ctxt *head, __be32 *p);
+                                   struct svc_rdma_recv_ctxt *head, __be32 *p);
 extern int svc_rdma_send_write_chunk(struct svcxprt_rdma *rdma,
                                     __be32 *wr_ch, struct xdr_buf *xdr);
 extern int svc_rdma_send_reply_chunk(struct svcxprt_rdma *rdma,
@@ -168,24 +173,22 @@ extern int svc_rdma_send_reply_chunk(struct svcxprt_rdma *rdma,
                                     struct xdr_buf *xdr);
 
 /* svc_rdma_sendto.c */
-extern int svc_rdma_map_reply_hdr(struct svcxprt_rdma *rdma,
-                                 struct svc_rdma_op_ctxt *ctxt,
-                                 __be32 *rdma_resp, unsigned int len);
-extern int svc_rdma_post_send_wr(struct svcxprt_rdma *rdma,
-                                struct svc_rdma_op_ctxt *ctxt,
-                                int num_sge, u32 inv_rkey);
+extern void svc_rdma_send_ctxts_destroy(struct svcxprt_rdma *rdma);
+extern struct svc_rdma_send_ctxt *
+               svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma);
+extern void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma,
+                                  struct svc_rdma_send_ctxt *ctxt);
+extern int svc_rdma_send(struct svcxprt_rdma *rdma, struct ib_send_wr *wr);
+extern void svc_rdma_sync_reply_hdr(struct svcxprt_rdma *rdma,
+                                   struct svc_rdma_send_ctxt *ctxt,
+                                   unsigned int len);
+extern int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma,
+                                 struct svc_rdma_send_ctxt *ctxt,
+                                 struct xdr_buf *xdr, __be32 *wr_lst);
 extern int svc_rdma_sendto(struct svc_rqst *);
 
 /* svc_rdma_transport.c */
-extern void svc_rdma_wc_send(struct ib_cq *, struct ib_wc *);
-extern void svc_rdma_wc_reg(struct ib_cq *, struct ib_wc *);
-extern void svc_rdma_wc_read(struct ib_cq *, struct ib_wc *);
-extern void svc_rdma_wc_inv(struct ib_cq *, struct ib_wc *);
-extern int svc_rdma_send(struct svcxprt_rdma *, struct ib_send_wr *);
 extern int svc_rdma_create_listen(struct svc_serv *, int, struct sockaddr *);
-extern struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *);
-extern void svc_rdma_put_context(struct svc_rdma_op_ctxt *, int);
-extern void svc_rdma_unmap_dma(struct svc_rdma_op_ctxt *ctxt);
 extern void svc_sq_reap(struct svcxprt_rdma *);
 extern void svc_rq_reap(struct svcxprt_rdma *);
 extern void svc_rdma_prep_reply_hdr(struct svc_rqst *);
index 5fea0fb420df2d3a42037e7e420aea1f38e05bd8..336fd1a19cca10deaeb811cb5330bf5d6520881f 100644 (file)
@@ -84,7 +84,6 @@ struct rpc_rqst {
        void (*rq_release_snd_buf)(struct rpc_rqst *); /* release rq_enc_pages */
        struct list_head        rq_list;
 
-       void                    *rq_xprtdata;   /* Per-xprt private data */
        void                    *rq_buffer;     /* Call XDR encode buffer */
        size_t                  rq_callsize;
        void                    *rq_rbuffer;    /* Reply XDR decode buffer */
@@ -127,6 +126,8 @@ struct rpc_xprt_ops {
        int             (*reserve_xprt)(struct rpc_xprt *xprt, struct rpc_task *task);
        void            (*release_xprt)(struct rpc_xprt *xprt, struct rpc_task *task);
        void            (*alloc_slot)(struct rpc_xprt *xprt, struct rpc_task *task);
+       void            (*free_slot)(struct rpc_xprt *xprt,
+                                    struct rpc_rqst *req);
        void            (*rpcbind)(struct rpc_task *task);
        void            (*set_port)(struct rpc_xprt *xprt, unsigned short port);
        void            (*connect)(struct rpc_xprt *xprt, struct rpc_task *task);
@@ -324,10 +325,13 @@ struct xprt_class {
 struct rpc_xprt                *xprt_create_transport(struct xprt_create *args);
 void                   xprt_connect(struct rpc_task *task);
 void                   xprt_reserve(struct rpc_task *task);
+void                   xprt_request_init(struct rpc_task *task);
 void                   xprt_retry_reserve(struct rpc_task *task);
 int                    xprt_reserve_xprt(struct rpc_xprt *xprt, struct rpc_task *task);
 int                    xprt_reserve_xprt_cong(struct rpc_xprt *xprt, struct rpc_task *task);
 void                   xprt_alloc_slot(struct rpc_xprt *xprt, struct rpc_task *task);
+void                   xprt_free_slot(struct rpc_xprt *xprt,
+                                      struct rpc_rqst *req);
 void                   xprt_lock_and_alloc_slot(struct rpc_xprt *xprt, struct rpc_task *task);
 bool                   xprt_prepare_transmit(struct rpc_task *task);
 void                   xprt_transmit(struct rpc_task *task);
index 5859563e3c1f7c578cd3fb12d9ed7a76729b0e19..86fc38ff03550b1a601bfb54f30d700339654887 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
  * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
  *
index 7834be668d80b6bd064c36b8ad364d21adc315ea..5f4705f46c2f9ab8aae927304443807de8e27f4d 100644 (file)
@@ -1,25 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
 /*
  *  thermal.h  ($Revision: 0 $)
  *
  *  Copyright (C) 2008  Intel Corp
  *  Copyright (C) 2008  Zhang Rui <rui.zhang@intel.com>
  *  Copyright (C) 2008  Sujith Thomas <sujith.thomas@intel.com>
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; version 2 of the License.
- *
- *  This program is distributed in the hope that it will be useful, but
- *  WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License along
- *  with this program; if not, write to the Free Software Foundation, Inc.,
- *  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- *
- * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  */
 
 #ifndef __THERMAL_H__
index cf2862bd134a400b99136aaf2ec1357bd79ba3d2..8d8821b3689a2e1638547f99b1335089c56ff9fc 100644 (file)
@@ -60,6 +60,15 @@ static inline void clear_ti_thread_flag(struct thread_info *ti, int flag)
        clear_bit(flag, (unsigned long *)&ti->flags);
 }
 
+static inline void update_ti_thread_flag(struct thread_info *ti, int flag,
+                                        bool value)
+{
+       if (value)
+               set_ti_thread_flag(ti, flag);
+       else
+               clear_ti_thread_flag(ti, flag);
+}
+
 static inline int test_and_set_ti_thread_flag(struct thread_info *ti, int flag)
 {
        return test_and_set_bit(flag, (unsigned long *)&ti->flags);
@@ -79,6 +88,8 @@ static inline int test_ti_thread_flag(struct thread_info *ti, int flag)
        set_ti_thread_flag(current_thread_info(), flag)
 #define clear_thread_flag(flag) \
        clear_ti_thread_flag(current_thread_info(), flag)
+#define update_thread_flag(flag, value) \
+       update_ti_thread_flag(current_thread_info(), flag, value)
 #define test_and_set_thread_flag(flag) \
        test_and_set_ti_thread_flag(current_thread_info(), flag)
 #define test_and_clear_thread_flag(flag) \
index c94f466d57ef1ee7b50d5afb57fc07407ea3833c..19a690b559ca1b1850336ffe5133e80db77121f2 100644 (file)
@@ -4,7 +4,7 @@
 /*
  * Kernel Tracepoint API.
  *
- * See Documentation/trace/tracepoints.txt.
+ * See Documentation/trace/tracepoints.rst.
  *
  * Copyright (C) 2008-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
index bbf32524ab279d8e353ca3d9d854a1ab2a12805c..fab02133a9197a43cd9df33728e657e1679c5e16 100644 (file)
@@ -35,7 +35,7 @@ static inline void virtio_rmb(bool weak_barriers)
        if (weak_barriers)
                virt_rmb();
        else
-               rmb();
+               dma_rmb();
 }
 
 static inline void virtio_wmb(bool weak_barriers)
@@ -43,7 +43,7 @@ static inline void virtio_wmb(bool weak_barriers)
        if (weak_barriers)
                virt_wmb();
        else
-               wmb();
+               dma_wmb();
 }
 
 static inline void virtio_store_mb(bool weak_barriers,
index 6d6e21dee46216baca029a4ccd686466a9589b60..a0bec23c6d5e4cd6a01bcec5104e12c27c895b62 100644 (file)
@@ -631,6 +631,7 @@ struct ip_vs_service {
 
        /* alternate persistence engine */
        struct ip_vs_pe __rcu   *pe;
+       int                     conntrack_afmask;
 
        struct rcu_head         rcu_head;
 };
@@ -1611,6 +1612,35 @@ static inline bool ip_vs_conn_uses_conntrack(struct ip_vs_conn *cp,
        return false;
 }
 
+static inline int ip_vs_register_conntrack(struct ip_vs_service *svc)
+{
+#if IS_ENABLED(CONFIG_NF_CONNTRACK)
+       int afmask = (svc->af == AF_INET6) ? 2 : 1;
+       int ret = 0;
+
+       if (!(svc->conntrack_afmask & afmask)) {
+               ret = nf_ct_netns_get(svc->ipvs->net, svc->af);
+               if (ret >= 0)
+                       svc->conntrack_afmask |= afmask;
+       }
+       return ret;
+#else
+       return 0;
+#endif
+}
+
+static inline void ip_vs_unregister_conntrack(struct ip_vs_service *svc)
+{
+#if IS_ENABLED(CONFIG_NF_CONNTRACK)
+       int afmask = (svc->af == AF_INET6) ? 2 : 1;
+
+       if (svc->conntrack_afmask & afmask) {
+               nf_ct_netns_put(svc->ipvs->net, svc->af);
+               svc->conntrack_afmask &= ~afmask;
+       }
+#endif
+}
+
 static inline int
 ip_vs_dest_conn_overhead(struct ip_vs_dest *dest)
 {
index 1910b657243027e3faf36dde94af7ac1b29a0843..3a188a0923a38189f010ebf7d99766d1bd6cea54 100644 (file)
@@ -20,7 +20,8 @@ unsigned int nf_conncount_lookup(struct net *net, struct hlist_head *head,
                                 bool *addit);
 
 bool nf_conncount_add(struct hlist_head *head,
-                     const struct nf_conntrack_tuple *tuple);
+                     const struct nf_conntrack_tuple *tuple,
+                     const struct nf_conntrack_zone *zone);
 
 void nf_conncount_cache_free(struct hlist_head *hhead);
 
diff --git a/include/net/netfilter/nft_dup.h b/include/net/netfilter/nft_dup.h
deleted file mode 100644 (file)
index 4d9d512..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _NFT_DUP_H_
-#define _NFT_DUP_H_
-
-struct nft_dup_inet {
-       enum nft_registers      sreg_addr:8;
-       enum nft_registers      sreg_dev:8;
-};
-
-#endif /* _NFT_DUP_H_ */
index ebf809eed33add7905ddd13abf98712a833ae0e0..dbe1b911a24d31e920f4c31d3c945857b760424b 100644 (file)
@@ -1133,6 +1133,11 @@ struct sctp_input_cb {
 };
 #define SCTP_INPUT_CB(__skb)   ((struct sctp_input_cb *)&((__skb)->cb[0]))
 
+struct sctp_output_cb {
+       struct sk_buff *last;
+};
+#define SCTP_OUTPUT_CB(__skb)  ((struct sctp_output_cb *)&((__skb)->cb[0]))
+
 static inline const struct sk_buff *sctp_gso_headskb(const struct sk_buff *skb)
 {
        const struct sctp_chunk *chunk = SCTP_INPUT_CB(skb)->chunk;
index 70c273777fe9fe27b2ef1ba7c2c80970da8ea5c4..7f84ea3e217cf5e3f78698ee63bc9dced179caed 100644 (file)
@@ -109,8 +109,7 @@ struct tls_sw_context_rx {
 
        struct strparser strp;
        void (*saved_data_ready)(struct sock *sk);
-       unsigned int (*sk_poll)(struct file *file, struct socket *sock,
-                               struct poll_table_struct *wait);
+       __poll_t (*sk_poll_mask)(struct socket *sock, __poll_t events);
        struct sk_buff *recv_pkt;
        u8 control;
        bool decrypted;
@@ -225,8 +224,7 @@ void tls_sw_free_resources_tx(struct sock *sk);
 void tls_sw_free_resources_rx(struct sock *sk);
 int tls_sw_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
                   int nonblock, int flags, int *addr_len);
-unsigned int tls_sw_poll(struct file *file, struct socket *sock,
-                        struct poll_table_struct *wait);
+__poll_t tls_sw_poll_mask(struct socket *sock, __poll_t events);
 ssize_t tls_sw_splice_read(struct socket *sock, loff_t *ppos,
                           struct pipe_inode_info *pipe,
                           size_t len, unsigned int flags);
index 2043e1a8f851aee28579436d1d34d4d959b78fbd..4c6241bc203931dcc6b74de5be72349e741cb6be 100644 (file)
@@ -2093,10 +2093,7 @@ struct ib_flow_attr {
        u32          flags;
        u8           num_of_specs;
        u8           port;
-       /* Following are the optional layers according to user request
-        * struct ib_flow_spec_xxx
-        * struct ib_flow_spec_yyy
-        */
+       union ib_flow_spec flows[];
 };
 
 struct ib_flow {
diff --git a/include/soc/qcom/cmd-db.h b/include/soc/qcom/cmd-db.h
new file mode 100644 (file)
index 0000000..578180c
--- /dev/null
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2016-2018, The Linux Foundation. All rights reserved. */
+
+#ifndef __QCOM_COMMAND_DB_H__
+#define __QCOM_COMMAND_DB_H__
+
+
+enum cmd_db_hw_type {
+       CMD_DB_HW_INVALID = 0,
+       CMD_DB_HW_MIN     = 3,
+       CMD_DB_HW_ARC     = CMD_DB_HW_MIN,
+       CMD_DB_HW_VRM     = 4,
+       CMD_DB_HW_BCM     = 5,
+       CMD_DB_HW_MAX     = CMD_DB_HW_BCM,
+       CMD_DB_HW_ALL     = 0xff,
+};
+
+#if IS_ENABLED(CONFIG_QCOM_COMMAND_DB)
+u32 cmd_db_read_addr(const char *resource_id);
+
+int cmd_db_read_aux_data(const char *resource_id, u8 *data, size_t len);
+
+size_t cmd_db_read_aux_data_len(const char *resource_id);
+
+enum cmd_db_hw_type cmd_db_read_slave_id(const char *resource_id);
+
+int cmd_db_ready(void);
+#else
+static inline u32 cmd_db_read_addr(const char *resource_id)
+{ return 0; }
+
+static inline int cmd_db_read_aux_data(const char *resource_id, u8 *data,
+                                      size_t len)
+{ return -ENODEV; }
+
+static inline size_t cmd_db_read_aux_data_len(const char *resource_id)
+{ return -ENODEV; }
+
+static inline enum cmd_db_hw_type cmd_db_read_slave_id(const char *resource_id)
+{ return -ENODEV; }
+
+static inline int cmd_db_ready(void)
+{ return -ENODEV; }
+#endif /* CONFIG_QCOM_COMMAND_DB */
+#endif /* __QCOM_COMMAND_DB_H__ */
index 1fae9c7800d1fb930d0b89db6579cdb38c1fc565..b6cf3221152076df1cda946dfef9fdd3183353f3 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef __SOC_TEGRA_CPUIDLE_H__
 #define __SOC_TEGRA_CPUIDLE_H__
 
-#if defined(CONFIG_ARM) && defined(CONFIG_CPU_IDLE)
+#if defined(CONFIG_ARM) && defined(CONFIG_ARCH_TEGRA) && defined(CONFIG_CPU_IDLE)
 void tegra_cpuidle_pcie_irqs_in_use(void);
 #else
 static inline void tegra_cpuidle_pcie_irqs_in_use(void)
index 233bae954970ac9af71c172b932ee9d56a4c9f84..b43f37fea09697c3b9ea6ea05bfcfe2d80a05ad0 100644 (file)
@@ -9,6 +9,7 @@
 #ifndef __SOC_TEGRA_MC_H__
 #define __SOC_TEGRA_MC_H__
 
+#include <linux/reset-controller.h>
 #include <linux/types.h>
 
 struct clk;
@@ -95,6 +96,30 @@ static inline void tegra_smmu_remove(struct tegra_smmu *smmu)
 }
 #endif
 
+struct tegra_mc_reset {
+       const char *name;
+       unsigned long id;
+       unsigned int control;
+       unsigned int status;
+       unsigned int reset;
+       unsigned int bit;
+};
+
+struct tegra_mc_reset_ops {
+       int (*hotreset_assert)(struct tegra_mc *mc,
+                              const struct tegra_mc_reset *rst);
+       int (*hotreset_deassert)(struct tegra_mc *mc,
+                                const struct tegra_mc_reset *rst);
+       int (*block_dma)(struct tegra_mc *mc,
+                        const struct tegra_mc_reset *rst);
+       bool (*dma_idling)(struct tegra_mc *mc,
+                          const struct tegra_mc_reset *rst);
+       int (*unblock_dma)(struct tegra_mc *mc,
+                          const struct tegra_mc_reset *rst);
+       int (*reset_status)(struct tegra_mc *mc,
+                           const struct tegra_mc_reset *rst);
+};
+
 struct tegra_mc_soc {
        const struct tegra_mc_client *clients;
        unsigned int num_clients;
@@ -108,12 +133,18 @@ struct tegra_mc_soc {
        u8 client_id_mask;
 
        const struct tegra_smmu_soc *smmu;
+
+       u32 intmask;
+
+       const struct tegra_mc_reset_ops *reset_ops;
+       const struct tegra_mc_reset *resets;
+       unsigned int num_resets;
 };
 
 struct tegra_mc {
        struct device *dev;
        struct tegra_smmu *smmu;
-       void __iomem *regs;
+       void __iomem *regs, *regs2;
        struct clk *clk;
        int irq;
 
@@ -122,6 +153,10 @@ struct tegra_mc {
 
        struct tegra_mc_timing *timings;
        unsigned int num_timings;
+
+       struct reset_controller_dev reset;
+
+       spinlock_t lock;
 };
 
 void tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
index 50ed3f8bf534a6ceb627f9afeb70cff7cd0b51a5..53df203b8057afd417ebbcb93a298f51af791a49 100644 (file)
@@ -1,6 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 /*
- * Copyright (c) 2017 Oracle.  All rights reserved.
+ * Copyright (c) 2017, 2018 Oracle.  All rights reserved.
+ *
+ * Trace point definitions for the "rpcrdma" subsystem.
  */
 #undef TRACE_SYSTEM
 #define TRACE_SYSTEM rpcrdma
@@ -528,24 +530,54 @@ TRACE_EVENT(xprtrdma_post_send,
 
 TRACE_EVENT(xprtrdma_post_recv,
        TP_PROTO(
-               const struct rpcrdma_rep *rep,
+               const struct ib_cqe *cqe
+       ),
+
+       TP_ARGS(cqe),
+
+       TP_STRUCT__entry(
+               __field(const void *, cqe)
+       ),
+
+       TP_fast_assign(
+               __entry->cqe = cqe;
+       ),
+
+       TP_printk("cqe=%p",
+               __entry->cqe
+       )
+);
+
+TRACE_EVENT(xprtrdma_post_recvs,
+       TP_PROTO(
+               const struct rpcrdma_xprt *r_xprt,
+               unsigned int count,
                int status
        ),
 
-       TP_ARGS(rep, status),
+       TP_ARGS(r_xprt, count, status),
 
        TP_STRUCT__entry(
-               __field(const void *, rep)
+               __field(const void *, r_xprt)
+               __field(unsigned int, count)
                __field(int, status)
+               __field(int, posted)
+               __string(addr, rpcrdma_addrstr(r_xprt))
+               __string(port, rpcrdma_portstr(r_xprt))
        ),
 
        TP_fast_assign(
-               __entry->rep = rep;
+               __entry->r_xprt = r_xprt;
+               __entry->count = count;
                __entry->status = status;
+               __entry->posted = r_xprt->rx_buf.rb_posted_receives;
+               __assign_str(addr, rpcrdma_addrstr(r_xprt));
+               __assign_str(port, rpcrdma_portstr(r_xprt));
        ),
 
-       TP_printk("rep=%p status=%d",
-               __entry->rep, __entry->status
+       TP_printk("peer=[%s]:%s r_xprt=%p: %u new recvs, %d active (rc %d)",
+               __get_str(addr), __get_str(port), __entry->r_xprt,
+               __entry->count, __entry->posted, __entry->status
        )
 );
 
@@ -584,28 +616,32 @@ TRACE_EVENT(xprtrdma_wc_send,
 
 TRACE_EVENT(xprtrdma_wc_receive,
        TP_PROTO(
-               const struct rpcrdma_rep *rep,
                const struct ib_wc *wc
        ),
 
-       TP_ARGS(rep, wc),
+       TP_ARGS(wc),
 
        TP_STRUCT__entry(
-               __field(const void *, rep)
-               __field(unsigned int, byte_len)
+               __field(const void *, cqe)
+               __field(u32, byte_len)
                __field(unsigned int, status)
-               __field(unsigned int, vendor_err)
+               __field(u32, vendor_err)
        ),
 
        TP_fast_assign(
-               __entry->rep = rep;
-               __entry->byte_len = wc->byte_len;
+               __entry->cqe = wc->wr_cqe;
                __entry->status = wc->status;
-               __entry->vendor_err = __entry->status ? wc->vendor_err : 0;
+               if (wc->status) {
+                       __entry->byte_len = 0;
+                       __entry->vendor_err = wc->vendor_err;
+               } else {
+                       __entry->byte_len = wc->byte_len;
+                       __entry->vendor_err = 0;
+               }
        ),
 
-       TP_printk("rep=%p, %u bytes: %s (%u/0x%x)",
-               __entry->rep, __entry->byte_len,
+       TP_printk("cqe=%p %u bytes: %s (%u/0x%x)",
+               __entry->cqe, __entry->byte_len,
                rdma_show_wc_status(__entry->status),
                __entry->status, __entry->vendor_err
        )
@@ -616,6 +652,7 @@ DEFINE_FRWR_DONE_EVENT(xprtrdma_wc_li);
 DEFINE_FRWR_DONE_EVENT(xprtrdma_wc_li_wake);
 
 DEFINE_MR_EVENT(xprtrdma_localinv);
+DEFINE_MR_EVENT(xprtrdma_dma_map);
 DEFINE_MR_EVENT(xprtrdma_dma_unmap);
 DEFINE_MR_EVENT(xprtrdma_remoteinv);
 DEFINE_MR_EVENT(xprtrdma_recover_mr);
@@ -799,7 +836,6 @@ TRACE_EVENT(xprtrdma_allocate,
                __field(unsigned int, task_id)
                __field(unsigned int, client_id)
                __field(const void *, req)
-               __field(const void *, rep)
                __field(size_t, callsize)
                __field(size_t, rcvsize)
        ),
@@ -808,15 +844,13 @@ TRACE_EVENT(xprtrdma_allocate,
                __entry->task_id = task->tk_pid;
                __entry->client_id = task->tk_client->cl_clid;
                __entry->req = req;
-               __entry->rep = req ? req->rl_reply : NULL;
                __entry->callsize = task->tk_rqstp->rq_callsize;
                __entry->rcvsize = task->tk_rqstp->rq_rcvsize;
        ),
 
-       TP_printk("task:%u@%u req=%p rep=%p (%zu, %zu)",
+       TP_printk("task:%u@%u req=%p (%zu, %zu)",
                __entry->task_id, __entry->client_id,
-               __entry->req, __entry->rep,
-               __entry->callsize, __entry->rcvsize
+               __entry->req, __entry->callsize, __entry->rcvsize
        )
 );
 
@@ -848,8 +882,6 @@ TRACE_EVENT(xprtrdma_rpc_done,
        )
 );
 
-DEFINE_RXPRT_EVENT(xprtrdma_noreps);
-
 /**
  ** Callback events
  **/
@@ -885,6 +917,586 @@ TRACE_EVENT(xprtrdma_cb_setup,
 DEFINE_CB_EVENT(xprtrdma_cb_call);
 DEFINE_CB_EVENT(xprtrdma_cb_reply);
 
+/**
+ ** Server-side RPC/RDMA events
+ **/
+
+DECLARE_EVENT_CLASS(svcrdma_xprt_event,
+       TP_PROTO(
+               const struct svc_xprt *xprt
+       ),
+
+       TP_ARGS(xprt),
+
+       TP_STRUCT__entry(
+               __field(const void *, xprt)
+               __string(addr, xprt->xpt_remotebuf)
+       ),
+
+       TP_fast_assign(
+               __entry->xprt = xprt;
+               __assign_str(addr, xprt->xpt_remotebuf);
+       ),
+
+       TP_printk("xprt=%p addr=%s",
+               __entry->xprt, __get_str(addr)
+       )
+);
+
+#define DEFINE_XPRT_EVENT(name)                                                \
+               DEFINE_EVENT(svcrdma_xprt_event, svcrdma_xprt_##name,   \
+                               TP_PROTO(                               \
+                                       const struct svc_xprt *xprt     \
+                               ),                                      \
+                               TP_ARGS(xprt))
+
+DEFINE_XPRT_EVENT(accept);
+DEFINE_XPRT_EVENT(fail);
+DEFINE_XPRT_EVENT(free);
+
+TRACE_DEFINE_ENUM(RDMA_MSG);
+TRACE_DEFINE_ENUM(RDMA_NOMSG);
+TRACE_DEFINE_ENUM(RDMA_MSGP);
+TRACE_DEFINE_ENUM(RDMA_DONE);
+TRACE_DEFINE_ENUM(RDMA_ERROR);
+
+#define show_rpcrdma_proc(x)                                           \
+               __print_symbolic(x,                                     \
+                               { RDMA_MSG, "RDMA_MSG" },               \
+                               { RDMA_NOMSG, "RDMA_NOMSG" },           \
+                               { RDMA_MSGP, "RDMA_MSGP" },             \
+                               { RDMA_DONE, "RDMA_DONE" },             \
+                               { RDMA_ERROR, "RDMA_ERROR" })
+
+TRACE_EVENT(svcrdma_decode_rqst,
+       TP_PROTO(
+               __be32 *p,
+               unsigned int hdrlen
+       ),
+
+       TP_ARGS(p, hdrlen),
+
+       TP_STRUCT__entry(
+               __field(u32, xid)
+               __field(u32, vers)
+               __field(u32, proc)
+               __field(u32, credits)
+               __field(unsigned int, hdrlen)
+       ),
+
+       TP_fast_assign(
+               __entry->xid = be32_to_cpup(p++);
+               __entry->vers = be32_to_cpup(p++);
+               __entry->credits = be32_to_cpup(p++);
+               __entry->proc = be32_to_cpup(p);
+               __entry->hdrlen = hdrlen;
+       ),
+
+       TP_printk("xid=0x%08x vers=%u credits=%u proc=%s hdrlen=%u",
+               __entry->xid, __entry->vers, __entry->credits,
+               show_rpcrdma_proc(__entry->proc), __entry->hdrlen)
+);
+
+TRACE_EVENT(svcrdma_decode_short,
+       TP_PROTO(
+               unsigned int hdrlen
+       ),
+
+       TP_ARGS(hdrlen),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, hdrlen)
+       ),
+
+       TP_fast_assign(
+               __entry->hdrlen = hdrlen;
+       ),
+
+       TP_printk("hdrlen=%u", __entry->hdrlen)
+);
+
+DECLARE_EVENT_CLASS(svcrdma_badreq_event,
+       TP_PROTO(
+               __be32 *p
+       ),
+
+       TP_ARGS(p),
+
+       TP_STRUCT__entry(
+               __field(u32, xid)
+               __field(u32, vers)
+               __field(u32, proc)
+               __field(u32, credits)
+       ),
+
+       TP_fast_assign(
+               __entry->xid = be32_to_cpup(p++);
+               __entry->vers = be32_to_cpup(p++);
+               __entry->credits = be32_to_cpup(p++);
+               __entry->proc = be32_to_cpup(p);
+       ),
+
+       TP_printk("xid=0x%08x vers=%u credits=%u proc=%u",
+               __entry->xid, __entry->vers, __entry->credits, __entry->proc)
+);
+
+#define DEFINE_BADREQ_EVENT(name)                                      \
+               DEFINE_EVENT(svcrdma_badreq_event, svcrdma_decode_##name,\
+                               TP_PROTO(                               \
+                                       __be32 *p                       \
+                               ),                                      \
+                               TP_ARGS(p))
+
+DEFINE_BADREQ_EVENT(badvers);
+DEFINE_BADREQ_EVENT(drop);
+DEFINE_BADREQ_EVENT(badproc);
+DEFINE_BADREQ_EVENT(parse);
+
+DECLARE_EVENT_CLASS(svcrdma_segment_event,
+       TP_PROTO(
+               u32 handle,
+               u32 length,
+               u64 offset
+       ),
+
+       TP_ARGS(handle, length, offset),
+
+       TP_STRUCT__entry(
+               __field(u32, handle)
+               __field(u32, length)
+               __field(u64, offset)
+       ),
+
+       TP_fast_assign(
+               __entry->handle = handle;
+               __entry->length = length;
+               __entry->offset = offset;
+       ),
+
+       TP_printk("%u@0x%016llx:0x%08x",
+               __entry->length, (unsigned long long)__entry->offset,
+               __entry->handle
+       )
+);
+
+#define DEFINE_SEGMENT_EVENT(name)                                     \
+               DEFINE_EVENT(svcrdma_segment_event, svcrdma_encode_##name,\
+                               TP_PROTO(                               \
+                                       u32 handle,                     \
+                                       u32 length,                     \
+                                       u64 offset                      \
+                               ),                                      \
+                               TP_ARGS(handle, length, offset))
+
+DEFINE_SEGMENT_EVENT(rseg);
+DEFINE_SEGMENT_EVENT(wseg);
+
+DECLARE_EVENT_CLASS(svcrdma_chunk_event,
+       TP_PROTO(
+               u32 length
+       ),
+
+       TP_ARGS(length),
+
+       TP_STRUCT__entry(
+               __field(u32, length)
+       ),
+
+       TP_fast_assign(
+               __entry->length = length;
+       ),
+
+       TP_printk("length=%u",
+               __entry->length
+       )
+);
+
+#define DEFINE_CHUNK_EVENT(name)                                       \
+               DEFINE_EVENT(svcrdma_chunk_event, svcrdma_encode_##name,\
+                               TP_PROTO(                               \
+                                       u32 length                      \
+                               ),                                      \
+                               TP_ARGS(length))
+
+DEFINE_CHUNK_EVENT(pzr);
+DEFINE_CHUNK_EVENT(write);
+DEFINE_CHUNK_EVENT(reply);
+
+TRACE_EVENT(svcrdma_encode_read,
+       TP_PROTO(
+               u32 length,
+               u32 position
+       ),
+
+       TP_ARGS(length, position),
+
+       TP_STRUCT__entry(
+               __field(u32, length)
+               __field(u32, position)
+       ),
+
+       TP_fast_assign(
+               __entry->length = length;
+               __entry->position = position;
+       ),
+
+       TP_printk("length=%u position=%u",
+               __entry->length, __entry->position
+       )
+);
+
+DECLARE_EVENT_CLASS(svcrdma_error_event,
+       TP_PROTO(
+               __be32 xid
+       ),
+
+       TP_ARGS(xid),
+
+       TP_STRUCT__entry(
+               __field(u32, xid)
+       ),
+
+       TP_fast_assign(
+               __entry->xid = be32_to_cpu(xid);
+       ),
+
+       TP_printk("xid=0x%08x",
+               __entry->xid
+       )
+);
+
+#define DEFINE_ERROR_EVENT(name)                                       \
+               DEFINE_EVENT(svcrdma_error_event, svcrdma_err_##name,   \
+                               TP_PROTO(                               \
+                                       __be32 xid                      \
+                               ),                                      \
+                               TP_ARGS(xid))
+
+DEFINE_ERROR_EVENT(vers);
+DEFINE_ERROR_EVENT(chunk);
+
+/**
+ ** Server-side RDMA API events
+ **/
+
+TRACE_EVENT(svcrdma_dma_map_page,
+       TP_PROTO(
+               const struct svcxprt_rdma *rdma,
+               const void *page
+       ),
+
+       TP_ARGS(rdma, page),
+
+       TP_STRUCT__entry(
+               __field(const void *, page);
+               __string(device, rdma->sc_cm_id->device->name)
+               __string(addr, rdma->sc_xprt.xpt_remotebuf)
+       ),
+
+       TP_fast_assign(
+               __entry->page = page;
+               __assign_str(device, rdma->sc_cm_id->device->name);
+               __assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
+       ),
+
+       TP_printk("addr=%s device=%s page=%p",
+               __get_str(addr), __get_str(device), __entry->page
+       )
+);
+
+TRACE_EVENT(svcrdma_dma_map_rwctx,
+       TP_PROTO(
+               const struct svcxprt_rdma *rdma,
+               int status
+       ),
+
+       TP_ARGS(rdma, status),
+
+       TP_STRUCT__entry(
+               __field(int, status)
+               __string(device, rdma->sc_cm_id->device->name)
+               __string(addr, rdma->sc_xprt.xpt_remotebuf)
+       ),
+
+       TP_fast_assign(
+               __entry->status = status;
+               __assign_str(device, rdma->sc_cm_id->device->name);
+               __assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
+       ),
+
+       TP_printk("addr=%s device=%s status=%d",
+               __get_str(addr), __get_str(device), __entry->status
+       )
+);
+
+TRACE_EVENT(svcrdma_send_failed,
+       TP_PROTO(
+               const struct svc_rqst *rqst,
+               int status
+       ),
+
+       TP_ARGS(rqst, status),
+
+       TP_STRUCT__entry(
+               __field(int, status)
+               __field(u32, xid)
+               __field(const void *, xprt)
+               __string(addr, rqst->rq_xprt->xpt_remotebuf)
+       ),
+
+       TP_fast_assign(
+               __entry->status = status;
+               __entry->xid = __be32_to_cpu(rqst->rq_xid);
+               __entry->xprt = rqst->rq_xprt;
+               __assign_str(addr, rqst->rq_xprt->xpt_remotebuf);
+       ),
+
+       TP_printk("xprt=%p addr=%s xid=0x%08x status=%d",
+               __entry->xprt, __get_str(addr),
+               __entry->xid, __entry->status
+       )
+);
+
+DECLARE_EVENT_CLASS(svcrdma_sendcomp_event,
+       TP_PROTO(
+               const struct ib_wc *wc
+       ),
+
+       TP_ARGS(wc),
+
+       TP_STRUCT__entry(
+               __field(const void *, cqe)
+               __field(unsigned int, status)
+               __field(unsigned int, vendor_err)
+       ),
+
+       TP_fast_assign(
+               __entry->cqe = wc->wr_cqe;
+               __entry->status = wc->status;
+               if (wc->status)
+                       __entry->vendor_err = wc->vendor_err;
+               else
+                       __entry->vendor_err = 0;
+       ),
+
+       TP_printk("cqe=%p status=%s (%u/0x%x)",
+               __entry->cqe, rdma_show_wc_status(__entry->status),
+               __entry->status, __entry->vendor_err
+       )
+);
+
+#define DEFINE_SENDCOMP_EVENT(name)                                    \
+               DEFINE_EVENT(svcrdma_sendcomp_event, svcrdma_wc_##name, \
+                               TP_PROTO(                               \
+                                       const struct ib_wc *wc          \
+                               ),                                      \
+                               TP_ARGS(wc))
+
+TRACE_EVENT(svcrdma_post_send,
+       TP_PROTO(
+               const struct ib_send_wr *wr,
+               int status
+       ),
+
+       TP_ARGS(wr, status),
+
+       TP_STRUCT__entry(
+               __field(const void *, cqe)
+               __field(unsigned int, num_sge)
+               __field(u32, inv_rkey)
+               __field(int, status)
+       ),
+
+       TP_fast_assign(
+               __entry->cqe = wr->wr_cqe;
+               __entry->num_sge = wr->num_sge;
+               __entry->inv_rkey = (wr->opcode == IB_WR_SEND_WITH_INV) ?
+                                       wr->ex.invalidate_rkey : 0;
+               __entry->status = status;
+       ),
+
+       TP_printk("cqe=%p num_sge=%u inv_rkey=0x%08x status=%d",
+               __entry->cqe, __entry->num_sge,
+               __entry->inv_rkey, __entry->status
+       )
+);
+
+DEFINE_SENDCOMP_EVENT(send);
+
+TRACE_EVENT(svcrdma_post_recv,
+       TP_PROTO(
+               const struct ib_recv_wr *wr,
+               int status
+       ),
+
+       TP_ARGS(wr, status),
+
+       TP_STRUCT__entry(
+               __field(const void *, cqe)
+               __field(int, status)
+       ),
+
+       TP_fast_assign(
+               __entry->cqe = wr->wr_cqe;
+               __entry->status = status;
+       ),
+
+       TP_printk("cqe=%p status=%d",
+               __entry->cqe, __entry->status
+       )
+);
+
+TRACE_EVENT(svcrdma_wc_receive,
+       TP_PROTO(
+               const struct ib_wc *wc
+       ),
+
+       TP_ARGS(wc),
+
+       TP_STRUCT__entry(
+               __field(const void *, cqe)
+               __field(u32, byte_len)
+               __field(unsigned int, status)
+               __field(u32, vendor_err)
+       ),
+
+       TP_fast_assign(
+               __entry->cqe = wc->wr_cqe;
+               __entry->status = wc->status;
+               if (wc->status) {
+                       __entry->byte_len = 0;
+                       __entry->vendor_err = wc->vendor_err;
+               } else {
+                       __entry->byte_len = wc->byte_len;
+                       __entry->vendor_err = 0;
+               }
+       ),
+
+       TP_printk("cqe=%p byte_len=%u status=%s (%u/0x%x)",
+               __entry->cqe, __entry->byte_len,
+               rdma_show_wc_status(__entry->status),
+               __entry->status, __entry->vendor_err
+       )
+);
+
+TRACE_EVENT(svcrdma_post_rw,
+       TP_PROTO(
+               const void *cqe,
+               int sqecount,
+               int status
+       ),
+
+       TP_ARGS(cqe, sqecount, status),
+
+       TP_STRUCT__entry(
+               __field(const void *, cqe)
+               __field(int, sqecount)
+               __field(int, status)
+       ),
+
+       TP_fast_assign(
+               __entry->cqe = cqe;
+               __entry->sqecount = sqecount;
+               __entry->status = status;
+       ),
+
+       TP_printk("cqe=%p sqecount=%d status=%d",
+               __entry->cqe, __entry->sqecount, __entry->status
+       )
+);
+
+DEFINE_SENDCOMP_EVENT(read);
+DEFINE_SENDCOMP_EVENT(write);
+
+TRACE_EVENT(svcrdma_cm_event,
+       TP_PROTO(
+               const struct rdma_cm_event *event,
+               const struct sockaddr *sap
+       ),
+
+       TP_ARGS(event, sap),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, event)
+               __field(int, status)
+               __array(__u8, addr, INET6_ADDRSTRLEN + 10)
+       ),
+
+       TP_fast_assign(
+               __entry->event = event->event;
+               __entry->status = event->status;
+               snprintf(__entry->addr, sizeof(__entry->addr) - 1,
+                        "%pISpc", sap);
+       ),
+
+       TP_printk("addr=%s event=%s (%u/%d)",
+               __entry->addr,
+               rdma_show_cm_event(__entry->event),
+               __entry->event, __entry->status
+       )
+);
+
+TRACE_EVENT(svcrdma_qp_error,
+       TP_PROTO(
+               const struct ib_event *event,
+               const struct sockaddr *sap
+       ),
+
+       TP_ARGS(event, sap),
+
+       TP_STRUCT__entry(
+               __field(unsigned int, event)
+               __string(device, event->device->name)
+               __array(__u8, addr, INET6_ADDRSTRLEN + 10)
+       ),
+
+       TP_fast_assign(
+               __entry->event = event->event;
+               __assign_str(device, event->device->name);
+               snprintf(__entry->addr, sizeof(__entry->addr) - 1,
+                        "%pISpc", sap);
+       ),
+
+       TP_printk("addr=%s dev=%s event=%s (%u)",
+               __entry->addr, __get_str(device),
+               rdma_show_ib_event(__entry->event), __entry->event
+       )
+);
+
+DECLARE_EVENT_CLASS(svcrdma_sendqueue_event,
+       TP_PROTO(
+               const struct svcxprt_rdma *rdma
+       ),
+
+       TP_ARGS(rdma),
+
+       TP_STRUCT__entry(
+               __field(int, avail)
+               __field(int, depth)
+               __string(addr, rdma->sc_xprt.xpt_remotebuf)
+       ),
+
+       TP_fast_assign(
+               __entry->avail = atomic_read(&rdma->sc_sq_avail);
+               __entry->depth = rdma->sc_sq_depth;
+               __assign_str(addr, rdma->sc_xprt.xpt_remotebuf);
+       ),
+
+       TP_printk("addr=%s sc_sq_avail=%d/%d",
+               __get_str(addr), __entry->avail, __entry->depth
+       )
+);
+
+#define DEFINE_SQ_EVENT(name)                                          \
+               DEFINE_EVENT(svcrdma_sendqueue_event, svcrdma_sq_##name,\
+                               TP_PROTO(                               \
+                                       const struct svcxprt_rdma *rdma \
+                               ),                                      \
+                               TP_ARGS(rdma))
+
+DEFINE_SQ_EVENT(full);
+DEFINE_SQ_EVENT(retry);
+
 #endif /* _TRACE_RPCRDMA_H */
 
 #include <trace/define_trace.h>
index 75846164290e9acaa9b2fbead09bdebc5422104c..d00221345c1988ff59de79f47401903d560c55e0 100644 (file)
@@ -109,7 +109,7 @@ struct iocb {
 #undef IFLITTLE
 
 struct __aio_sigset {
-       sigset_t __user *sigmask;
+       const sigset_t __user   *sigmask;
        size_t          sigsetsize;
 };
 
index b02c41e53d5616a3124e16dbec17250654a790b4..b6270a3b38e9f3fb410e8c80d8658b2c01a8ef96 100644 (file)
@@ -677,10 +677,10 @@ struct kvm_ioeventfd {
 };
 
 #define KVM_X86_DISABLE_EXITS_MWAIT          (1 << 0)
-#define KVM_X86_DISABLE_EXITS_HTL            (1 << 1)
+#define KVM_X86_DISABLE_EXITS_HLT            (1 << 1)
 #define KVM_X86_DISABLE_EXITS_PAUSE          (1 << 2)
 #define KVM_X86_DISABLE_VALID_EXITS          (KVM_X86_DISABLE_EXITS_MWAIT | \
-                                              KVM_X86_DISABLE_EXITS_HTL | \
+                                              KVM_X86_DISABLE_EXITS_HLT | \
                                               KVM_X86_DISABLE_EXITS_PAUSE)
 
 /* for KVM_ENABLE_CAP */
@@ -948,6 +948,7 @@ struct kvm_ppc_resize_hpt {
 #define KVM_CAP_S390_BPB 152
 #define KVM_CAP_GET_MSR_FEATURES 153
 #define KVM_CAP_HYPERV_EVENTFD 154
+#define KVM_CAP_HYPERV_TLBFLUSH 155
 
 #ifdef KVM_CAP_IRQ_ROUTING
 
index c712eb6879f116010b09815753c750fa678afd87..336014bf8868c3f04b92cdbf31bdf2ccafc68a71 100644 (file)
@@ -112,7 +112,7 @@ enum ip_conntrack_status {
                                 IPS_EXPECTED | IPS_CONFIRMED | IPS_DYING |
                                 IPS_SEQ_ADJUST | IPS_TEMPLATE | IPS_OFFLOAD),
 
-       __IPS_MAX_BIT = 14,
+       __IPS_MAX_BIT = 15,
 };
 
 /* Connection tracking event types */
index c9bf74b94f3704ca66791df3564f01569ec4ba30..89438e68dc030fd0ecf579bf5158e1042435a6b7 100644 (file)
@@ -266,7 +266,7 @@ enum nft_rule_compat_attributes {
  * @NFT_SET_INTERVAL: set contains intervals
  * @NFT_SET_MAP: set is used as a dictionary
  * @NFT_SET_TIMEOUT: set uses timeouts
- * @NFT_SET_EVAL: set contains expressions for evaluation
+ * @NFT_SET_EVAL: set can be updated from the evaluation path
  * @NFT_SET_OBJECT: set contains stateful objects
  */
 enum nft_set_flags {
index 28b36545de2445c338d404ba15b207eb9d0eaab1..27e4e441caacdbd590a1afad65c6f5c1b3ec3edd 100644 (file)
  *     only the %NL80211_ATTR_IE data is used and updated with this command.
  *
  * @NL80211_CMD_SET_PMK: For offloaded 4-Way handshake, set the PMK or PMK-R0
- *     for the given authenticator address (specified with &NL80211_ATTR_MAC).
- *     When &NL80211_ATTR_PMKR0_NAME is set, &NL80211_ATTR_PMK specifies the
+ *     for the given authenticator address (specified with %NL80211_ATTR_MAC).
+ *     When %NL80211_ATTR_PMKR0_NAME is set, %NL80211_ATTR_PMK specifies the
  *     PMK-R0, otherwise it specifies the PMK.
  * @NL80211_CMD_DEL_PMK: For offloaded 4-Way handshake, delete the previously
  *     configured PMK for the authenticator address identified by
- *     &NL80211_ATTR_MAC.
+ *     %NL80211_ATTR_MAC.
  * @NL80211_CMD_PORT_AUTHORIZED: An event that indicates that the 4 way
  *     handshake was completed successfully by the driver. The BSSID is
- *     specified with &NL80211_ATTR_MAC. Drivers that support 4 way handshake
+ *     specified with %NL80211_ATTR_MAC. Drivers that support 4 way handshake
  *     offload should send this event after indicating 802.11 association with
- *     &NL80211_CMD_CONNECT or &NL80211_CMD_ROAM. If the 4 way handshake failed
- *     &NL80211_CMD_DISCONNECT should be indicated instead.
+ *     %NL80211_CMD_CONNECT or %NL80211_CMD_ROAM. If the 4 way handshake failed
+ *     %NL80211_CMD_DISCONNECT should be indicated instead.
  *
  * @NL80211_CMD_CONTROL_PORT_FRAME: Control Port (e.g. PAE) frame TX request
  *     and RX notification.  This command is used both as a request to transmit
  *     initiated the connection through the connect request.
  *
  * @NL80211_CMD_STA_OPMODE_CHANGED: An event that notify station's
- *     ht opmode or vht opmode changes using any of &NL80211_ATTR_SMPS_MODE,
- *     &NL80211_ATTR_CHANNEL_WIDTH,&NL80211_ATTR_NSS attributes with its
- *     address(specified in &NL80211_ATTR_MAC).
+ *     ht opmode or vht opmode changes using any of %NL80211_ATTR_SMPS_MODE,
+ *     %NL80211_ATTR_CHANNEL_WIDTH,%NL80211_ATTR_NSS attributes with its
+ *     address(specified in %NL80211_ATTR_MAC).
  *
  * @NL80211_CMD_MAX: highest used command number
  * @__NL80211_CMD_AFTER_LAST: internal use
@@ -2218,7 +2218,7 @@ enum nl80211_commands {
  * @NL80211_ATTR_EXTERNAL_AUTH_ACTION: Identify the requested external
  *     authentication operation (u32 attribute with an
  *     &enum nl80211_external_auth_action value). This is used with the
- *     &NL80211_CMD_EXTERNAL_AUTH request event.
+ *     %NL80211_CMD_EXTERNAL_AUTH request event.
  * @NL80211_ATTR_EXTERNAL_AUTH_SUPPORT: Flag attribute indicating that the user
  *     space supports external authentication. This attribute shall be used
  *     only with %NL80211_CMD_CONNECT request. The driver may offload
@@ -3491,7 +3491,7 @@ enum nl80211_sched_scan_match_attr {
  * @NL80211_RRF_AUTO_BW: maximum available bandwidth should be calculated
  *     base on contiguous rules and wider channels will be allowed to cross
  *     multiple contiguous/overlapping frequency ranges.
- * @NL80211_RRF_IR_CONCURRENT: See &NL80211_FREQUENCY_ATTR_IR_CONCURRENT
+ * @NL80211_RRF_IR_CONCURRENT: See %NL80211_FREQUENCY_ATTR_IR_CONCURRENT
  * @NL80211_RRF_NO_HT40MINUS: channels can't be used in HT40- operation
  * @NL80211_RRF_NO_HT40PLUS: channels can't be used in HT40+ operation
  * @NL80211_RRF_NO_80MHZ: 80MHz operation not allowed
@@ -5643,11 +5643,11 @@ enum nl80211_nan_func_attributes {
  * @NL80211_NAN_SRF_INCLUDE: present if the include bit of the SRF set.
  *     This is a flag.
  * @NL80211_NAN_SRF_BF: Bloom Filter. Present if and only if
- *     &NL80211_NAN_SRF_MAC_ADDRS isn't present. This attribute is binary.
+ *     %NL80211_NAN_SRF_MAC_ADDRS isn't present. This attribute is binary.
  * @NL80211_NAN_SRF_BF_IDX: index of the Bloom Filter. Mandatory if
- *     &NL80211_NAN_SRF_BF is present. This is a u8.
+ *     %NL80211_NAN_SRF_BF is present. This is a u8.
  * @NL80211_NAN_SRF_MAC_ADDRS: list of MAC addresses for the SRF. Present if
- *     and only if &NL80211_NAN_SRF_BF isn't present. This is a nested
+ *     and only if %NL80211_NAN_SRF_BF isn't present. This is a nested
  *     attribute. Each nested attribute is a MAC address.
  * @NUM_NL80211_NAN_SRF_ATTR: internal
  * @NL80211_NAN_SRF_ATTR_MAX: highest NAN SRF attribute
index db9f15f5db047e643780ce23a0d33f9cc599ddf4..c0d7ea0bf5b62438ca8184551b64d5d29ad7951b 100644 (file)
@@ -170,7 +170,7 @@ struct prctl_mm_map {
  * asking selinux for a specific new context (e.g. with runcon) will result
  * in execve returning -EPERM.
  *
- * See Documentation/prctl/no_new_privs.txt for more details.
+ * See Documentation/userspace-api/no_new_privs.rst for more details.
  */
 #define PR_SET_NO_NEW_PRIVS    38
 #define PR_GET_NO_NEW_PRIVS    39
index 225eb38705dc065271938cbd87a0634be4d45948..e14c6dab4223735f1e558d63cc278313d19628ed 100644 (file)
@@ -1,15 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
 /*
  * Copyright (c) 2016, Linaro Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 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.
  */
 
 #ifndef _UAPI_RPMSG_H_
index 13d98e6e0db1a86f46cc7d77b5652bef0c8682d2..74e520fb944f7dbdf6426e75b5db5312a80b05ee 100644 (file)
@@ -230,6 +230,14 @@ struct uac1_output_terminal_descriptor {
 #define UAC_OUTPUT_TERMINAL_COMMUNICATION_SPEAKER      0x306
 #define UAC_OUTPUT_TERMINAL_LOW_FREQ_EFFECTS_SPEAKER   0x307
 
+/* Terminals - 2.4 Bi-directional Terminal Types */
+#define UAC_BIDIR_TERMINAL_UNDEFINED                   0x400
+#define UAC_BIDIR_TERMINAL_HANDSET                     0x401
+#define UAC_BIDIR_TERMINAL_HEADSET                     0x402
+#define UAC_BIDIR_TERMINAL_SPEAKER_PHONE               0x403
+#define UAC_BIDIR_TERMINAL_ECHO_SUPPRESSING            0x404
+#define UAC_BIDIR_TERMINAL_ECHO_CANCELING              0x405
+
 /* Set bControlSize = 2 as default setting */
 #define UAC_DT_FEATURE_UNIT_SIZE(ch)           (7 + ((ch) + 1) * 2)
 
index 308e2096291f8f109185848f3baea431253161da..449132c76b1cc809fc0c9d4cd90e3f56ed44442b 100644 (file)
 /* We've given up on this device. */
 #define VIRTIO_CONFIG_S_FAILED         0x80
 
-/* Some virtio feature bits (currently bits 28 through 32) are reserved for the
- * transport being used (eg. virtio_ring), the rest are per-device feature
- * bits. */
+/*
+ * Virtio feature bits VIRTIO_TRANSPORT_F_START through
+ * VIRTIO_TRANSPORT_F_END are reserved for the transport
+ * being used (e.g. virtio_ring, virtio_pci etc.), the
+ * rest are per-device feature bits.
+ */
 #define VIRTIO_TRANSPORT_F_START       28
-#define VIRTIO_TRANSPORT_F_END         34
+#define VIRTIO_TRANSPORT_F_END         38
 
 #ifndef VIRTIO_CONFIG_NO_LEGACY
 /* Do we get callbacks when the ring is completely used, even if we've
@@ -71,4 +74,9 @@
  * this is for compatibility with legacy systems.
  */
 #define VIRTIO_F_IOMMU_PLATFORM                33
+
+/*
+ * Does the device support Single Root I/O Virtualization?
+ */
+#define VIRTIO_F_SR_IOV                        37
 #endif /* _UAPI_LINUX_VIRTIO_CONFIG_H */
diff --git a/include/video/auo_k190xfb.h b/include/video/auo_k190xfb.h
deleted file mode 100644 (file)
index ac329ee..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Definitions for AUO-K190X framebuffer drivers
- *
- * Copyright (C) 2012 Heiko Stuebner <heiko@sntech.de>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef _LINUX_VIDEO_AUO_K190XFB_H_
-#define _LINUX_VIDEO_AUO_K190XFB_H_
-
-/* Controller standby command needs a param */
-#define AUOK190X_QUIRK_STANDBYPARAM    (1 << 0)
-
-/* Controller standby is completely broken */
-#define AUOK190X_QUIRK_STANDBYBROKEN   (1 << 1)
-
-/*
- * Resolutions for the displays
- */
-#define AUOK190X_RESOLUTION_800_600            0
-#define AUOK190X_RESOLUTION_1024_768           1
-#define AUOK190X_RESOLUTION_600_800            4
-#define AUOK190X_RESOLUTION_768_1024           5
-
-/*
- * struct used by auok190x. board specific stuff comes from *board
- */
-struct auok190xfb_par {
-       struct fb_info *info;
-       struct auok190x_board *board;
-
-       struct regulator *regulator;
-
-       struct mutex io_lock;
-       struct delayed_work work;
-       wait_queue_head_t waitq;
-       int resolution;
-       int rotation;
-       int consecutive_threshold;
-       int update_cnt;
-
-       /* panel and controller informations */
-       int epd_type;
-       int panel_size_int;
-       int panel_size_float;
-       int panel_model;
-       int tcon_version;
-       int lut_version;
-
-       /* individual controller callbacks */
-       void (*update_partial)(struct auok190xfb_par *par, u16 y1, u16 y2);
-       void (*update_all)(struct auok190xfb_par *par);
-       bool (*need_refresh)(struct auok190xfb_par *par);
-       void (*init)(struct auok190xfb_par *par);
-       void (*recover)(struct auok190xfb_par *par);
-
-       int update_mode; /* mode to use for updates */
-       int last_mode; /* update mode last used */
-       int flash;
-
-       /* power management */
-       int autosuspend_delay;
-       bool standby;
-       bool manual_standby;
-};
-
-/**
- * Board specific platform-data
- * @init:              initialize the controller interface
- * @cleanup:           cleanup the controller interface
- * @wait_for_rdy:      wait until the controller is not busy anymore
- * @set_ctl:           change an interface control
- * @set_hdb:           write a value to the data register
- * @get_hdb:           read a value from the data register
- * @setup_irq:         method to setup the irq handling on the busy gpio
- * @gpio_nsleep:       sleep gpio
- * @gpio_nrst:         reset gpio
- * @gpio_nbusy:                busy gpio
- * @resolution:                one of the AUOK190X_RESOLUTION constants
- * @rotation:          rotation of the framebuffer
- * @quirks:            controller quirks to honor
- * @fps:               frames per second for defio
- */
-struct auok190x_board {
-       int (*init)(struct auok190xfb_par *);
-       void (*cleanup)(struct auok190xfb_par *);
-       int (*wait_for_rdy)(struct auok190xfb_par *);
-
-       void (*set_ctl)(struct auok190xfb_par *, unsigned char, u8);
-       void (*set_hdb)(struct auok190xfb_par *, u16);
-       u16 (*get_hdb)(struct auok190xfb_par *);
-
-       int (*setup_irq)(struct fb_info *);
-
-       int gpio_nsleep;
-       int gpio_nrst;
-       int gpio_nbusy;
-
-       int resolution;
-       int quirks;
-       int fps;
-};
-
-#endif
index f706b0fed399df1f6aec9dc56580cf3878e8cd72..84aa976ca4ea44e161fd3cd9f54b60d015761ca9 100644 (file)
@@ -3,7 +3,6 @@
 #define __ASM_SH_MOBILE_LCDC_H__
 
 #include <linux/fb.h>
-#include <video/sh_mobile_meram.h>
 
 /* Register definitions */
 #define _LDDCKR                        0x410
@@ -184,7 +183,6 @@ struct sh_mobile_lcdc_chan_cfg {
        struct sh_mobile_lcdc_panel_cfg panel_cfg;
        struct sh_mobile_lcdc_bl_info bl_info;
        struct sh_mobile_lcdc_sys_bus_cfg sys_bus_cfg; /* only for SYSn I/F */
-       const struct sh_mobile_meram_cfg *meram_cfg;
 
        struct platform_device *tx_dev; /* HDMI/DSI transmitter device */
 };
@@ -193,7 +191,6 @@ struct sh_mobile_lcdc_info {
        int clock_source;
        struct sh_mobile_lcdc_chan_cfg ch[2];
        struct sh_mobile_lcdc_overlay_cfg overlays[4];
-       struct sh_mobile_meram_info *meram_dev;
 };
 
 #endif /* __ASM_SH_MOBILE_LCDC_H__ */
diff --git a/include/video/sh_mobile_meram.h b/include/video/sh_mobile_meram.h
deleted file mode 100644 (file)
index f4efc21..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __VIDEO_SH_MOBILE_MERAM_H__
-#define __VIDEO_SH_MOBILE_MERAM_H__
-
-/* For sh_mobile_meram_info.addr_mode */
-enum {
-       SH_MOBILE_MERAM_MODE0 = 0,
-       SH_MOBILE_MERAM_MODE1
-};
-
-enum {
-       SH_MOBILE_MERAM_PF_NV = 0,
-       SH_MOBILE_MERAM_PF_RGB,
-       SH_MOBILE_MERAM_PF_NV24
-};
-
-
-struct sh_mobile_meram_priv;
-
-/*
- * struct sh_mobile_meram_info - MERAM platform data
- * @reserved_icbs: Bitmask of reserved ICBs (for instance used through UIO)
- */
-struct sh_mobile_meram_info {
-       int                             addr_mode;
-       u32                             reserved_icbs;
-       struct sh_mobile_meram_priv     *priv;
-       struct platform_device          *pdev;
-};
-
-/* icb config */
-struct sh_mobile_meram_icb_cfg {
-       unsigned int meram_size;        /* MERAM Buffer Size to use */
-};
-
-struct sh_mobile_meram_cfg {
-       struct sh_mobile_meram_icb_cfg icb[2];
-};
-
-#if defined(CONFIG_FB_SH_MOBILE_MERAM) || \
-    defined(CONFIG_FB_SH_MOBILE_MERAM_MODULE)
-unsigned long sh_mobile_meram_alloc(struct sh_mobile_meram_info *meram_dev,
-                                   size_t size);
-void sh_mobile_meram_free(struct sh_mobile_meram_info *meram_dev,
-                         unsigned long mem, size_t size);
-void *sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev,
-                                 const struct sh_mobile_meram_cfg *cfg,
-                                 unsigned int xres, unsigned int yres,
-                                 unsigned int pixelformat,
-                                 unsigned int *pitch);
-void sh_mobile_meram_cache_free(struct sh_mobile_meram_info *dev, void *data);
-void sh_mobile_meram_cache_update(struct sh_mobile_meram_info *dev, void *data,
-                                 unsigned long base_addr_y,
-                                 unsigned long base_addr_c,
-                                 unsigned long *icb_addr_y,
-                                 unsigned long *icb_addr_c);
-#else
-static inline unsigned long
-sh_mobile_meram_alloc(struct sh_mobile_meram_info *meram_dev, size_t size)
-{
-       return 0;
-}
-
-static inline void
-sh_mobile_meram_free(struct sh_mobile_meram_info *meram_dev,
-                    unsigned long mem, size_t size)
-{
-}
-
-static inline void *
-sh_mobile_meram_cache_alloc(struct sh_mobile_meram_info *dev,
-                           const struct sh_mobile_meram_cfg *cfg,
-                           unsigned int xres, unsigned int yres,
-                           unsigned int pixelformat,
-                           unsigned int *pitch)
-{
-       return ERR_PTR(-ENODEV);
-}
-
-static inline void
-sh_mobile_meram_cache_free(struct sh_mobile_meram_info *dev, void *data)
-{
-}
-
-static inline void
-sh_mobile_meram_cache_update(struct sh_mobile_meram_info *dev, void *data,
-                            unsigned long base_addr_y,
-                            unsigned long base_addr_c,
-                            unsigned long *icb_addr_y,
-                            unsigned long *icb_addr_c)
-{
-}
-#endif
-
-#endif /* __VIDEO_SH_MOBILE_MERAM_H__  */
index 2a9510ade70181a4c10b65bdfc834d831ef8b287..e2340a4130cf932d4cc74f7883a984fe735f732d 100644 (file)
@@ -317,7 +317,7 @@ struct xenkbd_position {
  * Linux [2] and Windows [3] multi-touch support.
  *
  * [1] https://cgit.freedesktop.org/wayland/wayland/tree/protocol/wayland.xml
- * [2] https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.txt
+ * [2] https://www.kernel.org/doc/Documentation/input/multi-touch-protocol.rst
  * [3] https://msdn.microsoft.com/en-us/library/jj151564(v=vs.85).aspx
  *
  *
index d2b8b2ea097e861c1539868bfc65ca6e4ed3ae31..5a52f07259a2aab4ad5993801a6d15b5dfe5d4a3 100644 (file)
@@ -8,6 +8,21 @@ config DEFCONFIG_LIST
        default ARCH_DEFCONFIG
        default "arch/$(ARCH)/defconfig"
 
+config CC_IS_GCC
+       def_bool $(success,$(CC) --version | head -n 1 | grep -q gcc)
+
+config GCC_VERSION
+       int
+       default $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//') if CC_IS_GCC
+       default 0
+
+config CC_IS_CLANG
+       def_bool $(success,$(CC) --version | head -n 1 | grep -q clang)
+
+config CLANG_VERSION
+       int
+       default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
+
 config CONSTRUCTORS
        bool
        depends on !UML
index cfd94d48a9aa7ad719ed17e2e9f1a2d53ca028ee..5af1943ad782b415a3dd331161e9b2ecccf89210 100644 (file)
--- a/ipc/sem.c
+++ b/ipc/sem.c
@@ -85,6 +85,7 @@
 #include <linux/nsproxy.h>
 #include <linux/ipc_namespace.h>
 #include <linux/sched/wake_q.h>
+#include <linux/nospec.h>
 
 #include <linux/uaccess.h>
 #include "util.h"
@@ -368,6 +369,7 @@ static inline int sem_lock(struct sem_array *sma, struct sembuf *sops,
                              int nsops)
 {
        struct sem *sem;
+       int idx;
 
        if (nsops != 1) {
                /* Complex operation - acquire a full lock */
@@ -385,7 +387,8 @@ static inline int sem_lock(struct sem_array *sma, struct sembuf *sops,
         *
         * Both facts are tracked by use_global_mode.
         */
-       sem = &sma->sems[sops->sem_num];
+       idx = array_index_nospec(sops->sem_num, sma->sem_nsems);
+       sem = &sma->sems[idx];
 
        /*
         * Initial check for use_global_lock. Just an optimization,
@@ -638,7 +641,8 @@ static int perform_atomic_semop_slow(struct sem_array *sma, struct sem_queue *q)
        un = q->undo;
 
        for (sop = sops; sop < sops + nsops; sop++) {
-               curr = &sma->sems[sop->sem_num];
+               int idx = array_index_nospec(sop->sem_num, sma->sem_nsems);
+               curr = &sma->sems[idx];
                sem_op = sop->sem_op;
                result = curr->semval;
 
@@ -718,7 +722,9 @@ static int perform_atomic_semop(struct sem_array *sma, struct sem_queue *q)
         * until the operations can go through.
         */
        for (sop = sops; sop < sops + nsops; sop++) {
-               curr = &sma->sems[sop->sem_num];
+               int idx = array_index_nospec(sop->sem_num, sma->sem_nsems);
+
+               curr = &sma->sems[idx];
                sem_op = sop->sem_op;
                result = curr->semval;
 
@@ -1356,6 +1362,7 @@ static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum,
                return -EIDRM;
        }
 
+       semnum = array_index_nospec(semnum, sma->sem_nsems);
        curr = &sma->sems[semnum];
 
        ipc_assert_locked_object(&sma->sem_perm);
@@ -1509,6 +1516,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum,
                err = -EIDRM;
                goto out_unlock;
        }
+
+       semnum = array_index_nospec(semnum, nsems);
        curr = &sma->sems[semnum];
 
        switch (cmd) {
@@ -1945,7 +1954,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
        if (nsops > ns->sc_semopm)
                return -E2BIG;
        if (nsops > SEMOPM_FAST) {
-               sops = kvmalloc(sizeof(*sops)*nsops, GFP_KERNEL);
+               sops = kvmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
                if (sops == NULL)
                        return -ENOMEM;
        }
@@ -2081,7 +2090,8 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops,
         */
        if (nsops == 1) {
                struct sem *curr;
-               curr = &sma->sems[sops->sem_num];
+               int idx = array_index_nospec(sops->sem_num, sma->sem_nsems);
+               curr = &sma->sems[idx];
 
                if (alter) {
                        if (sma->complex_count) {
index 29978ee76c2e95a8f10c73c8f5322337afe7ca2a..051a3e1fb8df9b2bcb2073e8299d31cdfc938724 100644 (file)
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -408,7 +408,7 @@ void exit_shm(struct task_struct *task)
        up_write(&shm_ids(ns).rwsem);
 }
 
-static int shm_fault(struct vm_fault *vmf)
+static vm_fault_t shm_fault(struct vm_fault *vmf)
 {
        struct file *file = vmf->vma->vm_file;
        struct shm_file_data *sfd = shm_file_data(file);
index 52f368b6561e984e5b93b8e71bc56cb80f3683aa..fba78047fb37c525f6fa0a16e74418aa31b569cf 100644 (file)
@@ -109,7 +109,7 @@ struct audit_fsnotify_mark *audit_alloc_mark(struct audit_krule *krule, char *pa
        audit_update_mark(audit_mark, dentry->d_inode);
        audit_mark->rule = krule;
 
-       ret = fsnotify_add_mark(&audit_mark->mark, inode, NULL, true);
+       ret = fsnotify_add_inode_mark(&audit_mark->mark, inode, true);
        if (ret < 0) {
                fsnotify_put_mark(&audit_mark->mark);
                audit_mark = ERR_PTR(ret);
@@ -165,12 +165,11 @@ static void audit_autoremove_mark_rule(struct audit_fsnotify_mark *audit_mark)
 /* Update mark data in audit rules based on fsnotify events. */
 static int audit_mark_handle_event(struct fsnotify_group *group,
                                    struct inode *to_tell,
-                                   struct fsnotify_mark *inode_mark,
-                                   struct fsnotify_mark *vfsmount_mark,
                                    u32 mask, const void *data, int data_type,
                                    const unsigned char *dname, u32 cookie,
                                    struct fsnotify_iter_info *iter_info)
 {
+       struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);
        struct audit_fsnotify_mark *audit_mark;
        const struct inode *inode = NULL;
 
index 67e6956c0b61d0c2c08aa3f21546bd16696b4e75..c99ebaae5abce26ffad74f0bef100373069a7b37 100644 (file)
@@ -288,8 +288,8 @@ static void untag_chunk(struct node *p)
        if (!new)
                goto Fallback;
 
-       if (fsnotify_add_mark_locked(&new->mark, entry->connector->inode,
-                                    NULL, 1)) {
+       if (fsnotify_add_inode_mark_locked(&new->mark, entry->connector->inode,
+                                          1)) {
                fsnotify_put_mark(&new->mark);
                goto Fallback;
        }
@@ -354,7 +354,7 @@ static int create_chunk(struct inode *inode, struct audit_tree *tree)
                return -ENOMEM;
 
        entry = &chunk->mark;
-       if (fsnotify_add_mark(entry, inode, NULL, 0)) {
+       if (fsnotify_add_inode_mark(entry, inode, 0)) {
                fsnotify_put_mark(entry);
                return -ENOSPC;
        }
@@ -434,8 +434,8 @@ static int tag_chunk(struct inode *inode, struct audit_tree *tree)
                return -ENOENT;
        }
 
-       if (fsnotify_add_mark_locked(chunk_entry,
-                            old_entry->connector->inode, NULL, 1)) {
+       if (fsnotify_add_inode_mark_locked(chunk_entry,
+                            old_entry->connector->inode, 1)) {
                spin_unlock(&old_entry->lock);
                mutex_unlock(&old_entry->group->mark_mutex);
                fsnotify_put_mark(chunk_entry);
@@ -989,8 +989,6 @@ static void evict_chunk(struct audit_chunk *chunk)
 
 static int audit_tree_handle_event(struct fsnotify_group *group,
                                   struct inode *to_tell,
-                                  struct fsnotify_mark *inode_mark,
-                                  struct fsnotify_mark *vfsmount_mark,
                                   u32 mask, const void *data, int data_type,
                                   const unsigned char *file_name, u32 cookie,
                                   struct fsnotify_iter_info *iter_info)
index f1ba88994508baacf34fa8d8d04e57ec33e8cec5..c17c0c268436807211cc411f888c8bdffd9da8f4 100644 (file)
@@ -160,7 +160,7 @@ static struct audit_parent *audit_init_parent(struct path *path)
 
        fsnotify_init_mark(&parent->mark, audit_watch_group);
        parent->mark.mask = AUDIT_FS_WATCH;
-       ret = fsnotify_add_mark(&parent->mark, inode, NULL, 0);
+       ret = fsnotify_add_inode_mark(&parent->mark, inode, 0);
        if (ret < 0) {
                audit_free_parent(parent);
                return ERR_PTR(ret);
@@ -472,12 +472,11 @@ void audit_remove_watch_rule(struct audit_krule *krule)
 /* Update watch data in audit rules based on fsnotify events. */
 static int audit_watch_handle_event(struct fsnotify_group *group,
                                    struct inode *to_tell,
-                                   struct fsnotify_mark *inode_mark,
-                                   struct fsnotify_mark *vfsmount_mark,
                                    u32 mask, const void *data, int data_type,
                                    const unsigned char *dname, u32 cookie,
                                    struct fsnotify_iter_info *iter_info)
 {
+       struct fsnotify_mark *inode_mark = fsnotify_iter_inode_mark(iter_info);
        const struct inode *inode;
        struct audit_parent *parent;
 
index 8653ab004c73e9118e910f253b78deab23f7e609..2d49d18b793abaf60379c4050e4148a77bae732f 100644 (file)
@@ -608,7 +608,7 @@ static int btf_add_type(struct btf_verifier_env *env, struct btf_type *t)
                new_size = min_t(u32, BTF_MAX_TYPE,
                                 btf->types_size + expand_by);
 
-               new_types = kvzalloc(new_size * sizeof(*new_types),
+               new_types = kvcalloc(new_size, sizeof(*new_types),
                                     GFP_KERNEL | __GFP_NOWARN);
                if (!new_types)
                        return -ENOMEM;
@@ -698,17 +698,17 @@ static int env_resolve_init(struct btf_verifier_env *env)
        u8 *visit_states = NULL;
 
        /* +1 for btf_void */
-       resolved_sizes = kvzalloc((nr_types + 1) * sizeof(*resolved_sizes),
+       resolved_sizes = kvcalloc(nr_types + 1, sizeof(*resolved_sizes),
                                  GFP_KERNEL | __GFP_NOWARN);
        if (!resolved_sizes)
                goto nomem;
 
-       resolved_ids = kvzalloc((nr_types + 1) * sizeof(*resolved_ids),
+       resolved_ids = kvcalloc(nr_types + 1, sizeof(*resolved_ids),
                                GFP_KERNEL | __GFP_NOWARN);
        if (!resolved_ids)
                goto nomem;
 
-       visit_states = kvzalloc((nr_types + 1) * sizeof(*visit_states),
+       visit_states = kvcalloc(nr_types + 1, sizeof(*visit_states),
                                GFP_KERNEL | __GFP_NOWARN);
        if (!visit_states)
                goto nomem;
index ed13645bd80c48ea3e16e999cbd598182e934e63..76efe9a183f5313de5cc0b43f2bc4fc446d9bf6a 100644 (file)
@@ -295,6 +295,15 @@ static const struct file_operations bpffs_map_fops = {
        .release        = bpffs_map_release,
 };
 
+static int bpffs_obj_open(struct inode *inode, struct file *file)
+{
+       return -EIO;
+}
+
+static const struct file_operations bpffs_obj_fops = {
+       .open           = bpffs_obj_open,
+};
+
 static int bpf_mkobj_ops(struct dentry *dentry, umode_t mode, void *raw,
                         const struct inode_operations *iops,
                         const struct file_operations *fops)
@@ -314,7 +323,8 @@ static int bpf_mkobj_ops(struct dentry *dentry, umode_t mode, void *raw,
 
 static int bpf_mkprog(struct dentry *dentry, umode_t mode, void *arg)
 {
-       return bpf_mkobj_ops(dentry, mode, arg, &bpf_prog_iops, NULL);
+       return bpf_mkobj_ops(dentry, mode, arg, &bpf_prog_iops,
+                            &bpffs_obj_fops);
 }
 
 static int bpf_mkmap(struct dentry *dentry, umode_t mode, void *arg)
@@ -322,7 +332,7 @@ static int bpf_mkmap(struct dentry *dentry, umode_t mode, void *arg)
        struct bpf_map *map = arg;
 
        return bpf_mkobj_ops(dentry, mode, arg, &bpf_map_iops,
-                            map->btf ? &bpffs_map_fops : NULL);
+                            map->btf ? &bpffs_map_fops : &bpffs_obj_fops);
 }
 
 static struct dentry *
index b4b5b81e7251e6fab9530d9d0dd2f343d2045c0e..1603492c9cc7e7cfd98a677c43fad39c58cb85bb 100644 (file)
@@ -623,8 +623,9 @@ static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key)
        if (!key || key->prefixlen > trie->max_prefixlen)
                goto find_leftmost;
 
-       node_stack = kmalloc(trie->max_prefixlen * sizeof(struct lpm_trie_node *),
-                            GFP_ATOMIC | __GFP_NOWARN);
+       node_stack = kmalloc_array(trie->max_prefixlen,
+                                  sizeof(struct lpm_trie_node *),
+                                  GFP_ATOMIC | __GFP_NOWARN);
        if (!node_stack)
                return -ENOMEM;
 
index cced0c1e63e2d62f2bd60795e29b6cfbc8c0df93..9e2bf834f13a21090b566862a853e7567ee03ac9 100644 (file)
@@ -5206,7 +5206,8 @@ static int adjust_insn_aux_data(struct bpf_verifier_env *env, u32 prog_len,
 
        if (cnt == 1)
                return 0;
-       new_data = vzalloc(sizeof(struct bpf_insn_aux_data) * prog_len);
+       new_data = vzalloc(array_size(prog_len,
+                                     sizeof(struct bpf_insn_aux_data)));
        if (!new_data)
                return -ENOMEM;
        memcpy(new_data, old_data, sizeof(struct bpf_insn_aux_data) * off);
@@ -5447,7 +5448,7 @@ static int jit_subprogs(struct bpf_verifier_env *env)
                insn->imm = 1;
        }
 
-       func = kzalloc(sizeof(prog) * env->subprog_cnt, GFP_KERNEL);
+       func = kcalloc(env->subprog_cnt, sizeof(prog), GFP_KERNEL);
        if (!func)
                return -ENOMEM;
 
@@ -5870,8 +5871,9 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr)
                return -ENOMEM;
        log = &env->log;
 
-       env->insn_aux_data = vzalloc(sizeof(struct bpf_insn_aux_data) *
-                                    (*prog)->len);
+       env->insn_aux_data =
+               vzalloc(array_size(sizeof(struct bpf_insn_aux_data),
+                                  (*prog)->len));
        ret = -ENOMEM;
        if (!env->insn_aux_data)
                goto err_free_env;
index e06c97f3ed1a39c3e43a7895158b6a4a298d2bf3..8b4f0768efd62244d3939b985059963371e04d63 100644 (file)
@@ -195,9 +195,9 @@ struct cgroup_pidlist {
 static void *pidlist_allocate(int count)
 {
        if (PIDLIST_TOO_LARGE(count))
-               return vmalloc(count * sizeof(pid_t));
+               return vmalloc(array_size(count, sizeof(pid_t)));
        else
-               return kmalloc(count * sizeof(pid_t), GFP_KERNEL);
+               return kmalloc_array(count, sizeof(pid_t), GFP_KERNEL);
 }
 
 static void pidlist_free(void *p)
index b42037e6e81d3af0eb8a2d8c5cbdf4bbd56e5824..266f10cb7222b558aca0a777206d7bc747912750 100644 (file)
@@ -605,7 +605,7 @@ static inline int nr_cpusets(void)
  * load balancing domains (sched domains) as specified by that partial
  * partition.
  *
- * See "What is sched_load_balance" in Documentation/cgroups/cpusets.txt
+ * See "What is sched_load_balance" in Documentation/cgroup-v1/cpusets.txt
  * for a background explanation of this.
  *
  * Does not return errors, on the theory that the callers of this
@@ -683,7 +683,7 @@ static int generate_sched_domains(cpumask_var_t **domains,
                goto done;
        }
 
-       csa = kmalloc(nr_cpusets() * sizeof(cp), GFP_KERNEL);
+       csa = kmalloc_array(nr_cpusets(), sizeof(cp), GFP_KERNEL);
        if (!csa)
                goto done;
        csn = 0;
@@ -753,7 +753,8 @@ static int generate_sched_domains(cpumask_var_t **domains,
         * The rest of the code, including the scheduler, can deal with
         * dattr==NULL case. No need to abort if alloc fails.
         */
-       dattr = kmalloc(ndoms * sizeof(struct sched_domain_attr), GFP_KERNEL);
+       dattr = kmalloc_array(ndoms, sizeof(struct sched_domain_attr),
+                             GFP_KERNEL);
 
        for (nslot = 0, i = 0; i < csn; i++) {
                struct cpuset *a = csa[i];
index 946fb92418f7915af8fd28a1f6db2574e1937e53..81e9af7dcec2bf4bec26e72a83109ffa958d1e43 100644 (file)
@@ -12,7 +12,7 @@ CONFIG_BLK_DEV_DM=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_RAM=y
 CONFIG_BLK_DEV_RAM_SIZE=8192
-CONFIG_CC_STACKPROTECTOR_STRONG=y
+CONFIG_STACKPROTECTOR_STRONG=y
 CONFIG_COMPACTION=y
 CONFIG_CPU_SW_DOMAIN_PAN=y
 CONFIG_DM_CRYPT=y
index 9bfdffc100da48338c71a76b1a74a4f176f8ecdc..7fa0c4ae6394f028fa09694b219314dd3d7d8731 100644 (file)
@@ -10,7 +10,3 @@ CONFIG_OPTIMIZE_INLINING=y
 # CONFIG_SLAB is not set
 # CONFIG_SLUB is not set
 CONFIG_SLOB=y
-CONFIG_CC_STACKPROTECTOR_NONE=y
-# CONFIG_CC_STACKPROTECTOR_REGULAR is not set
-# CONFIG_CC_STACKPROTECTOR_STRONG is not set
-# CONFIG_CC_STACKPROTECTOR_AUTO is not set
index e405677ee08d6ae6b71c36afd2270d2ed806810d..2ddfce8f1e8fb2dddfc8fbbc2ca433da5b2aebbb 100644 (file)
@@ -691,7 +691,7 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0)
        }
        if (!s->usable)
                return KDB_NOTIMP;
-       s->command = kzalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB);
+       s->command = kcalloc(s->count + 1, sizeof(*(s->command)), GFP_KDB);
        if (!s->command) {
                kdb_printf("Could not allocate new kdb_defcmd table for %s\n",
                           cmdstr);
@@ -729,8 +729,8 @@ static int kdb_defcmd(int argc, const char **argv)
                kdb_printf("Command only available during kdb_init()\n");
                return KDB_NOTIMP;
        }
-       defcmd_set = kmalloc((defcmd_set_count + 1) * sizeof(*defcmd_set),
-                            GFP_KDB);
+       defcmd_set = kmalloc_array(defcmd_set_count + 1, sizeof(*defcmd_set),
+                                  GFP_KDB);
        if (!defcmd_set)
                goto fail_defcmd;
        memcpy(defcmd_set, save_defcmd_set,
@@ -2706,8 +2706,11 @@ int kdb_register_flags(char *cmd,
        }
 
        if (i >= kdb_max_commands) {
-               kdbtab_t *new = kmalloc((kdb_max_commands - KDB_BASE_CMD_MAX +
-                        kdb_command_extend) * sizeof(*new), GFP_KDB);
+               kdbtab_t *new = kmalloc_array(kdb_max_commands -
+                                               KDB_BASE_CMD_MAX +
+                                               kdb_command_extend,
+                                             sizeof(*new),
+                                             GFP_KDB);
                if (!new) {
                        kdb_printf("Could not allocate new kdb_command "
                                   "table\n");
index 1d8ca9ea997975e99af8aa5c73fd831dca0a22b4..045a37e9ddee3255fac6ab34b80682f4e2e968e1 100644 (file)
@@ -614,7 +614,8 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event,
                }
        }
 
-       rb->aux_pages = kzalloc_node(nr_pages * sizeof(void *), GFP_KERNEL, node);
+       rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL,
+                                    node);
        if (!rb->aux_pages)
                return -ENOMEM;
 
index 1725b902983fcd5b561fdc3b30d843b931f4cffd..ccc579a7d32e0c8a11835a19aee17b71d1375b8a 100644 (file)
@@ -1184,7 +1184,8 @@ static struct xol_area *__create_xol_area(unsigned long vaddr)
        if (unlikely(!area))
                goto out;
 
-       area->bitmap = kzalloc(BITS_TO_LONGS(UINSNS_PER_PAGE) * sizeof(long), GFP_KERNEL);
+       area->bitmap = kcalloc(BITS_TO_LONGS(UINSNS_PER_PAGE), sizeof(long),
+                              GFP_KERNEL);
        if (!area->bitmap)
                goto free_area;
 
index 1d5632d8bbccfd941a6b0b1cf0ac380c4aeb0a5c..5349c91c22983c4b9dc0d362aacf9579a705cf70 100644 (file)
@@ -258,7 +258,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer,
        /* cut off if it is too long */
        if (count > KSYM_NAME_LEN)
                count = KSYM_NAME_LEN;
-       buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL);
+       buf = kmalloc(count + 1, GFP_KERNEL);
        if (!buf)
                return -ENOMEM;
 
index 08c6e5e217a0355f39431634746b7bff10621263..9440d61b925ca08faa3beb7d3a02fedfdd0a9b84 100644 (file)
@@ -440,6 +440,14 @@ static __latent_entropy int dup_mmap(struct mm_struct *mm,
                        continue;
                }
                charge = 0;
+               /*
+                * Don't duplicate many vmas if we've been oom-killed (for
+                * example)
+                */
+               if (fatal_signal_pending(current)) {
+                       retval = -EINTR;
+                       goto out;
+               }
                if (mpnt->vm_flags & VM_ACCOUNT) {
                        unsigned long len = vma_pages(mpnt);
 
@@ -811,7 +819,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig, int node)
        clear_tsk_need_resched(tsk);
        set_task_stack_end_magic(tsk);
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
        tsk->stack_canary = get_random_canary();
 #endif
 
index 1276aabaab5504508ce783d539c3be8acac84fee..1e3823fa799b299b88f1eeb3f5818ed7a31e905e 100644 (file)
@@ -53,23 +53,16 @@ config GCOV_PROFILE_ALL
 choice
        prompt "Specify GCOV format"
        depends on GCOV_KERNEL
-       default GCOV_FORMAT_AUTODETECT
        ---help---
-       The gcov format is usually determined by the GCC version, but there are
+       The gcov format is usually determined by the GCC version, and the
+       default is chosen according to your GCC version. However, there are
        exceptions where format changes are integrated in lower-version GCCs.
-       In such a case use this option to adjust the format used in the kernel
-       accordingly.
-
-       If unsure, choose "Autodetect".
-
-config GCOV_FORMAT_AUTODETECT
-       bool "Autodetect"
-       ---help---
-       Select this option to use the format that corresponds to your GCC
-       version.
+       In such a case, change this option to adjust the format used in the
+       kernel accordingly.
 
 config GCOV_FORMAT_3_4
        bool "GCC 3.4 format"
+       depends on CC_IS_GCC && GCC_VERSION < 40700
        ---help---
        Select this option to use the format defined by GCC 3.4.
 
index c6c50e5c680e049f6ded431b722852150b2261d2..ff06d64df3976807840dffd3a7629e64f5270de2 100644 (file)
@@ -4,5 +4,3 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"'
 obj-y := base.o fs.o
 obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_3_4.o
 obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_4_7.o
-obj-$(CONFIG_GCOV_FORMAT_AUTODETECT) += $(call cc-ifversion, -lt, 0407, \
-                                                       gcc_3_4.o, gcc_4_7.o)
index 2c16f1ab5e107562a8f9ade9735d97d0277931fd..3ebd09efe72a67fcc1e88761e91e306880c5ae0a 100644 (file)
@@ -58,7 +58,7 @@ struct kcov {
 
 static bool check_kcov_mode(enum kcov_mode needed_mode, struct task_struct *t)
 {
-       enum kcov_mode mode;
+       unsigned int mode;
 
        /*
         * We are interested in code coverage as a function of a syscall inputs,
@@ -241,7 +241,8 @@ static void kcov_put(struct kcov *kcov)
 
 void kcov_task_init(struct task_struct *t)
 {
-       t->kcov_mode = KCOV_MODE_DISABLED;
+       WRITE_ONCE(t->kcov_mode, KCOV_MODE_DISABLED);
+       barrier();
        t->kcov_size = 0;
        t->kcov_area = NULL;
        t->kcov = NULL;
@@ -323,6 +324,21 @@ static int kcov_close(struct inode *inode, struct file *filep)
        return 0;
 }
 
+/*
+ * Fault in a lazily-faulted vmalloc area before it can be used by
+ * __santizer_cov_trace_pc(), to avoid recursion issues if any code on the
+ * vmalloc fault handling path is instrumented.
+ */
+static void kcov_fault_in_area(struct kcov *kcov)
+{
+       unsigned long stride = PAGE_SIZE / sizeof(unsigned long);
+       unsigned long *area = kcov->area;
+       unsigned long offset;
+
+       for (offset = 0; offset < kcov->size; offset += stride)
+               READ_ONCE(area[offset]);
+}
+
 static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd,
                             unsigned long arg)
 {
@@ -371,6 +387,7 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsigned int cmd,
 #endif
                else
                        return -EINVAL;
+               kcov_fault_in_area(kcov);
                /* Cache in task struct for performance. */
                t->kcov_size = kcov->size;
                t->kcov_area = kcov->area;
index 20fef1a38602d9d0ed6fdb5d359d5604fbafc3dd..23a83a4da38a1dffc5203c828a384531b6cce9b2 100644 (file)
@@ -829,6 +829,8 @@ static int kimage_load_normal_segment(struct kimage *image,
                else
                        buf += mchunk;
                mbytes -= mchunk;
+
+               cond_resched();
        }
 out:
        return result;
@@ -893,6 +895,8 @@ static int kimage_load_crash_segment(struct kimage *image,
                else
                        buf += mchunk;
                mbytes -= mchunk;
+
+               cond_resched();
        }
 out:
        return result;
index 75d8e7cf040e69bfcde16fb555c09054cfe9ebad..c6a3b6851372c480005d4f053757ba02ad101d8f 100644 (file)
@@ -793,7 +793,7 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi,
         * The section headers in kexec_purgatory are read-only. In order to
         * have them modifiable make a temporary copy.
         */
-       sechdrs = vzalloc(pi->ehdr->e_shnum * sizeof(Elf_Shdr));
+       sechdrs = vzalloc(array_size(sizeof(Elf_Shdr), pi->ehdr->e_shnum));
        if (!sechdrs)
                return -ENOMEM;
        memcpy(sechdrs, (void *)pi->ehdr + pi->ehdr->e_shoff,
index 6850ffd6912579ac6053a6bdcc22f3322acab261..8402b3349dca40a53a82a34900165c1054ae2fff 100644 (file)
@@ -913,7 +913,9 @@ static int __init lock_torture_init(void)
        /* Initialize the statistics so that each run gets its own numbers. */
        if (nwriters_stress) {
                lock_is_write_held = 0;
-               cxt.lwsa = kmalloc(sizeof(*cxt.lwsa) * cxt.nrealwriters_stress, GFP_KERNEL);
+               cxt.lwsa = kmalloc_array(cxt.nrealwriters_stress,
+                                        sizeof(*cxt.lwsa),
+                                        GFP_KERNEL);
                if (cxt.lwsa == NULL) {
                        VERBOSE_TOROUT_STRING("cxt.lwsa: Out of memory");
                        firsterr = -ENOMEM;
@@ -942,7 +944,9 @@ static int __init lock_torture_init(void)
 
                if (nreaders_stress) {
                        lock_is_read_held = 0;
-                       cxt.lrsa = kmalloc(sizeof(*cxt.lrsa) * cxt.nrealreaders_stress, GFP_KERNEL);
+                       cxt.lrsa = kmalloc_array(cxt.nrealreaders_stress,
+                                                sizeof(*cxt.lrsa),
+                                                GFP_KERNEL);
                        if (cxt.lrsa == NULL) {
                                VERBOSE_TOROUT_STRING("cxt.lrsa: Out of memory");
                                firsterr = -ENOMEM;
@@ -985,7 +989,8 @@ static int __init lock_torture_init(void)
        }
 
        if (nwriters_stress) {
-               writer_tasks = kzalloc(cxt.nrealwriters_stress * sizeof(writer_tasks[0]),
+               writer_tasks = kcalloc(cxt.nrealwriters_stress,
+                                      sizeof(writer_tasks[0]),
                                       GFP_KERNEL);
                if (writer_tasks == NULL) {
                        VERBOSE_TOROUT_ERRSTRING("writer_tasks: Out of memory");
@@ -995,7 +1000,8 @@ static int __init lock_torture_init(void)
        }
 
        if (cxt.cur_ops->readlock) {
-               reader_tasks = kzalloc(cxt.nrealreaders_stress * sizeof(reader_tasks[0]),
+               reader_tasks = kcalloc(cxt.nrealreaders_stress,
+                                      sizeof(reader_tasks[0]),
                                       GFP_KERNEL);
                if (reader_tasks == NULL) {
                        VERBOSE_TOROUT_ERRSTRING("reader_tasks: Out of memory");
index 68469b37d61a0c87e6a78a53006334cdcef8b7d5..f475f30eed8c031abc5e88241ee5088056dbb664 100644 (file)
@@ -274,9 +274,7 @@ static void module_assert_mutex_or_preempt(void)
 }
 
 static bool sig_enforce = IS_ENABLED(CONFIG_MODULE_SIG_FORCE);
-#ifndef CONFIG_MODULE_SIG_FORCE
 module_param(sig_enforce, bool_enable_only, 0644);
-#endif /* !CONFIG_MODULE_SIG_FORCE */
 
 /*
  * Export sig_enforce kernel cmdline parameter to allow other subsystems rely
@@ -2785,7 +2783,7 @@ static int module_sig_check(struct load_info *info, int flags)
        }
 
        /* Not having a signature is only an error if we're strict. */
-       if (err == -ENOKEY && !sig_enforce)
+       if (err == -ENOKEY && !is_module_sig_enforced())
                err = 0;
 
        return err;
index 42e48748855420af5fa2a0d45f04e54298546b9e..8b2e002d52eb0e6c927876077bddfcd0565d7929 100644 (file)
@@ -623,7 +623,7 @@ static __init int register_warn_debugfs(void)
 device_initcall(register_warn_debugfs);
 #endif
 
-#ifdef CONFIG_CC_STACKPROTECTOR
+#ifdef CONFIG_STACKPROTECTOR
 
 /*
  * Called when gcc's -fstack-protector feature is used, and
index 705c2366dafe19c13f011885df1e2ae93c2687e7..d9706da1093036dbdbce61e7cf74b2f410c8a99d 100644 (file)
@@ -455,8 +455,9 @@ struct kobject *power_kobj;
  * state - control system sleep states.
  *
  * show() returns available sleep state labels, which may be "mem", "standby",
- * "freeze" and "disk" (hibernation).  See Documentation/power/states.txt for a
- * description of what they mean.
+ * "freeze" and "disk" (hibernation).
+ * See Documentation/admin-guide/pm/sleep-states.rst for a description of
+ * what they mean.
  *
  * store() accepts one of those strings, translates it into the proper
  * enumerated value, and initiates a suspend transition.
index 1efcb5b0c3ed422aa20b86f5980bdeb9ba26493b..c2bcf97d24c8ff827f338f890c76595089d24e4e 100644 (file)
@@ -698,7 +698,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
                goto out_clean;
        }
 
-       data = vmalloc(sizeof(*data) * nr_threads);
+       data = vmalloc(array_size(nr_threads, sizeof(*data)));
        if (!data) {
                pr_err("Failed to allocate LZO data\n");
                ret = -ENOMEM;
@@ -1183,14 +1183,14 @@ static int load_image_lzo(struct swap_map_handle *handle,
        nr_threads = num_online_cpus() - 1;
        nr_threads = clamp_val(nr_threads, 1, LZO_THREADS);
 
-       page = vmalloc(sizeof(*page) * LZO_MAX_RD_PAGES);
+       page = vmalloc(array_size(LZO_MAX_RD_PAGES, sizeof(*page)));
        if (!page) {
                pr_err("Failed to allocate LZO page\n");
                ret = -ENOMEM;
                goto out_clean;
        }
 
-       data = vmalloc(sizeof(*data) * nr_threads);
+       data = vmalloc(array_size(nr_threads, sizeof(*data)));
        if (!data) {
                pr_err("Failed to allocate LZO data\n");
                ret = -ENOMEM;
index e628fcfd1bdedb32fcb187b8a8602d322bc10f79..42fcb7f05fac27dc6785fab9955db4f3cc2a8efc 100644 (file)
@@ -831,8 +831,9 @@ rcu_torture_cbflood(void *arg)
            cbflood_intra_holdoff > 0 &&
            cur_ops->call &&
            cur_ops->cb_barrier) {
-               rhp = vmalloc(sizeof(*rhp) *
-                             cbflood_n_burst * cbflood_n_per_burst);
+               rhp = vmalloc(array3_size(cbflood_n_burst,
+                                         cbflood_n_per_burst,
+                                         sizeof(*rhp)));
                err = !rhp;
        }
        if (err) {
index c955b10c973c0444ec491c7e6b3779b77fe1fa15..04f248644e065f601d78744be2bbe580a6aa1810 100644 (file)
@@ -39,7 +39,7 @@ static void relay_file_mmap_close(struct vm_area_struct *vma)
 /*
  * fault() vm_op implementation for relay file mapping.
  */
-static int relay_buf_fault(struct vm_fault *vmf)
+static vm_fault_t relay_buf_fault(struct vm_fault *vmf)
 {
        struct page *page;
        struct rchan_buf *buf = vmf->vma->vm_private_data;
@@ -169,7 +169,8 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan)
        buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
        if (!buf)
                return NULL;
-       buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL);
+       buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t *),
+                                    GFP_KERNEL);
        if (!buf->padding)
                goto free_buf;
 
index a98d54cd553502cb3f983416c0aae0fdac3d6a17..78d8facba456c2fc44c7024ae1a1c8d9db6f0692 100644 (file)
@@ -10,6 +10,8 @@
 #include <linux/kthread.h>
 #include <linux/nospec.h>
 
+#include <linux/kcov.h>
+
 #include <asm/switch_to.h>
 #include <asm/tlb.h>
 
@@ -2633,6 +2635,7 @@ static inline void
 prepare_task_switch(struct rq *rq, struct task_struct *prev,
                    struct task_struct *next)
 {
+       kcov_prepare_switch(prev);
        sched_info_switch(rq, prev, next);
        perf_event_task_sched_out(prev, next);
        rseq_preempt(prev);
@@ -2702,6 +2705,7 @@ static struct rq *finish_task_switch(struct task_struct *prev)
        finish_task(prev);
        finish_lock_switch(rq);
        finish_arch_post_lock_switch();
+       kcov_finish_switch(current);
 
        fire_sched_in_preempt_notifiers(current);
        /*
index e497c05aab7f84f8cea23b21e6f1b01da0c2a1b6..1866e64792a791f8737128c88ae691d7453ff117 100644 (file)
@@ -10215,10 +10215,10 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent)
        struct cfs_rq *cfs_rq;
        int i;
 
-       tg->cfs_rq = kzalloc(sizeof(cfs_rq) * nr_cpu_ids, GFP_KERNEL);
+       tg->cfs_rq = kcalloc(nr_cpu_ids, sizeof(cfs_rq), GFP_KERNEL);
        if (!tg->cfs_rq)
                goto err;
-       tg->se = kzalloc(sizeof(se) * nr_cpu_ids, GFP_KERNEL);
+       tg->se = kcalloc(nr_cpu_ids, sizeof(se), GFP_KERNEL);
        if (!tg->se)
                goto err;
 
index ef3c4e6f53457ba52151fe243c5d62c160ecc115..47556b0c9a95faff3e827f6ffd690646cff38224 100644 (file)
@@ -183,10 +183,10 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent)
        struct sched_rt_entity *rt_se;
        int i;
 
-       tg->rt_rq = kzalloc(sizeof(rt_rq) * nr_cpu_ids, GFP_KERNEL);
+       tg->rt_rq = kcalloc(nr_cpu_ids, sizeof(rt_rq), GFP_KERNEL);
        if (!tg->rt_rq)
                goto err;
-       tg->rt_se = kzalloc(sizeof(rt_se) * nr_cpu_ids, GFP_KERNEL);
+       tg->rt_se = kcalloc(nr_cpu_ids, sizeof(rt_se), GFP_KERNEL);
        if (!tg->rt_se)
                goto err;
 
index 61a1125c1ae4224e8f69938406f0d08ad47519b7..05a831427bc741e8d6290a6189bedbfda2457ded 100644 (file)
@@ -1750,7 +1750,7 @@ cpumask_var_t *alloc_sched_domains(unsigned int ndoms)
        int i;
        cpumask_var_t *doms;
 
-       doms = kmalloc(sizeof(*doms) * ndoms, GFP_KERNEL);
+       doms = kmalloc_array(ndoms, sizeof(*doms), GFP_KERNEL);
        if (!doms)
                return NULL;
        for (i = 0; i < ndoms; i++) {
index 6a78cf70761db3c436316f8e3f7453d20962dc08..2d9837c0aff4aef97ad8bb1542bcbd7cf1493b35 100644 (file)
@@ -3047,7 +3047,8 @@ int proc_do_large_bitmap(struct ctl_table *table, int write,
                if (IS_ERR(kbuf))
                        return PTR_ERR(kbuf);
 
-               tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
+               tmp_bitmap = kcalloc(BITS_TO_LONGS(bitmap_len),
+                                    sizeof(unsigned long),
                                     GFP_KERNEL);
                if (!tmp_bitmap) {
                        kfree(kbuf);
index dd6c0a2ad969fe3e3ff387833629bf6f611a1c50..dcc0166d1997a20e5d8c56c3facaca5315d8d1e4 100644 (file)
@@ -12,22 +12,22 @@ config NOP_TRACER
 config HAVE_FTRACE_NMI_ENTER
        bool
        help
-         See Documentation/trace/ftrace-design.txt
+         See Documentation/trace/ftrace-design.rst
 
 config HAVE_FUNCTION_TRACER
        bool
        help
-         See Documentation/trace/ftrace-design.txt
+         See Documentation/trace/ftrace-design.rst
 
 config HAVE_FUNCTION_GRAPH_TRACER
        bool
        help
-         See Documentation/trace/ftrace-design.txt
+         See Documentation/trace/ftrace-design.rst
 
 config HAVE_DYNAMIC_FTRACE
        bool
        help
-         See Documentation/trace/ftrace-design.txt
+         See Documentation/trace/ftrace-design.rst
 
 config HAVE_DYNAMIC_FTRACE_WITH_REGS
        bool
@@ -35,12 +35,12 @@ config HAVE_DYNAMIC_FTRACE_WITH_REGS
 config HAVE_FTRACE_MCOUNT_RECORD
        bool
        help
-         See Documentation/trace/ftrace-design.txt
+         See Documentation/trace/ftrace-design.rst
 
 config HAVE_SYSCALL_TRACEPOINTS
        bool
        help
-         See Documentation/trace/ftrace-design.txt
+         See Documentation/trace/ftrace-design.rst
 
 config HAVE_FENTRY
        bool
@@ -448,7 +448,7 @@ config KPROBE_EVENTS
        help
          This allows the user to add tracing events (similar to tracepoints)
          on the fly via the ftrace interface. See
-         Documentation/trace/kprobetrace.txt for more details.
+         Documentation/trace/kprobetrace.rst for more details.
 
          Those events can be inserted wherever kprobes can probe, and record
          various register and memory values.
@@ -575,7 +575,7 @@ config MMIOTRACE
          implementation and works via page faults. Tracing is disabled by
          default and can be enabled at run-time.
 
-         See Documentation/trace/mmiotrace.txt.
+         See Documentation/trace/mmiotrace.rst.
          If you are not helping to develop drivers, say N.
 
 config TRACING_MAP
index 8d83bcf9ef69fa894706b2005e5d5cf9fba97003..efed9c1cfb7ea4ea12182e711dacf01623f73452 100644 (file)
@@ -728,7 +728,7 @@ static int ftrace_profile_init_cpu(int cpu)
         */
        size = FTRACE_PROFILE_HASH_SIZE;
 
-       stat->hash = kzalloc(sizeof(struct hlist_head) * size, GFP_KERNEL);
+       stat->hash = kcalloc(size, sizeof(struct hlist_head), GFP_KERNEL);
 
        if (!stat->hash)
                return -ENOMEM;
@@ -6830,9 +6830,10 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list)
        struct task_struct *g, *t;
 
        for (i = 0; i < FTRACE_RETSTACK_ALLOC_SIZE; i++) {
-               ret_stack_list[i] = kmalloc(FTRACE_RETFUNC_DEPTH
-                                       * sizeof(struct ftrace_ret_stack),
-                                       GFP_KERNEL);
+               ret_stack_list[i] =
+                       kmalloc_array(FTRACE_RETFUNC_DEPTH,
+                                     sizeof(struct ftrace_ret_stack),
+                                     GFP_KERNEL);
                if (!ret_stack_list[i]) {
                        start = 0;
                        end = i;
@@ -6904,9 +6905,9 @@ static int start_graph_tracing(void)
        struct ftrace_ret_stack **ret_stack_list;
        int ret, cpu;
 
-       ret_stack_list = kmalloc(FTRACE_RETSTACK_ALLOC_SIZE *
-                               sizeof(struct ftrace_ret_stack *),
-                               GFP_KERNEL);
+       ret_stack_list = kmalloc_array(FTRACE_RETSTACK_ALLOC_SIZE,
+                                      sizeof(struct ftrace_ret_stack *),
+                                      GFP_KERNEL);
 
        if (!ret_stack_list)
                return -ENOMEM;
@@ -7088,9 +7089,10 @@ void ftrace_graph_init_idle_task(struct task_struct *t, int cpu)
 
                ret_stack = per_cpu(idle_ret_stack, cpu);
                if (!ret_stack) {
-                       ret_stack = kmalloc(FTRACE_RETFUNC_DEPTH
-                                           * sizeof(struct ftrace_ret_stack),
-                                           GFP_KERNEL);
+                       ret_stack =
+                               kmalloc_array(FTRACE_RETFUNC_DEPTH,
+                                             sizeof(struct ftrace_ret_stack),
+                                             GFP_KERNEL);
                        if (!ret_stack)
                                return;
                        per_cpu(idle_ret_stack, cpu) = ret_stack;
@@ -7109,9 +7111,9 @@ void ftrace_graph_init_task(struct task_struct *t)
        if (ftrace_graph_active) {
                struct ftrace_ret_stack *ret_stack;
 
-               ret_stack = kmalloc(FTRACE_RETFUNC_DEPTH
-                               * sizeof(struct ftrace_ret_stack),
-                               GFP_KERNEL);
+               ret_stack = kmalloc_array(FTRACE_RETFUNC_DEPTH,
+                                         sizeof(struct ftrace_ret_stack),
+                                         GFP_KERNEL);
                if (!ret_stack)
                        return;
                graph_init_task(t, ret_stack);
index 108ce3e1dc1374c21e8fc7fbc9756e095cb314fe..c9336e98ac59a778d31c16a9ac72b184477e7177 100644 (file)
@@ -1751,12 +1751,13 @@ static inline void set_cmdline(int idx, const char *cmdline)
 static int allocate_cmdlines_buffer(unsigned int val,
                                    struct saved_cmdlines_buffer *s)
 {
-       s->map_cmdline_to_pid = kmalloc(val * sizeof(*s->map_cmdline_to_pid),
-                                       GFP_KERNEL);
+       s->map_cmdline_to_pid = kmalloc_array(val,
+                                             sizeof(*s->map_cmdline_to_pid),
+                                             GFP_KERNEL);
        if (!s->map_cmdline_to_pid)
                return -ENOMEM;
 
-       s->saved_cmdlines = kmalloc(val * TASK_COMM_LEN, GFP_KERNEL);
+       s->saved_cmdlines = kmalloc_array(TASK_COMM_LEN, val, GFP_KERNEL);
        if (!s->saved_cmdlines) {
                kfree(s->map_cmdline_to_pid);
                return -ENOMEM;
@@ -4360,7 +4361,8 @@ int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
 
        if (mask == TRACE_ITER_RECORD_TGID) {
                if (!tgid_map)
-                       tgid_map = kzalloc((PID_MAX_DEFAULT + 1) * sizeof(*tgid_map),
+                       tgid_map = kcalloc(PID_MAX_DEFAULT + 1,
+                                          sizeof(*tgid_map),
                                           GFP_KERNEL);
                if (!tgid_map) {
                        tr->trace_flags &= ~TRACE_ITER_RECORD_TGID;
@@ -5063,7 +5065,7 @@ trace_insert_eval_map_file(struct module *mod, struct trace_eval_map **start,
         * where the head holds the module and length of array, and the
         * tail holds a pointer to the next list.
         */
-       map_array = kmalloc(sizeof(*map_array) * (len + 2), GFP_KERNEL);
+       map_array = kmalloc_array(len + 2, sizeof(*map_array), GFP_KERNEL);
        if (!map_array) {
                pr_warn("Unable to allocate trace eval mapping\n");
                return;
index 0171407d231f6219af55632fe32ef284c87e366c..e1c818dbc0d724c603be39463b83de8f021cf79f 100644 (file)
@@ -436,15 +436,15 @@ predicate_parse(const char *str, int nr_parens, int nr_preds,
 
        nr_preds += 2; /* For TRUE and FALSE */
 
-       op_stack = kmalloc(sizeof(*op_stack) * nr_parens, GFP_KERNEL);
+       op_stack = kmalloc_array(nr_parens, sizeof(*op_stack), GFP_KERNEL);
        if (!op_stack)
                return ERR_PTR(-ENOMEM);
-       prog_stack = kmalloc(sizeof(*prog_stack) * nr_preds, GFP_KERNEL);
+       prog_stack = kmalloc_array(nr_preds, sizeof(*prog_stack), GFP_KERNEL);
        if (!prog_stack) {
                parse_error(pe, -ENOMEM, 0);
                goto out_free;
        }
-       inverts = kmalloc(sizeof(*inverts) * nr_preds, GFP_KERNEL);
+       inverts = kmalloc_array(nr_preds, sizeof(*inverts), GFP_KERNEL);
        if (!inverts) {
                parse_error(pe, -ENOMEM, 0);
                goto out_free;
index 5cadb1b8b5fe6fd8f71d213581522bdb0d03ecf8..752d8042bad4e5acf0589f7ebf2771b05d0b34ed 100644 (file)
@@ -1075,7 +1075,7 @@ int tracing_map_sort_entries(struct tracing_map *map,
        struct tracing_map_sort_entry *sort_entry, **entries;
        int i, n_entries, ret;
 
-       entries = vmalloc(map->max_elts * sizeof(sort_entry));
+       entries = vmalloc(array_size(sizeof(sort_entry), map->max_elts));
        if (!entries)
                return -ENOMEM;
 
index 492c255e6c5a31ee135004123193310a8e6e3ce2..c3d7583fcd216d6f0b44b8d38c65ecc60c3e6fde 100644 (file)
@@ -764,8 +764,9 @@ static int insert_extent(struct uid_gid_map *map, struct uid_gid_extent *extent)
                struct uid_gid_extent *forward;
 
                /* Allocate memory for 340 mappings. */
-               forward = kmalloc(sizeof(struct uid_gid_extent) *
-                                UID_GID_MAP_MAX_EXTENTS, GFP_KERNEL);
+               forward = kmalloc_array(UID_GID_MAP_MAX_EXTENTS,
+                                       sizeof(struct uid_gid_extent),
+                                       GFP_KERNEL);
                if (!forward)
                        return -ENOMEM;
 
index 465a28b4cd32a53d09a5a9d1d71cd235752da09f..78b192071ef7b58a4d92bbc65943fdaad7ccf735 100644 (file)
@@ -5638,7 +5638,7 @@ static void __init wq_numa_init(void)
         * available.  Build one from cpu_to_node() which should have been
         * fully initialized by now.
         */
-       tbl = kzalloc(nr_node_ids * sizeof(tbl[0]), GFP_KERNEL);
+       tbl = kcalloc(nr_node_ids, sizeof(tbl[0]), GFP_KERNEL);
        BUG_ON(!tbl);
 
        for_each_node(node)
index abc111eb5054f238ece706bfe6cb540dbe0cdf0f..e34b04b56057a86cd0ade5cb9fcb4919730f80a2 100644 (file)
@@ -405,7 +405,7 @@ config ASSOCIATIVE_ARRAY
 
          See:
 
-               Documentation/assoc_array.txt
+               Documentation/core-api/assoc_array.rst
 
          for more information.
 
@@ -642,20 +642,20 @@ config STRING_SELFTEST
 
 endmenu
 
-config GENERIC_ASHLDI3
+config GENERIC_LIB_ASHLDI3
        bool
 
-config GENERIC_ASHRDI3
+config GENERIC_LIB_ASHRDI3
        bool
 
-config GENERIC_LSHRDI3
+config GENERIC_LIB_LSHRDI3
        bool
 
-config GENERIC_MULDI3
+config GENERIC_LIB_MULDI3
        bool
 
-config GENERIC_CMPDI2
+config GENERIC_LIB_CMPDI2
        bool
 
-config GENERIC_UCMPDI2
+config GENERIC_LIB_UCMPDI2
        bool
index eb885942eb0f1e6f39fdc1fa93596395cdc3313f..8838d1158d192bfafe61fc234480ad9c9a05971f 100644 (file)
@@ -736,12 +736,15 @@ config ARCH_HAS_KCOV
          only for x86_64. KCOV requires testing on other archs, and most likely
          disabling of instrumentation for some early boot code.
 
+config CC_HAS_SANCOV_TRACE_PC
+       def_bool $(cc-option,-fsanitize-coverage=trace-pc)
+
 config KCOV
        bool "Code coverage for fuzzing"
        depends on ARCH_HAS_KCOV
+       depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
        select DEBUG_FS
-       select GCC_PLUGINS if !COMPILE_TEST
-       select GCC_PLUGIN_SANCOV if !COMPILE_TEST
+       select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC
        help
          KCOV exposes kernel code coverage information in a form suitable
          for coverage-guided fuzzing (randomized testing).
@@ -755,7 +758,7 @@ config KCOV
 config KCOV_ENABLE_COMPARISONS
        bool "Enable comparison operands collection by KCOV"
        depends on KCOV
-       default n
+       depends on $(cc-option,-fsanitize-coverage=trace-cmp)
        help
          KCOV also exposes operands of every comparison in the instrumented
          code along with operand sizes and PCs of the comparison instructions.
@@ -765,7 +768,7 @@ config KCOV_ENABLE_COMPARISONS
 config KCOV_INSTRUMENT_ALL
        bool "Instrument all code by default"
        depends on KCOV
-       default y if KCOV
+       default y
        help
          If you are doing generic system call fuzzing (like e.g. syzkaller),
          then you will want to instrument the whole kernel and you should
@@ -1503,6 +1506,10 @@ config NETDEV_NOTIFIER_ERROR_INJECT
 
          If unsure, say N.
 
+config FUNCTION_ERROR_INJECTION
+       def_bool y
+       depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES
+
 config FAULT_INJECTION
        bool "Fault-injection framework"
        depends on DEBUG_KERNEL
@@ -1510,10 +1517,6 @@ config FAULT_INJECTION
          Provide fault-injection framework.
          For more details, see Documentation/fault-injection/.
 
-config FUNCTION_ERROR_INJECTION
-       def_bool y
-       depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES
-
 config FAILSLAB
        bool "Fault-injection capability for kmalloc"
        depends on FAULT_INJECTION
@@ -1544,16 +1547,6 @@ config FAIL_IO_TIMEOUT
          Only works with drivers that use the generic timeout handling,
          for others it wont do anything.
 
-config FAIL_MMC_REQUEST
-       bool "Fault-injection capability for MMC IO"
-       depends on FAULT_INJECTION_DEBUG_FS && MMC
-       help
-         Provide fault-injection capability for MMC IO.
-         This will make the mmc core return data errors. This is
-         useful to test the error handling in the mmc block device
-         and to test how the mmc host driver handles retries from
-         the block device.
-
 config FAIL_FUTEX
        bool "Fault-injection capability for futexes"
        select DEBUG_FS
@@ -1561,6 +1554,12 @@ config FAIL_FUTEX
        help
          Provide fault-injection capability for futexes.
 
+config FAULT_INJECTION_DEBUG_FS
+       bool "Debugfs entries for fault-injection capabilities"
+       depends on FAULT_INJECTION && SYSFS && DEBUG_FS
+       help
+         Enable configuration of fault-injection capabilities via debugfs.
+
 config FAIL_FUNCTION
        bool "Fault-injection capability for functions"
        depends on FAULT_INJECTION_DEBUG_FS && FUNCTION_ERROR_INJECTION
@@ -1571,11 +1570,15 @@ config FAIL_FUNCTION
          an error value and have to handle it. This is useful to test the
          error handling in various subsystems.
 
-config FAULT_INJECTION_DEBUG_FS
-       bool "Debugfs entries for fault-injection capabilities"
-       depends on FAULT_INJECTION && SYSFS && DEBUG_FS
+config FAIL_MMC_REQUEST
+       bool "Fault-injection capability for MMC IO"
+       depends on FAULT_INJECTION_DEBUG_FS && MMC
        help
-         Enable configuration of fault-injection capabilities via debugfs.
+         Provide fault-injection capability for MMC IO.
+         This will make the mmc core return data errors. This is
+         useful to test the error handling in the mmc block device
+         and to test how the mmc host driver handles retries from
+         the block device.
 
 config FAULT_INJECTION_STACKTRACE_FILTER
        bool "stacktrace filter for fault-injection capabilities"
index 84c6dcb31fbb408f0857368301f013b8cccf743c..956b320292fef9a4055a1a955f37b6f41c2a4b71 100644 (file)
@@ -261,9 +261,9 @@ obj-$(CONFIG_SBITMAP) += sbitmap.o
 obj-$(CONFIG_PARMAN) += parman.o
 
 # GCC library routines
-obj-$(CONFIG_GENERIC_ASHLDI3) += ashldi3.o
-obj-$(CONFIG_GENERIC_ASHRDI3) += ashrdi3.o
-obj-$(CONFIG_GENERIC_LSHRDI3) += lshrdi3.o
-obj-$(CONFIG_GENERIC_MULDI3) += muldi3.o
-obj-$(CONFIG_GENERIC_CMPDI2) += cmpdi2.o
-obj-$(CONFIG_GENERIC_UCMPDI2) += ucmpdi2.o
+obj-$(CONFIG_GENERIC_LIB_ASHLDI3) += ashldi3.o
+obj-$(CONFIG_GENERIC_LIB_ASHRDI3) += ashrdi3.o
+obj-$(CONFIG_GENERIC_LIB_LSHRDI3) += lshrdi3.o
+obj-$(CONFIG_GENERIC_LIB_MULDI3) += muldi3.o
+obj-$(CONFIG_GENERIC_LIB_CMPDI2) += cmpdi2.o
+obj-$(CONFIG_GENERIC_LIB_UCMPDI2) += ucmpdi2.o
index 5c35752a9414ca004def7ad9c27f34f36bbe9029..1a19a0a93dc1cb8931c2f9f5d512650a5a1a0fe6 100644 (file)
@@ -69,7 +69,7 @@ char **argv_split(gfp_t gfp, const char *str, int *argcp)
                return NULL;
 
        argc = count_argc(argv_str);
-       argv = kmalloc(sizeof(*argv) * (argc + 2), gfp);
+       argv = kmalloc_array(argc + 2, sizeof(*argv), gfp);
        if (!argv) {
                kfree(argv_str);
                return NULL;
index 835242e74aaa3372957e46291c08bdc16ec59882..75509a1511a3e0abaf78eeda2f0f6ae1cd86ea87 100644 (file)
@@ -64,11 +64,12 @@ static int interval_tree_test_init(void)
        unsigned long results;
        cycles_t time1, time2, time;
 
-       nodes = kmalloc(nnodes * sizeof(struct interval_tree_node), GFP_KERNEL);
+       nodes = kmalloc_array(nnodes, sizeof(struct interval_tree_node),
+                             GFP_KERNEL);
        if (!nodes)
                return -ENOMEM;
 
-       queries = kmalloc(nsearches * sizeof(int), GFP_KERNEL);
+       queries = kmalloc_array(nsearches, sizeof(int), GFP_KERNEL);
        if (!queries) {
                kfree(nodes);
                return -ENOMEM;
index b0f757bf72136856aa6ae54d93692111bcc1b0c9..015656aa8182d081522615c3eb71d406cc7f809f 100644 (file)
@@ -54,7 +54,7 @@ int __kfifo_alloc(struct __kfifo *fifo, unsigned int size,
                return -EINVAL;
        }
 
-       fifo->data = kmalloc(size * esize, gfp_mask);
+       fifo->data = kmalloc_array(esize, size, gfp_mask);
 
        if (!fifo->data) {
                fifo->mask = 0;
index 28ba40b99337e7098783b6693c55527ea1952ab3..2b10a4024c35179d6835589d18ba8b0a996cb8ab 100644 (file)
@@ -119,7 +119,7 @@ struct lru_cache *lc_create(const char *name, struct kmem_cache *cache,
        slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL);
        if (!slot)
                goto out_fail;
-       element = kzalloc(e_count * sizeof(struct lc_element *), GFP_KERNEL);
+       element = kcalloc(e_count, sizeof(struct lc_element *), GFP_KERNEL);
        if (!element)
                goto out_fail;
 
index 314f4dfa603ee98fd89e1f1006a09e8147af6cc7..20ed0f766787134cc459e5e43bbcbda607ab2217 100644 (file)
@@ -91,14 +91,14 @@ int mpi_resize(MPI a, unsigned nlimbs)
                return 0;       /* no need to do it */
 
        if (a->d) {
-               p = kmalloc(nlimbs * sizeof(mpi_limb_t), GFP_KERNEL);
+               p = kmalloc_array(nlimbs, sizeof(mpi_limb_t), GFP_KERNEL);
                if (!p)
                        return -ENOMEM;
                memcpy(p, a->d, a->alloced * sizeof(mpi_limb_t));
                kzfree(a->d);
                a->d = p;
        } else {
-               a->d = kzalloc(nlimbs * sizeof(mpi_limb_t), GFP_KERNEL);
+               a->d = kcalloc(nlimbs, sizeof(mpi_limb_t), GFP_KERNEL);
                if (!a->d)
                        return -ENOMEM;
        }
index 7d36c1e27ff6550de3f921bd865029b2b56487f7..b7055b2a07d37ad577c2845cc2088108181764db 100644 (file)
@@ -247,7 +247,7 @@ static int __init rbtree_test_init(void)
        cycles_t time1, time2, time;
        struct rb_node *node;
 
-       nodes = kmalloc(nnodes * sizeof(*nodes), GFP_KERNEL);
+       nodes = kmalloc_array(nnodes, sizeof(*nodes), GFP_KERNEL);
        if (!nodes)
                return -ENOMEM;
 
index dfcf54242fb92f50d544169b7c723b81e78f1984..d8bb1a1eba722f89fc307209ed97ba65f0579052 100644 (file)
@@ -88,15 +88,15 @@ static struct rs_codec *codec_init(int symsize, int gfpoly, int (*gffunc)(int),
        rs->gffunc = gffunc;
 
        /* Allocate the arrays */
-       rs->alpha_to = kmalloc(sizeof(uint16_t) * (rs->nn + 1), gfp);
+       rs->alpha_to = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp);
        if (rs->alpha_to == NULL)
                goto err;
 
-       rs->index_of = kmalloc(sizeof(uint16_t) * (rs->nn + 1), gfp);
+       rs->index_of = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp);
        if (rs->index_of == NULL)
                goto err;
 
-       rs->genpoly = kmalloc(sizeof(uint16_t) * (rs->nroots + 1), gfp);
+       rs->genpoly = kmalloc_array(rs->nroots + 1, sizeof(uint16_t), gfp);
        if(rs->genpoly == NULL)
                goto err;
 
index 6fdc6267f4a82ebc732ee049d41d1ecd5a39030d..fdd1b8aa8ac63c99f5165e4795043e653b821f7a 100644 (file)
@@ -52,7 +52,7 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift,
                return 0;
        }
 
-       sb->map = kzalloc_node(sb->map_nr * sizeof(*sb->map), flags, node);
+       sb->map = kcalloc_node(sb->map_nr, sizeof(*sb->map), flags, node);
        if (!sb->map)
                return -ENOMEM;
 
index 06dad7a072fd66385032f541f3c9f77b6d440235..1642fd507a960f5deb2b6d7366db83800a3e547b 100644 (file)
@@ -170,7 +170,8 @@ static struct scatterlist *sg_kmalloc(unsigned int nents, gfp_t gfp_mask)
                kmemleak_alloc(ptr, PAGE_SIZE, 1, gfp_mask);
                return ptr;
        } else
-               return kmalloc(nents * sizeof(struct scatterlist), gfp_mask);
+               return kmalloc_array(nents, sizeof(struct scatterlist),
+                                    gfp_mask);
 }
 
 static void sg_kfree(struct scatterlist *sg, unsigned int nents)
index cee000ac54d8d6813e6226851fe71dcaaa2fad48..b984806d7d7bb1f4665ffe6cecfa5849aecc8c22 100644 (file)
@@ -618,8 +618,9 @@ static ssize_t trigger_batched_requests_store(struct device *dev,
 
        mutex_lock(&test_fw_mutex);
 
-       test_fw_config->reqs = vzalloc(sizeof(struct test_batched_req) *
-                                      test_fw_config->num_requests * 2);
+       test_fw_config->reqs =
+               vzalloc(array3_size(sizeof(struct test_batched_req),
+                                   test_fw_config->num_requests, 2));
        if (!test_fw_config->reqs) {
                rc = -ENOMEM;
                goto out_unlock;
@@ -720,8 +721,9 @@ ssize_t trigger_batched_requests_async_store(struct device *dev,
 
        mutex_lock(&test_fw_mutex);
 
-       test_fw_config->reqs = vzalloc(sizeof(struct test_batched_req) *
-                                      test_fw_config->num_requests * 2);
+       test_fw_config->reqs =
+               vzalloc(array3_size(sizeof(struct test_batched_req),
+                                   test_fw_config->num_requests, 2));
        if (!test_fw_config->reqs) {
                rc = -ENOMEM;
                goto out;
index 0e5b7a61460bb092226a3785abeaa2168d95d790..e3ddd836491faef2a21c1b1218d4fd1c4b219f0f 100644 (file)
@@ -779,8 +779,9 @@ static int kmod_config_sync_info(struct kmod_test_device *test_dev)
        struct test_config *config = &test_dev->config;
 
        free_test_dev_info(test_dev);
-       test_dev->info = vzalloc(config->num_threads *
-                                sizeof(struct kmod_test_device_info));
+       test_dev->info =
+               vzalloc(array_size(sizeof(struct kmod_test_device_info),
+                                  config->num_threads));
        if (!test_dev->info)
                return -ENOMEM;
 
index aecbbb2173052229c9b28bbb5852a0e691c4b46b..2278fe05a1b0a033f3120a7a1927b982c103f5bb 100644 (file)
@@ -367,7 +367,7 @@ static int __init test_overflow_allocation(void)
 
        /* Create dummy device for devm_kmalloc()-family tests. */
        dev = root_device_register(device_name);
-       if (!dev) {
+       if (IS_ERR(dev)) {
                pr_warn("Cannot register test device\n");
                return 1;
        }
index cea592f402ed029d6d5dd63addd2d2bc8a8391f1..b2aa8f5148449de1557e3ee48feebb8f1cab3083 100644 (file)
@@ -260,6 +260,13 @@ plain(void)
 {
        int err;
 
+       /*
+        * Make sure crng is ready. Otherwise we get "(ptrval)" instead
+        * of a hashed address when printing '%p' in plain_hash() and
+        * plain_format().
+        */
+       wait_for_random_bytes();
+
        err = plain_hash();
        if (err) {
                pr_warn("plain 'p' does not appear to be hashed\n");
index f4000c137dbed6da5754713f3d280a9e1caed528..fb69681091134cc879748b40f1f371978056be25 100644 (file)
@@ -285,12 +285,14 @@ static int __init test_rhltable(unsigned int entries)
        if (entries == 0)
                entries = 1;
 
-       rhl_test_objects = vzalloc(sizeof(*rhl_test_objects) * entries);
+       rhl_test_objects = vzalloc(array_size(entries,
+                                             sizeof(*rhl_test_objects)));
        if (!rhl_test_objects)
                return -ENOMEM;
 
        ret = -ENOMEM;
-       obj_in_table = vzalloc(BITS_TO_LONGS(entries) * sizeof(unsigned long));
+       obj_in_table = vzalloc(array_size(sizeof(unsigned long),
+                                         BITS_TO_LONGS(entries)));
        if (!obj_in_table)
                goto out_free;
 
@@ -706,7 +708,8 @@ static int __init test_rht_init(void)
        test_rht_params.max_size = max_size ? : roundup_pow_of_two(entries);
        test_rht_params.nelem_hint = size;
 
-       objs = vzalloc((test_rht_params.max_size + 1) * sizeof(struct test_obj));
+       objs = vzalloc(array_size(sizeof(struct test_obj),
+                                 test_rht_params.max_size + 1));
        if (!objs)
                return -ENOMEM;
 
@@ -753,10 +756,10 @@ static int __init test_rht_init(void)
        pr_info("Testing concurrent rhashtable access from %d threads\n",
                tcount);
        sema_init(&prestart_sem, 1 - tcount);
-       tdata = vzalloc(tcount * sizeof(struct thread_data));
+       tdata = vzalloc(array_size(tcount, sizeof(struct thread_data)));
        if (!tdata)
                return -ENOMEM;
-       objs  = vzalloc(tcount * entries * sizeof(struct test_obj));
+       objs  = vzalloc(array3_size(sizeof(struct test_obj), tcount, entries));
        if (!objs) {
                vfree(tdata);
                return -ENOMEM;
index 25ca2d4c1e19118b2c34bdee66ab1a64ed54fe3d..597998169a96fc11a0270697b417240b977b0f2a 100644 (file)
@@ -17,7 +17,7 @@
 #include <linux/module.h>
 #include <linux/libgcc.h>
 
-word_type __ucmpdi2(unsigned long long a, unsigned long long b)
+word_type notrace __ucmpdi2(unsigned long long a, unsigned long long b)
 {
        const DWunion au = {.ll = a};
        const DWunion bu = {.ll = b};
index 126548b5a292bce68708be3b725dfa04465e5078..2bf12da9baa0666e6c772ede6ff63f4900106fe4 100644 (file)
@@ -307,12 +307,10 @@ static int __init init_cleancache(void)
        struct dentry *root = debugfs_create_dir("cleancache", NULL);
        if (root == NULL)
                return -ENXIO;
-       debugfs_create_u64("succ_gets", S_IRUGO, root, &cleancache_succ_gets);
-       debugfs_create_u64("failed_gets", S_IRUGO,
-                               root, &cleancache_failed_gets);
-       debugfs_create_u64("puts", S_IRUGO, root, &cleancache_puts);
-       debugfs_create_u64("invalidates", S_IRUGO,
-                               root, &cleancache_invalidates);
+       debugfs_create_u64("succ_gets", 0444, root, &cleancache_succ_gets);
+       debugfs_create_u64("failed_gets", 0444, root, &cleancache_failed_gets);
+       debugfs_create_u64("puts", 0444, root, &cleancache_puts);
+       debugfs_create_u64("invalidates", 0444, root, &cleancache_invalidates);
 #endif
        return 0;
 }
index 275df8b5b22e7bdb722e95774a1948d6c69fa4f8..f23467291cfb0bcb06ad736ee7dd34b5705ac989 100644 (file)
@@ -172,23 +172,18 @@ static void cma_debugfs_add_one(struct cma *cma, int idx)
 
        tmp = debugfs_create_dir(name, cma_debugfs_root);
 
-       debugfs_create_file("alloc", S_IWUSR, tmp, cma,
-                               &cma_alloc_fops);
-
-       debugfs_create_file("free", S_IWUSR, tmp, cma,
-                               &cma_free_fops);
-
-       debugfs_create_file("base_pfn", S_IRUGO, tmp,
-                               &cma->base_pfn, &cma_debugfs_fops);
-       debugfs_create_file("count", S_IRUGO, tmp,
-                               &cma->count, &cma_debugfs_fops);
-       debugfs_create_file("order_per_bit", S_IRUGO, tmp,
-                               &cma->order_per_bit, &cma_debugfs_fops);
-       debugfs_create_file("used", S_IRUGO, tmp, cma, &cma_used_fops);
-       debugfs_create_file("maxchunk", S_IRUGO, tmp, cma, &cma_maxchunk_fops);
+       debugfs_create_file("alloc", 0200, tmp, cma, &cma_alloc_fops);
+       debugfs_create_file("free", 0200, tmp, cma, &cma_free_fops);
+       debugfs_create_file("base_pfn", 0444, tmp,
+                           &cma->base_pfn, &cma_debugfs_fops);
+       debugfs_create_file("count", 0444, tmp, &cma->count, &cma_debugfs_fops);
+       debugfs_create_file("order_per_bit", 0444, tmp,
+                           &cma->order_per_bit, &cma_debugfs_fops);
+       debugfs_create_file("used", 0444, tmp, cma, &cma_used_fops);
+       debugfs_create_file("maxchunk", 0444, tmp, cma, &cma_maxchunk_fops);
 
        u32s = DIV_ROUND_UP(cma_bitmap_maxno(cma), BITS_PER_BYTE * sizeof(u32));
-       debugfs_create_u32_array("bitmap", S_IRUGO, tmp, (u32*)cma->bitmap, u32s);
+       debugfs_create_u32_array("bitmap", 0444, tmp, (u32 *)cma->bitmap, u32s);
 }
 
 static int __init cma_debugfs_init(void)
index 29bd1df18b98aff1d4a2a59c9253d5734c32bb20..faca45ebe62dfbb58099661158334ab9ce0155f8 100644 (file)
@@ -1899,7 +1899,7 @@ static ssize_t sysfs_compact_node(struct device *dev,
 
        return count;
 }
-static DEVICE_ATTR(compact, S_IWUSR, NULL, sysfs_compact_node);
+static DEVICE_ATTR(compact, 0200, NULL, sysfs_compact_node);
 
 int compaction_register_node(struct node *node)
 {
index 4d90a64b2fdc8d50af4ef60278901a5b089b5735..6d4b97e7e9e97752413caef09df772ece3d6f45c 100644 (file)
@@ -105,7 +105,7 @@ show_pools(struct device *dev, struct device_attribute *attr, char *buf)
        return PAGE_SIZE - size;
 }
 
-static DEVICE_ATTR(pools, S_IRUGO, show_pools, NULL);
+static DEVICE_ATTR(pools, 0444, show_pools, NULL);
 
 /**
  * dma_pool_create - Creates a pool of consistent memory blocks, for dma.
index 1f2f248e36019121bad626a9a81403b5b5316b1d..b135ebb88b6f729e145430999591beb3db2371d2 100644 (file)
@@ -42,7 +42,7 @@ __setup("failslab=", setup_failslab);
 static int __init failslab_debugfs_init(void)
 {
        struct dentry *dir;
-       umode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
+       umode_t mode = S_IFREG | 0600;
 
        dir = fault_create_debugfs_attr("failslab", NULL, &failslab.attr);
        if (IS_ERR(dir))
index 4f5476a0f95535a1c687b898b96373b7fc1c040e..157e5bf63504258e3d1be341854627d47d4b96d0 100644 (file)
@@ -486,12 +486,11 @@ static int __init init_frontswap(void)
        struct dentry *root = debugfs_create_dir("frontswap", NULL);
        if (root == NULL)
                return -ENXIO;
-       debugfs_create_u64("loads", S_IRUGO, root, &frontswap_loads);
-       debugfs_create_u64("succ_stores", S_IRUGO, root, &frontswap_succ_stores);
-       debugfs_create_u64("failed_stores", S_IRUGO, root,
-                               &frontswap_failed_stores);
-       debugfs_create_u64("invalidates", S_IRUGO,
-                               root, &frontswap_invalidates);
+       debugfs_create_u64("loads", 0444, root, &frontswap_loads);
+       debugfs_create_u64("succ_stores", 0444, root, &frontswap_succ_stores);
+       debugfs_create_u64("failed_stores", 0444, root,
+                          &frontswap_failed_stores);
+       debugfs_create_u64("invalidates", 0444, root, &frontswap_invalidates);
 #endif
        return 0;
 }
index 0f44759486e22e68ce88c9d73a4fdecd7eb925aa..6a473709e9b6b953393ea12215a38c9e47c9f849 100644 (file)
@@ -23,7 +23,7 @@ static int __gup_benchmark_ioctl(unsigned int cmd,
        struct page **pages;
 
        nr_pages = gup->size / PAGE_SIZE;
-       pages = kvzalloc(sizeof(void *) * nr_pages, GFP_KERNEL);
+       pages = kvcalloc(nr_pages, sizeof(void *), GFP_KERNEL);
        if (!pages)
                return -ENOMEM;
 
index ba8fdc0b6e7f712104e076244dc6def9ab2aa097..1cd7c1a57a144320b7d1729d7caa6ec93351cc54 100644 (file)
@@ -1131,8 +1131,8 @@ static int do_huge_pmd_wp_page_fallback(struct vm_fault *vmf, pmd_t orig_pmd,
        unsigned long mmun_start;       /* For mmu_notifiers */
        unsigned long mmun_end;         /* For mmu_notifiers */
 
-       pages = kmalloc(sizeof(struct page *) * HPAGE_PMD_NR,
-                       GFP_KERNEL);
+       pages = kmalloc_array(HPAGE_PMD_NR, sizeof(struct page *),
+                             GFP_KERNEL);
        if (unlikely(!pages)) {
                ret |= VM_FAULT_OOM;
                goto out;
index 696befffe6f7237b0d58f36839092e9f2a96aeec..3612fbb32e9d5412e8494e4c220fad84e3a4e779 100644 (file)
@@ -2798,7 +2798,8 @@ static int __init hugetlb_init(void)
        num_fault_mutexes = 1;
 #endif
        hugetlb_fault_mutex_table =
-               kmalloc(sizeof(struct mutex) * num_fault_mutexes, GFP_KERNEL);
+               kmalloc_array(num_fault_mutexes, sizeof(struct mutex),
+                             GFP_KERNEL);
        BUG_ON(!hugetlb_fault_mutex_table);
 
        for (i = 0; i < num_fault_mutexes; i++)
index e2d2886fb1df33d973e69ab49790c2d0dba4ee51..a6d43cf9a98240d31b18198fc6ef2e55e5a8713c 100644 (file)
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -216,6 +216,8 @@ struct rmap_item {
 #define SEQNR_MASK     0x0ff   /* low bits of unstable tree seqnr */
 #define UNSTABLE_FLAG  0x100   /* is a node of the unstable tree */
 #define STABLE_FLAG    0x200   /* is listed from the stable tree */
+#define KSM_FLAG_MASK  (SEQNR_MASK|UNSTABLE_FLAG|STABLE_FLAG)
+                               /* to mask all the flags */
 
 /* The stable and unstable tree heads */
 static struct rb_root one_stable_tree[1] = { RB_ROOT };
@@ -2598,10 +2600,15 @@ void rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc)
                anon_vma_lock_read(anon_vma);
                anon_vma_interval_tree_foreach(vmac, &anon_vma->rb_root,
                                               0, ULONG_MAX) {
+                       unsigned long addr;
+
                        cond_resched();
                        vma = vmac->vma;
-                       if (rmap_item->address < vma->vm_start ||
-                           rmap_item->address >= vma->vm_end)
+
+                       /* Ignore the stable/unstable/sqnr flags */
+                       addr = rmap_item->address & ~KSM_FLAG_MASK;
+
+                       if (addr < vma->vm_start || addr >= vma->vm_end)
                                continue;
                        /*
                         * Initially we examine only the vma which covers this
@@ -2615,8 +2622,7 @@ void rmap_walk_ksm(struct page *page, struct rmap_walk_control *rwc)
                        if (rwc->invalid_vma && rwc->invalid_vma(vma, rwc->arg))
                                continue;
 
-                       if (!rwc->rmap_one(page, vma,
-                                       rmap_item->address, rwc->arg)) {
+                       if (!rwc->rmap_one(page, vma, addr, rwc->arg)) {
                                anon_vma_unlock_read(anon_vma);
                                return;
                        }
index 93ad42bc8a73c0e6cb1f1e42847d44963c2510ec..cc16d70b8333890730d16c08b858631947e38d70 100644 (file)
@@ -20,6 +20,7 @@
 #include <linux/kmemleak.h>
 #include <linux/seq_file.h>
 #include <linux/memblock.h>
+#include <linux/bootmem.h>
 
 #include <asm/sections.h>
 #include <linux/io.h>
@@ -1808,10 +1809,13 @@ static int __init memblock_init_debugfs(void)
        struct dentry *root = debugfs_create_dir("memblock", NULL);
        if (!root)
                return -ENXIO;
-       debugfs_create_file("memory", S_IRUGO, root, &memblock.memory, &memblock_debug_fops);
-       debugfs_create_file("reserved", S_IRUGO, root, &memblock.reserved, &memblock_debug_fops);
+       debugfs_create_file("memory", 0444, root,
+                           &memblock.memory, &memblock_debug_fops);
+       debugfs_create_file("reserved", 0444, root,
+                           &memblock.reserved, &memblock_debug_fops);
 #ifdef CONFIG_HAVE_MEMBLOCK_PHYS_MAP
-       debugfs_create_file("physmem", S_IRUGO, root, &memblock.physmem, &memblock_debug_fops);
+       debugfs_create_file("physmem", 0444, root,
+                           &memblock.physmem, &memblock_debug_fops);
 #endif
 
        return 0;
index c1e64d60ed0285c3163235c7a5287c7d2f1edd2e..e6f0d5ef320aa65d2b65ceed4b202021a84fd49b 100644 (file)
@@ -3550,7 +3550,8 @@ static int mem_cgroup_oom_control_read(struct seq_file *sf, void *v)
 
        seq_printf(sf, "oom_kill_disable %d\n", memcg->oom_kill_disable);
        seq_printf(sf, "under_oom %d\n", (bool)memcg->under_oom);
-       seq_printf(sf, "oom_kill %lu\n", memcg_sum_events(memcg, OOM_KILL));
+       seq_printf(sf, "oom_kill %lu\n",
+                  atomic_long_read(&memcg->memory_events[MEMCG_OOM_KILL]));
        return 0;
 }
 
@@ -5239,7 +5240,8 @@ static int memory_events_show(struct seq_file *m, void *v)
                   atomic_long_read(&memcg->memory_events[MEMCG_MAX]));
        seq_printf(m, "oom %lu\n",
                   atomic_long_read(&memcg->memory_events[MEMCG_OOM]));
-       seq_printf(m, "oom_kill %lu\n", memcg_sum_events(memcg, OOM_KILL));
+       seq_printf(m, "oom_kill %lu\n",
+                  atomic_long_read(&memcg->memory_events[MEMCG_OOM_KILL]));
 
        return 0;
 }
@@ -5480,6 +5482,10 @@ enum mem_cgroup_protection mem_cgroup_protected(struct mem_cgroup *root,
        elow = memcg->memory.low;
 
        parent = parent_mem_cgroup(memcg);
+       /* No parent means a non-hierarchical mode on v1 memcg */
+       if (!parent)
+               return MEMCG_PROT_NONE;
+
        if (parent == root)
                goto exit;
 
index 049470aa1e3eefc88407e9a35f1ca252fd01912d..5c2e18505f75ba67da4b2c2df6a42b1785543b7a 100644 (file)
@@ -191,8 +191,6 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
                drop_rmap_locks(vma);
 }
 
-#define LATENCY_LIMIT  (64 * PAGE_SIZE)
-
 unsigned long move_page_tables(struct vm_area_struct *vma,
                unsigned long old_addr, struct vm_area_struct *new_vma,
                unsigned long new_addr, unsigned long len,
@@ -247,8 +245,6 @@ unsigned long move_page_tables(struct vm_area_struct *vma,
                next = (new_addr + PMD_SIZE) & PMD_MASK;
                if (extent > next - new_addr)
                        extent = next - new_addr;
-               if (extent > LATENCY_LIMIT)
-                       extent = LATENCY_LIMIT;
                move_ptes(vma, old_pmd, old_addr, old_addr + extent, new_vma,
                          new_pmd, new_addr, need_rmap_locks, &need_flush);
        }
index 6694348b27e98db274c1f99415061c71c1c1d7db..84081e77bc51cec7a9089937429046b7107aa027 100644 (file)
@@ -913,7 +913,7 @@ static void oom_kill_process(struct oom_control *oc, const char *message)
 
        /* Raise event before sending signal: task reaper must see this */
        count_vm_event(OOM_KILL);
-       count_memcg_event_mm(mm, OOM_KILL);
+       memcg_memory_event_mm(mm, MEMCG_OOM_KILL);
 
        /*
         * We should send SIGKILL before granting access to memory reserves
index 07b3c23762adbbc441ba7fb9e1f39c2c694d85c1..1521100f1e63b729bba37e21723a312950d688d8 100644 (file)
@@ -3061,7 +3061,7 @@ static bool should_fail_alloc_page(gfp_t gfp_mask, unsigned int order)
 
 static int __init fail_page_alloc_debugfs(void)
 {
-       umode_t mode = S_IFREG | S_IRUSR | S_IWUSR;
+       umode_t mode = S_IFREG | 0600;
        struct dentry *dir;
 
        dir = fault_create_debugfs_attr("fail_page_alloc", NULL,
index e412a63b2b74f7820298751e1cf382fe90c48005..6302bc62c27d6b69939ab2791c57a5da8945e8aa 100644 (file)
@@ -201,7 +201,7 @@ static ssize_t page_idle_bitmap_write(struct file *file, struct kobject *kobj,
 }
 
 static struct bin_attribute page_idle_bitmap_attr =
-               __BIN_ATTR(bitmap, S_IRUSR | S_IWUSR,
+               __BIN_ATTR(bitmap, 0600,
                           page_idle_bitmap_read, page_idle_bitmap_write, 0);
 
 static struct bin_attribute *page_idle_bin_attrs[] = {
index 75d21a2259b3b1ff9d2ac624fc9fbab10100580d..d80adfe702d3b85f754589135f3695b4e3394c72 100644 (file)
@@ -631,8 +631,8 @@ static int __init pageowner_init(void)
                return 0;
        }
 
-       dentry = debugfs_create_file("page_owner", S_IRUSR, NULL,
-                       NULL, &proc_page_owner_operations);
+       dentry = debugfs_create_file("page_owner", 0400, NULL,
+                                    NULL, &proc_page_owner_operations);
 
        return PTR_ERR_OR_ZERO(dentry);
 }
index 063ff60ecd901edd979d301e462a94fb51374a20..b5fdd43b60c9088de4779b2c3c02e0a08caf81ae 100644 (file)
@@ -144,7 +144,7 @@ static int percpu_stats_show(struct seq_file *m, void *v)
        spin_unlock_irq(&pcpu_lock);
 
        /* there can be at most this many free and allocated fragments */
-       buffer = vmalloc((2 * max_nr_alloc + 1) * sizeof(int));
+       buffer = vmalloc(array_size(sizeof(int), (2 * max_nr_alloc + 1)));
        if (!buffer)
                return -ENOMEM;
 
index e9a7ac74823de13b912c2896f3254e762d17a172..2cab8440305531f8ab97f3a56c95b91516bcd2ea 100644 (file)
@@ -3013,7 +3013,8 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
        if (len > PAGE_SIZE)
                return -ENAMETOOLONG;
 
-       inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK|S_IRWXUGO, 0, VM_NORESERVE);
+       inode = shmem_get_inode(dir->i_sb, dir, S_IFLNK | 0777, 0,
+                               VM_NORESERVE);
        if (!inode)
                return -ENOSPC;
 
@@ -3445,7 +3446,7 @@ static int shmem_show_options(struct seq_file *seq, struct dentry *root)
                        sbinfo->max_blocks << (PAGE_SHIFT - 10));
        if (sbinfo->max_inodes != shmem_default_max_inodes())
                seq_printf(seq, ",nr_inodes=%lu", sbinfo->max_inodes);
-       if (sbinfo->mode != (S_IRWXUGO | S_ISVTX))
+       if (sbinfo->mode != (0777 | S_ISVTX))
                seq_printf(seq, ",mode=%03ho", sbinfo->mode);
        if (!uid_eq(sbinfo->uid, GLOBAL_ROOT_UID))
                seq_printf(seq, ",uid=%u",
@@ -3486,7 +3487,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
        if (!sbinfo)
                return -ENOMEM;
 
-       sbinfo->mode = S_IRWXUGO | S_ISVTX;
+       sbinfo->mode = 0777 | S_ISVTX;
        sbinfo->uid = current_fsuid();
        sbinfo->gid = current_fsgid();
        sb->s_fs_info = sbinfo;
@@ -3929,7 +3930,7 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name, l
        d_set_d_op(path.dentry, &anon_ops);
 
        res = ERR_PTR(-ENOSPC);
-       inode = shmem_get_inode(sb, NULL, S_IFREG | S_IRWXUGO, 0, flags);
+       inode = shmem_get_inode(sb, NULL, S_IFREG | 0777, 0, flags);
        if (!inode)
                goto put_memory;
 
index 36688f6c87ebd84d8978cecb26bc4739cb8b0910..aa76a70e087e6f5f1b1f61a18065831447dffec5 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -4338,7 +4338,8 @@ static int leaks_show(struct seq_file *m, void *p)
        if (x[0] == x[1]) {
                /* Increase the buffer size */
                mutex_unlock(&slab_mutex);
-               m->private = kzalloc(x[0] * 4 * sizeof(unsigned long), GFP_KERNEL);
+               m->private = kcalloc(x[0] * 4, sizeof(unsigned long),
+                                    GFP_KERNEL);
                if (!m->private) {
                        /* Too bad, we are really out */
                        m->private = x;
index 98dcdc3520623bf776164982224b7b258e9a2291..890b1f04a03a3d46f80fe1b2cfccae1f14b79836 100644 (file)
@@ -136,6 +136,7 @@ void slab_init_memcg_params(struct kmem_cache *s)
        s->memcg_params.root_cache = NULL;
        RCU_INIT_POINTER(s->memcg_params.memcg_caches, NULL);
        INIT_LIST_HEAD(&s->memcg_params.children);
+       s->memcg_params.dying = false;
 }
 
 static int init_memcg_params(struct kmem_cache *s,
@@ -608,7 +609,7 @@ void memcg_create_kmem_cache(struct mem_cgroup *memcg,
         * The memory cgroup could have been offlined while the cache
         * creation work was pending.
         */
-       if (memcg->kmem_state != KMEM_ONLINE)
+       if (memcg->kmem_state != KMEM_ONLINE || root_cache->memcg_params.dying)
                goto out_unlock;
 
        idx = memcg_cache_id(memcg);
@@ -712,6 +713,9 @@ void slab_deactivate_memcg_cache_rcu_sched(struct kmem_cache *s,
            WARN_ON_ONCE(s->memcg_params.deact_fn))
                return;
 
+       if (s->memcg_params.root_cache->memcg_params.dying)
+               return;
+
        /* pin memcg so that @s doesn't get destroyed in the middle */
        css_get(&s->memcg_params.memcg->css);
 
@@ -823,11 +827,36 @@ static int shutdown_memcg_caches(struct kmem_cache *s)
                return -EBUSY;
        return 0;
 }
+
+static void flush_memcg_workqueue(struct kmem_cache *s)
+{
+       mutex_lock(&slab_mutex);
+       s->memcg_params.dying = true;
+       mutex_unlock(&slab_mutex);
+
+       /*
+        * SLUB deactivates the kmem_caches through call_rcu_sched. Make
+        * sure all registered rcu callbacks have been invoked.
+        */
+       if (IS_ENABLED(CONFIG_SLUB))
+               rcu_barrier_sched();
+
+       /*
+        * SLAB and SLUB create memcg kmem_caches through workqueue and SLUB
+        * deactivates the memcg kmem_caches through workqueue. Make sure all
+        * previous workitems on workqueue are processed.
+        */
+       flush_workqueue(memcg_kmem_cache_wq);
+}
 #else
 static inline int shutdown_memcg_caches(struct kmem_cache *s)
 {
        return 0;
 }
+
+static inline void flush_memcg_workqueue(struct kmem_cache *s)
+{
+}
 #endif /* CONFIG_MEMCG && !CONFIG_SLOB */
 
 void slab_kmem_cache_release(struct kmem_cache *s)
@@ -845,6 +874,8 @@ void kmem_cache_destroy(struct kmem_cache *s)
        if (unlikely(!s))
                return;
 
+       flush_memcg_workqueue(s);
+
        get_online_cpus();
        get_online_mems();
 
@@ -1212,9 +1243,9 @@ void cache_random_seq_destroy(struct kmem_cache *cachep)
 
 #if defined(CONFIG_SLAB) || defined(CONFIG_SLUB_DEBUG)
 #ifdef CONFIG_SLAB
-#define SLABINFO_RIGHTS (S_IWUSR | S_IRUSR)
+#define SLABINFO_RIGHTS (0600)
 #else
-#define SLABINFO_RIGHTS S_IRUSR
+#define SLABINFO_RIGHTS (0400)
 #endif
 
 static void print_slabinfo_header(struct seq_file *m)
index 15505479c3abb8265d8e4a48ffc1aafbf5d185a1..a3b8467c14af642138deaf35fd3ed3f7f87aed93 100644 (file)
--- a/mm/slub.c
+++ b/mm/slub.c
@@ -3623,8 +3623,9 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page,
 #ifdef CONFIG_SLUB_DEBUG
        void *addr = page_address(page);
        void *p;
-       unsigned long *map = kzalloc(BITS_TO_LONGS(page->objects) *
-                                    sizeof(long), GFP_ATOMIC);
+       unsigned long *map = kcalloc(BITS_TO_LONGS(page->objects),
+                                    sizeof(long),
+                                    GFP_ATOMIC);
        if (!map)
                return;
        slab_err(s, page, text, s->name);
@@ -4412,8 +4413,9 @@ static long validate_slab_cache(struct kmem_cache *s)
 {
        int node;
        unsigned long count = 0;
-       unsigned long *map = kmalloc(BITS_TO_LONGS(oo_objects(s->max)) *
-                               sizeof(unsigned long), GFP_KERNEL);
+       unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)),
+                                          sizeof(unsigned long),
+                                          GFP_KERNEL);
        struct kmem_cache_node *n;
 
        if (!map)
@@ -4573,8 +4575,9 @@ static int list_locations(struct kmem_cache *s, char *buf,
        unsigned long i;
        struct loc_track t = { 0, 0, NULL };
        int node;
-       unsigned long *map = kmalloc(BITS_TO_LONGS(oo_objects(s->max)) *
-                                    sizeof(unsigned long), GFP_KERNEL);
+       unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)),
+                                          sizeof(unsigned long),
+                                          GFP_KERNEL);
        struct kmem_cache_node *n;
 
        if (!map || !alloc_loc_track(&t, PAGE_SIZE / sizeof(struct location),
@@ -4750,7 +4753,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s,
        int x;
        unsigned long *nodes;
 
-       nodes = kzalloc(sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
+       nodes = kcalloc(nr_node_ids, sizeof(unsigned long), GFP_KERNEL);
        if (!nodes)
                return -ENOMEM;
 
@@ -5293,7 +5296,7 @@ static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si)
        unsigned long sum  = 0;
        int cpu;
        int len;
-       int *data = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL);
+       int *data = kmalloc_array(nr_cpu_ids, sizeof(int), GFP_KERNEL);
 
        if (!data)
                return -ENOMEM;
index f51ac051c0c9ede270c925081ba4be6428f9fe4b..a791411fed71663af9839f8c2a4cfaba42ddedca 100644 (file)
@@ -122,12 +122,12 @@ static int alloc_swap_slot_cache(unsigned int cpu)
         * as kvzalloc could trigger reclaim and get_swap_page,
         * which can lock swap_slots_cache_mutex.
         */
-       slots = kvzalloc(sizeof(swp_entry_t) * SWAP_SLOTS_CACHE_SIZE,
+       slots = kvcalloc(SWAP_SLOTS_CACHE_SIZE, sizeof(swp_entry_t),
                         GFP_KERNEL);
        if (!slots)
                return -ENOMEM;
 
-       slots_ret = kvzalloc(sizeof(swp_entry_t) * SWAP_SLOTS_CACHE_SIZE,
+       slots_ret = kvcalloc(SWAP_SLOTS_CACHE_SIZE, sizeof(swp_entry_t),
                             GFP_KERNEL);
        if (!slots_ret) {
                kvfree(slots);
index ab8e59cd18ea09df428b3eb6b19e58eb7592564c..ecee9c6c4cc1725028fd723452f3655c0799a8a7 100644 (file)
@@ -620,7 +620,7 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages)
        unsigned int i, nr;
 
        nr = DIV_ROUND_UP(nr_pages, SWAP_ADDRESS_SPACE_PAGES);
-       spaces = kvzalloc(sizeof(struct address_space) * nr, GFP_KERNEL);
+       spaces = kvcalloc(nr, sizeof(struct address_space), GFP_KERNEL);
        if (!spaces)
                return -ENOMEM;
        for (i = 0; i < nr; i++) {
index 78a015fcec3b1efe29b56580eb3d4dc510243f6a..2cc2972eedaf1088e8a1ea0017f701b18c729494 100644 (file)
@@ -100,7 +100,7 @@ atomic_t nr_rotate_swap = ATOMIC_INIT(0);
 
 static inline unsigned char swap_count(unsigned char ent)
 {
-       return ent & ~SWAP_HAS_CACHE;   /* may include SWAP_HAS_CONT flag */
+       return ent & ~SWAP_HAS_CACHE;   /* may include COUNT_CONTINUED flag */
 }
 
 /* returns 1 if swap entry is freed */
@@ -3196,7 +3196,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
                p->cluster_next = 1 + (prandom_u32() % p->highest_bit);
                nr_cluster = DIV_ROUND_UP(maxpages, SWAPFILE_CLUSTER);
 
-               cluster_info = kvzalloc(nr_cluster * sizeof(*cluster_info),
+               cluster_info = kvcalloc(nr_cluster, sizeof(*cluster_info),
                                        GFP_KERNEL);
                if (!cluster_info) {
                        error = -ENOMEM;
@@ -3233,7 +3233,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
        }
        /* frontswap enabled? set up bit-per-page map for frontswap */
        if (IS_ENABLED(CONFIG_FRONTSWAP))
-               frontswap_map = kvzalloc(BITS_TO_LONGS(maxpages) * sizeof(long),
+               frontswap_map = kvcalloc(BITS_TO_LONGS(maxpages),
+                                        sizeof(long),
                                         GFP_KERNEL);
 
        if (p->bdev &&(swap_flags & SWAP_FLAG_DISCARD) && swap_discardable(p)) {
index 89efac3a020e5bb47cc0fcbfb83c0fb114c0498f..cfea25be77548cfad6ffc5d4c4d3f60445804f52 100644 (file)
@@ -2741,11 +2741,11 @@ static const struct seq_operations vmalloc_op = {
 static int __init proc_vmalloc_init(void)
 {
        if (IS_ENABLED(CONFIG_NUMA))
-               proc_create_seq_private("vmallocinfo", S_IRUSR, NULL,
+               proc_create_seq_private("vmallocinfo", 0400, NULL,
                                &vmalloc_op,
                                nr_node_ids * sizeof(unsigned int), NULL);
        else
-               proc_create_seq("vmallocinfo", S_IRUSR, NULL, &vmalloc_op);
+               proc_create_seq("vmallocinfo", 0400, NULL, &vmalloc_op);
        return 0;
 }
 module_init(proc_vmalloc_init);
index 61cb05dc950caf394dbf375b5b7084a193cbaddb..8d87e973a4f509955e3c0974ed3a2e808cbd0688 100644 (file)
@@ -661,8 +661,9 @@ static void zs_pool_stat_create(struct zs_pool *pool, const char *name)
        }
        pool->stat_dentry = entry;
 
-       entry = debugfs_create_file("classes", S_IFREG | S_IRUGO,
-                       pool->stat_dentry, pool, &zs_stats_size_fops);
+       entry = debugfs_create_file("classes", S_IFREG | 0444,
+                                   pool->stat_dentry, pool,
+                                   &zs_stats_size_fops);
        if (!entry) {
                pr_warn("%s: debugfs file entry <%s> creation failed\n",
                                name, "classes");
index 61a5c41972dba22bc35179a13d40e900dea679b6..7d34e69507e305adec0a64b5e272626385f9d651 100644 (file)
@@ -1256,26 +1256,26 @@ static int __init zswap_debugfs_init(void)
        if (!zswap_debugfs_root)
                return -ENOMEM;
 
-       debugfs_create_u64("pool_limit_hit", S_IRUGO,
-                       zswap_debugfs_root, &zswap_pool_limit_hit);
-       debugfs_create_u64("reject_reclaim_fail", S_IRUGO,
-                       zswap_debugfs_root, &zswap_reject_reclaim_fail);
-       debugfs_create_u64("reject_alloc_fail", S_IRUGO,
-                       zswap_debugfs_root, &zswap_reject_alloc_fail);
-       debugfs_create_u64("reject_kmemcache_fail", S_IRUGO,
-                       zswap_debugfs_root, &zswap_reject_kmemcache_fail);
-       debugfs_create_u64("reject_compress_poor", S_IRUGO,
-                       zswap_debugfs_root, &zswap_reject_compress_poor);
-       debugfs_create_u64("written_back_pages", S_IRUGO,
-                       zswap_debugfs_root, &zswap_written_back_pages);
-       debugfs_create_u64("duplicate_entry", S_IRUGO,
-                       zswap_debugfs_root, &zswap_duplicate_entry);
-       debugfs_create_u64("pool_total_size", S_IRUGO,
-                       zswap_debugfs_root, &zswap_pool_total_size);
-       debugfs_create_atomic_t("stored_pages", S_IRUGO,
-                       zswap_debugfs_root, &zswap_stored_pages);
+       debugfs_create_u64("pool_limit_hit", 0444,
+                          zswap_debugfs_root, &zswap_pool_limit_hit);
+       debugfs_create_u64("reject_reclaim_fail", 0444,
+                          zswap_debugfs_root, &zswap_reject_reclaim_fail);
+       debugfs_create_u64("reject_alloc_fail", 0444,
+                          zswap_debugfs_root, &zswap_reject_alloc_fail);
+       debugfs_create_u64("reject_kmemcache_fail", 0444,
+                          zswap_debugfs_root, &zswap_reject_kmemcache_fail);
+       debugfs_create_u64("reject_compress_poor", 0444,
+                          zswap_debugfs_root, &zswap_reject_compress_poor);
+       debugfs_create_u64("written_back_pages", 0444,
+                          zswap_debugfs_root, &zswap_written_back_pages);
+       debugfs_create_u64("duplicate_entry", 0444,
+                          zswap_debugfs_root, &zswap_duplicate_entry);
+       debugfs_create_u64("pool_total_size", 0444,
+                          zswap_debugfs_root, &zswap_pool_total_size);
+       debugfs_create_atomic_t("stored_pages", 0444,
+                               zswap_debugfs_root, &zswap_stored_pages);
        debugfs_create_atomic_t("same_filled_pages", 0444,
-                       zswap_debugfs_root, &zswap_same_filled_pages);
+                               zswap_debugfs_root, &zswap_same_filled_pages);
 
        return 0;
 }
index 16e10680518c4cba784296ff96ddcc2643cabf82..931ea00c4fedb9a8a2c4d2ae9a1f24d7e51d7d04 100644 (file)
@@ -242,8 +242,9 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
                                                                "w", nwname);
                                if (!errcode) {
                                        *wnames =
-                                           kmalloc(sizeof(char *) * *nwname,
-                                                   GFP_NOFS);
+                                           kmalloc_array(*nwname,
+                                                         sizeof(char *),
+                                                         GFP_NOFS);
                                        if (!*wnames)
                                                errcode = -ENOMEM;
                                }
@@ -285,9 +286,9 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt,
                                    p9pdu_readf(pdu, proto_version, "w", nwqid);
                                if (!errcode) {
                                        *wqids =
-                                           kmalloc(*nwqid *
-                                                   sizeof(struct p9_qid),
-                                                   GFP_NOFS);
+                                           kmalloc_array(*nwqid,
+                                                         sizeof(struct p9_qid),
+                                                         GFP_NOFS);
                                        if (*wqids == NULL)
                                                errcode = -ENOMEM;
                                }
index 4d0372263e5d3057f0b300fbacb6f50a3c58e6ad..05006cbb33616e4a30de07180c1d400c91d05a10 100644 (file)
@@ -360,7 +360,8 @@ static int p9_get_mapped_pages(struct virtio_chan *chan,
                nr_pages = DIV_ROUND_UP((unsigned long)p + len, PAGE_SIZE) -
                           (unsigned long)p / PAGE_SIZE;
 
-               *pages = kmalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
+               *pages = kmalloc_array(nr_pages, sizeof(struct page *),
+                                      GFP_NOFS);
                if (!*pages)
                        return -ENOMEM;
 
index 31e0dcb970f81c0bfb1a827c3a7203c14a4527db..75620c2f261723a915b74df013ac214479ba70c4 100644 (file)
@@ -472,7 +472,7 @@ static const uint8_t *copy_macs(struct mpoa_client *mpc,
                if (mpc->number_of_mps_macs != 0)
                        kfree(mpc->mps_macs);
                mpc->number_of_mps_macs = 0;
-               mpc->mps_macs = kmalloc(num_macs * ETH_ALEN, GFP_KERNEL);
+               mpc->mps_macs = kmalloc_array(ETH_ALEN, num_macs, GFP_KERNEL);
                if (mpc->mps_macs == NULL) {
                        pr_info("(%s) out of mem\n", mpc->dev->name);
                        return NULL;
index 1dec337901988ad96b6eeaf6b7a46f3da85f59c7..ee8ef12282639d09ac975c7ef0e09b644a719009 100644 (file)
@@ -1281,7 +1281,7 @@ int hci_inquiry(void __user *arg)
        /* cache_dump can't sleep. Therefore we allocate temp buffer and then
         * copy it to the user space.
         */
-       buf = kmalloc(sizeof(struct inquiry_info) * max_rsp, GFP_KERNEL);
+       buf = kmalloc_array(max_rsp, sizeof(struct inquiry_info), GFP_KERNEL);
        if (!buf) {
                err = -ENOMEM;
                goto done;
index 9b7907ebfa01b0332be1528b507465c1a304ebe6..d17a4736e47c0abf6fe3be7df34f60bd1f32f1fb 100644 (file)
@@ -331,7 +331,7 @@ static int l2cap_seq_list_init(struct l2cap_seq_list *seq_list, u16 size)
         */
        alloc_size = roundup_pow_of_two(size);
 
-       seq_list->list = kmalloc(sizeof(u16) * alloc_size, GFP_KERNEL);
+       seq_list->list = kmalloc_array(alloc_size, sizeof(u16), GFP_KERNEL);
        if (!seq_list->list)
                return -ENOMEM;
 
index cb4729539b82d1b3013b9d6ca60f20ded0062a2d..920665dd92db30232734b7d8492c0687d974becc 100644 (file)
@@ -333,7 +333,7 @@ static int br_mdb_rehash(struct net_bridge_mdb_htable __rcu **mdbp, int max,
        mdb->max = max;
        mdb->old = old;
 
-       mdb->mhash = kzalloc(max * sizeof(*mdb->mhash), GFP_ATOMIC);
+       mdb->mhash = kcalloc(max, sizeof(*mdb->mhash), GFP_ATOMIC);
        if (!mdb->mhash) {
                kfree(mdb);
                return -ENOMEM;
index 28f68a2ec911d6b3e7e7c1e92a1e69ce83196c55..491828713e0bd738763beae0c48aff44dcc5c76f 100644 (file)
@@ -411,6 +411,12 @@ ebt_check_watcher(struct ebt_entry_watcher *w, struct xt_tgchk_param *par,
        watcher = xt_request_find_target(NFPROTO_BRIDGE, w->u.name, 0);
        if (IS_ERR(watcher))
                return PTR_ERR(watcher);
+
+       if (watcher->family != NFPROTO_BRIDGE) {
+               module_put(watcher->me);
+               return -ENOENT;
+       }
+
        w->u.watcher = watcher;
 
        par->target   = watcher;
@@ -709,6 +715,8 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
        }
        i = 0;
 
+       memset(&mtpar, 0, sizeof(mtpar));
+       memset(&tgpar, 0, sizeof(tgpar));
        mtpar.net       = tgpar.net       = net;
        mtpar.table     = tgpar.table     = name;
        mtpar.entryinfo = tgpar.entryinfo = e;
@@ -730,6 +738,13 @@ ebt_check_entry(struct ebt_entry *e, struct net *net,
                goto cleanup_watchers;
        }
 
+       /* Reject UNSPEC, xtables verdicts/return values are incompatible */
+       if (target->family != NFPROTO_BRIDGE) {
+               module_put(target->me);
+               ret = -ENOENT;
+               goto cleanup_watchers;
+       }
+
        t->u.target = target;
        if (t->u.target == &ebt_standard_target) {
                if (gap < sizeof(struct ebt_standard_target)) {
@@ -903,12 +918,13 @@ static int translate_table(struct net *net, const char *name,
                 * if an error occurs
                 */
                newinfo->chainstack =
-                       vmalloc(nr_cpu_ids * sizeof(*(newinfo->chainstack)));
+                       vmalloc(array_size(nr_cpu_ids,
+                                          sizeof(*(newinfo->chainstack))));
                if (!newinfo->chainstack)
                        return -ENOMEM;
                for_each_possible_cpu(i) {
                        newinfo->chainstack[i] =
-                         vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0])));
+                         vmalloc(array_size(udc_cnt, sizeof(*(newinfo->chainstack[0]))));
                        if (!newinfo->chainstack[i]) {
                                while (i)
                                        vfree(newinfo->chainstack[--i]);
@@ -918,7 +934,7 @@ static int translate_table(struct net *net, const char *name,
                        }
                }
 
-               cl_s = vmalloc(udc_cnt * sizeof(*cl_s));
+               cl_s = vmalloc(array_size(udc_cnt, sizeof(*cl_s)));
                if (!cl_s)
                        return -ENOMEM;
                i = 0; /* the i'th udc */
@@ -1293,7 +1309,7 @@ static int do_update_counters(struct net *net, const char *name,
        if (num_counters == 0)
                return -EINVAL;
 
-       tmp = vmalloc(num_counters * sizeof(*tmp));
+       tmp = vmalloc(array_size(num_counters, sizeof(*tmp)));
        if (!tmp)
                return -ENOMEM;
 
@@ -1434,7 +1450,7 @@ static int copy_counters_to_user(struct ebt_table *t,
                return -EINVAL;
        }
 
-       counterstmp = vmalloc(nentries * sizeof(*counterstmp));
+       counterstmp = vmalloc(array_size(nentries, sizeof(*counterstmp)));
        if (!counterstmp)
                return -ENOMEM;
 
@@ -1605,16 +1621,16 @@ struct compat_ebt_entry_mwt {
                compat_uptr_t ptr;
        } u;
        compat_uint_t match_size;
-       compat_uint_t data[0];
+       compat_uint_t data[0] __attribute__ ((aligned (__alignof__(struct compat_ebt_replace))));
 };
 
 /* account for possible padding between match_size and ->data */
 static int ebt_compat_entry_padsize(void)
 {
-       BUILD_BUG_ON(XT_ALIGN(sizeof(struct ebt_entry_match)) <
-                       COMPAT_XT_ALIGN(sizeof(struct compat_ebt_entry_mwt)));
-       return (int) XT_ALIGN(sizeof(struct ebt_entry_match)) -
-                       COMPAT_XT_ALIGN(sizeof(struct compat_ebt_entry_mwt));
+       BUILD_BUG_ON(sizeof(struct ebt_entry_match) <
+                       sizeof(struct compat_ebt_entry_mwt));
+       return (int) sizeof(struct ebt_entry_match) -
+                       sizeof(struct compat_ebt_entry_mwt);
 }
 
 static int ebt_compat_match_offset(const struct xt_match *match,
index eaf05de37f75ca204ded7efdba35c5257e8717d1..6de981270566966eca1c0e0eaf6ed7400fa3e9d3 100644 (file)
@@ -261,7 +261,7 @@ static void nft_reject_br_send_v6_unreach(struct net *net,
        if (!reject6_br_csum_ok(oldskb, hook))
                return;
 
-       nskb = alloc_skb(sizeof(struct iphdr) + sizeof(struct icmp6hdr) +
+       nskb = alloc_skb(sizeof(struct ipv6hdr) + sizeof(struct icmp6hdr) +
                         LL_MAX_HEADER + len, GFP_ATOMIC);
        if (!nskb)
                return;
index 97fedff3f0c4f56bea5f04d1708c59608ab87982..9393f25df08d3fce299aaa463efd79244e6527e9 100644 (file)
@@ -923,8 +923,9 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
                /* create array for CAN frames and copy the data */
                if (msg_head->nframes > 1) {
-                       op->frames = kmalloc(msg_head->nframes * op->cfsiz,
-                                            GFP_KERNEL);
+                       op->frames = kmalloc_array(msg_head->nframes,
+                                                  op->cfsiz,
+                                                  GFP_KERNEL);
                        if (!op->frames) {
                                kfree(op);
                                return -ENOMEM;
@@ -1095,15 +1096,17 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
 
                if (msg_head->nframes > 1) {
                        /* create array for CAN frames and copy the data */
-                       op->frames = kmalloc(msg_head->nframes * op->cfsiz,
-                                            GFP_KERNEL);
+                       op->frames = kmalloc_array(msg_head->nframes,
+                                                  op->cfsiz,
+                                                  GFP_KERNEL);
                        if (!op->frames) {
                                kfree(op);
                                return -ENOMEM;
                        }
 
                        /* create and init array for received CAN frames */
-                       op->last_frames = kzalloc(msg_head->nframes * op->cfsiz,
+                       op->last_frames = kcalloc(msg_head->nframes,
+                                                 op->cfsiz,
                                                  GFP_KERNEL);
                        if (!op->last_frames) {
                                kfree(op->frames);
index 3b3d33ea9ed830373c08889f3e38d7bc695f313b..c6413c3607712de1d20e2b6010433434395020be 100644 (file)
@@ -168,12 +168,6 @@ static char tag_keepalive2 = CEPH_MSGR_TAG_KEEPALIVE2;
 static struct lock_class_key socket_class;
 #endif
 
-/*
- * When skipping (ignoring) a block of input we read it into a "skip
- * buffer," which is this many bytes in size.
- */
-#define SKIP_BUF_SIZE  1024
-
 static void queue_con(struct ceph_connection *con);
 static void cancel_con(struct ceph_connection *con);
 static void ceph_con_workfn(struct work_struct *);
@@ -520,12 +514,18 @@ static int ceph_tcp_connect(struct ceph_connection *con)
        return 0;
 }
 
+/*
+ * If @buf is NULL, discard up to @len bytes.
+ */
 static int ceph_tcp_recvmsg(struct socket *sock, void *buf, size_t len)
 {
        struct kvec iov = {buf, len};
        struct msghdr msg = { .msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL };
        int r;
 
+       if (!buf)
+               msg.msg_flags |= MSG_TRUNC;
+
        iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, len);
        r = sock_recvmsg(sock, &msg, msg.msg_flags);
        if (r == -EAGAIN)
@@ -2575,9 +2575,6 @@ static int try_write(struct ceph_connection *con)
            con->state != CON_STATE_OPEN)
                return 0;
 
-more:
-       dout("try_write out_kvec_bytes %d\n", con->out_kvec_bytes);
-
        /* open the socket first? */
        if (con->state == CON_STATE_PREOPEN) {
                BUG_ON(con->sock);
@@ -2598,7 +2595,8 @@ static int try_write(struct ceph_connection *con)
                }
        }
 
-more_kvec:
+more:
+       dout("try_write out_kvec_bytes %d\n", con->out_kvec_bytes);
        BUG_ON(!con->sock);
 
        /* kvec data queued? */
@@ -2623,7 +2621,7 @@ static int try_write(struct ceph_connection *con)
 
                ret = write_partial_message_data(con);
                if (ret == 1)
-                       goto more_kvec;  /* we need to send the footer, too! */
+                       goto more;  /* we need to send the footer, too! */
                if (ret == 0)
                        goto out;
                if (ret < 0) {
@@ -2659,8 +2657,6 @@ static int try_write(struct ceph_connection *con)
        return ret;
 }
 
-
-
 /*
  * Read what we can from the socket.
  */
@@ -2721,16 +2717,11 @@ static int try_read(struct ceph_connection *con)
        if (con->in_base_pos < 0) {
                /*
                 * skipping + discarding content.
-                *
-                * FIXME: there must be a better way to do this!
                 */
-               static char buf[SKIP_BUF_SIZE];
-               int skip = min((int) sizeof (buf), -con->in_base_pos);
-
-               dout("skipping %d / %d bytes\n", skip, -con->in_base_pos);
-               ret = ceph_tcp_recvmsg(con->sock, buf, skip);
+               ret = ceph_tcp_recvmsg(con->sock, NULL, -con->in_base_pos);
                if (ret <= 0)
                        goto out;
+               dout("skipped %d / %d bytes\n", ret, -con->in_base_pos);
                con->in_base_pos += ret;
                if (con->in_base_pos)
                        goto more;
index 69a2581ddbba2ca2894a30bfe2204985244ad213..a00c74f1154e3a16902c3c788de921c601efe12b 100644 (file)
@@ -766,7 +766,7 @@ void osd_req_op_extent_dup_last(struct ceph_osd_request *osd_req,
 }
 EXPORT_SYMBOL(osd_req_op_extent_dup_last);
 
-void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
+int osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
                        u16 opcode, const char *class, const char *method)
 {
        struct ceph_osd_req_op *op = _osd_req_op_init(osd_req, which,
@@ -778,7 +778,9 @@ void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
        BUG_ON(opcode != CEPH_OSD_OP_CALL);
 
        pagelist = kmalloc(sizeof (*pagelist), GFP_NOFS);
-       BUG_ON(!pagelist);
+       if (!pagelist)
+               return -ENOMEM;
+
        ceph_pagelist_init(pagelist);
 
        op->cls.class_name = class;
@@ -798,6 +800,7 @@ void osd_req_op_cls_init(struct ceph_osd_request *osd_req, unsigned int which,
        osd_req_op_cls_request_info_pagelist(osd_req, which, pagelist);
 
        op->indata_len = payload_len;
+       return 0;
 }
 EXPORT_SYMBOL(osd_req_op_cls_init);
 
@@ -1026,7 +1029,6 @@ struct ceph_osd_request *ceph_osdc_new_request(struct ceph_osd_client *osdc,
                                       truncate_size, truncate_seq);
        }
 
-       req->r_abort_on_full = true;
        req->r_flags = flags;
        req->r_base_oloc.pool = layout->pool_id;
        req->r_base_oloc.pool_ns = ceph_try_get_string(layout->pool_ns);
@@ -1054,6 +1056,38 @@ EXPORT_SYMBOL(ceph_osdc_new_request);
 DEFINE_RB_FUNCS(request, struct ceph_osd_request, r_tid, r_node)
 DEFINE_RB_FUNCS(request_mc, struct ceph_osd_request, r_tid, r_mc_node)
 
+/*
+ * Call @fn on each OSD request as long as @fn returns 0.
+ */
+static void for_each_request(struct ceph_osd_client *osdc,
+                       int (*fn)(struct ceph_osd_request *req, void *arg),
+                       void *arg)
+{
+       struct rb_node *n, *p;
+
+       for (n = rb_first(&osdc->osds); n; n = rb_next(n)) {
+               struct ceph_osd *osd = rb_entry(n, struct ceph_osd, o_node);
+
+               for (p = rb_first(&osd->o_requests); p; ) {
+                       struct ceph_osd_request *req =
+                           rb_entry(p, struct ceph_osd_request, r_node);
+
+                       p = rb_next(p);
+                       if (fn(req, arg))
+                               return;
+               }
+       }
+
+       for (p = rb_first(&osdc->homeless_osd.o_requests); p; ) {
+               struct ceph_osd_request *req =
+                   rb_entry(p, struct ceph_osd_request, r_node);
+
+               p = rb_next(p);
+               if (fn(req, arg))
+                       return;
+       }
+}
+
 static bool osd_homeless(struct ceph_osd *osd)
 {
        return osd->o_osd == CEPH_HOMELESS_OSD;
@@ -1395,7 +1429,6 @@ static enum calc_target_result calc_target(struct ceph_osd_client *osdc,
        bool recovery_deletes = ceph_osdmap_flag(osdc,
                                                 CEPH_OSDMAP_RECOVERY_DELETES);
        enum calc_target_result ct_res;
-       int ret;
 
        t->epoch = osdc->osdmap->epoch;
        pi = ceph_pg_pool_by_id(osdc->osdmap, t->base_oloc.pool);
@@ -1431,14 +1464,7 @@ static enum calc_target_result calc_target(struct ceph_osd_client *osdc,
                }
        }
 
-       ret = __ceph_object_locator_to_pg(pi, &t->target_oid, &t->target_oloc,
-                                         &pgid);
-       if (ret) {
-               WARN_ON(ret != -ENOENT);
-               t->osd = CEPH_HOMELESS_OSD;
-               ct_res = CALC_TARGET_POOL_DNE;
-               goto out;
-       }
+       __ceph_object_locator_to_pg(pi, &t->target_oid, &t->target_oloc, &pgid);
        last_pgid.pool = pgid.pool;
        last_pgid.seed = ceph_stable_mod(pgid.seed, t->pg_num, t->pg_num_mask);
 
@@ -2161,9 +2187,9 @@ static void __submit_request(struct ceph_osd_request *req, bool wrlocked)
        struct ceph_osd_client *osdc = req->r_osdc;
        struct ceph_osd *osd;
        enum calc_target_result ct_res;
+       int err = 0;
        bool need_send = false;
        bool promoted = false;
-       bool need_abort = false;
 
        WARN_ON(req->r_tid);
        dout("%s req %p wrlocked %d\n", __func__, req, wrlocked);
@@ -2179,7 +2205,10 @@ static void __submit_request(struct ceph_osd_request *req, bool wrlocked)
                goto promote;
        }
 
-       if (osdc->osdmap->epoch < osdc->epoch_barrier) {
+       if (osdc->abort_err) {
+               dout("req %p abort_err %d\n", req, osdc->abort_err);
+               err = osdc->abort_err;
+       } else if (osdc->osdmap->epoch < osdc->epoch_barrier) {
                dout("req %p epoch %u barrier %u\n", req, osdc->osdmap->epoch,
                     osdc->epoch_barrier);
                req->r_t.paused = true;
@@ -2200,11 +2229,13 @@ static void __submit_request(struct ceph_osd_request *req, bool wrlocked)
                   (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) ||
                    pool_full(osdc, req->r_t.base_oloc.pool))) {
                dout("req %p full/pool_full\n", req);
-               pr_warn_ratelimited("FULL or reached pool quota\n");
-               req->r_t.paused = true;
-               maybe_request_map(osdc);
-               if (req->r_abort_on_full)
-                       need_abort = true;
+               if (osdc->abort_on_full) {
+                       err = -ENOSPC;
+               } else {
+                       pr_warn_ratelimited("FULL or reached pool quota\n");
+                       req->r_t.paused = true;
+                       maybe_request_map(osdc);
+               }
        } else if (!osd_homeless(osd)) {
                need_send = true;
        } else {
@@ -2221,11 +2252,11 @@ static void __submit_request(struct ceph_osd_request *req, bool wrlocked)
        link_request(osd, req);
        if (need_send)
                send_request(req);
-       else if (need_abort)
-               complete_request(req, -ENOSPC);
+       else if (err)
+               complete_request(req, err);
        mutex_unlock(&osd->lock);
 
-       if (ct_res == CALC_TARGET_POOL_DNE)
+       if (!err && ct_res == CALC_TARGET_POOL_DNE)
                send_map_check(req);
 
        if (promoted)
@@ -2281,11 +2312,21 @@ static void finish_request(struct ceph_osd_request *req)
 
 static void __complete_request(struct ceph_osd_request *req)
 {
-       if (req->r_callback) {
-               dout("%s req %p tid %llu cb %pf result %d\n", __func__, req,
-                    req->r_tid, req->r_callback, req->r_result);
+       dout("%s req %p tid %llu cb %pf result %d\n", __func__, req,
+            req->r_tid, req->r_callback, req->r_result);
+
+       if (req->r_callback)
                req->r_callback(req);
-       }
+       complete_all(&req->r_completion);
+       ceph_osdc_put_request(req);
+}
+
+static void complete_request_workfn(struct work_struct *work)
+{
+       struct ceph_osd_request *req =
+           container_of(work, struct ceph_osd_request, r_complete_work);
+
+       __complete_request(req);
 }
 
 /*
@@ -2297,9 +2338,9 @@ static void complete_request(struct ceph_osd_request *req, int err)
 
        req->r_result = err;
        finish_request(req);
-       __complete_request(req);
-       complete_all(&req->r_completion);
-       ceph_osdc_put_request(req);
+
+       INIT_WORK(&req->r_complete_work, complete_request_workfn);
+       queue_work(req->r_osdc->completion_wq, &req->r_complete_work);
 }
 
 static void cancel_map_check(struct ceph_osd_request *req)
@@ -2336,6 +2377,28 @@ static void abort_request(struct ceph_osd_request *req, int err)
        complete_request(req, err);
 }
 
+static int abort_fn(struct ceph_osd_request *req, void *arg)
+{
+       int err = *(int *)arg;
+
+       abort_request(req, err);
+       return 0; /* continue iteration */
+}
+
+/*
+ * Abort all in-flight requests with @err and arrange for all future
+ * requests to be failed immediately.
+ */
+void ceph_osdc_abort_requests(struct ceph_osd_client *osdc, int err)
+{
+       dout("%s osdc %p err %d\n", __func__, osdc, err);
+       down_write(&osdc->lock);
+       for_each_request(osdc, abort_fn, &err);
+       osdc->abort_err = err;
+       up_write(&osdc->lock);
+}
+EXPORT_SYMBOL(ceph_osdc_abort_requests);
+
 static void update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb)
 {
        if (likely(eb > osdc->epoch_barrier)) {
@@ -2362,6 +2425,30 @@ void ceph_osdc_update_epoch_barrier(struct ceph_osd_client *osdc, u32 eb)
 }
 EXPORT_SYMBOL(ceph_osdc_update_epoch_barrier);
 
+/*
+ * We can end up releasing caps as a result of abort_request().
+ * In that case, we probably want to ensure that the cap release message
+ * has an updated epoch barrier in it, so set the epoch barrier prior to
+ * aborting the first request.
+ */
+static int abort_on_full_fn(struct ceph_osd_request *req, void *arg)
+{
+       struct ceph_osd_client *osdc = req->r_osdc;
+       bool *victims = arg;
+
+       if ((req->r_flags & CEPH_OSD_FLAG_WRITE) &&
+           (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) ||
+            pool_full(osdc, req->r_t.base_oloc.pool))) {
+               if (!*victims) {
+                       update_epoch_barrier(osdc, osdc->osdmap->epoch);
+                       *victims = true;
+               }
+               abort_request(req, -ENOSPC);
+       }
+
+       return 0; /* continue iteration */
+}
+
 /*
  * Drop all pending requests that are stalled waiting on a full condition to
  * clear, and complete them with ENOSPC as the return code. Set the
@@ -2370,61 +2457,11 @@ EXPORT_SYMBOL(ceph_osdc_update_epoch_barrier);
  */
 static void ceph_osdc_abort_on_full(struct ceph_osd_client *osdc)
 {
-       struct rb_node *n;
        bool victims = false;
 
-       dout("enter abort_on_full\n");
-
-       if (!ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) && !have_pool_full(osdc))
-               goto out;
-
-       /* Scan list and see if there is anything to abort */
-       for (n = rb_first(&osdc->osds); n; n = rb_next(n)) {
-               struct ceph_osd *osd = rb_entry(n, struct ceph_osd, o_node);
-               struct rb_node *m;
-
-               m = rb_first(&osd->o_requests);
-               while (m) {
-                       struct ceph_osd_request *req = rb_entry(m,
-                                       struct ceph_osd_request, r_node);
-                       m = rb_next(m);
-
-                       if (req->r_abort_on_full) {
-                               victims = true;
-                               break;
-                       }
-               }
-               if (victims)
-                       break;
-       }
-
-       if (!victims)
-               goto out;
-
-       /*
-        * Update the barrier to current epoch if it's behind that point,
-        * since we know we have some calls to be aborted in the tree.
-        */
-       update_epoch_barrier(osdc, osdc->osdmap->epoch);
-
-       for (n = rb_first(&osdc->osds); n; n = rb_next(n)) {
-               struct ceph_osd *osd = rb_entry(n, struct ceph_osd, o_node);
-               struct rb_node *m;
-
-               m = rb_first(&osd->o_requests);
-               while (m) {
-                       struct ceph_osd_request *req = rb_entry(m,
-                                       struct ceph_osd_request, r_node);
-                       m = rb_next(m);
-
-                       if (req->r_abort_on_full &&
-                           (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) ||
-                            pool_full(osdc, req->r_t.target_oloc.pool)))
-                               abort_request(req, -ENOSPC);
-               }
-       }
-out:
-       dout("return abort_on_full barrier=%u\n", osdc->epoch_barrier);
+       if (osdc->abort_on_full &&
+           (ceph_osdmap_flag(osdc, CEPH_OSDMAP_FULL) || have_pool_full(osdc)))
+               for_each_request(osdc, abort_on_full_fn, &victims);
 }
 
 static void check_pool_dne(struct ceph_osd_request *req)
@@ -3541,8 +3578,6 @@ static void handle_reply(struct ceph_osd *osd, struct ceph_msg *msg)
        up_read(&osdc->lock);
 
        __complete_request(req);
-       complete_all(&req->r_completion);
-       ceph_osdc_put_request(req);
        return;
 
 fail_request:
@@ -4927,7 +4962,10 @@ int ceph_osdc_call(struct ceph_osd_client *osdc,
        if (ret)
                goto out_put_req;
 
-       osd_req_op_cls_init(req, 0, CEPH_OSD_OP_CALL, class, method);
+       ret = osd_req_op_cls_init(req, 0, CEPH_OSD_OP_CALL, class, method);
+       if (ret)
+               goto out_put_req;
+
        if (req_page)
                osd_req_op_cls_request_data_pages(req, 0, &req_page, req_len,
                                                  0, false, false);
@@ -4996,6 +5034,10 @@ int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client)
        if (!osdc->notify_wq)
                goto out_msgpool_reply;
 
+       osdc->completion_wq = create_singlethread_workqueue("ceph-completion");
+       if (!osdc->completion_wq)
+               goto out_notify_wq;
+
        schedule_delayed_work(&osdc->timeout_work,
                              osdc->client->options->osd_keepalive_timeout);
        schedule_delayed_work(&osdc->osds_timeout_work,
@@ -5003,6 +5045,8 @@ int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client)
 
        return 0;
 
+out_notify_wq:
+       destroy_workqueue(osdc->notify_wq);
 out_msgpool_reply:
        ceph_msgpool_destroy(&osdc->msgpool_op_reply);
 out_msgpool:
@@ -5017,7 +5061,7 @@ int ceph_osdc_init(struct ceph_osd_client *osdc, struct ceph_client *client)
 
 void ceph_osdc_stop(struct ceph_osd_client *osdc)
 {
-       flush_workqueue(osdc->notify_wq);
+       destroy_workqueue(osdc->completion_wq);
        destroy_workqueue(osdc->notify_wq);
        cancel_delayed_work_sync(&osdc->timeout_work);
        cancel_delayed_work_sync(&osdc->osds_timeout_work);
index 9645ffd6acfb24b1432ad69f655d1caa09741fcf..98c0ff3d644174fe9f5ce30fedfd617c5236539b 100644 (file)
@@ -1299,8 +1299,9 @@ static int set_primary_affinity(struct ceph_osdmap *map, int osd, u32 aff)
        if (!map->osd_primary_affinity) {
                int i;
 
-               map->osd_primary_affinity = kmalloc(map->max_osd*sizeof(u32),
-                                                   GFP_NOFS);
+               map->osd_primary_affinity = kmalloc_array(map->max_osd,
+                                                         sizeof(u32),
+                                                         GFP_NOFS);
                if (!map->osd_primary_affinity)
                        return -ENOMEM;
 
@@ -2145,10 +2146,10 @@ bool ceph_osds_changed(const struct ceph_osds *old_acting,
  * Should only be called with target_oid and target_oloc (as opposed to
  * base_oid and base_oloc), since tiering isn't taken into account.
  */
-int __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
-                               const struct ceph_object_id *oid,
-                               const struct ceph_object_locator *oloc,
-                               struct ceph_pg *raw_pgid)
+void __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
+                                const struct ceph_object_id *oid,
+                                const struct ceph_object_locator *oloc,
+                                struct ceph_pg *raw_pgid)
 {
        WARN_ON(pi->id != oloc->pool);
 
@@ -2164,11 +2165,8 @@ int __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
                int nsl = oloc->pool_ns->len;
                size_t total = nsl + 1 + oid->name_len;
 
-               if (total > sizeof(stack_buf)) {
-                       buf = kmalloc(total, GFP_NOIO);
-                       if (!buf)
-                               return -ENOMEM;
-               }
+               if (total > sizeof(stack_buf))
+                       buf = kmalloc(total, GFP_NOIO | __GFP_NOFAIL);
                memcpy(buf, oloc->pool_ns->str, nsl);
                buf[nsl] = '\037';
                memcpy(buf + nsl + 1, oid->name, oid->name_len);
@@ -2180,7 +2178,6 @@ int __ceph_object_locator_to_pg(struct ceph_pg_pool_info *pi,
                     oid->name, nsl, oloc->pool_ns->str,
                     raw_pgid->pool, raw_pgid->seed);
        }
-       return 0;
 }
 
 int ceph_object_locator_to_pg(struct ceph_osdmap *osdmap,
@@ -2194,7 +2191,8 @@ int ceph_object_locator_to_pg(struct ceph_osdmap *osdmap,
        if (!pi)
                return -ENOENT;
 
-       return __ceph_object_locator_to_pg(pi, oid, oloc, raw_pgid);
+       __ceph_object_locator_to_pg(pi, oid, oloc, raw_pgid);
+       return 0;
 }
 EXPORT_SYMBOL(ceph_object_locator_to_pg);
 
index a3d0adc828e6417e7772420fddbdff1313064f65..e560d3975f41cb89827017b1e920e43648d5b453 100644 (file)
@@ -20,7 +20,7 @@ struct page **ceph_get_direct_page_vector(const void __user *data,
        int got = 0;
        int rc = 0;
 
-       pages = kmalloc(sizeof(*pages) * num_pages, GFP_NOFS);
+       pages = kmalloc_array(num_pages, sizeof(*pages), GFP_NOFS);
        if (!pages)
                return ERR_PTR(-ENOMEM);
 
@@ -74,7 +74,7 @@ struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags)
        struct page **pages;
        int i;
 
-       pages = kmalloc(sizeof(*pages) * num_pages, flags);
+       pages = kmalloc_array(num_pages, sizeof(*pages), flags);
        if (!pages)
                return ERR_PTR(-ENOMEM);
        for (i = 0; i < num_pages; i++) {
index 6e18242a1caec5b4e2504f75622691dfaf1039c1..57b7bab5f70bb7c50a8be565cc90a40bc1c2d5d6 100644 (file)
@@ -8823,7 +8823,7 @@ static struct hlist_head * __net_init netdev_create_hash(void)
        int i;
        struct hlist_head *hash;
 
-       hash = kmalloc(sizeof(*hash) * NETDEV_HASHENTRIES, GFP_KERNEL);
+       hash = kmalloc_array(NETDEV_HASHENTRIES, sizeof(*hash), GFP_KERNEL);
        if (hash != NULL)
                for (i = 0; i < NETDEV_HASHENTRIES; i++)
                        INIT_HLIST_HEAD(&hash[i]);
index c15075dc7572cdd993e17e7ccc765c22c23bc75a..e677a20180cf304a27154d12c338da046c96a546 100644 (file)
@@ -911,7 +911,7 @@ static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev,
        memset(&info, 0, sizeof(info));
        info.cmd = ETHTOOL_GSSET_INFO;
 
-       info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER);
+       info_buf = kcalloc(n_bits, sizeof(u32), GFP_USER);
        if (!info_buf)
                return -ENOMEM;
 
@@ -1017,7 +1017,7 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev,
        if (info.cmd == ETHTOOL_GRXCLSRLALL) {
                if (info.rule_cnt > 0) {
                        if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
-                               rule_buf = kzalloc(info.rule_cnt * sizeof(u32),
+                               rule_buf = kcalloc(info.rule_cnt, sizeof(u32),
                                                   GFP_USER);
                        if (!rule_buf)
                                return -ENOMEM;
@@ -1816,7 +1816,7 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
                return -EFAULT;
 
        test.len = test_len;
-       data = kmalloc(test_len * sizeof(u64), GFP_USER);
+       data = kmalloc_array(test_len, sizeof(u64), GFP_USER);
        if (!data)
                return -ENOMEM;
 
@@ -1852,7 +1852,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr)
        WARN_ON_ONCE(!ret);
 
        gstrings.len = ret;
-       data = vzalloc(gstrings.len * ETH_GSTRING_LEN);
+       data = vzalloc(array_size(gstrings.len, ETH_GSTRING_LEN));
        if (gstrings.len && !data)
                return -ENOMEM;
 
@@ -1952,7 +1952,7 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr)
                return -EFAULT;
 
        stats.n_stats = n_stats;
-       data = vzalloc(n_stats * sizeof(u64));
+       data = vzalloc(array_size(n_stats, sizeof(u64)));
        if (n_stats && !data)
                return -ENOMEM;
 
@@ -1996,7 +1996,7 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr)
                return -EFAULT;
 
        stats.n_stats = n_stats;
-       data = vzalloc(n_stats * sizeof(u64));
+       data = vzalloc(array_size(n_stats, sizeof(u64)));
        if (n_stats && !data)
                return -ENOMEM;
 
index a7a9c3d738ba8c3309fa17cfb85dae81d0d9a095..8e3fda9e725cba97973ed2ce85ebe6f2e926e7cf 100644 (file)
@@ -119,13 +119,14 @@ unsigned long neigh_rand_reach_time(unsigned long base)
 EXPORT_SYMBOL(neigh_rand_reach_time);
 
 
-static bool neigh_del(struct neighbour *n, __u8 state,
+static bool neigh_del(struct neighbour *n, __u8 state, __u8 flags,
                      struct neighbour __rcu **np, struct neigh_table *tbl)
 {
        bool retval = false;
 
        write_lock(&n->lock);
-       if (refcount_read(&n->refcnt) == 1 && !(n->nud_state & state)) {
+       if (refcount_read(&n->refcnt) == 1 && !(n->nud_state & state) &&
+           !(n->flags & flags)) {
                struct neighbour *neigh;
 
                neigh = rcu_dereference_protected(n->next,
@@ -157,7 +158,7 @@ bool neigh_remove_one(struct neighbour *ndel, struct neigh_table *tbl)
        while ((n = rcu_dereference_protected(*np,
                                              lockdep_is_held(&tbl->lock)))) {
                if (n == ndel)
-                       return neigh_del(n, 0, np, tbl);
+                       return neigh_del(n, 0, 0, np, tbl);
                np = &n->next;
        }
        return false;
@@ -185,7 +186,8 @@ static int neigh_forced_gc(struct neigh_table *tbl)
                         * - nobody refers to it.
                         * - it is not permanent
                         */
-                       if (neigh_del(n, NUD_PERMANENT, np, tbl)) {
+                       if (neigh_del(n, NUD_PERMANENT, NTF_EXT_LEARNED, np,
+                                     tbl)) {
                                shrunk = 1;
                                continue;
                        }
index 7e4ede34cc52d957a9b449247f0d71b7ef251a6a..49368e21d228c3f0bd6684c8831fc1e4398d56b1 100644 (file)
@@ -3603,7 +3603,8 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname)
                return -ENOMEM;
 
        strcpy(pkt_dev->odevname, ifname);
-       pkt_dev->flows = vzalloc_node(MAX_CFLOWS * sizeof(struct flow_state),
+       pkt_dev->flows = vzalloc_node(array_size(MAX_CFLOWS,
+                                                sizeof(struct flow_state)),
                                      node);
        if (pkt_dev->flows == NULL) {
                kfree(pkt_dev);
index f333d75ef1a9cd011a70eca7f84b20b80f5765ee..bcc41829a16d50714bdd3c25c976c0b7296fab84 100644 (file)
@@ -728,22 +728,9 @@ int sock_setsockopt(struct socket *sock, int level, int optname,
                        sock_valbool_flag(sk, SOCK_DBG, valbool);
                break;
        case SO_REUSEADDR:
-               val = (valbool ? SK_CAN_REUSE : SK_NO_REUSE);
-               if ((sk->sk_family == PF_INET || sk->sk_family == PF_INET6) &&
-                   inet_sk(sk)->inet_num &&
-                   (sk->sk_reuse != val)) {
-                       ret = (sk->sk_state == TCP_ESTABLISHED) ? -EISCONN : -EUCLEAN;
-                       break;
-               }
-               sk->sk_reuse = val;
+               sk->sk_reuse = (valbool ? SK_CAN_REUSE : SK_NO_REUSE);
                break;
        case SO_REUSEPORT:
-               if ((sk->sk_family == PF_INET || sk->sk_family == PF_INET6) &&
-                   inet_sk(sk)->inet_num &&
-                   (sk->sk_reuseport != valbool)) {
-                       ret = (sk->sk_state == TCP_ESTABLISHED) ? -EISCONN : -EUCLEAN;
-                       break;
-               }
                sk->sk_reuseport = valbool;
                break;
        case SO_TYPE:
index d2f4e0c1faafa985f67bda48b55ea1bf409be05f..2589a6b78aa175a207cf592e5c8b611ca95f232e 100644 (file)
@@ -984,7 +984,8 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb,
         */
        err = ops->peer_getappinfo(netdev, &info, &app_count);
        if (!err && app_count) {
-               table = kmalloc(sizeof(struct dcb_app) * app_count, GFP_KERNEL);
+               table = kmalloc_array(app_count, sizeof(struct dcb_app),
+                                     GFP_KERNEL);
                if (!table)
                        return -ENOMEM;
 
index 385f153fe0318a160120e98a093260a55e485317..2b75df469220a8a5bf3ffa09aa6616eef0a9002d 100644 (file)
@@ -46,7 +46,8 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hc)
                return -ENOMEM;
 
        /* allocate buffer and initialize linked list */
-       seqp = kmalloc(CCID2_SEQBUF_LEN * sizeof(struct ccid2_seq), gfp_any());
+       seqp = kmalloc_array(CCID2_SEQBUF_LEN, sizeof(struct ccid2_seq),
+                            gfp_any());
        if (seqp == NULL)
                return -ENOMEM;
 
index 7d20e1f3de28a4826a9e39667a2a7a1a931cbb2b..56197f0d9608de25b857ad2f902c554002a2929b 100644 (file)
@@ -75,7 +75,8 @@ static struct sk_buff *trailer_rcv(struct sk_buff *skb, struct net_device *dev,
        if (!skb->dev)
                return NULL;
 
-       pskb_trim_rcsum(skb, skb->len - 4);
+       if (pskb_trim_rcsum(skb, skb->len - 4))
+               return NULL;
 
        return skb;
 }
index dc2960be51e0a6161d921bb3e3235926a15c3a82..b231e40f006a696b7d2bf20f1eaecb0e501f6bbb 100644 (file)
@@ -38,7 +38,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid,
 {
        void *hdr;
        int i, pages = 0;
-       uint32_t *buf = kzalloc(32 * sizeof(uint32_t), GFP_KERNEL);
+       uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL);
 
        pr_debug("%s\n", __func__);
 
index 63aa39b3af03cb70c50b16418bf95a5c736f6cae..b21833651394233bbdb143d765e4408333b13b72 100644 (file)
@@ -567,7 +567,7 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt,
                struct nlattr *mx;
                int len = 0;
 
-               mx = kzalloc(3 * nla_total_size(4), GFP_KERNEL);
+               mx = kcalloc(3, nla_total_size(4), GFP_KERNEL);
                if (!mx)
                        return -ENOMEM;
 
index 38ab97b0a2ece3b6d712269312e6e310da8918f6..ca0dad90803a92bdcbb1e199554985ad4626fada 100644 (file)
@@ -531,6 +531,7 @@ find_check_entry(struct ipt_entry *e, struct net *net, const char *name,
                return -ENOMEM;
 
        j = 0;
+       memset(&mtpar, 0, sizeof(mtpar));
        mtpar.net       = net;
        mtpar.table     = name;
        mtpar.entryinfo = &e->ip;
index bf4e4adc2d0002c3acc016bfa7e128a477150b33..1df6e97106d79eef9dfde27472c5f9c20cae3943 100644 (file)
@@ -649,7 +649,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw,
 
        hash = rcu_dereference(nh->nh_exceptions);
        if (!hash) {
-               hash = kzalloc(FNHE_HASH_SIZE * sizeof(*hash), GFP_ATOMIC);
+               hash = kcalloc(FNHE_HASH_SIZE, sizeof(*hash), GFP_ATOMIC);
                if (!hash)
                        goto out_unlock;
                rcu_assign_pointer(nh->nh_exceptions, hash);
@@ -3146,7 +3146,8 @@ int __init ip_rt_init(void)
 {
        int cpu;
 
-       ip_idents = kmalloc(IP_IDENTS_SZ * sizeof(*ip_idents), GFP_KERNEL);
+       ip_idents = kmalloc_array(IP_IDENTS_SZ, sizeof(*ip_idents),
+                                 GFP_KERNEL);
        if (!ip_idents)
                panic("IP: failed to allocate ip_idents\n");
 
index fed3f1c6616708997f621535efe9412e4afa0a50..bea17f1e8302585d70c1e0108ae1c33d149230d8 100644 (file)
@@ -1730,6 +1730,10 @@ int tcp_v4_rcv(struct sk_buff *skb)
                        reqsk_put(req);
                        goto discard_it;
                }
+               if (tcp_checksum_complete(skb)) {
+                       reqsk_put(req);
+                       goto csum_error;
+               }
                if (unlikely(sk->sk_state != TCP_LISTEN)) {
                        inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
index 4d58e2ce0b5b181b39aeb12f8761ba016606dd43..8cc7c348733052a8ef4bc06d09149171d8277006 100644 (file)
@@ -268,8 +268,6 @@ struct sk_buff **tcp_gro_receive(struct sk_buff **head, struct sk_buff *skb)
                goto out_check_final;
        }
 
-       p = *head;
-       th2 = tcp_hdr(p);
        tcp_flag_word(th2) |= flags & (TCP_FLAG_FIN | TCP_FLAG_PSH);
 
 out_check_final:
index 89019bf59f4651d45bcc69503ebf7028371d60c3..c134286d6a4179516709570ad534d1ae26fd0bce 100644 (file)
@@ -1324,6 +1324,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp,
                }
        }
 
+       memset(&cfg, 0, sizeof(cfg));
        cfg.valid_lft = min_t(__u32, ifp->valid_lft,
                              idev->cnf.temp_valid_lft + age);
        cfg.preferred_lft = cnf_temp_preferred_lft + age - idev->desync_factor;
@@ -1357,7 +1358,6 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp,
 
        cfg.pfx = &addr;
        cfg.scope = ipv6_addr_scope(cfg.pfx);
-       cfg.rt_priority = 0;
 
        ift = ipv6_add_addr(idev, &cfg, block, NULL);
        if (IS_ERR(ift)) {
index d8c4b63743772d60d6bd75176a3cd857179ed989..be491bf6ab6e9ff4d1a9d84bc78c4582f4fe8e01 100644 (file)
@@ -956,7 +956,7 @@ static int __net_init icmpv6_sk_init(struct net *net)
        int err, i, j;
 
        net->ipv6.icmp_sk =
-               kzalloc(nr_cpu_ids * sizeof(struct sock *), GFP_KERNEL);
+               kcalloc(nr_cpu_ids, sizeof(struct sock *), GFP_KERNEL);
        if (!net->ipv6.icmp_sk)
                return -ENOMEM;
 
index 44c39c5f06384c6c83901036a2e94bcda439f91c..10ae13560b407e28643fe2ed772de868ef41804f 100644 (file)
@@ -42,7 +42,8 @@ static int alloc_ila_locks(struct ila_net *ilan)
        size = roundup_pow_of_two(nr_pcpus * LOCKS_PER_CPU);
 
        if (sizeof(spinlock_t) != 0) {
-               ilan->locks = kvmalloc(size * sizeof(spinlock_t), GFP_KERNEL);
+               ilan->locks = kvmalloc_array(size, sizeof(spinlock_t),
+                                            GFP_KERNEL);
                if (!ilan->locks)
                        return -ENOMEM;
                for (i = 0; i < size; i++)
index 7aa4c41a3bd912e99490b46544b2fa6512e8a1fc..39d1d487eca25faceacbc3619fc6c4c38088d62a 100644 (file)
@@ -934,6 +934,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
 {
        struct fib6_info *leaf = rcu_dereference_protected(fn->leaf,
                                    lockdep_is_held(&rt->fib6_table->tb6_lock));
+       enum fib_event_type event = FIB_EVENT_ENTRY_ADD;
        struct fib6_info *iter = NULL, *match = NULL;
        struct fib6_info __rcu **ins;
        int replace = (info->nlh &&
@@ -1013,6 +1014,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
                                       "Can not append to a REJECT route");
                        return -EINVAL;
                }
+               event = FIB_EVENT_ENTRY_APPEND;
                rt->fib6_nsiblings = match->fib6_nsiblings;
                list_add_tail(&rt->fib6_siblings, &match->fib6_siblings);
                match->fib6_nsiblings++;
@@ -1034,15 +1036,12 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt,
         *      insert node
         */
        if (!replace) {
-               enum fib_event_type event;
-
                if (!add)
                        pr_warn("NLM_F_CREATE should be set when creating new route\n");
 
 add:
                nlflags |= NLM_F_CREATE;
 
-               event = append ? FIB_EVENT_ENTRY_APPEND : FIB_EVENT_ENTRY_ADD;
                err = call_fib6_entry_notifiers(info->nl_net, event, rt,
                                                extack);
                if (err)
index 0758b5bcfb2905e0bc342fc6e7ded6a3eb9bee28..7eab959734bc736cc103551fb50bce84f9aeaec7 100644 (file)
@@ -550,6 +550,7 @@ find_check_entry(struct ip6t_entry *e, struct net *net, const char *name,
                return -ENOMEM;
 
        j = 0;
+       memset(&mtpar, 0, sizeof(mtpar));
        mtpar.net       = net;
        mtpar.table     = name;
        mtpar.entryinfo = &e->ipv6;
index fb956989adaf4735f3c4ac94def46ff45782a9bf..86a0e4333d42212d03f53e0d54fcf4e03a328607 100644 (file)
@@ -2307,9 +2307,6 @@ static void __ip6_rt_update_pmtu(struct dst_entry *dst, const struct sock *sk,
        const struct in6_addr *daddr, *saddr;
        struct rt6_info *rt6 = (struct rt6_info *)dst;
 
-       if (rt6->rt6i_flags & RTF_LOCAL)
-               return;
-
        if (dst_metric_locked(dst, RTAX_MTU))
                return;
 
index b620d9b72e595ba4390b3e02ff8a0bbafa49eebe..7efa9fd7e1094dc43ca464e5c6f06ea36031d476 100644 (file)
@@ -1479,6 +1479,10 @@ static int tcp_v6_rcv(struct sk_buff *skb)
                        reqsk_put(req);
                        goto discard_it;
                }
+               if (tcp_checksum_complete(skb)) {
+                       reqsk_put(req);
+                       goto csum_error;
+               }
                if (unlikely(sk->sk_state != TCP_LISTEN)) {
                        inet_csk_reqsk_queue_drop_and_put(sk, req);
                        goto lookup;
index 6616c9fd292f1ddae6b974bb2d70de7d7dc1bd28..5b9900889e311f964c4d7640f152a60edfb02740 100644 (file)
@@ -553,6 +553,12 @@ static int l2tp_nl_cmd_session_create(struct sk_buff *skb, struct genl_info *inf
                goto out_tunnel;
        }
 
+       /* L2TPv2 only accepts PPP pseudo-wires */
+       if (tunnel->version == 2 && cfg.pw_type != L2TP_PWTYPE_PPP) {
+               ret = -EPROTONOSUPPORT;
+               goto out_tunnel;
+       }
+
        if (tunnel->version > 2) {
                if (info->attrs[L2TP_ATTR_DATA_SEQ])
                        cfg.data_seq = nla_get_u8(info->attrs[L2TP_ATTR_DATA_SEQ]);
index b56cb1df4fc076ecfa1c76031f621c2c79b06126..55188382845c310c98eb86cdfc3b78e1d03e8e0f 100644 (file)
@@ -612,6 +612,8 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
        u32 session_id, peer_session_id;
        bool drop_refcnt = false;
        bool drop_tunnel = false;
+       bool new_session = false;
+       bool new_tunnel = false;
        int ver = 2;
        int fd;
 
@@ -701,6 +703,15 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
                                .encap = L2TP_ENCAPTYPE_UDP,
                                .debug = 0,
                        };
+
+                       /* Prevent l2tp_tunnel_register() from trying to set up
+                        * a kernel socket.
+                        */
+                       if (fd < 0) {
+                               error = -EBADF;
+                               goto end;
+                       }
+
                        error = l2tp_tunnel_create(sock_net(sk), fd, ver, tunnel_id, peer_tunnel_id, &tcfg, &tunnel);
                        if (error < 0)
                                goto end;
@@ -713,6 +724,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
                                goto end;
                        }
                        drop_tunnel = true;
+                       new_tunnel = true;
                }
        } else {
                /* Error if we can't find the tunnel */
@@ -734,6 +746,12 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
        session = l2tp_session_get(sock_net(sk), tunnel, session_id);
        if (session) {
                drop_refcnt = true;
+
+               if (session->pwtype != L2TP_PWTYPE_PPP) {
+                       error = -EPROTOTYPE;
+                       goto end;
+               }
+
                ps = l2tp_session_priv(session);
 
                /* Using a pre-existing session is fine as long as it hasn't
@@ -751,6 +769,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
                /* Default MTU must allow space for UDP/L2TP/PPP headers */
                cfg.mtu = 1500 - PPPOL2TP_HEADER_OVERHEAD;
                cfg.mru = cfg.mtu;
+               cfg.pw_type = L2TP_PWTYPE_PPP;
 
                session = l2tp_session_create(sizeof(struct pppol2tp_session),
                                              tunnel, session_id,
@@ -772,6 +791,7 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
                        goto end;
                }
                drop_refcnt = true;
+               new_session = true;
        }
 
        /* Special case: if source & dest session_id == 0x0000, this
@@ -818,6 +838,12 @@ static int pppol2tp_connect(struct socket *sock, struct sockaddr *uservaddr,
                  session->name);
 
 end:
+       if (error) {
+               if (new_session)
+                       l2tp_session_delete(session);
+               if (new_tunnel)
+                       l2tp_tunnel_delete(tunnel);
+       }
        if (drop_refcnt)
                l2tp_session_dec_refcount(session);
        if (drop_tunnel)
@@ -1175,7 +1201,7 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
                                l2tp_session_get(sock_net(sk), tunnel,
                                                 stats.session_id);
 
-                       if (session) {
+                       if (session && session->pwtype == L2TP_PWTYPE_PPP) {
                                err = pppol2tp_session_ioctl(session, cmd,
                                                             arg);
                                l2tp_session_dec_refcount(session);
index 89178b46b32fab38f9c7dfc4359237ecd3fd9a8c..d9558ffb8acf73b8d596989a3fe22e753937f5d9 100644 (file)
@@ -1186,7 +1186,7 @@ static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local,
        lockdep_assert_held(&local->mtx);
        lockdep_assert_held(&local->chanctx_mtx);
 
-       vif_chsw = kzalloc(sizeof(vif_chsw[0]) * n_vifs, GFP_KERNEL);
+       vif_chsw = kcalloc(n_vifs, sizeof(vif_chsw[0]), GFP_KERNEL);
        if (!vif_chsw)
                return -ENOMEM;
 
index 4d2e797e3f168bdf784268b16de15799220e0146..fb73451ed85ec65cd0b4b5cc3808d51d40a8dd39 100644 (file)
@@ -772,7 +772,7 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local)
                if (have_mfp)
                        n_suites += 4;
 
-               suites = kmalloc(sizeof(u32) * n_suites, GFP_KERNEL);
+               suites = kmalloc_array(n_suites, sizeof(u32), GFP_KERNEL);
                if (!suites)
                        return -ENOMEM;
 
@@ -1098,6 +1098,10 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 
        ieee80211_led_init(local);
 
+       result = ieee80211_txq_setup_flows(local);
+       if (result)
+               goto fail_flows;
+
        rtnl_lock();
 
        result = ieee80211_init_rate_ctrl_alg(local,
@@ -1120,10 +1124,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 
        rtnl_unlock();
 
-       result = ieee80211_txq_setup_flows(local);
-       if (result)
-               goto fail_flows;
-
 #ifdef CONFIG_INET
        local->ifa_notifier.notifier_call = ieee80211_ifa_changed;
        result = register_inetaddr_notifier(&local->ifa_notifier);
@@ -1149,8 +1149,6 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
 #if defined(CONFIG_INET) || defined(CONFIG_IPV6)
  fail_ifa:
 #endif
-       ieee80211_txq_teardown_flows(local);
- fail_flows:
        rtnl_lock();
        rate_control_deinitialize(local);
        ieee80211_remove_interfaces(local);
@@ -1158,6 +1156,8 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
        rtnl_unlock();
        ieee80211_led_exit(local);
        ieee80211_wep_free(local);
+       ieee80211_txq_teardown_flows(local);
+ fail_flows:
        destroy_workqueue(local->workqueue);
  fail_workqueue:
        wiphy_unregister(local->hw.wiphy);
index 8221bc5582abf74251a6c76550e1a8dce71538e3..76048b53c5b27637d343868c69ab54c928c6614d 100644 (file)
@@ -592,11 +592,11 @@ minstrel_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
                        max_rates = sband->n_bitrates;
        }
 
-       mi->r = kzalloc(sizeof(struct minstrel_rate) * max_rates, gfp);
+       mi->r = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp);
        if (!mi->r)
                goto error;
 
-       mi->sample_table = kmalloc(SAMPLE_COLUMNS * max_rates, gfp);
+       mi->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp);
        if (!mi->sample_table)
                goto error1;
 
index fb586b6e5d49ddd0617bbcbe9464038bc0b20d2e..67ebdeaffbbc8e6afbc5259988bf463f0c46abb9 100644 (file)
@@ -1313,11 +1313,11 @@ minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp)
        if (!msp)
                return NULL;
 
-       msp->ratelist = kzalloc(sizeof(struct minstrel_rate) * max_rates, gfp);
+       msp->ratelist = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp);
        if (!msp->ratelist)
                goto error;
 
-       msp->sample_table = kmalloc(SAMPLE_COLUMNS * max_rates, gfp);
+       msp->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp);
        if (!msp->sample_table)
                goto error1;
 
index a3b1bcc2b4615373bc636a5f3e2b6ae326608c9b..2e917a6d239d234ce671b8b4017dbd23c4be5b2e 100644 (file)
@@ -1157,7 +1157,7 @@ int __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata,
                }
        }
 
-       ie = kzalloc(num_bands * iebufsz, GFP_KERNEL);
+       ie = kcalloc(iebufsz, num_bands, GFP_KERNEL);
        if (!ie) {
                ret = -ENOMEM;
                goto out;
index 2d82c88efd0b6f271b693067451cc75d210fb8c4..5e2e511c4a6f69cf0b613c1b3facd0665d672cfd 100644 (file)
@@ -1803,8 +1803,9 @@ static int ieee80211_reconfig_nan(struct ieee80211_sub_if_data *sdata)
        if (WARN_ON(res))
                return res;
 
-       funcs = kzalloc((sdata->local->hw.max_nan_de_entries + 1) *
-                       sizeof(*funcs), GFP_KERNEL);
+       funcs = kcalloc(sdata->local->hw.max_nan_de_entries + 1,
+                       sizeof(*funcs),
+                       GFP_KERNEL);
        if (!funcs)
                return -ENOMEM;
 
index bbad940c01373f7929feae44d5729e1a55fb58b7..8a33dac4e8058b0ec07281814f5c90507421eb4e 100644 (file)
@@ -1234,7 +1234,10 @@ IPSET_TOKEN(HTYPE, _create)(struct net *net, struct ip_set *set,
        pr_debug("Create set %s with family %s\n",
                 set->name, set->family == NFPROTO_IPV4 ? "inet" : "inet6");
 
-#ifndef IP_SET_PROTO_UNDEF
+#ifdef IP_SET_PROTO_UNDEF
+       if (set->family != NFPROTO_UNSPEC)
+               return -IPSET_ERR_INVALID_FAMILY;
+#else
        if (!(set->family == NFPROTO_IPV4 || set->family == NFPROTO_IPV6))
                return -IPSET_ERR_INVALID_FAMILY;
 #endif
index 61c3a389da89bcec22bc31858893bd0ba8cf4255..99e0aa350dc54c5735aedf8da1212c088224d1ee 100644 (file)
@@ -1380,7 +1380,8 @@ int __init ip_vs_conn_init(void)
        /*
         * Allocate the connection hash table and initialize its list heads
         */
-       ip_vs_conn_tab = vmalloc(ip_vs_conn_tab_size * sizeof(*ip_vs_conn_tab));
+       ip_vs_conn_tab = vmalloc(array_size(ip_vs_conn_tab_size,
+                                           sizeof(*ip_vs_conn_tab)));
        if (!ip_vs_conn_tab)
                return -ENOMEM;
 
index 0c03c0e16a964ccea12ffa54ea2e4f697d6ea244..dd21782e2f12fc30d5bd227f3c33bc9362c72942 100644 (file)
@@ -839,6 +839,9 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
                 *    For now only for NAT!
                 */
                ip_vs_rs_hash(ipvs, dest);
+               /* FTP-NAT requires conntrack for mangling */
+               if (svc->port == FTPPORT)
+                       ip_vs_register_conntrack(svc);
        }
        atomic_set(&dest->conn_flags, conn_flags);
 
@@ -1462,6 +1465,7 @@ static void __ip_vs_del_service(struct ip_vs_service *svc, bool cleanup)
  */
 static void ip_vs_unlink_service(struct ip_vs_service *svc, bool cleanup)
 {
+       ip_vs_unregister_conntrack(svc);
        /* Hold svc to avoid double release from dest_trash */
        atomic_inc(&svc->refcnt);
        /*
index ba0a0fd045c857b97e112d2e6a40634b690e1d83..473cce2a5231c8f3757e82c8f94eaf81326d9f4b 100644 (file)
@@ -168,7 +168,7 @@ static inline bool crosses_local_route_boundary(int skb_af, struct sk_buff *skb,
                                                bool new_rt_is_local)
 {
        bool rt_mode_allow_local = !!(rt_mode & IP_VS_RT_MODE_LOCAL);
-       bool rt_mode_allow_non_local = !!(rt_mode & IP_VS_RT_MODE_LOCAL);
+       bool rt_mode_allow_non_local = !!(rt_mode & IP_VS_RT_MODE_NON_LOCAL);
        bool rt_mode_allow_redirect = !!(rt_mode & IP_VS_RT_MODE_RDR);
        bool source_is_loopback;
        bool old_rt_is_local;
index 3b5059a8dcdd19d1aadaf10e5600cb65491c812c..d8383609fe2825b707cfb8ebc54381761ccc1108 100644 (file)
@@ -46,6 +46,7 @@
 struct nf_conncount_tuple {
        struct hlist_node               node;
        struct nf_conntrack_tuple       tuple;
+       struct nf_conntrack_zone        zone;
 };
 
 struct nf_conncount_rb {
@@ -80,7 +81,8 @@ static int key_diff(const u32 *a, const u32 *b, unsigned int klen)
 }
 
 bool nf_conncount_add(struct hlist_head *head,
-                     const struct nf_conntrack_tuple *tuple)
+                     const struct nf_conntrack_tuple *tuple,
+                     const struct nf_conntrack_zone *zone)
 {
        struct nf_conncount_tuple *conn;
 
@@ -88,6 +90,7 @@ bool nf_conncount_add(struct hlist_head *head,
        if (conn == NULL)
                return false;
        conn->tuple = *tuple;
+       conn->zone = *zone;
        hlist_add_head(&conn->node, head);
        return true;
 }
@@ -108,7 +111,7 @@ unsigned int nf_conncount_lookup(struct net *net, struct hlist_head *head,
 
        /* check the saved connections */
        hlist_for_each_entry_safe(conn, n, head, node) {
-               found = nf_conntrack_find_get(net, zone, &conn->tuple);
+               found = nf_conntrack_find_get(net, &conn->zone, &conn->tuple);
                if (found == NULL) {
                        hlist_del(&conn->node);
                        kmem_cache_free(conncount_conn_cachep, conn);
@@ -117,7 +120,8 @@ unsigned int nf_conncount_lookup(struct net *net, struct hlist_head *head,
 
                found_ct = nf_ct_tuplehash_to_ctrack(found);
 
-               if (tuple && nf_ct_tuple_equal(&conn->tuple, tuple)) {
+               if (tuple && nf_ct_tuple_equal(&conn->tuple, tuple) &&
+                   nf_ct_zone_equal(found_ct, zone, zone->dir)) {
                        /*
                         * Just to be sure we have it only once in the list.
                         * We should not see tuples twice unless someone hooks
@@ -196,7 +200,7 @@ count_tree(struct net *net, struct rb_root *root,
                        if (!addit)
                                return count;
 
-                       if (!nf_conncount_add(&rbconn->hhead, tuple))
+                       if (!nf_conncount_add(&rbconn->hhead, tuple, zone))
                                return 0; /* hotdrop */
 
                        return count + 1;
@@ -238,6 +242,7 @@ count_tree(struct net *net, struct rb_root *root,
        }
 
        conn->tuple = *tuple;
+       conn->zone = *zone;
        memcpy(rbconn->key, key, sizeof(u32) * keylen);
 
        INIT_HLIST_HEAD(&rbconn->hhead);
index 39327a42879f7f614fa46f6577c3f883aa3714ce..20a2e37c76d124e31771c9bf96bd13216501202a 100644 (file)
@@ -1446,7 +1446,8 @@ ctnetlink_parse_nat_setup(struct nf_conn *ct,
                }
                nfnl_lock(NFNL_SUBSYS_CTNETLINK);
                rcu_read_lock();
-               if (nat_hook->parse_nat_setup)
+               nat_hook = rcu_dereference(nf_nat_hook);
+               if (nat_hook)
                        return -EAGAIN;
 #endif
                return -EOPNOTSUPP;
index afdeca53e88b3fcbfe4c5815ee1b24945c6a61d8..d88841fbc560fcac4194938f4354907e51ecbcbf 100644 (file)
@@ -402,7 +402,8 @@ int nf_ct_l4proto_register_one(const struct nf_conntrack_l4proto *l4proto)
                struct nf_conntrack_l4proto __rcu **proto_array;
                int i;
 
-               proto_array = kmalloc(MAX_NF_CT_PROTO *
+               proto_array =
+                       kmalloc_array(MAX_NF_CT_PROTO,
                                      sizeof(struct nf_conntrack_l4proto *),
                                      GFP_KERNEL);
                if (proto_array == NULL) {
index b7df32a56e7ed2b495e39b54a7219a59af1531e4..46f9df99d276c3be7ff5839ba41273df38e59a72 100644 (file)
@@ -691,8 +691,9 @@ int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto)
 
        mutex_lock(&nf_nat_proto_mutex);
        if (nf_nat_l4protos[l3proto] == NULL) {
-               l4protos = kmalloc(IPPROTO_MAX * sizeof(struct nf_nat_l4proto *),
-                                  GFP_KERNEL);
+               l4protos = kmalloc_array(IPPROTO_MAX,
+                                        sizeof(struct nf_nat_l4proto *),
+                                        GFP_KERNEL);
                if (l4protos == NULL) {
                        ret = -ENOMEM;
                        goto out;
index ca4c4d994ddb09540b41fb28650552b31f85b4d9..896d4a36081d4bb527b10c5db27df1a4dab32df8 100644 (file)
@@ -2890,12 +2890,13 @@ static struct nft_set *nft_set_lookup_byid(const struct net *net,
        u32 id = ntohl(nla_get_be32(nla));
 
        list_for_each_entry(trans, &net->nft.commit_list, list) {
-               struct nft_set *set = nft_trans_set(trans);
+               if (trans->msg_type == NFT_MSG_NEWSET) {
+                       struct nft_set *set = nft_trans_set(trans);
 
-               if (trans->msg_type == NFT_MSG_NEWSET &&
-                   id == nft_trans_set_id(trans) &&
-                   nft_active_genmask(set, genmask))
-                       return set;
+                       if (id == nft_trans_set_id(trans) &&
+                           nft_active_genmask(set, genmask))
+                               return set;
+               }
        }
        return ERR_PTR(-ENOENT);
 }
@@ -5303,7 +5304,7 @@ static int nf_tables_flowtable_parse_hook(const struct nft_ctx *ctx,
        if (err < 0)
                return err;
 
-       ops = kzalloc(sizeof(struct nf_hook_ops) * n, GFP_KERNEL);
+       ops = kcalloc(n, sizeof(struct nf_hook_ops), GFP_KERNEL);
        if (!ops)
                return -ENOMEM;
 
@@ -5836,18 +5837,23 @@ static int nf_tables_flowtable_event(struct notifier_block *this,
        struct net_device *dev = netdev_notifier_info_to_dev(ptr);
        struct nft_flowtable *flowtable;
        struct nft_table *table;
+       struct net *net;
 
        if (event != NETDEV_UNREGISTER)
                return 0;
 
+       net = maybe_get_net(dev_net(dev));
+       if (!net)
+               return 0;
+
        nfnl_lock(NFNL_SUBSYS_NFTABLES);
-       list_for_each_entry(table, &dev_net(dev)->nft.tables, list) {
+       list_for_each_entry(table, &net->nft.tables, list) {
                list_for_each_entry(flowtable, &table->flowtables, list) {
                        nft_flowtable_event(event, dev, flowtable);
                }
        }
        nfnl_unlock(NFNL_SUBSYS_NFTABLES);
-
+       put_net(net);
        return NOTIFY_DONE;
 }
 
@@ -6438,7 +6444,7 @@ static void nf_tables_abort_release(struct nft_trans *trans)
        kfree(trans);
 }
 
-static int nf_tables_abort(struct net *net, struct sk_buff *skb)
+static int __nf_tables_abort(struct net *net)
 {
        struct nft_trans *trans, *next;
        struct nft_trans_elem *te;
@@ -6554,6 +6560,11 @@ static void nf_tables_cleanup(struct net *net)
        nft_validate_state_update(net, NFT_VALIDATE_SKIP);
 }
 
+static int nf_tables_abort(struct net *net, struct sk_buff *skb)
+{
+       return __nf_tables_abort(net);
+}
+
 static bool nf_tables_valid_genid(struct net *net, u32 genid)
 {
        return net->nft.base_seq == genid;
@@ -7148,9 +7159,12 @@ static int __net_init nf_tables_init_net(struct net *net)
 
 static void __net_exit nf_tables_exit_net(struct net *net)
 {
+       nfnl_lock(NFNL_SUBSYS_NFTABLES);
+       if (!list_empty(&net->nft.commit_list))
+               __nf_tables_abort(net);
        __nft_release_tables(net);
+       nfnl_unlock(NFNL_SUBSYS_NFTABLES);
        WARN_ON_ONCE(!list_empty(&net->nft.tables));
-       WARN_ON_ONCE(!list_empty(&net->nft.commit_list));
 }
 
 static struct pernet_operations nf_tables_net_ops = {
@@ -7164,8 +7178,8 @@ static int __init nf_tables_module_init(void)
 
        nft_chain_filter_init();
 
-       info = kmalloc(sizeof(struct nft_expr_info) * NFT_RULE_MAXEXPRS,
-                      GFP_KERNEL);
+       info = kmalloc_array(NFT_RULE_MAXEXPRS, sizeof(struct nft_expr_info),
+                            GFP_KERNEL);
        if (info == NULL) {
                err = -ENOMEM;
                goto err1;
@@ -7192,13 +7206,13 @@ static int __init nf_tables_module_init(void)
 
 static void __exit nf_tables_module_exit(void)
 {
-       unregister_pernet_subsys(&nf_tables_net_ops);
        nfnetlink_subsys_unregister(&nf_tables_subsys);
        unregister_netdevice_notifier(&nf_tables_flowtable_notifier);
+       nft_chain_filter_fini();
+       unregister_pernet_subsys(&nf_tables_net_ops);
        rcu_barrier();
        nf_tables_core_module_exit();
        kfree(info);
-       nft_chain_filter_fini();
 }
 
 module_init(nf_tables_module_init);
index deff10adef9c4b97bf60f0f5d18d46e33fcfd348..8de912ca53d3bfb1b2a924cbeb655d8e4d4ebd3a 100644 (file)
@@ -183,7 +183,8 @@ nft_do_chain(struct nft_pktinfo *pkt, void *priv)
 
        switch (regs.verdict.code) {
        case NFT_JUMP:
-               BUG_ON(stackptr >= NFT_JUMP_STACK_SIZE);
+               if (WARN_ON_ONCE(stackptr >= NFT_JUMP_STACK_SIZE))
+                       return NF_DROP;
                jumpstack[stackptr].chain = chain;
                jumpstack[stackptr].rules = rules + 1;
                stackptr++;
index 4d0da7042affbcc4a2d129c852cf1b6fd2bf04a3..e1b6be29848d2c00590ce98458f84b4243a5b45b 100644 (file)
@@ -429,7 +429,7 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
                         */
                        if (err == -EAGAIN) {
                                status |= NFNL_BATCH_REPLAY;
-                               goto next;
+                               goto done;
                        }
                }
 ack:
@@ -456,7 +456,7 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
                        if (err)
                                status |= NFNL_BATCH_FAILURE;
                }
-next:
+
                msglen = NLMSG_ALIGN(nlh->nlmsg_len);
                if (msglen > skb->len)
                        msglen = skb->len;
@@ -464,7 +464,11 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
        }
 done:
        if (status & NFNL_BATCH_REPLAY) {
-               ss->abort(net, oskb);
+               const struct nfnetlink_subsystem *ss2;
+
+               ss2 = nfnl_dereference_protected(subsys_id);
+               if (ss2 == ss)
+                       ss->abort(net, oskb);
                nfnl_err_reset(&err_list);
                nfnl_unlock(subsys_id);
                kfree_skb(skb);
index cb5b5f2077774c29fb987b7f1eb2d75e9efc2fe1..e5d27b2e4ebac9d7256ad53657167e3b87052f94 100644 (file)
@@ -190,8 +190,9 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper,
        if (class_max > NF_CT_MAX_EXPECT_CLASSES)
                return -EOVERFLOW;
 
-       expect_policy = kzalloc(sizeof(struct nf_conntrack_expect_policy) *
-                               class_max, GFP_KERNEL);
+       expect_policy = kcalloc(class_max,
+                               sizeof(struct nf_conntrack_expect_policy),
+                               GFP_KERNEL);
        if (expect_policy == NULL)
                return -ENOMEM;
 
index 84c902477a91efa963b7613743c0e07ff3afc867..d21834bed805b789c72d79640d8e98b2a6cf247c 100644 (file)
@@ -318,6 +318,10 @@ static int nf_tables_netdev_event(struct notifier_block *this,
            event != NETDEV_CHANGENAME)
                return NOTIFY_DONE;
 
+       ctx.net = maybe_get_net(ctx.net);
+       if (!ctx.net)
+               return NOTIFY_DONE;
+
        nfnl_lock(NFNL_SUBSYS_NFTABLES);
        list_for_each_entry(table, &ctx.net->nft.tables, list) {
                if (table->family != NFPROTO_NETDEV)
@@ -334,6 +338,7 @@ static int nf_tables_netdev_event(struct notifier_block *this,
                }
        }
        nfnl_unlock(NFNL_SUBSYS_NFTABLES);
+       put_net(ctx.net);
 
        return NOTIFY_DONE;
 }
index 50c068d660e54647c0068c087a9f6b90f9e14686..a832c59f0a9cbeb30cd1d261c2be81fc8b5d7027 100644 (file)
@@ -52,7 +52,7 @@ static inline void nft_connlimit_do_eval(struct nft_connlimit *priv,
        if (!addit)
                goto out;
 
-       if (!nf_conncount_add(&priv->hhead, tuple_ptr)) {
+       if (!nf_conncount_add(&priv->hhead, tuple_ptr, zone)) {
                regs->verdict.code = NF_DROP;
                spin_unlock_bh(&priv->lock);
                return;
index 4d49529cff615285bd3d1c8d5914e2624ece7da4..27d7e4598ab63c982b034136a3115f710b545679 100644 (file)
@@ -203,9 +203,7 @@ static int nft_dynset_init(const struct nft_ctx *ctx,
                                goto err1;
                        set->ops->gc_init(set);
                }
-
-       } else if (set->flags & NFT_SET_EVAL)
-               return -EINVAL;
+       }
 
        nft_set_ext_prepare(&priv->tmpl);
        nft_set_ext_add_length(&priv->tmpl, NFT_SET_EXT_KEY, set->klen);
index d260ce2d6671e8d18bed0eb8bcf673fdd132342d..7f3a9a211034b2dee751dd776e1b5f59db6c6b61 100644 (file)
@@ -66,7 +66,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set
                        parent = rcu_dereference_raw(parent->rb_left);
                        if (interval &&
                            nft_rbtree_equal(set, this, interval) &&
-                           nft_rbtree_interval_end(this) &&
+                           nft_rbtree_interval_end(rbe) &&
                            !nft_rbtree_interval_end(interval))
                                continue;
                        interval = rbe;
index f28a0b944087960d3eb6157c4a174fc8a8391c10..74e1b3bd695417daf3afb725d3183658a3a81342 100644 (file)
@@ -142,3 +142,4 @@ module_exit(nft_socket_module_exit);
 MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Máté Eckl");
 MODULE_DESCRIPTION("nf_tables socket match module");
+MODULE_ALIAS_NFT_EXPR("socket");
index df9ab71b0ed95a73e0e16443087507b91709c80d..d0d8397c95889f5b947def5ba90b62ac6b1bcaa7 100644 (file)
@@ -1904,7 +1904,7 @@ static int __init xt_init(void)
                seqcount_init(&per_cpu(xt_recseq, i));
        }
 
-       xt = kmalloc(sizeof(struct xt_af) * NFPROTO_NUMPROTO, GFP_KERNEL);
+       xt = kmalloc_array(NFPROTO_NUMPROTO, sizeof(struct xt_af), GFP_KERNEL);
        if (!xt)
                return -ENOMEM;
 
index 8790190c6feb3cf1bce5577319fc043a5c55dc2c..03b9a50ec93bd958d1ef46d59a981f8be1d89aa4 100644 (file)
@@ -245,12 +245,22 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
        }
 
        if (info->helper[0]) {
+               if (strnlen(info->helper, sizeof(info->helper)) == sizeof(info->helper)) {
+                       ret = -ENAMETOOLONG;
+                       goto err3;
+               }
+
                ret = xt_ct_set_helper(ct, info->helper, par);
                if (ret < 0)
                        goto err3;
        }
 
        if (info->timeout[0]) {
+               if (strnlen(info->timeout, sizeof(info->timeout)) == sizeof(info->timeout)) {
+                       ret = -ENAMETOOLONG;
+                       goto err4;
+               }
+
                ret = xt_ct_set_timeout(ct, par, info->timeout);
                if (ret < 0)
                        goto err4;
index 94df000abb92d657addb2cad35028a2d3f08e024..29c38aa7f72620dc095406955bcda94e686df82d 100644 (file)
@@ -211,7 +211,7 @@ static int __init connmark_mt_init(void)
 static void __exit connmark_mt_exit(void)
 {
        xt_unregister_match(&connmark_mt_reg);
-       xt_unregister_target(connmark_tg_reg);
+       xt_unregister_targets(connmark_tg_reg, ARRAY_SIZE(connmark_tg_reg));
 }
 
 module_init(connmark_mt_init);
index 6f4c5217d8358cadb1537b0f4c3a3b4c1ab43175..bf2890b1321280bbf0b2791647158854b85f29e1 100644 (file)
@@ -372,8 +372,8 @@ set_target_v2(struct sk_buff *skb, const struct xt_action_param *par)
 
        /* Normalize to fit into jiffies */
        if (add_opt.ext.timeout != IPSET_NO_TIMEOUT &&
-           add_opt.ext.timeout > UINT_MAX / MSEC_PER_SEC)
-               add_opt.ext.timeout = UINT_MAX / MSEC_PER_SEC;
+           add_opt.ext.timeout > IPSET_MAX_TIMEOUT)
+               add_opt.ext.timeout = IPSET_MAX_TIMEOUT;
        if (info->add_set.index != IPSET_INVALID_ID)
                ip_set_add(info->add_set.index, skb, par, &add_opt);
        if (info->del_set.index != IPSET_INVALID_ID)
@@ -407,8 +407,8 @@ set_target_v3(struct sk_buff *skb, const struct xt_action_param *par)
 
        /* Normalize to fit into jiffies */
        if (add_opt.ext.timeout != IPSET_NO_TIMEOUT &&
-           add_opt.ext.timeout > UINT_MAX / MSEC_PER_SEC)
-               add_opt.ext.timeout = UINT_MAX / MSEC_PER_SEC;
+           add_opt.ext.timeout > IPSET_MAX_TIMEOUT)
+               add_opt.ext.timeout = IPSET_MAX_TIMEOUT;
        if (info->add_set.index != IPSET_INVALID_ID)
                ip_set_add(info->add_set.index, skb, par, &add_opt);
        if (info->del_set.index != IPSET_INVALID_ID)
@@ -470,7 +470,7 @@ set_target_v3_checkentry(const struct xt_tgchk_param *par)
                }
                if (((info->flags & IPSET_FLAG_MAP_SKBPRIO) |
                     (info->flags & IPSET_FLAG_MAP_SKBQUEUE)) &&
-                    !(par->hook_mask & (1 << NF_INET_FORWARD |
+                    (par->hook_mask & ~(1 << NF_INET_FORWARD |
                                         1 << NF_INET_LOCAL_OUT |
                                         1 << NF_INET_POST_ROUTING))) {
                        pr_info_ratelimited("mapping of prio or/and queue is allowed only from OUTPUT/FORWARD/POSTROUTING chains\n");
index b9ce82c9440f1cde865a456ca926a6f5782c29a7..25eeb6d2a75a69059f387be103345e844284f743 100644 (file)
@@ -352,8 +352,9 @@ int genl_register_family(struct genl_family *family)
        }
 
        if (family->maxattr && !family->parallel_ops) {
-               family->attrbuf = kmalloc((family->maxattr+1) *
-                                       sizeof(struct nlattr *), GFP_KERNEL);
+               family->attrbuf = kmalloc_array(family->maxattr + 1,
+                                               sizeof(struct nlattr *),
+                                               GFP_KERNEL);
                if (family->attrbuf == NULL) {
                        err = -ENOMEM;
                        goto errout_locked;
@@ -566,8 +567,9 @@ static int genl_family_rcv_msg(const struct genl_family *family,
                return -EOPNOTSUPP;
 
        if (family->maxattr && family->parallel_ops) {
-               attrbuf = kmalloc((family->maxattr+1) *
-                                       sizeof(struct nlattr *), GFP_KERNEL);
+               attrbuf = kmalloc_array(family->maxattr + 1,
+                                       sizeof(struct nlattr *),
+                                       GFP_KERNEL);
                if (attrbuf == NULL)
                        return -ENOMEM;
        } else
index b97eb766a1d52a97d7c6445594f259aeee276ca4..93fbcafbf3886d34b0be87244c405b8319df89dd 100644 (file)
@@ -1395,7 +1395,7 @@ static int __init nr_proto_init(void)
                return -1;
        }
 
-       dev_nr = kzalloc(nr_ndevs * sizeof(struct net_device *), GFP_KERNEL);
+       dev_nr = kcalloc(nr_ndevs, sizeof(struct net_device *), GFP_KERNEL);
        if (dev_nr == NULL) {
                printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device array\n");
                return -1;
index a61818e943969936ba4cc2c49818b7b889d5faf5..0f5ce77460d44099277e142e37d11620e426e9cb 100644 (file)
@@ -1578,8 +1578,9 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
                goto err_destroy_table;
        }
 
-       dp->ports = kmalloc(DP_VPORT_HASH_BUCKETS * sizeof(struct hlist_head),
-                           GFP_KERNEL);
+       dp->ports = kmalloc_array(DP_VPORT_HASH_BUCKETS,
+                                 sizeof(struct hlist_head),
+                                 GFP_KERNEL);
        if (!dp->ports) {
                err = -ENOMEM;
                goto err_destroy_percpu;
index f81c1d0ddff4d6e05da635f78e84bd28cc681f06..19f6765566e727d8e02655f0dd6c2f0f971f64e3 100644 (file)
@@ -47,7 +47,7 @@ static struct hlist_head *dev_table;
  */
 int ovs_vport_init(void)
 {
-       dev_table = kzalloc(VPORT_HASH_BUCKETS * sizeof(struct hlist_head),
+       dev_table = kcalloc(VPORT_HASH_BUCKETS, sizeof(struct hlist_head),
                            GFP_KERNEL);
        if (!dev_table)
                return -ENOMEM;
index ee018564b2b4749d55c2080ac7ccd34fcd805e9a..50809748c1279ea17b7499acbec5699443804f64 100644 (file)
@@ -4161,7 +4161,7 @@ static char *alloc_one_pg_vec_page(unsigned long order)
                return buffer;
 
        /* __get_free_pages failed, fall back to vmalloc */
-       buffer = vzalloc((1 << order) * PAGE_SIZE);
+       buffer = vzalloc(array_size((1 << order), PAGE_SIZE));
        if (buffer)
                return buffer;
 
index 02deee29e7f109e96908382345faf528471f2d90..b6ad38e48f62692fa9dc6cc9f7c7081c706394a7 100644 (file)
@@ -163,7 +163,8 @@ static void rds_ib_add_one(struct ib_device *device)
        rds_ibdev->max_initiator_depth = device->attrs.max_qp_init_rd_atom;
        rds_ibdev->max_responder_resources = device->attrs.max_qp_rd_atom;
 
-       rds_ibdev->vector_load = kzalloc(sizeof(int) * device->num_comp_vectors,
+       rds_ibdev->vector_load = kcalloc(device->num_comp_vectors,
+                                        sizeof(int),
                                         GFP_KERNEL);
        if (!rds_ibdev->vector_load) {
                pr_err("RDS/IB: %s failed to allocate vector memory\n",
index 13b38ad0fa4a4c9e70f4f593a5a1c2a058a0d446..f1684ae6abfd520fc0579a50f007316e9a09c31d 100644 (file)
@@ -526,7 +526,8 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
                goto recv_hdrs_dma_out;
        }
 
-       ic->i_sends = vzalloc_node(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work),
+       ic->i_sends = vzalloc_node(array_size(sizeof(struct rds_ib_send_work),
+                                             ic->i_send_ring.w_nr),
                                   ibdev_to_node(dev));
        if (!ic->i_sends) {
                ret = -ENOMEM;
@@ -534,7 +535,8 @@ static int rds_ib_setup_qp(struct rds_connection *conn)
                goto ack_dma_out;
        }
 
-       ic->i_recvs = vzalloc_node(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work),
+       ic->i_recvs = vzalloc_node(array_size(sizeof(struct rds_ib_recv_work),
+                                             ic->i_recv_ring.w_nr),
                                   ibdev_to_node(dev));
        if (!ic->i_recvs) {
                ret = -ENOMEM;
index 140a44a5f7b7f1c08b3f329707b72fc75a9a81fe..e367a97a18c805f7e0c6c473e5e273d280acc2fb 100644 (file)
@@ -188,7 +188,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval,
        nr_pages = (PAGE_ALIGN(start + len) - (start & PAGE_MASK))
                        >> PAGE_SHIFT;
 
-       pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL);
+       pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL);
        if (!pages) {
                ret = -ENOMEM;
                goto out;
index f2bf78de5688a3ee44862fe158bffee4ca94d91a..dac6218a460ed4d4a5b7b03ad4f6056a68784a16 100644 (file)
@@ -193,4 +193,5 @@ struct rds_transport rds_loop_transport = {
        .inc_copy_to_user       = rds_message_inc_copy_to_user,
        .inc_free               = rds_loop_inc_free,
        .t_name                 = "loopback",
+       .t_type                 = RDS_TRANS_LOOP,
 };
index b04c333d9d1c201ba4aa4617c750941cf4cdfec7..f2272fb8cd456e7b5bb2495d5d02691803c3769f 100644 (file)
@@ -479,6 +479,11 @@ struct rds_notifier {
        int                     n_status;
 };
 
+/* Available as part of RDS core, so doesn't need to participate
+ * in get_preferred transport etc
+ */
+#define        RDS_TRANS_LOOP  3
+
 /**
  * struct rds_transport -  transport specific behavioural hooks
  *
index dc67458b52f0043c2328d4a77a43536e7c62b0ed..192ac6f78ded7b0288ac01d641cd5f7772b03fd8 100644 (file)
@@ -103,6 +103,11 @@ static void rds_recv_rcvbuf_delta(struct rds_sock *rs, struct sock *sk,
                rds_stats_add(s_recv_bytes_added_to_socket, delta);
        else
                rds_stats_add(s_recv_bytes_removed_from_socket, -delta);
+
+       /* loop transport doesn't send/recv congestion updates */
+       if (rs->rs_transport->t_type == RDS_TRANS_LOOP)
+               return;
+
        now_congested = rs->rs_rcv_bytes > rds_sk_rcvbuf(rs);
 
        rdsdebug("rs %p (%pI4:%u) recv bytes %d buf %d "
index 5b73fea849dff2d72bca7dbc5295ba9f369acf84..ebe42e7eb45697030367c4baba455b50c973c409 100644 (file)
@@ -1514,7 +1514,8 @@ static int __init rose_proto_init(void)
 
        rose_callsign = null_ax25_address;
 
-       dev_rose = kzalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL);
+       dev_rose = kcalloc(rose_ndevs, sizeof(struct net_device *),
+                          GFP_KERNEL);
        if (dev_rose == NULL) {
                printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
                rc = -ENOMEM;
index 6c0ae27fff84e2312bdc6a7f84abc7ed288e05de..278ac0807a60a8664bbb825ccd06737a595d8631 100644 (file)
@@ -432,7 +432,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,
 
        sg = _sg;
        if (unlikely(nsg > 4)) {
-               sg = kmalloc(sizeof(*sg) * nsg, GFP_NOIO);
+               sg = kmalloc_array(nsg, sizeof(*sg), GFP_NOIO);
                if (!sg)
                        goto nomem;
        }
index 22fa13cf5d8b89916cb004438ed5132adbad521a..cd2e0e342fb6235840860ff15ceaeb73eddaa492 100644 (file)
@@ -489,11 +489,12 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
                return err;
 
        if (!q->flows) {
-               q->flows = kvzalloc(q->flows_cnt *
-                                          sizeof(struct fq_codel_flow), GFP_KERNEL);
+               q->flows = kvcalloc(q->flows_cnt,
+                                   sizeof(struct fq_codel_flow),
+                                   GFP_KERNEL);
                if (!q->flows)
                        return -ENOMEM;
-               q->backlogs = kvzalloc(q->flows_cnt * sizeof(u32), GFP_KERNEL);
+               q->backlogs = kvcalloc(q->flows_cnt, sizeof(u32), GFP_KERNEL);
                if (!q->backlogs)
                        return -ENOMEM;
                for (i = 0; i < q->flows_cnt; i++) {
index bce2632212d3e795b9ff5cac779f25a5c94bcac3..c3a8388dcdf6bcd5e8fc34f16c3104ce5c0de075 100644 (file)
@@ -599,8 +599,8 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt,
 
        if (!q->hh_flows) {
                /* Initialize heavy-hitter flow table. */
-               q->hh_flows = kvzalloc(HH_FLOWS_CNT *
-                                        sizeof(struct list_head), GFP_KERNEL);
+               q->hh_flows = kvcalloc(HH_FLOWS_CNT, sizeof(struct list_head),
+                                      GFP_KERNEL);
                if (!q->hh_flows)
                        return -ENOMEM;
                for (i = 0; i < HH_FLOWS_CNT; i++)
@@ -614,8 +614,9 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt,
 
                /* Initialize heavy-hitter filter arrays. */
                for (i = 0; i < HHF_ARRAYS_CNT; i++) {
-                       q->hhf_arrays[i] = kvzalloc(HHF_ARRAYS_LEN *
-                                                     sizeof(u32), GFP_KERNEL);
+                       q->hhf_arrays[i] = kvcalloc(HHF_ARRAYS_LEN,
+                                                   sizeof(u32),
+                                                   GFP_KERNEL);
                        if (!q->hhf_arrays[i]) {
                                /* Note: hhf_destroy() will be called
                                 * by our caller.
index e64630cd33318ef3c90339bd61388fafd27928f3..5b537613946fcaaabcb2716b74b5a7188a828142 100644 (file)
@@ -482,8 +482,9 @@ int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp)
                return 0;
 
        /* Allocated the array of pointers to transorms */
-       ep->auth_hmacs = kzalloc(sizeof(struct crypto_shash *) *
-                                SCTP_AUTH_NUM_HMACS, gfp);
+       ep->auth_hmacs = kcalloc(SCTP_AUTH_NUM_HMACS,
+                                sizeof(struct crypto_shash *),
+                                gfp);
        if (!ep->auth_hmacs)
                return -ENOMEM;
 
index e672dee302c7092433a64ed3ed8bfcd183e1f9c8..7f849b01ec8e6767b851145bbf3d7086cc1cef23 100644 (file)
@@ -409,6 +409,21 @@ static void sctp_packet_set_owner_w(struct sk_buff *skb, struct sock *sk)
        refcount_inc(&sk->sk_wmem_alloc);
 }
 
+static void sctp_packet_gso_append(struct sk_buff *head, struct sk_buff *skb)
+{
+       if (SCTP_OUTPUT_CB(head)->last == head)
+               skb_shinfo(head)->frag_list = skb;
+       else
+               SCTP_OUTPUT_CB(head)->last->next = skb;
+       SCTP_OUTPUT_CB(head)->last = skb;
+
+       head->truesize += skb->truesize;
+       head->data_len += skb->len;
+       head->len += skb->len;
+
+       __skb_header_release(skb);
+}
+
 static int sctp_packet_pack(struct sctp_packet *packet,
                            struct sk_buff *head, int gso, gfp_t gfp)
 {
@@ -422,7 +437,7 @@ static int sctp_packet_pack(struct sctp_packet *packet,
 
        if (gso) {
                skb_shinfo(head)->gso_type = sk->sk_gso_type;
-               NAPI_GRO_CB(head)->last = head;
+               SCTP_OUTPUT_CB(head)->last = head;
        } else {
                nskb = head;
                pkt_size = packet->size;
@@ -503,15 +518,8 @@ static int sctp_packet_pack(struct sctp_packet *packet,
                                         &packet->chunk_list);
                }
 
-               if (gso) {
-                       if (skb_gro_receive(&head, nskb)) {
-                               kfree_skb(nskb);
-                               return 0;
-                       }
-                       if (WARN_ON_ONCE(skb_shinfo(head)->gso_segs >=
-                                        sk->sk_gso_max_segs))
-                               return 0;
-               }
+               if (gso)
+                       sctp_packet_gso_append(head, nskb);
 
                pkt_count++;
        } while (!list_empty(&packet->chunk_list));
index 11d93377ba5e86b6863b7a16b95e2f599d01f8c1..5dffbc4930086699cefa10f704de5fd2068169c8 100644 (file)
@@ -1438,7 +1438,7 @@ static __init int sctp_init(void)
        /* Allocate and initialize the endpoint hash table.  */
        sctp_ep_hashsize = 64;
        sctp_ep_hashtable =
-               kmalloc(64 * sizeof(struct sctp_hashbucket), GFP_KERNEL);
+               kmalloc_array(64, sizeof(struct sctp_hashbucket), GFP_KERNEL);
        if (!sctp_ep_hashtable) {
                pr_err("Failed endpoint_hash alloc\n");
                status = -ENOMEM;
index 973b4471b532b0e64525e94bb2cb181a88b17bbc..da7f02edcd374c44437e34a2705f410317ea536d 100644 (file)
@@ -1273,8 +1273,7 @@ static __poll_t smc_accept_poll(struct sock *parent)
        return mask;
 }
 
-static __poll_t smc_poll(struct file *file, struct socket *sock,
-                            poll_table *wait)
+static __poll_t smc_poll_mask(struct socket *sock, __poll_t events)
 {
        struct sock *sk = sock->sk;
        __poll_t mask = 0;
@@ -1290,7 +1289,7 @@ static __poll_t smc_poll(struct file *file, struct socket *sock,
        if ((sk->sk_state == SMC_INIT) || smc->use_fallback) {
                /* delegate to CLC child sock */
                release_sock(sk);
-               mask = smc->clcsock->ops->poll(file, smc->clcsock, wait);
+               mask = smc->clcsock->ops->poll_mask(smc->clcsock, events);
                lock_sock(sk);
                sk->sk_err = smc->clcsock->sk->sk_err;
                if (sk->sk_err) {
@@ -1308,11 +1307,6 @@ static __poll_t smc_poll(struct file *file, struct socket *sock,
                        }
                }
        } else {
-               if (sk->sk_state != SMC_CLOSED) {
-                       release_sock(sk);
-                       sock_poll_wait(file, sk_sleep(sk), wait);
-                       lock_sock(sk);
-               }
                if (sk->sk_err)
                        mask |= EPOLLERR;
                if ((sk->sk_shutdown == SHUTDOWN_MASK) ||
@@ -1625,7 +1619,7 @@ static const struct proto_ops smc_sock_ops = {
        .socketpair     = sock_no_socketpair,
        .accept         = smc_accept,
        .getname        = smc_getname,
-       .poll           = smc_poll,
+       .poll_mask      = smc_poll_mask,
        .ioctl          = smc_ioctl,
        .listen         = smc_listen,
        .shutdown       = smc_shutdown,
index cc7c1bb60fe87115e942f96f7c6a87602ccd6094..dbd2605d19627b0f91731767f3d0d8e0c166f454 100644 (file)
@@ -584,9 +584,9 @@ int smc_wr_alloc_link_mem(struct smc_link *link)
                                   GFP_KERNEL);
        if (!link->wr_rx_sges)
                goto no_mem_wr_tx_sges;
-       link->wr_tx_mask = kzalloc(
-               BITS_TO_LONGS(SMC_WR_BUF_CNT) * sizeof(*link->wr_tx_mask),
-               GFP_KERNEL);
+       link->wr_tx_mask = kcalloc(BITS_TO_LONGS(SMC_WR_BUF_CNT),
+                                  sizeof(*link->wr_tx_mask),
+                                  GFP_KERNEL);
        if (!link->wr_tx_mask)
                goto no_mem_wr_rx_sges;
        link->wr_tx_pends = kcalloc(SMC_WR_BUF_CNT,
index 9463af4b32e8d7d688523986c584e73046d4dd7a..be8f103d22fdb7e439bb3ae610aaa3726a4b8332 100644 (file)
@@ -1753,7 +1753,8 @@ alloc_enc_pages(struct rpc_rqst *rqstp)
        last = (snd_buf->page_base + snd_buf->page_len - 1) >> PAGE_SHIFT;
        rqstp->rq_enc_pages_num = last - first + 1 + 1;
        rqstp->rq_enc_pages
-               = kmalloc(rqstp->rq_enc_pages_num * sizeof(struct page *),
+               = kmalloc_array(rqstp->rq_enc_pages_num,
+                               sizeof(struct page *),
                                GFP_NOFS);
        if (!rqstp->rq_enc_pages)
                goto out;
index 46b295e4f2b82c3ca70efe04091aeebfb97b8ae9..1c7c49dbf8ba6a837658aef0a72dc0b0e58df128 100644 (file)
@@ -224,7 +224,7 @@ static void gssp_free_receive_pages(struct gssx_arg_accept_sec_context *arg)
 static int gssp_alloc_receive_pages(struct gssx_arg_accept_sec_context *arg)
 {
        arg->npages = DIV_ROUND_UP(NGROUPS_MAX * 4, PAGE_SIZE);
-       arg->pages = kzalloc(arg->npages * sizeof(struct page *), GFP_KERNEL);
+       arg->pages = kcalloc(arg->npages, sizeof(struct page *), GFP_KERNEL);
        /*
         * XXX: actual pages are allocated by xdr layer in
         * xdr_partial_copy_from_skb.
@@ -298,9 +298,11 @@ int gssp_accept_sec_context_upcall(struct net *net,
        if (res.context_handle) {
                data->out_handle = rctxh.exported_context_token;
                data->mech_oid.len = rctxh.mech.len;
-               if (rctxh.mech.data)
+               if (rctxh.mech.data) {
                        memcpy(data->mech_oid.data, rctxh.mech.data,
                                                data->mech_oid.len);
+                       kfree(rctxh.mech.data);
+               }
                client_name = rctxh.src_name.display_name;
        }
 
index cdda4744c9b154295cbff961a3f5a71eacb86983..109fbe591e7bf35de11e7d5fee20de519e872aa0 100644 (file)
@@ -1683,7 +1683,7 @@ struct cache_detail *cache_create_net(const struct cache_detail *tmpl, struct ne
        if (cd == NULL)
                return ERR_PTR(-ENOMEM);
 
-       cd->hash_table = kzalloc(cd->hash_size * sizeof(struct hlist_head),
+       cd->hash_table = kcalloc(cd->hash_size, sizeof(struct hlist_head),
                                 GFP_KERNEL);
        if (cd->hash_table == NULL) {
                kfree(cd);
index c2266f3872137a55993b2ad7d59bd9b623d03322..d839c33ae7d9909c627727ca1e2da9ec432021eb 100644 (file)
@@ -1546,6 +1546,7 @@ call_reserveresult(struct rpc_task *task)
        task->tk_status = 0;
        if (status >= 0) {
                if (task->tk_rqstp) {
+                       xprt_request_init(task);
                        task->tk_action = call_refresh;
                        return;
                }
index 70f005044f06417ee09c94b85b9d125dc34da206..3c85af058227d14bda8d9f598ec45e7b8db1785e 100644 (file)
@@ -66,7 +66,7 @@
  * Local functions
  */
 static void     xprt_init(struct rpc_xprt *xprt, struct net *net);
-static void    xprt_request_init(struct rpc_task *, struct rpc_xprt *);
+static __be32  xprt_alloc_xid(struct rpc_xprt *xprt);
 static void    xprt_connect_status(struct rpc_task *task);
 static int      __xprt_get_cong(struct rpc_xprt *, struct rpc_task *);
 static void     __xprt_put_cong(struct rpc_xprt *, struct rpc_rqst *);
@@ -987,6 +987,8 @@ bool xprt_prepare_transmit(struct rpc_task *task)
                task->tk_status = -EAGAIN;
                goto out_unlock;
        }
+       if (!bc_prealloc(req) && !req->rq_xmit_bytes_sent)
+               req->rq_xid = xprt_alloc_xid(xprt);
        ret = true;
 out_unlock:
        spin_unlock_bh(&xprt->transport_lock);
@@ -1163,10 +1165,10 @@ void xprt_alloc_slot(struct rpc_xprt *xprt, struct rpc_task *task)
 out_init_req:
        xprt->stat.max_slots = max_t(unsigned int, xprt->stat.max_slots,
                                     xprt->num_reqs);
+       spin_unlock(&xprt->reserve_lock);
+
        task->tk_status = 0;
        task->tk_rqstp = req;
-       xprt_request_init(task, xprt);
-       spin_unlock(&xprt->reserve_lock);
 }
 EXPORT_SYMBOL_GPL(xprt_alloc_slot);
 
@@ -1184,7 +1186,7 @@ void xprt_lock_and_alloc_slot(struct rpc_xprt *xprt, struct rpc_task *task)
 }
 EXPORT_SYMBOL_GPL(xprt_lock_and_alloc_slot);
 
-static void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
+void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
 {
        spin_lock(&xprt->reserve_lock);
        if (!xprt_dynamic_free_slot(xprt, req)) {
@@ -1194,6 +1196,7 @@ static void xprt_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *req)
        xprt_wake_up_backlog(xprt);
        spin_unlock(&xprt->reserve_lock);
 }
+EXPORT_SYMBOL_GPL(xprt_free_slot);
 
 static void xprt_free_all_slots(struct rpc_xprt *xprt)
 {
@@ -1303,8 +1306,9 @@ static inline void xprt_init_xid(struct rpc_xprt *xprt)
        xprt->xid = prandom_u32();
 }
 
-static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
+void xprt_request_init(struct rpc_task *task)
 {
+       struct rpc_xprt *xprt = task->tk_xprt;
        struct rpc_rqst *req = task->tk_rqstp;
 
        INIT_LIST_HEAD(&req->rq_list);
@@ -1312,7 +1316,6 @@ static void xprt_request_init(struct rpc_task *task, struct rpc_xprt *xprt)
        req->rq_task    = task;
        req->rq_xprt    = xprt;
        req->rq_buffer  = NULL;
-       req->rq_xid     = xprt_alloc_xid(xprt);
        req->rq_connect_cookie = xprt->connect_cookie - 1;
        req->rq_bytes_sent = 0;
        req->rq_snd_buf.len = 0;
@@ -1373,7 +1376,7 @@ void xprt_release(struct rpc_task *task)
 
        dprintk("RPC: %5u release request %p\n", task->tk_pid, req);
        if (likely(!bc_prealloc(req)))
-               xprt_free_slot(xprt, req);
+               xprt->ops->free_slot(xprt, req);
        else
                xprt_free_bc_request(req);
 }
index 47ebac94976991269be86f7200c9f73d8bfc8959..90adeff4c06b889391ae9d08e22ebe7d13dd9bbc 100644 (file)
@@ -9,8 +9,10 @@
 #include <linux/sunrpc/xprt.h>
 #include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/svc_xprt.h>
+#include <linux/sunrpc/svc_rdma.h>
 
 #include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
 
 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
 # define RPCDBG_FACILITY       RPCDBG_TRANS
@@ -29,29 +31,41 @@ static void rpcrdma_bc_free_rqst(struct rpcrdma_xprt *r_xprt,
        spin_unlock(&buf->rb_reqslock);
 
        rpcrdma_destroy_req(req);
-
-       kfree(rqst);
 }
 
-static int rpcrdma_bc_setup_rqst(struct rpcrdma_xprt *r_xprt,
-                                struct rpc_rqst *rqst)
+static int rpcrdma_bc_setup_reqs(struct rpcrdma_xprt *r_xprt,
+                                unsigned int count)
 {
-       struct rpcrdma_regbuf *rb;
-       struct rpcrdma_req *req;
-       size_t size;
+       struct rpc_xprt *xprt = &r_xprt->rx_xprt;
+       struct rpc_rqst *rqst;
+       unsigned int i;
+
+       for (i = 0; i < (count << 1); i++) {
+               struct rpcrdma_regbuf *rb;
+               struct rpcrdma_req *req;
+               size_t size;
+
+               req = rpcrdma_create_req(r_xprt);
+               if (IS_ERR(req))
+                       return PTR_ERR(req);
+               rqst = &req->rl_slot;
+
+               rqst->rq_xprt = xprt;
+               INIT_LIST_HEAD(&rqst->rq_list);
+               INIT_LIST_HEAD(&rqst->rq_bc_list);
+               __set_bit(RPC_BC_PA_IN_USE, &rqst->rq_bc_pa_state);
+               spin_lock_bh(&xprt->bc_pa_lock);
+               list_add(&rqst->rq_bc_pa_list, &xprt->bc_pa_list);
+               spin_unlock_bh(&xprt->bc_pa_lock);
 
-       req = rpcrdma_create_req(r_xprt);
-       if (IS_ERR(req))
-               return PTR_ERR(req);
-
-       size = r_xprt->rx_data.inline_rsize;
-       rb = rpcrdma_alloc_regbuf(size, DMA_TO_DEVICE, GFP_KERNEL);
-       if (IS_ERR(rb))
-               goto out_fail;
-       req->rl_sendbuf = rb;
-       xdr_buf_init(&rqst->rq_snd_buf, rb->rg_base,
-                    min_t(size_t, size, PAGE_SIZE));
-       rpcrdma_set_xprtdata(rqst, req);
+               size = r_xprt->rx_data.inline_rsize;
+               rb = rpcrdma_alloc_regbuf(size, DMA_TO_DEVICE, GFP_KERNEL);
+               if (IS_ERR(rb))
+                       goto out_fail;
+               req->rl_sendbuf = rb;
+               xdr_buf_init(&rqst->rq_snd_buf, rb->rg_base,
+                            min_t(size_t, size, PAGE_SIZE));
+       }
        return 0;
 
 out_fail:
@@ -59,23 +73,6 @@ static int rpcrdma_bc_setup_rqst(struct rpcrdma_xprt *r_xprt,
        return -ENOMEM;
 }
 
-/* Allocate and add receive buffers to the rpcrdma_buffer's
- * existing list of rep's. These are released when the
- * transport is destroyed.
- */
-static int rpcrdma_bc_setup_reps(struct rpcrdma_xprt *r_xprt,
-                                unsigned int count)
-{
-       int rc = 0;
-
-       while (count--) {
-               rc = rpcrdma_create_rep(r_xprt);
-               if (rc)
-                       break;
-       }
-       return rc;
-}
-
 /**
  * xprt_rdma_bc_setup - Pre-allocate resources for handling backchannel requests
  * @xprt: transport associated with these backchannel resources
@@ -86,9 +83,6 @@ static int rpcrdma_bc_setup_reps(struct rpcrdma_xprt *r_xprt,
 int xprt_rdma_bc_setup(struct rpc_xprt *xprt, unsigned int reqs)
 {
        struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
-       struct rpcrdma_buffer *buffer = &r_xprt->rx_buf;
-       struct rpc_rqst *rqst;
-       unsigned int i;
        int rc;
 
        /* The backchannel reply path returns each rpc_rqst to the
@@ -103,35 +97,11 @@ int xprt_rdma_bc_setup(struct rpc_xprt *xprt, unsigned int reqs)
        if (reqs > RPCRDMA_BACKWARD_WRS >> 1)
                goto out_err;
 
-       for (i = 0; i < (reqs << 1); i++) {
-               rqst = kzalloc(sizeof(*rqst), GFP_KERNEL);
-               if (!rqst)
-                       goto out_free;
-
-               dprintk("RPC:       %s: new rqst %p\n", __func__, rqst);
-
-               rqst->rq_xprt = &r_xprt->rx_xprt;
-               INIT_LIST_HEAD(&rqst->rq_list);
-               INIT_LIST_HEAD(&rqst->rq_bc_list);
-               __set_bit(RPC_BC_PA_IN_USE, &rqst->rq_bc_pa_state);
-
-               if (rpcrdma_bc_setup_rqst(r_xprt, rqst))
-                       goto out_free;
-
-               spin_lock_bh(&xprt->bc_pa_lock);
-               list_add(&rqst->rq_bc_pa_list, &xprt->bc_pa_list);
-               spin_unlock_bh(&xprt->bc_pa_lock);
-       }
-
-       rc = rpcrdma_bc_setup_reps(r_xprt, reqs);
+       rc = rpcrdma_bc_setup_reqs(r_xprt, reqs);
        if (rc)
                goto out_free;
 
-       rc = rpcrdma_ep_post_extra_recv(r_xprt, reqs);
-       if (rc)
-               goto out_free;
-
-       buffer->rb_bc_srv_max_requests = reqs;
+       r_xprt->rx_buf.rb_bc_srv_max_requests = reqs;
        request_module("svcrdma");
        trace_xprtrdma_cb_setup(r_xprt, reqs);
        return 0;
@@ -235,6 +205,7 @@ int xprt_rdma_bc_send_reply(struct rpc_rqst *rqst)
        if (rc < 0)
                goto failed_marshal;
 
+       rpcrdma_post_recvs(r_xprt, true);
        if (rpcrdma_ep_post(&r_xprt->rx_ia, &r_xprt->rx_ep, req))
                goto drop_connection;
        return 0;
@@ -275,10 +246,14 @@ void xprt_rdma_bc_destroy(struct rpc_xprt *xprt, unsigned int reqs)
  */
 void xprt_rdma_bc_free_rqst(struct rpc_rqst *rqst)
 {
+       struct rpcrdma_req *req = rpcr_to_rdmar(rqst);
        struct rpc_xprt *xprt = rqst->rq_xprt;
 
        dprintk("RPC:       %s: freeing rqst %p (req %p)\n",
-               __func__, rqst, rpcr_to_rdmar(rqst));
+               __func__, rqst, req);
+
+       rpcrdma_recv_buffer_put(req->rl_reply);
+       req->rl_reply = NULL;
 
        spin_lock_bh(&xprt->bc_pa_lock);
        list_add_tail(&rqst->rq_bc_pa_list, &xprt->bc_pa_list);
index f2f63959fddd3f5b6610fb9e566f06f42e5377b1..17fb1e02565466462e95d479b6c1cc9d5f853f20 100644 (file)
  * verb (fmr_op_unmap).
  */
 
+#include <linux/sunrpc/svc_rdma.h>
+
 #include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
 
 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
 # define RPCDBG_FACILITY       RPCDBG_TRANS
@@ -156,10 +159,32 @@ fmr_op_recover_mr(struct rpcrdma_mr *mr)
        fmr_op_release_mr(mr);
 }
 
+/* On success, sets:
+ *     ep->rep_attr.cap.max_send_wr
+ *     ep->rep_attr.cap.max_recv_wr
+ *     cdata->max_requests
+ *     ia->ri_max_segs
+ */
 static int
 fmr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
            struct rpcrdma_create_data_internal *cdata)
 {
+       int max_qp_wr;
+
+       max_qp_wr = ia->ri_device->attrs.max_qp_wr;
+       max_qp_wr -= RPCRDMA_BACKWARD_WRS;
+       max_qp_wr -= 1;
+       if (max_qp_wr < RPCRDMA_MIN_SLOT_TABLE)
+               return -ENOMEM;
+       if (cdata->max_requests > max_qp_wr)
+               cdata->max_requests = max_qp_wr;
+       ep->rep_attr.cap.max_send_wr = cdata->max_requests;
+       ep->rep_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS;
+       ep->rep_attr.cap.max_send_wr += 1; /* for ib_drain_sq */
+       ep->rep_attr.cap.max_recv_wr = cdata->max_requests;
+       ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS;
+       ep->rep_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */
+
        ia->ri_max_segs = max_t(unsigned int, 1, RPCRDMA_MAX_DATA_SEGS /
                                RPCRDMA_MAX_FMR_SGES);
        return 0;
@@ -219,6 +244,7 @@ fmr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
                                     mr->mr_sg, i, mr->mr_dir);
        if (!mr->mr_nents)
                goto out_dmamap_err;
+       trace_xprtrdma_dma_map(mr);
 
        for (i = 0, dma_pages = mr->fmr.fm_physaddrs; i < mr->mr_nents; i++)
                dma_pages[i] = sg_dma_address(&mr->mr_sg[i]);
index c59c5c788db0e8478ef06a7d7615dd2e813ef395..c040de196e13a0b2fb7d71478500a34f3fcd6169 100644 (file)
  */
 
 #include <linux/sunrpc/rpc_rdma.h>
+#include <linux/sunrpc/svc_rdma.h>
 
 #include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
 
 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
 # define RPCDBG_FACILITY       RPCDBG_TRANS
@@ -202,12 +204,22 @@ frwr_op_recover_mr(struct rpcrdma_mr *mr)
        frwr_op_release_mr(mr);
 }
 
+/* On success, sets:
+ *     ep->rep_attr.cap.max_send_wr
+ *     ep->rep_attr.cap.max_recv_wr
+ *     cdata->max_requests
+ *     ia->ri_max_segs
+ *
+ * And these FRWR-related fields:
+ *     ia->ri_max_frwr_depth
+ *     ia->ri_mrtype
+ */
 static int
 frwr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
             struct rpcrdma_create_data_internal *cdata)
 {
        struct ib_device_attr *attrs = &ia->ri_device->attrs;
-       int depth, delta;
+       int max_qp_wr, depth, delta;
 
        ia->ri_mrtype = IB_MR_TYPE_MEM_REG;
        if (attrs->device_cap_flags & IB_DEVICE_SG_GAPS_REG)
@@ -241,14 +253,26 @@ frwr_op_open(struct rpcrdma_ia *ia, struct rpcrdma_ep *ep,
                } while (delta > 0);
        }
 
-       ep->rep_attr.cap.max_send_wr *= depth;
-       if (ep->rep_attr.cap.max_send_wr > attrs->max_qp_wr) {
-               cdata->max_requests = attrs->max_qp_wr / depth;
+       max_qp_wr = ia->ri_device->attrs.max_qp_wr;
+       max_qp_wr -= RPCRDMA_BACKWARD_WRS;
+       max_qp_wr -= 1;
+       if (max_qp_wr < RPCRDMA_MIN_SLOT_TABLE)
+               return -ENOMEM;
+       if (cdata->max_requests > max_qp_wr)
+               cdata->max_requests = max_qp_wr;
+       ep->rep_attr.cap.max_send_wr = cdata->max_requests * depth;
+       if (ep->rep_attr.cap.max_send_wr > max_qp_wr) {
+               cdata->max_requests = max_qp_wr / depth;
                if (!cdata->max_requests)
                        return -EINVAL;
                ep->rep_attr.cap.max_send_wr = cdata->max_requests *
                                               depth;
        }
+       ep->rep_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS;
+       ep->rep_attr.cap.max_send_wr += 1; /* for ib_drain_sq */
+       ep->rep_attr.cap.max_recv_wr = cdata->max_requests;
+       ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS;
+       ep->rep_attr.cap.max_recv_wr += 1; /* for ib_drain_rq */
 
        ia->ri_max_segs = max_t(unsigned int, 1, RPCRDMA_MAX_DATA_SEGS /
                                ia->ri_max_frwr_depth);
@@ -393,6 +417,7 @@ frwr_op_map(struct rpcrdma_xprt *r_xprt, struct rpcrdma_mr_seg *seg,
        mr->mr_nents = ib_dma_map_sg(ia->ri_device, mr->mr_sg, i, mr->mr_dir);
        if (!mr->mr_nents)
                goto out_dmamap_err;
+       trace_xprtrdma_dma_map(mr);
 
        ibmr = frwr->fr_mr;
        n = ib_map_mr_sg(ibmr, mr->mr_sg, mr->mr_nents, NULL, PAGE_SIZE);
index a762d192372b0a91d1768cb7af5ac779f336da12..620327c01302ce8702062bd48f7545f9882cea24 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
  * Copyright (c) 2015, 2017 Oracle.  All rights reserved.
  */
 
 #include <asm/swab.h>
 
-#define CREATE_TRACE_POINTS
 #include "xprt_rdma.h"
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/rpcrdma.h>
+
 MODULE_AUTHOR("Open Grid Computing and Network Appliance, Inc.");
 MODULE_DESCRIPTION("RPC/RDMA Transport");
 MODULE_LICENSE("Dual BSD/GPL");
index e8adad33d0bb71671625c4da2b29ca05d8ce7b2a..c8ae983c6cc017ae342ac71604625e25bb7fe777 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
  * Copyright (c) 2014-2017 Oracle.  All rights reserved.
  * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
  * to the Linux RPC framework lives.
  */
 
-#include "xprt_rdma.h"
-
 #include <linux/highmem.h>
 
+#include <linux/sunrpc/svc_rdma.h>
+
+#include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
+
 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
 # define RPCDBG_FACILITY       RPCDBG_TRANS
 #endif
 
-static const char transfertypes[][12] = {
-       "inline",       /* no chunks */
-       "read list",    /* some argument via rdma read */
-       "*read list",   /* entire request via rdma read */
-       "write list",   /* some result via rdma write */
-       "reply chunk"   /* entire reply via rdma write */
-};
-
 /* Returns size of largest RPC-over-RDMA header in a Call message
  *
  * The largest Call header contains a full-size Read list and a
@@ -230,7 +226,7 @@ rpcrdma_convert_iovs(struct rpcrdma_xprt *r_xprt, struct xdr_buf *xdrbuf,
                         */
                        *ppages = alloc_page(GFP_ATOMIC);
                        if (!*ppages)
-                               return -EAGAIN;
+                               return -ENOBUFS;
                }
                seg->mr_page = *ppages;
                seg->mr_offset = (char *)page_base;
@@ -365,7 +361,7 @@ rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
                seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs,
                                                   false, &mr);
                if (IS_ERR(seg))
-                       goto out_maperr;
+                       return PTR_ERR(seg);
                rpcrdma_mr_push(mr, &req->rl_registered);
 
                if (encode_read_segment(xdr, mr, pos) < 0)
@@ -377,11 +373,6 @@ rpcrdma_encode_read_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
        } while (nsegs);
 
        return 0;
-
-out_maperr:
-       if (PTR_ERR(seg) == -EAGAIN)
-               xprt_wait_for_buffer_space(rqst->rq_task, NULL);
-       return PTR_ERR(seg);
 }
 
 /* Register and XDR encode the Write list. Supports encoding a list
@@ -428,7 +419,7 @@ rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
                seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs,
                                                   true, &mr);
                if (IS_ERR(seg))
-                       goto out_maperr;
+                       return PTR_ERR(seg);
                rpcrdma_mr_push(mr, &req->rl_registered);
 
                if (encode_rdma_segment(xdr, mr) < 0)
@@ -445,11 +436,6 @@ rpcrdma_encode_write_list(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
        *segcount = cpu_to_be32(nchunks);
 
        return 0;
-
-out_maperr:
-       if (PTR_ERR(seg) == -EAGAIN)
-               xprt_wait_for_buffer_space(rqst->rq_task, NULL);
-       return PTR_ERR(seg);
 }
 
 /* Register and XDR encode the Reply chunk. Supports encoding an array
@@ -491,7 +477,7 @@ rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
                seg = r_xprt->rx_ia.ri_ops->ro_map(r_xprt, seg, nsegs,
                                                   true, &mr);
                if (IS_ERR(seg))
-                       goto out_maperr;
+                       return PTR_ERR(seg);
                rpcrdma_mr_push(mr, &req->rl_registered);
 
                if (encode_rdma_segment(xdr, mr) < 0)
@@ -508,11 +494,6 @@ rpcrdma_encode_reply_chunk(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
        *segcount = cpu_to_be32(nchunks);
 
        return 0;
-
-out_maperr:
-       if (PTR_ERR(seg) == -EAGAIN)
-               xprt_wait_for_buffer_space(rqst->rq_task, NULL);
-       return PTR_ERR(seg);
 }
 
 /**
@@ -709,7 +690,7 @@ rpcrdma_prepare_send_sges(struct rpcrdma_xprt *r_xprt,
 {
        req->rl_sendctx = rpcrdma_sendctx_get_locked(&r_xprt->rx_buf);
        if (!req->rl_sendctx)
-               return -ENOBUFS;
+               return -EAGAIN;
        req->rl_sendctx->sc_wr.num_sge = 0;
        req->rl_sendctx->sc_unmap_count = 0;
        req->rl_sendctx->sc_req = req;
@@ -883,7 +864,15 @@ rpcrdma_marshal_req(struct rpcrdma_xprt *r_xprt, struct rpc_rqst *rqst)
        return 0;
 
 out_err:
-       r_xprt->rx_stats.failed_marshal_count++;
+       switch (ret) {
+       case -EAGAIN:
+               xprt_wait_for_buffer_space(rqst->rq_task, NULL);
+               break;
+       case -ENOBUFS:
+               break;
+       default:
+               r_xprt->rx_stats.failed_marshal_count++;
+       }
        return ret;
 }
 
@@ -1026,8 +1015,6 @@ rpcrdma_is_bcall(struct rpcrdma_xprt *r_xprt, struct rpcrdma_rep *rep)
 
 out_short:
        pr_warn("RPC/RDMA short backward direction call\n");
-       if (rpcrdma_ep_post_recv(&r_xprt->rx_ia, rep))
-               xprt_disconnect_done(&r_xprt->rx_xprt);
        return true;
 }
 #else  /* CONFIG_SUNRPC_BACKCHANNEL */
@@ -1333,13 +1320,14 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep)
        u32 credits;
        __be32 *p;
 
+       --buf->rb_posted_receives;
+
        if (rep->rr_hdrbuf.head[0].iov_len == 0)
                goto out_badstatus;
 
+       /* Fixed transport header fields */
        xdr_init_decode(&rep->rr_stream, &rep->rr_hdrbuf,
                        rep->rr_hdrbuf.head[0].iov_base);
-
-       /* Fixed transport header fields */
        p = xdr_inline_decode(&rep->rr_stream, 4 * sizeof(*p));
        if (unlikely(!p))
                goto out_shortreply;
@@ -1378,17 +1366,10 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep)
 
        trace_xprtrdma_reply(rqst->rq_task, rep, req, credits);
 
+       rpcrdma_post_recvs(r_xprt, false);
        queue_work(rpcrdma_receive_wq, &rep->rr_work);
        return;
 
-out_badstatus:
-       rpcrdma_recv_buffer_put(rep);
-       if (r_xprt->rx_ep.rep_connected == 1) {
-               r_xprt->rx_ep.rep_connected = -EIO;
-               rpcrdma_conn_func(&r_xprt->rx_ep);
-       }
-       return;
-
 out_badversion:
        trace_xprtrdma_reply_vers(rep);
        goto repost;
@@ -1408,7 +1389,7 @@ void rpcrdma_reply_handler(struct rpcrdma_rep *rep)
  * receive buffer before returning.
  */
 repost:
-       r_xprt->rx_stats.bad_reply_count++;
-       if (rpcrdma_ep_post_recv(&r_xprt->rx_ia, rep))
-               rpcrdma_recv_buffer_put(rep);
+       rpcrdma_post_recvs(r_xprt, false);
+out_badstatus:
+       rpcrdma_recv_buffer_put(rep);
 }
index dd8a431dc2ae155304a9b3bd3aa8d1132b9dccc7..357ba90c382d5d6e44efe28d7b7971dca0ffc211 100644 (file)
@@ -1,4 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
+ * Copyright (c) 2015-2018 Oracle.  All rights reserved.
  * Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
  *
  * This software is available to you under a choice of one of two
@@ -46,7 +48,6 @@
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/sched.h>
 #include <linux/sunrpc/svc_rdma.h>
-#include "xprt_rdma.h"
 
 #define RPCDBG_FACILITY        RPCDBG_SVCXPRT
 
index a73632ca9048228a6aa29b7f182a3ddd71049e79..a68180090554f2f40ebb9ed5cd72a70cd9639541 100644 (file)
@@ -1,13 +1,16 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2015 Oracle.  All rights reserved.
+ * Copyright (c) 2015-2018 Oracle.  All rights reserved.
  *
  * Support for backward direction RPCs on RPC/RDMA (server-side).
  */
 
 #include <linux/module.h>
+
 #include <linux/sunrpc/svc_rdma.h>
+
 #include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
 
 #define RPCDBG_FACILITY        RPCDBG_SVCXPRT
 
@@ -112,39 +115,21 @@ int svc_rdma_handle_bc_reply(struct rpc_xprt *xprt, __be32 *rdma_resp,
  * the adapter has a small maximum SQ depth.
  */
 static int svc_rdma_bc_sendto(struct svcxprt_rdma *rdma,
-                             struct rpc_rqst *rqst)
+                             struct rpc_rqst *rqst,
+                             struct svc_rdma_send_ctxt *ctxt)
 {
-       struct svc_rdma_op_ctxt *ctxt;
        int ret;
 
-       ctxt = svc_rdma_get_context(rdma);
-
-       /* rpcrdma_bc_send_request builds the transport header and
-        * the backchannel RPC message in the same buffer. Thus only
-        * one SGE is needed to send both.
-        */
-       ret = svc_rdma_map_reply_hdr(rdma, ctxt, rqst->rq_buffer,
-                                    rqst->rq_snd_buf.len);
+       ret = svc_rdma_map_reply_msg(rdma, ctxt, &rqst->rq_snd_buf, NULL);
        if (ret < 0)
-               goto out_err;
+               return -EIO;
 
        /* Bump page refcnt so Send completion doesn't release
         * the rq_buffer before all retransmits are complete.
         */
        get_page(virt_to_page(rqst->rq_buffer));
-       ret = svc_rdma_post_send_wr(rdma, ctxt, 1, 0);
-       if (ret)
-               goto out_unmap;
-
-out_err:
-       dprintk("svcrdma: %s returns %d\n", __func__, ret);
-       return ret;
-
-out_unmap:
-       svc_rdma_unmap_dma(ctxt);
-       svc_rdma_put_context(ctxt, 1);
-       ret = -EIO;
-       goto out_err;
+       ctxt->sc_send_wr.opcode = IB_WR_SEND;
+       return svc_rdma_send(rdma, &ctxt->sc_send_wr);
 }
 
 /* Server-side transport endpoint wants a whole page for its send
@@ -191,13 +176,15 @@ rpcrdma_bc_send_request(struct svcxprt_rdma *rdma, struct rpc_rqst *rqst)
 {
        struct rpc_xprt *xprt = rqst->rq_xprt;
        struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
+       struct svc_rdma_send_ctxt *ctxt;
        __be32 *p;
        int rc;
 
-       /* Space in the send buffer for an RPC/RDMA header is reserved
-        * via xprt->tsh_size.
-        */
-       p = rqst->rq_buffer;
+       ctxt = svc_rdma_send_ctxt_get(rdma);
+       if (!ctxt)
+               goto drop_connection;
+
+       p = ctxt->sc_xprt_buf;
        *p++ = rqst->rq_xid;
        *p++ = rpcrdma_version;
        *p++ = cpu_to_be32(r_xprt->rx_buf.rb_bc_max_requests);
@@ -205,14 +192,17 @@ rpcrdma_bc_send_request(struct svcxprt_rdma *rdma, struct rpc_rqst *rqst)
        *p++ = xdr_zero;
        *p++ = xdr_zero;
        *p   = xdr_zero;
+       svc_rdma_sync_reply_hdr(rdma, ctxt, RPCRDMA_HDRLEN_MIN);
 
 #ifdef SVCRDMA_BACKCHANNEL_DEBUG
        pr_info("%s: %*ph\n", __func__, 64, rqst->rq_buffer);
 #endif
 
-       rc = svc_rdma_bc_sendto(rdma, rqst);
-       if (rc)
+       rc = svc_rdma_bc_sendto(rdma, rqst, ctxt);
+       if (rc) {
+               svc_rdma_send_ctxt_put(rdma, ctxt);
                goto drop_connection;
+       }
        return rc;
 
 drop_connection:
@@ -273,6 +263,7 @@ static const struct rpc_xprt_ops xprt_rdma_bc_procs = {
        .reserve_xprt           = xprt_reserve_xprt_cong,
        .release_xprt           = xprt_release_xprt_cong,
        .alloc_slot             = xprt_alloc_slot,
+       .free_slot              = xprt_free_slot,
        .release_request        = xprt_release_rqst_cong,
        .buf_alloc              = xprt_rdma_bc_allocate,
        .buf_free               = xprt_rdma_bc_free,
@@ -320,7 +311,7 @@ xprt_setup_rdma_bc(struct xprt_create *args)
        xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO;
 
        xprt->prot = XPRT_TRANSPORT_BC_RDMA;
-       xprt->tsh_size = RPCRDMA_HDRLEN_MIN / sizeof(__be32);
+       xprt->tsh_size = 0;
        xprt->ops = &xprt_rdma_bc_procs;
 
        memcpy(&xprt->addr, args->dstaddr, args->addrlen);
index 3d45015dca97420e4a9734d258db2958bb0838e2..841fca143804fd4ef86cfe05454935e8efda4cfc 100644 (file)
@@ -1,5 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (c) 2016, 2017 Oracle. All rights reserved.
+ * Copyright (c) 2016-2018 Oracle. All rights reserved.
  * Copyright (c) 2014 Open Grid Computing, Inc. All rights reserved.
  * Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
  *
@@ -60,7 +61,7 @@
  * svc_rdma_recvfrom must post RDMA Reads to pull the RPC Call's
  * data payload from the client. svc_rdma_recvfrom sets up the
  * RDMA Reads using pages in svc_rqst::rq_pages, which are
- * transferred to an svc_rdma_op_ctxt for the duration of the
+ * transferred to an svc_rdma_recv_ctxt for the duration of the
  * I/O. svc_rdma_recvfrom then returns zero, since the RPC message
  * is still not yet ready.
  *
  * svc_rdma_recvfrom again. This second call may use a different
  * svc_rqst than the first one, thus any information that needs
  * to be preserved across these two calls is kept in an
- * svc_rdma_op_ctxt.
+ * svc_rdma_recv_ctxt.
  *
  * The second call to svc_rdma_recvfrom performs final assembly
  * of the RPC Call message, using the RDMA Read sink pages kept in
- * the svc_rdma_op_ctxt. The xdr_buf is copied from the
- * svc_rdma_op_ctxt to the second svc_rqst. The second call returns
+ * the svc_rdma_recv_ctxt. The xdr_buf is copied from the
+ * svc_rdma_recv_ctxt to the second svc_rqst. The second call returns
  * the length of the completed RPC Call message.
  *
  * Page Management
  *
  * Pages under I/O must be transferred from the first svc_rqst to an
- * svc_rdma_op_ctxt before the first svc_rdma_recvfrom call returns.
+ * svc_rdma_recv_ctxt before the first svc_rdma_recvfrom call returns.
  *
  * The first svc_rqst supplies pages for RDMA Reads. These are moved
  * from rqstp::rq_pages into ctxt::pages. The consumed elements of
  * svc_rdma_recvfrom call returns.
  *
  * During the second svc_rdma_recvfrom call, RDMA Read sink pages
- * are transferred from the svc_rdma_op_ctxt to the second svc_rqst
+ * are transferred from the svc_rdma_recv_ctxt to the second svc_rqst
  * (see rdma_read_complete() below).
  */
 
+#include <linux/spinlock.h>
 #include <asm/unaligned.h>
 #include <rdma/ib_verbs.h>
 #include <rdma/rdma_cm.h>
 
-#include <linux/spinlock.h>
-
 #include <linux/sunrpc/xdr.h>
 #include <linux/sunrpc/debug.h>
 #include <linux/sunrpc/rpc_rdma.h>
 #include <linux/sunrpc/svc_rdma.h>
 
+#include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
+
 #define RPCDBG_FACILITY        RPCDBG_SVCXPRT
 
-/*
- * Replace the pages in the rq_argpages array with the pages from the SGE in
- * the RDMA_RECV completion. The SGL should contain full pages up until the
- * last one.
+static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc);
+
+static inline struct svc_rdma_recv_ctxt *
+svc_rdma_next_recv_ctxt(struct list_head *list)
+{
+       return list_first_entry_or_null(list, struct svc_rdma_recv_ctxt,
+                                       rc_list);
+}
+
+static struct svc_rdma_recv_ctxt *
+svc_rdma_recv_ctxt_alloc(struct svcxprt_rdma *rdma)
+{
+       struct svc_rdma_recv_ctxt *ctxt;
+       dma_addr_t addr;
+       void *buffer;
+
+       ctxt = kmalloc(sizeof(*ctxt), GFP_KERNEL);
+       if (!ctxt)
+               goto fail0;
+       buffer = kmalloc(rdma->sc_max_req_size, GFP_KERNEL);
+       if (!buffer)
+               goto fail1;
+       addr = ib_dma_map_single(rdma->sc_pd->device, buffer,
+                                rdma->sc_max_req_size, DMA_FROM_DEVICE);
+       if (ib_dma_mapping_error(rdma->sc_pd->device, addr))
+               goto fail2;
+
+       ctxt->rc_recv_wr.next = NULL;
+       ctxt->rc_recv_wr.wr_cqe = &ctxt->rc_cqe;
+       ctxt->rc_recv_wr.sg_list = &ctxt->rc_recv_sge;
+       ctxt->rc_recv_wr.num_sge = 1;
+       ctxt->rc_cqe.done = svc_rdma_wc_receive;
+       ctxt->rc_recv_sge.addr = addr;
+       ctxt->rc_recv_sge.length = rdma->sc_max_req_size;
+       ctxt->rc_recv_sge.lkey = rdma->sc_pd->local_dma_lkey;
+       ctxt->rc_recv_buf = buffer;
+       ctxt->rc_temp = false;
+       return ctxt;
+
+fail2:
+       kfree(buffer);
+fail1:
+       kfree(ctxt);
+fail0:
+       return NULL;
+}
+
+static void svc_rdma_recv_ctxt_destroy(struct svcxprt_rdma *rdma,
+                                      struct svc_rdma_recv_ctxt *ctxt)
+{
+       ib_dma_unmap_single(rdma->sc_pd->device, ctxt->rc_recv_sge.addr,
+                           ctxt->rc_recv_sge.length, DMA_FROM_DEVICE);
+       kfree(ctxt->rc_recv_buf);
+       kfree(ctxt);
+}
+
+/**
+ * svc_rdma_recv_ctxts_destroy - Release all recv_ctxt's for an xprt
+ * @rdma: svcxprt_rdma being torn down
+ *
  */
-static void svc_rdma_build_arg_xdr(struct svc_rqst *rqstp,
-                                  struct svc_rdma_op_ctxt *ctxt)
+void svc_rdma_recv_ctxts_destroy(struct svcxprt_rdma *rdma)
 {
-       struct page *page;
-       int sge_no;
-       u32 len;
+       struct svc_rdma_recv_ctxt *ctxt;
 
-       /* The reply path assumes the Call's transport header resides
-        * in rqstp->rq_pages[0].
-        */
-       page = ctxt->pages[0];
-       put_page(rqstp->rq_pages[0]);
-       rqstp->rq_pages[0] = page;
-
-       /* Set up the XDR head */
-       rqstp->rq_arg.head[0].iov_base = page_address(page);
-       rqstp->rq_arg.head[0].iov_len =
-               min_t(size_t, ctxt->byte_len, ctxt->sge[0].length);
-       rqstp->rq_arg.len = ctxt->byte_len;
-       rqstp->rq_arg.buflen = ctxt->byte_len;
-
-       /* Compute bytes past head in the SGL */
-       len = ctxt->byte_len - rqstp->rq_arg.head[0].iov_len;
-
-       /* If data remains, store it in the pagelist */
-       rqstp->rq_arg.page_len = len;
-       rqstp->rq_arg.page_base = 0;
-
-       sge_no = 1;
-       while (len && sge_no < ctxt->count) {
-               page = ctxt->pages[sge_no];
-               put_page(rqstp->rq_pages[sge_no]);
-               rqstp->rq_pages[sge_no] = page;
-               len -= min_t(u32, len, ctxt->sge[sge_no].length);
-               sge_no++;
+       while ((ctxt = svc_rdma_next_recv_ctxt(&rdma->sc_recv_ctxts))) {
+               list_del(&ctxt->rc_list);
+               svc_rdma_recv_ctxt_destroy(rdma, ctxt);
        }
-       rqstp->rq_respages = &rqstp->rq_pages[sge_no];
-       rqstp->rq_next_page = rqstp->rq_respages + 1;
+}
+
+static struct svc_rdma_recv_ctxt *
+svc_rdma_recv_ctxt_get(struct svcxprt_rdma *rdma)
+{
+       struct svc_rdma_recv_ctxt *ctxt;
+
+       spin_lock(&rdma->sc_recv_lock);
+       ctxt = svc_rdma_next_recv_ctxt(&rdma->sc_recv_ctxts);
+       if (!ctxt)
+               goto out_empty;
+       list_del(&ctxt->rc_list);
+       spin_unlock(&rdma->sc_recv_lock);
+
+out:
+       ctxt->rc_page_count = 0;
+       return ctxt;
+
+out_empty:
+       spin_unlock(&rdma->sc_recv_lock);
+
+       ctxt = svc_rdma_recv_ctxt_alloc(rdma);
+       if (!ctxt)
+               return NULL;
+       goto out;
+}
+
+/**
+ * svc_rdma_recv_ctxt_put - Return recv_ctxt to free list
+ * @rdma: controlling svcxprt_rdma
+ * @ctxt: object to return to the free list
+ *
+ */
+void svc_rdma_recv_ctxt_put(struct svcxprt_rdma *rdma,
+                           struct svc_rdma_recv_ctxt *ctxt)
+{
+       unsigned int i;
+
+       for (i = 0; i < ctxt->rc_page_count; i++)
+               put_page(ctxt->rc_pages[i]);
+
+       if (!ctxt->rc_temp) {
+               spin_lock(&rdma->sc_recv_lock);
+               list_add(&ctxt->rc_list, &rdma->sc_recv_ctxts);
+               spin_unlock(&rdma->sc_recv_lock);
+       } else
+               svc_rdma_recv_ctxt_destroy(rdma, ctxt);
+}
+
+static int __svc_rdma_post_recv(struct svcxprt_rdma *rdma,
+                               struct svc_rdma_recv_ctxt *ctxt)
+{
+       struct ib_recv_wr *bad_recv_wr;
+       int ret;
+
+       svc_xprt_get(&rdma->sc_xprt);
+       ret = ib_post_recv(rdma->sc_qp, &ctxt->rc_recv_wr, &bad_recv_wr);
+       trace_svcrdma_post_recv(&ctxt->rc_recv_wr, ret);
+       if (ret)
+               goto err_post;
+       return 0;
+
+err_post:
+       svc_rdma_recv_ctxt_put(rdma, ctxt);
+       svc_xprt_put(&rdma->sc_xprt);
+       return ret;
+}
 
-       /* If not all pages were used from the SGL, free the remaining ones */
-       len = sge_no;
-       while (sge_no < ctxt->count) {
-               page = ctxt->pages[sge_no++];
-               put_page(page);
+static int svc_rdma_post_recv(struct svcxprt_rdma *rdma)
+{
+       struct svc_rdma_recv_ctxt *ctxt;
+
+       ctxt = svc_rdma_recv_ctxt_get(rdma);
+       if (!ctxt)
+               return -ENOMEM;
+       return __svc_rdma_post_recv(rdma, ctxt);
+}
+
+/**
+ * svc_rdma_post_recvs - Post initial set of Recv WRs
+ * @rdma: fresh svcxprt_rdma
+ *
+ * Returns true if successful, otherwise false.
+ */
+bool svc_rdma_post_recvs(struct svcxprt_rdma *rdma)
+{
+       struct svc_rdma_recv_ctxt *ctxt;
+       unsigned int i;
+       int ret;
+
+       for (i = 0; i < rdma->sc_max_requests; i++) {
+               ctxt = svc_rdma_recv_ctxt_get(rdma);
+               if (!ctxt)
+                       return false;
+               ctxt->rc_temp = true;
+               ret = __svc_rdma_post_recv(rdma, ctxt);
+               if (ret) {
+                       pr_err("svcrdma: failure posting recv buffers: %d\n",
+                              ret);
+                       return false;
+               }
        }
-       ctxt->count = len;
+       return true;
+}
 
-       /* Set up tail */
-       rqstp->rq_arg.tail[0].iov_base = NULL;
-       rqstp->rq_arg.tail[0].iov_len = 0;
+/**
+ * svc_rdma_wc_receive - Invoked by RDMA provider for each polled Receive WC
+ * @cq: Completion Queue context
+ * @wc: Work Completion object
+ *
+ * NB: The svc_xprt/svcxprt_rdma is pinned whenever it's possible that
+ * the Receive completion handler could be running.
+ */
+static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
+{
+       struct svcxprt_rdma *rdma = cq->cq_context;
+       struct ib_cqe *cqe = wc->wr_cqe;
+       struct svc_rdma_recv_ctxt *ctxt;
+
+       trace_svcrdma_wc_receive(wc);
+
+       /* WARNING: Only wc->wr_cqe and wc->status are reliable */
+       ctxt = container_of(cqe, struct svc_rdma_recv_ctxt, rc_cqe);
+
+       if (wc->status != IB_WC_SUCCESS)
+               goto flushed;
+
+       if (svc_rdma_post_recv(rdma))
+               goto post_err;
+
+       /* All wc fields are now known to be valid */
+       ctxt->rc_byte_len = wc->byte_len;
+       ib_dma_sync_single_for_cpu(rdma->sc_pd->device,
+                                  ctxt->rc_recv_sge.addr,
+                                  wc->byte_len, DMA_FROM_DEVICE);
+
+       spin_lock(&rdma->sc_rq_dto_lock);
+       list_add_tail(&ctxt->rc_list, &rdma->sc_rq_dto_q);
+       spin_unlock(&rdma->sc_rq_dto_lock);
+       set_bit(XPT_DATA, &rdma->sc_xprt.xpt_flags);
+       if (!test_bit(RDMAXPRT_CONN_PENDING, &rdma->sc_flags))
+               svc_xprt_enqueue(&rdma->sc_xprt);
+       goto out;
+
+flushed:
+       if (wc->status != IB_WC_WR_FLUSH_ERR)
+               pr_err("svcrdma: Recv: %s (%u/0x%x)\n",
+                      ib_wc_status_msg(wc->status),
+                      wc->status, wc->vendor_err);
+post_err:
+       svc_rdma_recv_ctxt_put(rdma, ctxt);
+       set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags);
+       svc_xprt_enqueue(&rdma->sc_xprt);
+out:
+       svc_xprt_put(&rdma->sc_xprt);
+}
+
+/**
+ * svc_rdma_flush_recv_queues - Drain pending Receive work
+ * @rdma: svcxprt_rdma being shut down
+ *
+ */
+void svc_rdma_flush_recv_queues(struct svcxprt_rdma *rdma)
+{
+       struct svc_rdma_recv_ctxt *ctxt;
+
+       while ((ctxt = svc_rdma_next_recv_ctxt(&rdma->sc_read_complete_q))) {
+               list_del(&ctxt->rc_list);
+               svc_rdma_recv_ctxt_put(rdma, ctxt);
+       }
+       while ((ctxt = svc_rdma_next_recv_ctxt(&rdma->sc_rq_dto_q))) {
+               list_del(&ctxt->rc_list);
+               svc_rdma_recv_ctxt_put(rdma, ctxt);
+       }
+}
+
+static void svc_rdma_build_arg_xdr(struct svc_rqst *rqstp,
+                                  struct svc_rdma_recv_ctxt *ctxt)
+{
+       struct xdr_buf *arg = &rqstp->rq_arg;
+
+       arg->head[0].iov_base = ctxt->rc_recv_buf;
+       arg->head[0].iov_len = ctxt->rc_byte_len;
+       arg->tail[0].iov_base = NULL;
+       arg->tail[0].iov_len = 0;
+       arg->page_len = 0;
+       arg->page_base = 0;
+       arg->buflen = ctxt->rc_byte_len;
+       arg->len = ctxt->rc_byte_len;
+
+       rqstp->rq_respages = &rqstp->rq_pages[0];
+       rqstp->rq_next_page = rqstp->rq_respages + 1;
 }
 
 /* This accommodates the largest possible Write chunk,
@@ -294,7 +503,6 @@ static int svc_rdma_xdr_decode_req(struct xdr_buf *rq_arg)
 {
        __be32 *p, *end, *rdma_argp;
        unsigned int hdr_len;
-       char *proc;
 
        /* Verify that there's enough bytes for header + something */
        if (rq_arg->len <= RPCRDMA_HDRLEN_ERR)
@@ -306,10 +514,8 @@ static int svc_rdma_xdr_decode_req(struct xdr_buf *rq_arg)
 
        switch (*(rdma_argp + 3)) {
        case rdma_msg:
-               proc = "RDMA_MSG";
                break;
        case rdma_nomsg:
-               proc = "RDMA_NOMSG";
                break;
 
        case rdma_done:
@@ -339,103 +545,94 @@ static int svc_rdma_xdr_decode_req(struct xdr_buf *rq_arg)
        hdr_len = (unsigned long)p - (unsigned long)rdma_argp;
        rq_arg->head[0].iov_len -= hdr_len;
        rq_arg->len -= hdr_len;
-       dprintk("svcrdma: received %s request for XID 0x%08x, hdr_len=%u\n",
-               proc, be32_to_cpup(rdma_argp), hdr_len);
+       trace_svcrdma_decode_rqst(rdma_argp, hdr_len);
        return hdr_len;
 
 out_short:
-       dprintk("svcrdma: header too short = %d\n", rq_arg->len);
+       trace_svcrdma_decode_short(rq_arg->len);
        return -EINVAL;
 
 out_version:
-       dprintk("svcrdma: bad xprt version: %u\n",
-               be32_to_cpup(rdma_argp + 1));
+       trace_svcrdma_decode_badvers(rdma_argp);
        return -EPROTONOSUPPORT;
 
 out_drop:
-       dprintk("svcrdma: dropping RDMA_DONE/ERROR message\n");
+       trace_svcrdma_decode_drop(rdma_argp);
        return 0;
 
 out_proc:
-       dprintk("svcrdma: bad rdma procedure (%u)\n",
-               be32_to_cpup(rdma_argp + 3));
+       trace_svcrdma_decode_badproc(rdma_argp);
        return -EINVAL;
 
 out_inval:
-       dprintk("svcrdma: failed to parse transport header\n");
+       trace_svcrdma_decode_parse(rdma_argp);
        return -EINVAL;
 }
 
 static void rdma_read_complete(struct svc_rqst *rqstp,
-                              struct svc_rdma_op_ctxt *head)
+                              struct svc_rdma_recv_ctxt *head)
 {
        int page_no;
 
-       /* Copy RPC pages */
-       for (page_no = 0; page_no < head->count; page_no++) {
+       /* Move Read chunk pages to rqstp so that they will be released
+        * when svc_process is done with them.
+        */
+       for (page_no = 0; page_no < head->rc_page_count; page_no++) {
                put_page(rqstp->rq_pages[page_no]);
-               rqstp->rq_pages[page_no] = head->pages[page_no];
+               rqstp->rq_pages[page_no] = head->rc_pages[page_no];
        }
+       head->rc_page_count = 0;
 
        /* Point rq_arg.pages past header */
-       rqstp->rq_arg.pages = &rqstp->rq_pages[head->hdr_count];
-       rqstp->rq_arg.page_len = head->arg.page_len;
+       rqstp->rq_arg.pages = &rqstp->rq_pages[head->rc_hdr_count];
+       rqstp->rq_arg.page_len = head->rc_arg.page_len;
 
        /* rq_respages starts after the last arg page */
        rqstp->rq_respages = &rqstp->rq_pages[page_no];
        rqstp->rq_next_page = rqstp->rq_respages + 1;
 
        /* Rebuild rq_arg head and tail. */
-       rqstp->rq_arg.head[0] = head->arg.head[0];
-       rqstp->rq_arg.tail[0] = head->arg.tail[0];
-       rqstp->rq_arg.len = head->arg.len;
-       rqstp->rq_arg.buflen = head->arg.buflen;
+       rqstp->rq_arg.head[0] = head->rc_arg.head[0];
+       rqstp->rq_arg.tail[0] = head->rc_arg.tail[0];
+       rqstp->rq_arg.len = head->rc_arg.len;
+       rqstp->rq_arg.buflen = head->rc_arg.buflen;
 }
 
 static void svc_rdma_send_error(struct svcxprt_rdma *xprt,
                                __be32 *rdma_argp, int status)
 {
-       struct svc_rdma_op_ctxt *ctxt;
-       __be32 *p, *err_msgp;
+       struct svc_rdma_send_ctxt *ctxt;
        unsigned int length;
-       struct page *page;
+       __be32 *p;
        int ret;
 
-       page = alloc_page(GFP_KERNEL);
-       if (!page)
+       ctxt = svc_rdma_send_ctxt_get(xprt);
+       if (!ctxt)
                return;
-       err_msgp = page_address(page);
 
-       p = err_msgp;
+       p = ctxt->sc_xprt_buf;
        *p++ = *rdma_argp;
        *p++ = *(rdma_argp + 1);
        *p++ = xprt->sc_fc_credits;
        *p++ = rdma_error;
-       if (status == -EPROTONOSUPPORT) {
+       switch (status) {
+       case -EPROTONOSUPPORT:
                *p++ = err_vers;
                *p++ = rpcrdma_version;
                *p++ = rpcrdma_version;
-       } else {
+               trace_svcrdma_err_vers(*rdma_argp);
+               break;
+       default:
                *p++ = err_chunk;
+               trace_svcrdma_err_chunk(*rdma_argp);
        }
-       length = (unsigned long)p - (unsigned long)err_msgp;
-
-       /* Map transport header; no RPC message payload */
-       ctxt = svc_rdma_get_context(xprt);
-       ret = svc_rdma_map_reply_hdr(xprt, ctxt, err_msgp, length);
-       if (ret) {
-               dprintk("svcrdma: Error %d mapping send for protocol error\n",
-                       ret);
-               return;
-       }
+       length = (unsigned long)p - (unsigned long)ctxt->sc_xprt_buf;
+       svc_rdma_sync_reply_hdr(xprt, ctxt, length);
 
-       ret = svc_rdma_post_send_wr(xprt, ctxt, 1, 0);
-       if (ret) {
-               dprintk("svcrdma: Error %d posting send for protocol error\n",
-                       ret);
-               svc_rdma_unmap_dma(ctxt);
-               svc_rdma_put_context(ctxt, 1);
-       }
+       ctxt->sc_send_wr.opcode = IB_WR_SEND;
+       ret = svc_rdma_send(xprt, &ctxt->sc_send_wr);
+       if (ret)
+               svc_rdma_send_ctxt_put(xprt, ctxt);
 }
 
 /* By convention, backchannel calls arrive via rdma_msg type
@@ -507,32 +704,28 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
        struct svc_xprt *xprt = rqstp->rq_xprt;
        struct svcxprt_rdma *rdma_xprt =
                container_of(xprt, struct svcxprt_rdma, sc_xprt);
-       struct svc_rdma_op_ctxt *ctxt;
+       struct svc_rdma_recv_ctxt *ctxt;
        __be32 *p;
        int ret;
 
        spin_lock(&rdma_xprt->sc_rq_dto_lock);
-       if (!list_empty(&rdma_xprt->sc_read_complete_q)) {
-               ctxt = list_first_entry(&rdma_xprt->sc_read_complete_q,
-                                       struct svc_rdma_op_ctxt, list);
-               list_del(&ctxt->list);
+       ctxt = svc_rdma_next_recv_ctxt(&rdma_xprt->sc_read_complete_q);
+       if (ctxt) {
+               list_del(&ctxt->rc_list);
                spin_unlock(&rdma_xprt->sc_rq_dto_lock);
                rdma_read_complete(rqstp, ctxt);
                goto complete;
-       } else if (!list_empty(&rdma_xprt->sc_rq_dto_q)) {
-               ctxt = list_first_entry(&rdma_xprt->sc_rq_dto_q,
-                                       struct svc_rdma_op_ctxt, list);
-               list_del(&ctxt->list);
-       } else {
+       }
+       ctxt = svc_rdma_next_recv_ctxt(&rdma_xprt->sc_rq_dto_q);
+       if (!ctxt) {
                /* No new incoming requests, terminate the loop */
                clear_bit(XPT_DATA, &xprt->xpt_flags);
                spin_unlock(&rdma_xprt->sc_rq_dto_lock);
                return 0;
        }
+       list_del(&ctxt->rc_list);
        spin_unlock(&rdma_xprt->sc_rq_dto_lock);
 
-       dprintk("svcrdma: recvfrom: ctxt=%p on xprt=%p, rqstp=%p\n",
-               ctxt, rdma_xprt, rqstp);
        atomic_inc(&rdma_stat_recv);
 
        svc_rdma_build_arg_xdr(rqstp, ctxt);
@@ -548,7 +741,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
        if (svc_rdma_is_backchannel_reply(xprt, p)) {
                ret = svc_rdma_handle_bc_reply(xprt->xpt_bc_xprt, p,
                                               &rqstp->rq_arg);
-               svc_rdma_put_context(ctxt, 0);
+               svc_rdma_recv_ctxt_put(rdma_xprt, ctxt);
                return ret;
        }
 
@@ -557,9 +750,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
                goto out_readchunk;
 
 complete:
-       svc_rdma_put_context(ctxt, 0);
-       dprintk("svcrdma: recvfrom: xprt=%p, rqstp=%p, rq_arg.len=%u\n",
-               rdma_xprt, rqstp, rqstp->rq_arg.len);
+       rqstp->rq_xprt_ctxt = ctxt;
        rqstp->rq_prot = IPPROTO_MAX;
        svc_xprt_copy_addrs(rqstp, xprt);
        return rqstp->rq_arg.len;
@@ -572,16 +763,16 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
 
 out_err:
        svc_rdma_send_error(rdma_xprt, p, ret);
-       svc_rdma_put_context(ctxt, 0);
+       svc_rdma_recv_ctxt_put(rdma_xprt, ctxt);
        return 0;
 
 out_postfail:
        if (ret == -EINVAL)
                svc_rdma_send_error(rdma_xprt, p, ret);
-       svc_rdma_put_context(ctxt, 1);
+       svc_rdma_recv_ctxt_put(rdma_xprt, ctxt);
        return ret;
 
 out_drop:
-       svc_rdma_put_context(ctxt, 1);
+       svc_rdma_recv_ctxt_put(rdma_xprt, ctxt);
        return 0;
 }
index 12b9a7e0b6d23a655fc8751b95a5052ab036aaee..ce3ea8419704839cc48c050a134070ac3a7a864f 100644 (file)
@@ -1,15 +1,18 @@
 // SPDX-License-Identifier: GPL-2.0
 /*
- * Copyright (c) 2016 Oracle.  All rights reserved.
+ * Copyright (c) 2016-2018 Oracle.  All rights reserved.
  *
  * Use the core R/W API to move RPC-over-RDMA Read and Write chunks.
  */
 
+#include <rdma/rw.h>
+
 #include <linux/sunrpc/rpc_rdma.h>
 #include <linux/sunrpc/svc_rdma.h>
 #include <linux/sunrpc/debug.h>
 
-#include <rdma/rw.h>
+#include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
 
 #define RPCDBG_FACILITY        RPCDBG_SVCXPRT
 
@@ -205,6 +208,8 @@ static void svc_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc)
        struct svc_rdma_write_info *info =
                        container_of(cc, struct svc_rdma_write_info, wi_cc);
 
+       trace_svcrdma_wc_write(wc);
+
        atomic_add(cc->cc_sqecount, &rdma->sc_sq_avail);
        wake_up(&rdma->sc_send_wait);
 
@@ -222,7 +227,7 @@ static void svc_rdma_write_done(struct ib_cq *cq, struct ib_wc *wc)
 /* State for pulling a Read chunk.
  */
 struct svc_rdma_read_info {
-       struct svc_rdma_op_ctxt         *ri_readctxt;
+       struct svc_rdma_recv_ctxt       *ri_readctxt;
        unsigned int                    ri_position;
        unsigned int                    ri_pageno;
        unsigned int                    ri_pageoff;
@@ -266,6 +271,8 @@ static void svc_rdma_wc_read_done(struct ib_cq *cq, struct ib_wc *wc)
        struct svc_rdma_read_info *info =
                        container_of(cc, struct svc_rdma_read_info, ri_cc);
 
+       trace_svcrdma_wc_read(wc);
+
        atomic_add(cc->cc_sqecount, &rdma->sc_sq_avail);
        wake_up(&rdma->sc_send_wait);
 
@@ -275,10 +282,10 @@ static void svc_rdma_wc_read_done(struct ib_cq *cq, struct ib_wc *wc)
                        pr_err("svcrdma: read ctx: %s (%u/0x%x)\n",
                               ib_wc_status_msg(wc->status),
                               wc->status, wc->vendor_err);
-               svc_rdma_put_context(info->ri_readctxt, 1);
+               svc_rdma_recv_ctxt_put(rdma, info->ri_readctxt);
        } else {
                spin_lock(&rdma->sc_rq_dto_lock);
-               list_add_tail(&info->ri_readctxt->list,
+               list_add_tail(&info->ri_readctxt->rc_list,
                              &rdma->sc_read_complete_q);
                spin_unlock(&rdma->sc_rq_dto_lock);
 
@@ -323,18 +330,20 @@ static int svc_rdma_post_chunk_ctxt(struct svc_rdma_chunk_ctxt *cc)
                if (atomic_sub_return(cc->cc_sqecount,
                                      &rdma->sc_sq_avail) > 0) {
                        ret = ib_post_send(rdma->sc_qp, first_wr, &bad_wr);
+                       trace_svcrdma_post_rw(&cc->cc_cqe,
+                                             cc->cc_sqecount, ret);
                        if (ret)
                                break;
                        return 0;
                }
 
-               atomic_inc(&rdma_stat_sq_starve);
+               trace_svcrdma_sq_full(rdma);
                atomic_add(cc->cc_sqecount, &rdma->sc_sq_avail);
                wait_event(rdma->sc_send_wait,
                           atomic_read(&rdma->sc_sq_avail) > cc->cc_sqecount);
+               trace_svcrdma_sq_retry(rdma);
        } while (1);
 
-       pr_err("svcrdma: ib_post_send failed (%d)\n", ret);
        set_bit(XPT_CLOSE, &xprt->xpt_flags);
 
        /* If even one was posted, there will be a completion. */
@@ -437,6 +446,7 @@ svc_rdma_build_writes(struct svc_rdma_write_info *info,
                if (ret < 0)
                        goto out_initerr;
 
+               trace_svcrdma_encode_wseg(seg_handle, write_len, seg_offset);
                list_add(&ctxt->rw_list, &cc->cc_rwctxts);
                cc->cc_sqecount += ret;
                if (write_len == seg_length - info->wi_seg_off) {
@@ -462,7 +472,7 @@ svc_rdma_build_writes(struct svc_rdma_write_info *info,
 
 out_initerr:
        svc_rdma_put_rw_ctxt(rdma, ctxt);
-       pr_err("svcrdma: failed to map pagelist (%d)\n", ret);
+       trace_svcrdma_dma_map_rwctx(rdma, ret);
        return -EIO;
 }
 
@@ -526,6 +536,8 @@ int svc_rdma_send_write_chunk(struct svcxprt_rdma *rdma, __be32 *wr_ch,
        ret = svc_rdma_post_chunk_ctxt(&info->wi_cc);
        if (ret < 0)
                goto out_err;
+
+       trace_svcrdma_encode_write(xdr->page_len);
        return xdr->page_len;
 
 out_err:
@@ -582,6 +594,8 @@ int svc_rdma_send_reply_chunk(struct svcxprt_rdma *rdma, __be32 *rp_ch,
        ret = svc_rdma_post_chunk_ctxt(&info->wi_cc);
        if (ret < 0)
                goto out_err;
+
+       trace_svcrdma_encode_reply(consumed);
        return consumed;
 
 out_err:
@@ -593,7 +607,7 @@ static int svc_rdma_build_read_segment(struct svc_rdma_read_info *info,
                                       struct svc_rqst *rqstp,
                                       u32 rkey, u32 len, u64 offset)
 {
-       struct svc_rdma_op_ctxt *head = info->ri_readctxt;
+       struct svc_rdma_recv_ctxt *head = info->ri_readctxt;
        struct svc_rdma_chunk_ctxt *cc = &info->ri_cc;
        struct svc_rdma_rw_ctxt *ctxt;
        unsigned int sge_no, seg_len;
@@ -606,18 +620,15 @@ static int svc_rdma_build_read_segment(struct svc_rdma_read_info *info,
                goto out_noctx;
        ctxt->rw_nents = sge_no;
 
-       dprintk("svcrdma: reading segment %u@0x%016llx:0x%08x (%u sges)\n",
-               len, offset, rkey, sge_no);
-
        sg = ctxt->rw_sg_table.sgl;
        for (sge_no = 0; sge_no < ctxt->rw_nents; sge_no++) {
                seg_len = min_t(unsigned int, len,
                                PAGE_SIZE - info->ri_pageoff);
 
-               head->arg.pages[info->ri_pageno] =
+               head->rc_arg.pages[info->ri_pageno] =
                        rqstp->rq_pages[info->ri_pageno];
                if (!info->ri_pageoff)
-                       head->count++;
+                       head->rc_page_count++;
 
                sg_set_page(sg, rqstp->rq_pages[info->ri_pageno],
                            seg_len, info->ri_pageoff);
@@ -656,8 +667,8 @@ static int svc_rdma_build_read_segment(struct svc_rdma_read_info *info,
        return -EINVAL;
 
 out_initerr:
+       trace_svcrdma_dma_map_rwctx(cc->cc_rdma, ret);
        svc_rdma_put_rw_ctxt(cc->cc_rdma, ctxt);
-       pr_err("svcrdma: failed to map pagelist (%d)\n", ret);
        return -EIO;
 }
 
@@ -686,6 +697,7 @@ static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
                if (ret < 0)
                        break;
 
+               trace_svcrdma_encode_rseg(rs_handle, rs_length, rs_offset);
                info->ri_chunklen += rs_length;
        }
 
@@ -693,9 +705,9 @@ static int svc_rdma_build_read_chunk(struct svc_rqst *rqstp,
 }
 
 /* Construct RDMA Reads to pull over a normal Read chunk. The chunk
- * data lands in the page list of head->arg.pages.
+ * data lands in the page list of head->rc_arg.pages.
  *
- * Currently NFSD does not look at the head->arg.tail[0] iovec.
+ * Currently NFSD does not look at the head->rc_arg.tail[0] iovec.
  * Therefore, XDR round-up of the Read chunk and trailing
  * inline content must both be added at the end of the pagelist.
  */
@@ -703,29 +715,27 @@ static int svc_rdma_build_normal_read_chunk(struct svc_rqst *rqstp,
                                            struct svc_rdma_read_info *info,
                                            __be32 *p)
 {
-       struct svc_rdma_op_ctxt *head = info->ri_readctxt;
+       struct svc_rdma_recv_ctxt *head = info->ri_readctxt;
        int ret;
 
-       dprintk("svcrdma: Reading Read chunk at position %u\n",
-               info->ri_position);
-
-       info->ri_pageno = head->hdr_count;
-       info->ri_pageoff = 0;
-
        ret = svc_rdma_build_read_chunk(rqstp, info, p);
        if (ret < 0)
                goto out;
 
+       trace_svcrdma_encode_read(info->ri_chunklen, info->ri_position);
+
+       head->rc_hdr_count = 0;
+
        /* Split the Receive buffer between the head and tail
         * buffers at Read chunk's position. XDR roundup of the
         * chunk is not included in either the pagelist or in
         * the tail.
         */
-       head->arg.tail[0].iov_base =
-               head->arg.head[0].iov_base + info->ri_position;
-       head->arg.tail[0].iov_len =
-               head->arg.head[0].iov_len - info->ri_position;
-       head->arg.head[0].iov_len = info->ri_position;
+       head->rc_arg.tail[0].iov_base =
+               head->rc_arg.head[0].iov_base + info->ri_position;
+       head->rc_arg.tail[0].iov_len =
+               head->rc_arg.head[0].iov_len - info->ri_position;
+       head->rc_arg.head[0].iov_len = info->ri_position;
 
        /* Read chunk may need XDR roundup (see RFC 8166, s. 3.4.5.2).
         *
@@ -738,9 +748,9 @@ static int svc_rdma_build_normal_read_chunk(struct svc_rqst *rqstp,
         */
        info->ri_chunklen = XDR_QUADLEN(info->ri_chunklen) << 2;
 
-       head->arg.page_len = info->ri_chunklen;
-       head->arg.len += info->ri_chunklen;
-       head->arg.buflen += info->ri_chunklen;
+       head->rc_arg.page_len = info->ri_chunklen;
+       head->rc_arg.len += info->ri_chunklen;
+       head->rc_arg.buflen += info->ri_chunklen;
 
 out:
        return ret;
@@ -749,7 +759,7 @@ static int svc_rdma_build_normal_read_chunk(struct svc_rqst *rqstp,
 /* Construct RDMA Reads to pull over a Position Zero Read chunk.
  * The start of the data lands in the first page just after
  * the Transport header, and the rest lands in the page list of
- * head->arg.pages.
+ * head->rc_arg.pages.
  *
  * Assumptions:
  *     - A PZRC has an XDR-aligned length (no implicit round-up).
@@ -761,35 +771,25 @@ static int svc_rdma_build_pz_read_chunk(struct svc_rqst *rqstp,
                                        struct svc_rdma_read_info *info,
                                        __be32 *p)
 {
-       struct svc_rdma_op_ctxt *head = info->ri_readctxt;
+       struct svc_rdma_recv_ctxt *head = info->ri_readctxt;
        int ret;
 
-       dprintk("svcrdma: Reading Position Zero Read chunk\n");
-
-       info->ri_pageno = head->hdr_count - 1;
-       info->ri_pageoff = offset_in_page(head->byte_len);
-
        ret = svc_rdma_build_read_chunk(rqstp, info, p);
        if (ret < 0)
                goto out;
 
-       head->arg.len += info->ri_chunklen;
-       head->arg.buflen += info->ri_chunklen;
+       trace_svcrdma_encode_pzr(info->ri_chunklen);
 
-       if (head->arg.buflen <= head->sge[0].length) {
-               /* Transport header and RPC message fit entirely
-                * in page where head iovec resides.
-                */
-               head->arg.head[0].iov_len = info->ri_chunklen;
-       } else {
-               /* Transport header and part of RPC message reside
-                * in the head iovec's page.
-                */
-               head->arg.head[0].iov_len =
-                               head->sge[0].length - head->byte_len;
-               head->arg.page_len =
-                               info->ri_chunklen - head->arg.head[0].iov_len;
-       }
+       head->rc_arg.len += info->ri_chunklen;
+       head->rc_arg.buflen += info->ri_chunklen;
+
+       head->rc_hdr_count = 1;
+       head->rc_arg.head[0].iov_base = page_address(head->rc_pages[0]);
+       head->rc_arg.head[0].iov_len = min_t(size_t, PAGE_SIZE,
+                                            info->ri_chunklen);
+
+       head->rc_arg.page_len = info->ri_chunklen -
+                               head->rc_arg.head[0].iov_len;
 
 out:
        return ret;
@@ -813,29 +813,30 @@ static int svc_rdma_build_pz_read_chunk(struct svc_rqst *rqstp,
  * - All Read segments in @p have the same Position value.
  */
 int svc_rdma_recv_read_chunk(struct svcxprt_rdma *rdma, struct svc_rqst *rqstp,
-                            struct svc_rdma_op_ctxt *head, __be32 *p)
+                            struct svc_rdma_recv_ctxt *head, __be32 *p)
 {
        struct svc_rdma_read_info *info;
        struct page **page;
        int ret;
 
        /* The request (with page list) is constructed in
-        * head->arg. Pages involved with RDMA Read I/O are
+        * head->rc_arg. Pages involved with RDMA Read I/O are
         * transferred there.
         */
-       head->hdr_count = head->count;
-       head->arg.head[0] = rqstp->rq_arg.head[0];
-       head->arg.tail[0] = rqstp->rq_arg.tail[0];
-       head->arg.pages = head->pages;
-       head->arg.page_base = 0;
-       head->arg.page_len = 0;
-       head->arg.len = rqstp->rq_arg.len;
-       head->arg.buflen = rqstp->rq_arg.buflen;
+       head->rc_arg.head[0] = rqstp->rq_arg.head[0];
+       head->rc_arg.tail[0] = rqstp->rq_arg.tail[0];
+       head->rc_arg.pages = head->rc_pages;
+       head->rc_arg.page_base = 0;
+       head->rc_arg.page_len = 0;
+       head->rc_arg.len = rqstp->rq_arg.len;
+       head->rc_arg.buflen = rqstp->rq_arg.buflen;
 
        info = svc_rdma_read_info_alloc(rdma);
        if (!info)
                return -ENOMEM;
        info->ri_readctxt = head;
+       info->ri_pageno = 0;
+       info->ri_pageoff = 0;
 
        info->ri_position = be32_to_cpup(p + 1);
        if (info->ri_position)
@@ -856,7 +857,7 @@ int svc_rdma_recv_read_chunk(struct svcxprt_rdma *rdma, struct svc_rqst *rqstp,
 
 out:
        /* Read sink pages have been moved from rqstp->rq_pages to
-        * head->arg.pages. Force svc_recv to refill those slots
+        * head->rc_arg.pages. Force svc_recv to refill those slots
         * in rq_pages.
         */
        for (page = rqstp->rq_pages; page < rqstp->rq_respages; page++)
index 649441d5087d9abd0c3a2db1c488d4d3d3ef5c62..4a3efaea277c2e766cf4b94f974b11700d59ec79 100644 (file)
@@ -1,5 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
- * Copyright (c) 2016 Oracle. All rights reserved.
+ * Copyright (c) 2016-2018 Oracle. All rights reserved.
  * Copyright (c) 2014 Open Grid Computing, Inc. All rights reserved.
  * Copyright (c) 2005-2006 Network Appliance, Inc. All rights reserved.
  *
  * DMA-unmap the pages under I/O for that Write segment. The Write
  * completion handler does not release any pages.
  *
- * When the Send WR is constructed, it also gets its own svc_rdma_op_ctxt.
+ * When the Send WR is constructed, it also gets its own svc_rdma_send_ctxt.
  * The ownership of all of the Reply's pages are transferred into that
  * ctxt, the Send WR is posted, and sendto returns.
  *
- * The svc_rdma_op_ctxt is presented when the Send WR completes. The
+ * The svc_rdma_send_ctxt is presented when the Send WR completes. The
  * Send completion handler finally releases the Reply's pages.
  *
  * This mechanism also assumes that completions on the transport's Send
  * where two different Write segments send portions of the same page.
  */
 
-#include <linux/sunrpc/debug.h>
-#include <linux/sunrpc/rpc_rdma.h>
 #include <linux/spinlock.h>
 #include <asm/unaligned.h>
+
 #include <rdma/ib_verbs.h>
 #include <rdma/rdma_cm.h>
+
+#include <linux/sunrpc/debug.h>
+#include <linux/sunrpc/rpc_rdma.h>
 #include <linux/sunrpc/svc_rdma.h>
 
+#include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
+
 #define RPCDBG_FACILITY        RPCDBG_SVCXPRT
 
+static void svc_rdma_wc_send(struct ib_cq *cq, struct ib_wc *wc);
+
+static inline struct svc_rdma_send_ctxt *
+svc_rdma_next_send_ctxt(struct list_head *list)
+{
+       return list_first_entry_or_null(list, struct svc_rdma_send_ctxt,
+                                       sc_list);
+}
+
+static struct svc_rdma_send_ctxt *
+svc_rdma_send_ctxt_alloc(struct svcxprt_rdma *rdma)
+{
+       struct svc_rdma_send_ctxt *ctxt;
+       dma_addr_t addr;
+       void *buffer;
+       size_t size;
+       int i;
+
+       size = sizeof(*ctxt);
+       size += rdma->sc_max_send_sges * sizeof(struct ib_sge);
+       ctxt = kmalloc(size, GFP_KERNEL);
+       if (!ctxt)
+               goto fail0;
+       buffer = kmalloc(rdma->sc_max_req_size, GFP_KERNEL);
+       if (!buffer)
+               goto fail1;
+       addr = ib_dma_map_single(rdma->sc_pd->device, buffer,
+                                rdma->sc_max_req_size, DMA_TO_DEVICE);
+       if (ib_dma_mapping_error(rdma->sc_pd->device, addr))
+               goto fail2;
+
+       ctxt->sc_send_wr.next = NULL;
+       ctxt->sc_send_wr.wr_cqe = &ctxt->sc_cqe;
+       ctxt->sc_send_wr.sg_list = ctxt->sc_sges;
+       ctxt->sc_send_wr.send_flags = IB_SEND_SIGNALED;
+       ctxt->sc_cqe.done = svc_rdma_wc_send;
+       ctxt->sc_xprt_buf = buffer;
+       ctxt->sc_sges[0].addr = addr;
+
+       for (i = 0; i < rdma->sc_max_send_sges; i++)
+               ctxt->sc_sges[i].lkey = rdma->sc_pd->local_dma_lkey;
+       return ctxt;
+
+fail2:
+       kfree(buffer);
+fail1:
+       kfree(ctxt);
+fail0:
+       return NULL;
+}
+
+/**
+ * svc_rdma_send_ctxts_destroy - Release all send_ctxt's for an xprt
+ * @rdma: svcxprt_rdma being torn down
+ *
+ */
+void svc_rdma_send_ctxts_destroy(struct svcxprt_rdma *rdma)
+{
+       struct svc_rdma_send_ctxt *ctxt;
+
+       while ((ctxt = svc_rdma_next_send_ctxt(&rdma->sc_send_ctxts))) {
+               list_del(&ctxt->sc_list);
+               ib_dma_unmap_single(rdma->sc_pd->device,
+                                   ctxt->sc_sges[0].addr,
+                                   rdma->sc_max_req_size,
+                                   DMA_TO_DEVICE);
+               kfree(ctxt->sc_xprt_buf);
+               kfree(ctxt);
+       }
+}
+
+/**
+ * svc_rdma_send_ctxt_get - Get a free send_ctxt
+ * @rdma: controlling svcxprt_rdma
+ *
+ * Returns a ready-to-use send_ctxt, or NULL if none are
+ * available and a fresh one cannot be allocated.
+ */
+struct svc_rdma_send_ctxt *svc_rdma_send_ctxt_get(struct svcxprt_rdma *rdma)
+{
+       struct svc_rdma_send_ctxt *ctxt;
+
+       spin_lock(&rdma->sc_send_lock);
+       ctxt = svc_rdma_next_send_ctxt(&rdma->sc_send_ctxts);
+       if (!ctxt)
+               goto out_empty;
+       list_del(&ctxt->sc_list);
+       spin_unlock(&rdma->sc_send_lock);
+
+out:
+       ctxt->sc_send_wr.num_sge = 0;
+       ctxt->sc_cur_sge_no = 0;
+       ctxt->sc_page_count = 0;
+       return ctxt;
+
+out_empty:
+       spin_unlock(&rdma->sc_send_lock);
+       ctxt = svc_rdma_send_ctxt_alloc(rdma);
+       if (!ctxt)
+               return NULL;
+       goto out;
+}
+
+/**
+ * svc_rdma_send_ctxt_put - Return send_ctxt to free list
+ * @rdma: controlling svcxprt_rdma
+ * @ctxt: object to return to the free list
+ *
+ * Pages left in sc_pages are DMA unmapped and released.
+ */
+void svc_rdma_send_ctxt_put(struct svcxprt_rdma *rdma,
+                           struct svc_rdma_send_ctxt *ctxt)
+{
+       struct ib_device *device = rdma->sc_cm_id->device;
+       unsigned int i;
+
+       /* The first SGE contains the transport header, which
+        * remains mapped until @ctxt is destroyed.
+        */
+       for (i = 1; i < ctxt->sc_send_wr.num_sge; i++)
+               ib_dma_unmap_page(device,
+                                 ctxt->sc_sges[i].addr,
+                                 ctxt->sc_sges[i].length,
+                                 DMA_TO_DEVICE);
+
+       for (i = 0; i < ctxt->sc_page_count; ++i)
+               put_page(ctxt->sc_pages[i]);
+
+       spin_lock(&rdma->sc_send_lock);
+       list_add(&ctxt->sc_list, &rdma->sc_send_ctxts);
+       spin_unlock(&rdma->sc_send_lock);
+}
+
+/**
+ * svc_rdma_wc_send - Invoked by RDMA provider for each polled Send WC
+ * @cq: Completion Queue context
+ * @wc: Work Completion object
+ *
+ * NB: The svc_xprt/svcxprt_rdma is pinned whenever it's possible that
+ * the Send completion handler could be running.
+ */
+static void svc_rdma_wc_send(struct ib_cq *cq, struct ib_wc *wc)
+{
+       struct svcxprt_rdma *rdma = cq->cq_context;
+       struct ib_cqe *cqe = wc->wr_cqe;
+       struct svc_rdma_send_ctxt *ctxt;
+
+       trace_svcrdma_wc_send(wc);
+
+       atomic_inc(&rdma->sc_sq_avail);
+       wake_up(&rdma->sc_send_wait);
+
+       ctxt = container_of(cqe, struct svc_rdma_send_ctxt, sc_cqe);
+       svc_rdma_send_ctxt_put(rdma, ctxt);
+
+       if (unlikely(wc->status != IB_WC_SUCCESS)) {
+               set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags);
+               svc_xprt_enqueue(&rdma->sc_xprt);
+               if (wc->status != IB_WC_WR_FLUSH_ERR)
+                       pr_err("svcrdma: Send: %s (%u/0x%x)\n",
+                              ib_wc_status_msg(wc->status),
+                              wc->status, wc->vendor_err);
+       }
+
+       svc_xprt_put(&rdma->sc_xprt);
+}
+
+/**
+ * svc_rdma_send - Post a single Send WR
+ * @rdma: transport on which to post the WR
+ * @wr: prepared Send WR to post
+ *
+ * Returns zero the Send WR was posted successfully. Otherwise, a
+ * negative errno is returned.
+ */
+int svc_rdma_send(struct svcxprt_rdma *rdma, struct ib_send_wr *wr)
+{
+       struct ib_send_wr *bad_wr;
+       int ret;
+
+       might_sleep();
+
+       /* If the SQ is full, wait until an SQ entry is available */
+       while (1) {
+               if ((atomic_dec_return(&rdma->sc_sq_avail) < 0)) {
+                       atomic_inc(&rdma_stat_sq_starve);
+                       trace_svcrdma_sq_full(rdma);
+                       atomic_inc(&rdma->sc_sq_avail);
+                       wait_event(rdma->sc_send_wait,
+                                  atomic_read(&rdma->sc_sq_avail) > 1);
+                       if (test_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags))
+                               return -ENOTCONN;
+                       trace_svcrdma_sq_retry(rdma);
+                       continue;
+               }
+
+               svc_xprt_get(&rdma->sc_xprt);
+               ret = ib_post_send(rdma->sc_qp, wr, &bad_wr);
+               trace_svcrdma_post_send(wr, ret);
+               if (ret) {
+                       set_bit(XPT_CLOSE, &rdma->sc_xprt.xpt_flags);
+                       svc_xprt_put(&rdma->sc_xprt);
+                       wake_up(&rdma->sc_send_wait);
+               }
+               break;
+       }
+       return ret;
+}
+
 static u32 xdr_padsize(u32 len)
 {
        return (len & 3) ? (4 - (len & 3)) : 0;
@@ -296,41 +511,10 @@ static u32 svc_rdma_get_inv_rkey(__be32 *rdma_argp,
        return be32_to_cpup(p);
 }
 
-/* ib_dma_map_page() is used here because svc_rdma_dma_unmap()
- * is used during completion to DMA-unmap this memory, and
- * it uses ib_dma_unmap_page() exclusively.
- */
-static int svc_rdma_dma_map_buf(struct svcxprt_rdma *rdma,
-                               struct svc_rdma_op_ctxt *ctxt,
-                               unsigned int sge_no,
-                               unsigned char *base,
-                               unsigned int len)
-{
-       unsigned long offset = (unsigned long)base & ~PAGE_MASK;
-       struct ib_device *dev = rdma->sc_cm_id->device;
-       dma_addr_t dma_addr;
-
-       dma_addr = ib_dma_map_page(dev, virt_to_page(base),
-                                  offset, len, DMA_TO_DEVICE);
-       if (ib_dma_mapping_error(dev, dma_addr))
-               goto out_maperr;
-
-       ctxt->sge[sge_no].addr = dma_addr;
-       ctxt->sge[sge_no].length = len;
-       ctxt->sge[sge_no].lkey = rdma->sc_pd->local_dma_lkey;
-       svc_rdma_count_mappings(rdma, ctxt);
-       return 0;
-
-out_maperr:
-       pr_err("svcrdma: failed to map buffer\n");
-       return -EIO;
-}
-
 static int svc_rdma_dma_map_page(struct svcxprt_rdma *rdma,
-                                struct svc_rdma_op_ctxt *ctxt,
-                                unsigned int sge_no,
+                                struct svc_rdma_send_ctxt *ctxt,
                                 struct page *page,
-                                unsigned int offset,
+                                unsigned long offset,
                                 unsigned int len)
 {
        struct ib_device *dev = rdma->sc_cm_id->device;
@@ -340,58 +524,71 @@ static int svc_rdma_dma_map_page(struct svcxprt_rdma *rdma,
        if (ib_dma_mapping_error(dev, dma_addr))
                goto out_maperr;
 
-       ctxt->sge[sge_no].addr = dma_addr;
-       ctxt->sge[sge_no].length = len;
-       ctxt->sge[sge_no].lkey = rdma->sc_pd->local_dma_lkey;
-       svc_rdma_count_mappings(rdma, ctxt);
+       ctxt->sc_sges[ctxt->sc_cur_sge_no].addr = dma_addr;
+       ctxt->sc_sges[ctxt->sc_cur_sge_no].length = len;
+       ctxt->sc_send_wr.num_sge++;
        return 0;
 
 out_maperr:
-       pr_err("svcrdma: failed to map page\n");
+       trace_svcrdma_dma_map_page(rdma, page);
        return -EIO;
 }
 
+/* ib_dma_map_page() is used here because svc_rdma_dma_unmap()
+ * handles DMA-unmap and it uses ib_dma_unmap_page() exclusively.
+ */
+static int svc_rdma_dma_map_buf(struct svcxprt_rdma *rdma,
+                               struct svc_rdma_send_ctxt *ctxt,
+                               unsigned char *base,
+                               unsigned int len)
+{
+       return svc_rdma_dma_map_page(rdma, ctxt, virt_to_page(base),
+                                    offset_in_page(base), len);
+}
+
 /**
- * svc_rdma_map_reply_hdr - DMA map the transport header buffer
+ * svc_rdma_sync_reply_hdr - DMA sync the transport header buffer
  * @rdma: controlling transport
- * @ctxt: op_ctxt for the Send WR
- * @rdma_resp: buffer containing transport header
+ * @ctxt: send_ctxt for the Send WR
  * @len: length of transport header
  *
- * Returns:
- *     %0 if the header is DMA mapped,
- *     %-EIO if DMA mapping failed.
  */
-int svc_rdma_map_reply_hdr(struct svcxprt_rdma *rdma,
-                          struct svc_rdma_op_ctxt *ctxt,
-                          __be32 *rdma_resp,
-                          unsigned int len)
+void svc_rdma_sync_reply_hdr(struct svcxprt_rdma *rdma,
+                            struct svc_rdma_send_ctxt *ctxt,
+                            unsigned int len)
 {
-       ctxt->direction = DMA_TO_DEVICE;
-       ctxt->pages[0] = virt_to_page(rdma_resp);
-       ctxt->count = 1;
-       return svc_rdma_dma_map_page(rdma, ctxt, 0, ctxt->pages[0], 0, len);
+       ctxt->sc_sges[0].length = len;
+       ctxt->sc_send_wr.num_sge++;
+       ib_dma_sync_single_for_device(rdma->sc_pd->device,
+                                     ctxt->sc_sges[0].addr, len,
+                                     DMA_TO_DEVICE);
 }
 
-/* Load the xdr_buf into the ctxt's sge array, and DMA map each
+/* svc_rdma_map_reply_msg - Map the buffer holding RPC message
+ * @rdma: controlling transport
+ * @ctxt: send_ctxt for the Send WR
+ * @xdr: prepared xdr_buf containing RPC message
+ * @wr_lst: pointer to Call header's Write list, or NULL
+ *
+ * Load the xdr_buf into the ctxt's sge array, and DMA map each
  * element as it is added.
  *
- * Returns the number of sge elements loaded on success, or
- * a negative errno on failure.
+ * Returns zero on success, or a negative errno on failure.
  */
-static int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma,
-                                 struct svc_rdma_op_ctxt *ctxt,
-                                 struct xdr_buf *xdr, __be32 *wr_lst)
+int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma,
+                          struct svc_rdma_send_ctxt *ctxt,
+                          struct xdr_buf *xdr, __be32 *wr_lst)
 {
-       unsigned int len, sge_no, remaining, page_off;
+       unsigned int len, remaining;
+       unsigned long page_off;
        struct page **ppages;
        unsigned char *base;
        u32 xdr_pad;
        int ret;
 
-       sge_no = 1;
-
-       ret = svc_rdma_dma_map_buf(rdma, ctxt, sge_no++,
+       if (++ctxt->sc_cur_sge_no >= rdma->sc_max_send_sges)
+               return -EIO;
+       ret = svc_rdma_dma_map_buf(rdma, ctxt,
                                   xdr->head[0].iov_base,
                                   xdr->head[0].iov_len);
        if (ret < 0)
@@ -421,8 +618,10 @@ static int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma,
        while (remaining) {
                len = min_t(u32, PAGE_SIZE - page_off, remaining);
 
-               ret = svc_rdma_dma_map_page(rdma, ctxt, sge_no++,
-                                           *ppages++, page_off, len);
+               if (++ctxt->sc_cur_sge_no >= rdma->sc_max_send_sges)
+                       return -EIO;
+               ret = svc_rdma_dma_map_page(rdma, ctxt, *ppages++,
+                                           page_off, len);
                if (ret < 0)
                        return ret;
 
@@ -434,12 +633,14 @@ static int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma,
        len = xdr->tail[0].iov_len;
 tail:
        if (len) {
-               ret = svc_rdma_dma_map_buf(rdma, ctxt, sge_no++, base, len);
+               if (++ctxt->sc_cur_sge_no >= rdma->sc_max_send_sges)
+                       return -EIO;
+               ret = svc_rdma_dma_map_buf(rdma, ctxt, base, len);
                if (ret < 0)
                        return ret;
        }
 
-       return sge_no - 1;
+       return 0;
 }
 
 /* The svc_rqst and all resources it owns are released as soon as
@@ -447,62 +648,25 @@ static int svc_rdma_map_reply_msg(struct svcxprt_rdma *rdma,
  * so they are released by the Send completion handler.
  */
 static void svc_rdma_save_io_pages(struct svc_rqst *rqstp,
-                                  struct svc_rdma_op_ctxt *ctxt)
+                                  struct svc_rdma_send_ctxt *ctxt)
 {
        int i, pages = rqstp->rq_next_page - rqstp->rq_respages;
 
-       ctxt->count += pages;
+       ctxt->sc_page_count += pages;
        for (i = 0; i < pages; i++) {
-               ctxt->pages[i + 1] = rqstp->rq_respages[i];
+               ctxt->sc_pages[i] = rqstp->rq_respages[i];
                rqstp->rq_respages[i] = NULL;
        }
        rqstp->rq_next_page = rqstp->rq_respages + 1;
 }
 
-/**
- * svc_rdma_post_send_wr - Set up and post one Send Work Request
- * @rdma: controlling transport
- * @ctxt: op_ctxt for transmitting the Send WR
- * @num_sge: number of SGEs to send
- * @inv_rkey: R_key argument to Send With Invalidate, or zero
- *
- * Returns:
- *     %0 if the Send* was posted successfully,
- *     %-ENOTCONN if the connection was lost or dropped,
- *     %-EINVAL if there was a problem with the Send we built,
- *     %-ENOMEM if ib_post_send failed.
- */
-int svc_rdma_post_send_wr(struct svcxprt_rdma *rdma,
-                         struct svc_rdma_op_ctxt *ctxt, int num_sge,
-                         u32 inv_rkey)
-{
-       struct ib_send_wr *send_wr = &ctxt->send_wr;
-
-       dprintk("svcrdma: posting Send WR with %u sge(s)\n", num_sge);
-
-       send_wr->next = NULL;
-       ctxt->cqe.done = svc_rdma_wc_send;
-       send_wr->wr_cqe = &ctxt->cqe;
-       send_wr->sg_list = ctxt->sge;
-       send_wr->num_sge = num_sge;
-       send_wr->send_flags = IB_SEND_SIGNALED;
-       if (inv_rkey) {
-               send_wr->opcode = IB_WR_SEND_WITH_INV;
-               send_wr->ex.invalidate_rkey = inv_rkey;
-       } else {
-               send_wr->opcode = IB_WR_SEND;
-       }
-
-       return svc_rdma_send(rdma, send_wr);
-}
-
 /* Prepare the portion of the RPC Reply that will be transmitted
  * via RDMA Send. The RPC-over-RDMA transport header is prepared
- * in sge[0], and the RPC xdr_buf is prepared in following sges.
+ * in sc_sges[0], and the RPC xdr_buf is prepared in following sges.
  *
  * Depending on whether a Write list or Reply chunk is present,
  * the server may send all, a portion of, or none of the xdr_buf.
- * In the latter case, only the transport header (sge[0]) is
+ * In the latter case, only the transport header (sc_sges[0]) is
  * transmitted.
  *
  * RDMA Send is the last step of transmitting an RPC reply. Pages
@@ -515,49 +679,32 @@ int svc_rdma_post_send_wr(struct svcxprt_rdma *rdma,
  * - The Reply's transport header will never be larger than a page.
  */
 static int svc_rdma_send_reply_msg(struct svcxprt_rdma *rdma,
-                                  __be32 *rdma_argp, __be32 *rdma_resp,
+                                  struct svc_rdma_send_ctxt *ctxt,
+                                  __be32 *rdma_argp,
                                   struct svc_rqst *rqstp,
                                   __be32 *wr_lst, __be32 *rp_ch)
 {
-       struct svc_rdma_op_ctxt *ctxt;
-       u32 inv_rkey;
        int ret;
 
-       dprintk("svcrdma: sending %s reply: head=%zu, pagelen=%u, tail=%zu\n",
-               (rp_ch ? "RDMA_NOMSG" : "RDMA_MSG"),
-               rqstp->rq_res.head[0].iov_len,
-               rqstp->rq_res.page_len,
-               rqstp->rq_res.tail[0].iov_len);
-
-       ctxt = svc_rdma_get_context(rdma);
-
-       ret = svc_rdma_map_reply_hdr(rdma, ctxt, rdma_resp,
-                                    svc_rdma_reply_hdr_len(rdma_resp));
-       if (ret < 0)
-               goto err;
-
        if (!rp_ch) {
                ret = svc_rdma_map_reply_msg(rdma, ctxt,
                                             &rqstp->rq_res, wr_lst);
                if (ret < 0)
-                       goto err;
+                       return ret;
        }
 
        svc_rdma_save_io_pages(rqstp, ctxt);
 
-       inv_rkey = 0;
-       if (rdma->sc_snd_w_inv)
-               inv_rkey = svc_rdma_get_inv_rkey(rdma_argp, wr_lst, rp_ch);
-       ret = svc_rdma_post_send_wr(rdma, ctxt, 1 + ret, inv_rkey);
-       if (ret)
-               goto err;
-
-       return 0;
-
-err:
-       svc_rdma_unmap_dma(ctxt);
-       svc_rdma_put_context(ctxt, 1);
-       return ret;
+       ctxt->sc_send_wr.opcode = IB_WR_SEND;
+       if (rdma->sc_snd_w_inv) {
+               ctxt->sc_send_wr.ex.invalidate_rkey =
+                       svc_rdma_get_inv_rkey(rdma_argp, wr_lst, rp_ch);
+               if (ctxt->sc_send_wr.ex.invalidate_rkey)
+                       ctxt->sc_send_wr.opcode = IB_WR_SEND_WITH_INV;
+       }
+       dprintk("svcrdma: posting Send WR with %u sge(s)\n",
+               ctxt->sc_send_wr.num_sge);
+       return svc_rdma_send(rdma, &ctxt->sc_send_wr);
 }
 
 /* Given the client-provided Write and Reply chunks, the server was not
@@ -568,38 +715,29 @@ static int svc_rdma_send_reply_msg(struct svcxprt_rdma *rdma,
  * Remote Invalidation is skipped for simplicity.
  */
 static int svc_rdma_send_error_msg(struct svcxprt_rdma *rdma,
-                                  __be32 *rdma_resp, struct svc_rqst *rqstp)
+                                  struct svc_rdma_send_ctxt *ctxt,
+                                  struct svc_rqst *rqstp)
 {
-       struct svc_rdma_op_ctxt *ctxt;
        __be32 *p;
        int ret;
 
-       ctxt = svc_rdma_get_context(rdma);
-
-       /* Replace the original transport header with an
-        * RDMA_ERROR response. XID etc are preserved.
-        */
-       p = rdma_resp + 3;
+       p = ctxt->sc_xprt_buf;
+       trace_svcrdma_err_chunk(*p);
+       p += 3;
        *p++ = rdma_error;
        *p   = err_chunk;
-
-       ret = svc_rdma_map_reply_hdr(rdma, ctxt, rdma_resp, 20);
-       if (ret < 0)
-               goto err;
+       svc_rdma_sync_reply_hdr(rdma, ctxt, RPCRDMA_HDRLEN_ERR);
 
        svc_rdma_save_io_pages(rqstp, ctxt);
 
-       ret = svc_rdma_post_send_wr(rdma, ctxt, 1 + ret, 0);
-       if (ret)
-               goto err;
+       ctxt->sc_send_wr.opcode = IB_WR_SEND;
+       ret = svc_rdma_send(rdma, &ctxt->sc_send_wr);
+       if (ret) {
+               svc_rdma_send_ctxt_put(rdma, ctxt);
+               return ret;
+       }
 
        return 0;
-
-err:
-       pr_err("svcrdma: failed to post Send WR (%d)\n", ret);
-       svc_rdma_unmap_dma(ctxt);
-       svc_rdma_put_context(ctxt, 1);
-       return ret;
 }
 
 void svc_rdma_prep_reply_hdr(struct svc_rqst *rqstp)
@@ -623,20 +761,15 @@ int svc_rdma_sendto(struct svc_rqst *rqstp)
        struct svc_xprt *xprt = rqstp->rq_xprt;
        struct svcxprt_rdma *rdma =
                container_of(xprt, struct svcxprt_rdma, sc_xprt);
+       struct svc_rdma_recv_ctxt *rctxt = rqstp->rq_xprt_ctxt;
        __be32 *p, *rdma_argp, *rdma_resp, *wr_lst, *rp_ch;
        struct xdr_buf *xdr = &rqstp->rq_res;
-       struct page *res_page;
+       struct svc_rdma_send_ctxt *sctxt;
        int ret;
 
-       /* Find the call's chunk lists to decide how to send the reply.
-        * Receive places the Call's xprt header at the start of page 0.
-        */
-       rdma_argp = page_address(rqstp->rq_pages[0]);
+       rdma_argp = rctxt->rc_recv_buf;
        svc_rdma_get_write_arrays(rdma_argp, &wr_lst, &rp_ch);
 
-       dprintk("svcrdma: preparing response for XID 0x%08x\n",
-               be32_to_cpup(rdma_argp));
-
        /* Create the RDMA response header. xprt->xpt_mutex,
         * acquired in svc_send(), serializes RPC replies. The
         * code path below that inserts the credit grant value
@@ -644,10 +777,10 @@ int svc_rdma_sendto(struct svc_rqst *rqstp)
         * critical section.
         */
        ret = -ENOMEM;
-       res_page = alloc_page(GFP_KERNEL);
-       if (!res_page)
+       sctxt = svc_rdma_send_ctxt_get(rdma);
+       if (!sctxt)
                goto err0;
-       rdma_resp = page_address(res_page);
+       rdma_resp = sctxt->sc_xprt_buf;
 
        p = rdma_resp;
        *p++ = *rdma_argp;
@@ -674,26 +807,33 @@ int svc_rdma_sendto(struct svc_rqst *rqstp)
                svc_rdma_xdr_encode_reply_chunk(rdma_resp, rp_ch, ret);
        }
 
-       ret = svc_rdma_send_reply_msg(rdma, rdma_argp, rdma_resp, rqstp,
+       svc_rdma_sync_reply_hdr(rdma, sctxt, svc_rdma_reply_hdr_len(rdma_resp));
+       ret = svc_rdma_send_reply_msg(rdma, sctxt, rdma_argp, rqstp,
                                      wr_lst, rp_ch);
        if (ret < 0)
-               goto err0;
-       return 0;
+               goto err1;
+       ret = 0;
+
+out:
+       rqstp->rq_xprt_ctxt = NULL;
+       svc_rdma_recv_ctxt_put(rdma, rctxt);
+       return ret;
 
  err2:
        if (ret != -E2BIG && ret != -EINVAL)
                goto err1;
 
-       ret = svc_rdma_send_error_msg(rdma, rdma_resp, rqstp);
+       ret = svc_rdma_send_error_msg(rdma, sctxt, rqstp);
        if (ret < 0)
-               goto err0;
-       return 0;
+               goto err1;
+       ret = 0;
+       goto out;
 
  err1:
-       put_page(res_page);
+       svc_rdma_send_ctxt_put(rdma, sctxt);
  err0:
-       pr_err("svcrdma: Could not send reply, err=%d. Closing transport.\n",
-              ret);
+       trace_svcrdma_send_failed(rqstp, ret);
        set_bit(XPT_CLOSE, &xprt->xpt_flags);
-       return -ENOTCONN;
+       ret = -ENOTCONN;
+       goto out;
 }
index 96cc8f6597d36421f831282fcb9a4a470d7965ea..e9535a66bab0044de5aee1fa3a3df0f837430701 100644 (file)
@@ -1,4 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
+ * Copyright (c) 2015-2018 Oracle. All rights reserved.
  * Copyright (c) 2014 Open Grid Computing, Inc. All rights reserved.
  * Copyright (c) 2005-2007 Network Appliance, Inc. All rights reserved.
  *
  * Author: Tom Tucker <tom@opengridcomputing.com>
  */
 
-#include <linux/sunrpc/svc_xprt.h>
-#include <linux/sunrpc/addr.h>
-#include <linux/sunrpc/debug.h>
-#include <linux/sunrpc/rpc_rdma.h>
 #include <linux/interrupt.h>
 #include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/workqueue.h>
+#include <linux/export.h>
+
 #include <rdma/ib_verbs.h>
 #include <rdma/rdma_cm.h>
 #include <rdma/rw.h>
+
+#include <linux/sunrpc/addr.h>
+#include <linux/sunrpc/debug.h>
+#include <linux/sunrpc/rpc_rdma.h>
+#include <linux/sunrpc/svc_xprt.h>
 #include <linux/sunrpc/svc_rdma.h>
-#include <linux/export.h>
+
 #include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
 
 #define RPCDBG_FACILITY        RPCDBG_SVCXPRT
 
-static int svc_rdma_post_recv(struct svcxprt_rdma *xprt);
-static struct svcxprt_rdma *rdma_create_xprt(struct svc_serv *, int);
+static struct svcxprt_rdma *svc_rdma_create_xprt(struct svc_serv *serv,
+                                                struct net *net);
 static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,
                                        struct net *net,
                                        struct sockaddr *sa, int salen,
@@ -123,7 +129,7 @@ static struct svc_xprt *svc_rdma_bc_create(struct svc_serv *serv,
        struct svcxprt_rdma *cma_xprt;
        struct svc_xprt *xprt;
 
-       cma_xprt = rdma_create_xprt(serv, 0);
+       cma_xprt = svc_rdma_create_xprt(serv, net);
        if (!cma_xprt)
                return ERR_PTR(-ENOMEM);
        xprt = &cma_xprt->sc_xprt;
@@ -152,133 +158,20 @@ static void svc_rdma_bc_free(struct svc_xprt *xprt)
 }
 #endif /* CONFIG_SUNRPC_BACKCHANNEL */
 
-static struct svc_rdma_op_ctxt *alloc_ctxt(struct svcxprt_rdma *xprt,
-                                          gfp_t flags)
-{
-       struct svc_rdma_op_ctxt *ctxt;
-
-       ctxt = kmalloc(sizeof(*ctxt), flags);
-       if (ctxt) {
-               ctxt->xprt = xprt;
-               INIT_LIST_HEAD(&ctxt->list);
-       }
-       return ctxt;
-}
-
-static bool svc_rdma_prealloc_ctxts(struct svcxprt_rdma *xprt)
-{
-       unsigned int i;
-
-       /* Each RPC/RDMA credit can consume one Receive and
-        * one Send WQE at the same time.
-        */
-       i = xprt->sc_sq_depth + xprt->sc_rq_depth;
-
-       while (i--) {
-               struct svc_rdma_op_ctxt *ctxt;
-
-               ctxt = alloc_ctxt(xprt, GFP_KERNEL);
-               if (!ctxt) {
-                       dprintk("svcrdma: No memory for RDMA ctxt\n");
-                       return false;
-               }
-               list_add(&ctxt->list, &xprt->sc_ctxts);
-       }
-       return true;
-}
-
-struct svc_rdma_op_ctxt *svc_rdma_get_context(struct svcxprt_rdma *xprt)
-{
-       struct svc_rdma_op_ctxt *ctxt = NULL;
-
-       spin_lock(&xprt->sc_ctxt_lock);
-       xprt->sc_ctxt_used++;
-       if (list_empty(&xprt->sc_ctxts))
-               goto out_empty;
-
-       ctxt = list_first_entry(&xprt->sc_ctxts,
-                               struct svc_rdma_op_ctxt, list);
-       list_del(&ctxt->list);
-       spin_unlock(&xprt->sc_ctxt_lock);
-
-out:
-       ctxt->count = 0;
-       ctxt->mapped_sges = 0;
-       return ctxt;
-
-out_empty:
-       /* Either pre-allocation missed the mark, or send
-        * queue accounting is broken.
-        */
-       spin_unlock(&xprt->sc_ctxt_lock);
-
-       ctxt = alloc_ctxt(xprt, GFP_NOIO);
-       if (ctxt)
-               goto out;
-
-       spin_lock(&xprt->sc_ctxt_lock);
-       xprt->sc_ctxt_used--;
-       spin_unlock(&xprt->sc_ctxt_lock);
-       WARN_ONCE(1, "svcrdma: empty RDMA ctxt list?\n");
-       return NULL;
-}
-
-void svc_rdma_unmap_dma(struct svc_rdma_op_ctxt *ctxt)
-{
-       struct svcxprt_rdma *xprt = ctxt->xprt;
-       struct ib_device *device = xprt->sc_cm_id->device;
-       unsigned int i;
-
-       for (i = 0; i < ctxt->mapped_sges; i++)
-               ib_dma_unmap_page(device,
-                                 ctxt->sge[i].addr,
-                                 ctxt->sge[i].length,
-                                 ctxt->direction);
-       ctxt->mapped_sges = 0;
-}
-
-void svc_rdma_put_context(struct svc_rdma_op_ctxt *ctxt, int free_pages)
-{
-       struct svcxprt_rdma *xprt = ctxt->xprt;
-       int i;
-
-       if (free_pages)
-               for (i = 0; i < ctxt->count; i++)
-                       put_page(ctxt->pages[i]);
-
-       spin_lock(&xprt->sc_ctxt_lock);
-       xprt->sc_ctxt_used--;
-       list_add(&ctxt->list, &xprt->sc_ctxts);
-       spin_unlock(&xprt->sc_ctxt_lock);
-}
-
-static void svc_rdma_destroy_ctxts(struct svcxprt_rdma *xprt)
-{
-       while (!list_empty(&xprt->sc_ctxts)) {
-               struct svc_rdma_op_ctxt *ctxt;
-
-               ctxt = list_first_entry(&xprt->sc_ctxts,
-                                       struct svc_rdma_op_ctxt, list);
-               list_del(&ctxt->list);
-               kfree(ctxt);
-       }
-}
-
 /* QP event handler */
 static void qp_event_handler(struct ib_event *event, void *context)
 {
        struct svc_xprt *xprt = context;
 
+       trace_svcrdma_qp_error(event, (struct sockaddr *)&xprt->xpt_remote);
        switch (event->event) {
        /* These are considered benign events */
        case IB_EVENT_PATH_MIG:
        case IB_EVENT_COMM_EST:
        case IB_EVENT_SQ_DRAINED:
        case IB_EVENT_QP_LAST_WQE_REACHED:
-               dprintk("svcrdma: QP event %s (%d) received for QP=%p\n",
-                       ib_event_msg(event->event), event->event,
-                       event->element.qp);
                break;
+
        /* These are considered fatal events */
        case IB_EVENT_PATH_MIG_ERR:
        case IB_EVENT_QP_FATAL:
@@ -286,111 +179,34 @@ static void qp_event_handler(struct ib_event *event, void *context)
        case IB_EVENT_QP_ACCESS_ERR:
        case IB_EVENT_DEVICE_FATAL:
        default:
-               dprintk("svcrdma: QP ERROR event %s (%d) received for QP=%p, "
-                       "closing transport\n",
-                       ib_event_msg(event->event), event->event,
-                       event->element.qp);
                set_bit(XPT_CLOSE, &xprt->xpt_flags);
                svc_xprt_enqueue(xprt);
                break;
        }
 }
 
-/**
- * svc_rdma_wc_receive - Invoked by RDMA provider for each polled Receive WC
- * @cq:        completion queue
- * @wc:        completed WR
- *
- */
-static void svc_rdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
-{
-       struct svcxprt_rdma *xprt = cq->cq_context;
-       struct ib_cqe *cqe = wc->wr_cqe;
-       struct svc_rdma_op_ctxt *ctxt;
-
-       /* WARNING: Only wc->wr_cqe and wc->status are reliable */
-       ctxt = container_of(cqe, struct svc_rdma_op_ctxt, cqe);
-       svc_rdma_unmap_dma(ctxt);
-
-       if (wc->status != IB_WC_SUCCESS)
-               goto flushed;
-
-       /* All wc fields are now known to be valid */
-       ctxt->byte_len = wc->byte_len;
-       spin_lock(&xprt->sc_rq_dto_lock);
-       list_add_tail(&ctxt->list, &xprt->sc_rq_dto_q);
-       spin_unlock(&xprt->sc_rq_dto_lock);
-
-       svc_rdma_post_recv(xprt);
-
-       set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
-       if (test_bit(RDMAXPRT_CONN_PENDING, &xprt->sc_flags))
-               goto out;
-       goto out_enqueue;
-
-flushed:
-       if (wc->status != IB_WC_WR_FLUSH_ERR)
-               pr_err("svcrdma: Recv: %s (%u/0x%x)\n",
-                      ib_wc_status_msg(wc->status),
-                      wc->status, wc->vendor_err);
-       set_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags);
-       svc_rdma_put_context(ctxt, 1);
-
-out_enqueue:
-       svc_xprt_enqueue(&xprt->sc_xprt);
-out:
-       svc_xprt_put(&xprt->sc_xprt);
-}
-
-/**
- * svc_rdma_wc_send - Invoked by RDMA provider for each polled Send WC
- * @cq:        completion queue
- * @wc:        completed WR
- *
- */
-void svc_rdma_wc_send(struct ib_cq *cq, struct ib_wc *wc)
-{
-       struct svcxprt_rdma *xprt = cq->cq_context;
-       struct ib_cqe *cqe = wc->wr_cqe;
-       struct svc_rdma_op_ctxt *ctxt;
-
-       atomic_inc(&xprt->sc_sq_avail);
-       wake_up(&xprt->sc_send_wait);
-
-       ctxt = container_of(cqe, struct svc_rdma_op_ctxt, cqe);
-       svc_rdma_unmap_dma(ctxt);
-       svc_rdma_put_context(ctxt, 1);
-
-       if (unlikely(wc->status != IB_WC_SUCCESS)) {
-               set_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags);
-               svc_xprt_enqueue(&xprt->sc_xprt);
-               if (wc->status != IB_WC_WR_FLUSH_ERR)
-                       pr_err("svcrdma: Send: %s (%u/0x%x)\n",
-                              ib_wc_status_msg(wc->status),
-                              wc->status, wc->vendor_err);
-       }
-
-       svc_xprt_put(&xprt->sc_xprt);
-}
-
-static struct svcxprt_rdma *rdma_create_xprt(struct svc_serv *serv,
-                                            int listener)
+static struct svcxprt_rdma *svc_rdma_create_xprt(struct svc_serv *serv,
+                                                struct net *net)
 {
        struct svcxprt_rdma *cma_xprt = kzalloc(sizeof *cma_xprt, GFP_KERNEL);
 
-       if (!cma_xprt)
+       if (!cma_xprt) {
+               dprintk("svcrdma: failed to create new transport\n");
                return NULL;
-       svc_xprt_init(&init_net, &svc_rdma_class, &cma_xprt->sc_xprt, serv);
+       }
+       svc_xprt_init(net, &svc_rdma_class, &cma_xprt->sc_xprt, serv);
        INIT_LIST_HEAD(&cma_xprt->sc_accept_q);
        INIT_LIST_HEAD(&cma_xprt->sc_rq_dto_q);
        INIT_LIST_HEAD(&cma_xprt->sc_read_complete_q);
-       INIT_LIST_HEAD(&cma_xprt->sc_ctxts);
+       INIT_LIST_HEAD(&cma_xprt->sc_send_ctxts);
+       INIT_LIST_HEAD(&cma_xprt->sc_recv_ctxts);
        INIT_LIST_HEAD(&cma_xprt->sc_rw_ctxts);
        init_waitqueue_head(&cma_xprt->sc_send_wait);
 
        spin_lock_init(&cma_xprt->sc_lock);
        spin_lock_init(&cma_xprt->sc_rq_dto_lock);
-       spin_lock_init(&cma_xprt->sc_ctxt_lock);
+       spin_lock_init(&cma_xprt->sc_send_lock);
+       spin_lock_init(&cma_xprt->sc_recv_lock);
        spin_lock_init(&cma_xprt->sc_rw_ctxt_lock);
 
        /*
@@ -401,70 +217,9 @@ static struct svcxprt_rdma *rdma_create_xprt(struct svc_serv *serv,
         */
        set_bit(XPT_CONG_CTRL, &cma_xprt->sc_xprt.xpt_flags);
 
-       if (listener) {
-               strcpy(cma_xprt->sc_xprt.xpt_remotebuf, "listener");
-               set_bit(XPT_LISTENER, &cma_xprt->sc_xprt.xpt_flags);
-       }
-
        return cma_xprt;
 }
 
-static int
-svc_rdma_post_recv(struct svcxprt_rdma *xprt)
-{
-       struct ib_recv_wr recv_wr, *bad_recv_wr;
-       struct svc_rdma_op_ctxt *ctxt;
-       struct page *page;
-       dma_addr_t pa;
-       int sge_no;
-       int buflen;
-       int ret;
-
-       ctxt = svc_rdma_get_context(xprt);
-       buflen = 0;
-       ctxt->direction = DMA_FROM_DEVICE;
-       ctxt->cqe.done = svc_rdma_wc_receive;
-       for (sge_no = 0; buflen < xprt->sc_max_req_size; sge_no++) {
-               if (sge_no >= xprt->sc_max_sge) {
-                       pr_err("svcrdma: Too many sges (%d)\n", sge_no);
-                       goto err_put_ctxt;
-               }
-               page = alloc_page(GFP_KERNEL);
-               if (!page)
-                       goto err_put_ctxt;
-               ctxt->pages[sge_no] = page;
-               pa = ib_dma_map_page(xprt->sc_cm_id->device,
-                                    page, 0, PAGE_SIZE,
-                                    DMA_FROM_DEVICE);
-               if (ib_dma_mapping_error(xprt->sc_cm_id->device, pa))
-                       goto err_put_ctxt;
-               svc_rdma_count_mappings(xprt, ctxt);
-               ctxt->sge[sge_no].addr = pa;
-               ctxt->sge[sge_no].length = PAGE_SIZE;
-               ctxt->sge[sge_no].lkey = xprt->sc_pd->local_dma_lkey;
-               ctxt->count = sge_no + 1;
-               buflen += PAGE_SIZE;
-       }
-       recv_wr.next = NULL;
-       recv_wr.sg_list = &ctxt->sge[0];
-       recv_wr.num_sge = ctxt->count;
-       recv_wr.wr_cqe = &ctxt->cqe;
-
-       svc_xprt_get(&xprt->sc_xprt);
-       ret = ib_post_recv(xprt->sc_qp, &recv_wr, &bad_recv_wr);
-       if (ret) {
-               svc_rdma_unmap_dma(ctxt);
-               svc_rdma_put_context(ctxt, 1);
-               svc_xprt_put(&xprt->sc_xprt);
-       }
-       return ret;
-
- err_put_ctxt:
-       svc_rdma_unmap_dma(ctxt);
-       svc_rdma_put_context(ctxt, 1);
-       return -ENOMEM;
-}
-
 static void
 svc_rdma_parse_connect_private(struct svcxprt_rdma *newxprt,
                               struct rdma_conn_param *param)
@@ -504,15 +259,12 @@ static void handle_connect_req(struct rdma_cm_id *new_cma_id,
        struct sockaddr *sa;
 
        /* Create a new transport */
-       newxprt = rdma_create_xprt(listen_xprt->sc_xprt.xpt_server, 0);
-       if (!newxprt) {
-               dprintk("svcrdma: failed to create new transport\n");
+       newxprt = svc_rdma_create_xprt(listen_xprt->sc_xprt.xpt_server,
+                                      listen_xprt->sc_xprt.xpt_net);
+       if (!newxprt)
                return;
-       }
        newxprt->sc_cm_id = new_cma_id;
        new_cma_id->context = newxprt;
-       dprintk("svcrdma: Creating newxprt=%p, cm_id=%p, listenxprt=%p\n",
-               newxprt, newxprt->sc_cm_id, listen_xprt);
        svc_rdma_parse_connect_private(newxprt, param);
 
        /* Save client advertised inbound read limit for use later in accept. */
@@ -543,9 +295,11 @@ static void handle_connect_req(struct rdma_cm_id *new_cma_id,
 static int rdma_listen_handler(struct rdma_cm_id *cma_id,
                               struct rdma_cm_event *event)
 {
-       struct svcxprt_rdma *xprt = cma_id->context;
+       struct sockaddr *sap = (struct sockaddr *)&cma_id->route.addr.src_addr;
        int ret = 0;
 
+       trace_svcrdma_cm_event(event, sap);
+
        switch (event->event) {
        case RDMA_CM_EVENT_CONNECT_REQUEST:
                dprintk("svcrdma: Connect request on cma_id=%p, xprt = %p, "
@@ -553,23 +307,8 @@ static int rdma_listen_handler(struct rdma_cm_id *cma_id,
                        rdma_event_msg(event->event), event->event);
                handle_connect_req(cma_id, &event->param.conn);
                break;
-
-       case RDMA_CM_EVENT_ESTABLISHED:
-               /* Accept complete */
-               dprintk("svcrdma: Connection completed on LISTEN xprt=%p, "
-                       "cm_id=%p\n", xprt, cma_id);
-               break;
-
-       case RDMA_CM_EVENT_DEVICE_REMOVAL:
-               dprintk("svcrdma: Device removal xprt=%p, cm_id=%p\n",
-                       xprt, cma_id);
-               if (xprt) {
-                       set_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags);
-                       svc_xprt_enqueue(&xprt->sc_xprt);
-               }
-               break;
-
        default:
+               /* NB: No device removal upcall for INADDR_ANY listeners */
                dprintk("svcrdma: Unexpected event on listening endpoint %p, "
                        "event = %s (%d)\n", cma_id,
                        rdma_event_msg(event->event), event->event);
@@ -582,9 +321,12 @@ static int rdma_listen_handler(struct rdma_cm_id *cma_id,
 static int rdma_cma_handler(struct rdma_cm_id *cma_id,
                            struct rdma_cm_event *event)
 {
-       struct svc_xprt *xprt = cma_id->context;
-       struct svcxprt_rdma *rdma =
-               container_of(xprt, struct svcxprt_rdma, sc_xprt);
+       struct sockaddr *sap = (struct sockaddr *)&cma_id->route.addr.dst_addr;
+       struct svcxprt_rdma *rdma = cma_id->context;
+       struct svc_xprt *xprt = &rdma->sc_xprt;
+
+       trace_svcrdma_cm_event(event, sap);
+
        switch (event->event) {
        case RDMA_CM_EVENT_ESTABLISHED:
                /* Accept complete */
@@ -597,21 +339,17 @@ static int rdma_cma_handler(struct rdma_cm_id *cma_id,
        case RDMA_CM_EVENT_DISCONNECTED:
                dprintk("svcrdma: Disconnect on DTO xprt=%p, cm_id=%p\n",
                        xprt, cma_id);
-               if (xprt) {
-                       set_bit(XPT_CLOSE, &xprt->xpt_flags);
-                       svc_xprt_enqueue(xprt);
-                       svc_xprt_put(xprt);
-               }
+               set_bit(XPT_CLOSE, &xprt->xpt_flags);
+               svc_xprt_enqueue(xprt);
+               svc_xprt_put(xprt);
                break;
        case RDMA_CM_EVENT_DEVICE_REMOVAL:
                dprintk("svcrdma: Device removal cma_id=%p, xprt = %p, "
                        "event = %s (%d)\n", cma_id, xprt,
                        rdma_event_msg(event->event), event->event);
-               if (xprt) {
-                       set_bit(XPT_CLOSE, &xprt->xpt_flags);
-                       svc_xprt_enqueue(xprt);
-                       svc_xprt_put(xprt);
-               }
+               set_bit(XPT_CLOSE, &xprt->xpt_flags);
+               svc_xprt_enqueue(xprt);
+               svc_xprt_put(xprt);
                break;
        default:
                dprintk("svcrdma: Unexpected event on DTO endpoint %p, "
@@ -634,16 +372,18 @@ static struct svc_xprt *svc_rdma_create(struct svc_serv *serv,
        struct svcxprt_rdma *cma_xprt;
        int ret;
 
-       dprintk("svcrdma: Creating RDMA socket\n");
+       dprintk("svcrdma: Creating RDMA listener\n");
        if ((sa->sa_family != AF_INET) && (sa->sa_family != AF_INET6)) {
                dprintk("svcrdma: Address family %d is not supported.\n", sa->sa_family);
                return ERR_PTR(-EAFNOSUPPORT);
        }
-       cma_xprt = rdma_create_xprt(serv, 1);
+       cma_xprt = svc_rdma_create_xprt(serv, net);
        if (!cma_xprt)
                return ERR_PTR(-ENOMEM);
+       set_bit(XPT_LISTENER, &cma_xprt->sc_xprt.xpt_flags);
+       strcpy(cma_xprt->sc_xprt.xpt_remotebuf, "listener");
 
-       listen_id = rdma_create_id(&init_net, rdma_listen_handler, cma_xprt,
+       listen_id = rdma_create_id(net, rdma_listen_handler, cma_xprt,
                                   RDMA_PS_TCP, IB_QPT_RC);
        if (IS_ERR(listen_id)) {
                ret = PTR_ERR(listen_id);
@@ -708,9 +448,9 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
        struct rdma_conn_param conn_param;
        struct rpcrdma_connect_private pmsg;
        struct ib_qp_init_attr qp_attr;
+       unsigned int ctxts, rq_depth;
        struct ib_device *dev;
        struct sockaddr *sap;
-       unsigned int i, ctxts;
        int ret = 0;
 
        listen_rdma = container_of(xprt, struct svcxprt_rdma, sc_xprt);
@@ -736,24 +476,28 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
 
        /* Qualify the transport resource defaults with the
         * capabilities of this particular device */
-       newxprt->sc_max_sge = min((size_t)dev->attrs.max_sge,
-                                 (size_t)RPCSVC_MAXPAGES);
+       newxprt->sc_max_send_sges = dev->attrs.max_sge;
+       /* transport hdr, head iovec, one page list entry, tail iovec */
+       if (newxprt->sc_max_send_sges < 4) {
+               pr_err("svcrdma: too few Send SGEs available (%d)\n",
+                      newxprt->sc_max_send_sges);
+               goto errout;
+       }
        newxprt->sc_max_req_size = svcrdma_max_req_size;
        newxprt->sc_max_requests = svcrdma_max_requests;
        newxprt->sc_max_bc_requests = svcrdma_max_bc_requests;
-       newxprt->sc_rq_depth = newxprt->sc_max_requests +
-                              newxprt->sc_max_bc_requests;
-       if (newxprt->sc_rq_depth > dev->attrs.max_qp_wr) {
+       rq_depth = newxprt->sc_max_requests + newxprt->sc_max_bc_requests;
+       if (rq_depth > dev->attrs.max_qp_wr) {
                pr_warn("svcrdma: reducing receive depth to %d\n",
                        dev->attrs.max_qp_wr);
-               newxprt->sc_rq_depth = dev->attrs.max_qp_wr;
-               newxprt->sc_max_requests = newxprt->sc_rq_depth - 2;
+               rq_depth = dev->attrs.max_qp_wr;
+               newxprt->sc_max_requests = rq_depth - 2;
                newxprt->sc_max_bc_requests = 2;
        }
        newxprt->sc_fc_credits = cpu_to_be32(newxprt->sc_max_requests);
        ctxts = rdma_rw_mr_factor(dev, newxprt->sc_port_num, RPCSVC_MAXPAGES);
        ctxts *= newxprt->sc_max_requests;
-       newxprt->sc_sq_depth = newxprt->sc_rq_depth + ctxts;
+       newxprt->sc_sq_depth = rq_depth + ctxts;
        if (newxprt->sc_sq_depth > dev->attrs.max_qp_wr) {
                pr_warn("svcrdma: reducing send depth to %d\n",
                        dev->attrs.max_qp_wr);
@@ -761,9 +505,6 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
        }
        atomic_set(&newxprt->sc_sq_avail, newxprt->sc_sq_depth);
 
-       if (!svc_rdma_prealloc_ctxts(newxprt))
-               goto errout;
-
        newxprt->sc_pd = ib_alloc_pd(dev, 0);
        if (IS_ERR(newxprt->sc_pd)) {
                dprintk("svcrdma: error creating PD for connect request\n");
@@ -775,7 +516,7 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
                dprintk("svcrdma: error creating SQ CQ for connect request\n");
                goto errout;
        }
-       newxprt->sc_rq_cq = ib_alloc_cq(dev, newxprt, newxprt->sc_rq_depth,
+       newxprt->sc_rq_cq = ib_alloc_cq(dev, newxprt, rq_depth,
                                        0, IB_POLL_WORKQUEUE);
        if (IS_ERR(newxprt->sc_rq_cq)) {
                dprintk("svcrdma: error creating RQ CQ for connect request\n");
@@ -788,9 +529,9 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
        qp_attr.port_num = newxprt->sc_port_num;
        qp_attr.cap.max_rdma_ctxs = ctxts;
        qp_attr.cap.max_send_wr = newxprt->sc_sq_depth - ctxts;
-       qp_attr.cap.max_recv_wr = newxprt->sc_rq_depth;
-       qp_attr.cap.max_send_sge = newxprt->sc_max_sge;
-       qp_attr.cap.max_recv_sge = newxprt->sc_max_sge;
+       qp_attr.cap.max_recv_wr = rq_depth;
+       qp_attr.cap.max_send_sge = newxprt->sc_max_send_sges;
+       qp_attr.cap.max_recv_sge = 1;
        qp_attr.sq_sig_type = IB_SIGNAL_REQ_WR;
        qp_attr.qp_type = IB_QPT_RC;
        qp_attr.send_cq = newxprt->sc_sq_cq;
@@ -815,14 +556,8 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
            !rdma_ib_or_roce(dev, newxprt->sc_port_num))
                goto errout;
 
-       /* Post receive buffers */
-       for (i = 0; i < newxprt->sc_max_requests; i++) {
-               ret = svc_rdma_post_recv(newxprt);
-               if (ret) {
-                       dprintk("svcrdma: failure posting receive buffers\n");
-                       goto errout;
-               }
-       }
+       if (!svc_rdma_post_recvs(newxprt))
+               goto errout;
 
        /* Swap out the handler */
        newxprt->sc_cm_id->event_handler = rdma_cma_handler;
@@ -856,16 +591,18 @@ static struct svc_xprt *svc_rdma_accept(struct svc_xprt *xprt)
        dprintk("    local address   : %pIS:%u\n", sap, rpc_get_port(sap));
        sap = (struct sockaddr *)&newxprt->sc_cm_id->route.addr.dst_addr;
        dprintk("    remote address  : %pIS:%u\n", sap, rpc_get_port(sap));
-       dprintk("    max_sge         : %d\n", newxprt->sc_max_sge);
+       dprintk("    max_sge         : %d\n", newxprt->sc_max_send_sges);
        dprintk("    sq_depth        : %d\n", newxprt->sc_sq_depth);
        dprintk("    rdma_rw_ctxs    : %d\n", ctxts);
        dprintk("    max_requests    : %d\n", newxprt->sc_max_requests);
        dprintk("    ord             : %d\n", conn_param.initiator_depth);
 
+       trace_svcrdma_xprt_accept(&newxprt->sc_xprt);
        return &newxprt->sc_xprt;
 
  errout:
        dprintk("svcrdma: failure accepting new connection rc=%d.\n", ret);
+       trace_svcrdma_xprt_fail(&newxprt->sc_xprt);
        /* Take a reference in case the DTO handler runs */
        svc_xprt_get(&newxprt->sc_xprt);
        if (newxprt->sc_qp && !IS_ERR(newxprt->sc_qp))
@@ -896,7 +633,6 @@ static void svc_rdma_detach(struct svc_xprt *xprt)
 {
        struct svcxprt_rdma *rdma =
                container_of(xprt, struct svcxprt_rdma, sc_xprt);
-       dprintk("svc: svc_rdma_detach(%p)\n", xprt);
 
        /* Disconnect and flush posted WQE */
        rdma_disconnect(rdma->sc_cm_id);
@@ -908,7 +644,7 @@ static void __svc_rdma_free(struct work_struct *work)
                container_of(work, struct svcxprt_rdma, sc_work);
        struct svc_xprt *xprt = &rdma->sc_xprt;
 
-       dprintk("svcrdma: %s(%p)\n", __func__, rdma);
+       trace_svcrdma_xprt_free(xprt);
 
        if (rdma->sc_qp && !IS_ERR(rdma->sc_qp))
                ib_drain_qp(rdma->sc_qp);
@@ -918,25 +654,7 @@ static void __svc_rdma_free(struct work_struct *work)
                pr_err("svcrdma: sc_xprt still in use? (%d)\n",
                       kref_read(&xprt->xpt_ref));
 
-       while (!list_empty(&rdma->sc_read_complete_q)) {
-               struct svc_rdma_op_ctxt *ctxt;
-               ctxt = list_first_entry(&rdma->sc_read_complete_q,
-                                       struct svc_rdma_op_ctxt, list);
-               list_del(&ctxt->list);
-               svc_rdma_put_context(ctxt, 1);
-       }
-       while (!list_empty(&rdma->sc_rq_dto_q)) {
-               struct svc_rdma_op_ctxt *ctxt;
-               ctxt = list_first_entry(&rdma->sc_rq_dto_q,
-                                       struct svc_rdma_op_ctxt, list);
-               list_del(&ctxt->list);
-               svc_rdma_put_context(ctxt, 1);
-       }
-
-       /* Warn if we leaked a resource or under-referenced */
-       if (rdma->sc_ctxt_used != 0)
-               pr_err("svcrdma: ctxt still in use? (%d)\n",
-                      rdma->sc_ctxt_used);
+       svc_rdma_flush_recv_queues(rdma);
 
        /* Final put of backchannel client transport */
        if (xprt->xpt_bc_xprt) {
@@ -945,7 +663,8 @@ static void __svc_rdma_free(struct work_struct *work)
        }
 
        svc_rdma_destroy_rw_ctxts(rdma);
-       svc_rdma_destroy_ctxts(rdma);
+       svc_rdma_send_ctxts_destroy(rdma);
+       svc_rdma_recv_ctxts_destroy(rdma);
 
        /* Destroy the QP if present (not a listener) */
        if (rdma->sc_qp && !IS_ERR(rdma->sc_qp))
@@ -998,51 +717,3 @@ static void svc_rdma_secure_port(struct svc_rqst *rqstp)
 static void svc_rdma_kill_temp_xprt(struct svc_xprt *xprt)
 {
 }
-
-int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
-{
-       struct ib_send_wr *bad_wr, *n_wr;
-       int wr_count;
-       int i;
-       int ret;
-
-       if (test_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags))
-               return -ENOTCONN;
-
-       wr_count = 1;
-       for (n_wr = wr->next; n_wr; n_wr = n_wr->next)
-               wr_count++;
-
-       /* If the SQ is full, wait until an SQ entry is available */
-       while (1) {
-               if ((atomic_sub_return(wr_count, &xprt->sc_sq_avail) < 0)) {
-                       atomic_inc(&rdma_stat_sq_starve);
-
-                       /* Wait until SQ WR available if SQ still full */
-                       atomic_add(wr_count, &xprt->sc_sq_avail);
-                       wait_event(xprt->sc_send_wait,
-                                  atomic_read(&xprt->sc_sq_avail) > wr_count);
-                       if (test_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags))
-                               return -ENOTCONN;
-                       continue;
-               }
-               /* Take a transport ref for each WR posted */
-               for (i = 0; i < wr_count; i++)
-                       svc_xprt_get(&xprt->sc_xprt);
-
-               /* Bump used SQ WR count and post */
-               ret = ib_post_send(xprt->sc_qp, wr, &bad_wr);
-               if (ret) {
-                       set_bit(XPT_CLOSE, &xprt->sc_xprt.xpt_flags);
-                       for (i = 0; i < wr_count; i ++)
-                               svc_xprt_put(&xprt->sc_xprt);
-                       dprintk("svcrdma: failed to post SQ WR rc=%d\n", ret);
-                       dprintk("    sc_sq_avail=%d, sc_sq_depth=%d\n",
-                               atomic_read(&xprt->sc_sq_avail),
-                               xprt->sc_sq_depth);
-                       wake_up(&xprt->sc_send_wait);
-               }
-               break;
-       }
-       return ret;
-}
index cc1aad325496ad13b3eb9fda328276a401e72ca6..143ce2579ba90cca47a87b5413ba35caf9d10792 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
  * Copyright (c) 2014-2017 Oracle.  All rights reserved.
  * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/seq_file.h>
+#include <linux/smp.h>
+
 #include <linux/sunrpc/addr.h>
+#include <linux/sunrpc/svc_rdma.h>
 
 #include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
 
 #if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
 # define RPCDBG_FACILITY       RPCDBG_TRANS
@@ -330,9 +335,7 @@ xprt_setup_rdma(struct xprt_create *args)
                return ERR_PTR(-EBADF);
        }
 
-       xprt = xprt_alloc(args->net, sizeof(struct rpcrdma_xprt),
-                       xprt_rdma_slot_table_entries,
-                       xprt_rdma_slot_table_entries);
+       xprt = xprt_alloc(args->net, sizeof(struct rpcrdma_xprt), 0, 0);
        if (xprt == NULL) {
                dprintk("RPC:       %s: couldn't allocate rpcrdma_xprt\n",
                        __func__);
@@ -364,7 +367,7 @@ xprt_setup_rdma(struct xprt_create *args)
                xprt_set_bound(xprt);
        xprt_rdma_format_addresses(xprt, sap);
 
-       cdata.max_requests = xprt->max_reqs;
+       cdata.max_requests = xprt_rdma_slot_table_entries;
 
        cdata.rsize = RPCRDMA_MAX_SEGS * PAGE_SIZE; /* RDMA write max */
        cdata.wsize = RPCRDMA_MAX_SEGS * PAGE_SIZE; /* RDMA read max */
@@ -537,6 +540,47 @@ xprt_rdma_connect(struct rpc_xprt *xprt, struct rpc_task *task)
        }
 }
 
+/**
+ * xprt_rdma_alloc_slot - allocate an rpc_rqst
+ * @xprt: controlling RPC transport
+ * @task: RPC task requesting a fresh rpc_rqst
+ *
+ * tk_status values:
+ *     %0 if task->tk_rqstp points to a fresh rpc_rqst
+ *     %-EAGAIN if no rpc_rqst is available; queued on backlog
+ */
+static void
+xprt_rdma_alloc_slot(struct rpc_xprt *xprt, struct rpc_task *task)
+{
+       struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(xprt);
+       struct rpcrdma_req *req;
+
+       req = rpcrdma_buffer_get(&r_xprt->rx_buf);
+       if (!req)
+               goto out_sleep;
+       task->tk_rqstp = &req->rl_slot;
+       task->tk_status = 0;
+       return;
+
+out_sleep:
+       rpc_sleep_on(&xprt->backlog, task, NULL);
+       task->tk_status = -EAGAIN;
+}
+
+/**
+ * xprt_rdma_free_slot - release an rpc_rqst
+ * @xprt: controlling RPC transport
+ * @rqst: rpc_rqst to release
+ *
+ */
+static void
+xprt_rdma_free_slot(struct rpc_xprt *xprt, struct rpc_rqst *rqst)
+{
+       memset(rqst, 0, sizeof(*rqst));
+       rpcrdma_buffer_put(rpcr_to_rdmar(rqst));
+       rpc_wake_up_next(&xprt->backlog);
+}
+
 static bool
 rpcrdma_get_sendbuf(struct rpcrdma_xprt *r_xprt, struct rpcrdma_req *req,
                    size_t size, gfp_t flags)
@@ -607,13 +651,9 @@ xprt_rdma_allocate(struct rpc_task *task)
 {
        struct rpc_rqst *rqst = task->tk_rqstp;
        struct rpcrdma_xprt *r_xprt = rpcx_to_rdmax(rqst->rq_xprt);
-       struct rpcrdma_req *req;
+       struct rpcrdma_req *req = rpcr_to_rdmar(rqst);
        gfp_t flags;
 
-       req = rpcrdma_buffer_get(&r_xprt->rx_buf);
-       if (req == NULL)
-               goto out_get;
-
        flags = RPCRDMA_DEF_GFP;
        if (RPC_IS_SWAPPER(task))
                flags = __GFP_MEMALLOC | GFP_NOWAIT | __GFP_NOWARN;
@@ -623,15 +663,12 @@ xprt_rdma_allocate(struct rpc_task *task)
        if (!rpcrdma_get_recvbuf(r_xprt, req, rqst->rq_rcvsize, flags))
                goto out_fail;
 
-       rpcrdma_set_xprtdata(rqst, req);
        rqst->rq_buffer = req->rl_sendbuf->rg_base;
        rqst->rq_rbuffer = req->rl_recvbuf->rg_base;
        trace_xprtrdma_allocate(task, req);
        return 0;
 
 out_fail:
-       rpcrdma_buffer_put(req);
-out_get:
        trace_xprtrdma_allocate(task, NULL);
        return -ENOMEM;
 }
@@ -652,7 +689,6 @@ xprt_rdma_free(struct rpc_task *task)
        if (test_bit(RPCRDMA_REQ_F_PENDING, &req->rl_flags))
                rpcrdma_release_rqst(r_xprt, req);
        trace_xprtrdma_rpc_done(task, req);
-       rpcrdma_buffer_put(req);
 }
 
 /**
@@ -690,9 +726,6 @@ xprt_rdma_send_request(struct rpc_task *task)
        if (rc < 0)
                goto failed_marshal;
 
-       if (req->rl_reply == NULL)              /* e.g. reconnection */
-               rpcrdma_recv_buffer_get(req);
-
        /* Must suppress retransmit to maintain credits */
        if (rqst->rq_connect_cookie == xprt->connect_cookie)
                goto drop_connection;
@@ -779,7 +812,8 @@ xprt_rdma_disable_swap(struct rpc_xprt *xprt)
 static const struct rpc_xprt_ops xprt_rdma_procs = {
        .reserve_xprt           = xprt_reserve_xprt_cong,
        .release_xprt           = xprt_release_xprt_cong, /* sunrpc/xprt.c */
-       .alloc_slot             = xprt_alloc_slot,
+       .alloc_slot             = xprt_rdma_alloc_slot,
+       .free_slot              = xprt_rdma_free_slot,
        .release_request        = xprt_release_rqst_cong,       /* ditto */
        .set_retrans_timeout    = xprt_set_retrans_timeout_def, /* ditto */
        .timer                  = xprt_rdma_timer,
index c345d365af886514d61c35c79291718a77f155e7..16161a36dc739896b6712f14ccdbf5cc6106ec8a 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
 /*
  * Copyright (c) 2014-2017 Oracle.  All rights reserved.
  * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
@@ -59,6 +60,7 @@
 #include <rdma/ib_cm.h>
 
 #include "xprt_rdma.h"
+#include <trace/events/rpcrdma.h>
 
 /*
  * Globals/Macros
 /*
  * internal functions
  */
+static void rpcrdma_sendctx_put_locked(struct rpcrdma_sendctx *sc);
 static void rpcrdma_mrs_create(struct rpcrdma_xprt *r_xprt);
 static void rpcrdma_mrs_destroy(struct rpcrdma_buffer *buf);
+static int rpcrdma_create_rep(struct rpcrdma_xprt *r_xprt, bool temp);
 static void rpcrdma_dma_unmap_regbuf(struct rpcrdma_regbuf *rb);
 
 struct workqueue_struct *rpcrdma_receive_wq __read_mostly;
@@ -159,7 +163,7 @@ rpcrdma_wc_receive(struct ib_cq *cq, struct ib_wc *wc)
                                               rr_cqe);
 
        /* WARNING: Only wr_id and status are reliable at this point */
-       trace_xprtrdma_wc_receive(rep, wc);
+       trace_xprtrdma_wc_receive(wc);
        if (wc->status != IB_WC_SUCCESS)
                goto out_fail;
 
@@ -231,7 +235,7 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
                complete(&ia->ri_done);
                break;
        case RDMA_CM_EVENT_ADDR_ERROR:
-               ia->ri_async_rc = -EHOSTUNREACH;
+               ia->ri_async_rc = -EPROTO;
                complete(&ia->ri_done);
                break;
        case RDMA_CM_EVENT_ROUTE_ERROR:
@@ -262,7 +266,7 @@ rpcrdma_conn_upcall(struct rdma_cm_id *id, struct rdma_cm_event *event)
                connstate = -ENOTCONN;
                goto connected;
        case RDMA_CM_EVENT_UNREACHABLE:
-               connstate = -ENETDOWN;
+               connstate = -ENETUNREACH;
                goto connected;
        case RDMA_CM_EVENT_REJECTED:
                dprintk("rpcrdma: connection to %s:%s rejected: %s\n",
@@ -305,8 +309,8 @@ rpcrdma_create_id(struct rpcrdma_xprt *xprt, struct rpcrdma_ia *ia)
        init_completion(&ia->ri_done);
        init_completion(&ia->ri_remove_done);
 
-       id = rdma_create_id(&init_net, rpcrdma_conn_upcall, xprt, RDMA_PS_TCP,
-                           IB_QPT_RC);
+       id = rdma_create_id(xprt->rx_xprt.xprt_net, rpcrdma_conn_upcall,
+                           xprt, RDMA_PS_TCP, IB_QPT_RC);
        if (IS_ERR(id)) {
                rc = PTR_ERR(id);
                dprintk("RPC:       %s: rdma_create_id() failed %i\n",
@@ -500,8 +504,8 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
                  struct rpcrdma_create_data_internal *cdata)
 {
        struct rpcrdma_connect_private *pmsg = &ep->rep_cm_private;
-       unsigned int max_qp_wr, max_sge;
        struct ib_cq *sendcq, *recvcq;
+       unsigned int max_sge;
        int rc;
 
        max_sge = min_t(unsigned int, ia->ri_device->attrs.max_sge,
@@ -512,29 +516,13 @@ rpcrdma_ep_create(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia,
        }
        ia->ri_max_send_sges = max_sge;
 
-       if (ia->ri_device->attrs.max_qp_wr <= RPCRDMA_BACKWARD_WRS) {
-               dprintk("RPC:       %s: insufficient wqe's available\n",
-                       __func__);
-               return -ENOMEM;
-       }
-       max_qp_wr = ia->ri_device->attrs.max_qp_wr - RPCRDMA_BACKWARD_WRS - 1;
-
-       /* check provider's send/recv wr limits */
-       if (cdata->max_requests > max_qp_wr)
-               cdata->max_requests = max_qp_wr;
+       rc = ia->ri_ops->ro_open(ia, ep, cdata);
+       if (rc)
+               return rc;
 
        ep->rep_attr.event_handler = rpcrdma_qp_async_error_upcall;
        ep->rep_attr.qp_context = ep;
        ep->rep_attr.srq = NULL;
-       ep->rep_attr.cap.max_send_wr = cdata->max_requests;
-       ep->rep_attr.cap.max_send_wr += RPCRDMA_BACKWARD_WRS;
-       ep->rep_attr.cap.max_send_wr += 1;      /* drain cqe */
-       rc = ia->ri_ops->ro_open(ia, ep, cdata);
-       if (rc)
-               return rc;
-       ep->rep_attr.cap.max_recv_wr = cdata->max_requests;
-       ep->rep_attr.cap.max_recv_wr += RPCRDMA_BACKWARD_WRS;
-       ep->rep_attr.cap.max_recv_wr += 1;      /* drain cqe */
        ep->rep_attr.cap.max_send_sge = max_sge;
        ep->rep_attr.cap.max_recv_sge = 1;
        ep->rep_attr.cap.max_inline_data = 0;
@@ -741,7 +729,6 @@ rpcrdma_ep_connect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
 {
        struct rpcrdma_xprt *r_xprt = container_of(ia, struct rpcrdma_xprt,
                                                   rx_ia);
-       unsigned int extras;
        int rc;
 
 retry:
@@ -785,9 +772,8 @@ rpcrdma_ep_connect(struct rpcrdma_ep *ep, struct rpcrdma_ia *ia)
        }
 
        dprintk("RPC:       %s: connected\n", __func__);
-       extras = r_xprt->rx_buf.rb_bc_srv_max_requests;
-       if (extras)
-               rpcrdma_ep_post_extra_recv(r_xprt, extras);
+
+       rpcrdma_post_recvs(r_xprt, true);
 
 out:
        if (rc)
@@ -893,6 +879,7 @@ static int rpcrdma_sendctxs_create(struct rpcrdma_xprt *r_xprt)
                sc->sc_xprt = r_xprt;
                buf->rb_sc_ctxs[i] = sc;
        }
+       buf->rb_flags = 0;
 
        return 0;
 
@@ -950,7 +937,7 @@ struct rpcrdma_sendctx *rpcrdma_sendctx_get_locked(struct rpcrdma_buffer *buf)
         * completions recently. This is a sign the Send Queue is
         * backing up. Cause the caller to pause and try again.
         */
-       dprintk("RPC:       %s: empty sendctx queue\n", __func__);
+       set_bit(RPCRDMA_BUF_F_EMPTY_SCQ, &buf->rb_flags);
        r_xprt = container_of(buf, struct rpcrdma_xprt, rx_buf);
        r_xprt->rx_stats.empty_sendctx_q++;
        return NULL;
@@ -965,7 +952,8 @@ struct rpcrdma_sendctx *rpcrdma_sendctx_get_locked(struct rpcrdma_buffer *buf)
  *
  * The caller serializes calls to this function (per rpcrdma_buffer).
  */
-void rpcrdma_sendctx_put_locked(struct rpcrdma_sendctx *sc)
+static void
+rpcrdma_sendctx_put_locked(struct rpcrdma_sendctx *sc)
 {
        struct rpcrdma_buffer *buf = &sc->sc_xprt->rx_buf;
        unsigned long next_tail;
@@ -984,6 +972,11 @@ void rpcrdma_sendctx_put_locked(struct rpcrdma_sendctx *sc)
 
        /* Paired with READ_ONCE */
        smp_store_release(&buf->rb_sc_tail, next_tail);
+
+       if (test_and_clear_bit(RPCRDMA_BUF_F_EMPTY_SCQ, &buf->rb_flags)) {
+               smp_mb__after_atomic();
+               xprt_write_space(&sc->sc_xprt->rx_xprt);
+       }
 }
 
 static void
@@ -1097,14 +1090,8 @@ rpcrdma_create_req(struct rpcrdma_xprt *r_xprt)
        return req;
 }
 
-/**
- * rpcrdma_create_rep - Allocate an rpcrdma_rep object
- * @r_xprt: controlling transport
- *
- * Returns 0 on success or a negative errno on failure.
- */
-int
-rpcrdma_create_rep(struct rpcrdma_xprt *r_xprt)
+static int
+rpcrdma_create_rep(struct rpcrdma_xprt *r_xprt, bool temp)
 {
        struct rpcrdma_create_data_internal *cdata = &r_xprt->rx_data;
        struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
@@ -1132,6 +1119,7 @@ rpcrdma_create_rep(struct rpcrdma_xprt *r_xprt)
        rep->rr_recv_wr.wr_cqe = &rep->rr_cqe;
        rep->rr_recv_wr.sg_list = &rep->rr_rdmabuf->rg_iov;
        rep->rr_recv_wr.num_sge = 1;
+       rep->rr_temp = temp;
 
        spin_lock(&buf->rb_lock);
        list_add(&rep->rr_list, &buf->rb_recv_bufs);
@@ -1183,12 +1171,8 @@ rpcrdma_buffer_create(struct rpcrdma_xprt *r_xprt)
                list_add(&req->rl_list, &buf->rb_send_bufs);
        }
 
+       buf->rb_posted_receives = 0;
        INIT_LIST_HEAD(&buf->rb_recv_bufs);
-       for (i = 0; i <= buf->rb_max_requests; i++) {
-               rc = rpcrdma_create_rep(r_xprt);
-               if (rc)
-                       goto out;
-       }
 
        rc = rpcrdma_sendctxs_create(r_xprt);
        if (rc)
@@ -1200,28 +1184,6 @@ rpcrdma_buffer_create(struct rpcrdma_xprt *r_xprt)
        return rc;
 }
 
-static struct rpcrdma_req *
-rpcrdma_buffer_get_req_locked(struct rpcrdma_buffer *buf)
-{
-       struct rpcrdma_req *req;
-
-       req = list_first_entry(&buf->rb_send_bufs,
-                              struct rpcrdma_req, rl_list);
-       list_del_init(&req->rl_list);
-       return req;
-}
-
-static struct rpcrdma_rep *
-rpcrdma_buffer_get_rep_locked(struct rpcrdma_buffer *buf)
-{
-       struct rpcrdma_rep *rep;
-
-       rep = list_first_entry(&buf->rb_recv_bufs,
-                              struct rpcrdma_rep, rr_list);
-       list_del(&rep->rr_list);
-       return rep;
-}
-
 static void
 rpcrdma_destroy_rep(struct rpcrdma_rep *rep)
 {
@@ -1280,10 +1242,11 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
        while (!list_empty(&buf->rb_recv_bufs)) {
                struct rpcrdma_rep *rep;
 
-               rep = rpcrdma_buffer_get_rep_locked(buf);
+               rep = list_first_entry(&buf->rb_recv_bufs,
+                                      struct rpcrdma_rep, rr_list);
+               list_del(&rep->rr_list);
                rpcrdma_destroy_rep(rep);
        }
-       buf->rb_send_count = 0;
 
        spin_lock(&buf->rb_reqslock);
        while (!list_empty(&buf->rb_allreqs)) {
@@ -1298,7 +1261,6 @@ rpcrdma_buffer_destroy(struct rpcrdma_buffer *buf)
                spin_lock(&buf->rb_reqslock);
        }
        spin_unlock(&buf->rb_reqslock);
-       buf->rb_recv_count = 0;
 
        rpcrdma_mrs_destroy(buf);
 }
@@ -1371,27 +1333,11 @@ rpcrdma_mr_unmap_and_put(struct rpcrdma_mr *mr)
        __rpcrdma_mr_put(&r_xprt->rx_buf, mr);
 }
 
-static struct rpcrdma_rep *
-rpcrdma_buffer_get_rep(struct rpcrdma_buffer *buffers)
-{
-       /* If an RPC previously completed without a reply (say, a
-        * credential problem or a soft timeout occurs) then hold off
-        * on supplying more Receive buffers until the number of new
-        * pending RPCs catches up to the number of posted Receives.
-        */
-       if (unlikely(buffers->rb_send_count < buffers->rb_recv_count))
-               return NULL;
-
-       if (unlikely(list_empty(&buffers->rb_recv_bufs)))
-               return NULL;
-       buffers->rb_recv_count++;
-       return rpcrdma_buffer_get_rep_locked(buffers);
-}
-
-/*
- * Get a set of request/reply buffers.
+/**
+ * rpcrdma_buffer_get - Get a request buffer
+ * @buffers: Buffer pool from which to obtain a buffer
  *
- * Reply buffer (if available) is attached to send buffer upon return.
+ * Returns a fresh rpcrdma_req, or NULL if none are available.
  */
 struct rpcrdma_req *
 rpcrdma_buffer_get(struct rpcrdma_buffer *buffers)
@@ -1399,23 +1345,18 @@ rpcrdma_buffer_get(struct rpcrdma_buffer *buffers)
        struct rpcrdma_req *req;
 
        spin_lock(&buffers->rb_lock);
-       if (list_empty(&buffers->rb_send_bufs))
-               goto out_reqbuf;
-       buffers->rb_send_count++;
-       req = rpcrdma_buffer_get_req_locked(buffers);
-       req->rl_reply = rpcrdma_buffer_get_rep(buffers);
+       req = list_first_entry_or_null(&buffers->rb_send_bufs,
+                                      struct rpcrdma_req, rl_list);
+       if (req)
+               list_del_init(&req->rl_list);
        spin_unlock(&buffers->rb_lock);
-
        return req;
-
-out_reqbuf:
-       spin_unlock(&buffers->rb_lock);
-       return NULL;
 }
 
-/*
- * Put request/reply buffers back into pool.
- * Pre-decrement counter/array index.
+/**
+ * rpcrdma_buffer_put - Put request/reply buffers back into pool
+ * @req: object to return
+ *
  */
 void
 rpcrdma_buffer_put(struct rpcrdma_req *req)
@@ -1426,27 +1367,16 @@ rpcrdma_buffer_put(struct rpcrdma_req *req)
        req->rl_reply = NULL;
 
        spin_lock(&buffers->rb_lock);
-       buffers->rb_send_count--;
-       list_add_tail(&req->rl_list, &buffers->rb_send_bufs);
+       list_add(&req->rl_list, &buffers->rb_send_bufs);
        if (rep) {
-               buffers->rb_recv_count--;
-               list_add_tail(&rep->rr_list, &buffers->rb_recv_bufs);
+               if (!rep->rr_temp) {
+                       list_add(&rep->rr_list, &buffers->rb_recv_bufs);
+                       rep = NULL;
+               }
        }
        spin_unlock(&buffers->rb_lock);
-}
-
-/*
- * Recover reply buffers from pool.
- * This happens when recovering from disconnect.
- */
-void
-rpcrdma_recv_buffer_get(struct rpcrdma_req *req)
-{
-       struct rpcrdma_buffer *buffers = req->rl_buffer;
-
-       spin_lock(&buffers->rb_lock);
-       req->rl_reply = rpcrdma_buffer_get_rep(buffers);
-       spin_unlock(&buffers->rb_lock);
+       if (rep)
+               rpcrdma_destroy_rep(rep);
 }
 
 /*
@@ -1458,10 +1388,13 @@ rpcrdma_recv_buffer_put(struct rpcrdma_rep *rep)
 {
        struct rpcrdma_buffer *buffers = &rep->rr_rxprt->rx_buf;
 
-       spin_lock(&buffers->rb_lock);
-       buffers->rb_recv_count--;
-       list_add_tail(&rep->rr_list, &buffers->rb_recv_bufs);
-       spin_unlock(&buffers->rb_lock);
+       if (!rep->rr_temp) {
+               spin_lock(&buffers->rb_lock);
+               list_add(&rep->rr_list, &buffers->rb_recv_bufs);
+               spin_unlock(&buffers->rb_lock);
+       } else {
+               rpcrdma_destroy_rep(rep);
+       }
 }
 
 /**
@@ -1557,13 +1490,6 @@ rpcrdma_ep_post(struct rpcrdma_ia *ia,
        struct ib_send_wr *send_wr = &req->rl_sendctx->sc_wr;
        int rc;
 
-       if (req->rl_reply) {
-               rc = rpcrdma_ep_post_recv(ia, req->rl_reply);
-               if (rc)
-                       return rc;
-               req->rl_reply = NULL;
-       }
-
        if (!ep->rep_send_count ||
            test_bit(RPCRDMA_REQ_F_TX_RESOURCES, &req->rl_flags)) {
                send_wr->send_flags |= IB_SEND_SIGNALED;
@@ -1580,61 +1506,69 @@ rpcrdma_ep_post(struct rpcrdma_ia *ia,
        return 0;
 }
 
-int
-rpcrdma_ep_post_recv(struct rpcrdma_ia *ia,
-                    struct rpcrdma_rep *rep)
-{
-       struct ib_recv_wr *recv_wr_fail;
-       int rc;
-
-       if (!rpcrdma_dma_map_regbuf(ia, rep->rr_rdmabuf))
-               goto out_map;
-       rc = ib_post_recv(ia->ri_id->qp, &rep->rr_recv_wr, &recv_wr_fail);
-       trace_xprtrdma_post_recv(rep, rc);
-       if (rc)
-               return -ENOTCONN;
-       return 0;
-
-out_map:
-       pr_err("rpcrdma: failed to DMA map the Receive buffer\n");
-       return -EIO;
-}
-
 /**
- * rpcrdma_ep_post_extra_recv - Post buffers for incoming backchannel requests
- * @r_xprt: transport associated with these backchannel resources
- * @count: minimum number of incoming requests expected
+ * rpcrdma_post_recvs - Maybe post some Receive buffers
+ * @r_xprt: controlling transport
+ * @temp: when true, allocate temp rpcrdma_rep objects
  *
- * Returns zero if all requested buffers were posted, or a negative errno.
  */
-int
-rpcrdma_ep_post_extra_recv(struct rpcrdma_xprt *r_xprt, unsigned int count)
+void
+rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp)
 {
-       struct rpcrdma_buffer *buffers = &r_xprt->rx_buf;
-       struct rpcrdma_ia *ia = &r_xprt->rx_ia;
-       struct rpcrdma_rep *rep;
-       int rc;
+       struct rpcrdma_buffer *buf = &r_xprt->rx_buf;
+       struct ib_recv_wr *wr, *bad_wr;
+       int needed, count, rc;
 
-       while (count--) {
-               spin_lock(&buffers->rb_lock);
-               if (list_empty(&buffers->rb_recv_bufs))
-                       goto out_reqbuf;
-               rep = rpcrdma_buffer_get_rep_locked(buffers);
-               spin_unlock(&buffers->rb_lock);
+       needed = buf->rb_credits + (buf->rb_bc_srv_max_requests << 1);
+       if (buf->rb_posted_receives > needed)
+               return;
+       needed -= buf->rb_posted_receives;
 
-               rc = rpcrdma_ep_post_recv(ia, rep);
-               if (rc)
-                       goto out_rc;
-       }
+       count = 0;
+       wr = NULL;
+       while (needed) {
+               struct rpcrdma_regbuf *rb;
+               struct rpcrdma_rep *rep;
 
-       return 0;
+               spin_lock(&buf->rb_lock);
+               rep = list_first_entry_or_null(&buf->rb_recv_bufs,
+                                              struct rpcrdma_rep, rr_list);
+               if (likely(rep))
+                       list_del(&rep->rr_list);
+               spin_unlock(&buf->rb_lock);
+               if (!rep) {
+                       if (rpcrdma_create_rep(r_xprt, temp))
+                               break;
+                       continue;
+               }
 
-out_reqbuf:
-       spin_unlock(&buffers->rb_lock);
-       trace_xprtrdma_noreps(r_xprt);
-       return -ENOMEM;
+               rb = rep->rr_rdmabuf;
+               if (!rpcrdma_regbuf_is_mapped(rb)) {
+                       if (!__rpcrdma_dma_map_regbuf(&r_xprt->rx_ia, rb)) {
+                               rpcrdma_recv_buffer_put(rep);
+                               break;
+                       }
+               }
 
-out_rc:
-       rpcrdma_recv_buffer_put(rep);
-       return rc;
+               trace_xprtrdma_post_recv(rep->rr_recv_wr.wr_cqe);
+               rep->rr_recv_wr.next = wr;
+               wr = &rep->rr_recv_wr;
+               ++count;
+               --needed;
+       }
+       if (!count)
+               return;
+
+       rc = ib_post_recv(r_xprt->rx_ia.ri_id->qp, wr, &bad_wr);
+       if (rc) {
+               for (wr = bad_wr; wr; wr = wr->next) {
+                       struct rpcrdma_rep *rep;
+
+                       rep = container_of(wr, struct rpcrdma_rep, rr_recv_wr);
+                       rpcrdma_recv_buffer_put(rep);
+                       --count;
+               }
+       }
+       buf->rb_posted_receives += count;
+       trace_xprtrdma_post_recvs(r_xprt, count, rc);
 }
index cb41b12a3bf8d985ae155d7977cb69f043af4f1c..2ca14f7c2d51adb89d8df5f313fc2d30c1e9c16c 100644 (file)
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
 /*
  * Copyright (c) 2014-2017 Oracle.  All rights reserved.
  * Copyright (c) 2003-2007 Network Appliance, Inc. All rights reserved.
@@ -196,6 +197,7 @@ struct rpcrdma_rep {
        __be32                  rr_proc;
        int                     rr_wc_flags;
        u32                     rr_inv_rkey;
+       bool                    rr_temp;
        struct rpcrdma_regbuf   *rr_rdmabuf;
        struct rpcrdma_xprt     *rr_rxprt;
        struct work_struct      rr_work;
@@ -334,6 +336,7 @@ enum {
 struct rpcrdma_buffer;
 struct rpcrdma_req {
        struct list_head        rl_list;
+       struct rpc_rqst         rl_slot;
        struct rpcrdma_buffer   *rl_buffer;
        struct rpcrdma_rep      *rl_reply;
        struct xdr_stream       rl_stream;
@@ -356,16 +359,10 @@ enum {
        RPCRDMA_REQ_F_TX_RESOURCES,
 };
 
-static inline void
-rpcrdma_set_xprtdata(struct rpc_rqst *rqst, struct rpcrdma_req *req)
-{
-       rqst->rq_xprtdata = req;
-}
-
 static inline struct rpcrdma_req *
 rpcr_to_rdmar(const struct rpc_rqst *rqst)
 {
-       return rqst->rq_xprtdata;
+       return container_of(rqst, struct rpcrdma_req, rl_slot);
 }
 
 static inline void
@@ -401,11 +398,12 @@ struct rpcrdma_buffer {
        struct rpcrdma_sendctx  **rb_sc_ctxs;
 
        spinlock_t              rb_lock;        /* protect buf lists */
-       int                     rb_send_count, rb_recv_count;
        struct list_head        rb_send_bufs;
        struct list_head        rb_recv_bufs;
+       unsigned long           rb_flags;
        u32                     rb_max_requests;
        u32                     rb_credits;     /* most recent credit grant */
+       int                     rb_posted_receives;
 
        u32                     rb_bc_srv_max_requests;
        spinlock_t              rb_reqslock;    /* protect rb_allreqs */
@@ -420,6 +418,11 @@ struct rpcrdma_buffer {
 };
 #define rdmab_to_ia(b) (&container_of((b), struct rpcrdma_xprt, rx_buf)->rx_ia)
 
+/* rb_flags */
+enum {
+       RPCRDMA_BUF_F_EMPTY_SCQ = 0,
+};
+
 /*
  * Internal structure for transport instance creation. This
  * exists primarily for modularity.
@@ -561,18 +564,16 @@ void rpcrdma_ep_disconnect(struct rpcrdma_ep *, struct rpcrdma_ia *);
 
 int rpcrdma_ep_post(struct rpcrdma_ia *, struct rpcrdma_ep *,
                                struct rpcrdma_req *);
-int rpcrdma_ep_post_recv(struct rpcrdma_ia *, struct rpcrdma_rep *);
+void rpcrdma_post_recvs(struct rpcrdma_xprt *r_xprt, bool temp);
 
 /*
  * Buffer calls - xprtrdma/verbs.c
  */
 struct rpcrdma_req *rpcrdma_create_req(struct rpcrdma_xprt *);
 void rpcrdma_destroy_req(struct rpcrdma_req *);
-int rpcrdma_create_rep(struct rpcrdma_xprt *r_xprt);
 int rpcrdma_buffer_create(struct rpcrdma_xprt *);
 void rpcrdma_buffer_destroy(struct rpcrdma_buffer *);
 struct rpcrdma_sendctx *rpcrdma_sendctx_get_locked(struct rpcrdma_buffer *buf);
-void rpcrdma_sendctx_put_locked(struct rpcrdma_sendctx *sc);
 
 struct rpcrdma_mr *rpcrdma_mr_get(struct rpcrdma_xprt *r_xprt);
 void rpcrdma_mr_put(struct rpcrdma_mr *mr);
@@ -581,7 +582,6 @@ void rpcrdma_mr_defer_recovery(struct rpcrdma_mr *mr);
 
 struct rpcrdma_req *rpcrdma_buffer_get(struct rpcrdma_buffer *);
 void rpcrdma_buffer_put(struct rpcrdma_req *);
-void rpcrdma_recv_buffer_get(struct rpcrdma_req *);
 void rpcrdma_recv_buffer_put(struct rpcrdma_rep *);
 
 struct rpcrdma_regbuf *rpcrdma_alloc_regbuf(size_t, enum dma_data_direction,
@@ -603,8 +603,6 @@ rpcrdma_dma_map_regbuf(struct rpcrdma_ia *ia, struct rpcrdma_regbuf *rb)
        return __rpcrdma_dma_map_regbuf(ia, rb);
 }
 
-int rpcrdma_ep_post_extra_recv(struct rpcrdma_xprt *, unsigned int);
-
 int rpcrdma_alloc_wq(void);
 void rpcrdma_destroy_wq(void);
 
@@ -675,5 +673,3 @@ void xprt_rdma_bc_destroy(struct rpc_xprt *, unsigned int);
 extern struct xprt_class xprt_rdma_bc;
 
 #endif                         /* _LINUX_SUNRPC_XPRT_RDMA_H */
-
-#include <trace/events/rpcrdma.h>
index c8902f11efdd513c066f7f1b4c2c24405d8dfe5f..9e1c5024aba97750f05946a98e38238b9aaa20e6 100644 (file)
@@ -2763,6 +2763,7 @@ static const struct rpc_xprt_ops xs_local_ops = {
        .reserve_xprt           = xprt_reserve_xprt,
        .release_xprt           = xs_tcp_release_xprt,
        .alloc_slot             = xprt_alloc_slot,
+       .free_slot              = xprt_free_slot,
        .rpcbind                = xs_local_rpcbind,
        .set_port               = xs_local_set_port,
        .connect                = xs_local_connect,
@@ -2782,6 +2783,7 @@ static const struct rpc_xprt_ops xs_udp_ops = {
        .reserve_xprt           = xprt_reserve_xprt_cong,
        .release_xprt           = xprt_release_xprt_cong,
        .alloc_slot             = xprt_alloc_slot,
+       .free_slot              = xprt_free_slot,
        .rpcbind                = rpcb_getport_async,
        .set_port               = xs_set_port,
        .connect                = xs_connect,
@@ -2803,6 +2805,7 @@ static const struct rpc_xprt_ops xs_tcp_ops = {
        .reserve_xprt           = xprt_reserve_xprt,
        .release_xprt           = xs_tcp_release_xprt,
        .alloc_slot             = xprt_lock_and_alloc_slot,
+       .free_slot              = xprt_free_slot,
        .rpcbind                = rpcb_getport_async,
        .set_port               = xs_set_port,
        .connect                = xs_connect,
@@ -2834,6 +2837,7 @@ static const struct rpc_xprt_ops bc_tcp_ops = {
        .reserve_xprt           = xprt_reserve_xprt,
        .release_xprt           = xprt_release_xprt,
        .alloc_slot             = xprt_alloc_slot,
+       .free_slot              = xprt_free_slot,
        .buf_alloc              = bc_malloc,
        .buf_free               = bc_free,
        .send_request           = bc_send_request,
index 4492cda45566503627ad20a648524fdd59e3cbde..a2f76743c73af07bdfe3ed524aebb6d5bb000dbc 100644 (file)
@@ -285,8 +285,9 @@ static int __tipc_nl_compat_doit(struct tipc_nl_compat_cmd_doit *cmd,
        if (!trans_buf)
                return -ENOMEM;
 
-       attrbuf = kmalloc((tipc_genl_family.maxattr + 1) *
-                       sizeof(struct nlattr *), GFP_KERNEL);
+       attrbuf = kmalloc_array(tipc_genl_family.maxattr + 1,
+                               sizeof(struct nlattr *),
+                               GFP_KERNEL);
        if (!attrbuf) {
                err = -ENOMEM;
                goto trans_out;
index 301f224304698950544088c16518ea2e14ff41a6..a127d61e8af984d3aaefde49c94f48a9a9187d53 100644 (file)
@@ -712,7 +712,7 @@ static int __init tls_register(void)
        build_protos(tls_prots[TLSV4], &tcp_prot);
 
        tls_sw_proto_ops = inet_stream_ops;
-       tls_sw_proto_ops.poll = tls_sw_poll;
+       tls_sw_proto_ops.poll_mask = tls_sw_poll_mask;
        tls_sw_proto_ops.splice_read = tls_sw_splice_read;
 
 #ifdef CONFIG_TLS_DEVICE
index 8ca57d01b18f6bfc55a06bcc0c21d6220c7a01d5..f127fac88acfe0046b0a7dd55bab4d6d486de105 100644 (file)
@@ -191,18 +191,12 @@ static void tls_free_both_sg(struct sock *sk)
 }
 
 static int tls_do_encryption(struct tls_context *tls_ctx,
-                            struct tls_sw_context_tx *ctx, size_t data_len,
-                            gfp_t flags)
+                            struct tls_sw_context_tx *ctx,
+                            struct aead_request *aead_req,
+                            size_t data_len)
 {
-       unsigned int req_size = sizeof(struct aead_request) +
-               crypto_aead_reqsize(ctx->aead_send);
-       struct aead_request *aead_req;
        int rc;
 
-       aead_req = kzalloc(req_size, flags);
-       if (!aead_req)
-               return -ENOMEM;
-
        ctx->sg_encrypted_data[0].offset += tls_ctx->tx.prepend_size;
        ctx->sg_encrypted_data[0].length -= tls_ctx->tx.prepend_size;
 
@@ -219,7 +213,6 @@ static int tls_do_encryption(struct tls_context *tls_ctx,
        ctx->sg_encrypted_data[0].offset -= tls_ctx->tx.prepend_size;
        ctx->sg_encrypted_data[0].length += tls_ctx->tx.prepend_size;
 
-       kfree(aead_req);
        return rc;
 }
 
@@ -228,8 +221,14 @@ static int tls_push_record(struct sock *sk, int flags,
 {
        struct tls_context *tls_ctx = tls_get_ctx(sk);
        struct tls_sw_context_tx *ctx = tls_sw_ctx_tx(tls_ctx);
+       struct aead_request *req;
        int rc;
 
+       req = kzalloc(sizeof(struct aead_request) +
+                     crypto_aead_reqsize(ctx->aead_send), sk->sk_allocation);
+       if (!req)
+               return -ENOMEM;
+
        sg_mark_end(ctx->sg_plaintext_data + ctx->sg_plaintext_num_elem - 1);
        sg_mark_end(ctx->sg_encrypted_data + ctx->sg_encrypted_num_elem - 1);
 
@@ -245,15 +244,14 @@ static int tls_push_record(struct sock *sk, int flags,
        tls_ctx->pending_open_record_frags = 0;
        set_bit(TLS_PENDING_CLOSED_RECORD, &tls_ctx->flags);
 
-       rc = tls_do_encryption(tls_ctx, ctx, ctx->sg_plaintext_size,
-                              sk->sk_allocation);
+       rc = tls_do_encryption(tls_ctx, ctx, req, ctx->sg_plaintext_size);
        if (rc < 0) {
                /* If we are called from write_space and
                 * we fail, we need to set this SOCK_NOSPACE
                 * to trigger another write_space in the future.
                 */
                set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
-               return rc;
+               goto out_req;
        }
 
        free_sg(sk, ctx->sg_plaintext_data, &ctx->sg_plaintext_num_elem,
@@ -268,6 +266,8 @@ static int tls_push_record(struct sock *sk, int flags,
                tls_err_abort(sk, EBADMSG);
 
        tls_advance_record_sn(sk, &tls_ctx->tx);
+out_req:
+       kfree(req);
        return rc;
 }
 
@@ -754,7 +754,7 @@ int tls_sw_recvmsg(struct sock *sk,
        struct sk_buff *skb;
        ssize_t copied = 0;
        bool cmsg = false;
-       int err = 0;
+       int target, err = 0;
        long timeo;
 
        flags |= nonblock;
@@ -764,6 +764,7 @@ int tls_sw_recvmsg(struct sock *sk,
 
        lock_sock(sk);
 
+       target = sock_rcvlowat(sk, flags & MSG_WAITALL, len);
        timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
        do {
                bool zc = false;
@@ -856,6 +857,9 @@ int tls_sw_recvmsg(struct sock *sk,
                                        goto recv_end;
                        }
                }
+               /* If we have a new message from strparser, continue now. */
+               if (copied >= target && !ctx->recv_pkt)
+                       break;
        } while (len);
 
 recv_end:
@@ -915,23 +919,22 @@ ssize_t tls_sw_splice_read(struct socket *sock,  loff_t *ppos,
        return copied ? : err;
 }
 
-unsigned int tls_sw_poll(struct file *file, struct socket *sock,
-                        struct poll_table_struct *wait)
+__poll_t tls_sw_poll_mask(struct socket *sock, __poll_t events)
 {
-       unsigned int ret;
        struct sock *sk = sock->sk;
        struct tls_context *tls_ctx = tls_get_ctx(sk);
        struct tls_sw_context_rx *ctx = tls_sw_ctx_rx(tls_ctx);
+       __poll_t mask;
 
-       /* Grab POLLOUT and POLLHUP from the underlying socket */
-       ret = ctx->sk_poll(file, sock, wait);
+       /* Grab EPOLLOUT and EPOLLHUP from the underlying socket */
+       mask = ctx->sk_poll_mask(sock, events);
 
-       /* Clear POLLIN bits, and set based on recv_pkt */
-       ret &= ~(POLLIN | POLLRDNORM);
+       /* Clear EPOLLIN bits, and set based on recv_pkt */
+       mask &= ~(EPOLLIN | EPOLLRDNORM);
        if (ctx->recv_pkt)
-               ret |= POLLIN | POLLRDNORM;
+               mask |= EPOLLIN | EPOLLRDNORM;
 
-       return ret;
+       return mask;
 }
 
 static int tls_read_size(struct strparser *strp, struct sk_buff *skb)
@@ -1188,7 +1191,7 @@ int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx, int tx)
                sk->sk_data_ready = tls_data_ready;
                write_unlock_bh(&sk->sk_callback_lock);
 
-               sw_ctx_rx->sk_poll = sk->sk_socket->ops->poll;
+               sw_ctx_rx->sk_poll_mask = sk->sk_socket->ops->poll_mask;
 
                strp_check_rcv(&sw_ctx_rx->strp);
        }
index 5fe35aafdd9cf849d78d46f0f7d960356c804987..48e8097339ab44cca29bc9bbc938b58ea3a43333 100644 (file)
@@ -1012,6 +1012,7 @@ void cfg80211_unregister_wdev(struct wireless_dev *wdev)
        nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);
 
        list_del_rcu(&wdev->list);
+       synchronize_rcu();
        rdev->devlist_generation++;
 
        switch (wdev->iftype) {
index 07514ca011b2fb24cabd18659d1b0f01cebde7fe..c7bbe5f0aae8839bdfe5ac7b7bd02c6aad8ac8dc 100644 (file)
@@ -10833,7 +10833,7 @@ static int nl80211_parse_wowlan_nd(struct cfg80211_registered_device *rdev,
        struct nlattr **tb;
        int err;
 
-       tb = kzalloc(NUM_NL80211_ATTR * sizeof(*tb), GFP_KERNEL);
+       tb = kcalloc(NUM_NL80211_ATTR, sizeof(*tb), GFP_KERNEL);
        if (!tb)
                return -ENOMEM;
 
@@ -11793,7 +11793,7 @@ static int nl80211_nan_add_func(struct sk_buff *skb,
 
                        func->srf_num_macs = n_entries;
                        func->srf_macs =
-                               kzalloc(sizeof(*func->srf_macs) * n_entries,
+                               kcalloc(n_entries, sizeof(*func->srf_macs),
                                        GFP_KERNEL);
                        if (!func->srf_macs) {
                                err = -ENOMEM;
index b5bb1c30991461d980cd57e3e582e3ca69ac4516..3c654cd7ba562ad874c7176960c688b53fb80f61 100644 (file)
@@ -1746,6 +1746,8 @@ int cfg80211_get_station(struct net_device *dev, const u8 *mac_addr,
        if (!rdev->ops->get_station)
                return -EOPNOTSUPP;
 
+       memset(sinfo, 0, sizeof(*sinfo));
+
        return rdev_get_station(rdev, dev, mac_addr, sinfo);
 }
 EXPORT_SYMBOL(cfg80211_get_station);
index b9ef487c4618b56160ac73ed89271a6f03ebf371..f47abb46c5874c8b949b8d3cb3d278c479775e06 100644 (file)
@@ -204,7 +204,8 @@ static int xdp_umem_pin_pages(struct xdp_umem *umem)
        long npgs;
        int err;
 
-       umem->pgs = kcalloc(umem->npgs, sizeof(*umem->pgs), GFP_KERNEL);
+       umem->pgs = kcalloc(umem->npgs, sizeof(*umem->pgs),
+                           GFP_KERNEL | __GFP_NOWARN);
        if (!umem->pgs)
                return -ENOMEM;
 
index 3db002b9e1d39b4987d87dadc26c3673287d6508..bd133efc1a566ecff49092b9b32f13e1d9754143 100644 (file)
@@ -115,6 +115,37 @@ config SAMPLE_VFIO_MDEV_MTTY
          Build a virtual tty sample driver for use as a VFIO
          mediated device
 
+config SAMPLE_VFIO_MDEV_MDPY
+       tristate "Build VFIO mdpy example mediated device sample code -- loadable modules only"
+       depends on VFIO_MDEV_DEVICE && m
+       help
+         Build a virtual display sample driver for use as a VFIO
+         mediated device.  It is a simple framebuffer and supports
+         the region display interface (VFIO_GFX_PLANE_TYPE_REGION).
+
+config SAMPLE_VFIO_MDEV_MDPY_FB
+       tristate "Build VFIO mdpy example guest fbdev driver -- loadable module only"
+       depends on FB && m
+       select FB_CFB_FILLRECT
+       select FB_CFB_COPYAREA
+       select FB_CFB_IMAGEBLIT
+       help
+         Guest fbdev driver for the virtual display sample driver.
+
+config SAMPLE_VFIO_MDEV_MBOCHS
+       tristate "Build VFIO mdpy example mediated device sample code -- loadable modules only"
+       depends on VFIO_MDEV_DEVICE && m
+       select DMA_SHARED_BUFFER
+       help
+         Build a virtual display sample driver for use as a VFIO
+         mediated device.  It supports the region display interface
+         (VFIO_GFX_PLANE_TYPE_DMABUF).
+         Emulate enough of qemu stdvga to make bochs-drm.ko happy.
+         That is basically the vram memory bar and the bochs dispi
+         interface vbe registers in the mmio register bar.
+         Specifically it does *not* include any legacy vga stuff.
+         Device looks a lot like "qemu -device secondary-vga".
+
 config SAMPLE_STATX
        bool "Build example extended-stat using code"
        depends on BROKEN
index cbbd868a50a8b145bf018329542f4fde829e06da..7db889ca135c33c8f5e8552dc5f2c98f4e4edb30 100644 (file)
@@ -1 +1,4 @@
 obj-$(CONFIG_SAMPLE_VFIO_MDEV_MTTY) += mtty.o
+obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY) += mdpy.o
+obj-$(CONFIG_SAMPLE_VFIO_MDEV_MDPY_FB) += mdpy-fb.o
+obj-$(CONFIG_SAMPLE_VFIO_MDEV_MBOCHS) += mbochs.o
diff --git a/samples/vfio-mdev/mbochs.c b/samples/vfio-mdev/mbochs.c
new file mode 100644 (file)
index 0000000..2960e26
--- /dev/null
@@ -0,0 +1,1406 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Mediated virtual PCI display host device driver
+ *
+ * Emulate enough of qemu stdvga to make bochs-drm.ko happy.  That is
+ * basically the vram memory bar and the bochs dispi interface vbe
+ * registers in the mmio register bar. Specifically it does *not*
+ * include any legacy vga stuff.  Device looks a lot like "qemu -device
+ * secondary-vga".
+ *
+ *   (c) Gerd Hoffmann <kraxel@redhat.com>
+ *
+ * based on mtty driver which is:
+ *   Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *      Author: Neo Jia <cjia@nvidia.com>
+ *              Kirti Wankhede <kwankhede@nvidia.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/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/cdev.h>
+#include <linux/vfio.h>
+#include <linux/iommu.h>
+#include <linux/sysfs.h>
+#include <linux/mdev.h>
+#include <linux/pci.h>
+#include <linux/dma-buf.h>
+#include <linux/highmem.h>
+#include <drm/drm_fourcc.h>
+#include <drm/drm_rect.h>
+#include <drm/drm_modeset_lock.h>
+#include <drm/drm_property.h>
+#include <drm/drm_plane.h>
+
+
+#define VBE_DISPI_INDEX_ID             0x0
+#define VBE_DISPI_INDEX_XRES           0x1
+#define VBE_DISPI_INDEX_YRES           0x2
+#define VBE_DISPI_INDEX_BPP            0x3
+#define VBE_DISPI_INDEX_ENABLE         0x4
+#define VBE_DISPI_INDEX_BANK           0x5
+#define VBE_DISPI_INDEX_VIRT_WIDTH     0x6
+#define VBE_DISPI_INDEX_VIRT_HEIGHT    0x7
+#define VBE_DISPI_INDEX_X_OFFSET       0x8
+#define VBE_DISPI_INDEX_Y_OFFSET       0x9
+#define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa
+#define VBE_DISPI_INDEX_COUNT          0xb
+
+#define VBE_DISPI_ID0                  0xB0C0
+#define VBE_DISPI_ID1                  0xB0C1
+#define VBE_DISPI_ID2                  0xB0C2
+#define VBE_DISPI_ID3                  0xB0C3
+#define VBE_DISPI_ID4                  0xB0C4
+#define VBE_DISPI_ID5                  0xB0C5
+
+#define VBE_DISPI_DISABLED             0x00
+#define VBE_DISPI_ENABLED              0x01
+#define VBE_DISPI_GETCAPS              0x02
+#define VBE_DISPI_8BIT_DAC             0x20
+#define VBE_DISPI_LFB_ENABLED          0x40
+#define VBE_DISPI_NOCLEARMEM           0x80
+
+
+#define MBOCHS_NAME              "mbochs"
+#define MBOCHS_CLASS_NAME        "mbochs"
+
+#define MBOCHS_CONFIG_SPACE_SIZE  0xff
+#define MBOCHS_MMIO_BAR_OFFSET   PAGE_SIZE
+#define MBOCHS_MMIO_BAR_SIZE     PAGE_SIZE
+#define MBOCHS_MEMORY_BAR_OFFSET  (MBOCHS_MMIO_BAR_OFFSET + \
+                                  MBOCHS_MMIO_BAR_SIZE)
+
+#define STORE_LE16(addr, val)  (*(u16 *)addr = val)
+#define STORE_LE32(addr, val)  (*(u32 *)addr = val)
+
+
+MODULE_LICENSE("GPL v2");
+
+static int max_mbytes = 256;
+module_param_named(count, max_mbytes, int, 0444);
+MODULE_PARM_DESC(mem, "megabytes available to " MBOCHS_NAME " devices");
+
+
+#define MBOCHS_TYPE_1 "small"
+#define MBOCHS_TYPE_2 "medium"
+#define MBOCHS_TYPE_3 "large"
+
+static const struct mbochs_type {
+       const char *name;
+       u32 mbytes;
+} mbochs_types[] = {
+       {
+               .name   = MBOCHS_CLASS_NAME "-" MBOCHS_TYPE_1,
+               .mbytes = 4,
+       }, {
+               .name   = MBOCHS_CLASS_NAME "-" MBOCHS_TYPE_2,
+               .mbytes = 16,
+       }, {
+               .name   = MBOCHS_CLASS_NAME "-" MBOCHS_TYPE_3,
+               .mbytes = 64,
+       },
+};
+
+
+static dev_t           mbochs_devt;
+static struct class    *mbochs_class;
+static struct cdev     mbochs_cdev;
+static struct device   mbochs_dev;
+static int             mbochs_used_mbytes;
+
+struct mbochs_mode {
+       u32 drm_format;
+       u32 bytepp;
+       u32 width;
+       u32 height;
+       u32 stride;
+       u32 __pad;
+       u64 offset;
+       u64 size;
+};
+
+struct mbochs_dmabuf {
+       struct mbochs_mode mode;
+       u32 id;
+       struct page **pages;
+       pgoff_t pagecount;
+       struct dma_buf *buf;
+       struct mdev_state *mdev_state;
+       struct list_head next;
+       bool unlinked;
+};
+
+/* State of each mdev device */
+struct mdev_state {
+       u8 *vconfig;
+       u64 bar_mask[3];
+       u32 memory_bar_mask;
+       struct mutex ops_lock;
+       struct mdev_device *mdev;
+       struct vfio_device_info dev_info;
+
+       const struct mbochs_type *type;
+       u16 vbe[VBE_DISPI_INDEX_COUNT];
+       u64 memsize;
+       struct page **pages;
+       pgoff_t pagecount;
+
+       struct list_head dmabufs;
+       u32 active_id;
+       u32 next_id;
+};
+
+static const char *vbe_name_list[VBE_DISPI_INDEX_COUNT] = {
+       [VBE_DISPI_INDEX_ID]               = "id",
+       [VBE_DISPI_INDEX_XRES]             = "xres",
+       [VBE_DISPI_INDEX_YRES]             = "yres",
+       [VBE_DISPI_INDEX_BPP]              = "bpp",
+       [VBE_DISPI_INDEX_ENABLE]           = "enable",
+       [VBE_DISPI_INDEX_BANK]             = "bank",
+       [VBE_DISPI_INDEX_VIRT_WIDTH]       = "virt-width",
+       [VBE_DISPI_INDEX_VIRT_HEIGHT]      = "virt-height",
+       [VBE_DISPI_INDEX_X_OFFSET]         = "x-offset",
+       [VBE_DISPI_INDEX_Y_OFFSET]         = "y-offset",
+       [VBE_DISPI_INDEX_VIDEO_MEMORY_64K] = "video-mem",
+};
+
+static const char *vbe_name(u32 index)
+{
+       if (index < ARRAY_SIZE(vbe_name_list))
+               return vbe_name_list[index];
+       return "(invalid)";
+}
+
+static struct page *mbochs_get_page(struct mdev_state *mdev_state,
+                                   pgoff_t pgoff);
+
+static const struct mbochs_type *mbochs_find_type(struct kobject *kobj)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(mbochs_types); i++)
+               if (strcmp(mbochs_types[i].name, kobj->name) == 0)
+                       return mbochs_types + i;
+       return NULL;
+}
+
+static void mbochs_create_config_space(struct mdev_state *mdev_state)
+{
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_VENDOR_ID],
+                  0x1234);
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_DEVICE_ID],
+                  0x1111);
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_SUBSYSTEM_VENDOR_ID],
+                  PCI_SUBVENDOR_ID_REDHAT_QUMRANET);
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_SUBSYSTEM_ID],
+                  PCI_SUBDEVICE_ID_QEMU);
+
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_COMMAND],
+                  PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_CLASS_DEVICE],
+                  PCI_CLASS_DISPLAY_OTHER);
+       mdev_state->vconfig[PCI_CLASS_REVISION] =  0x01;
+
+       STORE_LE32((u32 *) &mdev_state->vconfig[PCI_BASE_ADDRESS_0],
+                  PCI_BASE_ADDRESS_SPACE_MEMORY |
+                  PCI_BASE_ADDRESS_MEM_TYPE_32  |
+                  PCI_BASE_ADDRESS_MEM_PREFETCH);
+       mdev_state->bar_mask[0] = ~(mdev_state->memsize) + 1;
+
+       STORE_LE32((u32 *) &mdev_state->vconfig[PCI_BASE_ADDRESS_2],
+                  PCI_BASE_ADDRESS_SPACE_MEMORY |
+                  PCI_BASE_ADDRESS_MEM_TYPE_32);
+       mdev_state->bar_mask[2] = ~(MBOCHS_MMIO_BAR_SIZE) + 1;
+}
+
+static int mbochs_check_framebuffer(struct mdev_state *mdev_state,
+                                   struct mbochs_mode *mode)
+{
+       struct device *dev = mdev_dev(mdev_state->mdev);
+       u16 *vbe = mdev_state->vbe;
+       u32 virt_width;
+
+       WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));
+
+       if (!(vbe[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED))
+               goto nofb;
+
+       memset(mode, 0, sizeof(*mode));
+       switch (vbe[VBE_DISPI_INDEX_BPP]) {
+       case 32:
+               mode->drm_format = DRM_FORMAT_XRGB8888;
+               mode->bytepp = 4;
+               break;
+       default:
+               dev_info_ratelimited(dev, "%s: bpp %d not supported\n",
+                                    __func__, vbe[VBE_DISPI_INDEX_BPP]);
+               goto nofb;
+       }
+
+       mode->width  = vbe[VBE_DISPI_INDEX_XRES];
+       mode->height = vbe[VBE_DISPI_INDEX_YRES];
+       virt_width  = vbe[VBE_DISPI_INDEX_VIRT_WIDTH];
+       if (virt_width < mode->width)
+               virt_width = mode->width;
+       mode->stride = virt_width * mode->bytepp;
+       mode->size   = (u64)mode->stride * mode->height;
+       mode->offset = ((u64)vbe[VBE_DISPI_INDEX_X_OFFSET] * mode->bytepp +
+                      (u64)vbe[VBE_DISPI_INDEX_Y_OFFSET] * mode->stride);
+
+       if (mode->width < 64 || mode->height < 64) {
+               dev_info_ratelimited(dev, "%s: invalid resolution %dx%d\n",
+                                    __func__, mode->width, mode->height);
+               goto nofb;
+       }
+       if (mode->offset + mode->size > mdev_state->memsize) {
+               dev_info_ratelimited(dev, "%s: framebuffer memory overflow\n",
+                                    __func__);
+               goto nofb;
+       }
+
+       return 0;
+
+nofb:
+       memset(mode, 0, sizeof(*mode));
+       return -EINVAL;
+}
+
+static bool mbochs_modes_equal(struct mbochs_mode *mode1,
+                              struct mbochs_mode *mode2)
+{
+       return memcmp(mode1, mode2, sizeof(struct mbochs_mode)) == 0;
+}
+
+static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
+                                char *buf, u32 count)
+{
+       struct device *dev = mdev_dev(mdev_state->mdev);
+       int index = (offset - PCI_BASE_ADDRESS_0) / 0x04;
+       u32 cfg_addr;
+
+       switch (offset) {
+       case PCI_BASE_ADDRESS_0:
+       case PCI_BASE_ADDRESS_2:
+               cfg_addr = *(u32 *)buf;
+
+               if (cfg_addr == 0xffffffff) {
+                       cfg_addr = (cfg_addr & mdev_state->bar_mask[index]);
+               } else {
+                       cfg_addr &= PCI_BASE_ADDRESS_MEM_MASK;
+                       if (cfg_addr)
+                               dev_info(dev, "BAR #%d @ 0x%x\n",
+                                        index, cfg_addr);
+               }
+
+               cfg_addr |= (mdev_state->vconfig[offset] &
+                            ~PCI_BASE_ADDRESS_MEM_MASK);
+               STORE_LE32(&mdev_state->vconfig[offset], cfg_addr);
+               break;
+       }
+}
+
+static void handle_mmio_write(struct mdev_state *mdev_state, u16 offset,
+                             char *buf, u32 count)
+{
+       struct device *dev = mdev_dev(mdev_state->mdev);
+       int index;
+       u16 reg16;
+
+       switch (offset) {
+       case 0x400 ... 0x41f: /* vga ioports remapped */
+               goto unhandled;
+       case 0x500 ... 0x515: /* bochs dispi interface */
+               if (count != 2)
+                       goto unhandled;
+               index = (offset - 0x500) / 2;
+               reg16 = *(u16 *)buf;
+               if (index < ARRAY_SIZE(mdev_state->vbe))
+                       mdev_state->vbe[index] = reg16;
+               dev_dbg(dev, "%s: vbe write %d = %d (%s)\n",
+                       __func__, index, reg16, vbe_name(index));
+               break;
+       case 0x600 ... 0x607: /* qemu extended regs */
+               goto unhandled;
+       default:
+unhandled:
+               dev_dbg(dev, "%s: @0x%03x, count %d (unhandled)\n",
+                       __func__, offset, count);
+               break;
+       }
+}
+
+static void handle_mmio_read(struct mdev_state *mdev_state, u16 offset,
+                            char *buf, u32 count)
+{
+       struct device *dev = mdev_dev(mdev_state->mdev);
+       u16 reg16 = 0;
+       int index;
+
+       switch (offset) {
+       case 0x500 ... 0x515: /* bochs dispi interface */
+               if (count != 2)
+                       goto unhandled;
+               index = (offset - 0x500) / 2;
+               if (index < ARRAY_SIZE(mdev_state->vbe))
+                       reg16 = mdev_state->vbe[index];
+               dev_dbg(dev, "%s: vbe read %d = %d (%s)\n",
+                       __func__, index, reg16, vbe_name(index));
+               *(u16 *)buf = reg16;
+               break;
+       default:
+unhandled:
+               dev_dbg(dev, "%s: @0x%03x, count %d (unhandled)\n",
+                       __func__, offset, count);
+               memset(buf, 0, count);
+               break;
+       }
+}
+
+static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count,
+                          loff_t pos, bool is_write)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+       struct device *dev = mdev_dev(mdev);
+       struct page *pg;
+       loff_t poff;
+       char *map;
+       int ret = 0;
+
+       mutex_lock(&mdev_state->ops_lock);
+
+       if (pos < MBOCHS_CONFIG_SPACE_SIZE) {
+               if (is_write)
+                       handle_pci_cfg_write(mdev_state, pos, buf, count);
+               else
+                       memcpy(buf, (mdev_state->vconfig + pos), count);
+
+       } else if (pos >= MBOCHS_MMIO_BAR_OFFSET &&
+                  pos + count <= MBOCHS_MEMORY_BAR_OFFSET) {
+               pos -= MBOCHS_MMIO_BAR_OFFSET;
+               if (is_write)
+                       handle_mmio_write(mdev_state, pos, buf, count);
+               else
+                       handle_mmio_read(mdev_state, pos, buf, count);
+
+       } else if (pos >= MBOCHS_MEMORY_BAR_OFFSET &&
+                  pos + count <=
+                  MBOCHS_MEMORY_BAR_OFFSET + mdev_state->memsize) {
+               pos -= MBOCHS_MMIO_BAR_OFFSET;
+               poff = pos & ~PAGE_MASK;
+               pg = mbochs_get_page(mdev_state, pos >> PAGE_SHIFT);
+               map = kmap(pg);
+               if (is_write)
+                       memcpy(map + poff, buf, count);
+               else
+                       memcpy(buf, map + poff, count);
+               kunmap(pg);
+               put_page(pg);
+
+       } else {
+               dev_dbg(dev, "%s: %s @0x%llx (unhandled)\n",
+                       __func__, is_write ? "WR" : "RD", pos);
+               ret = -1;
+               goto accessfailed;
+       }
+
+       ret = count;
+
+
+accessfailed:
+       mutex_unlock(&mdev_state->ops_lock);
+
+       return ret;
+}
+
+static int mbochs_reset(struct mdev_device *mdev)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+       u32 size64k = mdev_state->memsize / (64 * 1024);
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(mdev_state->vbe); i++)
+               mdev_state->vbe[i] = 0;
+       mdev_state->vbe[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID5;
+       mdev_state->vbe[VBE_DISPI_INDEX_VIDEO_MEMORY_64K] = size64k;
+       return 0;
+}
+
+static int mbochs_create(struct kobject *kobj, struct mdev_device *mdev)
+{
+       const struct mbochs_type *type = mbochs_find_type(kobj);
+       struct device *dev = mdev_dev(mdev);
+       struct mdev_state *mdev_state;
+
+       if (!type)
+               type = &mbochs_types[0];
+       if (type->mbytes + mbochs_used_mbytes > max_mbytes)
+               return -ENOMEM;
+
+       mdev_state = kzalloc(sizeof(struct mdev_state), GFP_KERNEL);
+       if (mdev_state == NULL)
+               return -ENOMEM;
+
+       mdev_state->vconfig = kzalloc(MBOCHS_CONFIG_SPACE_SIZE, GFP_KERNEL);
+       if (mdev_state->vconfig == NULL)
+               goto err_mem;
+
+       mdev_state->memsize = type->mbytes * 1024 * 1024;
+       mdev_state->pagecount = mdev_state->memsize >> PAGE_SHIFT;
+       mdev_state->pages = kcalloc(mdev_state->pagecount,
+                                   sizeof(struct page *),
+                                   GFP_KERNEL);
+       if (!mdev_state->pages)
+               goto err_mem;
+
+       dev_info(dev, "%s: %s, %d MB, %ld pages\n", __func__,
+                kobj->name, type->mbytes, mdev_state->pagecount);
+
+       mutex_init(&mdev_state->ops_lock);
+       mdev_state->mdev = mdev;
+       mdev_set_drvdata(mdev, mdev_state);
+       INIT_LIST_HEAD(&mdev_state->dmabufs);
+       mdev_state->next_id = 1;
+
+       mdev_state->type = type;
+       mbochs_create_config_space(mdev_state);
+       mbochs_reset(mdev);
+
+       mbochs_used_mbytes += type->mbytes;
+       return 0;
+
+err_mem:
+       kfree(mdev_state->vconfig);
+       kfree(mdev_state);
+       return -ENOMEM;
+}
+
+static int mbochs_remove(struct mdev_device *mdev)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+
+       mbochs_used_mbytes -= mdev_state->type->mbytes;
+       mdev_set_drvdata(mdev, NULL);
+       kfree(mdev_state->pages);
+       kfree(mdev_state->vconfig);
+       kfree(mdev_state);
+       return 0;
+}
+
+static ssize_t mbochs_read(struct mdev_device *mdev, char __user *buf,
+                          size_t count, loff_t *ppos)
+{
+       unsigned int done = 0;
+       int ret;
+
+       while (count) {
+               size_t filled;
+
+               if (count >= 4 && !(*ppos % 4)) {
+                       u32 val;
+
+                       ret =  mdev_access(mdev, (char *)&val, sizeof(val),
+                                          *ppos, false);
+                       if (ret <= 0)
+                               goto read_err;
+
+                       if (copy_to_user(buf, &val, sizeof(val)))
+                               goto read_err;
+
+                       filled = 4;
+               } else if (count >= 2 && !(*ppos % 2)) {
+                       u16 val;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, false);
+                       if (ret <= 0)
+                               goto read_err;
+
+                       if (copy_to_user(buf, &val, sizeof(val)))
+                               goto read_err;
+
+                       filled = 2;
+               } else {
+                       u8 val;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, false);
+                       if (ret <= 0)
+                               goto read_err;
+
+                       if (copy_to_user(buf, &val, sizeof(val)))
+                               goto read_err;
+
+                       filled = 1;
+               }
+
+               count -= filled;
+               done += filled;
+               *ppos += filled;
+               buf += filled;
+       }
+
+       return done;
+
+read_err:
+       return -EFAULT;
+}
+
+static ssize_t mbochs_write(struct mdev_device *mdev, const char __user *buf,
+                           size_t count, loff_t *ppos)
+{
+       unsigned int done = 0;
+       int ret;
+
+       while (count) {
+               size_t filled;
+
+               if (count >= 4 && !(*ppos % 4)) {
+                       u32 val;
+
+                       if (copy_from_user(&val, buf, sizeof(val)))
+                               goto write_err;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, true);
+                       if (ret <= 0)
+                               goto write_err;
+
+                       filled = 4;
+               } else if (count >= 2 && !(*ppos % 2)) {
+                       u16 val;
+
+                       if (copy_from_user(&val, buf, sizeof(val)))
+                               goto write_err;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, true);
+                       if (ret <= 0)
+                               goto write_err;
+
+                       filled = 2;
+               } else {
+                       u8 val;
+
+                       if (copy_from_user(&val, buf, sizeof(val)))
+                               goto write_err;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, true);
+                       if (ret <= 0)
+                               goto write_err;
+
+                       filled = 1;
+               }
+               count -= filled;
+               done += filled;
+               *ppos += filled;
+               buf += filled;
+       }
+
+       return done;
+write_err:
+       return -EFAULT;
+}
+
+static struct page *__mbochs_get_page(struct mdev_state *mdev_state,
+                                     pgoff_t pgoff)
+{
+       WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));
+
+       if (!mdev_state->pages[pgoff]) {
+               mdev_state->pages[pgoff] =
+                       alloc_pages(GFP_HIGHUSER | __GFP_ZERO, 0);
+               if (!mdev_state->pages[pgoff])
+                       return NULL;
+       }
+
+       get_page(mdev_state->pages[pgoff]);
+       return mdev_state->pages[pgoff];
+}
+
+static struct page *mbochs_get_page(struct mdev_state *mdev_state,
+                                   pgoff_t pgoff)
+{
+       struct page *page;
+
+       if (WARN_ON(pgoff >= mdev_state->pagecount))
+               return NULL;
+
+       mutex_lock(&mdev_state->ops_lock);
+       page = __mbochs_get_page(mdev_state, pgoff);
+       mutex_unlock(&mdev_state->ops_lock);
+
+       return page;
+}
+
+static void mbochs_put_pages(struct mdev_state *mdev_state)
+{
+       struct device *dev = mdev_dev(mdev_state->mdev);
+       int i, count = 0;
+
+       WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));
+
+       for (i = 0; i < mdev_state->pagecount; i++) {
+               if (!mdev_state->pages[i])
+                       continue;
+               put_page(mdev_state->pages[i]);
+               mdev_state->pages[i] = NULL;
+               count++;
+       }
+       dev_dbg(dev, "%s: %d pages released\n", __func__, count);
+}
+
+static int mbochs_region_vm_fault(struct vm_fault *vmf)
+{
+       struct vm_area_struct *vma = vmf->vma;
+       struct mdev_state *mdev_state = vma->vm_private_data;
+       pgoff_t page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT;
+
+       if (page_offset >= mdev_state->pagecount)
+               return VM_FAULT_SIGBUS;
+
+       vmf->page = mbochs_get_page(mdev_state, page_offset);
+       if (!vmf->page)
+               return VM_FAULT_SIGBUS;
+
+       return 0;
+}
+
+static const struct vm_operations_struct mbochs_region_vm_ops = {
+       .fault = mbochs_region_vm_fault,
+};
+
+static int mbochs_mmap(struct mdev_device *mdev, struct vm_area_struct *vma)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+
+       if (vma->vm_pgoff != MBOCHS_MEMORY_BAR_OFFSET >> PAGE_SHIFT)
+               return -EINVAL;
+       if (vma->vm_end < vma->vm_start)
+               return -EINVAL;
+       if (vma->vm_end - vma->vm_start > mdev_state->memsize)
+               return -EINVAL;
+       if ((vma->vm_flags & VM_SHARED) == 0)
+               return -EINVAL;
+
+       vma->vm_ops = &mbochs_region_vm_ops;
+       vma->vm_private_data = mdev_state;
+       return 0;
+}
+
+static int mbochs_dmabuf_vm_fault(struct vm_fault *vmf)
+{
+       struct vm_area_struct *vma = vmf->vma;
+       struct mbochs_dmabuf *dmabuf = vma->vm_private_data;
+
+       if (WARN_ON(vmf->pgoff >= dmabuf->pagecount))
+               return VM_FAULT_SIGBUS;
+
+       vmf->page = dmabuf->pages[vmf->pgoff];
+       get_page(vmf->page);
+       return 0;
+}
+
+static const struct vm_operations_struct mbochs_dmabuf_vm_ops = {
+       .fault = mbochs_dmabuf_vm_fault,
+};
+
+static int mbochs_mmap_dmabuf(struct dma_buf *buf, struct vm_area_struct *vma)
+{
+       struct mbochs_dmabuf *dmabuf = buf->priv;
+       struct device *dev = mdev_dev(dmabuf->mdev_state->mdev);
+
+       dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id);
+
+       if ((vma->vm_flags & VM_SHARED) == 0)
+               return -EINVAL;
+
+       vma->vm_ops = &mbochs_dmabuf_vm_ops;
+       vma->vm_private_data = dmabuf;
+       return 0;
+}
+
+static void mbochs_print_dmabuf(struct mbochs_dmabuf *dmabuf,
+                               const char *prefix)
+{
+       struct device *dev = mdev_dev(dmabuf->mdev_state->mdev);
+       u32 fourcc = dmabuf->mode.drm_format;
+
+       dev_dbg(dev, "%s/%d: %c%c%c%c, %dx%d, stride %d, off 0x%llx, size 0x%llx, pages %ld\n",
+               prefix, dmabuf->id,
+               fourcc ? ((fourcc >>  0) & 0xff) : '-',
+               fourcc ? ((fourcc >>  8) & 0xff) : '-',
+               fourcc ? ((fourcc >> 16) & 0xff) : '-',
+               fourcc ? ((fourcc >> 24) & 0xff) : '-',
+               dmabuf->mode.width, dmabuf->mode.height, dmabuf->mode.stride,
+               dmabuf->mode.offset, dmabuf->mode.size, dmabuf->pagecount);
+}
+
+static struct sg_table *mbochs_map_dmabuf(struct dma_buf_attachment *at,
+                                         enum dma_data_direction direction)
+{
+       struct mbochs_dmabuf *dmabuf = at->dmabuf->priv;
+       struct device *dev = mdev_dev(dmabuf->mdev_state->mdev);
+       struct sg_table *sg;
+
+       dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id);
+
+       sg = kzalloc(sizeof(*sg), GFP_KERNEL);
+       if (!sg)
+               goto err1;
+       if (sg_alloc_table_from_pages(sg, dmabuf->pages, dmabuf->pagecount,
+                                     0, dmabuf->mode.size, GFP_KERNEL) < 0)
+               goto err2;
+       if (!dma_map_sg(at->dev, sg->sgl, sg->nents, direction))
+               goto err3;
+
+       return sg;
+
+err3:
+       sg_free_table(sg);
+err2:
+       kfree(sg);
+err1:
+       return ERR_PTR(-ENOMEM);
+}
+
+static void mbochs_unmap_dmabuf(struct dma_buf_attachment *at,
+                               struct sg_table *sg,
+                               enum dma_data_direction direction)
+{
+       struct mbochs_dmabuf *dmabuf = at->dmabuf->priv;
+       struct device *dev = mdev_dev(dmabuf->mdev_state->mdev);
+
+       dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id);
+
+       sg_free_table(sg);
+       kfree(sg);
+}
+
+static void mbochs_release_dmabuf(struct dma_buf *buf)
+{
+       struct mbochs_dmabuf *dmabuf = buf->priv;
+       struct mdev_state *mdev_state = dmabuf->mdev_state;
+       struct device *dev = mdev_dev(mdev_state->mdev);
+       pgoff_t pg;
+
+       dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id);
+
+       for (pg = 0; pg < dmabuf->pagecount; pg++)
+               put_page(dmabuf->pages[pg]);
+
+       mutex_lock(&mdev_state->ops_lock);
+       dmabuf->buf = NULL;
+       if (dmabuf->unlinked)
+               kfree(dmabuf);
+       mutex_unlock(&mdev_state->ops_lock);
+}
+
+static void *mbochs_kmap_atomic_dmabuf(struct dma_buf *buf,
+                                      unsigned long page_num)
+{
+       struct mbochs_dmabuf *dmabuf = buf->priv;
+       struct page *page = dmabuf->pages[page_num];
+
+       return kmap_atomic(page);
+}
+
+static void *mbochs_kmap_dmabuf(struct dma_buf *buf, unsigned long page_num)
+{
+       struct mbochs_dmabuf *dmabuf = buf->priv;
+       struct page *page = dmabuf->pages[page_num];
+
+       return kmap(page);
+}
+
+static struct dma_buf_ops mbochs_dmabuf_ops = {
+       .map_dma_buf      = mbochs_map_dmabuf,
+       .unmap_dma_buf    = mbochs_unmap_dmabuf,
+       .release          = mbochs_release_dmabuf,
+       .map_atomic       = mbochs_kmap_atomic_dmabuf,
+       .map              = mbochs_kmap_dmabuf,
+       .mmap             = mbochs_mmap_dmabuf,
+};
+
+static struct mbochs_dmabuf *mbochs_dmabuf_alloc(struct mdev_state *mdev_state,
+                                                struct mbochs_mode *mode)
+{
+       struct mbochs_dmabuf *dmabuf;
+       pgoff_t page_offset, pg;
+
+       WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));
+
+       dmabuf = kzalloc(sizeof(struct mbochs_dmabuf), GFP_KERNEL);
+       if (!dmabuf)
+               return NULL;
+
+       dmabuf->mode = *mode;
+       dmabuf->id = mdev_state->next_id++;
+       dmabuf->pagecount = DIV_ROUND_UP(mode->size, PAGE_SIZE);
+       dmabuf->pages = kcalloc(dmabuf->pagecount, sizeof(struct page *),
+                               GFP_KERNEL);
+       if (!dmabuf->pages)
+               goto err_free_dmabuf;
+
+       page_offset = dmabuf->mode.offset >> PAGE_SHIFT;
+       for (pg = 0; pg < dmabuf->pagecount; pg++) {
+               dmabuf->pages[pg] = __mbochs_get_page(mdev_state,
+                                                     page_offset + pg);
+               if (!dmabuf->pages[pg])
+                       goto err_free_pages;
+       }
+
+       dmabuf->mdev_state = mdev_state;
+       list_add(&dmabuf->next, &mdev_state->dmabufs);
+
+       mbochs_print_dmabuf(dmabuf, __func__);
+       return dmabuf;
+
+err_free_pages:
+       while (pg > 0)
+               put_page(dmabuf->pages[--pg]);
+       kfree(dmabuf->pages);
+err_free_dmabuf:
+       kfree(dmabuf);
+       return NULL;
+}
+
+static struct mbochs_dmabuf *
+mbochs_dmabuf_find_by_mode(struct mdev_state *mdev_state,
+                          struct mbochs_mode *mode)
+{
+       struct mbochs_dmabuf *dmabuf;
+
+       WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));
+
+       list_for_each_entry(dmabuf, &mdev_state->dmabufs, next)
+               if (mbochs_modes_equal(&dmabuf->mode, mode))
+                       return dmabuf;
+
+       return NULL;
+}
+
+static struct mbochs_dmabuf *
+mbochs_dmabuf_find_by_id(struct mdev_state *mdev_state, u32 id)
+{
+       struct mbochs_dmabuf *dmabuf;
+
+       WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));
+
+       list_for_each_entry(dmabuf, &mdev_state->dmabufs, next)
+               if (dmabuf->id == id)
+                       return dmabuf;
+
+       return NULL;
+}
+
+static int mbochs_dmabuf_export(struct mbochs_dmabuf *dmabuf)
+{
+       struct mdev_state *mdev_state = dmabuf->mdev_state;
+       struct device *dev = mdev_dev(mdev_state->mdev);
+       DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
+       struct dma_buf *buf;
+
+       WARN_ON(!mutex_is_locked(&mdev_state->ops_lock));
+
+       if (!IS_ALIGNED(dmabuf->mode.offset, PAGE_SIZE)) {
+               dev_info_ratelimited(dev, "%s: framebuffer not page-aligned\n",
+                                    __func__);
+               return -EINVAL;
+       }
+
+       exp_info.ops = &mbochs_dmabuf_ops;
+       exp_info.size = dmabuf->mode.size;
+       exp_info.priv = dmabuf;
+
+       buf = dma_buf_export(&exp_info);
+       if (IS_ERR(buf)) {
+               dev_info_ratelimited(dev, "%s: dma_buf_export failed: %ld\n",
+                                    __func__, PTR_ERR(buf));
+               return PTR_ERR(buf);
+       }
+
+       dmabuf->buf = buf;
+       dev_dbg(dev, "%s: %d\n", __func__, dmabuf->id);
+       return 0;
+}
+
+static int mbochs_get_region_info(struct mdev_device *mdev,
+                                 struct vfio_region_info *region_info,
+                                 u16 *cap_type_id, void **cap_type)
+{
+       struct mdev_state *mdev_state;
+
+       mdev_state = mdev_get_drvdata(mdev);
+       if (!mdev_state)
+               return -EINVAL;
+
+       if (region_info->index >= VFIO_PCI_NUM_REGIONS)
+               return -EINVAL;
+
+       switch (region_info->index) {
+       case VFIO_PCI_CONFIG_REGION_INDEX:
+               region_info->offset = 0;
+               region_info->size   = MBOCHS_CONFIG_SPACE_SIZE;
+               region_info->flags  = (VFIO_REGION_INFO_FLAG_READ |
+                                      VFIO_REGION_INFO_FLAG_WRITE);
+               break;
+       case VFIO_PCI_BAR0_REGION_INDEX:
+               region_info->offset = MBOCHS_MEMORY_BAR_OFFSET;
+               region_info->size   = mdev_state->memsize;
+               region_info->flags  = (VFIO_REGION_INFO_FLAG_READ  |
+                                      VFIO_REGION_INFO_FLAG_WRITE |
+                                      VFIO_REGION_INFO_FLAG_MMAP);
+               break;
+       case VFIO_PCI_BAR2_REGION_INDEX:
+               region_info->offset = MBOCHS_MMIO_BAR_OFFSET;
+               region_info->size   = MBOCHS_MMIO_BAR_SIZE;
+               region_info->flags  = (VFIO_REGION_INFO_FLAG_READ  |
+                                      VFIO_REGION_INFO_FLAG_WRITE);
+               break;
+       default:
+               region_info->size   = 0;
+               region_info->offset = 0;
+               region_info->flags  = 0;
+       }
+
+       return 0;
+}
+
+static int mbochs_get_irq_info(struct mdev_device *mdev,
+                              struct vfio_irq_info *irq_info)
+{
+       irq_info->count = 0;
+       return 0;
+}
+
+static int mbochs_get_device_info(struct mdev_device *mdev,
+                                 struct vfio_device_info *dev_info)
+{
+       dev_info->flags = VFIO_DEVICE_FLAGS_PCI;
+       dev_info->num_regions = VFIO_PCI_NUM_REGIONS;
+       dev_info->num_irqs = VFIO_PCI_NUM_IRQS;
+       return 0;
+}
+
+static int mbochs_query_gfx_plane(struct mdev_device *mdev,
+                                 struct vfio_device_gfx_plane_info *plane)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+       struct device *dev = mdev_dev(mdev);
+       struct mbochs_dmabuf *dmabuf;
+       struct mbochs_mode mode;
+       int ret;
+
+       if (plane->flags & VFIO_GFX_PLANE_TYPE_PROBE) {
+               if (plane->flags == (VFIO_GFX_PLANE_TYPE_PROBE |
+                                    VFIO_GFX_PLANE_TYPE_DMABUF))
+                       return 0;
+               return -EINVAL;
+       }
+
+       if (plane->flags != VFIO_GFX_PLANE_TYPE_DMABUF)
+               return -EINVAL;
+
+       plane->drm_format_mod = 0;
+       plane->x_pos          = 0;
+       plane->y_pos          = 0;
+       plane->x_hot          = 0;
+       plane->y_hot          = 0;
+
+       mutex_lock(&mdev_state->ops_lock);
+
+       ret = -EINVAL;
+       if (plane->drm_plane_type == DRM_PLANE_TYPE_PRIMARY)
+               ret = mbochs_check_framebuffer(mdev_state, &mode);
+       if (ret < 0) {
+               plane->drm_format     = 0;
+               plane->width          = 0;
+               plane->height         = 0;
+               plane->stride         = 0;
+               plane->size           = 0;
+               plane->dmabuf_id      = 0;
+               goto done;
+       }
+
+       dmabuf = mbochs_dmabuf_find_by_mode(mdev_state, &mode);
+       if (!dmabuf)
+               mbochs_dmabuf_alloc(mdev_state, &mode);
+       if (!dmabuf) {
+               mutex_unlock(&mdev_state->ops_lock);
+               return -ENOMEM;
+       }
+
+       plane->drm_format     = dmabuf->mode.drm_format;
+       plane->width          = dmabuf->mode.width;
+       plane->height         = dmabuf->mode.height;
+       plane->stride         = dmabuf->mode.stride;
+       plane->size           = dmabuf->mode.size;
+       plane->dmabuf_id      = dmabuf->id;
+
+done:
+       if (plane->drm_plane_type == DRM_PLANE_TYPE_PRIMARY &&
+           mdev_state->active_id != plane->dmabuf_id) {
+               dev_dbg(dev, "%s: primary: %d => %d\n", __func__,
+                       mdev_state->active_id, plane->dmabuf_id);
+               mdev_state->active_id = plane->dmabuf_id;
+       }
+       mutex_unlock(&mdev_state->ops_lock);
+       return 0;
+}
+
+static int mbochs_get_gfx_dmabuf(struct mdev_device *mdev,
+                                u32 id)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+       struct mbochs_dmabuf *dmabuf;
+
+       mutex_lock(&mdev_state->ops_lock);
+
+       dmabuf = mbochs_dmabuf_find_by_id(mdev_state, id);
+       if (!dmabuf) {
+               mutex_unlock(&mdev_state->ops_lock);
+               return -ENOENT;
+       }
+
+       if (!dmabuf->buf)
+               mbochs_dmabuf_export(dmabuf);
+
+       mutex_unlock(&mdev_state->ops_lock);
+
+       if (!dmabuf->buf)
+               return -EINVAL;
+
+       return dma_buf_fd(dmabuf->buf, 0);
+}
+
+static long mbochs_ioctl(struct mdev_device *mdev, unsigned int cmd,
+                       unsigned long arg)
+{
+       int ret = 0;
+       unsigned long minsz;
+       struct mdev_state *mdev_state;
+
+       mdev_state = mdev_get_drvdata(mdev);
+
+       switch (cmd) {
+       case VFIO_DEVICE_GET_INFO:
+       {
+               struct vfio_device_info info;
+
+               minsz = offsetofend(struct vfio_device_info, num_irqs);
+
+               if (copy_from_user(&info, (void __user *)arg, minsz))
+                       return -EFAULT;
+
+               if (info.argsz < minsz)
+                       return -EINVAL;
+
+               ret = mbochs_get_device_info(mdev, &info);
+               if (ret)
+                       return ret;
+
+               memcpy(&mdev_state->dev_info, &info, sizeof(info));
+
+               if (copy_to_user((void __user *)arg, &info, minsz))
+                       return -EFAULT;
+
+               return 0;
+       }
+       case VFIO_DEVICE_GET_REGION_INFO:
+       {
+               struct vfio_region_info info;
+               u16 cap_type_id = 0;
+               void *cap_type = NULL;
+
+               minsz = offsetofend(struct vfio_region_info, offset);
+
+               if (copy_from_user(&info, (void __user *)arg, minsz))
+                       return -EFAULT;
+
+               if (info.argsz < minsz)
+                       return -EINVAL;
+
+               ret = mbochs_get_region_info(mdev, &info, &cap_type_id,
+                                          &cap_type);
+               if (ret)
+                       return ret;
+
+               if (copy_to_user((void __user *)arg, &info, minsz))
+                       return -EFAULT;
+
+               return 0;
+       }
+
+       case VFIO_DEVICE_GET_IRQ_INFO:
+       {
+               struct vfio_irq_info info;
+
+               minsz = offsetofend(struct vfio_irq_info, count);
+
+               if (copy_from_user(&info, (void __user *)arg, minsz))
+                       return -EFAULT;
+
+               if ((info.argsz < minsz) ||
+                   (info.index >= mdev_state->dev_info.num_irqs))
+                       return -EINVAL;
+
+               ret = mbochs_get_irq_info(mdev, &info);
+               if (ret)
+                       return ret;
+
+               if (copy_to_user((void __user *)arg, &info, minsz))
+                       return -EFAULT;
+
+               return 0;
+       }
+
+       case VFIO_DEVICE_QUERY_GFX_PLANE:
+       {
+               struct vfio_device_gfx_plane_info plane;
+
+               minsz = offsetofend(struct vfio_device_gfx_plane_info,
+                                   region_index);
+
+               if (copy_from_user(&plane, (void __user *)arg, minsz))
+                       return -EFAULT;
+
+               if (plane.argsz < minsz)
+                       return -EINVAL;
+
+               ret = mbochs_query_gfx_plane(mdev, &plane);
+               if (ret)
+                       return ret;
+
+               if (copy_to_user((void __user *)arg, &plane, minsz))
+                       return -EFAULT;
+
+               return 0;
+       }
+
+       case VFIO_DEVICE_GET_GFX_DMABUF:
+       {
+               u32 dmabuf_id;
+
+               if (get_user(dmabuf_id, (__u32 __user *)arg))
+                       return -EFAULT;
+
+               return mbochs_get_gfx_dmabuf(mdev, dmabuf_id);
+       }
+
+       case VFIO_DEVICE_SET_IRQS:
+               return -EINVAL;
+
+       case VFIO_DEVICE_RESET:
+               return mbochs_reset(mdev);
+       }
+       return -ENOTTY;
+}
+
+static int mbochs_open(struct mdev_device *mdev)
+{
+       if (!try_module_get(THIS_MODULE))
+               return -ENODEV;
+
+       return 0;
+}
+
+static void mbochs_close(struct mdev_device *mdev)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+       struct mbochs_dmabuf *dmabuf, *tmp;
+
+       mutex_lock(&mdev_state->ops_lock);
+
+       list_for_each_entry_safe(dmabuf, tmp, &mdev_state->dmabufs, next) {
+               list_del(&dmabuf->next);
+               if (dmabuf->buf) {
+                       /* free in mbochs_release_dmabuf() */
+                       dmabuf->unlinked = true;
+               } else {
+                       kfree(dmabuf);
+               }
+       }
+       mbochs_put_pages(mdev_state);
+
+       mutex_unlock(&mdev_state->ops_lock);
+       module_put(THIS_MODULE);
+}
+
+static ssize_t
+memory_show(struct device *dev, struct device_attribute *attr,
+           char *buf)
+{
+       struct mdev_device *mdev = mdev_from_dev(dev);
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+
+       return sprintf(buf, "%d MB\n", mdev_state->type->mbytes);
+}
+static DEVICE_ATTR_RO(memory);
+
+static struct attribute *mdev_dev_attrs[] = {
+       &dev_attr_memory.attr,
+       NULL,
+};
+
+static const struct attribute_group mdev_dev_group = {
+       .name  = "vendor",
+       .attrs = mdev_dev_attrs,
+};
+
+const struct attribute_group *mdev_dev_groups[] = {
+       &mdev_dev_group,
+       NULL,
+};
+
+static ssize_t
+name_show(struct kobject *kobj, struct device *dev, char *buf)
+{
+       return sprintf(buf, "%s\n", kobj->name);
+}
+MDEV_TYPE_ATTR_RO(name);
+
+static ssize_t
+description_show(struct kobject *kobj, struct device *dev, char *buf)
+{
+       const struct mbochs_type *type = mbochs_find_type(kobj);
+
+       return sprintf(buf, "virtual display, %d MB video memory\n",
+                      type ? type->mbytes  : 0);
+}
+MDEV_TYPE_ATTR_RO(description);
+
+static ssize_t
+available_instances_show(struct kobject *kobj, struct device *dev, char *buf)
+{
+       const struct mbochs_type *type = mbochs_find_type(kobj);
+       int count = (max_mbytes - mbochs_used_mbytes) / type->mbytes;
+
+       return sprintf(buf, "%d\n", count);
+}
+MDEV_TYPE_ATTR_RO(available_instances);
+
+static ssize_t device_api_show(struct kobject *kobj, struct device *dev,
+                              char *buf)
+{
+       return sprintf(buf, "%s\n", VFIO_DEVICE_API_PCI_STRING);
+}
+MDEV_TYPE_ATTR_RO(device_api);
+
+static struct attribute *mdev_types_attrs[] = {
+       &mdev_type_attr_name.attr,
+       &mdev_type_attr_description.attr,
+       &mdev_type_attr_device_api.attr,
+       &mdev_type_attr_available_instances.attr,
+       NULL,
+};
+
+static struct attribute_group mdev_type_group1 = {
+       .name  = MBOCHS_TYPE_1,
+       .attrs = mdev_types_attrs,
+};
+
+static struct attribute_group mdev_type_group2 = {
+       .name  = MBOCHS_TYPE_2,
+       .attrs = mdev_types_attrs,
+};
+
+static struct attribute_group mdev_type_group3 = {
+       .name  = MBOCHS_TYPE_3,
+       .attrs = mdev_types_attrs,
+};
+
+static struct attribute_group *mdev_type_groups[] = {
+       &mdev_type_group1,
+       &mdev_type_group2,
+       &mdev_type_group3,
+       NULL,
+};
+
+static const struct mdev_parent_ops mdev_fops = {
+       .owner                  = THIS_MODULE,
+       .mdev_attr_groups       = mdev_dev_groups,
+       .supported_type_groups  = mdev_type_groups,
+       .create                 = mbochs_create,
+       .remove                 = mbochs_remove,
+       .open                   = mbochs_open,
+       .release                = mbochs_close,
+       .read                   = mbochs_read,
+       .write                  = mbochs_write,
+       .ioctl                  = mbochs_ioctl,
+       .mmap                   = mbochs_mmap,
+};
+
+static const struct file_operations vd_fops = {
+       .owner          = THIS_MODULE,
+};
+
+static void mbochs_device_release(struct device *dev)
+{
+       /* nothing */
+}
+
+static int __init mbochs_dev_init(void)
+{
+       int ret = 0;
+
+       ret = alloc_chrdev_region(&mbochs_devt, 0, MINORMASK, MBOCHS_NAME);
+       if (ret < 0) {
+               pr_err("Error: failed to register mbochs_dev, err: %d\n", ret);
+               return ret;
+       }
+       cdev_init(&mbochs_cdev, &vd_fops);
+       cdev_add(&mbochs_cdev, mbochs_devt, MINORMASK);
+       pr_info("%s: major %d\n", __func__, MAJOR(mbochs_devt));
+
+       mbochs_class = class_create(THIS_MODULE, MBOCHS_CLASS_NAME);
+       if (IS_ERR(mbochs_class)) {
+               pr_err("Error: failed to register mbochs_dev class\n");
+               ret = PTR_ERR(mbochs_class);
+               goto failed1;
+       }
+       mbochs_dev.class = mbochs_class;
+       mbochs_dev.release = mbochs_device_release;
+       dev_set_name(&mbochs_dev, "%s", MBOCHS_NAME);
+
+       ret = device_register(&mbochs_dev);
+       if (ret)
+               goto failed2;
+
+       ret = mdev_register_device(&mbochs_dev, &mdev_fops);
+       if (ret)
+               goto failed3;
+
+       return 0;
+
+failed3:
+       device_unregister(&mbochs_dev);
+failed2:
+       class_destroy(mbochs_class);
+failed1:
+       cdev_del(&mbochs_cdev);
+       unregister_chrdev_region(mbochs_devt, MINORMASK);
+       return ret;
+}
+
+static void __exit mbochs_dev_exit(void)
+{
+       mbochs_dev.bus = NULL;
+       mdev_unregister_device(&mbochs_dev);
+
+       device_unregister(&mbochs_dev);
+       cdev_del(&mbochs_cdev);
+       unregister_chrdev_region(mbochs_devt, MINORMASK);
+       class_destroy(mbochs_class);
+       mbochs_class = NULL;
+}
+
+module_init(mbochs_dev_init)
+module_exit(mbochs_dev_exit)
diff --git a/samples/vfio-mdev/mdpy-defs.h b/samples/vfio-mdev/mdpy-defs.h
new file mode 100644 (file)
index 0000000..96b3b1b
--- /dev/null
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Simple pci display device.
+ *
+ * Framebuffer memory is pci bar 0.
+ * Configuration (read-only) is in pci config space.
+ * Format field uses drm fourcc codes.
+ * ATM only DRM_FORMAT_XRGB8888 is supported.
+ */
+
+/* pci ids */
+#define MDPY_PCI_VENDOR_ID     0x1b36 /* redhat */
+#define MDPY_PCI_DEVICE_ID     0x000f
+#define MDPY_PCI_SUBVENDOR_ID  PCI_SUBVENDOR_ID_REDHAT_QUMRANET
+#define MDPY_PCI_SUBDEVICE_ID  PCI_SUBDEVICE_ID_QEMU
+
+/* pci cfg space offsets for fb config (dword) */
+#define MDPY_VENDORCAP_OFFSET   0x40
+#define MDPY_VENDORCAP_SIZE     0x10
+#define MDPY_FORMAT_OFFSET     (MDPY_VENDORCAP_OFFSET + 0x04)
+#define MDPY_WIDTH_OFFSET      (MDPY_VENDORCAP_OFFSET + 0x08)
+#define MDPY_HEIGHT_OFFSET     (MDPY_VENDORCAP_OFFSET + 0x0c)
diff --git a/samples/vfio-mdev/mdpy-fb.c b/samples/vfio-mdev/mdpy-fb.c
new file mode 100644 (file)
index 0000000..2719bb2
--- /dev/null
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Framebuffer driver for mdpy (mediated virtual pci display device).
+ *
+ * See mdpy-defs.h for device specs
+ *
+ *   (c) Gerd Hoffmann <kraxel@redhat.com>
+ *
+ * Using some code snippets from simplefb and cirrusfb.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+#include <linux/errno.h>
+#include <linux/fb.h>
+#include <linux/io.h>
+#include <linux/pci.h>
+#include <linux/module.h>
+#include <drm/drm_fourcc.h>
+#include "mdpy-defs.h"
+
+static const struct fb_fix_screeninfo mdpy_fb_fix = {
+       .id             = "mdpy-fb",
+       .type           = FB_TYPE_PACKED_PIXELS,
+       .visual         = FB_VISUAL_TRUECOLOR,
+       .accel          = FB_ACCEL_NONE,
+};
+
+static const struct fb_var_screeninfo mdpy_fb_var = {
+       .height         = -1,
+       .width          = -1,
+       .activate       = FB_ACTIVATE_NOW,
+       .vmode          = FB_VMODE_NONINTERLACED,
+
+       .bits_per_pixel = 32,
+       .transp.offset  = 24,
+       .red.offset     = 16,
+       .green.offset   = 8,
+       .blue.offset    = 0,
+       .transp.length  = 8,
+       .red.length     = 8,
+       .green.length   = 8,
+       .blue.length    = 8,
+};
+
+#define PSEUDO_PALETTE_SIZE 16
+
+struct mdpy_fb_par {
+       u32 palette[PSEUDO_PALETTE_SIZE];
+};
+
+static int mdpy_fb_setcolreg(u_int regno, u_int red, u_int green, u_int blue,
+                             u_int transp, struct fb_info *info)
+{
+       u32 *pal = info->pseudo_palette;
+       u32 cr = red >> (16 - info->var.red.length);
+       u32 cg = green >> (16 - info->var.green.length);
+       u32 cb = blue >> (16 - info->var.blue.length);
+       u32 value, mask;
+
+       if (regno >= PSEUDO_PALETTE_SIZE)
+               return -EINVAL;
+
+       value = (cr << info->var.red.offset) |
+               (cg << info->var.green.offset) |
+               (cb << info->var.blue.offset);
+       if (info->var.transp.length > 0) {
+               mask = (1 << info->var.transp.length) - 1;
+               mask <<= info->var.transp.offset;
+               value |= mask;
+       }
+       pal[regno] = value;
+
+       return 0;
+}
+
+static void mdpy_fb_destroy(struct fb_info *info)
+{
+       if (info->screen_base)
+               iounmap(info->screen_base);
+}
+
+static struct fb_ops mdpy_fb_ops = {
+       .owner          = THIS_MODULE,
+       .fb_destroy     = mdpy_fb_destroy,
+       .fb_setcolreg   = mdpy_fb_setcolreg,
+       .fb_fillrect    = cfb_fillrect,
+       .fb_copyarea    = cfb_copyarea,
+       .fb_imageblit   = cfb_imageblit,
+};
+
+static int mdpy_fb_probe(struct pci_dev *pdev,
+                        const struct pci_device_id *ent)
+{
+       struct fb_info *info;
+       struct mdpy_fb_par *par;
+       u32 format, width, height;
+       int ret;
+
+       ret = pci_enable_device(pdev);
+       if (ret < 0)
+               return ret;
+
+       ret = pci_request_regions(pdev, "mdpy-fb");
+       if (ret < 0)
+               return ret;
+
+       pci_read_config_dword(pdev, MDPY_FORMAT_OFFSET, &format);
+       pci_read_config_dword(pdev, MDPY_WIDTH_OFFSET,  &width);
+       pci_read_config_dword(pdev, MDPY_HEIGHT_OFFSET, &height);
+       if (format != DRM_FORMAT_XRGB8888) {
+               pci_err(pdev, "format mismatch (0x%x != 0x%x)\n",
+                       format, DRM_FORMAT_XRGB8888);
+               return -EINVAL;
+       }
+       if (width < 100  || width > 10000) {
+               pci_err(pdev, "width (%d) out of range\n", width);
+               return -EINVAL;
+       }
+       if (height < 100 || height > 10000) {
+               pci_err(pdev, "height (%d) out of range\n", height);
+               return -EINVAL;
+       }
+       pci_info(pdev, "mdpy found: %dx%d framebuffer\n",
+                width, height);
+
+       info = framebuffer_alloc(sizeof(struct mdpy_fb_par), &pdev->dev);
+       if (!info)
+               goto err_release_regions;
+       pci_set_drvdata(pdev, info);
+       par = info->par;
+
+       info->fix = mdpy_fb_fix;
+       info->fix.smem_start = pci_resource_start(pdev, 0);
+       info->fix.smem_len = pci_resource_len(pdev, 0);
+       info->fix.line_length = width * 4;
+
+       info->var = mdpy_fb_var;
+       info->var.xres = width;
+       info->var.yres = height;
+       info->var.xres_virtual = width;
+       info->var.yres_virtual = height;
+
+       info->screen_size = info->fix.smem_len;
+       info->screen_base = ioremap(info->fix.smem_start,
+                                   info->screen_size);
+       if (!info->screen_base) {
+               pci_err(pdev, "ioremap(pcibar) failed\n");
+               ret = -EIO;
+               goto err_release_fb;
+       }
+
+       info->apertures = alloc_apertures(1);
+       if (!info->apertures) {
+               ret = -ENOMEM;
+               goto err_unmap;
+       }
+       info->apertures->ranges[0].base = info->fix.smem_start;
+       info->apertures->ranges[0].size = info->fix.smem_len;
+
+       info->fbops = &mdpy_fb_ops;
+       info->flags = FBINFO_DEFAULT;
+       info->pseudo_palette = par->palette;
+
+       ret = register_framebuffer(info);
+       if (ret < 0) {
+               pci_err(pdev, "mdpy-fb device register failed: %d\n", ret);
+               goto err_unmap;
+       }
+
+       pci_info(pdev, "fb%d registered\n", info->node);
+       return 0;
+
+err_unmap:
+       iounmap(info->screen_base);
+
+err_release_fb:
+       framebuffer_release(info);
+
+err_release_regions:
+       pci_release_regions(pdev);
+
+       return ret;
+}
+
+static void mdpy_fb_remove(struct pci_dev *pdev)
+{
+       struct fb_info *info = pci_get_drvdata(pdev);
+
+       unregister_framebuffer(info);
+       framebuffer_release(info);
+}
+
+static struct pci_device_id mdpy_fb_pci_table[] = {
+       {
+               .vendor    = MDPY_PCI_VENDOR_ID,
+               .device    = MDPY_PCI_DEVICE_ID,
+               .subvendor = MDPY_PCI_SUBVENDOR_ID,
+               .subdevice = MDPY_PCI_SUBDEVICE_ID,
+       }, {
+               /* end of list */
+       }
+};
+
+static struct pci_driver mdpy_fb_pci_driver = {
+       .name           = "mdpy-fb",
+       .id_table       = mdpy_fb_pci_table,
+       .probe          = mdpy_fb_probe,
+       .remove         = mdpy_fb_remove,
+};
+
+static int __init mdpy_fb_init(void)
+{
+       int ret;
+
+       ret = pci_register_driver(&mdpy_fb_pci_driver);
+       if (ret)
+               return ret;
+
+       return 0;
+}
+
+module_init(mdpy_fb_init);
+
+MODULE_DEVICE_TABLE(pci, mdpy_fb_pci_table);
+MODULE_LICENSE("GPL v2");
diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c
new file mode 100644 (file)
index 0000000..96e7969
--- /dev/null
@@ -0,0 +1,807 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Mediated virtual PCI display host device driver
+ *
+ * See mdpy-defs.h for device specs
+ *
+ *   (c) Gerd Hoffmann <kraxel@redhat.com>
+ *
+ * based on mtty driver which is:
+ *   Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved.
+ *      Author: Neo Jia <cjia@nvidia.com>
+ *              Kirti Wankhede <kwankhede@nvidia.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/init.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+#include <linux/cdev.h>
+#include <linux/vfio.h>
+#include <linux/iommu.h>
+#include <linux/sysfs.h>
+#include <linux/mdev.h>
+#include <linux/pci.h>
+#include <drm/drm_fourcc.h>
+#include "mdpy-defs.h"
+
+#define MDPY_NAME              "mdpy"
+#define MDPY_CLASS_NAME                "mdpy"
+
+#define MDPY_CONFIG_SPACE_SIZE 0xff
+#define MDPY_MEMORY_BAR_OFFSET PAGE_SIZE
+#define MDPY_DISPLAY_REGION    16
+
+#define STORE_LE16(addr, val)  (*(u16 *)addr = val)
+#define STORE_LE32(addr, val)  (*(u32 *)addr = val)
+
+
+MODULE_LICENSE("GPL v2");
+
+static int max_devices = 4;
+module_param_named(count, max_devices, int, 0444);
+MODULE_PARM_DESC(count, "number of " MDPY_NAME " devices");
+
+
+#define MDPY_TYPE_1 "vga"
+#define MDPY_TYPE_2 "xga"
+#define MDPY_TYPE_3 "hd"
+
+static const struct mdpy_type {
+       const char *name;
+       u32 format;
+       u32 bytepp;
+       u32 width;
+       u32 height;
+} mdpy_types[] = {
+       {
+               .name   = MDPY_CLASS_NAME "-" MDPY_TYPE_1,
+               .format = DRM_FORMAT_XRGB8888,
+               .bytepp = 4,
+               .width  = 640,
+               .height = 480,
+       }, {
+               .name   = MDPY_CLASS_NAME "-" MDPY_TYPE_2,
+               .format = DRM_FORMAT_XRGB8888,
+               .bytepp = 4,
+               .width  = 1024,
+               .height = 768,
+       }, {
+               .name   = MDPY_CLASS_NAME "-" MDPY_TYPE_3,
+               .format = DRM_FORMAT_XRGB8888,
+               .bytepp = 4,
+               .width  = 1920,
+               .height = 1080,
+       },
+};
+
+static dev_t           mdpy_devt;
+static struct class    *mdpy_class;
+static struct cdev     mdpy_cdev;
+static struct device   mdpy_dev;
+static u32             mdpy_count;
+
+/* State of each mdev device */
+struct mdev_state {
+       u8 *vconfig;
+       u32 bar_mask;
+       struct mutex ops_lock;
+       struct mdev_device *mdev;
+       struct vfio_device_info dev_info;
+
+       const struct mdpy_type *type;
+       u32 memsize;
+       void *memblk;
+};
+
+static const struct mdpy_type *mdpy_find_type(struct kobject *kobj)
+{
+       int i;
+
+       for (i = 0; i < ARRAY_SIZE(mdpy_types); i++)
+               if (strcmp(mdpy_types[i].name, kobj->name) == 0)
+                       return mdpy_types + i;
+       return NULL;
+}
+
+static void mdpy_create_config_space(struct mdev_state *mdev_state)
+{
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_VENDOR_ID],
+                  MDPY_PCI_VENDOR_ID);
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_DEVICE_ID],
+                  MDPY_PCI_DEVICE_ID);
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_SUBSYSTEM_VENDOR_ID],
+                  MDPY_PCI_SUBVENDOR_ID);
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_SUBSYSTEM_ID],
+                  MDPY_PCI_SUBDEVICE_ID);
+
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_COMMAND],
+                  PCI_COMMAND_IO | PCI_COMMAND_MEMORY);
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_STATUS],
+                  PCI_STATUS_CAP_LIST);
+       STORE_LE16((u16 *) &mdev_state->vconfig[PCI_CLASS_DEVICE],
+                  PCI_CLASS_DISPLAY_OTHER);
+       mdev_state->vconfig[PCI_CLASS_REVISION] =  0x01;
+
+       STORE_LE32((u32 *) &mdev_state->vconfig[PCI_BASE_ADDRESS_0],
+                  PCI_BASE_ADDRESS_SPACE_MEMORY |
+                  PCI_BASE_ADDRESS_MEM_TYPE_32  |
+                  PCI_BASE_ADDRESS_MEM_PREFETCH);
+       mdev_state->bar_mask = ~(mdev_state->memsize) + 1;
+
+       /* vendor specific capability for the config registers */
+       mdev_state->vconfig[PCI_CAPABILITY_LIST]       = MDPY_VENDORCAP_OFFSET;
+       mdev_state->vconfig[MDPY_VENDORCAP_OFFSET + 0] = 0x09; /* vendor cap */
+       mdev_state->vconfig[MDPY_VENDORCAP_OFFSET + 1] = 0x00; /* next ptr */
+       mdev_state->vconfig[MDPY_VENDORCAP_OFFSET + 2] = MDPY_VENDORCAP_SIZE;
+       STORE_LE32((u32 *) &mdev_state->vconfig[MDPY_FORMAT_OFFSET],
+                  mdev_state->type->format);
+       STORE_LE32((u32 *) &mdev_state->vconfig[MDPY_WIDTH_OFFSET],
+                  mdev_state->type->width);
+       STORE_LE32((u32 *) &mdev_state->vconfig[MDPY_HEIGHT_OFFSET],
+                  mdev_state->type->height);
+}
+
+static void handle_pci_cfg_write(struct mdev_state *mdev_state, u16 offset,
+                                char *buf, u32 count)
+{
+       struct device *dev = mdev_dev(mdev_state->mdev);
+       u32 cfg_addr;
+
+       switch (offset) {
+       case PCI_BASE_ADDRESS_0:
+               cfg_addr = *(u32 *)buf;
+
+               if (cfg_addr == 0xffffffff) {
+                       cfg_addr = (cfg_addr & mdev_state->bar_mask);
+               } else {
+                       cfg_addr &= PCI_BASE_ADDRESS_MEM_MASK;
+                       if (cfg_addr)
+                               dev_info(dev, "BAR0 @ 0x%x\n", cfg_addr);
+               }
+
+               cfg_addr |= (mdev_state->vconfig[offset] &
+                            ~PCI_BASE_ADDRESS_MEM_MASK);
+               STORE_LE32(&mdev_state->vconfig[offset], cfg_addr);
+               break;
+       }
+}
+
+static ssize_t mdev_access(struct mdev_device *mdev, char *buf, size_t count,
+                          loff_t pos, bool is_write)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+       struct device *dev = mdev_dev(mdev);
+       int ret = 0;
+
+       mutex_lock(&mdev_state->ops_lock);
+
+       if (pos < MDPY_CONFIG_SPACE_SIZE) {
+               if (is_write)
+                       handle_pci_cfg_write(mdev_state, pos, buf, count);
+               else
+                       memcpy(buf, (mdev_state->vconfig + pos), count);
+
+       } else if ((pos >= MDPY_MEMORY_BAR_OFFSET) &&
+                  (pos + count <=
+                   MDPY_MEMORY_BAR_OFFSET + mdev_state->memsize)) {
+               pos -= MDPY_MEMORY_BAR_OFFSET;
+               if (is_write)
+                       memcpy(mdev_state->memblk, buf, count);
+               else
+                       memcpy(buf, mdev_state->memblk, count);
+
+       } else {
+               dev_info(dev, "%s: %s @0x%llx (unhandled)\n",
+                        __func__, is_write ? "WR" : "RD", pos);
+               ret = -1;
+               goto accessfailed;
+       }
+
+       ret = count;
+
+
+accessfailed:
+       mutex_unlock(&mdev_state->ops_lock);
+
+       return ret;
+}
+
+static int mdpy_reset(struct mdev_device *mdev)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+       u32 stride, i;
+
+       /* initialize with gray gradient */
+       stride = mdev_state->type->width * mdev_state->type->bytepp;
+       for (i = 0; i < mdev_state->type->height; i++)
+               memset(mdev_state->memblk + i * stride,
+                      i * 255 / mdev_state->type->height,
+                      stride);
+       return 0;
+}
+
+static int mdpy_create(struct kobject *kobj, struct mdev_device *mdev)
+{
+       const struct mdpy_type *type = mdpy_find_type(kobj);
+       struct device *dev = mdev_dev(mdev);
+       struct mdev_state *mdev_state;
+       u32 fbsize;
+
+       if (mdpy_count >= max_devices)
+               return -ENOMEM;
+
+       mdev_state = kzalloc(sizeof(struct mdev_state), GFP_KERNEL);
+       if (mdev_state == NULL)
+               return -ENOMEM;
+
+       mdev_state->vconfig = kzalloc(MDPY_CONFIG_SPACE_SIZE, GFP_KERNEL);
+       if (mdev_state->vconfig == NULL) {
+               kfree(mdev_state);
+               return -ENOMEM;
+       }
+
+       if (!type)
+               type = &mdpy_types[0];
+       fbsize = roundup_pow_of_two(type->width * type->height * type->bytepp);
+
+       mdev_state->memblk = vmalloc_user(fbsize);
+       if (!mdev_state->memblk) {
+               kfree(mdev_state->vconfig);
+               kfree(mdev_state);
+               return -ENOMEM;
+       }
+       dev_info(dev, "%s: %s (%dx%d)\n",
+                __func__, kobj->name, type->width, type->height);
+
+       mutex_init(&mdev_state->ops_lock);
+       mdev_state->mdev = mdev;
+       mdev_set_drvdata(mdev, mdev_state);
+
+       mdev_state->type    = type;
+       mdev_state->memsize = fbsize;
+       mdpy_create_config_space(mdev_state);
+       mdpy_reset(mdev);
+
+       mdpy_count++;
+       return 0;
+}
+
+static int mdpy_remove(struct mdev_device *mdev)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+       struct device *dev = mdev_dev(mdev);
+
+       dev_info(dev, "%s\n", __func__);
+
+       mdev_set_drvdata(mdev, NULL);
+       vfree(mdev_state->memblk);
+       kfree(mdev_state->vconfig);
+       kfree(mdev_state);
+
+       mdpy_count--;
+       return 0;
+}
+
+static ssize_t mdpy_read(struct mdev_device *mdev, char __user *buf,
+                        size_t count, loff_t *ppos)
+{
+       unsigned int done = 0;
+       int ret;
+
+       while (count) {
+               size_t filled;
+
+               if (count >= 4 && !(*ppos % 4)) {
+                       u32 val;
+
+                       ret =  mdev_access(mdev, (char *)&val, sizeof(val),
+                                          *ppos, false);
+                       if (ret <= 0)
+                               goto read_err;
+
+                       if (copy_to_user(buf, &val, sizeof(val)))
+                               goto read_err;
+
+                       filled = 4;
+               } else if (count >= 2 && !(*ppos % 2)) {
+                       u16 val;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, false);
+                       if (ret <= 0)
+                               goto read_err;
+
+                       if (copy_to_user(buf, &val, sizeof(val)))
+                               goto read_err;
+
+                       filled = 2;
+               } else {
+                       u8 val;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, false);
+                       if (ret <= 0)
+                               goto read_err;
+
+                       if (copy_to_user(buf, &val, sizeof(val)))
+                               goto read_err;
+
+                       filled = 1;
+               }
+
+               count -= filled;
+               done += filled;
+               *ppos += filled;
+               buf += filled;
+       }
+
+       return done;
+
+read_err:
+       return -EFAULT;
+}
+
+static ssize_t mdpy_write(struct mdev_device *mdev, const char __user *buf,
+                         size_t count, loff_t *ppos)
+{
+       unsigned int done = 0;
+       int ret;
+
+       while (count) {
+               size_t filled;
+
+               if (count >= 4 && !(*ppos % 4)) {
+                       u32 val;
+
+                       if (copy_from_user(&val, buf, sizeof(val)))
+                               goto write_err;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, true);
+                       if (ret <= 0)
+                               goto write_err;
+
+                       filled = 4;
+               } else if (count >= 2 && !(*ppos % 2)) {
+                       u16 val;
+
+                       if (copy_from_user(&val, buf, sizeof(val)))
+                               goto write_err;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, true);
+                       if (ret <= 0)
+                               goto write_err;
+
+                       filled = 2;
+               } else {
+                       u8 val;
+
+                       if (copy_from_user(&val, buf, sizeof(val)))
+                               goto write_err;
+
+                       ret = mdev_access(mdev, (char *)&val, sizeof(val),
+                                         *ppos, true);
+                       if (ret <= 0)
+                               goto write_err;
+
+                       filled = 1;
+               }
+               count -= filled;
+               done += filled;
+               *ppos += filled;
+               buf += filled;
+       }
+
+       return done;
+write_err:
+       return -EFAULT;
+}
+
+static int mdpy_mmap(struct mdev_device *mdev, struct vm_area_struct *vma)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+
+       if (vma->vm_pgoff != MDPY_MEMORY_BAR_OFFSET >> PAGE_SHIFT)
+               return -EINVAL;
+       if (vma->vm_end < vma->vm_start)
+               return -EINVAL;
+       if (vma->vm_end - vma->vm_start > mdev_state->memsize)
+               return -EINVAL;
+       if ((vma->vm_flags & VM_SHARED) == 0)
+               return -EINVAL;
+
+       return remap_vmalloc_range_partial(vma, vma->vm_start,
+                                          mdev_state->memblk,
+                                          vma->vm_end - vma->vm_start);
+}
+
+static int mdpy_get_region_info(struct mdev_device *mdev,
+                               struct vfio_region_info *region_info,
+                               u16 *cap_type_id, void **cap_type)
+{
+       struct mdev_state *mdev_state;
+
+       mdev_state = mdev_get_drvdata(mdev);
+       if (!mdev_state)
+               return -EINVAL;
+
+       if (region_info->index >= VFIO_PCI_NUM_REGIONS &&
+           region_info->index != MDPY_DISPLAY_REGION)
+               return -EINVAL;
+
+       switch (region_info->index) {
+       case VFIO_PCI_CONFIG_REGION_INDEX:
+               region_info->offset = 0;
+               region_info->size   = MDPY_CONFIG_SPACE_SIZE;
+               region_info->flags  = (VFIO_REGION_INFO_FLAG_READ |
+                                      VFIO_REGION_INFO_FLAG_WRITE);
+               break;
+       case VFIO_PCI_BAR0_REGION_INDEX:
+       case MDPY_DISPLAY_REGION:
+               region_info->offset = MDPY_MEMORY_BAR_OFFSET;
+               region_info->size   = mdev_state->memsize;
+               region_info->flags  = (VFIO_REGION_INFO_FLAG_READ  |
+                                      VFIO_REGION_INFO_FLAG_WRITE |
+                                      VFIO_REGION_INFO_FLAG_MMAP);
+               break;
+       default:
+               region_info->size   = 0;
+               region_info->offset = 0;
+               region_info->flags  = 0;
+       }
+
+       return 0;
+}
+
+static int mdpy_get_irq_info(struct mdev_device *mdev,
+                            struct vfio_irq_info *irq_info)
+{
+       irq_info->count = 0;
+       return 0;
+}
+
+static int mdpy_get_device_info(struct mdev_device *mdev,
+                               struct vfio_device_info *dev_info)
+{
+       dev_info->flags = VFIO_DEVICE_FLAGS_PCI;
+       dev_info->num_regions = VFIO_PCI_NUM_REGIONS;
+       dev_info->num_irqs = VFIO_PCI_NUM_IRQS;
+       return 0;
+}
+
+static int mdpy_query_gfx_plane(struct mdev_device *mdev,
+                               struct vfio_device_gfx_plane_info *plane)
+{
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+
+       if (plane->flags & VFIO_GFX_PLANE_TYPE_PROBE) {
+               if (plane->flags == (VFIO_GFX_PLANE_TYPE_PROBE |
+                                    VFIO_GFX_PLANE_TYPE_REGION))
+                       return 0;
+               return -EINVAL;
+       }
+
+       if (plane->flags != VFIO_GFX_PLANE_TYPE_REGION)
+               return -EINVAL;
+
+       plane->drm_format     = mdev_state->type->format;
+       plane->width          = mdev_state->type->width;
+       plane->height         = mdev_state->type->height;
+       plane->stride         = (mdev_state->type->width *
+                                mdev_state->type->bytepp);
+       plane->size           = mdev_state->memsize;
+       plane->region_index   = MDPY_DISPLAY_REGION;
+
+       /* unused */
+       plane->drm_format_mod = 0;
+       plane->x_pos          = 0;
+       plane->y_pos          = 0;
+       plane->x_hot          = 0;
+       plane->y_hot          = 0;
+
+       return 0;
+}
+
+static long mdpy_ioctl(struct mdev_device *mdev, unsigned int cmd,
+                      unsigned long arg)
+{
+       int ret = 0;
+       unsigned long minsz;
+       struct mdev_state *mdev_state;
+
+       mdev_state = mdev_get_drvdata(mdev);
+
+       switch (cmd) {
+       case VFIO_DEVICE_GET_INFO:
+       {
+               struct vfio_device_info info;
+
+               minsz = offsetofend(struct vfio_device_info, num_irqs);
+
+               if (copy_from_user(&info, (void __user *)arg, minsz))
+                       return -EFAULT;
+
+               if (info.argsz < minsz)
+                       return -EINVAL;
+
+               ret = mdpy_get_device_info(mdev, &info);
+               if (ret)
+                       return ret;
+
+               memcpy(&mdev_state->dev_info, &info, sizeof(info));
+
+               if (copy_to_user((void __user *)arg, &info, minsz))
+                       return -EFAULT;
+
+               return 0;
+       }
+       case VFIO_DEVICE_GET_REGION_INFO:
+       {
+               struct vfio_region_info info;
+               u16 cap_type_id = 0;
+               void *cap_type = NULL;
+
+               minsz = offsetofend(struct vfio_region_info, offset);
+
+               if (copy_from_user(&info, (void __user *)arg, minsz))
+                       return -EFAULT;
+
+               if (info.argsz < minsz)
+                       return -EINVAL;
+
+               ret = mdpy_get_region_info(mdev, &info, &cap_type_id,
+                                          &cap_type);
+               if (ret)
+                       return ret;
+
+               if (copy_to_user((void __user *)arg, &info, minsz))
+                       return -EFAULT;
+
+               return 0;
+       }
+
+       case VFIO_DEVICE_GET_IRQ_INFO:
+       {
+               struct vfio_irq_info info;
+
+               minsz = offsetofend(struct vfio_irq_info, count);
+
+               if (copy_from_user(&info, (void __user *)arg, minsz))
+                       return -EFAULT;
+
+               if ((info.argsz < minsz) ||
+                   (info.index >= mdev_state->dev_info.num_irqs))
+                       return -EINVAL;
+
+               ret = mdpy_get_irq_info(mdev, &info);
+               if (ret)
+                       return ret;
+
+               if (copy_to_user((void __user *)arg, &info, minsz))
+                       return -EFAULT;
+
+               return 0;
+       }
+
+       case VFIO_DEVICE_QUERY_GFX_PLANE:
+       {
+               struct vfio_device_gfx_plane_info plane;
+
+               minsz = offsetofend(struct vfio_device_gfx_plane_info,
+                                   region_index);
+
+               if (copy_from_user(&plane, (void __user *)arg, minsz))
+                       return -EFAULT;
+
+               if (plane.argsz < minsz)
+                       return -EINVAL;
+
+               ret = mdpy_query_gfx_plane(mdev, &plane);
+               if (ret)
+                       return ret;
+
+               if (copy_to_user((void __user *)arg, &plane, minsz))
+                       return -EFAULT;
+
+               return 0;
+       }
+
+       case VFIO_DEVICE_SET_IRQS:
+               return -EINVAL;
+
+       case VFIO_DEVICE_RESET:
+               return mdpy_reset(mdev);
+       }
+       return -ENOTTY;
+}
+
+static int mdpy_open(struct mdev_device *mdev)
+{
+       if (!try_module_get(THIS_MODULE))
+               return -ENODEV;
+
+       return 0;
+}
+
+static void mdpy_close(struct mdev_device *mdev)
+{
+       module_put(THIS_MODULE);
+}
+
+static ssize_t
+resolution_show(struct device *dev, struct device_attribute *attr,
+               char *buf)
+{
+       struct mdev_device *mdev = mdev_from_dev(dev);
+       struct mdev_state *mdev_state = mdev_get_drvdata(mdev);
+
+       return sprintf(buf, "%dx%d\n",
+                      mdev_state->type->width,
+                      mdev_state->type->height);
+}
+static DEVICE_ATTR_RO(resolution);
+
+static struct attribute *mdev_dev_attrs[] = {
+       &dev_attr_resolution.attr,
+       NULL,
+};
+
+static const struct attribute_group mdev_dev_group = {
+       .name  = "vendor",
+       .attrs = mdev_dev_attrs,
+};
+
+const struct attribute_group *mdev_dev_groups[] = {
+       &mdev_dev_group,
+       NULL,
+};
+
+static ssize_t
+name_show(struct kobject *kobj, struct device *dev, char *buf)
+{
+       return sprintf(buf, "%s\n", kobj->name);
+}
+MDEV_TYPE_ATTR_RO(name);
+
+static ssize_t
+description_show(struct kobject *kobj, struct device *dev, char *buf)
+{
+       const struct mdpy_type *type = mdpy_find_type(kobj);
+
+       return sprintf(buf, "virtual display, %dx%d framebuffer\n",
+                      type ? type->width  : 0,
+                      type ? type->height : 0);
+}
+MDEV_TYPE_ATTR_RO(description);
+
+static ssize_t
+available_instances_show(struct kobject *kobj, struct device *dev, char *buf)
+{
+       return sprintf(buf, "%d\n", max_devices - mdpy_count);
+}
+MDEV_TYPE_ATTR_RO(available_instances);
+
+static ssize_t device_api_show(struct kobject *kobj, struct device *dev,
+                              char *buf)
+{
+       return sprintf(buf, "%s\n", VFIO_DEVICE_API_PCI_STRING);
+}
+MDEV_TYPE_ATTR_RO(device_api);
+
+static struct attribute *mdev_types_attrs[] = {
+       &mdev_type_attr_name.attr,
+       &mdev_type_attr_description.attr,
+       &mdev_type_attr_device_api.attr,
+       &mdev_type_attr_available_instances.attr,
+       NULL,
+};
+
+static struct attribute_group mdev_type_group1 = {
+       .name  = MDPY_TYPE_1,
+       .attrs = mdev_types_attrs,
+};
+
+static struct attribute_group mdev_type_group2 = {
+       .name  = MDPY_TYPE_2,
+       .attrs = mdev_types_attrs,
+};
+
+static struct attribute_group mdev_type_group3 = {
+       .name  = MDPY_TYPE_3,
+       .attrs = mdev_types_attrs,
+};
+
+static struct attribute_group *mdev_type_groups[] = {
+       &mdev_type_group1,
+       &mdev_type_group2,
+       &mdev_type_group3,
+       NULL,
+};
+
+static const struct mdev_parent_ops mdev_fops = {
+       .owner                  = THIS_MODULE,
+       .mdev_attr_groups       = mdev_dev_groups,
+       .supported_type_groups  = mdev_type_groups,
+       .create                 = mdpy_create,
+       .remove                 = mdpy_remove,
+       .open                   = mdpy_open,
+       .release                = mdpy_close,
+       .read                   = mdpy_read,
+       .write                  = mdpy_write,
+       .ioctl                  = mdpy_ioctl,
+       .mmap                   = mdpy_mmap,
+};
+
+static const struct file_operations vd_fops = {
+       .owner          = THIS_MODULE,
+};
+
+static void mdpy_device_release(struct device *dev)
+{
+       /* nothing */
+}
+
+static int __init mdpy_dev_init(void)
+{
+       int ret = 0;
+
+       ret = alloc_chrdev_region(&mdpy_devt, 0, MINORMASK, MDPY_NAME);
+       if (ret < 0) {
+               pr_err("Error: failed to register mdpy_dev, err: %d\n", ret);
+               return ret;
+       }
+       cdev_init(&mdpy_cdev, &vd_fops);
+       cdev_add(&mdpy_cdev, mdpy_devt, MINORMASK);
+       pr_info("%s: major %d\n", __func__, MAJOR(mdpy_devt));
+
+       mdpy_class = class_create(THIS_MODULE, MDPY_CLASS_NAME);
+       if (IS_ERR(mdpy_class)) {
+               pr_err("Error: failed to register mdpy_dev class\n");
+               ret = PTR_ERR(mdpy_class);
+               goto failed1;
+       }
+       mdpy_dev.class = mdpy_class;
+       mdpy_dev.release = mdpy_device_release;
+       dev_set_name(&mdpy_dev, "%s", MDPY_NAME);
+
+       ret = device_register(&mdpy_dev);
+       if (ret)
+               goto failed2;
+
+       ret = mdev_register_device(&mdpy_dev, &mdev_fops);
+       if (ret)
+               goto failed3;
+
+       return 0;
+
+failed3:
+       device_unregister(&mdpy_dev);
+failed2:
+       class_destroy(mdpy_class);
+failed1:
+       cdev_del(&mdpy_cdev);
+       unregister_chrdev_region(mdpy_devt, MINORMASK);
+       return ret;
+}
+
+static void __exit mdpy_dev_exit(void)
+{
+       mdpy_dev.bus = NULL;
+       mdev_unregister_device(&mdpy_dev);
+
+       device_unregister(&mdpy_dev);
+       cdev_del(&mdpy_cdev);
+       unregister_chrdev_region(mdpy_devt, MINORMASK);
+       class_destroy(mdpy_class);
+       mdpy_class = NULL;
+}
+
+module_init(mdpy_dev_init)
+module_exit(mdpy_dev_exit)
index bf7c0c9fa3a49d1ac45b41ffd4746b352b76a5c4..dad5583451afba96b2de211309fa898c9e69eb3e 100644 (file)
@@ -25,3 +25,6 @@ cc-option = $(success,$(CC) -Werror $(1) -E -x c /dev/null -o /dev/null)
 # $(ld-option,<flag>)
 # Return y if the linker supports <flag>, n otherwise
 ld-option = $(success,$(LD) -v $(1))
+
+# gcc version including patch level
+gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh -p $(CC) | sed 's/^0*//')
index 7f5c862461383c0d067f9ab017dd56b8cde390f4..c961b9a65d11ac7954b2a5a3b0826f6a5697063a 100644 (file)
@@ -1,84 +1,37 @@
 # SPDX-License-Identifier: GPL-2.0
-ifdef CONFIG_GCC_PLUGINS
-  __PLUGINCC := $(call cc-ifversion, -ge, 0408, $(HOSTCXX), $(HOSTCC))
-  PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)")
-
-  SANCOV_PLUGIN := -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
-
-  gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY)       += cyc_complexity_plugin.so
+gcc-plugin-$(CONFIG_GCC_PLUGIN_CYC_COMPLEXITY) += cyc_complexity_plugin.so
 
-  gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)       += latent_entropy_plugin.so
-  gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)        += -DLATENT_ENTROPY_PLUGIN
-  ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
+gcc-plugin-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY) += latent_entropy_plugin.so
+gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_LATENT_ENTROPY)  += -DLATENT_ENTROPY_PLUGIN
+ifdef CONFIG_GCC_PLUGIN_LATENT_ENTROPY
     DISABLE_LATENT_ENTROPY_PLUGIN                      += -fplugin-arg-latent_entropy_plugin-disable
-  endif
-
-  ifdef CONFIG_GCC_PLUGIN_SANCOV
-    ifeq ($(strip $(CFLAGS_KCOV)),)
-      # It is needed because of the gcc-plugin.sh and gcc version checks.
-      gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV)           += sancov_plugin.so
-
-      ifneq ($(PLUGINCC),)
-        CFLAGS_KCOV := $(SANCOV_PLUGIN)
-      else
-        $(warning warning: cannot use CONFIG_KCOV: -fsanitize-coverage=trace-pc is not supported by compiler)
-      endif
-    endif
-  endif
-
-  gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)   += structleak_plugin.so
-  gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE)    += -fplugin-arg-structleak_plugin-verbose
-  gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL)  += -fplugin-arg-structleak_plugin-byref-all
-  gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)    += -DSTRUCTLEAK_PLUGIN
+endif
 
-  gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)   += randomize_layout_plugin.so
-  gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)    += -DRANDSTRUCT_PLUGIN
-  gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE)        += -fplugin-arg-randomize_layout_plugin-performance-mode
+gcc-plugin-$(CONFIG_GCC_PLUGIN_SANCOV)         += sancov_plugin.so
+gcc-plugin-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)     += structleak_plugin.so
+gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_VERBOSE)      += -fplugin-arg-structleak_plugin-verbose
+gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL)    += -fplugin-arg-structleak_plugin-byref-all
+gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_STRUCTLEAK)      += -DSTRUCTLEAK_PLUGIN
 
-  GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
+gcc-plugin-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)     += randomize_layout_plugin.so
+gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT)      += -DRANDSTRUCT_PLUGIN
+gcc-plugin-cflags-$(CONFIG_GCC_PLUGIN_RANDSTRUCT_PERFORMANCE)  += -fplugin-arg-randomize_layout_plugin-performance-mode
 
-  export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR
-  export SANCOV_PLUGIN DISABLE_LATENT_ENTROPY_PLUGIN
+GCC_PLUGINS_CFLAGS := $(strip $(addprefix -fplugin=$(objtree)/scripts/gcc-plugins/, $(gcc-plugin-y)) $(gcc-plugin-cflags-y))
 
-  ifneq ($(PLUGINCC),)
-    # SANCOV_PLUGIN can be only in CFLAGS_KCOV because avoid duplication.
-    GCC_PLUGINS_CFLAGS := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGINS_CFLAGS))
-  endif
+export GCC_PLUGINS_CFLAGS GCC_PLUGIN GCC_PLUGIN_SUBDIR
+export DISABLE_LATENT_ENTROPY_PLUGIN
 
-  KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
-  GCC_PLUGIN := $(gcc-plugin-y)
-  GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y)
-endif
+# sancov_plugin.so can be only in CFLAGS_KCOV because avoid duplication.
+GCC_PLUGINS_CFLAGS := $(filter-out %/sancov_plugin.so, $(GCC_PLUGINS_CFLAGS))
 
-# If plugins aren't supported, abort the build before hard-to-read compiler
-# errors start getting spewed by the main build.
-PHONY += gcc-plugins-check
-gcc-plugins-check: FORCE
-ifdef CONFIG_GCC_PLUGINS
-  ifeq ($(PLUGINCC),)
-    ifneq ($(GCC_PLUGINS_CFLAGS),)
-      # Various gccs between 4.5 and 5.1 have bugs on powerpc due to missing
-      # header files. gcc <= 4.6 doesn't work at all, gccs from 4.8 to 5.1 have
-      # issues with 64-bit targets.
-      ifeq ($(ARCH),powerpc)
-        ifeq ($(call cc-ifversion, -le, 0501, y), y)
-         @echo "Cannot use CONFIG_GCC_PLUGINS: plugin support on gcc <= 5.1 is buggy on powerpc, please upgrade to gcc 5.2 or newer" >&2 && exit 1
-        endif
-      endif
-      ifeq ($(call cc-ifversion, -ge, 0405, y), y)
-       $(Q)$(srctree)/scripts/gcc-plugin.sh --show-error "$(__PLUGINCC)" "$(HOSTCXX)" "$(CC)" || true
-       @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc installation does not support plugins, perhaps the necessary headers are missing?" >&2 && exit 1
-      else
-       @echo "Cannot use CONFIG_GCC_PLUGINS: your gcc version does not support plugins, you should upgrade it to at least gcc 4.5" >&2 && exit 1
-      endif
-    endif
-  endif
-endif
-       @:
+KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
+GCC_PLUGIN := $(gcc-plugin-y)
+GCC_PLUGIN_SUBDIR := $(gcc-plugin-subdir-y)
 
 # Actually do the build, if requested.
 PHONY += gcc-plugins
-gcc-plugins: scripts_basic gcc-plugins-check
+gcc-plugins: scripts_basic
 ifdef CONFIG_GCC_PLUGINS
        $(Q)$(MAKE) $(build)=scripts/gcc-plugins
 endif
index 5cc72037e423459820d060bdeedaca44a54b8975..3d61c4bfcbee48d3129d4eed56fcebd8af267dea 100644 (file)
@@ -1,7 +1,9 @@
 ifdef CONFIG_KCOV
-CFLAGS_KCOV    := $(call cc-option,-fsanitize-coverage=trace-pc,)
-ifeq ($(CONFIG_KCOV_ENABLE_COMPARISONS),y)
-CFLAGS_KCOV += $(call cc-option,-fsanitize-coverage=trace-cmp,)
-endif
+
+kcov-flags-$(CONFIG_CC_HAS_SANCOV_TRACE_PC)    += -fsanitize-coverage=trace-pc
+kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS)   += -fsanitize-coverage=trace-cmp
+kcov-flags-$(CONFIG_GCC_PLUGIN_SANCOV)         += -fplugin=$(objtree)/scripts/gcc-plugins/sancov_plugin.so
+
+export CFLAGS_KCOV := $(kcov-flags-y)
 
 endif
index 9780efa56980098ad3d3f9c9d544050655faeb82..dbf0a31eb111c9ea166f090f78932a0b51d68faa 100755 (executable)
 # clang-5.0.1 etc.
 #
 
-if [ "$1" = "-p" ] ; then
-       with_patchlevel=1;
-       shift;
-fi
-
 compiler="$*"
 
-if [ ${#compiler} -eq 0 ]; then
-       echo "Error: No compiler specified."
-       printf "Usage:\n\t$0 <clang-command>\n"
+if !( $compiler --version | grep -q clang) ; then
+       echo 0
        exit 1
 fi
 
 MAJOR=$(echo __clang_major__ | $compiler -E -x c - | tail -n 1)
 MINOR=$(echo __clang_minor__ | $compiler -E -x c - | tail -n 1)
-if [ "x$with_patchlevel" != "x" ] ; then
-       PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1)
-       printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
-else
-       printf "%02d%02d\\n" $MAJOR $MINOR
-fi
+PATCHLEVEL=$(echo __clang_patchlevel__ | $compiler -E -x c - | tail -n 1)
+printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
index 2520bc14ffacf71f29e4db4d6682162deb6f6fe4..078999a3fdff7542ff52db288b96d9f0848e1c49 100755 (executable)
@@ -21,7 +21,7 @@ GetOptions(
 );
 
 if ($help != 0) {
-    print "$scriptname [--help] [--fix-rst]\n";
+    print "$scriptname [--help] [--fix]\n";
     exit -1;
 }
 
@@ -38,16 +38,31 @@ while (<IN>) {
        my $f = $1;
        my $ln = $2;
 
-       # Makefiles contain nasty expressions to parse docs
-       next if ($f =~ m/Makefile/);
+       # Makefiles and scripts contain nasty expressions to parse docs
+       next if ($f =~ m/Makefile/ || $f =~ m/\.sh$/);
+
        # Skip this script
        next if ($f eq $scriptname);
 
-       if ($ln =~ m,\b(\S*)(Documentation/[A-Za-z0-9\_\.\,\~/\*+-]*),) {
+       if ($ln =~ m,\b(\S*)(Documentation/[A-Za-z0-9\_\.\,\~/\*\[\]\?+-]*)(.*),) {
                my $prefix = $1;
                my $ref = $2;
                my $base = $2;
+               my $extra = $3;
+
+               # some file references are like:
+               # /usr/src/linux/Documentation/DMA-{API,mapping}.txt
+               # For now, ignore them
+               next if ($extra =~ m/^{/);
+
+               # Remove footnotes at the end like:
+               # Documentation/devicetree/dt-object-internal.txt[1]
+               $ref =~ s/(txt|rst)\[\d+]$/$1/;
+
+               # Remove ending ']' without any '['
+               $ref =~ s/\].*// if (!($ref =~ m/\[/));
 
+               # Remove puntuation marks at the end
                $ref =~ s/[\,\.]+$//;
 
                my $fulref = "$prefix$ref";
@@ -63,8 +78,15 @@ while (<IN>) {
                # Check if exists, evaluating wildcards
                next if (grep -e, glob("$ref $fulref"));
 
+               # Accept relative Documentation patches for tools/
+               if ($f =~ m/tools/) {
+                       my $path = $f;
+                       $path =~ s,(.*)/.*,$1,;
+                       next if (grep -e, glob("$path/$ref $path/$fulref"));
+               }
+
                if ($fix) {
-                       if (!($ref =~ m/(devicetree|scripts|Kconfig|Kbuild)/)) {
+                       if (!($ref =~ m/(scripts|Kconfig|Kbuild)/)) {
                                $broken_ref{$ref}++;
                        }
                } else {
@@ -84,10 +106,19 @@ foreach my $ref (keys %broken_ref) {
        # get just the basename
        $new =~ s,.*/,,;
 
-       # Seek for the same name on another place, as it may have been moved
        my $f="";
 
-       $f = qx(find . -iname $new) if ($new);
+       # usual reason for breakage: DT file moved around
+       if ($ref =~ /devicetree/) {
+               my $search = $new;
+               $search =~ s,^.*/,,;
+               $f = qx(find Documentation/devicetree/ -iname "*$search*") if ($search);
+               if (!$f) {
+                       # Manufacturer name may have changed
+                       $search =~ s/^.*,//;
+                       $f = qx(find Documentation/devicetree/ -iname "*$search*") if ($search);
+               }
+       }
 
        # usual reason for breakage: file renamed to .rst
        if (!$f) {
@@ -95,6 +126,17 @@ foreach my $ref (keys %broken_ref) {
                $f=qx(find . -iname $new) if ($new);
        }
 
+       # usual reason for breakage: use dash or underline
+       if (!$f) {
+               $new =~ s/[-_]/[-_]/g;
+               $f=qx(find . -iname $new) if ($new);
+       }
+
+       # Wild guess: seek for the same name on another place
+       if (!$f) {
+               $f = qx(find . -iname $new) if ($new);
+       }
+
        my @find = split /\s+/, $f;
 
        if (!$f) {
index e2ff425f4c7ea6958beddb3571ed9ac72a3b9ea8..326254653bd0464f28e8c966289d5ad030377f3b 100644 (file)
@@ -1,4 +1,5 @@
 # SPDX-License-Identifier: GPL-2.0
+PLUGINCC := $(CONFIG_PLUGIN_HOSTCC:"%"=%)
 GCC_PLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
 
 ifeq ($(PLUGINCC),$(HOSTCC))
@@ -13,10 +14,6 @@ else
   export HOST_EXTRACXXFLAGS
 endif
 
-ifneq ($(CFLAGS_KCOV), $(SANCOV_PLUGIN))
-  GCC_PLUGIN := $(filter-out $(SANCOV_PLUGIN), $(GCC_PLUGIN))
-endif
-
 export HOSTLIBS
 
 $(obj)/randomize_layout_plugin.o: $(objtree)/$(obj)/randomize_layout_seed.h
index 6b2aeefb9cd3e0884da9ce0cfaaa8d288e03a6ee..f5c11949525404f43a22e6efb14a59207898ff9d 100755 (executable)
@@ -1,9 +1,4 @@
 #!/bin/sh
 # SPDX-License-Identifier: GPL-2.0
 
-echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
-if [ "$?" -eq "0" ] ; then
-       echo y
-else
-       echo n
-fi
+echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -m32 -O0 -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
index 4a48bdcd4d6be6309eb895f197d370bb7b6c60db..3755af0cd9f7f24c1942fd9df216c525f79d04b3 100755 (executable)
@@ -2,8 +2,3 @@
 # SPDX-License-Identifier: GPL-2.0
 
 echo "int foo(void) { char X[200]; return 3; }" | $* -S -x c -c -O0 -mcmodel=kernel -fno-PIE -fstack-protector - -o - 2> /dev/null | grep -q "%gs"
-if [ "$?" -eq "0" ] ; then
-       echo y
-else
-       echo n
-fi
index a2e83ab17de3cc2c4c5a15f06b8c0f0eecc4ed99..4686531e2f8ce6fe88c375917724fb076bc8679e 100755 (executable)
@@ -165,10 +165,10 @@ sub read_kconfig {
     my $last_source = "";
 
     # Check for any environment variables used
-    while ($source =~ /\$(\w+)/ && $last_source ne $source) {
+    while ($source =~ /\$\((\w+)\)/ && $last_source ne $source) {
        my $env = $1;
        $last_source = $source;
-       $source =~ s/\$$env/$ENV{$env}/;
+       $source =~ s/\$\($env\)/$ENV{$env}/;
     }
 
     open(my $kinfile, '<', $source) || die "Can't open $kconfig";
index 8f9ecac7f8dea26f2621ba63bcb05dd781af3584..eeaddfe0c0fb9c3999453451de1899db81a9ad84 100644 (file)
@@ -19,7 +19,7 @@
 #include "include/audit.h"
 #include "include/policy.h"
 #include "include/policy_ns.h"
-
+#include "include/secid.h"
 
 const char *const audit_mode_names[] = {
        "normal",
@@ -163,3 +163,91 @@ int aa_audit(int type, struct aa_profile *profile, struct common_audit_data *sa,
 
        return aad(sa)->error;
 }
+
+struct aa_audit_rule {
+       struct aa_label *label;
+};
+
+void aa_audit_rule_free(void *vrule)
+{
+       struct aa_audit_rule *rule = vrule;
+
+       if (rule) {
+               if (!IS_ERR(rule->label))
+                       aa_put_label(rule->label);
+               kfree(rule);
+       }
+}
+
+int aa_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule)
+{
+       struct aa_audit_rule *rule;
+
+       switch (field) {
+       case AUDIT_SUBJ_ROLE:
+               if (op != Audit_equal && op != Audit_not_equal)
+                       return -EINVAL;
+               break;
+       default:
+               return -EINVAL;
+       }
+
+       rule = kzalloc(sizeof(struct aa_audit_rule), GFP_KERNEL);
+
+       if (!rule)
+               return -ENOMEM;
+
+       /* Currently rules are treated as coming from the root ns */
+       rule->label = aa_label_parse(&root_ns->unconfined->label, rulestr,
+                                    GFP_KERNEL, true, false);
+       if (IS_ERR(rule->label)) {
+               aa_audit_rule_free(rule);
+               return PTR_ERR(rule->label);
+       }
+
+       *vrule = rule;
+       return 0;
+}
+
+int aa_audit_rule_known(struct audit_krule *rule)
+{
+       int i;
+
+       for (i = 0; i < rule->field_count; i++) {
+               struct audit_field *f = &rule->fields[i];
+
+               switch (f->type) {
+               case AUDIT_SUBJ_ROLE:
+                       return 1;
+               }
+       }
+
+       return 0;
+}
+
+int aa_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule,
+                       struct audit_context *actx)
+{
+       struct aa_audit_rule *rule = vrule;
+       struct aa_label *label;
+       int found = 0;
+
+       label = aa_secid_to_label(sid);
+
+       if (!label)
+               return -ENOENT;
+
+       if (aa_label_is_subset(label, rule->label))
+               found = 1;
+
+       switch (field) {
+       case AUDIT_SUBJ_ROLE:
+               switch (op) {
+               case Audit_equal:
+                       return found;
+               case Audit_not_equal:
+                       return !found;
+               }
+       }
+       return 0;
+}
index 590b7e8cd21c5450b24dfc84ea6b82c39b3c7959..098d546d8253d920737d368fab9966b4d60dcc30 100644 (file)
@@ -839,7 +839,7 @@ static struct aa_label *handle_onexec(struct aa_label *label,
                                                   cond, unsafe));
 
        } else {
-               /* TODO: determine how much we want to losen this */
+               /* TODO: determine how much we want to loosen this */
                error = fn_for_each_in_ns(label, profile,
                                profile_onexec(profile, onexec, stack, bprm,
                                               buffer, cond, unsafe));
index 9c9be9c98c153e52c763dcbf2f4773e5ccfa7eba..b8c8b1066b0a126ad4ac50f343a721cbabcd8748 100644 (file)
@@ -189,4 +189,10 @@ static inline int complain_error(int error)
        return error;
 }
 
+void aa_audit_rule_free(void *vrule);
+int aa_audit_rule_init(u32 field, u32 op, char *rulestr, void **vrule);
+int aa_audit_rule_known(struct audit_krule *rule);
+int aa_audit_rule_match(u32 sid, u32 field, u32 op, void *vrule,
+                       struct audit_context *actx);
+
 #endif /* __AA_AUDIT_H */
index d871e7ff095275e8a23685449945036d016682eb..7ce5fe73ae7f5f641c279d03ad79c3b9f4ab8d0d 100644 (file)
@@ -281,7 +281,7 @@ void __aa_labelset_update_subtree(struct aa_ns *ns);
 
 void aa_label_free(struct aa_label *label);
 void aa_label_kref(struct kref *kref);
-bool aa_label_init(struct aa_label *label, int size);
+bool aa_label_init(struct aa_label *label, int size, gfp_t gfp);
 struct aa_label *aa_label_alloc(int size, struct aa_proxy *proxy, gfp_t gfp);
 
 bool aa_label_is_subset(struct aa_label *set, struct aa_label *sub);
index e042b994f2b8bae575abe142dcdc7c3e2b5828f2..b6380c5f00972702807407cbc1f853192a308333 100644 (file)
@@ -43,10 +43,11 @@ struct aa_buffers {
 
 DECLARE_PER_CPU(struct aa_buffers, aa_buffers);
 
-#define ASSIGN(FN, X, N) ((X) = FN(N))
-#define EVAL1(FN, X) ASSIGN(FN, X, 0) /*X = FN(0)*/
-#define EVAL2(FN, X, Y...) do { ASSIGN(FN, X, 1);  EVAL1(FN, Y); } while (0)
-#define EVAL(FN, X...) CONCATENATE(EVAL, COUNT_ARGS(X))(FN, X)
+#define ASSIGN(FN, A, X, N) ((X) = FN(A, N))
+#define EVAL1(FN, A, X) ASSIGN(FN, A, X, 0) /*X = FN(0)*/
+#define EVAL2(FN, A, X, Y...)  \
+       do { ASSIGN(FN, A, X, 1);  EVAL1(FN, A, Y); } while (0)
+#define EVAL(FN, A, X...) CONCATENATE(EVAL, COUNT_ARGS(X))(FN, A, X)
 
 #define for_each_cpu_buffer(I) for ((I) = 0; (I) < MAX_PATH_BUFFERS; (I)++)
 
@@ -56,26 +57,24 @@ DECLARE_PER_CPU(struct aa_buffers, aa_buffers);
 #define AA_BUG_PREEMPT_ENABLED(X) /* nop */
 #endif
 
-#define __get_buffer(N) ({                                     \
-       struct aa_buffers *__cpu_var; \
+#define __get_buffer(C, N) ({                                          \
        AA_BUG_PREEMPT_ENABLED("__get_buffer without preempt disabled");  \
-       __cpu_var = this_cpu_ptr(&aa_buffers);                  \
-       __cpu_var->buf[(N)]; })
+       (C)->buf[(N)]; })
 
-#define __get_buffers(X...)    EVAL(__get_buffer, X)
+#define __get_buffers(C, X...)    EVAL(__get_buffer, C, X)
 
 #define __put_buffers(X, Y...) ((void)&(X))
 
-#define get_buffers(X...)      \
-do {                           \
-       preempt_disable();      \
-       __get_buffers(X);       \
+#define get_buffers(X...)                                              \
+do {                                                                   \
+       struct aa_buffers *__cpu_var = get_cpu_ptr(&aa_buffers);        \
+       __get_buffers(__cpu_var, X);                                    \
 } while (0)
 
-#define put_buffers(X, Y...)   \
-do {                           \
-       __put_buffers(X, Y);    \
-       preempt_enable();       \
+#define put_buffers(X, Y...)           \
+do {                                   \
+       __put_buffers(X, Y);            \
+       put_cpu_ptr(&aa_buffers);       \
 } while (0)
 
 #endif /* __AA_PATH_H */
index 95ed86a0f1e28c75e7c5394f320ec0ad482f78dd..dee6fa3b6081e1342bfa3e0c4077ea960ca7bfff 100644 (file)
@@ -3,7 +3,7 @@
  *
  * This file contains AppArmor security identifier (secid) definitions
  *
- * Copyright 2009-2010 Canonical Ltd.
+ * Copyright 2009-2018 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
 #ifndef __AA_SECID_H
 #define __AA_SECID_H
 
+#include <linux/slab.h>
 #include <linux/types.h>
 
+struct aa_label;
+
 /* secid value that will not be allocated */
 #define AA_SECID_INVALID 0
-#define AA_SECID_ALLOC AA_SECID_INVALID
 
-u32 aa_alloc_secid(void);
+struct aa_label *aa_secid_to_label(u32 secid);
+int apparmor_secid_to_secctx(u32 secid, char **secdata, u32 *seclen);
+int apparmor_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid);
+void apparmor_release_secctx(char *secdata, u32 seclen);
+
+
+int aa_alloc_secid(struct aa_label *label, gfp_t gfp);
 void aa_free_secid(u32 secid);
+void aa_secid_update(u32 secid, struct aa_label *label);
+
+void aa_secids_init(void);
 
 #endif /* __AA_SECID_H */
index 523250e348378d1ef7ddcd80f7e6e64285ef787b..ba11bdf9043aacd26acf7119873c212240e3cb3f 100644 (file)
@@ -128,7 +128,7 @@ static int ns_cmp(struct aa_ns *a, struct aa_ns *b)
 }
 
 /**
- * profile_cmp - profile comparision for set ordering
+ * profile_cmp - profile comparison for set ordering
  * @a: profile to compare (NOT NULL)
  * @b: profile to compare (NOT NULL)
  *
@@ -157,7 +157,7 @@ static int profile_cmp(struct aa_profile *a, struct aa_profile *b)
 }
 
 /**
- * vec_cmp - label comparision for set ordering
+ * vec_cmp - label comparison for set ordering
  * @a: label to compare (NOT NULL)
  * @vec: vector of profiles to compare (NOT NULL)
  * @n: length of @vec
@@ -402,13 +402,12 @@ static void label_free_or_put_new(struct aa_label *label, struct aa_label *new)
                aa_put_label(new);
 }
 
-bool aa_label_init(struct aa_label *label, int size)
+bool aa_label_init(struct aa_label *label, int size, gfp_t gfp)
 {
        AA_BUG(!label);
        AA_BUG(size < 1);
 
-       label->secid = aa_alloc_secid();
-       if (label->secid == AA_SECID_INVALID)
+       if (aa_alloc_secid(label, gfp) < 0)
                return false;
 
        label->size = size;                     /* doesn't include null */
@@ -441,7 +440,7 @@ struct aa_label *aa_label_alloc(int size, struct aa_proxy *proxy, gfp_t gfp)
        if (!new)
                goto fail;
 
-       if (!aa_label_init(new, size))
+       if (!aa_label_init(new, size, gfp))
                goto fail;
 
        if (!proxy) {
@@ -463,7 +462,7 @@ struct aa_label *aa_label_alloc(int size, struct aa_proxy *proxy, gfp_t gfp)
 
 
 /**
- * label_cmp - label comparision for set ordering
+ * label_cmp - label comparison for set ordering
  * @a: label to compare (NOT NULL)
  * @b: label to compare (NOT NULL)
  *
@@ -2011,7 +2010,7 @@ static struct aa_label *labelset_next_stale(struct aa_labelset *ls)
 
 /**
  * __label_update - insert updated version of @label into labelset
- * @label - the label to update/repace
+ * @label - the label to update/replace
  *
  * Returns: new label that is up to date
  *     else NULL on failure
index 068a9f471f774d57543c6a93d978056070ac9cfb..a7b3f681b80e19aed6b0733ad0edf863b20c0c9b 100644 (file)
@@ -408,7 +408,7 @@ int aa_profile_label_perm(struct aa_profile *profile, struct aa_profile *target,
  * @request: requested perms
  * @deny: Returns: explicit deny set
  * @sa: initialized audit structure (MAY BE NULL if not auditing)
- * @cb: callback fn for tpye specific fields (MAY BE NULL)
+ * @cb: callback fn for type specific fields (MAY BE NULL)
  *
  * Returns: 0 if permission else error code
  *
index ce2b89e9ad94eb9b5b657a8ccce703894c021e19..74f17376202bd1cf36cafcf849abd06fe36ec35a 100644 (file)
@@ -39,6 +39,7 @@
 #include "include/policy_ns.h"
 #include "include/procattr.h"
 #include "include/mount.h"
+#include "include/secid.h"
 
 /* Flag indicating whether initialization completed */
 int apparmor_initialized;
@@ -116,7 +117,8 @@ static int apparmor_ptrace_access_check(struct task_struct *child,
        tracer = begin_current_label_crit_section();
        tracee = aa_get_task_label(child);
        error = aa_may_ptrace(tracer, tracee,
-                 mode == PTRACE_MODE_READ ? AA_PTRACE_READ : AA_PTRACE_TRACE);
+                       (mode & PTRACE_MODE_READ) ? AA_PTRACE_READ
+                                                 : AA_PTRACE_TRACE);
        aa_put_label(tracee);
        end_current_label_crit_section(tracer);
 
@@ -710,6 +712,13 @@ static void apparmor_bprm_committed_creds(struct linux_binprm *bprm)
        return;
 }
 
+static void apparmor_task_getsecid(struct task_struct *p, u32 *secid)
+{
+       struct aa_label *label = aa_get_task_label(p);
+       *secid = label->secid;
+       aa_put_label(label);
+}
+
 static int apparmor_task_setrlimit(struct task_struct *task,
                unsigned int resource, struct rlimit *new_rlim)
 {
@@ -1186,8 +1195,20 @@ static struct security_hook_list apparmor_hooks[] __lsm_ro_after_init = {
 
        LSM_HOOK_INIT(task_free, apparmor_task_free),
        LSM_HOOK_INIT(task_alloc, apparmor_task_alloc),
+       LSM_HOOK_INIT(task_getsecid, apparmor_task_getsecid),
        LSM_HOOK_INIT(task_setrlimit, apparmor_task_setrlimit),
        LSM_HOOK_INIT(task_kill, apparmor_task_kill),
+
+#ifdef CONFIG_AUDIT
+       LSM_HOOK_INIT(audit_rule_init, aa_audit_rule_init),
+       LSM_HOOK_INIT(audit_rule_known, aa_audit_rule_known),
+       LSM_HOOK_INIT(audit_rule_match, aa_audit_rule_match),
+       LSM_HOOK_INIT(audit_rule_free, aa_audit_rule_free),
+#endif
+
+       LSM_HOOK_INIT(secid_to_secctx, apparmor_secid_to_secctx),
+       LSM_HOOK_INIT(secctx_to_secid, apparmor_secctx_to_secid),
+       LSM_HOOK_INIT(release_secctx, apparmor_release_secctx),
 };
 
 /*
@@ -1378,14 +1399,12 @@ static int param_set_audit(const char *val, const struct kernel_param *kp)
        if (apparmor_initialized && !policy_admin_capable(NULL))
                return -EPERM;
 
-       for (i = 0; i < AUDIT_MAX_INDEX; i++) {
-               if (strcmp(val, audit_mode_names[i]) == 0) {
-                       aa_g_audit = i;
-                       return 0;
-               }
-       }
+       i = match_string(audit_mode_names, AUDIT_MAX_INDEX, val);
+       if (i < 0)
+               return -EINVAL;
 
-       return -EINVAL;
+       aa_g_audit = i;
+       return 0;
 }
 
 static int param_get_mode(char *buffer, const struct kernel_param *kp)
@@ -1409,14 +1428,13 @@ static int param_set_mode(const char *val, const struct kernel_param *kp)
        if (apparmor_initialized && !policy_admin_capable(NULL))
                return -EPERM;
 
-       for (i = 0; i < APPARMOR_MODE_NAMES_MAX_INDEX; i++) {
-               if (strcmp(val, aa_profile_mode_names[i]) == 0) {
-                       aa_g_profile_mode = i;
-                       return 0;
-               }
-       }
+       i = match_string(aa_profile_mode_names, APPARMOR_MODE_NAMES_MAX_INDEX,
+                        val);
+       if (i < 0)
+               return -EINVAL;
 
-       return -EINVAL;
+       aa_g_profile_mode = i;
+       return 0;
 }
 
 /*
@@ -1530,6 +1548,8 @@ static int __init apparmor_init(void)
                return 0;
        }
 
+       aa_secids_init();
+
        error = aa_setup_dfa_engine();
        if (error) {
                AA_ERROR("Unable to setup dfa engine\n");
index 280eba082c7bfbb05b0c96d8d4bd7aa3e604a7a8..55f2ee505a019411de885560a5e80f79a23d0e5b 100644 (file)
@@ -472,7 +472,7 @@ unsigned int aa_dfa_match(struct aa_dfa *dfa, unsigned int start,
 
 /**
  * aa_dfa_next - step one character to the next state in the dfa
- * @dfa: the dfa to tranverse (NOT NULL)
+ * @dfa: the dfa to traverse (NOT NULL)
  * @state: the state to start in
  * @c: the input character to transition on
  *
index 6e8c7ac0b33d1e7b678db852dcce3eb183a51ca8..c1da22482bfbb3162f81203062daaae6186d45d2 100644 (file)
@@ -121,7 +121,7 @@ static void audit_cb(struct audit_buffer *ab, void *va)
  * @src_name: src_name of object being mediated (MAYBE_NULL)
  * @type: type of filesystem (MAYBE_NULL)
  * @trans: name of trans (MAYBE NULL)
- * @flags: filesystem idependent mount flags
+ * @flags: filesystem independent mount flags
  * @data: filesystem mount flags
  * @request: permissions requested
  * @perms: the permissions computed for the request (NOT NULL)
index c07493ce237680c7183d93282a310cf4eacbfbde..1590e2de4e841c131ac472fa5e9c312d448b0866 100644 (file)
@@ -268,7 +268,7 @@ struct aa_profile *aa_alloc_profile(const char *hname, struct aa_proxy *proxy,
 
        if (!aa_policy_init(&profile->base, NULL, hname, gfp))
                goto fail;
-       if (!aa_label_init(&profile->label, 1))
+       if (!aa_label_init(&profile->label, 1, gfp))
                goto fail;
 
        /* update being set needed by fs interface */
@@ -1008,6 +1008,9 @@ ssize_t aa_replace_profiles(struct aa_ns *policy_ns, struct aa_label *label,
                        audit_policy(label, op, ns_name, ent->new->base.hname,
                                     "same as current profile, skipping",
                                     error);
+                       /* break refcount cycle with proxy. */
+                       aa_put_proxy(ent->new->label.proxy);
+                       ent->new->label.proxy = NULL;
                        goto skip;
                }
 
@@ -1085,7 +1088,7 @@ ssize_t aa_replace_profiles(struct aa_ns *policy_ns, struct aa_label *label,
  * Remove a profile or sub namespace from the current namespace, so that
  * they can not be found anymore and mark them as replaced by unconfined
  *
- * NOTE: removing confinement does not restore rlimits to preconfinemnet values
+ * NOTE: removing confinement does not restore rlimits to preconfinement values
  *
  * Returns: size of data consume else error code if fails
  */
index b9e6b2cafa6993fe29820e13429988e7e9d01c09..0e566a01d217c8dee874f7a063c18ef3eb190523 100644 (file)
@@ -475,7 +475,7 @@ static bool unpack_trans_table(struct aa_ext *e, struct aa_profile *profile)
                /* currently 4 exec bits and entries 0-3 are reserved iupcx */
                if (size > 16 - 4)
                        goto fail;
-               profile->file.trans.table = kzalloc(sizeof(char *) * size,
+               profile->file.trans.table = kcalloc(size, sizeof(char *),
                                                    GFP_KERNEL);
                if (!profile->file.trans.table)
                        goto fail;
index d022137143b9eb2eb0a846ed00bfbc860e388a3b..95fd26d09757f2c7fb7b39d541e1aa6fdc923a5d 100644 (file)
@@ -124,7 +124,7 @@ int aa_task_setrlimit(struct aa_label *label, struct task_struct *task,
         */
 
        if (label != peer &&
-           !aa_capable(label, CAP_SYS_RESOURCE, SECURITY_CAP_NOAUDIT))
+           aa_capable(label, CAP_SYS_RESOURCE, SECURITY_CAP_NOAUDIT) != 0)
                error = fn_for_each(label, profile,
                                audit_resource(profile, resource,
                                               new_rlim->rlim_max, peer,
index 3a3edbad0b214c8d77560a25e7917f1fef1fe96e..f2f22d00db18893a917006794c5a09e341aae2b0 100644 (file)
@@ -3,7 +3,7 @@
  *
  * This file contains AppArmor security identifier (secid) manipulation fns
  *
- * Copyright 2009-2010 Canonical Ltd.
+ * Copyright 2009-2017 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License as
  * License.
  *
  *
- * AppArmor allocates a unique secid for every profile loaded.  If a profile
- * is replaced it receives the secid of the profile it is replacing.
- *
- * The secid value of 0 is invalid.
+ * AppArmor allocates a unique secid for every label used. If a label
+ * is replaced it receives the secid of the label it is replacing.
  */
 
-#include <linux/spinlock.h>
 #include <linux/errno.h>
 #include <linux/err.h>
+#include <linux/gfp.h>
+#include <linux/idr.h>
+#include <linux/slab.h>
+#include <linux/spinlock.h>
 
+#include "include/cred.h"
+#include "include/lib.h"
 #include "include/secid.h"
+#include "include/label.h"
+#include "include/policy_ns.h"
+
+/*
+ * secids - do not pin labels with a refcount. They rely on the label
+ * properly updating/freeing them
+ */
 
-/* global counter from which secids are allocated */
-static u32 global_secid;
+#define AA_FIRST_SECID 1
+
+static DEFINE_IDR(aa_secids);
 static DEFINE_SPINLOCK(secid_lock);
 
-/* TODO FIXME: add secid to profile mapping, and secid recycling */
+/*
+ * TODO: allow policy to reserve a secid range?
+ * TODO: add secid pinning
+ * TODO: use secid_update in label replace
+ */
+
+/**
+ * aa_secid_update - update a secid mapping to a new label
+ * @secid: secid to update
+ * @label: label the secid will now map to
+ */
+void aa_secid_update(u32 secid, struct aa_label *label)
+{
+       unsigned long flags;
+
+       spin_lock_irqsave(&secid_lock, flags);
+       idr_replace(&aa_secids, label, secid);
+       spin_unlock_irqrestore(&secid_lock, flags);
+}
+
+/**
+ *
+ * see label for inverse aa_label_to_secid
+ */
+struct aa_label *aa_secid_to_label(u32 secid)
+{
+       struct aa_label *label;
+
+       rcu_read_lock();
+       label = idr_find(&aa_secids, secid);
+       rcu_read_unlock();
+
+       return label;
+}
+
+int apparmor_secid_to_secctx(u32 secid, char **secdata, u32 *seclen)
+{
+       /* TODO: cache secctx and ref count so we don't have to recreate */
+       struct aa_label *label = aa_secid_to_label(secid);
+       int len;
+
+       AA_BUG(!secdata);
+       AA_BUG(!seclen);
+
+       if (!label)
+               return -EINVAL;
+
+       if (secdata)
+               len = aa_label_asxprint(secdata, root_ns, label,
+                                       FLAG_SHOW_MODE | FLAG_VIEW_SUBNS |
+                                       FLAG_HIDDEN_UNCONFINED | FLAG_ABS_ROOT,
+                                       GFP_ATOMIC);
+       else
+               len = aa_label_snxprint(NULL, 0, root_ns, label,
+                                       FLAG_SHOW_MODE | FLAG_VIEW_SUBNS |
+                                       FLAG_HIDDEN_UNCONFINED | FLAG_ABS_ROOT);
+       if (len < 0)
+               return -ENOMEM;
+
+       *seclen = len;
+
+       return 0;
+}
+
+int apparmor_secctx_to_secid(const char *secdata, u32 seclen, u32 *secid)
+{
+       struct aa_label *label;
+
+       label = aa_label_strn_parse(&root_ns->unconfined->label, secdata,
+                                   seclen, GFP_KERNEL, false, false);
+       if (IS_ERR(label))
+               return PTR_ERR(label);
+       *secid = label->secid;
+
+       return 0;
+}
+
+void apparmor_release_secctx(char *secdata, u32 seclen)
+{
+       kfree(secdata);
+}
 
 /**
  * aa_alloc_secid - allocate a new secid for a profile
+ * @label: the label to allocate a secid for
+ * @gfp: memory allocation flags
+ *
+ * Returns: 0 with @label->secid initialized
+ *          <0 returns error with @label->secid set to AA_SECID_INVALID
  */
-u32 aa_alloc_secid(void)
+int aa_alloc_secid(struct aa_label *label, gfp_t gfp)
 {
-       u32 secid;
+       unsigned long flags;
+       int ret;
+
+       idr_preload(gfp);
+       spin_lock_irqsave(&secid_lock, flags);
+       ret = idr_alloc(&aa_secids, label, AA_FIRST_SECID, 0, GFP_ATOMIC);
+       spin_unlock_irqrestore(&secid_lock, flags);
+       idr_preload_end();
 
-       /*
-        * TODO FIXME: secid recycling - part of profile mapping table
-        */
-       spin_lock(&secid_lock);
-       secid = (++global_secid);
-       spin_unlock(&secid_lock);
-       return secid;
+       if (ret < 0) {
+               label->secid = AA_SECID_INVALID;
+               return ret;
+       }
+
+       AA_BUG(ret == AA_SECID_INVALID);
+       label->secid = ret;
+       return 0;
 }
 
 /**
@@ -51,5 +155,14 @@ u32 aa_alloc_secid(void)
  */
 void aa_free_secid(u32 secid)
 {
-       ;                       /* NOP ATM */
+       unsigned long flags;
+
+       spin_lock_irqsave(&secid_lock, flags);
+       idr_remove(&aa_secids, secid);
+       spin_unlock_irqrestore(&secid_lock, flags);
+}
+
+void aa_secids_init(void)
+{
+       idr_init_base(&aa_secids, AA_FIRST_SECID);
 }
index c65b39bafdfee2e259a5695dee791fa7ae661c0e..cd97929fac663f61250edeae3397e3ab75b5ff49 100644 (file)
@@ -509,7 +509,7 @@ static inline int may_allow_all(struct dev_cgroup *parent)
  * This is one of the three key functions for hierarchy implementation.
  * This function is responsible for re-evaluating all the cgroup's active
  * exceptions due to a parent's exception change.
- * Refer to Documentation/cgroups/devices.txt for more details.
+ * Refer to Documentation/cgroup-v1/devices.txt for more details.
  */
 static void revalidate_active_exceptions(struct dev_cgroup *devcg)
 {
index 42377668202597527bf5ac660342031ecf4afdd5..b69d3b1777c25d1d3f9cc5af3514352ed0220fcc 100644 (file)
@@ -1148,7 +1148,7 @@ static long trusted_read(const struct key *key, char __user *buffer,
                return -EINVAL;
 
        if (buffer && buflen >= 2 * p->blob_len) {
-               ascii_buf = kmalloc(2 * p->blob_len, GFP_KERNEL);
+               ascii_buf = kmalloc_array(2, p->blob_len, GFP_KERNEL);
                if (!ascii_buf)
                        return -ENOMEM;
 
index 9a46dc24ac1040279bedcdab897a7ab40b0eaa1d..2b5ee5fbd652de22a951d7618e6daad3d7cb82f5 100644 (file)
@@ -4728,7 +4728,7 @@ static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, in
 }
 
 /* This supports connect(2) and SCTP connect services such as sctp_connectx(3)
- * and sctp_sendmsg(3) as described in Documentation/security/LSM-sctp.txt
+ * and sctp_sendmsg(3) as described in Documentation/security/LSM-sctp.rst
  */
 static int selinux_socket_connect_helper(struct socket *sock,
                                         struct sockaddr *address, int addrlen)
index a2d44824121c7287ee028f6f14529d970d577ec5..dd2ceec06fef27dbf5ca47bb622b254dd5256231 100644 (file)
@@ -2118,7 +2118,7 @@ int security_load_policy(struct selinux_state *state, void *data, size_t len)
        int rc = 0;
        struct policy_file file = { data, len }, *fp = &file;
 
-       oldpolicydb = kzalloc(2 * sizeof(*oldpolicydb), GFP_KERNEL);
+       oldpolicydb = kcalloc(2, sizeof(*oldpolicydb), GFP_KERNEL);
        if (!oldpolicydb) {
                rc = -ENOMEM;
                goto out;
index 6e937a8146a184a4b8ee6211db0b0f235f5f5425..63b3ef9c83f59f7599207f8b639c68bb6e16fc3b 100644 (file)
@@ -48,7 +48,7 @@ config SND_MIXER_OSS
        depends on SND_OSSEMUL
        help
          To enable OSS mixer API emulation (/dev/mixer*), say Y here
-         and read <file:Documentation/sound/alsa/OSS-Emulation.txt>.
+         and read <file:Documentation/sound/designs/oss-emulation.rst>.
 
          Many programs still use the OSS API, so say Y.
 
@@ -61,7 +61,7 @@ config SND_PCM_OSS
        select SND_PCM
        help
          To enable OSS digital audio (PCM) emulation (/dev/dsp*), say Y
-         here and read <file:Documentation/sound/alsa/OSS-Emulation.txt>.
+         here and read <file:Documentation/sound/designs/oss-emulation.rst>.
 
          Many programs still use the OSS API, so say Y.
 
index 39d853bfa5ac0a8b88eb802ea12b947c35557a09..946ab080ac00315f6dc818bd4842970820b71029 100644 (file)
@@ -426,7 +426,7 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream,
            get_user(frames, &data32->frames))
                return -EFAULT;
        bufptr = compat_ptr(buf);
-       bufs = kmalloc(sizeof(void __user *) * ch, GFP_KERNEL);
+       bufs = kmalloc_array(ch, sizeof(void __user *), GFP_KERNEL);
        if (bufs == NULL)
                return -ENOMEM;
        for (i = 0; i < ch; i++) {
index 04c6301394d053ce5751ae33087c080cddd59b71..cecc79772c947ecde8237e199b6043eb39e38e44 100644 (file)
@@ -3072,7 +3072,7 @@ static ssize_t snd_pcm_readv(struct kiocb *iocb, struct iov_iter *to)
        if (!frame_aligned(runtime, to->iov->iov_len))
                return -EINVAL;
        frames = bytes_to_samples(runtime, to->iov->iov_len);
-       bufs = kmalloc(sizeof(void *) * to->nr_segs, GFP_KERNEL);
+       bufs = kmalloc_array(to->nr_segs, sizeof(void *), GFP_KERNEL);
        if (bufs == NULL)
                return -ENOMEM;
        for (i = 0; i < to->nr_segs; ++i)
@@ -3107,7 +3107,7 @@ static ssize_t snd_pcm_writev(struct kiocb *iocb, struct iov_iter *from)
            !frame_aligned(runtime, from->iov->iov_len))
                return -EINVAL;
        frames = bytes_to_samples(runtime, from->iov->iov_len);
-       bufs = kmalloc(sizeof(void *) * from->nr_segs, GFP_KERNEL);
+       bufs = kmalloc_array(from->nr_segs, sizeof(void *), GFP_KERNEL);
        if (bufs == NULL)
                return -ENOMEM;
        for (i = 0; i < from->nr_segs; ++i)
index ab1112e90f88dbd29bae5eea8edd175175504edc..a4c8543176b2d8adbe459bf57f2117ca54174cff 100644 (file)
@@ -389,7 +389,8 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
        if (snd_BUG_ON(!pool))
                return -EINVAL;
 
-       cellptr = vmalloc(sizeof(struct snd_seq_event_cell) * pool->size);
+       cellptr = vmalloc(array_size(sizeof(struct snd_seq_event_cell),
+                                    pool->size));
        if (!cellptr)
                return -ENOMEM;
 
index 9e2912e3e80fd6822324198def600b60f3e7d709..288f839a554b5afbfbb7421d8bc464e6c045d86c 100644 (file)
@@ -657,7 +657,7 @@ static struct snd_midi_channel *snd_midi_channel_init_set(int n)
        struct snd_midi_channel *chan;
        int  i;
 
-       chan = kmalloc(n * sizeof(struct snd_midi_channel), GFP_KERNEL);
+       chan = kmalloc_array(n, sizeof(struct snd_midi_channel), GFP_KERNEL);
        if (chan) {
                for (i = 0; i < n; i++)
                        snd_midi_channel_init(chan+i, i);
index 7144cc36e8ae16e4c4b190a75be56cd9a6a39aa6..648a12da44f99be375c365bb0f0d8ba59384d3ea 100644 (file)
@@ -153,7 +153,7 @@ config SND_SERIAL_U16550
        select SND_RAWMIDI
        help
          To include support for MIDI serial port interfaces, say Y here
-         and read <file:Documentation/sound/alsa/serial-u16550.txt>.
+         and read <file:Documentation/sound/cards/serial-u16550.rst>.
          This driver works with serial UARTs 16550 and better.
 
          This driver accesses the serial port hardware directly, so
@@ -223,7 +223,7 @@ config SND_AC97_POWER_SAVE
          the device frequently.  A value of 10 seconds would be a
          good choice for normal operations.
 
-         See Documentation/sound/alsa/powersave.txt for more details.
+         See Documentation/sound/designs/powersave.rst for more details.
 
 config SND_AC97_POWER_SAVE_DEFAULT
        int "Default time-out for AC97 power-save mode"
index 12aa15df435d1cca2bf6f3cf42b60704b2340004..ad7a0a32557dc778e32acc6cb813cf4e56a54623 100644 (file)
@@ -147,7 +147,7 @@ static int ff400_switch_fetching_mode(struct snd_ff *ff, bool enable)
        __le32 *reg;
        int i;
 
-       reg = kzalloc(sizeof(__le32) * 18, GFP_KERNEL);
+       reg = kcalloc(18, sizeof(__le32), GFP_KERNEL);
        if (reg == NULL)
                return -ENOMEM;
 
index ea1506679c6650753b2efea810e77d85c9ddb0f5..1ebf00c83409666579b2a35d9b05836dd2f745bf 100644 (file)
@@ -27,7 +27,7 @@ int iso_packets_buffer_init(struct iso_packets_buffer *b, struct fw_unit *unit,
        void *p;
        int err;
 
-       b->packets = kmalloc(count * sizeof(*b->packets), GFP_KERNEL);
+       b->packets = kmalloc_array(count, sizeof(*b->packets), GFP_KERNEL);
        if (!b->packets) {
                err = -ENOMEM;
                goto error;
index 8c0f8a9ee0baef5bd42961742b91b50356f90bbb..fc9bcd47d6a4c8ae92dfb620041411d887e32b6f 100644 (file)
@@ -420,7 +420,7 @@ static int sq_allocate_buffers(struct sound_queue *sq, int num, int size)
                return 0;
        sq->numBufs = num;
        sq->bufSize = size;
-       sq->buffers = kmalloc (num * sizeof(char *), GFP_KERNEL);
+       sq->buffers = kmalloc_array (num, sizeof(char *), GFP_KERNEL);
        if (!sq->buffers)
                return -ENOMEM;
        for (i = 0; i < num; i++) {
index d9f3fdb777e42bf2b7b89f5e7948fc1335597a5f..4105d9f653d9042a159ab8ba67f3d5cc6817e57e 100644 (file)
@@ -175,7 +175,7 @@ config SND_BT87X
        help
          If you want to record audio from TV cards based on
          Brooktree Bt878/Bt879 chips, say Y here and read
-         <file:Documentation/sound/alsa/Bt87x.txt>.
+         <file:Documentation/sound/cards/bt87x.rst>.
 
          To compile this driver as a module, choose M here: the module
          will be called snd-bt87x.
@@ -210,7 +210,7 @@ config SND_CMIPCI
        help
          If you want to use soundcards based on C-Media CMI8338, CMI8738,
          CMI8768 or CMI8770 chips, say Y here and read
-         <file:Documentation/sound/alsa/CMIPCI.txt>.
+         <file:Documentation/sound/cards/cmipci.rst>.
 
          To compile this driver as a module, choose M here: the module
          will be called snd-cmipci.
@@ -472,8 +472,8 @@ config SND_EMU10K1
          Audigy and E-mu APS (partially supported) soundcards.
 
          The confusing multitude of mixer controls is documented in
-         <file:Documentation/sound/alsa/SB-Live-mixer.txt> and
-         <file:Documentation/sound/alsa/Audigy-mixer.txt>.
+         <file:Documentation/sound/cards/sb-live-mixer.rst> and
+         <file:Documentation/sound/cards/audigy-mixer.rst>.
 
          To compile this driver as a module, choose M here: the module
          will be called snd-emu10k1.
@@ -735,7 +735,7 @@ config SND_MIXART
        select SND_PCM
        help
          If you want to use Digigram miXart soundcards, say Y here and
-         read <file:Documentation/sound/alsa/MIXART.txt>.
+         read <file:Documentation/sound/cards/mixart.rst>.
 
          To compile this driver as a module, choose M here: the module
          will be called snd-mixart.
index ed1251c5f449a9f2189745e03d6bfcc5e7eb61ba..146e1a3498c7352c53751871fb1dfd166df8dac1 100644 (file)
@@ -460,7 +460,7 @@ static int load_firmware(struct snd_cs46xx *chip,
                entry->size = le32_to_cpu(fwdat[fwlen++]);
                if (fwlen + entry->size > fwsize)
                        goto error_inval;
-               entry->data = kmalloc(entry->size * 4, GFP_KERNEL);
+               entry->data = kmalloc_array(entry->size, 4, GFP_KERNEL);
                if (!entry->data)
                        goto error;
                memcpy_le32(entry->data, &fwdat[fwlen], entry->size * 4);
@@ -4036,8 +4036,9 @@ int snd_cs46xx_create(struct snd_card *card,
        snd_cs46xx_proc_init(card, chip);
 
 #ifdef CONFIG_PM_SLEEP
-       chip->saved_regs = kmalloc(sizeof(*chip->saved_regs) *
-                                  ARRAY_SIZE(saved_regs), GFP_KERNEL);
+       chip->saved_regs = kmalloc_array(ARRAY_SIZE(saved_regs),
+                                        sizeof(*chip->saved_regs),
+                                        GFP_KERNEL);
        if (!chip->saved_regs) {
                snd_cs46xx_free(chip);
                return -ENOMEM;
index c44eadef64ae20db5d31e0d00ed416b629fe4289..598d140bb7cb719c799f07e381361ebd133f19a6 100644 (file)
@@ -240,10 +240,13 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip)
                return NULL;
 
        /* better to use vmalloc for this big table */
-       ins->symbol_table.symbols = vmalloc(sizeof(struct dsp_symbol_entry) *
-                                           DSP_MAX_SYMBOLS);
+       ins->symbol_table.symbols =
+               vmalloc(array_size(DSP_MAX_SYMBOLS,
+                                  sizeof(struct dsp_symbol_entry)));
        ins->code.data = kmalloc(DSP_CODE_BYTE_SIZE, GFP_KERNEL);
-       ins->modules = kmalloc(sizeof(struct dsp_module_desc) * DSP_MAX_MODULES, GFP_KERNEL);
+       ins->modules = kmalloc_array(DSP_MAX_MODULES,
+                                    sizeof(struct dsp_module_desc),
+                                    GFP_KERNEL);
        if (!ins->symbol_table.symbols || !ins->code.data || !ins->modules) {
                cs46xx_dsp_spos_destroy(chip);
                goto error;
index 908658a00377e3b2fb56579e97d93a3b94851af9..2ada8444abd99ba4d5d4ab14a59285eed87b61fb 100644 (file)
@@ -275,7 +275,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm)
 
        /* Get AMIXER resource */
        n_amixer = (n_amixer < 2) ? 2 : n_amixer;
-       apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
+       apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL);
        if (!apcm->amixers) {
                err = -ENOMEM;
                goto error1;
@@ -543,18 +543,18 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm)
        }
 
        if (n_srcc) {
-               apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL);
+               apcm->srccs = kcalloc(n_srcc, sizeof(void *), GFP_KERNEL);
                if (!apcm->srccs)
                        return -ENOMEM;
        }
        if (n_amixer) {
-               apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
+               apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL);
                if (!apcm->amixers) {
                        err = -ENOMEM;
                        goto error1;
                }
        }
-       apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL);
+       apcm->srcimps = kcalloc(n_srcimp, sizeof(void *), GFP_KERNEL);
        if (!apcm->srcimps) {
                err = -ENOMEM;
                goto error1;
@@ -819,7 +819,7 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc,
 
        /* Get AMIXER resource */
        n_amixer = (n_amixer < 2) ? 2 : n_amixer;
-       apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
+       apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL);
        if (!apcm->amixers) {
                err = -ENOMEM;
                goto error1;
@@ -1378,19 +1378,19 @@ static int atc_get_resources(struct ct_atc *atc)
        num_daios = ((atc->model == CTSB1270) ? 8 : 7);
        num_srcs = ((atc->model == CTSB1270) ? 6 : 4);
 
-       atc->daios = kzalloc(sizeof(void *)*num_daios, GFP_KERNEL);
+       atc->daios = kcalloc(num_daios, sizeof(void *), GFP_KERNEL);
        if (!atc->daios)
                return -ENOMEM;
 
-       atc->srcs = kzalloc(sizeof(void *)*num_srcs, GFP_KERNEL);
+       atc->srcs = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL);
        if (!atc->srcs)
                return -ENOMEM;
 
-       atc->srcimps = kzalloc(sizeof(void *)*num_srcs, GFP_KERNEL);
+       atc->srcimps = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL);
        if (!atc->srcimps)
                return -ENOMEM;
 
-       atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL);
+       atc->pcm = kcalloc(2 * 4, sizeof(void *), GFP_KERNEL);
        if (!atc->pcm)
                return -ENOMEM;
 
index 7f089cb433e17d6c9dde341d09b328aa471ec0c1..f35a7341e44634c1f4108e7c32c7cde102d8a369 100644 (file)
@@ -398,7 +398,8 @@ static int dao_rsc_init(struct dao *dao,
        if (err)
                return err;
 
-       dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL);
+       dao->imappers = kzalloc(array3_size(sizeof(void *), desc->msr, 2),
+                               GFP_KERNEL);
        if (!dao->imappers) {
                err = -ENOMEM;
                goto error1;
index 4f4a2a5dedb8f0fd8eb5b1679cfbab08c5441e12..db710d0a609fc14a55c0719816992b8a976ea2f0 100644 (file)
@@ -910,13 +910,14 @@ static int ct_mixer_get_mem(struct ct_mixer **rmixer)
        if (!mixer)
                return -ENOMEM;
 
-       mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM),
+       mixer->amixers = kcalloc(NUM_CT_AMIXERS * CHN_NUM, sizeof(void *),
                                 GFP_KERNEL);
        if (!mixer->amixers) {
                err = -ENOMEM;
                goto error1;
        }
-       mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL);
+       mixer->sums = kcalloc(NUM_CT_SUMS * CHN_NUM, sizeof(void *),
+                             GFP_KERNEL);
        if (!mixer->sums) {
                err = -ENOMEM;
                goto error2;
index bb4c9c3c89aee0c26583096b9a23c1b8d986b5d6..a4fc10723fc6b4d044b5a72846191faebb9ae96e 100644 (file)
@@ -679,7 +679,7 @@ static int srcimp_rsc_init(struct srcimp *srcimp,
                return err;
 
        /* Reserve memory for imapper nodes */
-       srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr,
+       srcimp->imappers = kcalloc(desc->msr, sizeof(struct imapper),
                                   GFP_KERNEL);
        if (!srcimp->imappers) {
                err = -ENOMEM;
index 18267de3a26993b834dfe9ad8f6fdc8363feda30..61f85ff91cd9ae39f91d485f09b0bbc40f026898 100644 (file)
@@ -1941,9 +1941,10 @@ int snd_emu10k1_create(struct snd_card *card,
                (unsigned long)emu->ptb_pages.addr,
                (unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes));
 
-       emu->page_ptr_table = vmalloc(emu->max_cache_pages * sizeof(void *));
-       emu->page_addr_table = vmalloc(emu->max_cache_pages *
-                                      sizeof(unsigned long));
+       emu->page_ptr_table = vmalloc(array_size(sizeof(void *),
+                                                emu->max_cache_pages));
+       emu->page_addr_table = vmalloc(array_size(sizeof(unsigned long),
+                                                 emu->max_cache_pages));
        if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) {
                err = -ENOMEM;
                goto error;
@@ -2099,7 +2100,7 @@ static int alloc_pm_buffer(struct snd_emu10k1 *emu)
        size = ARRAY_SIZE(saved_regs);
        if (emu->audigy)
                size += ARRAY_SIZE(saved_regs_audigy);
-       emu->saved_ptr = vmalloc(4 * NUM_G * size);
+       emu->saved_ptr = vmalloc(array3_size(4, NUM_G, size));
        if (!emu->saved_ptr)
                return -ENOMEM;
        if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0)
index b45a01bb73e5cd4f6f69c33f1dc367b6beb01000..de2ecbe95d6c2a31f10e6e540c15d1ec12598232 100644 (file)
@@ -2683,16 +2683,16 @@ int snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu)
        int len;
 
        len = emu->audigy ? 0x200 : 0x100;
-       emu->saved_gpr = kmalloc(len * 4, GFP_KERNEL);
+       emu->saved_gpr = kmalloc_array(len, 4, GFP_KERNEL);
        if (! emu->saved_gpr)
                return -ENOMEM;
        len = emu->audigy ? 0x100 : 0xa0;
-       emu->tram_val_saved = kmalloc(len * 4, GFP_KERNEL);
-       emu->tram_addr_saved = kmalloc(len * 4, GFP_KERNEL);
+       emu->tram_val_saved = kmalloc_array(len, 4, GFP_KERNEL);
+       emu->tram_addr_saved = kmalloc_array(len, 4, GFP_KERNEL);
        if (! emu->tram_val_saved || ! emu->tram_addr_saved)
                return -ENOMEM;
        len = emu->audigy ? 2 * 1024 : 2 * 512;
-       emu->saved_icode = vmalloc(len * 4);
+       emu->saved_icode = vmalloc(array_size(len, 4));
        if (! emu->saved_icode)
                return -ENOMEM;
        return 0;
index d39458ab251fb0685e28993f2c89b2505dc6174c..69f9b100bd24c12e834378006e5649f6b668aedb 100644 (file)
@@ -1858,7 +1858,9 @@ int snd_emu10k1_pcm_efx(struct snd_emu10k1 *emu, int device)
        if (!kctl)
                return -ENOMEM;
        kctl->id.device = device;
-       snd_ctl_add(emu->card, kctl);
+       err = snd_ctl_add(emu->card, kctl);
+       if (err < 0)
+               return err;
 
        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_DEV, snd_dma_pci_data(emu->pci), 64*1024, 64*1024);
 
index a30da78a95b7035b36e9442eefe6962f2255e4ca..4948b95f66653320e86c4a9d8abe29ce48ec7085 100644 (file)
@@ -874,7 +874,7 @@ int snd_p16v_mixer(struct snd_emu10k1 *emu)
 
 int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu)
 {
-       emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80);
+       emu->p16v_saved = vmalloc(array_size(NUM_CHS * 4, 0x80));
        if (! emu->p16v_saved)
                return -ENOMEM;
        return 0;
index 73a67bc3586bcd55e6e0387093fcda8917e6c2e7..e3fb9c61017c6535e3d8fb4cb4f9694bce2e2bb1 100644 (file)
@@ -1068,11 +1068,19 @@ static int snd_fm801_mixer(struct fm801 *chip)
                if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_sec)) < 0)
                        return err;
        }
-       for (i = 0; i < FM801_CONTROLS; i++)
-               snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls[i], chip));
+       for (i = 0; i < FM801_CONTROLS; i++) {
+               err = snd_ctl_add(chip->card,
+                       snd_ctl_new1(&snd_fm801_controls[i], chip));
+               if (err < 0)
+                       return err;
+       }
        if (chip->multichannel) {
-               for (i = 0; i < FM801_CONTROLS_MULTI; i++)
-                       snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls_multi[i], chip));
+               for (i = 0; i < FM801_CONTROLS_MULTI; i++) {
+                       err = snd_ctl_add(chip->card,
+                               snd_ctl_new1(&snd_fm801_controls_multi[i], chip));
+                       if (err < 0)
+                               return err;
+               }
        }
        return 0;
 }
index 08151f3c0b139703fcd175cc5c255f66f89755ca..d91c87e41756ea5fceaee73d84e211b9ebba929d 100644 (file)
@@ -158,7 +158,7 @@ static int read_and_add_raw_conns(struct hda_codec *codec, hda_nid_t nid)
        len = snd_hda_get_raw_connections(codec, nid, list, ARRAY_SIZE(list));
        if (len == -ENOSPC) {
                len = snd_hda_get_num_raw_conns(codec, nid);
-               result = kmalloc(sizeof(hda_nid_t) * len, GFP_KERNEL);
+               result = kmalloc_array(len, sizeof(hda_nid_t), GFP_KERNEL);
                if (!result)
                        return -ENOMEM;
                len = snd_hda_get_raw_connections(codec, nid, result, len);
@@ -438,7 +438,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node)
        int i;
        hda_nid_t nid;
 
-       codec->wcaps = kmalloc(codec->core.num_nodes * 4, GFP_KERNEL);
+       codec->wcaps = kmalloc_array(codec->core.num_nodes, 4, GFP_KERNEL);
        if (!codec->wcaps)
                return -ENOMEM;
        nid = codec->core.start_nid;
index 033aa84365b9b26de27dbb2918498c1d114b892b..c6b778b2580c12c7f34a08147ce623099f386cff 100644 (file)
@@ -825,8 +825,9 @@ static void print_codec_info(struct snd_info_entry *entry,
                if (wid_caps & AC_WCAP_CONN_LIST) {
                        conn_len = snd_hda_get_num_raw_conns(codec, nid);
                        if (conn_len > 0) {
-                               conn = kmalloc(sizeof(hda_nid_t) * conn_len,
-                                              GFP_KERNEL);
+                               conn = kmalloc_array(conn_len,
+                                                    sizeof(hda_nid_t),
+                                                    GFP_KERNEL);
                                if (!conn)
                                        return;
                                if (snd_hda_get_raw_connections(codec, nid, conn,
index 292e2c592c17af0b5580f67e2e49be18fdd9e1fc..04e949aa01ada5492765cd313608624f3a42c7b9 100644 (file)
@@ -7482,7 +7482,9 @@ static int ca0132_prepare_verbs(struct hda_codec *codec)
        spec->chip_init_verbs = ca0132_init_verbs0;
        if (spec->quirk == QUIRK_SBZ)
                spec->sbz_init_verbs = sbz_init_verbs;
-       spec->spec_init_verbs = kzalloc(sizeof(struct hda_verb) * NUM_SPEC_VERBS, GFP_KERNEL);
+       spec->spec_init_verbs = kcalloc(NUM_SPEC_VERBS,
+                                       sizeof(struct hda_verb),
+                                       GFP_KERNEL);
        if (!spec->spec_init_verbs)
                return -ENOMEM;
 
index dbf9910c52693bfaaf0017bb31aeab240d2152d4..e7fcfc3b8885fb7470dc1b10a49f305f7bca323d 100644 (file)
@@ -958,6 +958,8 @@ static const struct snd_pci_quirk cxt5066_fixups[] = {
        SND_PCI_QUIRK(0x103c, 0x8079, "HP EliteBook 840 G3", CXT_FIXUP_HP_DOCK),
        SND_PCI_QUIRK(0x103c, 0x807C, "HP EliteBook 820 G3", CXT_FIXUP_HP_DOCK),
        SND_PCI_QUIRK(0x103c, 0x80FD, "HP ProBook 640 G2", CXT_FIXUP_HP_DOCK),
+       SND_PCI_QUIRK(0x103c, 0x83b3, "HP EliteBook 830 G5", CXT_FIXUP_HP_DOCK),
+       SND_PCI_QUIRK(0x103c, 0x83d3, "HP ProBook 640 G4", CXT_FIXUP_HP_DOCK),
        SND_PCI_QUIRK(0x103c, 0x8174, "HP Spectre x360", CXT_FIXUP_HP_SPECTRE),
        SND_PCI_QUIRK(0x103c, 0x8115, "HP Z1 Gen3", CXT_FIXUP_HP_GATE_MIC),
        SND_PCI_QUIRK(0x103c, 0x814f, "HP ZBook 15u G3", CXT_FIXUP_MUTE_LED_GPIO),
index d64dcb9a4c9957ed8d473eb1cb92e9af93a5e4f4..e9bd33ea538f239891c031a1a81e075a35c75043 100644 (file)
@@ -793,6 +793,9 @@ static inline void alc_shutup(struct hda_codec *codec)
 {
        struct alc_spec *spec = codec->spec;
 
+       if (!snd_hda_get_bool_hint(codec, "shutup"))
+               return; /* disabled explicitly by hints */
+
        if (spec && spec->shutup)
                spec->shutup(codec);
        else
index 9655b08a1c52f194c7b627ba32732dab604f5929..6c85f13ab23f17f7ef4031f5f73797fb383584a7 100644 (file)
@@ -1016,6 +1016,10 @@ static int snd_lx6464es_create(struct snd_card *card,
 
        /* dsp port */
        chip->port_dsp_bar = pci_ioremap_bar(pci, 2);
+       if (!chip->port_dsp_bar) {
+               dev_err(card->dev, "cannot remap PCI memory region\n");
+               goto remap_pci_failed;
+       }
 
        err = request_threaded_irq(pci->irq, lx_interrupt, lx_threaded_irq,
                                   IRQF_SHARED, KBUILD_MODNAME, chip);
@@ -1055,6 +1059,9 @@ static int snd_lx6464es_create(struct snd_card *card,
        free_irq(pci->irq, chip);
 
 request_irq_failed:
+       iounmap(chip->port_dsp_bar);
+
+remap_pci_failed:
        pci_release_regions(pci);
 
 request_regions_failed:
index 8f20dec97843edf05df2ea27f5c816fc51f15f1e..224e942f556de061ad91a5e416f4645919d88e94 100644 (file)
@@ -2657,7 +2657,10 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
        chip->irq = pci->irq;
 
 #ifdef CONFIG_PM_SLEEP
-       chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH));
+       chip->suspend_mem =
+               vmalloc(array_size(sizeof(u16),
+                                  REV_B_CODE_MEMORY_LENGTH +
+                                       REV_B_DATA_MEMORY_LENGTH));
        if (chip->suspend_mem == NULL)
                dev_warn(card->dev, "can't allocate apm buffer\n");
 #endif
index a8abb15e3c3ab0d3bce8b7c984d15d826b8699bd..7fbdb703bfcd58ef5df9401a3c6c6ab4a0d8d454 100644 (file)
@@ -1188,6 +1188,7 @@ SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0);
 static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
 {
        struct gameport *gp;
+       int err;
 
        sonic->gameport = gp = gameport_allocate_port();
        if (!gp) {
@@ -1203,7 +1204,10 @@ static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
 
        gameport_register_port(gp);
 
-       snd_ctl_add(sonic->card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic));
+       err = snd_ctl_add(sonic->card,
+               snd_ctl_new1(&snd_sonicvibes_game_control, sonic));
+       if (err < 0)
+               return err;
 
        return 0;
 }
@@ -1515,7 +1519,11 @@ static int snd_sonic_probe(struct pci_dev *pci,
                return err;
        }
 
-       snd_sonicvibes_create_gameport(sonic);
+       err = snd_sonicvibes_create_gameport(sonic);
+       if (err < 0) {
+               snd_card_free(card);
+               return err;
+       }
 
        if ((err = snd_card_register(card)) < 0) {
                snd_card_free(card);
index eabd84d9ffee7728bef4184a06c4a1b9c494f870..49c64fae3466c755bae81e12a9d09d3461837ad2 100644 (file)
@@ -3362,7 +3362,9 @@ static int snd_trident_tlb_alloc(struct snd_trident *trident)
        trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);
        trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4);
        /* allocate shadow TLB page table (virtual addresses) */
-       trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long));
+       trident->tlb.shadow_entries =
+               vmalloc(array_size(SNDRV_TRIDENT_MAX_PAGES,
+                                  sizeof(unsigned long)));
        if (!trident->tlb.shadow_entries)
                return -ENOMEM;
 
index 3a1c0b8b4ea276e840ce9f397cecc61610e736f6..c488c5afa19591410d4c872bd3decf531f0c4555 100644 (file)
@@ -439,7 +439,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
                        return -ENOMEM;
        }
        if (! dev->idx_table) {
-               dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL);
+               dev->idx_table = kmalloc_array(VIA_TABLE_SIZE,
+                                              sizeof(*dev->idx_table),
+                                              GFP_KERNEL);
                if (! dev->idx_table)
                        return -ENOMEM;
        }
index 8a69221c1b86db0410fa64a981bafd37e7a69c79..b13c8688cc8d98b947910a6a86653fc5b8b0d1ab 100644 (file)
@@ -292,7 +292,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre
                        return -ENOMEM;
        }
        if (! dev->idx_table) {
-               dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL);
+               dev->idx_table = kmalloc_array(VIA_TABLE_SIZE,
+                                              sizeof(*dev->idx_table),
+                                              GFP_KERNEL);
                if (! dev->idx_table)
                        return -ENOMEM;
        }
index 8ca2e41e58270044c1442eb8b5546688cd519c83..6f81396aadc9efc510c4b3dc7bf49f3895e62936 100644 (file)
@@ -2435,8 +2435,8 @@ int snd_ymfpci_create(struct snd_card *card,
                goto free_chip;
 
 #ifdef CONFIG_PM_SLEEP
-       chip->saved_regs = kmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32),
-                                  GFP_KERNEL);
+       chip->saved_regs = kmalloc_array(YDSXGR_NUM_SAVED_REGS, sizeof(u32),
+                                        GFP_KERNEL);
        if (chip->saved_regs == NULL) {
                err = -ENOMEM;
                goto free_chip;
index fb650659c3a3ef229ca03b9b51744834b8a34500..a906560d0cddfad320aa75b56f719d94d01acef4 100644 (file)
@@ -339,8 +339,8 @@ static int au1xpsc_pcm_drvprobe(struct platform_device *pdev)
 {
        struct au1xpsc_audio_dmadata *dmadata;
 
-       dmadata = devm_kzalloc(&pdev->dev,
-                              2 * sizeof(struct au1xpsc_audio_dmadata),
+       dmadata = devm_kcalloc(&pdev->dev,
+                              2, sizeof(struct au1xpsc_audio_dmadata),
                               GFP_KERNEL);
        if (!dmadata)
                return -ENOMEM;
index 6fa11888672d4ca0c60096205c45e52f647f9ab8..38e4a8515709743c75befa77addca1b491c7979b 100644 (file)
@@ -771,7 +771,7 @@ static int hdmi_codec_probe(struct platform_device *pdev)
        hcp->hcd = *hcd;
        mutex_init(&hcp->current_stream_lock);
 
-       hcp->daidrv = devm_kzalloc(dev, dai_count * sizeof(*hcp->daidrv),
+       hcp->daidrv = devm_kcalloc(dev, dai_count, sizeof(*hcp->daidrv),
                                   GFP_KERNEL);
        if (!hcp->daidrv)
                return -ENOMEM;
index 712384581ebf3d2f5307936bf0ebf3a6ef3f1210..1dc70f452c1b9505d8e0e2952f46fcf2982195c4 100644 (file)
@@ -3449,8 +3449,9 @@ static int rt5645_probe(struct snd_soc_component *component)
        if (rt5645->pdata.long_name)
                component->card->long_name = rt5645->pdata.long_name;
 
-       rt5645->eq_param = devm_kzalloc(component->dev,
-               RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s), GFP_KERNEL);
+       rt5645->eq_param = devm_kcalloc(component->dev,
+               RT5645_HWEQ_NUM, sizeof(struct rt5645_eq_param_s),
+               GFP_KERNEL);
 
        return 0;
 }
index f13ef334c0d728dec446c24b7da63d0fa1d4fdc3..9037a35b931dbc7a6c07173439d456f81b3bba76 100644 (file)
@@ -2023,8 +2023,9 @@ static void wm8904_handle_pdata(struct snd_soc_component *component)
                                     wm8904_get_drc_enum, wm8904_put_drc_enum);
 
                /* We need an array of texts for the enum API */
-               wm8904->drc_texts = kmalloc(sizeof(char *)
-                                           * pdata->num_drc_cfgs, GFP_KERNEL);
+               wm8904->drc_texts = kmalloc_array(pdata->num_drc_cfgs,
+                                                 sizeof(char *),
+                                                 GFP_KERNEL);
                if (!wm8904->drc_texts)
                        return;
 
index 8d495220fa25d840b1090294b297b6e737339c26..108e8bf42a346e3651076b9b320e973787046eb2 100644 (file)
@@ -932,8 +932,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
                };
 
                /* We need an array of texts for the enum API */
-               wm8994->mbc_texts = kmalloc(sizeof(char *)
-                                           * pdata->num_mbc_cfgs, GFP_KERNEL);
+               wm8994->mbc_texts = kmalloc_array(pdata->num_mbc_cfgs,
+                                                 sizeof(char *),
+                                                 GFP_KERNEL);
                if (!wm8994->mbc_texts)
                        return;
 
@@ -957,8 +958,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
                };
 
                /* We need an array of texts for the enum API */
-               wm8994->vss_texts = kmalloc(sizeof(char *)
-                                           * pdata->num_vss_cfgs, GFP_KERNEL);
+               wm8994->vss_texts = kmalloc_array(pdata->num_vss_cfgs,
+                                                 sizeof(char *),
+                                                 GFP_KERNEL);
                if (!wm8994->vss_texts)
                        return;
 
@@ -983,8 +985,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
                };
 
                /* We need an array of texts for the enum API */
-               wm8994->vss_hpf_texts = kmalloc(sizeof(char *)
-                                               * pdata->num_vss_hpf_cfgs, GFP_KERNEL);
+               wm8994->vss_hpf_texts = kmalloc_array(pdata->num_vss_hpf_cfgs,
+                                                     sizeof(char *),
+                                                     GFP_KERNEL);
                if (!wm8994->vss_hpf_texts)
                        return;
 
@@ -1010,8 +1013,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component)
                };
 
                /* We need an array of texts for the enum API */
-               wm8994->enh_eq_texts = kmalloc(sizeof(char *)
-                                               * pdata->num_enh_eq_cfgs, GFP_KERNEL);
+               wm8994->enh_eq_texts = kmalloc_array(pdata->num_enh_eq_cfgs,
+                                                    sizeof(char *),
+                                                    GFP_KERNEL);
                if (!wm8994->enh_eq_texts)
                        return;
 
index 6e9e32a072598ac670c6a532f645f042c9bb71e1..7fdfdf3f6e67e5c045d6b80b0ac516dac3697dea 100644 (file)
@@ -3298,8 +3298,8 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
                };
 
                /* We need an array of texts for the enum API */
-               wm8994->drc_texts = devm_kzalloc(wm8994->hubs.component->dev,
-                           sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL);
+               wm8994->drc_texts = devm_kcalloc(wm8994->hubs.component->dev,
+                           pdata->num_drc_cfgs, sizeof(char *), GFP_KERNEL);
                if (!wm8994->drc_texts)
                        return;
 
index 2175dccdf38891045d89212f5f60aa18c19f2807..2fcdd84021a565b36f46b3858a0f28aaae88c411 100644 (file)
@@ -1899,7 +1899,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs,
                adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n",
                          pos + len, be32_to_cpu(val));
 
-       alg = kzalloc(len * 2, GFP_KERNEL | GFP_DMA);
+       alg = kcalloc(len, 2, GFP_KERNEL | GFP_DMA);
        if (!alg)
                return ERR_PTR(-ENOMEM);
 
index 1f96c9dbe9c49c1422561b7bd8b6dbd3c45bc68d..47c0c821d325f4b14b50b16b8fb9043c06670861 100644 (file)
@@ -1868,8 +1868,8 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
 
        mcasp->num_serializer = pdata->num_serializer;
 #ifdef CONFIG_PM_SLEEP
-       mcasp->context.xrsr_regs = devm_kzalloc(&pdev->dev,
-                                       sizeof(u32) * mcasp->num_serializer,
+       mcasp->context.xrsr_regs = devm_kcalloc(&pdev->dev,
+                                       mcasp->num_serializer, sizeof(u32),
                                        GFP_KERNEL);
        if (!mcasp->context.xrsr_regs) {
                ret = -ENOMEM;
@@ -2004,13 +2004,15 @@ static int davinci_mcasp_probe(struct platform_device *pdev)
         * bytes.
         */
        mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list =
-               devm_kzalloc(mcasp->dev, sizeof(unsigned int) *
-                            (32 + mcasp->num_serializer - 1),
+               devm_kcalloc(mcasp->dev,
+                            32 + mcasp->num_serializer - 1,
+                            sizeof(unsigned int),
                             GFP_KERNEL);
 
        mcasp->chconstr[SNDRV_PCM_STREAM_CAPTURE].list =
-               devm_kzalloc(mcasp->dev, sizeof(unsigned int) *
-                            (32 + mcasp->num_serializer - 1),
+               devm_kcalloc(mcasp->dev,
+                            32 + mcasp->num_serializer - 1,
+                            sizeof(unsigned int),
                             GFP_KERNEL);
 
        if (!mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list ||
index 1b6164249341138ec70ae38e57d48957c69c7ba1..d93bacacbd5b4d018b0633b24f71cee60bf756e3 100644 (file)
@@ -296,8 +296,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev)
        if (num == 0)
                return -EINVAL;
 
-       dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
-       dai_link  = devm_kzalloc(dev, sizeof(*dai_link)  * num, GFP_KERNEL);
+       dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
+       dai_link  = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
        if (!dai_props || !dai_link)
                return -ENOMEM;
 
index a967aa143d51864cb03e3c9f8fcb9c7ea72c8a51..095ef6426d4217ec91e001aee1f8b6997a821651 100644 (file)
@@ -348,8 +348,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev)
        if (num == 0)
                return -EINVAL;
 
-       dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
-       dai_link  = devm_kzalloc(dev, sizeof(*dai_link)  * num, GFP_KERNEL);
+       dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
+       dai_link  = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
        if (!dai_props || !dai_link)
                return -ENOMEM;
 
index 4a516c428b3df239b7af267f978af87619f5827c..8b374af86a6e26e7b0af5efa4e45d0fa84c14983 100644 (file)
@@ -340,8 +340,8 @@ static int asoc_simple_card_parse_aux_devs(struct device_node *node,
        if (n <= 0)
                return -EINVAL;
 
-       card->aux_dev = devm_kzalloc(dev,
-                       n * sizeof(*card->aux_dev), GFP_KERNEL);
+       card->aux_dev = devm_kcalloc(dev,
+                       n, sizeof(*card->aux_dev), GFP_KERNEL);
        if (!card->aux_dev)
                return -ENOMEM;
 
@@ -435,8 +435,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
        if (!priv)
                return -ENOMEM;
 
-       dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
-       dai_link  = devm_kzalloc(dev, sizeof(*dai_link)  * num, GFP_KERNEL);
+       dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
+       dai_link  = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
        if (!dai_props || !dai_link)
                return -ENOMEM;
 
index 48606c63562a7694a83fe7b4d38210908d38ad4e..487716559deb6c58762f8c1441264366102387ae 100644 (file)
@@ -246,8 +246,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev)
 
        num = of_get_child_count(np);
 
-       dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
-       dai_link  = devm_kzalloc(dev, sizeof(*dai_link)  * num, GFP_KERNEL);
+       dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
+       dai_link  = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
        if (!dai_props || !dai_link)
                return -ENOMEM;
 
index d7fbb0a0a28b02f16d12ef89fef24f98b8dac6da..388cefd7340ab3a8932fe93b31c2cc60069326b7 100644 (file)
@@ -509,8 +509,8 @@ static int img_i2s_in_probe(struct platform_device *pdev)
 
        pm_runtime_put(&pdev->dev);
 
-       i2s->suspend_ch_ctl = devm_kzalloc(dev,
-               sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL);
+       i2s->suspend_ch_ctl = devm_kcalloc(dev,
+               i2s->max_i2s_chan, sizeof(*i2s->suspend_ch_ctl), GFP_KERNEL);
        if (!i2s->suspend_ch_ctl) {
                ret = -ENOMEM;
                goto err_suspend;
index 30a95bcef2db97ebd9c2904c1caf697109309d30..fc2d1dac63339e84385ad3ffa8228e8259ad4817 100644 (file)
@@ -479,8 +479,8 @@ static int img_i2s_out_probe(struct platform_device *pdev)
                return PTR_ERR(i2s->clk_ref);
        }
 
-       i2s->suspend_ch_ctl = devm_kzalloc(dev,
-               sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL);
+       i2s->suspend_ch_ctl = devm_kcalloc(dev,
+               i2s->max_i2s_chan, sizeof(*i2s->suspend_ch_ctl), GFP_KERNEL);
        if (!i2s->suspend_ch_ctl)
                return -ENOMEM;
 
index 62f3a8e0ec87696389d46c7824297b5e36fce188..dcff13802c007ece2a87b6bd695c6362613dc67b 100644 (file)
@@ -121,8 +121,8 @@ static int msg_empty_list_init(struct sst_generic_ipc *ipc)
 {
        int i;
 
-       ipc->msg = kzalloc(sizeof(struct ipc_message) *
-               IPC_EMPTY_LIST_SIZE, GFP_KERNEL);
+       ipc->msg = kcalloc(IPC_EMPTY_LIST_SIZE, sizeof(struct ipc_message),
+                          GFP_KERNEL);
        if (ipc->msg == NULL)
                return -ENOMEM;
 
index 2c5129782959730e471eae741528b9814f7e2068..fcdc716754b6349b4ec304c31a535748842b2dc9 100644 (file)
@@ -2428,8 +2428,10 @@ static int skl_tplg_get_token(struct device *dev,
 
        case SKL_TKN_U8_DYN_IN_PIN:
                if (!mconfig->m_in_pin)
-                       mconfig->m_in_pin = devm_kzalloc(dev, MAX_IN_QUEUE *
-                                       sizeof(*mconfig->m_in_pin), GFP_KERNEL);
+                       mconfig->m_in_pin =
+                               devm_kcalloc(dev, MAX_IN_QUEUE,
+                                            sizeof(*mconfig->m_in_pin),
+                                            GFP_KERNEL);
                if (!mconfig->m_in_pin)
                        return -ENOMEM;
 
@@ -2439,8 +2441,10 @@ static int skl_tplg_get_token(struct device *dev,
 
        case SKL_TKN_U8_DYN_OUT_PIN:
                if (!mconfig->m_out_pin)
-                       mconfig->m_out_pin = devm_kzalloc(dev, MAX_IN_QUEUE *
-                                       sizeof(*mconfig->m_in_pin), GFP_KERNEL);
+                       mconfig->m_out_pin =
+                               devm_kcalloc(dev, MAX_IN_QUEUE,
+                                            sizeof(*mconfig->m_in_pin),
+                                            GFP_KERNEL);
                if (!mconfig->m_out_pin)
                        return -ENOMEM;
 
@@ -2852,14 +2856,14 @@ static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w,
        mconfig->time_slot = dfw->time_slot;
        mconfig->formats_config.caps_size = dfw->caps.caps_size;
 
-       mconfig->m_in_pin = devm_kzalloc(dev,
-                               MAX_IN_QUEUE * sizeof(*mconfig->m_in_pin),
+       mconfig->m_in_pin = devm_kcalloc(dev,
+                               MAX_IN_QUEUE, sizeof(*mconfig->m_in_pin),
                                GFP_KERNEL);
        if (!mconfig->m_in_pin)
                return -ENOMEM;
 
-       mconfig->m_out_pin = devm_kzalloc(dev,
-                               MAX_OUT_QUEUE * sizeof(*mconfig->m_out_pin),
+       mconfig->m_out_pin = devm_kcalloc(dev,
+                               MAX_OUT_QUEUE, sizeof(*mconfig->m_out_pin),
                                GFP_KERNEL);
        if (!mconfig->m_out_pin)
                return -ENOMEM;
index 828d11c30c6a20f39acda7db3406611a5f747665..968fba4d75339922c398f0fb4d56556e0b9a8e5f 100644 (file)
@@ -1347,7 +1347,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
        afe->dev = &pdev->dev;
        dev = afe->dev;
 
-       afe_priv->i2s_path = devm_kzalloc(dev, afe_priv->soc->i2s_num *
+       afe_priv->i2s_path = devm_kcalloc(dev,
+                                         afe_priv->soc->i2s_num,
                                          sizeof(struct mt2701_i2s_path),
                                          GFP_KERNEL);
        if (!afe_priv->i2s_path)
index 77a30f0f0c960fd89b7bb4fedb70607bbb40bd41..4dce494dfbd3e6c3e6cb3126cb0dfe4db13907eb 100644 (file)
@@ -22,7 +22,7 @@
  *
  */
 
-#include <linux/gpio.h>
+#include <linux/gpio/consumer.h>
 #include <linux/spinlock.h>
 #include <linux/tty.h>
 #include <linux/module.h>
@@ -32,7 +32,6 @@
 
 #include <asm/mach-types.h>
 
-#include <mach/board-ams-delta.h>
 #include <linux/platform_data/asoc-ti-mcbsp.h>
 
 #include "omap-mcbsp.h"
@@ -213,7 +212,6 @@ static const struct snd_kcontrol_new ams_delta_audio_controls[] = {
 static struct snd_soc_jack ams_delta_hook_switch;
 static struct snd_soc_jack_gpio ams_delta_hook_switch_gpios[] = {
        {
-               .gpio = 4,
                .name = "hook_switch",
                .report = SND_JACK_HEADSET,
                .invert = 1,
@@ -259,6 +257,7 @@ static struct timer_list cx81801_timer;
 static bool cx81801_cmd_pending;
 static bool ams_delta_muted;
 static DEFINE_SPINLOCK(ams_delta_lock);
+static struct gpio_desc *gpiod_modem_codec;
 
 static void cx81801_timeout(struct timer_list *unused)
 {
@@ -272,7 +271,7 @@ static void cx81801_timeout(struct timer_list *unused)
        /* Reconnect the codec DAI back from the modem to the CPU DAI
         * only if digital mute still off */
        if (!muted)
-               ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC, 0);
+               gpiod_set_value(gpiod_modem_codec, 0);
 }
 
 /* Line discipline .open() */
@@ -381,8 +380,7 @@ static void cx81801_receive(struct tty_struct *tty,
                /* Apply config pulse by connecting the codec to the modem
                 * if not already done */
                if (apply)
-                       ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
-                                               AMS_DELTA_LATCH2_MODEM_CODEC);
+                       gpiod_set_value(gpiod_modem_codec, 1);
                break;
        }
 }
@@ -432,8 +430,7 @@ static int ams_delta_digital_mute(struct snd_soc_dai *dai, int mute)
        spin_unlock_bh(&ams_delta_lock);
 
        if (apply)
-               ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
-                               mute ? AMS_DELTA_LATCH2_MODEM_CODEC : 0);
+               gpiod_set_value(gpiod_modem_codec, !!mute);
        return 0;
 }
 
@@ -469,14 +466,6 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
        /* Store a pointer to the codec structure for tty ldisc use */
        cx20442_codec = rtd->codec_dai->component;
 
-       /* Set up digital mute if not provided by the codec */
-       if (!codec_dai->driver->ops) {
-               codec_dai->driver->ops = &ams_delta_dai_ops;
-       } else {
-               ams_delta_ops.startup = ams_delta_startup;
-               ams_delta_ops.shutdown = ams_delta_shutdown;
-       }
-
        /* Add hook switch - can be used to control the codec from userspace
         * even if line discipline fails */
        ret = snd_soc_card_jack_new(card, "hook_switch", SND_JACK_HEADSET,
@@ -486,7 +475,7 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
                                "Failed to allocate resources for hook switch, "
                                "will continue without one.\n");
        else {
-               ret = snd_soc_jack_add_gpios(&ams_delta_hook_switch,
+               ret = snd_soc_jack_add_gpiods(card->dev, &ams_delta_hook_switch,
                                        ARRAY_SIZE(ams_delta_hook_switch_gpios),
                                        ams_delta_hook_switch_gpios);
                if (ret)
@@ -495,6 +484,21 @@ static int ams_delta_cx20442_init(struct snd_soc_pcm_runtime *rtd)
                                "will continue with hook switch inactive.\n");
        }
 
+       gpiod_modem_codec = devm_gpiod_get(card->dev, "modem_codec",
+                                          GPIOD_OUT_HIGH);
+       if (IS_ERR(gpiod_modem_codec)) {
+               dev_warn(card->dev, "Failed to obtain modem_codec GPIO\n");
+               return 0;
+       }
+
+       /* Set up digital mute if not provided by the codec */
+       if (!codec_dai->driver->ops) {
+               codec_dai->driver->ops = &ams_delta_dai_ops;
+       } else {
+               ams_delta_ops.startup = ams_delta_startup;
+               ams_delta_ops.shutdown = ams_delta_shutdown;
+       }
+
        /* Register optional line discipline for over the modem control */
        ret = tty_register_ldisc(N_V253, &cx81801_ops);
        if (ret) {
index 7c998ea4ebee02bdd27354d034f90b22d596c035..12d4513ebe8af17ba22614053a27b2ad2dbe23ee 100644 (file)
@@ -425,8 +425,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev)
        if (priv->sspa == NULL)
                return -ENOMEM;
 
-       priv->dma_params = devm_kzalloc(&pdev->dev,
-                       2 * sizeof(struct snd_dmaengine_dai_dma_data),
+       priv->dma_params = devm_kcalloc(&pdev->dev,
+                       2, sizeof(struct snd_dmaengine_dai_dma_data),
                        GFP_KERNEL);
        if (priv->dma_params == NULL)
                return -ENOMEM;
index f184168f9a416191368ae19a3279826fb6831c7d..f2a51ae2b674d5a3107ab568bdc1842d6e746145 100644 (file)
@@ -462,7 +462,7 @@ static int rockchip_sound_of_parse_dais(struct device *dev,
        num_routes = 0;
        for (i = 0; i < ARRAY_SIZE(rockchip_routes); i++)
                num_routes += rockchip_routes[i].num_routes;
-       routes = devm_kzalloc(dev, num_routes * sizeof(*routes),
+       routes = devm_kcalloc(dev, num_routes, sizeof(*routes),
                              GFP_KERNEL);
        if (!routes)
                return -ENOMEM;
index 4221937ae79bab7b90d229afd15e77fe05eb7afe..5900fb535a2bf9f4f91d82e16a7a516b1d9506f5 100644 (file)
@@ -155,7 +155,7 @@ int rsnd_cmd_probe(struct rsnd_priv *priv)
        if (!nr)
                return 0;
 
-       cmd = devm_kzalloc(dev, sizeof(*cmd) * nr, GFP_KERNEL);
+       cmd = devm_kcalloc(dev, nr, sizeof(*cmd), GFP_KERNEL);
        if (!cmd)
                return -ENOMEM;
 
index af04d41a4274c85d79ba6ba64edb09b437235c56..f237002180c0c95dbd954cf408f8de56fb2555db 100644 (file)
@@ -1110,8 +1110,8 @@ static int rsnd_dai_probe(struct rsnd_priv *priv)
        if (!nr)
                return -EINVAL;
 
-       rdrv = devm_kzalloc(dev, sizeof(*rdrv) * nr, GFP_KERNEL);
-       rdai = devm_kzalloc(dev, sizeof(*rdai) * nr, GFP_KERNEL);
+       rdrv = devm_kcalloc(dev, nr, sizeof(*rdrv), GFP_KERNEL);
+       rdai = devm_kcalloc(dev, nr, sizeof(*rdai), GFP_KERNEL);
        if (!rdrv || !rdai)
                return -ENOMEM;
 
index d201d551866db10e3f6523d1bb30caa045df0e8a..83be7d3ae0a8390ad7eab05c4dd666708bf62b16 100644 (file)
@@ -378,7 +378,7 @@ int rsnd_ctu_probe(struct rsnd_priv *priv)
                goto rsnd_ctu_probe_done;
        }
 
-       ctu = devm_kzalloc(dev, sizeof(*ctu) * nr, GFP_KERNEL);
+       ctu = devm_kcalloc(dev, nr, sizeof(*ctu), GFP_KERNEL);
        if (!ctu) {
                ret = -ENOMEM;
                goto rsnd_ctu_probe_done;
index dbe54f024d68824fa0b3bd81122891989adb9faf..ca1780e0b8304afc0567585d002b965fc978682b 100644 (file)
@@ -344,7 +344,7 @@ int rsnd_dvc_probe(struct rsnd_priv *priv)
                goto rsnd_dvc_probe_done;
        }
 
-       dvc     = devm_kzalloc(dev, sizeof(*dvc) * nr, GFP_KERNEL);
+       dvc     = devm_kcalloc(dev, nr, sizeof(*dvc), GFP_KERNEL);
        if (!dvc) {
                ret = -ENOMEM;
                goto rsnd_dvc_probe_done;
index 7998380766f6f210accaa91bc50f3b3aaeea0bd0..1881b2de9126e3b6cc3218a5a067f32aa5b56868 100644 (file)
@@ -294,7 +294,7 @@ int rsnd_mix_probe(struct rsnd_priv *priv)
                goto rsnd_mix_probe_done;
        }
 
-       mix     = devm_kzalloc(dev, sizeof(*mix) * nr, GFP_KERNEL);
+       mix     = devm_kcalloc(dev, nr, sizeof(*mix), GFP_KERNEL);
        if (!mix) {
                ret = -ENOMEM;
                goto rsnd_mix_probe_done;
index a727e71587b6e305ff89011b1bce8dc2f5789bc8..6c72d1a81cf5e56237c9e3b4f34128316afdfd36 100644 (file)
@@ -575,7 +575,7 @@ int rsnd_src_probe(struct rsnd_priv *priv)
                goto rsnd_src_probe_done;
        }
 
-       src     = devm_kzalloc(dev, sizeof(*src) * nr, GFP_KERNEL);
+       src     = devm_kcalloc(dev, nr, sizeof(*src), GFP_KERNEL);
        if (!src) {
                ret = -ENOMEM;
                goto rsnd_src_probe_done;
index 9538f76f8e2067dd42f1507515388593462c43ad..6e1166ec24a0acbabd9dec1c08b6687261d7a3c7 100644 (file)
@@ -1116,7 +1116,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv)
                goto rsnd_ssi_probe_done;
        }
 
-       ssi     = devm_kzalloc(dev, sizeof(*ssi) * nr, GFP_KERNEL);
+       ssi     = devm_kcalloc(dev, nr, sizeof(*ssi), GFP_KERNEL);
        if (!ssi) {
                ret = -ENOMEM;
                goto rsnd_ssi_probe_done;
index 6ff8a36c2c82224da8ae88c94b317092ea87f88f..47bdba9fc58228878289f0f5b3b2245785812c6b 100644 (file)
@@ -258,7 +258,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv)
 
        /* same number to SSI */
        nr      = priv->ssi_nr;
-       ssiu    = devm_kzalloc(dev, sizeof(*ssiu) * nr, GFP_KERNEL);
+       ssiu    = devm_kcalloc(dev, nr, sizeof(*ssiu), GFP_KERNEL);
        if (!ssiu)
                return -ENOMEM;
 
index 3d56f1fe5914e981ac9e480e3b335c139d25b6f5..4663de3cf495278f42b2950a3474ee4afb293674 100644 (file)
@@ -373,8 +373,8 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime(
        if (!rtd->dai_link->ops)
                rtd->dai_link->ops = &null_snd_soc_ops;
 
-       rtd->codec_dais = kzalloc(sizeof(struct snd_soc_dai *) *
-                                       dai_link->num_codecs,
+       rtd->codec_dais = kcalloc(dai_link->num_codecs,
+                                       sizeof(struct snd_soc_dai *),
                                        GFP_KERNEL);
        if (!rtd->codec_dais) {
                kfree(rtd);
@@ -3354,7 +3354,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card,
                return -EINVAL;
        }
 
-       routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
+       routes = devm_kcalloc(card->dev, num_routes, sizeof(*routes),
                              GFP_KERNEL);
        if (!routes) {
                dev_err(card->dev,
@@ -3678,8 +3678,8 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev,
                        dev_err(dev, "Bad phandle in 'sound-dai'\n");
                return num_codecs;
        }
-       component = devm_kzalloc(dev,
-                                sizeof *component * num_codecs,
+       component = devm_kcalloc(dev,
+                                num_codecs, sizeof(*component),
                                 GFP_KERNEL);
        if (!component)
                return -ENOMEM;
index 255cad43a972119622d5eb1cb2b3bf9e151ac06e..229c123498030b092e3f82a7c021128ec5618d55 100644 (file)
@@ -3055,7 +3055,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card)
                        continue;
 
                if (w->num_kcontrols) {
-                       w->kcontrols = kzalloc(w->num_kcontrols *
+                       w->kcontrols = kcalloc(w->num_kcontrols,
                                                sizeof(struct snd_kcontrol *),
                                                GFP_KERNEL);
                        if (!w->kcontrols) {
index 3fd5d9c867b9b5d30c39eee8d615849d094630b6..53f121a50c97bd6858a2b846b1a3f53e03026dd6 100644 (file)
@@ -885,7 +885,7 @@ static int soc_tplg_denum_create_texts(struct soc_enum *se,
        int i, ret;
 
        se->dobj.control.dtexts =
-               kzalloc(sizeof(char *) * ec->items, GFP_KERNEL);
+               kcalloc(ec->items, sizeof(char *), GFP_KERNEL);
        if (se->dobj.control.dtexts == NULL)
                return -ENOMEM;
 
index 80daec17be258ac3d8e616c321dd91c36f3ababe..2d9b7dde2ffa1dbc4750eda9d2dc5557753bfdc4 100644 (file)
@@ -624,15 +624,17 @@ int uniphier_aio_probe(struct platform_device *pdev)
                return PTR_ERR(chip->rst);
 
        chip->num_aios = chip->chip_spec->num_dais;
-       chip->aios = devm_kzalloc(dev,
-                                 sizeof(struct uniphier_aio) * chip->num_aios,
+       chip->aios = devm_kcalloc(dev,
+                                 chip->num_aios, sizeof(struct uniphier_aio),
                                  GFP_KERNEL);
        if (!chip->aios)
                return -ENOMEM;
 
        chip->num_plls = chip->chip_spec->num_plls;
-       chip->plls = devm_kzalloc(dev, sizeof(struct uniphier_aio_pll) *
-                                 chip->num_plls, GFP_KERNEL);
+       chip->plls = devm_kcalloc(dev,
+                                 chip->num_plls,
+                                 sizeof(struct uniphier_aio_pll),
+                                 GFP_KERNEL);
        if (!chip->plls)
                return -ENOMEM;
        memcpy(chip->plls, chip->chip_spec->plls,
index 224a6a5d1c0e7a6d9b2b359ea7b94b9588bf360c..2dd2518a71d3e2b7ecffbbe1df5d6d98de8ae14d 100644 (file)
@@ -591,12 +591,14 @@ static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt)
        int i;
 
        for (i = 0; i < PCM_N_URBS; i++) {
-               rt->out_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
-                               * PCM_MAX_PACKET_SIZE, GFP_KERNEL);
+               rt->out_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE,
+                                                PCM_N_PACKETS_PER_URB,
+                                                GFP_KERNEL);
                if (!rt->out_urbs[i].buffer)
                        return -ENOMEM;
-               rt->in_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
-                               * PCM_MAX_PACKET_SIZE, GFP_KERNEL);
+               rt->in_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE,
+                                               PCM_N_PACKETS_PER_URB,
+                                               GFP_KERNEL);
                if (!rt->in_urbs[i].buffer)
                        return -ENOMEM;
        }
index fb1c1eac0b5ef3b56cd9b9873d46f694eda43457..f35d29f49ffe13afae1501c219d500e8f3212383 100644 (file)
@@ -728,7 +728,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
                usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) :
                usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE);
 
-       urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL);
+       urbs = kmalloc_array(N_URBS, sizeof(*urbs), GFP_KERNEL);
        if (!urbs) {
                *ret = -ENOMEM;
                return NULL;
@@ -742,7 +742,8 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret)
                }
 
                urbs[i]->transfer_buffer =
-                       kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL);
+                       kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB,
+                                     GFP_KERNEL);
                if (!urbs[i]->transfer_buffer) {
                        *ret = -ENOMEM;
                        return urbs;
@@ -857,7 +858,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev)
                                &snd_usb_caiaq_ops);
 
        cdev->data_cb_info =
-               kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS,
+               kmalloc_array(N_URBS, sizeof(struct snd_usb_caiaq_cb_info),
                                        GFP_KERNEL);
 
        if (!cdev->data_cb_info)
index 1406292d50ece6d9b0da7dba51e7252176ac61d1..9b41b7dda84fafff418d357590efadd5c2763ca7 100644 (file)
@@ -32,6 +32,7 @@ struct audioformat {
        struct snd_pcm_chmap_elem *chmap; /* (optional) channel map */
        bool dsd_dop;                   /* add DOP headers in case of DSD samples */
        bool dsd_bitrev;                /* reverse the bits of each DSD sample */
+       bool dsd_raw;                   /* altsetting is raw DSD */
 };
 
 struct snd_usb_substream;
index 49e7ec6d2399072c456f5f7975a5a2a22a5bf94a..fd13ac11b13674e1c06500f7ab3eef151b1226e2 100644 (file)
@@ -64,8 +64,11 @@ static u64 parse_audio_format_i_type(struct snd_usb_audio *chip,
                sample_width = fmt->bBitResolution;
                sample_bytes = fmt->bSubslotSize;
 
-               if (format & UAC2_FORMAT_TYPE_I_RAW_DATA)
+               if (format & UAC2_FORMAT_TYPE_I_RAW_DATA) {
                        pcm_formats |= SNDRV_PCM_FMTBIT_SPECIAL;
+                       /* flag potentially raw DSD capable altsettings */
+                       fp->dsd_raw = true;
+               }
 
                format <<= 1;
                break;
@@ -188,7 +191,8 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof
                 */
                int r, idx;
 
-               fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
+               fp->rate_table = kmalloc_array(nr_rates, sizeof(int),
+                                              GFP_KERNEL);
                if (fp->rate_table == NULL)
                        return -ENOMEM;
 
@@ -362,7 +366,7 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip,
                goto err_free;
        }
 
-       fp->rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL);
+       fp->rate_table = kmalloc_array(fp->nr_rates, sizeof(int), GFP_KERNEL);
        if (!fp->rate_table) {
                ret = -ENOMEM;
                goto err_free;
index 947d6168f24abe477e7ec9456e7c4fe293138707..d8a14d769f482732e9ecdd9fb2473b9e787420e0 100644 (file)
@@ -264,8 +264,8 @@ int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm)
        struct usb_line6 *line6 = line6pcm->line6;
        int i;
 
-       line6pcm->in.urbs = kzalloc(
-               sizeof(struct urb *) * line6->iso_buffers, GFP_KERNEL);
+       line6pcm->in.urbs = kcalloc(line6->iso_buffers, sizeof(struct urb *),
+                                   GFP_KERNEL);
        if (line6pcm->in.urbs == NULL)
                return -ENOMEM;
 
index b3854f8c0c679f4d5da9b3ab00a644eacb5c99d9..72c6f8e82a7e9cb06e9c4489064d05dc39891448 100644 (file)
@@ -158,8 +158,10 @@ static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm,
 
        /* Invoked multiple times in a row so allocate once only */
        if (!test_and_set_bit(type, &pstr->opened) && !pstr->buffer) {
-               pstr->buffer = kmalloc(line6pcm->line6->iso_buffers *
-                                      LINE6_ISO_PACKETS * pkt_size, GFP_KERNEL);
+               pstr->buffer =
+                       kmalloc(array3_size(line6pcm->line6->iso_buffers,
+                                           LINE6_ISO_PACKETS, pkt_size),
+                               GFP_KERNEL);
                if (!pstr->buffer)
                        return -ENOMEM;
        }
index 819e9b2d1d6e5ea4376c2d85829311937ef9958a..dec89d2beb57807175fa3806ac68e1fd92f340fe 100644 (file)
@@ -409,8 +409,8 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm)
        struct usb_line6 *line6 = line6pcm->line6;
        int i;
 
-       line6pcm->out.urbs = kzalloc(
-               sizeof(struct urb *) * line6->iso_buffers, GFP_KERNEL);
+       line6pcm->out.urbs = kcalloc(line6->iso_buffers, sizeof(struct urb *),
+                                    GFP_KERNEL);
        if (line6pcm->out.urbs == NULL)
                return -ENOMEM;
 
index 898afd3001ea0bb64f4fa9237df32c41bc68b2c2..ca963e94ec03ca261fe271577c0568b7832c84fb 100644 (file)
@@ -1653,11 +1653,11 @@ static void build_feature_ctl_badd(struct usb_mixer_interface *mixer,
                        NULL, NULL, unitid, 0, 0);
 }
 
-static void get_connector_control_name(struct mixer_build *state,
+static void get_connector_control_name(struct usb_mixer_interface *mixer,
                                       struct usb_audio_term *term,
                                       bool is_input, char *name, int name_size)
 {
-       int name_len = get_term_name(state->chip, term, name, name_size, 0);
+       int name_len = get_term_name(mixer->chip, term, name, name_size, 0);
 
        if (name_len == 0)
                strlcpy(name, "Unknown", name_size);
@@ -1674,7 +1674,7 @@ static void get_connector_control_name(struct mixer_build *state,
 }
 
 /* Build a mixer control for a UAC connector control (jack-detect) */
-static void build_connector_control(struct mixer_build *state,
+static void build_connector_control(struct usb_mixer_interface *mixer,
                                    struct usb_audio_term *term, bool is_input)
 {
        struct snd_kcontrol *kctl;
@@ -1683,7 +1683,7 @@ static void build_connector_control(struct mixer_build *state,
        cval = kzalloc(sizeof(*cval), GFP_KERNEL);
        if (!cval)
                return;
-       snd_usb_mixer_elem_init_std(&cval->head, state->mixer, term->id);
+       snd_usb_mixer_elem_init_std(&cval->head, mixer, term->id);
        /*
         * UAC2: The first byte from reading the UAC2_TE_CONNECTOR control returns the
         * number of channels connected.
@@ -1694,7 +1694,7 @@ static void build_connector_control(struct mixer_build *state,
         * This boolean ctl will simply report if any channels are connected
         * or not.
         */
-       if (state->mixer->protocol == UAC_VERSION_2)
+       if (mixer->protocol == UAC_VERSION_2)
                cval->control = UAC2_TE_CONNECTOR;
        else /* UAC_VERSION_3 */
                cval->control = UAC3_TE_INSERTION;
@@ -1705,11 +1705,11 @@ static void build_connector_control(struct mixer_build *state,
        cval->max = 1;
        kctl = snd_ctl_new1(&usb_connector_ctl_ro, cval);
        if (!kctl) {
-               usb_audio_err(state->chip, "cannot malloc kcontrol\n");
+               usb_audio_err(mixer->chip, "cannot malloc kcontrol\n");
                kfree(cval);
                return;
        }
-       get_connector_control_name(state, term, is_input, kctl->id.name,
+       get_connector_control_name(mixer, term, is_input, kctl->id.name,
                                   sizeof(kctl->id.name));
        kctl->private_free = snd_usb_mixer_elem_free;
        snd_usb_mixer_add_control(&cval->head, kctl);
@@ -2042,7 +2042,7 @@ static int parse_audio_input_terminal(struct mixer_build *state, int unitid,
 
        /* Check for jack detection. */
        if (uac_v2v3_control_is_readable(bmctls, control))
-               build_connector_control(state, &iterm, true);
+               build_connector_control(state->mixer, &iterm, true);
 
        return 0;
 }
@@ -2515,7 +2515,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid,
                cval->control = (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) ?
                        UAC2_CX_CLOCK_SELECTOR : UAC2_SU_SELECTOR;
 
-       namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL);
+       namelist = kmalloc_array(desc->bNrInPins, sizeof(char *), GFP_KERNEL);
        if (!namelist) {
                kfree(cval);
                return -ENOMEM;
@@ -2918,6 +2918,23 @@ static int snd_usb_mixer_controls_badd(struct usb_mixer_interface *mixer,
                                       UAC3_BADD_FU_ID7, map->map);
        }
 
+       /* Insertion Control */
+       if (f->subclass == UAC3_FUNCTION_SUBCLASS_HEADSET_ADAPTER) {
+               struct usb_audio_term iterm, oterm;
+
+               /* Input Term - Insertion control */
+               memset(&iterm, 0, sizeof(iterm));
+               iterm.id = UAC3_BADD_IT_ID4;
+               iterm.type = UAC_BIDIR_TERMINAL_HEADSET;
+               build_connector_control(mixer, &iterm, true);
+
+               /* Output Term - Insertion control */
+               memset(&oterm, 0, sizeof(oterm));
+               oterm.id = UAC3_BADD_OT_ID3;
+               oterm.type = UAC_BIDIR_TERMINAL_HEADSET;
+               build_connector_control(mixer, &oterm, false);
+       }
+
        return 0;
 }
 
@@ -2990,7 +3007,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
 
                        if (uac_v2v3_control_is_readable(le16_to_cpu(desc->bmControls),
                                                         UAC2_TE_CONNECTOR)) {
-                               build_connector_control(&state, &state.oterm,
+                               build_connector_control(state.mixer, &state.oterm,
                                                        false);
                        }
                } else {  /* UAC_VERSION_3 */
@@ -3017,7 +3034,7 @@ static int snd_usb_mixer_controls(struct usb_mixer_interface *mixer)
 
                        if (uac_v2v3_control_is_readable(le32_to_cpu(desc->bmControls),
                                                         UAC3_TE_INSERTION)) {
-                               build_connector_control(&state, &state.oterm,
+                               build_connector_control(state.mixer, &state.oterm,
                                                        false);
                        }
                }
@@ -3321,10 +3338,12 @@ int snd_usb_create_mixer(struct snd_usb_audio *chip, int ctrlif,
                err = snd_usb_mixer_controls(mixer);
                if (err < 0)
                        goto _error;
-               err = snd_usb_mixer_status_create(mixer);
-               if (err < 0)
-                       goto _error;
        }
+
+       err = snd_usb_mixer_status_create(mixer);
+       if (err < 0)
+               goto _error;
+
        err = create_keep_iface_ctl(mixer);
        if (err < 0)
                goto _error;
index 78d1cad08a0ae6fcef52cae202653c7250f1ace4..160f52c4871b6a20a32625dabdef3a0032b3a210 100644 (file)
@@ -1123,7 +1123,7 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime,
                return 0;
 
        subs->rate_list.list = rate_list =
-               kmalloc(sizeof(int) * count, GFP_KERNEL);
+               kmalloc_array(count, sizeof(int), GFP_KERNEL);
        if (!subs->rate_list.list)
                return -ENOMEM;
        subs->rate_list.count = count;
index 0e37e358ca97e30196477c9ec60b13515c2d92a2..8aac48f9c32272b194e5bdebee7f23272c9ce828 100644 (file)
@@ -3277,6 +3277,10 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
        }
 },
 
+/* disabled due to regression for other devices;
+ * see https://bugzilla.kernel.org/show_bug.cgi?id=199905
+ */
+#if 0
 {
        /*
         * Nura's first gen headphones use Cambridge Silicon Radio's vendor
@@ -3324,6 +3328,7 @@ AU0828_DEVICE(0x2040, 0x7270, "Hauppauge", "HVR-950Q"),
                }
        }
 },
+#endif /* disabled */
 
 {
        /*
index f4b69173682ccddc8c5f3cfb4d5931c52bc11116..02b6cc02767f88d11af8c5cff60cbd48cf1d8726 100644 (file)
@@ -1362,16 +1362,12 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
        case USB_ID(0x1511, 0x0037): /* AURALiC VEGA */
        case USB_ID(0x20b1, 0x0002): /* Wyred 4 Sound DAC-2 DSD */
        case USB_ID(0x20b1, 0x2004): /* Matrix Audio X-SPDIF 2 */
-       case USB_ID(0x20b1, 0x3008): /* iFi Audio micro/nano iDSD */
        case USB_ID(0x20b1, 0x2008): /* Matrix Audio X-Sabre */
        case USB_ID(0x20b1, 0x300a): /* Matrix Audio Mini-i Pro */
        case USB_ID(0x22d9, 0x0416): /* OPPO HA-1 */
        case USB_ID(0x22d9, 0x0436): /* OPPO Sonica */
        case USB_ID(0x22d9, 0x0461): /* OPPO UDP-205 */
        case USB_ID(0x2522, 0x0012): /* LH Labs VI DAC Infinity */
-       case USB_ID(0x25ce, 0x001f): /* Mytek Brooklyn DAC */
-       case USB_ID(0x25ce, 0x0021): /* Mytek Manhattan DAC */
-       case USB_ID(0x25ce, 0x8025): /* Mytek Brooklyn DAC+ */
        case USB_ID(0x2772, 0x0230): /* Pro-Ject Pre Box S2 Digital */
                if (fp->altsetting == 2)
                        return SNDRV_PCM_FMTBIT_DSD_U32_BE;
@@ -1389,7 +1385,6 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
        case USB_ID(0x20b1, 0x3021): /* Eastern El. MiniMax Tube DAC Supreme */
        case USB_ID(0x20b1, 0x3023): /* Aune X1S 32BIT/384 DSD DAC */
        case USB_ID(0x20b1, 0x302d): /* Unison Research Unico CD Due */
-       case USB_ID(0x20b1, 0x3036): /* Holo Springs Level 3 R2R DAC */
        case USB_ID(0x20b1, 0x307b): /* CH Precision C1 DAC */
        case USB_ID(0x20b1, 0x3086): /* Singxer F-1 converter board */
        case USB_ID(0x22d9, 0x0426): /* OPPO HA-2 */
@@ -1443,6 +1438,20 @@ u64 snd_usb_interface_dsd_format_quirks(struct snd_usb_audio *chip,
                        return SNDRV_PCM_FMTBIT_DSD_U32_BE;
        }
 
+       /* Mostly generic method to detect many DSD-capable implementations -
+        * from XMOS/Thesycon
+        */
+       switch (USB_ID_VENDOR(chip->usb_id)) {
+       case 0x20b1:  /* XMOS based devices */
+       case 0x25ce:  /* Mytek devices */
+               if (fp->dsd_raw)
+                       return SNDRV_PCM_FMTBIT_DSD_U32_BE;
+               break;
+       default:
+               break;
+
+       }
+
        return 0;
 }
 
index 0ddf29267d70fc8f10e68109b70fd6c6798ac856..da4a5a541512ddabba38d84565e2b98e1457fb3e 100644 (file)
@@ -266,7 +266,9 @@ int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y)
        int     err = 0,
                i;
 
-       if (NULL == (usX2Y->AS04.buffer = kmalloc(URB_DataLen_AsyncSeq*URBS_AsyncSeq, GFP_KERNEL))) {
+       usX2Y->AS04.buffer = kmalloc_array(URBS_AsyncSeq,
+                                          URB_DataLen_AsyncSeq, GFP_KERNEL);
+       if (NULL == usX2Y->AS04.buffer) {
                err = -ENOMEM;
        } else
                for (i = 0; i < URBS_AsyncSeq; ++i) {
index 345e439aa95b43dc237f8ca26032547b9115c422..2b833054e3b0d04236472e0df44ce2eef1a3fe97 100644 (file)
@@ -436,7 +436,9 @@ static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs)
                }
                if (!is_playback && !(*purb)->transfer_buffer) {
                        /* allocate a capture buffer per urb */
-                       (*purb)->transfer_buffer = kmalloc(subs->maxpacksize * nr_of_packs(), GFP_KERNEL);
+                       (*purb)->transfer_buffer =
+                               kmalloc_array(subs->maxpacksize,
+                                             nr_of_packs(), GFP_KERNEL);
                        if (NULL == (*purb)->transfer_buffer) {
                                usX2Y_urbs_release(subs);
                                return -ENOMEM;
@@ -662,7 +664,8 @@ static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate)
                        err = -ENOMEM;
                        goto cleanup;
                }
-               usbdata = kmalloc(sizeof(int) * NOOF_SETRATE_URBS, GFP_KERNEL);
+               usbdata = kmalloc_array(NOOF_SETRATE_URBS, sizeof(int),
+                                       GFP_KERNEL);
                if (NULL == usbdata) {
                        err = -ENOMEM;
                        goto cleanup;
index b02c41e53d5616a3124e16dbec17250654a790b4..39e364c70caf780312808e179a1bb234aa45460e 100644 (file)
@@ -677,10 +677,10 @@ struct kvm_ioeventfd {
 };
 
 #define KVM_X86_DISABLE_EXITS_MWAIT          (1 << 0)
-#define KVM_X86_DISABLE_EXITS_HTL            (1 << 1)
+#define KVM_X86_DISABLE_EXITS_HLT            (1 << 1)
 #define KVM_X86_DISABLE_EXITS_PAUSE          (1 << 2)
 #define KVM_X86_DISABLE_VALID_EXITS          (KVM_X86_DISABLE_EXITS_MWAIT | \
-                                              KVM_X86_DISABLE_EXITS_HTL | \
+                                              KVM_X86_DISABLE_EXITS_HLT | \
                                               KVM_X86_DISABLE_EXITS_PAUSE)
 
 /* for KVM_ENABLE_CAP */
index db9f15f5db047e643780ce23a0d33f9cc599ddf4..c0d7ea0bf5b62438ca8184551b64d5d29ad7951b 100644 (file)
@@ -170,7 +170,7 @@ struct prctl_mm_map {
  * asking selinux for a specific new context (e.g. with runcon) will result
  * in execve returning -EPERM.
  *
- * See Documentation/prctl/no_new_privs.txt for more details.
+ * See Documentation/userspace-api/no_new_privs.rst for more details.
  */
 #define PR_SET_NO_NEW_PRIVS    38
 #define PR_GET_NO_NEW_PRIVS    39
index 6a12bbf39f7ba189325374f940893af82ba62cee..7aba8243a0e7cbd3fa4726910db27bcaa3be6d1a 100644 (file)
@@ -201,7 +201,7 @@ static void mem_toupper(char *f, size_t len)
 
 /*
  * Check for "NAME_PATH" environment variable to override fs location (for
- * testing). This matches the recommendation in Documentation/sysfs-rules.txt
+ * testing). This matches the recommendation in Documentation/admin-guide/sysfs-rules.rst
  * for SYSFS_PATH.
  */
 static bool fs__env_override(struct fs *fs)
index 29347756b0afbe9767fca0ac3ab3c5c897acbeed..77e4891e17b0aa9ef2492d70fe77209a7d28439a 100644 (file)
@@ -61,7 +61,7 @@ check_pos(struct bpf_insn_pos *pos)
 
 /*
  * Convert type string (u8/u16/u32/u64/s8/s16/s32/s64 ..., see
- * Documentation/trace/kprobetrace.txt) to size field of BPF_LDX_MEM
+ * Documentation/trace/kprobetrace.rst) to size field of BPF_LDX_MEM
  * instruction (BPF_{B,H,W,DW}).
  */
 static int
index 9b65f052081f354d594ed319eccfe57874bfaa77..9ba8a44ad2a714e11cc4947e0293430ed988ba73 100644 (file)
@@ -104,7 +104,7 @@ FILE *prepare_output(const char *dirname)
                        dirname, time(NULL));
        }
 
-       dprintf("logilename: %s\n", filename);
+       dprintf("logfilename: %s\n", filename);
 
        output = fopen(filename, "w+");
        if (output == NULL) {
index 5b3205f1621749bb6ebc340413ae16d957064cb9..5b8c4956ff9a1809b087475e9b166cedd414c7c5 100644 (file)
@@ -126,6 +126,20 @@ void fix_up_intel_idle_driver_name(char *tmp, int num)
        }
 }
 
+#ifdef __powerpc__
+void map_power_idle_state_name(char *tmp)
+{
+       if (!strncmp(tmp, "stop0_lite", CSTATE_NAME_LEN))
+               strcpy(tmp, "stop0L");
+       else if (!strncmp(tmp, "stop1_lite", CSTATE_NAME_LEN))
+               strcpy(tmp, "stop1L");
+       else if (!strncmp(tmp, "stop2_lite", CSTATE_NAME_LEN))
+               strcpy(tmp, "stop2L");
+}
+#else
+void map_power_idle_state_name(char *tmp) { }
+#endif
+
 static struct cpuidle_monitor *cpuidle_register(void)
 {
        int num;
@@ -145,6 +159,7 @@ static struct cpuidle_monitor *cpuidle_register(void)
                if (tmp == NULL)
                        continue;
 
+               map_power_idle_state_name(tmp);
                fix_up_intel_idle_driver_name(tmp, num);
                strncpy(cpuidle_cstates[num].name, tmp, CSTATE_NAME_LEN - 1);
                free(tmp);
index 05f953f0f0a0cf2b3d479ce6a6dcbc9c0d9a8c28..051da0a7c4548114e270e27d4265279dabedca79 100644 (file)
@@ -70,36 +70,43 @@ void print_n_spaces(int n)
                printf(" ");
 }
 
-/* size of s must be at least n + 1 */
+/*s is filled with left and right spaces
+ *to make its length atleast n+1
+ */
 int fill_string_with_spaces(char *s, int n)
 {
+       char *temp;
        int len = strlen(s);
-       if (len > n)
+
+       if (len >= n)
                return -1;
+
+       temp = malloc(sizeof(char) * (n+1));
        for (; len < n; len++)
                s[len] = ' ';
        s[len] = '\0';
+       snprintf(temp, n+1, " %s", s);
+       strcpy(s, temp);
+       free(temp);
        return 0;
 }
 
+#define MAX_COL_WIDTH 6
 void print_header(int topology_depth)
 {
        int unsigned mon;
        int state, need_len;
        cstate_t s;
        char buf[128] = "";
-       int percent_width = 4;
 
        fill_string_with_spaces(buf, topology_depth * 5 - 1);
        printf("%s|", buf);
 
        for (mon = 0; mon < avail_monitors; mon++) {
-               need_len = monitors[mon]->hw_states_num * (percent_width + 3)
+               need_len = monitors[mon]->hw_states_num * (MAX_COL_WIDTH + 1)
                        - 1;
-               if (mon != 0) {
-                       printf("|| ");
-                       need_len--;
-               }
+               if (mon != 0)
+                       printf("||");
                sprintf(buf, "%s", monitors[mon]->name);
                fill_string_with_spaces(buf, need_len);
                printf("%s", buf);
@@ -107,23 +114,21 @@ void print_header(int topology_depth)
        printf("\n");
 
        if (topology_depth > 2)
-               printf("PKG |");
+               printf(" PKG|");
        if (topology_depth > 1)
                printf("CORE|");
        if (topology_depth > 0)
-               printf("CPU |");
+               printf(" CPU|");
 
        for (mon = 0; mon < avail_monitors; mon++) {
                if (mon != 0)
-                       printf("|| ");
-               else
-                       printf(" ");
+                       printf("||");
                for (state = 0; state < monitors[mon]->hw_states_num; state++) {
                        if (state != 0)
-                               printf(" | ");
+                               printf("|");
                        s = monitors[mon]->hw_states[state];
                        sprintf(buf, "%s", s.name);
-                       fill_string_with_spaces(buf, percent_width);
+                       fill_string_with_spaces(buf, MAX_COL_WIDTH);
                        printf("%s", buf);
                }
                printf(" ");
index 9e43f3371fbc625eaabaaeb941ae3a14a732ff7f..2ae50b499e0a67beff988944384d446290028599 100644 (file)
 
 #define MONITORS_MAX 20
 #define MONITOR_NAME_LEN 20
+
+/* CSTATE_NAME_LEN is limited by header field width defined
+ * in cpupower-monitor.c. Header field width is defined to be
+ * sum of percent width and two spaces for padding.
+ */
+#ifdef __powerpc__
+#define CSTATE_NAME_LEN 7
+#else
 #define CSTATE_NAME_LEN 5
+#endif
 #define CSTATE_DESC_LEN 60
 
 int cpu_count;
index 4f80ad7d72755b308bdc4d963f620a9548dcdbb3..f8fcb06fd68b3b45cce94694fc4b8c1982d03f6a 100644 (file)
@@ -105,7 +105,7 @@ override-dev-timeline-functions: true
 #       example: [color=#CC00CC]
 #
 #   arglist: A list of arguments from registers/stack addresses. See URL:
-#            https://www.kernel.org/doc/Documentation/trace/kprobetrace.txt
+#            https://www.kernel.org/doc/Documentation/trace/kprobetrace.rst
 #
 #       example: cpu=%di:s32
 #
@@ -170,7 +170,7 @@ pm_restore_console:
 #       example: [color=#CC00CC]
 #
 #   arglist: A list of arguments from registers/stack addresses. See URL:
-#            https://www.kernel.org/doc/Documentation/trace/kprobetrace.txt
+#            https://www.kernel.org/doc/Documentation/trace/kprobetrace.rst
 #
 #       example: port=+36(%di):s32
 #
index 607ed8729c06d107fa1fa7454c3efa00abfcff10..7a6214e9ae58d4432668394bf4762a0e2cb5c669 100644 (file)
@@ -16,9 +16,7 @@ LDLIBS += -lcap -lelf -lrt -lpthread
 TEST_CUSTOM_PROGS = $(OUTPUT)/urandom_read
 all: $(TEST_CUSTOM_PROGS)
 
-$(TEST_CUSTOM_PROGS): urandom_read
-
-urandom_read: urandom_read.c
+$(TEST_CUSTOM_PROGS): $(OUTPUT)/%: %.c
        $(CC) -o $(TEST_CUSTOM_PROGS) -static $< -Wl,--build-id
 
 # Order correspond to 'make run_tests' order
index b69bdeb4b9febdb9b6446e56138cbebcfa791914..1e9e3c4705611792f2423cad1682c494b9332bc5 100644 (file)
@@ -35,7 +35,7 @@ static ssize_t read_text(const char *path, char *buf, size_t max_len)
        return len;
 }
 
-static ssize_t write_text(const char *path, char *buf, size_t len)
+static ssize_t write_text(const char *path, char *buf, ssize_t len)
 {
        int fd;
 
@@ -140,7 +140,7 @@ long cg_read_key_long(const char *cgroup, const char *control, const char *key)
 int cg_write(const char *cgroup, const char *control, char *buf)
 {
        char path[PATH_MAX];
-       size_t len = strlen(buf);
+       ssize_t len = strlen(buf);
 
        snprintf(path, sizeof(path), "%s/%s", cgroup, control);
 
index 5ba73035e1d95ad45788610668950084844d1861..a0002563e9eeecc8f6b97d0a95ed90309cbd9a8c 100644 (file)
@@ -24,6 +24,14 @@ arm*)
   ARG2=%r1
   OFFS=4
 ;;
+ppc64*)
+  ARG2=%r4
+  OFFS=8
+;;
+ppc*)
+  ARG2=%r4
+  OFFS=4
+;;
 *)
   echo "Please implement other architecture here"
   exit_untested
index 231bcd2c4eb59e9d3528be1e181650424fe13130..d026ff4e562f3a49f0f5cca7fa39a6dcfa112af1 100644 (file)
@@ -34,6 +34,13 @@ arm*)
   GOODREG=%r0
   BADREG=%ax
 ;;
+ppc*)
+  GOODREG=%r3
+  BADREG=%msr
+;;
+*)
+  echo "Please implement other architecture here"
+  exit_untested
 esac
 
 test_goodarg() # Good-args
index de97e4ff705cd1212840f01e975003b6bb99de84..637ea0219617f3beb9a69016e5b613bf173f5ada 100644 (file)
         "matchPattern": "action order [0-9]*: ife encode action pass.*type 0xED3E.*use tcindex 65535.*index 1",
         "matchCount": "1",
         "teardown": [
-            "$TC actions flush action skbedit"
+            "$TC actions flush action ife"
         ]
     },
     {
index cca7e065a075d8eebb33097ec4a46f3e5bd2c3a3..72143cfaf6ec39404dad5f72a8cf08c5e5fefc7e 100644 (file)
@@ -54,3 +54,6 @@ config HAVE_KVM_IRQ_BYPASS
 
 config HAVE_KVM_VCPU_ASYNC_IOCTL
        bool
+
+config HAVE_KVM_VCPU_RUN_PID_CHANGE
+       bool
index 2d9b4795edb2beecd04588c791735d155cc05741..04e554cae3a2066e5eb6e4d2544efc84a62d88de 100644 (file)
@@ -16,6 +16,7 @@
  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 
+#include <linux/bug.h>
 #include <linux/cpu_pm.h>
 #include <linux/errno.h>
 #include <linux/err.h>
@@ -41,6 +42,7 @@
 #include <asm/mman.h>
 #include <asm/tlbflush.h>
 #include <asm/cacheflush.h>
+#include <asm/cpufeature.h>
 #include <asm/virt.h>
 #include <asm/kvm_arm.h>
 #include <asm/kvm_asm.h>
@@ -163,7 +165,7 @@ int kvm_arch_create_vcpu_debugfs(struct kvm_vcpu *vcpu)
        return 0;
 }
 
-int kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
+vm_fault_t kvm_arch_vcpu_fault(struct kvm_vcpu *vcpu, struct vm_fault *vmf)
 {
        return VM_FAULT_SIGBUS;
 }
@@ -249,6 +251,21 @@ long kvm_arch_dev_ioctl(struct file *filp,
        return -EINVAL;
 }
 
+struct kvm *kvm_arch_alloc_vm(void)
+{
+       if (!has_vhe())
+               return kzalloc(sizeof(struct kvm), GFP_KERNEL);
+
+       return vzalloc(sizeof(struct kvm));
+}
+
+void kvm_arch_free_vm(struct kvm *kvm)
+{
+       if (!has_vhe())
+               kfree(kvm);
+       else
+               vfree(kvm);
+}
 
 struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
 {
@@ -290,7 +307,6 @@ struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, unsigned int id)
 
 void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
 {
-       kvm_vgic_vcpu_early_init(vcpu);
 }
 
 void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu)
@@ -363,10 +379,12 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
        kvm_vgic_load(vcpu);
        kvm_timer_vcpu_load(vcpu);
        kvm_vcpu_load_sysregs(vcpu);
+       kvm_arch_vcpu_load_fp(vcpu);
 }
 
 void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
 {
+       kvm_arch_vcpu_put_fp(vcpu);
        kvm_vcpu_put_sysregs(vcpu);
        kvm_timer_vcpu_put(vcpu);
        kvm_vgic_put(vcpu);
@@ -678,9 +696,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
                 */
                preempt_disable();
 
-               /* Flush FP/SIMD state that can't survive guest entry/exit */
-               kvm_fpsimd_flush_cpu_state();
-
                kvm_pmu_flush_hwstate(vcpu);
 
                local_irq_disable();
@@ -778,6 +793,8 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *run)
                if (static_branch_unlikely(&userspace_irqchip_in_use))
                        kvm_timer_sync_hwstate(vcpu);
 
+               kvm_arch_vcpu_ctxsync_fp(vcpu);
+
                /*
                 * We may have taken a host interrupt in HYP mode (ie
                 * while executing the guest). This interrupt is still
@@ -1574,6 +1591,11 @@ int kvm_arch_init(void *opaque)
                return -ENODEV;
        }
 
+       if (!kvm_arch_check_sve_has_vhe()) {
+               kvm_pr_unimpl("SVE system without VHE unsupported.  Broken cpu?");
+               return -ENODEV;
+       }
+
        for_each_online_cpu(cpu) {
                smp_call_function_single(cpu, check_kvm_target_cpu, &ret, 1);
                if (ret < 0) {
index 4ffc0b5e610560c752c99de33d6f5857e7344773..c589d4c2b478b2df7ada6cee1837340c762a41b5 100644 (file)
@@ -264,21 +264,12 @@ static const struct file_operations vgic_debug_fops = {
        .release = seq_release
 };
 
-int vgic_debug_init(struct kvm *kvm)
+void vgic_debug_init(struct kvm *kvm)
 {
-       if (!kvm->debugfs_dentry)
-               return -ENOENT;
-
-       if (!debugfs_create_file("vgic-state", 0444,
-                                kvm->debugfs_dentry,
-                                kvm,
-                                &vgic_debug_fops))
-               return -ENOMEM;
-
-       return 0;
+       debugfs_create_file("vgic-state", 0444, kvm->debugfs_dentry, kvm,
+                           &vgic_debug_fops);
 }
 
-int vgic_debug_destroy(struct kvm *kvm)
+void vgic_debug_destroy(struct kvm *kvm)
 {
-       return 0;
 }
index e07156c303235e13dc00b31d39e38ff1d30d281d..2673efce65f34ac95511f555377981e78119f248 100644 (file)
@@ -44,7 +44,7 @@
  *
  * CPU Interface:
  *
- * - kvm_vgic_vcpu_early_init(): initialization of static data that
+ * - kvm_vgic_vcpu_init(): initialization of static data that
  *   doesn't depend on any sizing information or emulation type. No
  *   allocation is allowed there.
  */
@@ -67,46 +67,6 @@ void kvm_vgic_early_init(struct kvm *kvm)
        spin_lock_init(&dist->lpi_list_lock);
 }
 
-/**
- * kvm_vgic_vcpu_early_init() - Initialize static VGIC VCPU data structures
- * @vcpu: The VCPU whose VGIC data structures whould be initialized
- *
- * Only do initialization, but do not actually enable the VGIC CPU interface
- * yet.
- */
-void kvm_vgic_vcpu_early_init(struct kvm_vcpu *vcpu)
-{
-       struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
-       int i;
-
-       INIT_LIST_HEAD(&vgic_cpu->ap_list_head);
-       spin_lock_init(&vgic_cpu->ap_list_lock);
-
-       /*
-        * Enable and configure all SGIs to be edge-triggered and
-        * configure all PPIs as level-triggered.
-        */
-       for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) {
-               struct vgic_irq *irq = &vgic_cpu->private_irqs[i];
-
-               INIT_LIST_HEAD(&irq->ap_list);
-               spin_lock_init(&irq->irq_lock);
-               irq->intid = i;
-               irq->vcpu = NULL;
-               irq->target_vcpu = vcpu;
-               irq->targets = 1U << vcpu->vcpu_id;
-               kref_init(&irq->refcount);
-               if (vgic_irq_is_sgi(i)) {
-                       /* SGIs */
-                       irq->enabled = 1;
-                       irq->config = VGIC_CONFIG_EDGE;
-               } else {
-                       /* PPIs */
-                       irq->config = VGIC_CONFIG_LEVEL;
-               }
-       }
-}
-
 /* CREATION */
 
 /**
@@ -167,8 +127,11 @@ int kvm_vgic_create(struct kvm *kvm, u32 type)
        kvm->arch.vgic.vgic_model = type;
 
        kvm->arch.vgic.vgic_dist_base = VGIC_ADDR_UNDEF;
-       kvm->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF;
-       kvm->arch.vgic.vgic_redist_base = VGIC_ADDR_UNDEF;
+
+       if (type == KVM_DEV_TYPE_ARM_VGIC_V2)
+               kvm->arch.vgic.vgic_cpu_base = VGIC_ADDR_UNDEF;
+       else
+               INIT_LIST_HEAD(&kvm->arch.vgic.rd_regions);
 
 out_unlock:
        for (; vcpu_lock_idx >= 0; vcpu_lock_idx--) {
@@ -221,13 +184,50 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
 }
 
 /**
- * kvm_vgic_vcpu_init() - Register VCPU-specific KVM iodevs
+ * kvm_vgic_vcpu_init() - Initialize static VGIC VCPU data
+ * structures and register VCPU-specific KVM iodevs
+ *
  * @vcpu: pointer to the VCPU being created and initialized
+ *
+ * Only do initialization, but do not actually enable the
+ * VGIC CPU interface
  */
 int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
 {
-       int ret = 0;
+       struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
        struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
+       int ret = 0;
+       int i;
+
+       vgic_cpu->rd_iodev.base_addr = VGIC_ADDR_UNDEF;
+       vgic_cpu->sgi_iodev.base_addr = VGIC_ADDR_UNDEF;
+
+       INIT_LIST_HEAD(&vgic_cpu->ap_list_head);
+       spin_lock_init(&vgic_cpu->ap_list_lock);
+
+       /*
+        * Enable and configure all SGIs to be edge-triggered and
+        * configure all PPIs as level-triggered.
+        */
+       for (i = 0; i < VGIC_NR_PRIVATE_IRQS; i++) {
+               struct vgic_irq *irq = &vgic_cpu->private_irqs[i];
+
+               INIT_LIST_HEAD(&irq->ap_list);
+               spin_lock_init(&irq->irq_lock);
+               irq->intid = i;
+               irq->vcpu = NULL;
+               irq->target_vcpu = vcpu;
+               irq->targets = 1U << vcpu->vcpu_id;
+               kref_init(&irq->refcount);
+               if (vgic_irq_is_sgi(i)) {
+                       /* SGIs */
+                       irq->enabled = 1;
+                       irq->config = VGIC_CONFIG_EDGE;
+               } else {
+                       /* PPIs */
+                       irq->config = VGIC_CONFIG_LEVEL;
+               }
+       }
 
        if (!irqchip_in_kernel(vcpu->kvm))
                return 0;
@@ -303,13 +303,23 @@ int vgic_init(struct kvm *kvm)
 static void kvm_vgic_dist_destroy(struct kvm *kvm)
 {
        struct vgic_dist *dist = &kvm->arch.vgic;
+       struct vgic_redist_region *rdreg, *next;
 
        dist->ready = false;
        dist->initialized = false;
 
        kfree(dist->spis);
+       dist->spis = NULL;
        dist->nr_spis = 0;
 
+       if (kvm->arch.vgic.vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3) {
+               list_for_each_entry_safe(rdreg, next, &dist->rd_regions, list) {
+                       list_del(&rdreg->list);
+                       kfree(rdreg);
+               }
+               INIT_LIST_HEAD(&dist->rd_regions);
+       }
+
        if (vgic_supports_direct_msis(kvm))
                vgic_v4_teardown(kvm);
 }
index 10ae6f394b718d8e49805d23481974b0526764d1..6ada2432e37c7cd0a9c4825fcb06334298aca426 100644 (file)
@@ -66,6 +66,7 @@ int kvm_vgic_addr(struct kvm *kvm, unsigned long type, u64 *addr, bool write)
        int r = 0;
        struct vgic_dist *vgic = &kvm->arch.vgic;
        phys_addr_t *addr_ptr, alignment;
+       u64 undef_value = VGIC_ADDR_UNDEF;
 
        mutex_lock(&kvm->lock);
        switch (type) {
@@ -84,16 +85,61 @@ int kvm_vgic_addr(struct kvm *kvm, unsigned long type, u64 *addr, bool write)
                addr_ptr = &vgic->vgic_dist_base;
                alignment = SZ_64K;
                break;
-       case KVM_VGIC_V3_ADDR_TYPE_REDIST:
+       case KVM_VGIC_V3_ADDR_TYPE_REDIST: {
+               struct vgic_redist_region *rdreg;
+
                r = vgic_check_type(kvm, KVM_DEV_TYPE_ARM_VGIC_V3);
                if (r)
                        break;
                if (write) {
-                       r = vgic_v3_set_redist_base(kvm, *addr);
+                       r = vgic_v3_set_redist_base(kvm, 0, *addr, 0);
                        goto out;
                }
-               addr_ptr = &vgic->vgic_redist_base;
+               rdreg = list_first_entry(&vgic->rd_regions,
+                                        struct vgic_redist_region, list);
+               if (!rdreg)
+                       addr_ptr = &undef_value;
+               else
+                       addr_ptr = &rdreg->base;
                break;
+       }
+       case KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION:
+       {
+               struct vgic_redist_region *rdreg;
+               u8 index;
+
+               r = vgic_check_type(kvm, KVM_DEV_TYPE_ARM_VGIC_V3);
+               if (r)
+                       break;
+
+               index = *addr & KVM_VGIC_V3_RDIST_INDEX_MASK;
+
+               if (write) {
+                       gpa_t base = *addr & KVM_VGIC_V3_RDIST_BASE_MASK;
+                       u32 count = (*addr & KVM_VGIC_V3_RDIST_COUNT_MASK)
+                                       >> KVM_VGIC_V3_RDIST_COUNT_SHIFT;
+                       u8 flags = (*addr & KVM_VGIC_V3_RDIST_FLAGS_MASK)
+                                       >> KVM_VGIC_V3_RDIST_FLAGS_SHIFT;
+
+                       if (!count || flags)
+                               r = -EINVAL;
+                       else
+                               r = vgic_v3_set_redist_base(kvm, index,
+                                                           base, count);
+                       goto out;
+               }
+
+               rdreg = vgic_v3_rdist_region_from_index(kvm, index);
+               if (!rdreg) {
+                       r = -ENOENT;
+                       goto out;
+               }
+
+               *addr = index;
+               *addr |= rdreg->base;
+               *addr |= (u64)rdreg->count << KVM_VGIC_V3_RDIST_COUNT_SHIFT;
+               goto out;
+       }
        default:
                r = -ENODEV;
        }
@@ -665,6 +711,7 @@ static int vgic_v3_has_attr(struct kvm_device *dev,
                switch (attr->attr) {
                case KVM_VGIC_V3_ADDR_TYPE_DIST:
                case KVM_VGIC_V3_ADDR_TYPE_REDIST:
+               case KVM_VGIC_V3_ADDR_TYPE_REDIST_REGION:
                        return 0;
                }
                break;
index 671fe81f8e1de991e1636a9901012b0a203618a4..287784095b5b30a28c380d53f90bfcee977aa434 100644 (file)
@@ -184,12 +184,17 @@ static unsigned long vgic_mmio_read_v3r_typer(struct kvm_vcpu *vcpu,
                                              gpa_t addr, unsigned int len)
 {
        unsigned long mpidr = kvm_vcpu_get_mpidr_aff(vcpu);
+       struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
+       struct vgic_redist_region *rdreg = vgic_cpu->rdreg;
        int target_vcpu_id = vcpu->vcpu_id;
+       gpa_t last_rdist_typer = rdreg->base + GICR_TYPER +
+                       (rdreg->free_index - 1) * KVM_VGIC_V3_REDIST_SIZE;
        u64 value;
 
        value = (u64)(mpidr & GENMASK(23, 0)) << 32;
        value |= ((target_vcpu_id & 0xffff) << 8);
-       if (target_vcpu_id == atomic_read(&vcpu->kvm->online_vcpus) - 1)
+
+       if (addr == last_rdist_typer)
                value |= GICR_TYPER_LAST;
        if (vgic_has_its(vcpu->kvm))
                value |= GICR_TYPER_PLPIS;
@@ -580,24 +585,32 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)
 {
        struct kvm *kvm = vcpu->kvm;
        struct vgic_dist *vgic = &kvm->arch.vgic;
+       struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
        struct vgic_io_device *rd_dev = &vcpu->arch.vgic_cpu.rd_iodev;
        struct vgic_io_device *sgi_dev = &vcpu->arch.vgic_cpu.sgi_iodev;
+       struct vgic_redist_region *rdreg;
        gpa_t rd_base, sgi_base;
        int ret;
 
+       if (!IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr))
+               return 0;
+
        /*
         * We may be creating VCPUs before having set the base address for the
         * redistributor region, in which case we will come back to this
         * function for all VCPUs when the base address is set.  Just return
         * without doing any work for now.
         */
-       if (IS_VGIC_ADDR_UNDEF(vgic->vgic_redist_base))
+       rdreg = vgic_v3_rdist_free_slot(&vgic->rd_regions);
+       if (!rdreg)
                return 0;
 
        if (!vgic_v3_check_base(kvm))
                return -EINVAL;
 
-       rd_base = vgic->vgic_redist_base + vgic->vgic_redist_free_offset;
+       vgic_cpu->rdreg = rdreg;
+
+       rd_base = rdreg->base + rdreg->free_index * KVM_VGIC_V3_REDIST_SIZE;
        sgi_base = rd_base + SZ_64K;
 
        kvm_iodevice_init(&rd_dev->dev, &kvm_io_gic_ops);
@@ -631,7 +644,7 @@ int vgic_register_redist_iodev(struct kvm_vcpu *vcpu)
                goto out;
        }
 
-       vgic->vgic_redist_free_offset += 2 * SZ_64K;
+       rdreg->free_index++;
 out:
        mutex_unlock(&kvm->slots_lock);
        return ret;
@@ -670,22 +683,95 @@ static int vgic_register_all_redist_iodevs(struct kvm *kvm)
        return ret;
 }
 
-int vgic_v3_set_redist_base(struct kvm *kvm, u64 addr)
+/**
+ * vgic_v3_insert_redist_region - Insert a new redistributor region
+ *
+ * Performs various checks before inserting the rdist region in the list.
+ * Those tests depend on whether the size of the rdist region is known
+ * (ie. count != 0). The list is sorted by rdist region index.
+ *
+ * @kvm: kvm handle
+ * @index: redist region index
+ * @base: base of the new rdist region
+ * @count: number of redistributors the region is made of (0 in the old style
+ * single region, whose size is induced from the number of vcpus)
+ *
+ * Return 0 on success, < 0 otherwise
+ */
+static int vgic_v3_insert_redist_region(struct kvm *kvm, uint32_t index,
+                                       gpa_t base, uint32_t count)
 {
-       struct vgic_dist *vgic = &kvm->arch.vgic;
+       struct vgic_dist *d = &kvm->arch.vgic;
+       struct vgic_redist_region *rdreg;
+       struct list_head *rd_regions = &d->rd_regions;
+       size_t size = count * KVM_VGIC_V3_REDIST_SIZE;
        int ret;
 
-       /* vgic_check_ioaddr makes sure we don't do this twice */
-       ret = vgic_check_ioaddr(kvm, &vgic->vgic_redist_base, addr, SZ_64K);
-       if (ret)
-               return ret;
+       /* single rdist region already set ?*/
+       if (!count && !list_empty(rd_regions))
+               return -EINVAL;
 
-       vgic->vgic_redist_base = addr;
-       if (!vgic_v3_check_base(kvm)) {
-               vgic->vgic_redist_base = VGIC_ADDR_UNDEF;
+       /* cross the end of memory ? */
+       if (base + size < base)
                return -EINVAL;
+
+       if (list_empty(rd_regions)) {
+               if (index != 0)
+                       return -EINVAL;
+       } else {
+               rdreg = list_last_entry(rd_regions,
+                                       struct vgic_redist_region, list);
+               if (index != rdreg->index + 1)
+                       return -EINVAL;
+
+               /* Cannot add an explicitly sized regions after legacy region */
+               if (!rdreg->count)
+                       return -EINVAL;
        }
 
+       /*
+        * For legacy single-region redistributor regions (!count),
+        * check that the redistributor region does not overlap with the
+        * distributor's address space.
+        */
+       if (!count && !IS_VGIC_ADDR_UNDEF(d->vgic_dist_base) &&
+               vgic_dist_overlap(kvm, base, size))
+               return -EINVAL;
+
+       /* collision with any other rdist region? */
+       if (vgic_v3_rdist_overlap(kvm, base, size))
+               return -EINVAL;
+
+       rdreg = kzalloc(sizeof(*rdreg), GFP_KERNEL);
+       if (!rdreg)
+               return -ENOMEM;
+
+       rdreg->base = VGIC_ADDR_UNDEF;
+
+       ret = vgic_check_ioaddr(kvm, &rdreg->base, base, SZ_64K);
+       if (ret)
+               goto free;
+
+       rdreg->base = base;
+       rdreg->count = count;
+       rdreg->free_index = 0;
+       rdreg->index = index;
+
+       list_add_tail(&rdreg->list, rd_regions);
+       return 0;
+free:
+       kfree(rdreg);
+       return ret;
+}
+
+int vgic_v3_set_redist_base(struct kvm *kvm, u32 index, u64 addr, u32 count)
+{
+       int ret;
+
+       ret = vgic_v3_insert_redist_region(kvm, index, addr, count);
+       if (ret)
+               return ret;
+
        /*
         * Register iodevs for each existing VCPU.  Adding more VCPUs
         * afterwards will register the iodevs when needed.
index bdcf8e7a6161298d373a7605dc5fe6be43fa872e..ff7dc890941a8447d6e5abeae6dfe6544fac18d7 100644 (file)
@@ -419,6 +419,29 @@ int vgic_v3_save_pending_tables(struct kvm *kvm)
        return 0;
 }
 
+/**
+ * vgic_v3_rdist_overlap - check if a region overlaps with any
+ * existing redistributor region
+ *
+ * @kvm: kvm handle
+ * @base: base of the region
+ * @size: size of region
+ *
+ * Return: true if there is an overlap
+ */
+bool vgic_v3_rdist_overlap(struct kvm *kvm, gpa_t base, size_t size)
+{
+       struct vgic_dist *d = &kvm->arch.vgic;
+       struct vgic_redist_region *rdreg;
+
+       list_for_each_entry(rdreg, &d->rd_regions, list) {
+               if ((base + size > rdreg->base) &&
+                       (base < rdreg->base + vgic_v3_rd_region_size(kvm, rdreg)))
+                       return true;
+       }
+       return false;
+}
+
 /*
  * Check for overlapping regions and for regions crossing the end of memory
  * for base addresses which have already been set.
@@ -426,41 +449,83 @@ int vgic_v3_save_pending_tables(struct kvm *kvm)
 bool vgic_v3_check_base(struct kvm *kvm)
 {
        struct vgic_dist *d = &kvm->arch.vgic;
-       gpa_t redist_size = KVM_VGIC_V3_REDIST_SIZE;
-
-       redist_size *= atomic_read(&kvm->online_vcpus);
+       struct vgic_redist_region *rdreg;
 
        if (!IS_VGIC_ADDR_UNDEF(d->vgic_dist_base) &&
            d->vgic_dist_base + KVM_VGIC_V3_DIST_SIZE < d->vgic_dist_base)
                return false;
 
-       if (!IS_VGIC_ADDR_UNDEF(d->vgic_redist_base) &&
-           d->vgic_redist_base + redist_size < d->vgic_redist_base)
-               return false;
+       list_for_each_entry(rdreg, &d->rd_regions, list) {
+               if (rdreg->base + vgic_v3_rd_region_size(kvm, rdreg) <
+                       rdreg->base)
+                       return false;
+       }
 
-       /* Both base addresses must be set to check if they overlap */
-       if (IS_VGIC_ADDR_UNDEF(d->vgic_dist_base) ||
-           IS_VGIC_ADDR_UNDEF(d->vgic_redist_base))
+       if (IS_VGIC_ADDR_UNDEF(d->vgic_dist_base))
                return true;
 
-       if (d->vgic_dist_base + KVM_VGIC_V3_DIST_SIZE <= d->vgic_redist_base)
-               return true;
-       if (d->vgic_redist_base + redist_size <= d->vgic_dist_base)
-               return true;
+       return !vgic_v3_rdist_overlap(kvm, d->vgic_dist_base,
+                                     KVM_VGIC_V3_DIST_SIZE);
+}
 
-       return false;
+/**
+ * vgic_v3_rdist_free_slot - Look up registered rdist regions and identify one
+ * which has free space to put a new rdist region.
+ *
+ * @rd_regions: redistributor region list head
+ *
+ * A redistributor regions maps n redistributors, n = region size / (2 x 64kB).
+ * Stride between redistributors is 0 and regions are filled in the index order.
+ *
+ * Return: the redist region handle, if any, that has space to map a new rdist
+ * region.
+ */
+struct vgic_redist_region *vgic_v3_rdist_free_slot(struct list_head *rd_regions)
+{
+       struct vgic_redist_region *rdreg;
+
+       list_for_each_entry(rdreg, rd_regions, list) {
+               if (!vgic_v3_redist_region_full(rdreg))
+                       return rdreg;
+       }
+       return NULL;
 }
 
+struct vgic_redist_region *vgic_v3_rdist_region_from_index(struct kvm *kvm,
+                                                          u32 index)
+{
+       struct list_head *rd_regions = &kvm->arch.vgic.rd_regions;
+       struct vgic_redist_region *rdreg;
+
+       list_for_each_entry(rdreg, rd_regions, list) {
+               if (rdreg->index == index)
+                       return rdreg;
+       }
+       return NULL;
+}
+
+
 int vgic_v3_map_resources(struct kvm *kvm)
 {
-       int ret = 0;
        struct vgic_dist *dist = &kvm->arch.vgic;
+       struct kvm_vcpu *vcpu;
+       int ret = 0;
+       int c;
 
        if (vgic_ready(kvm))
                goto out;
 
-       if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base) ||
-           IS_VGIC_ADDR_UNDEF(dist->vgic_redist_base)) {
+       kvm_for_each_vcpu(c, vcpu, kvm) {
+               struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
+
+               if (IS_VGIC_ADDR_UNDEF(vgic_cpu->rd_iodev.base_addr)) {
+                       kvm_debug("vcpu %d redistributor base not set\n", c);
+                       ret = -ENXIO;
+                       goto out;
+               }
+       }
+
+       if (IS_VGIC_ADDR_UNDEF(dist->vgic_dist_base)) {
                kvm_err("Need to set vgic distributor addresses first\n");
                ret = -ENXIO;
                goto out;
index bc4265154bacf0665e2cf450641ab8839e35a1f6..1ed5f2286b8e1511782404b1bfc2ea606ccde8e0 100644 (file)
@@ -126,7 +126,7 @@ int vgic_v4_init(struct kvm *kvm)
 
        nr_vcpus = atomic_read(&kvm->online_vcpus);
 
-       dist->its_vm.vpes = kzalloc(sizeof(*dist->its_vm.vpes) * nr_vcpus,
+       dist->its_vm.vpes = kcalloc(nr_vcpus, sizeof(*dist->its_vm.vpes),
                                    GFP_KERNEL);
        if (!dist->its_vm.vpes)
                return -ENOMEM;
index 32c25d42c93f401390f5d00fca80e637c8670151..ead00b2072b260321c31330e20a8031b5ba362d8 100644 (file)
 /* we only support 64 kB translation table page size */
 #define KVM_ITS_L1E_ADDR_MASK          GENMASK_ULL(51, 16)
 
+#define KVM_VGIC_V3_RDIST_INDEX_MASK   GENMASK_ULL(11, 0)
+#define KVM_VGIC_V3_RDIST_FLAGS_MASK   GENMASK_ULL(15, 12)
+#define KVM_VGIC_V3_RDIST_FLAGS_SHIFT  12
+#define KVM_VGIC_V3_RDIST_BASE_MASK    GENMASK_ULL(51, 16)
+#define KVM_VGIC_V3_RDIST_COUNT_MASK   GENMASK_ULL(63, 52)
+#define KVM_VGIC_V3_RDIST_COUNT_SHIFT  52
+
 /* Requires the irq_lock to be held by the caller. */
 static inline bool irq_is_pending(struct vgic_irq *irq)
 {
@@ -215,7 +222,7 @@ int vgic_v3_probe(const struct gic_kvm_info *info);
 int vgic_v3_map_resources(struct kvm *kvm);
 int vgic_v3_lpi_sync_pending_status(struct kvm *kvm, struct vgic_irq *irq);
 int vgic_v3_save_pending_tables(struct kvm *kvm);
-int vgic_v3_set_redist_base(struct kvm *kvm, u64 addr);
+int vgic_v3_set_redist_base(struct kvm *kvm, u32 index, u64 addr, u32 count);
 int vgic_register_redist_iodev(struct kvm_vcpu *vcpu);
 bool vgic_v3_check_base(struct kvm *kvm);
 
@@ -243,8 +250,8 @@ void vgic_get_vmcr(struct kvm_vcpu *vcpu, struct vgic_vmcr *vmcr);
 int vgic_lazy_init(struct kvm *kvm);
 int vgic_init(struct kvm *kvm);
 
-int vgic_debug_init(struct kvm *kvm);
-int vgic_debug_destroy(struct kvm *kvm);
+void vgic_debug_init(struct kvm *kvm);
+void vgic_debug_destroy(struct kvm *kvm);
 
 bool lock_all_vcpus(struct kvm *kvm);
 void unlock_all_vcpus(struct kvm *kvm);
@@ -265,6 +272,39 @@ static inline int vgic_v3_max_apr_idx(struct kvm_vcpu *vcpu)
        }
 }
 
+static inline bool
+vgic_v3_redist_region_full(struct vgic_redist_region *region)
+{
+       if (!region->count)
+               return false;
+
+       return (region->free_index >= region->count);
+}
+
+struct vgic_redist_region *vgic_v3_rdist_free_slot(struct list_head *rdregs);
+
+static inline size_t
+vgic_v3_rd_region_size(struct kvm *kvm, struct vgic_redist_region *rdreg)
+{
+       if (!rdreg->count)
+               return atomic_read(&kvm->online_vcpus) * KVM_VGIC_V3_REDIST_SIZE;
+       else
+               return rdreg->count * KVM_VGIC_V3_REDIST_SIZE;
+}
+
+struct vgic_redist_region *vgic_v3_rdist_region_from_index(struct kvm *kvm,
+                                                          u32 index);
+
+bool vgic_v3_rdist_overlap(struct kvm *kvm, gpa_t base, size_t size);
+
+static inline bool vgic_dist_overlap(struct kvm *kvm, gpa_t base, size_t size)
+{
+       struct vgic_dist *d = &kvm->arch.vgic;
+
+       return (base + size > d->vgic_dist_base) &&
+               (base < d->vgic_dist_base + KVM_VGIC_V3_DIST_SIZE);
+}
+
 int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its,
                         u32 devid, u32 eventid, struct vgic_irq **irq);
 struct vgic_its *vgic_msi_to_its(struct kvm *kvm, struct kvm_msi *msi);
index c7b2e927f69903c4eb8bb571282d7a5b7ca5ca27..ada21f47f22b5a902e81572ba94efb16a2a7bccb 100644 (file)
@@ -203,29 +203,47 @@ static inline bool kvm_kick_many_cpus(const struct cpumask *cpus, bool wait)
        return true;
 }
 
-bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
+bool kvm_make_vcpus_request_mask(struct kvm *kvm, unsigned int req,
+                                unsigned long *vcpu_bitmap, cpumask_var_t tmp)
 {
        int i, cpu, me;
-       cpumask_var_t cpus;
-       bool called;
        struct kvm_vcpu *vcpu;
-
-       zalloc_cpumask_var(&cpus, GFP_ATOMIC);
+       bool called;
 
        me = get_cpu();
+
        kvm_for_each_vcpu(i, vcpu, kvm) {
+               if (!test_bit(i, vcpu_bitmap))
+                       continue;
+
                kvm_make_request(req, vcpu);
                cpu = vcpu->cpu;
 
                if (!(req & KVM_REQUEST_NO_WAKEUP) && kvm_vcpu_wake_up(vcpu))
                        continue;
 
-               if (cpus != NULL && cpu != -1 && cpu != me &&
+               if (tmp != NULL && cpu != -1 && cpu != me &&
                    kvm_request_needs_ipi(vcpu, req))
-                       __cpumask_set_cpu(cpu, cpus);
+                       __cpumask_set_cpu(cpu, tmp);
        }
-       called = kvm_kick_many_cpus(cpus, !!(req & KVM_REQUEST_WAIT));
+
+       called = kvm_kick_many_cpus(tmp, !!(req & KVM_REQUEST_WAIT));
        put_cpu();
+
+       return called;
+}
+
+bool kvm_make_all_cpus_request(struct kvm *kvm, unsigned int req)
+{
+       cpumask_var_t cpus;
+       bool called;
+       static unsigned long vcpu_bitmap[BITS_TO_LONGS(KVM_MAX_VCPUS)]
+               = {[0 ... BITS_TO_LONGS(KVM_MAX_VCPUS)-1] = ULONG_MAX};
+
+       zalloc_cpumask_var(&cpus, GFP_ATOMIC);
+
+       called = kvm_make_vcpus_request_mask(kvm, req, vcpu_bitmap, cpus);
+
        free_cpumask_var(cpus);
        return called;
 }
@@ -572,10 +590,7 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
                return 0;
 
        snprintf(dir_name, sizeof(dir_name), "%d-%d", task_pid_nr(current), fd);
-       kvm->debugfs_dentry = debugfs_create_dir(dir_name,
-                                                kvm_debugfs_dir);
-       if (!kvm->debugfs_dentry)
-               return -ENOMEM;
+       kvm->debugfs_dentry = debugfs_create_dir(dir_name, kvm_debugfs_dir);
 
        kvm->debugfs_stat_data = kcalloc(kvm_debugfs_num_entries,
                                         sizeof(*kvm->debugfs_stat_data),
@@ -591,11 +606,8 @@ static int kvm_create_vm_debugfs(struct kvm *kvm, int fd)
                stat_data->kvm = kvm;
                stat_data->offset = p->offset;
                kvm->debugfs_stat_data[p - debugfs_entries] = stat_data;
-               if (!debugfs_create_file(p->name, 0644,
-                                        kvm->debugfs_dentry,
-                                        stat_data,
-                                        stat_fops_per_vm[p->kind]))
-                       return -ENOMEM;
+               debugfs_create_file(p->name, 0644, kvm->debugfs_dentry,
+                                   stat_data, stat_fops_per_vm[p->kind]);
        }
        return 0;
 }
@@ -2340,7 +2352,7 @@ void kvm_vcpu_on_spin(struct kvm_vcpu *me, bool yield_to_kernel_mode)
 }
 EXPORT_SYMBOL_GPL(kvm_vcpu_on_spin);
 
-static int kvm_vcpu_fault(struct vm_fault *vmf)
+static vm_fault_t kvm_vcpu_fault(struct vm_fault *vmf)
 {
        struct kvm_vcpu *vcpu = vmf->vma->vm_file->private_data;
        struct page *page;
@@ -2550,8 +2562,13 @@ static long kvm_vcpu_ioctl(struct file *filp,
                oldpid = rcu_access_pointer(vcpu->pid);
                if (unlikely(oldpid != current->pids[PIDTYPE_PID].pid)) {
                        /* The thread running this VCPU changed. */
-                       struct pid *newpid = get_task_pid(current, PIDTYPE_PID);
+                       struct pid *newpid;
+
+                       r = kvm_arch_vcpu_run_pid_change(vcpu);
+                       if (r)
+                               break;
 
+                       newpid = get_task_pid(current, PIDTYPE_PID);
                        rcu_assign_pointer(vcpu->pid, newpid);
                        if (oldpid)
                                synchronize_rcu();
@@ -3059,7 +3076,8 @@ static long kvm_vm_ioctl(struct file *filp,
                        goto out;
                if (routing.nr) {
                        r = -ENOMEM;
-                       entries = vmalloc(routing.nr * sizeof(*entries));
+                       entries = vmalloc(array_size(sizeof(*entries),
+                                                    routing.nr));
                        if (!entries)
                                goto out;
                        r = -EFAULT;
@@ -3896,29 +3914,18 @@ static void kvm_uevent_notify_change(unsigned int type, struct kvm *kvm)
        kfree(env);
 }
 
-static int kvm_init_debug(void)
+static void kvm_init_debug(void)
 {
-       int r = -EEXIST;
        struct kvm_stats_debugfs_item *p;
 
        kvm_debugfs_dir = debugfs_create_dir("kvm", NULL);
-       if (kvm_debugfs_dir == NULL)
-               goto out;
 
        kvm_debugfs_num_entries = 0;
        for (p = debugfs_entries; p->name; ++p, kvm_debugfs_num_entries++) {
-               if (!debugfs_create_file(p->name, 0644, kvm_debugfs_dir,
-                                        (void *)(long)p->offset,
-                                        stat_fops[p->kind]))
-                       goto out_dir;
+               debugfs_create_file(p->name, 0644, kvm_debugfs_dir,
+                                   (void *)(long)p->offset,
+                                   stat_fops[p->kind]);
        }
-
-       return 0;
-
-out_dir:
-       debugfs_remove_recursive(kvm_debugfs_dir);
-out:
-       return r;
 }
 
 static int kvm_suspend(void)
@@ -4046,20 +4053,13 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
        kvm_preempt_ops.sched_in = kvm_sched_in;
        kvm_preempt_ops.sched_out = kvm_sched_out;
 
-       r = kvm_init_debug();
-       if (r) {
-               pr_err("kvm: create debugfs files failed\n");
-               goto out_undebugfs;
-       }
+       kvm_init_debug();
 
        r = kvm_vfio_ops_init();
        WARN_ON(r);
 
        return 0;
 
-out_undebugfs:
-       unregister_syscore_ops(&kvm_syscore_ops);
-       misc_deregister(&kvm_dev);
 out_unreg:
        kvm_async_pf_deinit();
 out_free: